@plone/volto 18.0.0-alpha.32 → 18.0.0-alpha.33

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 (61) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/locales/ca/LC_MESSAGES/volto.po +12 -0
  3. package/locales/ca.json +1 -1
  4. package/locales/de/LC_MESSAGES/volto.po +12 -0
  5. package/locales/de.json +1 -1
  6. package/locales/en/LC_MESSAGES/volto.po +12 -0
  7. package/locales/en.json +1 -1
  8. package/locales/es/LC_MESSAGES/volto.po +12 -0
  9. package/locales/es.json +1 -1
  10. package/locales/eu/LC_MESSAGES/volto.po +12 -0
  11. package/locales/eu.json +1 -1
  12. package/locales/fi/LC_MESSAGES/volto.po +12 -0
  13. package/locales/fi.json +1 -1
  14. package/locales/fr/LC_MESSAGES/volto.po +12 -0
  15. package/locales/fr.json +1 -1
  16. package/locales/hi/LC_MESSAGES/volto.po +12 -0
  17. package/locales/hi.json +1 -1
  18. package/locales/it/LC_MESSAGES/volto.po +12 -0
  19. package/locales/it.json +1 -1
  20. package/locales/ja/LC_MESSAGES/volto.po +12 -0
  21. package/locales/ja.json +1 -1
  22. package/locales/nl/LC_MESSAGES/volto.po +12 -0
  23. package/locales/nl.json +1 -1
  24. package/locales/pt/LC_MESSAGES/volto.po +12 -0
  25. package/locales/pt.json +1 -1
  26. package/locales/pt_BR/LC_MESSAGES/volto.po +12 -0
  27. package/locales/pt_BR.json +1 -1
  28. package/locales/ro/LC_MESSAGES/volto.po +12 -0
  29. package/locales/ro.json +1 -1
  30. package/locales/volto.pot +13 -1
  31. package/locales/zh_CN/LC_MESSAGES/volto.po +12 -0
  32. package/locales/zh_CN.json +1 -1
  33. package/package.json +6 -4
  34. package/razzle.config.js +49 -0
  35. package/src/components/manage/BlockChooser/BlockChooserSearch.jsx +1 -0
  36. package/src/components/manage/Sidebar/ObjectBrowserBody.jsx +158 -65
  37. package/src/components/manage/Sidebar/ObjectBrowserNav.jsx +125 -71
  38. package/src/components/manage/Widgets/IdWidget.jsx +138 -203
  39. package/src/components/manage/Widgets/TextWidget.jsx +92 -124
  40. package/src/components/manage/Widgets/TextWidget.stories.jsx +14 -3
  41. package/src/components/theme/App/App.jsx +5 -0
  42. package/src/components/theme/Footer/Footer.jsx +1 -0
  43. package/src/components/theme/Navigation/Navigation.jsx +1 -1
  44. package/src/components/theme/SlotRenderer/SlotRenderer.tsx +3 -4
  45. package/src/components/theme/View/View.jsx +1 -1
  46. package/src/config/server.js +0 -1
  47. package/src/express-middleware/static.js +37 -19
  48. package/src/helpers/Html/Html.jsx +6 -8
  49. package/src/helpers/Slots/index.tsx +12 -5
  50. package/src/server.jsx +34 -36
  51. package/theme/themes/pastanaga/extras/objectbrowser-widget.less +83 -0
  52. package/theme/themes/pastanaga/extras/widgets.less +19 -0
  53. package/types/components/manage/Sidebar/ObjectBrowserNav.d.ts +2 -1
  54. package/types/components/manage/Widgets/IdWidget.d.ts +54 -2
  55. package/types/components/manage/Widgets/TextWidget.d.ts +54 -5
  56. package/types/components/manage/Widgets/TextWidget.stories.d.ts +13 -1
  57. package/types/components/manage/Widgets/index.d.ts +2 -2
  58. package/types/config/Widgets.d.ts +1 -1
  59. package/types/config/server.d.ts +0 -3
  60. package/types/helpers/Slots/index.d.ts +5 -3
  61. package/types/start-client.d.ts +1 -1
@@ -237,7 +237,7 @@ class View extends Component {
237
237
  this.getViewByLayout() || this.getViewByType() || this.getViewDefault();
238
238
 
239
239
  return (
240
- <div id="view">
240
+ <div id="view" tabIndex="-1">
241
241
  <ContentMetadataTags content={this.props.content} />
242
242
  {/* Body class if displayName in component is set */}
243
243
  <BodyClass
@@ -18,7 +18,6 @@ const settings = {
18
18
  ],
19
19
  criticalCssPath: 'public/critical.css',
20
20
  readCriticalCss: null, // so it will be defaultReadCriticalCss
21
- extractScripts: { errorPages: false },
22
21
  staticFiles: [
23
22
  {
24
23
  id: 'root_static',
@@ -1,28 +1,46 @@
1
1
  import express from 'express';
2
2
  import path from 'path';
3
+ import AddonConfigurationRegistry from '@plone/registry/src/addon-registry';
3
4
  import config from '@plone/volto/registry';
4
5
 
5
- const staticMiddlewareFn = express.static(
6
- process.env.BUILD_DIR
7
- ? path.join(process.env.BUILD_DIR, 'public')
8
- : process.env.RAZZLE_PUBLIC_DIR,
9
- {
10
- setHeaders: function (res, path) {
11
- const pathLib = require('path');
12
- const base = pathLib.resolve(process.env.RAZZLE_PUBLIC_DIR);
13
- const relpath = path.substr(base.length);
14
- config.settings.serverConfig.staticFiles.some((elem) => {
15
- if (relpath.match(elem.match)) {
16
- for (const name in elem.headers) {
17
- res.setHeader(name, elem.headers[name] || 'undefined');
18
- }
19
- return true;
6
+ const projectRootPath = path.resolve('.');
7
+ const registry = new AddonConfigurationRegistry(projectRootPath);
8
+
9
+ const staticDirectory = () => {
10
+ if (process.env.BUILD_DIR) {
11
+ return path.join(process.env.BUILD_DIR, 'public');
12
+ }
13
+ // Only for development, when Volto detects that it's working on itself (not an
14
+ // old fashioned Volto project), there are add-ons (so it's the new setup) then
15
+ // point to the public folder in the root of the setup, instead of the inner Volto
16
+ // public folder.
17
+ if (
18
+ process.env.NODE_ENV !== 'production' &&
19
+ !registry.isVoltoProject &&
20
+ registry.addonNames.length > 0
21
+ ) {
22
+ return path.join(projectRootPath, '../../../public');
23
+ }
24
+ // Is always set (Razzle does it)
25
+ return process.env.RAZZLE_PUBLIC_DIR;
26
+ };
27
+
28
+ const staticMiddlewareFn = express.static(staticDirectory(), {
29
+ setHeaders: function (res, path) {
30
+ const pathLib = require('path');
31
+ const base = pathLib.resolve(process.env.RAZZLE_PUBLIC_DIR);
32
+ const relpath = path.substr(base.length);
33
+ config.settings.serverConfig.staticFiles.some((elem) => {
34
+ if (relpath.match(elem.match)) {
35
+ for (const name in elem.headers) {
36
+ res.setHeader(name, elem.headers[name] || 'undefined');
20
37
  }
21
- return false;
22
- });
23
- },
38
+ return true;
39
+ }
40
+ return false;
41
+ });
24
42
  },
25
- );
43
+ });
26
44
 
27
45
  export default function staticsMiddleware() {
28
46
  const middleware = express.Router();
@@ -187,14 +187,12 @@ class Html extends Component {
187
187
  charSet="UTF-8"
188
188
  />
189
189
  {/* Add the crossorigin while in development */}
190
- {this.props.extractScripts !== false
191
- ? extractor.getScriptElements().map((elem) =>
192
- React.cloneElement(elem, {
193
- crossOrigin:
194
- process.env.NODE_ENV === 'production' ? undefined : 'true',
195
- }),
196
- )
197
- : ''}
190
+ {extractor.getScriptElements().map((elem) =>
191
+ React.cloneElement(elem, {
192
+ crossOrigin:
193
+ process.env.NODE_ENV === 'production' ? undefined : 'true',
194
+ }),
195
+ )}
198
196
  </body>
199
197
  </html>
200
198
  );
@@ -1,12 +1,19 @@
1
- import type { Content } from '@plone/types';
2
1
  import { matchPath } from 'react-router-dom';
2
+ import type { Content } from '@plone/types';
3
+ import type { Location } from 'history';
3
4
 
4
5
  export function RouteCondition(path: string, exact?: boolean) {
5
- return ({ pathname }: { pathname: string }) =>
6
- Boolean(matchPath(pathname, { path, exact }));
6
+ return ({ location }: { location: Location }) =>
7
+ Boolean(matchPath(location.pathname, { path, exact }));
7
8
  }
8
9
 
9
10
  export function ContentTypeCondition(contentType: string[]) {
10
- return ({ content }: { content: Content }) =>
11
- contentType.includes(content?.['@type']);
11
+ return ({ content, location }: { content: Content; location: Location }) => {
12
+ return (
13
+ contentType.includes(content?.['@type']) ||
14
+ contentType.some((type) => {
15
+ return location.search.includes(`type=${encodeURIComponent(type)}`);
16
+ })
17
+ );
18
+ };
12
19
  }
package/src/server.jsx CHANGED
@@ -272,50 +272,48 @@ server.get('/*', (req, res) => {
272
272
  });
273
273
  }
274
274
 
275
+ const sendHtmlResponse = (
276
+ res,
277
+ statusCode,
278
+ extractor,
279
+ markup,
280
+ store,
281
+ req,
282
+ config,
283
+ ) => {
284
+ res.status(statusCode).send(
285
+ `<!doctype html>
286
+ ${renderToString(
287
+ <Html
288
+ extractor={extractor}
289
+ markup={markup}
290
+ store={store}
291
+ criticalCss={readCriticalCss(req)}
292
+ apiPath={res.locals.detectedHost || config.settings.apiPath}
293
+ publicURL={res.locals.detectedHost || config.settings.publicURL}
294
+ />,
295
+ )}
296
+ `,
297
+ );
298
+ };
299
+
275
300
  if (context.url) {
276
301
  res.redirect(flattenToAppURL(context.url));
277
302
  } else if (context.error_code) {
278
303
  res.set({
279
304
  'Cache-Control': 'no-cache',
280
305
  });
281
-
282
- res.status(context.error_code).send(
283
- `<!doctype html>
284
- ${renderToString(
285
- <Html
286
- extractor={extractor}
287
- markup={markup}
288
- store={store}
289
- extractScripts={
290
- config.settings.serverConfig.extractScripts?.errorPages ||
291
- process.env.NODE_ENV !== 'production'
292
- }
293
- criticalCss={readCriticalCss(req)}
294
- apiPath={res.locals.detectedHost || config.settings.apiPath}
295
- publicURL={
296
- res.locals.detectedHost || config.settings.publicURL
297
- }
298
- />,
299
- )}
300
- `,
306
+ sendHtmlResponse(
307
+ res,
308
+ context.error_code,
309
+ extractor,
310
+ markup,
311
+ store,
312
+ req,
313
+ config,
301
314
  );
302
315
  } else {
303
- res.status(200).send(
304
- `<!doctype html>
305
- ${renderToString(
306
- <Html
307
- extractor={extractor}
308
- markup={markup}
309
- store={store}
310
- criticalCss={readCriticalCss(req)}
311
- apiPath={res.locals.detectedHost || config.settings.apiPath}
312
- publicURL={
313
- res.locals.detectedHost || config.settings.publicURL
314
- }
315
- />,
316
- )}
317
- `,
318
- );
316
+ sendHtmlResponse(res, 200, extractor, markup, store, req, config);
319
317
  }
320
318
  }, errorHandler)
321
319
  .catch(errorHandler);
@@ -41,3 +41,86 @@
41
41
  border: none !important;
42
42
  }
43
43
  }
44
+
45
+ .object-browser {
46
+ .mode-switch {
47
+ margin-right: 8px;
48
+ cursor: pointer;
49
+ float: right;
50
+ }
51
+
52
+ header h2 {
53
+ margin: 2px 0 !important;
54
+ }
55
+
56
+ .searchResults {
57
+ margin-left: 20px;
58
+ font-size: 14px;
59
+ -webkit-font-smoothing: antialiased;
60
+ -moz-osx-font-smoothing: grayscale;
61
+ line-height: 1.5;
62
+ text-rendering: optimizeLegibility;
63
+ text-size-adjust: 100%;
64
+ }
65
+
66
+ ul.object-listing {
67
+ padding: 0;
68
+ }
69
+
70
+ .image-wrapper {
71
+ display: block;
72
+ margin: 16px;
73
+ float: left;
74
+
75
+ img,
76
+ .icon-wrapper {
77
+ background-color: #edf1f2;
78
+ cursor: pointer;
79
+ outline: 0;
80
+ }
81
+
82
+ .selected {
83
+ outline: solid 3px #517776 !important;
84
+ }
85
+
86
+ img:hover,
87
+ .icon-wrapper:hover {
88
+ outline: solid 3px rgb(187, 198, 200);
89
+ }
90
+
91
+ .image-preview,
92
+ .image-preview:hover {
93
+ display: flex;
94
+ border: 0;
95
+ border-radius: 0;
96
+ box-shadow: none;
97
+
98
+ img {
99
+ width: 200px;
100
+ height: 200px;
101
+ object-fit: contain;
102
+ }
103
+ }
104
+
105
+ .image-preview,
106
+ .image-title {
107
+ cursor: pointer;
108
+ text-align: center;
109
+ }
110
+
111
+ .image-title {
112
+ margin-top: 5px;
113
+ }
114
+
115
+ .image-title-content {
116
+ overflow: hidden;
117
+ text-overflow: ellipsis;
118
+ white-space: nowrap;
119
+ }
120
+
121
+ .icon-wrapper {
122
+ display: flex;
123
+ padding: 46px;
124
+ }
125
+ }
126
+ }
@@ -153,3 +153,22 @@ body.babel-view .field.language-independent-field {
153
153
  .react-select__option {
154
154
  .word-break();
155
155
  }
156
+
157
+ // makes sure event recurrence form buttons don't overflow when font is big
158
+ .recurrence-form {
159
+ .byday-field {
160
+ .button {
161
+ flex-grow: 1;
162
+ padding-right: 0px;
163
+ padding-left: 0px;
164
+ }
165
+ }
166
+
167
+ .byyear-field {
168
+ .byyear-byday {
169
+ display: flex;
170
+ flex-wrap: wrap;
171
+ align-items: center;
172
+ }
173
+ }
174
+ }
@@ -1,10 +1,11 @@
1
1
  export default ObjectBrowserNav;
2
- declare function ObjectBrowserNav({ currentSearchResults, selected, handleClickOnItem, handleDoubleClickOnItem, mode, navigateTo, isSelectable, }: {
2
+ declare function ObjectBrowserNav({ currentSearchResults, selected, handleClickOnItem, handleDoubleClickOnItem, mode, view, navigateTo, isSelectable, }: {
3
3
  currentSearchResults: any;
4
4
  selected: any;
5
5
  handleClickOnItem: any;
6
6
  handleDoubleClickOnItem: any;
7
7
  mode: any;
8
+ view: any;
8
9
  navigateTo: any;
9
10
  isSelectable: any;
10
11
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,54 @@
1
- declare const _default: any;
2
- export default _default;
1
+ export default IdWidget;
2
+ declare function IdWidget(props: any): import("react/jsx-runtime").JSX.Element;
3
+ declare namespace IdWidget {
4
+ namespace propTypes {
5
+ let id: any;
6
+ let title: any;
7
+ let description: any;
8
+ let required: any;
9
+ let error: any;
10
+ let value: any;
11
+ let focus: any;
12
+ let onChange: any;
13
+ let onBlur: any;
14
+ let onClick: any;
15
+ let onEdit: any;
16
+ let onDelete: any;
17
+ let icon: any;
18
+ let iconAction: any;
19
+ let minLength: any;
20
+ let maxLength: any;
21
+ let wrapped: any;
22
+ let placeholder: any;
23
+ }
24
+ namespace defaultProps {
25
+ let description_1: any;
26
+ export { description_1 as description };
27
+ let required_1: boolean;
28
+ export { required_1 as required };
29
+ let error_1: any[];
30
+ export { error_1 as error };
31
+ let value_1: any;
32
+ export { value_1 as value };
33
+ export function onChange_1(): void;
34
+ export { onChange_1 as onChange };
35
+ export function onBlur_1(): void;
36
+ export { onBlur_1 as onBlur };
37
+ export function onClick_1(): void;
38
+ export { onClick_1 as onClick };
39
+ let onEdit_1: any;
40
+ export { onEdit_1 as onEdit };
41
+ let onDelete_1: any;
42
+ export { onDelete_1 as onDelete };
43
+ let focus_1: boolean;
44
+ export { focus_1 as focus };
45
+ let icon_1: any;
46
+ export { icon_1 as icon };
47
+ let iconAction_1: any;
48
+ export { iconAction_1 as iconAction };
49
+ let minLength_1: any;
50
+ export { minLength_1 as minLength };
51
+ let maxLength_1: any;
52
+ export { maxLength_1 as maxLength };
53
+ }
54
+ }
@@ -1,5 +1,54 @@
1
- declare const _default: React.FC<import("react-intl").WithIntlProps<any>> & {
2
- WrappedComponent: React.ComponentType<any>;
3
- };
4
- export default _default;
5
- import React from 'react';
1
+ export default TextWidget;
2
+ declare function TextWidget(props: any): import("react/jsx-runtime").JSX.Element;
3
+ declare namespace TextWidget {
4
+ namespace propTypes {
5
+ let id: any;
6
+ let title: any;
7
+ let description: any;
8
+ let required: any;
9
+ let error: any;
10
+ let value: any;
11
+ let focus: any;
12
+ let onChange: any;
13
+ let onBlur: any;
14
+ let onClick: any;
15
+ let onEdit: any;
16
+ let onDelete: any;
17
+ let icon: any;
18
+ let iconAction: any;
19
+ let minLength: any;
20
+ let maxLength: any;
21
+ let wrapped: any;
22
+ let placeholder: any;
23
+ }
24
+ namespace defaultProps {
25
+ let description_1: any;
26
+ export { description_1 as description };
27
+ let required_1: boolean;
28
+ export { required_1 as required };
29
+ let error_1: any[];
30
+ export { error_1 as error };
31
+ let value_1: any;
32
+ export { value_1 as value };
33
+ export function onChange_1(): void;
34
+ export { onChange_1 as onChange };
35
+ export function onBlur_1(): void;
36
+ export { onBlur_1 as onBlur };
37
+ export function onClick_1(): void;
38
+ export { onClick_1 as onClick };
39
+ let onEdit_1: any;
40
+ export { onEdit_1 as onEdit };
41
+ let onDelete_1: any;
42
+ export { onDelete_1 as onDelete };
43
+ let focus_1: boolean;
44
+ export { focus_1 as focus };
45
+ let icon_1: any;
46
+ export { icon_1 as icon };
47
+ let iconAction_1: any;
48
+ export { iconAction_1 as iconAction };
49
+ let minLength_1: any;
50
+ export { minLength_1 as minLength };
51
+ let maxLength_1: any;
52
+ export { maxLength_1 as maxLength };
53
+ }
54
+ }
@@ -3,7 +3,19 @@ declare namespace _default {
3
3
  export let title: string;
4
4
  export { TextWidget as component };
5
5
  export let decorators: ((Story: any) => import("react/jsx-runtime").JSX.Element)[];
6
- export let argTypes: {};
6
+ export namespace argTypes {
7
+ namespace description {
8
+ export let control: string;
9
+ let description_1: string;
10
+ export { description_1 as description };
11
+ }
12
+ namespace placeholder {
13
+ let control_1: string;
14
+ export { control_1 as control };
15
+ let description_2: string;
16
+ export { description_2 as description };
17
+ }
18
+ }
7
19
  }
8
20
  export default _default;
9
21
  import TextWidget from './TextWidget';
@@ -4,7 +4,7 @@ export declare const ButtonsWidget: import("@loadable/component").LoadableCompon
4
4
  export declare const ArrayWidget: import("@loadable/component").LoadableClassComponent<any>;
5
5
  export declare const CheckboxWidget: import("@loadable/component").LoadableComponent<import("react-intl").WithIntlProps<any>>;
6
6
  export declare const FileWidget: import("@loadable/component").LoadableComponent<import("react-intl").WithIntlProps<any>>;
7
- export declare const IdWidget: import("@loadable/component").LoadableClassComponent<any>;
7
+ export declare const IdWidget: import("@loadable/component").LoadableComponent<any>;
8
8
  export declare const PasswordWidget: import("@loadable/component").LoadableComponent<import("react-intl").WithIntlProps<any>>;
9
9
  export declare const QueryWidget: import("@loadable/component").LoadableClassComponent<any>;
10
10
  export declare const QuerySortOnWidget: import("@loadable/component").LoadableClassComponent<any>;
@@ -12,7 +12,7 @@ export declare const QuerystringWidget: import("@loadable/component").LoadableCo
12
12
  export declare const SchemaWidget: import("@loadable/component").LoadableClassComponent<any>;
13
13
  export declare const SelectWidget: import("@loadable/component").LoadableClassComponent<any>;
14
14
  export declare const TextareaWidget: import("@loadable/component").LoadableComponent<import("react-intl").WithIntlProps<any>>;
15
- export declare const TextWidget: import("@loadable/component").LoadableComponent<import("react-intl").WithIntlProps<any>>;
15
+ export declare const TextWidget: import("@loadable/component").LoadableComponent<any>;
16
16
  export declare const TokenWidget: import("@loadable/component").LoadableClassComponent<any>;
17
17
  export declare const WysiwygWidget: import("@loadable/component").LoadableClassComponent<any>;
18
18
  export declare const UrlWidget: import("@loadable/component").LoadableClassComponent<{
@@ -96,7 +96,7 @@ export namespace widgetMapping {
96
96
  export { type_1 as type };
97
97
  }
98
98
  }
99
- export const defaultWidget: import("@loadable/component").LoadableComponent<import("react-intl").WithIntlProps<any>>;
99
+ export const defaultWidget: import("@loadable/component").LoadableComponent<any>;
100
100
  import { SchemaWidget } from '@plone/volto/components/manage/Widgets';
101
101
  import { TokenWidget } from '@plone/volto/components/manage/Widgets';
102
102
  import { QuerystringWidget } from '@plone/volto/components/manage/Widgets';
@@ -3,9 +3,6 @@ declare namespace settings {
3
3
  let expressMiddleware: any[];
4
4
  let criticalCssPath: string;
5
5
  let readCriticalCss: any;
6
- namespace extractScripts {
7
- let errorPages: boolean;
8
- }
9
6
  let staticFiles: {
10
7
  id: string;
11
8
  match: RegExp;
@@ -1,7 +1,9 @@
1
1
  import type { Content } from '@plone/types';
2
- export declare function RouteCondition(path: string, exact?: boolean): ({ pathname }: {
3
- pathname: string;
2
+ import type { Location } from 'history';
3
+ export declare function RouteCondition(path: string, exact?: boolean): ({ location }: {
4
+ location: Location;
4
5
  }) => boolean;
5
- export declare function ContentTypeCondition(contentType: string[]): ({ content }: {
6
+ export declare function ContentTypeCondition(contentType: string[]): ({ content, location }: {
6
7
  content: Content;
8
+ location: Location;
7
9
  }) => boolean;
@@ -1,2 +1,2 @@
1
1
  export default function client(): void;
2
- export const history: any;
2
+ export const history: import("history").History<unknown>;