design-comuni-plone-theme 11.31.2 → 11.32.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 (36) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/CHANGELOG.md +26 -0
  3. package/RELEASE.md +11 -0
  4. package/locales/de/LC_MESSAGES/volto.po +41 -0
  5. package/locales/en/LC_MESSAGES/volto.po +41 -0
  6. package/locales/es/LC_MESSAGES/volto.po +41 -0
  7. package/locales/fr/LC_MESSAGES/volto.po +41 -0
  8. package/locales/it/LC_MESSAGES/volto.po +41 -0
  9. package/locales/volto.pot +42 -1
  10. package/package.json +1 -1
  11. package/publiccode.yml +2 -2
  12. package/src/actions/getCTSchema.js +13 -0
  13. package/src/actions/index.js +3 -0
  14. package/src/components/ItaliaTheme/Blocks/Listing/Commons/ListingImage.jsx +1 -1
  15. package/src/components/ItaliaTheme/Blocks/Listing/TableTemplate.jsx +163 -0
  16. package/src/components/ItaliaTheme/Blocks/Listing/TemplatesSkeletons/TableTemplateSkeleton.jsx +50 -0
  17. package/src/components/ItaliaTheme/View/Commons/SideMenu.jsx +2 -1
  18. package/src/components/ItaliaTheme/View/Commons/SideMenuByTitles.jsx +16 -8
  19. package/src/components/ItaliaTheme/index.js +5 -0
  20. package/src/components/ItaliaTheme/manage/Widgets/BlocksViewWidget.jsx +7 -0
  21. package/src/components/ItaliaTheme/manage/Widgets/CTFieldsWidget.jsx +84 -0
  22. package/src/components/ItaliaTheme/manage/Widgets/CTTitleColumnWidget.jsx +22 -0
  23. package/src/components/ItaliaTheme/manage/Widgets/DataGridWidget.jsx +26 -0
  24. package/src/components/ItaliaTheme/manage/Widgets/PDCViewWidget.jsx +21 -0
  25. package/src/config/Blocks/ListingOptions/index.js +1 -0
  26. package/src/config/Blocks/ListingOptions/tableTemplate.js +105 -0
  27. package/src/config/Blocks/listingVariations.js +18 -0
  28. package/src/config/Widgets/widgets.js +24 -1
  29. package/src/customizations/volto/helpers/Html/Html.jsx +28 -14
  30. package/src/helpers/getWidgetView.js +112 -0
  31. package/src/helpers/index.js +1 -0
  32. package/src/reducers/ctSchema.js +80 -0
  33. package/src/reducers/index.js +2 -0
  34. package/src/theme/ItaliaTheme/Blocks/_smallblockLinkstemplate.scss +1 -0
  35. package/src/theme/ItaliaTheme/Blocks/_tableTemplate.scss +46 -0
  36. package/src/theme/site.scss +1 -0
@@ -20,11 +20,16 @@ const messages = defineMessages({
20
20
  id: 'index',
21
21
  defaultMessage: 'Indice della pagina',
22
22
  },
23
+ sideMenuNavigation: {
24
+ id: 'sideMenuNavigation',
25
+ defaultMessage: 'Navigazione della pagina',
26
+ },
23
27
  });
24
28
 
25
29
  const extractHeaders = (elements, intl) => {
26
30
  let item;
27
31
  let headers = [];
32
+
28
33
  for (var index = 0; index < elements.length; index++) {
29
34
  item = elements[index];
30
35
 
@@ -140,7 +145,10 @@ const SideMenuByTitles = ({ data, content_uid, index_title }) => {
140
145
 
141
146
  return headers?.length > 0 ? (
142
147
  <div className="sticky-wrapper navbar-wrapper page-side-menu">
143
- <nav className="navbar it-navscroll-wrapper navbar-expand-lg">
148
+ <nav
149
+ className="navbar it-navscroll-wrapper navbar-expand-lg"
150
+ aria-label={intl.formatMessage(messages.sideMenuNavigation)}
151
+ >
144
152
  <div className="menu-wrapper">
145
153
  <div className="link-list-wrapper menu-link-list">
146
154
  <div className="accordion-wrapper">
@@ -151,20 +159,20 @@ const SideMenuByTitles = ({ data, content_uid, index_title }) => {
151
159
  setIsNavOpen(!isNavOpen);
152
160
  }}
153
161
  aria-controls="side-menu-body"
162
+ aria-expanded={isNavOpen}
154
163
  >
155
- <h3>{index_title ?? intl.formatMessage(messages.index)}</h3>
164
+ <h2 className="h3">
165
+ {index_title ?? intl.formatMessage(messages.index)}
166
+ </h2>
156
167
  </AccordionHeader>
157
168
  <div className="mb-3">
158
169
  <Progress
159
170
  value={progressValue > 0 ? 100 * progressValue : 0}
160
- role="progressbar"
171
+ role="progressbar"
172
+ aria-labelledby={`item-${activeSection}`}
161
173
  />
162
174
  </div>
163
- <AccordionBody
164
- active={isNavOpen}
165
- id="side-menu-body"
166
- role="region"
167
- >
175
+ <AccordionBody active={isNavOpen} id="side-menu-body">
168
176
  <ul className="link-list" data-element="page-index">
169
177
  {headers.map((item, i) => {
170
178
  return (
@@ -17,6 +17,11 @@ export FileWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/
17
17
  export PathFiltersWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/PathFiltersWidget';
18
18
  export LocationFiltersWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/LocationFiltersWidget';
19
19
  export CanaleDigitaleWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/CanaleDigitaleWidget';
20
+ export CTFieldsWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/CTFieldsWidget';
21
+ export CTTitleColumnWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/CTTitleColumnWidget';
22
+ export BlocksViewWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/BlocksViewWidget.jsx';
23
+ export PDCViewWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/PDCViewWidget.jsx';
24
+ export DataGridWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/DataGridWidget.jsx';
20
25
 
21
26
  /********* ICONS ********* */
22
27
  export getItemIcon from 'design-comuni-plone-theme/components/ItaliaTheme/Icons/common/common';
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { RichTextRender } from 'design-comuni-plone-theme/components/ItaliaTheme/View';
3
+ const BlocksViewWidget = ({ value, children, className }) => {
4
+ return <RichTextRender data={value} add_class={className} serif={false} />;
5
+ };
6
+
7
+ export default BlocksViewWidget;
@@ -0,0 +1,84 @@
1
+ import React, { useEffect } from 'react';
2
+ import { useIntl } from 'react-intl';
3
+ import { useDispatch, useSelector } from 'react-redux';
4
+ import { getCTSchema } from 'design-comuni-plone-theme/actions';
5
+ import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
6
+ import FormFieldWrapper from '@plone/volto/components/manage/Widgets/FormFieldWrapper';
7
+ import { normalizeValue } from '@plone/volto/components/manage/Widgets/SelectUtils';
8
+
9
+ import {
10
+ Option,
11
+ DropdownIndicator,
12
+ selectTheme,
13
+ customSelectStyles,
14
+ } from '@plone/volto/components/manage/Widgets/SelectStyling';
15
+
16
+ const CTFieldsWidget = ({ ct, reactSelect, value, ...props }) => {
17
+ const intl = useIntl();
18
+ const dispatch = useDispatch();
19
+ const Select = reactSelect.default;
20
+ const exclude_fieldsets = ['ownership', 'seo', 'settings'];
21
+ const ct_schema = useSelector(
22
+ (state) => state.ct_schema?.subrequests?.[ct]?.result,
23
+ );
24
+
25
+ useEffect(() => {
26
+ if (!ct_schema) {
27
+ dispatch(getCTSchema(ct));
28
+ }
29
+ }, [ct, ct_schema, dispatch]);
30
+
31
+ const groups_choices =
32
+ ct_schema?.fieldsets
33
+ ?.filter((fieldset) => exclude_fieldsets.indexOf(fieldset.id) < 0)
34
+ .map((fieldset) => {
35
+ return {
36
+ label: fieldset.title,
37
+ options: fieldset.fields.map((f) => {
38
+ return {
39
+ value: f,
40
+ label: ct_schema.properties[f].title,
41
+ };
42
+ }),
43
+ };
44
+ }) ?? [];
45
+
46
+ const disabled = props.disabled || props.isDisabled;
47
+ const normalizedValue = normalizeValue(
48
+ groups_choices.reduce((acc, fieldset) => {
49
+ return [...acc, ...fieldset.options];
50
+ }, []),
51
+ value,
52
+ intl,
53
+ );
54
+
55
+ return groups_choices?.length > 0 ? (
56
+ <FormFieldWrapper {...props}>
57
+ <Select
58
+ id={`field-${props.id}`}
59
+ name={props.id}
60
+ disabled={disabled}
61
+ className="react-select-container"
62
+ classNamePrefix="react-select"
63
+ placeholder={props.placeholder ?? 'Seleziona un valore'}
64
+ options={groups_choices}
65
+ styles={customSelectStyles}
66
+ theme={selectTheme}
67
+ components={{ DropdownIndicator, Option }}
68
+ value={normalizedValue}
69
+ onChange={(selectedOption) => {
70
+ props.onChange(
71
+ props.id,
72
+ selectedOption && selectedOption.value !== 'no-value'
73
+ ? selectedOption.value
74
+ : undefined,
75
+ );
76
+ }}
77
+ />
78
+ </FormFieldWrapper>
79
+ ) : (
80
+ <></>
81
+ );
82
+ };
83
+
84
+ export default injectLazyLibs('reactSelect')(CTFieldsWidget);
@@ -0,0 +1,22 @@
1
+ import React, { useEffect } from 'react';
2
+ import { useSelector } from 'react-redux';
3
+ import { TextWidget } from '@plone/volto/components';
4
+
5
+ const CTTitleColumnWidget = (props) => {
6
+ const { onChange, id } = props;
7
+ const { ct, field } = props.objectvalue;
8
+ const ct_schema = useSelector(
9
+ (state) => state.ct_schema?.subrequests?.[ct]?.result,
10
+ );
11
+
12
+ useEffect(() => {
13
+ const field_label = ct_schema?.properties?.[field]?.title;
14
+ if (field_label) {
15
+ onChange(id, field_label);
16
+ }
17
+ }, [field]);
18
+
19
+ return <TextWidget {...props} className="text" />;
20
+ };
21
+
22
+ export default CTTitleColumnWidget;
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import cx from 'classnames';
3
+
4
+ const DataGridWidget = ({ value, children, className }) => {
5
+ return value ? (
6
+ <span className={cx(className, 'array', 'widget')}>
7
+ {value.map((item, key) =>
8
+ Object.keys(item).length > 0 ? (
9
+ <div>
10
+ {Object.keys(item).map((el) => (
11
+ <div>
12
+ <span className="fw-bold">{el}</span>: <span>{item[el]}</span>
13
+ </div>
14
+ ))}
15
+ </div>
16
+ ) : (
17
+ <></>
18
+ ),
19
+ )}
20
+ </span>
21
+ ) : (
22
+ ''
23
+ );
24
+ };
25
+
26
+ export default DataGridWidget;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { useIntl } from 'react-intl';
3
+ import { renderPDCItemValue } from 'design-comuni-plone-theme/helpers';
4
+ const PDCViewWidget = ({ value }) => {
5
+ const intl = useIntl();
6
+
7
+ return (
8
+ <div className="d-flex flex-column">
9
+ {value
10
+ ? value.map((pdc) => (
11
+ <div>
12
+ <span className="me-2">{pdc.pdc_desc}</span>
13
+ <span>{renderPDCItemValue(pdc, intl)}</span>
14
+ </div>
15
+ ))
16
+ : null}
17
+ </div>
18
+ );
19
+ };
20
+
21
+ export default PDCViewWidget;
@@ -23,3 +23,4 @@ export { addCardWithSlideUpTextTemplateOptions } from 'design-comuni-plone-theme
23
23
  export { addPhotogalleryTemplateOptions } from 'design-comuni-plone-theme/config/Blocks/ListingOptions/photogalleryTemplate';
24
24
  export { addSmallBlockLinksTemplateOptions } from 'design-comuni-plone-theme/config/Blocks/ListingOptions/smallBlockLinksTemplate';
25
25
  export { addAttachmentCardTemplateOptions } from 'design-comuni-plone-theme/config/Blocks/ListingOptions/attachmentCardTemplate';
26
+ export { addTableTemplateOptions } from 'design-comuni-plone-theme/config/Blocks/ListingOptions/tableTemplate';
@@ -0,0 +1,105 @@
1
+ import { defineMessages } from 'react-intl';
2
+ import cloneDeep from 'lodash/cloneDeep';
3
+
4
+ import { addSchemaField } from 'design-comuni-plone-theme/config/Blocks/ListingOptions';
5
+
6
+ const messages = defineMessages({
7
+ columns: {
8
+ id: 'table_variation_columns',
9
+ defaultMessage: 'Colonne della tabella',
10
+ },
11
+ alternate_rows: {
12
+ id: 'table_variation_alternate_rows',
13
+ defaultMessage: 'Colore delle righe alternato',
14
+ },
15
+ column: {
16
+ id: 'table_variaton_column',
17
+ defaultMessage: 'Colonna',
18
+ },
19
+ ct: { id: 'table_variaton_ct', defaultMessage: 'Tipo di contenuto' },
20
+ field: { id: 'table_variaton_field', defaultMessage: 'Campo' },
21
+ title: {
22
+ id: 'table_variaton_title',
23
+ defaultMessage: 'Titolo',
24
+ },
25
+ title_description: {
26
+ id: 'table_variaton_title_description',
27
+ defaultMessage:
28
+ 'Titolo della colonna. Se vuoi, puoi modificare il titolo di default.',
29
+ },
30
+ //sortable: { id: 'table_variaton_sortable', defaultMessage: 'Ordinabile' },
31
+ });
32
+
33
+ const ColumnSchema = ({ intl }) => ({
34
+ title: intl.formatMessage(messages.column),
35
+ fieldsets: [
36
+ {
37
+ id: 'default',
38
+ title: 'Default',
39
+ fields: ['ct' /*'field', 'title', 'sortable'*/], //questi campi commentati vengono aggiunti solo quando è valorizzato il campo ct
40
+ },
41
+ ],
42
+ properties: {
43
+ ct: {
44
+ title: intl.formatMessage(messages.ct),
45
+ vocabulary: {
46
+ '@id': 'plone.app.vocabularies.ReallyUserFriendlyTypes',
47
+ },
48
+ },
49
+ field: {
50
+ title: intl.formatMessage(messages.field),
51
+ widget: 'ct_fields',
52
+ },
53
+ title: {
54
+ title: intl.formatMessage(messages.title),
55
+ description: intl.formatMessage(messages.title_description),
56
+ widget: 'ct_title_column',
57
+ },
58
+ // sortable: {
59
+ // title: intl.formatMessage(messages.sortable),
60
+ // type: 'boolean',
61
+ // },
62
+ },
63
+ });
64
+
65
+ export const addTableTemplateOptions = (
66
+ schema,
67
+ formData,
68
+ intl,
69
+ position = 1,
70
+ ) => {
71
+ let pos = position;
72
+
73
+ addSchemaField(
74
+ schema,
75
+ 'alternate_rows',
76
+ intl.formatMessage(messages.alternate_rows),
77
+ null,
78
+ { type: 'boolean', default: true },
79
+ pos,
80
+ );
81
+ pos++;
82
+
83
+ addSchemaField(
84
+ schema,
85
+ 'columns',
86
+ intl.formatMessage(messages.columns),
87
+ null,
88
+ {
89
+ widget: 'object_list',
90
+ schema: ColumnSchema({ intl }),
91
+ schemaExtender: (schema, data, intl) => {
92
+ const mutated = cloneDeep(schema);
93
+ if (data.ct) {
94
+ mutated.fieldsets[0].fields.push('field', 'title' /*, 'sortable'*/);
95
+ mutated.properties.field.ct = data.ct;
96
+ }
97
+ return mutated;
98
+ },
99
+ },
100
+ pos,
101
+ );
102
+ pos++;
103
+
104
+ return pos;
105
+ };
@@ -47,6 +47,8 @@ import CardWithSlideUpTextTemplateSkeleton from 'design-comuni-plone-theme/compo
47
47
 
48
48
  import AttachmentCardTemplate from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/Listing/AttachmentCardTemplate';
49
49
 
50
+ import TableTemplate from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/Listing/TableTemplate.jsx';
51
+ import TableTemplateSkeleton from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/Listing/TemplatesSkeletons/TableTemplateSkeleton';
50
52
  // import AmministrazioneTrasparenteTablesTemplate from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/Listing/AmministrazioneTrasparenteTablesTemplate';
51
53
  // import AmministrazioneTrasparenteTablesTemplateSkeleton from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/Listing/TemplatesSkeletons/AmministrazioneTrasparenteTablesTemplateSkeleton';
52
54
 
@@ -67,6 +69,7 @@ import {
67
69
  addSmallBlockLinksTemplateOptions,
68
70
  addAttachmentCardTemplateOptions,
69
71
  cloneBlock,
72
+ addTableTemplateOptions,
70
73
  } from 'design-comuni-plone-theme/config/Blocks/ListingOptions';
71
74
 
72
75
  import { addLighthouseField } from 'design-comuni-plone-theme/config/Blocks/ListingOptions/utils';
@@ -293,6 +296,21 @@ const italiaListingVariations = [
293
296
  },
294
297
  cloneData: cloneBlock,
295
298
  },
299
+ {
300
+ id: 'table',
301
+ isDefault: false,
302
+ title: 'Tabella',
303
+ template: TableTemplate,
304
+ skeleton: TableTemplateSkeleton,
305
+ schemaEnhancer: ({ schema, formData, intl }) => {
306
+ let pos = addDefaultOptions(schema, formData, intl);
307
+ addTableTemplateOptions(schema, formData, intl, pos);
308
+ addLinkMoreOptions(schema, formData, intl);
309
+ return schema;
310
+ },
311
+ fullobjects: true,
312
+ cloneData: cloneBlock,
313
+ },
296
314
  // {
297
315
  // id: 'amministrazioneTrasparenteTablesTemplate',
298
316
  // isDefault: false,
@@ -10,12 +10,20 @@ import MenuConfigurationForm from 'design-comuni-plone-theme/components/ItaliaTh
10
10
  import SecondaryMenuConfigurationForm from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/SecondaryMenuConfigurationForm';
11
11
  import SubFooterConfigurationForm from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/SubFooterConfigurationForm';
12
12
  import SearchSectionsConfigurationWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/SearchSectionsConfigurationWidget/SearchSectionsConfigurationWidget';
13
- import { defaultIconWidgetOptions } from 'design-comuni-plone-theme/helpers';
13
+ import {
14
+ defaultIconWidgetOptions,
15
+ getWidgetView,
16
+ } from 'design-comuni-plone-theme/helpers';
14
17
  import {
15
18
  ColorListWidget,
16
19
  PathFiltersWidget,
17
20
  LocationFiltersWidget,
18
21
  CanaleDigitaleWidget,
22
+ CTFieldsWidget,
23
+ CTTitleColumnWidget,
24
+ BlocksViewWidget,
25
+ PDCViewWidget,
26
+ DataGridWidget,
19
27
  } from 'design-comuni-plone-theme/components/ItaliaTheme';
20
28
  import LuoghiCorrelatiEventoWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/LuoghiCorrelatiEventoWidget';
21
29
 
@@ -88,6 +96,21 @@ const getItaliaWidgets = (config) => {
88
96
  path_filters: PathFiltersWidget,
89
97
  location_filter: LocationFiltersWidget,
90
98
  luoghi_correlati_evento: LuoghiCorrelatiEventoWidget,
99
+ ct_fields: CTFieldsWidget,
100
+ ct_title_column: CTTitleColumnWidget,
101
+ },
102
+ views: {
103
+ ...config.widgets.views,
104
+ getWidget: getWidgetView,
105
+ widget: {
106
+ ...config.widgets.views.widget,
107
+ blocks: BlocksViewWidget,
108
+ data_grid: DataGridWidget,
109
+ },
110
+ id: {
111
+ ...config.widgets.views.id,
112
+ value_punto_contatto: PDCViewWidget,
113
+ },
91
114
  },
92
115
  };
93
116
  };
@@ -2,13 +2,17 @@
2
2
  * Html helper.
3
3
  * @module helpers/Html
4
4
  */
5
+
5
6
  /*
6
- CUSTOMIZATIONS:
7
- - Rimosso <link rel="shortcut icon" href="/favicon.ico" /> perchè creato da volto-site-settings
8
- - Add shrink-to-fit=no in viewport meta
9
- - Remove link for manifest and svg/apple icons
7
+ * original: https://raw.githubusercontent.com/plone/volto/refs/tags/17.20.4/src/helpers/Html/Html.jsx
8
+ *
9
+ * CUSTOMIZATIONS:
10
+ * - Rimossi <link per rle favicon perchè creato da volto-site-settings
11
+ * - Add shrink-to-fit=no in viewport meta
12
+ * - Remove link for manifest and svg/apple icons
13
+ * - Aggiunto og:type website
10
14
  */
11
-
15
+
12
16
  import React, { Component } from 'react';
13
17
  import PropTypes from 'prop-types';
14
18
  import Helmet from '@plone/volto/helpers/Helmet/Helmet';
@@ -97,8 +101,10 @@ class Html extends Component {
97
101
  this.props;
98
102
  const head = Helmet.rewind();
99
103
  const bodyClass = join(BodyClass.rewind(), ' ');
104
+ const htmlAttributes = head.htmlAttributes.toComponent();
105
+
100
106
  return (
101
- <html lang="en">
107
+ <html lang={htmlAttributes.lang}>
102
108
  <head>
103
109
  <meta charSet="utf-8" />
104
110
  {head.base.toComponent()}
@@ -122,13 +128,21 @@ class Html extends Component {
122
128
  })};`,
123
129
  }}
124
130
  />
125
- {/* <link rel="shortcut icon" href="/favicon.ico" /> */}
131
+
132
+ {/*
133
+ * <link rel="icon" href="/favicon.ico" sizes="any" />
134
+ * <link rel="icon" href="/icon.svg" type="image/svg+xml" />
135
+ * <link
136
+ * rel="apple-touch-icon"
137
+ * sizes="180x180"
138
+ * href="/apple-touch-icon.png"
139
+ * />
140
+ * <link rel="manifest" href="/site.webmanifest" />
141
+ */}
142
+
126
143
  <meta property="og:type" content="website" />
127
144
  <meta name="generator" content="Plone 6 - https://plone.org" />
128
- <meta
129
- name="viewport"
130
- content="width=device-width, initial-scale=1, shrink-to-fit=no"
131
- />
145
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
132
146
  <meta name="apple-mobile-web-app-capable" content="yes" />
133
147
  {process.env.NODE_ENV === 'production' && criticalCss && (
134
148
  <style
@@ -143,8 +157,8 @@ class Html extends Component {
143
157
  rel: !criticalCss
144
158
  ? elem.props.rel
145
159
  : elem.props.as === 'style'
146
- ? 'prefetch'
147
- : elem.props.rel,
160
+ ? 'prefetch'
161
+ : elem.props.rel,
148
162
  }),
149
163
  )}
150
164
  {/* Styles in development are loaded with Webpack's style-loader, in production,
@@ -177,7 +191,7 @@ class Html extends Component {
177
191
  <body className={bodyClass}>
178
192
  <div role="navigation" aria-label="Toolbar" id="toolbar" />
179
193
  <div id="main" dangerouslySetInnerHTML={{ __html: markup }} />
180
- <div id="sidebar" />
194
+ <div role="complementary" aria-label="Sidebar" id="sidebar" />
181
195
  <script
182
196
  dangerouslySetInnerHTML={{
183
197
  __html: `window.__data=${serialize(
@@ -0,0 +1,112 @@
1
+ import config from '@plone/volto/registry';
2
+
3
+ /**
4
+ * Get widget by field's `id` attribute
5
+ * @method getWidgetByFieldId
6
+ * @param {string} id Id
7
+ * @returns {string} Widget component.
8
+ */
9
+ const getWidgetByFieldId = (id) => config.widgets.views.id[id] || null;
10
+
11
+ /**
12
+ * Get widget by field's `front end options` attribute
13
+ * @method getWidgetFromTaggedValues
14
+ * @param {object} widgetOptions widgetOptions
15
+ * @returns {string} Widget component.
16
+ */
17
+ const getWidgetFromTaggedValues = (widgetOptions) =>
18
+ typeof widgetOptions?.frontendOptions?.widget === 'string'
19
+ ? config.widgets.views.widget[widgetOptions.frontendOptions.widget]
20
+ : null;
21
+
22
+ /**
23
+ * Get widget by field's `widget` attribute
24
+ * @method getWidgetByName
25
+ * @param {string} widget Widget
26
+ * @returns {string} Widget component.
27
+ */
28
+ const getWidgetByName = (widget) =>
29
+ typeof widget === 'string' ? config.widgets.views.widget[widget] : null;
30
+ /**
31
+ * Get widget by field's `vocabulary` attribute
32
+ * @method getWidgetByVocabulary
33
+ * @param {string} vocabulary Widget
34
+ * @returns {string} Widget component.
35
+ */
36
+ const getWidgetByVocabulary = (vocabulary) =>
37
+ vocabulary && vocabulary['@id']
38
+ ? config.widgets.views.vocabulary[
39
+ vocabulary['@id'].replace(
40
+ `${config.settings.apiPath}/@vocabularies/`,
41
+ '',
42
+ )
43
+ ]
44
+ : null;
45
+
46
+ /**
47
+ * Get widget by field's hints `vocabulary` attribute in widgetOptions
48
+ * @method getWidgetByVocabularyFromHint
49
+ * @param {string} props Widget props
50
+ * @returns {string} Widget component.
51
+ */
52
+ const getWidgetByVocabularyFromHint = (props) =>
53
+ props.widgetOptions && props.widgetOptions.vocabulary
54
+ ? config.widgets.views.vocabulary[
55
+ props.widgetOptions.vocabulary['@id'].replace(
56
+ `${config.settings.apiPath}/@vocabularies/`,
57
+ '',
58
+ )
59
+ ]
60
+ : null;
61
+
62
+ /**
63
+ * Get widget by field's `choices` attribute
64
+ * @method getWidgetByChoices
65
+ * @param {string} choices Widget
66
+ * @returns {string} Widget component.
67
+ */
68
+ const getWidgetByChoices = (props) => {
69
+ if (props.choices) {
70
+ return config.widgets.views.choices;
71
+ }
72
+
73
+ if (props.vocabulary) {
74
+ // If vocabulary exists, then it means it's a choice field in disguise with
75
+ // no widget specified that probably contains a string then we force it
76
+ // to be a select widget instead
77
+ return config.widgets.views.choices;
78
+ }
79
+
80
+ return null;
81
+ };
82
+
83
+ /**
84
+ * Get widget by field's `type` attribute
85
+ * @method getWidgetByType
86
+ * @param {string} type Type
87
+ * @returns {string} Widget component.
88
+ */
89
+ const getWidgetByType = (type) => config.widgets.views.type[type] || null;
90
+
91
+ /**
92
+ * Get default widget
93
+ * @method getWidgetDefault
94
+ * @returns {string} Widget component.
95
+ */
96
+ const getWidgetDefault = () => config.widgets.views.default;
97
+
98
+ /**
99
+ * Get Widget View
100
+ * @method getWidgetView
101
+ * @param {dict} props Props
102
+ * @returns {string} Widget component.
103
+ */
104
+ export const getWidgetView = (props) =>
105
+ getWidgetByFieldId(props.id) ||
106
+ getWidgetFromTaggedValues(props.widgetOptions) ||
107
+ getWidgetByName(props.widget) ||
108
+ getWidgetByChoices(props) ||
109
+ getWidgetByVocabulary(props.vocabulary) ||
110
+ getWidgetByVocabularyFromHint(props) ||
111
+ getWidgetByType(props.type) ||
112
+ getWidgetDefault();
@@ -63,3 +63,4 @@ export {
63
63
  useFallbackImageSrc,
64
64
  contentHasImage,
65
65
  } from 'design-comuni-plone-theme/helpers/images';
66
+ export { getWidgetView } from 'design-comuni-plone-theme/helpers/getWidgetView';