@plone/volto 19.1.5 → 19.2.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 (163) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/locales/af/LC_MESSAGES/volto.po +18 -11
  3. package/locales/af.json +1 -1
  4. package/locales/ar/LC_MESSAGES/volto.po +18 -11
  5. package/locales/ar.json +1 -1
  6. package/locales/bg/LC_MESSAGES/volto.po +18 -11
  7. package/locales/bg.json +1 -1
  8. package/locales/bn/LC_MESSAGES/volto.po +18 -11
  9. package/locales/bn.json +1 -1
  10. package/locales/ca/LC_MESSAGES/volto.po +18 -11
  11. package/locales/ca.json +1 -1
  12. package/locales/cs/LC_MESSAGES/volto.po +18 -11
  13. package/locales/cs.json +1 -1
  14. package/locales/cy/LC_MESSAGES/volto.po +18 -11
  15. package/locales/cy.json +1 -1
  16. package/locales/da/LC_MESSAGES/volto.po +18 -11
  17. package/locales/da.json +1 -1
  18. package/locales/de/LC_MESSAGES/volto.po +18 -11
  19. package/locales/de.json +1 -1
  20. package/locales/el/LC_MESSAGES/volto.po +18 -11
  21. package/locales/el.json +1 -1
  22. package/locales/en/LC_MESSAGES/volto.po +18 -11
  23. package/locales/en.json +1 -1
  24. package/locales/en_AU/LC_MESSAGES/volto.po +18 -11
  25. package/locales/en_AU.json +1 -1
  26. package/locales/en_GB/LC_MESSAGES/volto.po +18 -11
  27. package/locales/en_GB.json +1 -1
  28. package/locales/eo/LC_MESSAGES/volto.po +18 -11
  29. package/locales/eo.json +1 -1
  30. package/locales/es/LC_MESSAGES/volto.po +18 -11
  31. package/locales/es.json +1 -1
  32. package/locales/et/LC_MESSAGES/volto.po +18 -11
  33. package/locales/et.json +1 -1
  34. package/locales/eu/LC_MESSAGES/volto.po +18 -11
  35. package/locales/eu.json +1 -1
  36. package/locales/fa/LC_MESSAGES/volto.po +18 -11
  37. package/locales/fa.json +1 -1
  38. package/locales/fi/LC_MESSAGES/volto.po +18 -11
  39. package/locales/fi.json +1 -1
  40. package/locales/fr/LC_MESSAGES/volto.po +18 -11
  41. package/locales/fr.json +1 -1
  42. package/locales/fu/LC_MESSAGES/volto.po +18 -11
  43. package/locales/fu.json +1 -1
  44. package/locales/gl/LC_MESSAGES/volto.po +18 -11
  45. package/locales/gl.json +1 -1
  46. package/locales/he/LC_MESSAGES/volto.po +18 -11
  47. package/locales/he.json +1 -1
  48. package/locales/hi/LC_MESSAGES/volto.po +18 -11
  49. package/locales/hi.json +1 -1
  50. package/locales/hr/LC_MESSAGES/volto.po +18 -11
  51. package/locales/hr.json +1 -1
  52. package/locales/hu/LC_MESSAGES/volto.po +18 -11
  53. package/locales/hu.json +1 -1
  54. package/locales/hy/LC_MESSAGES/volto.po +18 -11
  55. package/locales/hy.json +1 -1
  56. package/locales/id/LC_MESSAGES/volto.po +18 -11
  57. package/locales/id.json +1 -1
  58. package/locales/it/LC_MESSAGES/volto.po +18 -11
  59. package/locales/it.json +1 -1
  60. package/locales/ja/LC_MESSAGES/volto.po +18 -11
  61. package/locales/ja.json +1 -1
  62. package/locales/ka/LC_MESSAGES/volto.po +18 -11
  63. package/locales/ka.json +1 -1
  64. package/locales/kn/LC_MESSAGES/volto.po +18 -11
  65. package/locales/kn.json +1 -1
  66. package/locales/ko/LC_MESSAGES/volto.po +18 -11
  67. package/locales/ko.json +1 -1
  68. package/locales/lt/LC_MESSAGES/volto.po +18 -11
  69. package/locales/lt.json +1 -1
  70. package/locales/lv/LC_MESSAGES/volto.po +18 -11
  71. package/locales/lv.json +1 -1
  72. package/locales/mi/LC_MESSAGES/volto.po +18 -11
  73. package/locales/mi.json +1 -1
  74. package/locales/mk/LC_MESSAGES/volto.po +18 -11
  75. package/locales/mk.json +1 -1
  76. package/locales/my/LC_MESSAGES/volto.po +18 -11
  77. package/locales/my.json +1 -1
  78. package/locales/nb_NO/LC_MESSAGES/volto.po +18 -11
  79. package/locales/nb_NO.json +1 -1
  80. package/locales/nl/LC_MESSAGES/volto.po +18 -11
  81. package/locales/nl.json +1 -1
  82. package/locales/nn/LC_MESSAGES/volto.po +18 -11
  83. package/locales/nn.json +1 -1
  84. package/locales/pl/LC_MESSAGES/volto.po +18 -11
  85. package/locales/pl.json +1 -1
  86. package/locales/pt/LC_MESSAGES/volto.po +18 -11
  87. package/locales/pt.json +1 -1
  88. package/locales/pt_BR/LC_MESSAGES/volto.po +18 -11
  89. package/locales/pt_BR.json +1 -1
  90. package/locales/rm/LC_MESSAGES/volto.po +18 -11
  91. package/locales/rm.json +1 -1
  92. package/locales/ro/LC_MESSAGES/volto.po +18 -11
  93. package/locales/ro.json +1 -1
  94. package/locales/ru/LC_MESSAGES/volto.po +18 -11
  95. package/locales/ru.json +1 -1
  96. package/locales/sk/LC_MESSAGES/volto.po +18 -11
  97. package/locales/sk.json +1 -1
  98. package/locales/sl/LC_MESSAGES/volto.po +18 -11
  99. package/locales/sl.json +1 -1
  100. package/locales/sm/LC_MESSAGES/volto.po +18 -11
  101. package/locales/sm.json +1 -1
  102. package/locales/sq/LC_MESSAGES/volto.po +18 -11
  103. package/locales/sq.json +1 -1
  104. package/locales/sr/LC_MESSAGES/volto.po +18 -11
  105. package/locales/sr.json +1 -1
  106. package/locales/sr@cyrl/LC_MESSAGES/volto.po +18 -11
  107. package/locales/sr@cyrl.json +1 -1
  108. package/locales/sr@latn/LC_MESSAGES/volto.po +18 -11
  109. package/locales/sr@latn.json +1 -1
  110. package/locales/sv/LC_MESSAGES/volto.po +18 -11
  111. package/locales/sv.json +1 -1
  112. package/locales/ta/LC_MESSAGES/volto.po +18 -11
  113. package/locales/ta.json +1 -1
  114. package/locales/te/LC_MESSAGES/volto.po +18 -11
  115. package/locales/te.json +1 -1
  116. package/locales/th/LC_MESSAGES/volto.po +18 -11
  117. package/locales/th.json +1 -1
  118. package/locales/to/LC_MESSAGES/volto.po +18 -11
  119. package/locales/to.json +1 -1
  120. package/locales/tr/LC_MESSAGES/volto.po +18 -11
  121. package/locales/tr.json +1 -1
  122. package/locales/uk/LC_MESSAGES/volto.po +18 -11
  123. package/locales/uk.json +1 -1
  124. package/locales/vi/LC_MESSAGES/volto.po +18 -11
  125. package/locales/vi.json +1 -1
  126. package/locales/volto.pot +17 -10
  127. package/locales/zh_CN/LC_MESSAGES/volto.po +18 -11
  128. package/locales/zh_CN.json +1 -1
  129. package/locales/zh_Hant/LC_MESSAGES/volto.po +18 -11
  130. package/locales/zh_Hant.json +1 -1
  131. package/locales/zh_Hant_HK/LC_MESSAGES/volto.po +18 -11
  132. package/locales/zh_Hant_HK.json +1 -1
  133. package/package.json +6 -7
  134. package/src/actions/querystringsearch/querystringsearch.test.js +107 -0
  135. package/src/actions/querystringsearch/querystringsearch.ts +135 -0
  136. package/src/components/manage/Blocks/Listing/getAsyncData.js +5 -0
  137. package/src/components/manage/Blocks/Listing/withQuerystringResults.jsx +18 -5
  138. package/src/components/manage/Controlpanels/BlockTypes.test.ts +132 -0
  139. package/src/components/manage/Controlpanels/BlockTypes.tsx +32 -11
  140. package/src/components/manage/Sidebar/ObjectBrowserBody.jsx +23 -2
  141. package/src/components/manage/Toolbar/More.jsx +13 -0
  142. package/src/components/manage/Widgets/FileWidget.jsx +19 -9
  143. package/src/components/manage/Widgets/QuerystringWidget.jsx +18 -1
  144. package/src/components/manage/Widgets/QuerystringWidget.test.jsx +11 -0
  145. package/src/components/manage/Widgets/RegistryImageWidget.jsx +5 -3
  146. package/src/config/server.js +2 -0
  147. package/src/express-middleware/images.js +0 -1
  148. package/src/express-middleware/portraits.js +34 -0
  149. package/src/helpers/Api/PloneBackendAPIResourceWithAuth.js +39 -0
  150. package/src/helpers/Api/PloneBackendAPIResourceWithAuth.test.js +60 -0
  151. package/src/helpers/Pagination/Pagination.test.ts +259 -0
  152. package/src/helpers/Pagination/Pagination.ts +151 -0
  153. package/theme/themes/pastanaga/extras/focus.less +33 -0
  154. package/theme/themes/pastanaga/extras/main.less +1 -0
  155. package/theme/themes/pastanaga/extras/skiplinks.less +0 -2
  156. package/theme/themes/pastanaga/globals/site.variables +7 -0
  157. package/types/actions/querystringsearch/querystringsearch.d.ts +51 -3
  158. package/types/components/manage/Controlpanels/BlockTypes.d.ts +48 -0
  159. package/types/components/manage/Widgets/QuerystringWidget.d.ts +6 -0
  160. package/types/express-middleware/portraits.d.ts +1 -0
  161. package/types/helpers/Api/PloneBackendAPIResourceWithAuth.d.ts +1 -0
  162. package/types/helpers/Pagination/Pagination.d.ts +74 -0
  163. package/src/actions/querystringsearch/querystringsearch.js +0 -63
@@ -12,9 +12,7 @@
12
12
  top: 10px;
13
13
  left: 10px;
14
14
  padding: 10px;
15
- border: 2px solid @linkColor;
16
15
  background: #fff;
17
- outline: 3px solid @linkColor;
18
16
  }
19
17
 
20
18
  &:hover {
@@ -362,3 +362,10 @@
362
362
  /*--- Dark Tones ---*/
363
363
 
364
364
  /*--- Light Tones ---*/
365
+
366
+ /*-------------------
367
+ Focused Input
368
+ --------------------*/
369
+
370
+ @innerFocusShadow: #fff;
371
+ @outerFocusOutline: #000;
@@ -1,7 +1,55 @@
1
+ /**
2
+ * Querystring search actions.
3
+ * @module actions/querystringsearch/querystringsearch
4
+ */
5
+ import { GET_QUERYSTRING_RESULTS } from '@plone/volto/constants/ActionTypes';
6
+ import { type IntegerLike } from '@plone/volto/helpers/Pagination/Pagination';
7
+ /**
8
+ * A single `plone.app.querystring` criterion: index, operation, value.
9
+ */
10
+ export interface QuerystringCriterion {
11
+ i: string;
12
+ o: string;
13
+ v?: unknown;
14
+ }
15
+ /**
16
+ * The querystring settings stored on a block. Numeric fields are typed as
17
+ * `IntegerLike` because they are edited through JSON schema `number` widgets
18
+ * and may reach us as strings.
19
+ */
20
+ export interface QuerystringData {
21
+ query?: QuerystringCriterion[];
22
+ sort_on?: string;
23
+ sort_order?: string | boolean | null;
24
+ b_size?: IntegerLike;
25
+ offset?: IntegerLike;
26
+ limit?: IntegerLike;
27
+ depth?: IntegerLike;
28
+ [key: string]: unknown;
29
+ }
30
+ /**
31
+ * The payload sent to the `@querystring-search` endpoint. `b_start` is only
32
+ * present once a page or an offset places the batch past the beginning.
33
+ */
34
+ export interface QuerystringSearchQuery extends QuerystringData {
35
+ b_start?: number;
36
+ }
37
+ export interface GetQueryStringResultsAction {
38
+ type: typeof GET_QUERYSTRING_RESULTS;
39
+ subrequest?: string;
40
+ request: {
41
+ op: 'get' | 'post';
42
+ path: string;
43
+ data: QuerystringSearchQuery | null;
44
+ };
45
+ }
1
46
  /**
2
47
  * Get querystring results.
3
48
  * @function getQueryStringResults
4
- * @param {Object} data Data.
5
- * @returns {Object} Get querystringsearch results action.
49
+ * @param {string} path Path to search under.
50
+ * @param {QuerystringData} data Querystring settings from the block.
51
+ * @param {string} subrequest Subrequest id used to store the results.
52
+ * @param {IntegerLike} page 1-based page number. Defaults to the first page.
53
+ * @returns {GetQueryStringResultsAction} Get querystringsearch results action.
6
54
  */
7
- export function getQueryStringResults(path: any, data: any, subrequest: any, page: any): any;
55
+ export declare function getQueryStringResults(path: string, data: QuerystringData, subrequest?: string, page?: IntegerLike): GetQueryStringResultsAction;
@@ -1,7 +1,55 @@
1
+ import type { IntlShape } from 'react-intl';
1
2
  import type { Location } from 'history';
3
+ import type { BlocksConfigData } from '@plone/types';
2
4
  type RouteProps = {
3
5
  history: History;
4
6
  location: Location;
5
7
  };
8
+ /**
9
+ * List the configured blocks, by title.
10
+ *
11
+ * An add-on can configure a block that was never registered — enhancing one
12
+ * that ships with another add-on, say — which leaves an entry behind that is
13
+ * not a block at all, with no id or no title. `BlockConfigBase` says both are
14
+ * always there, but the config disagrees, so drop those entries rather than
15
+ * list a block that does not exist.
16
+ * @function sortConfigBlocks
17
+ * @param {BlocksConfigData} blocksConfig The blocks configuration.
18
+ * @param {IntlShape} intl Used to translate each block title.
19
+ * @returns {Array} The configured blocks, sorted by translated title.
20
+ */
21
+ export declare function sortConfigBlocks(blocksConfig: BlocksConfigData, intl: IntlShape): {
22
+ title: string;
23
+ id: string;
24
+ icon: string;
25
+ group: string;
26
+ category?: string;
27
+ blockModel?: number;
28
+ view?: React.ComponentType<import("@plone/types").BlockViewProps>;
29
+ edit?: React.ComponentType<import("@plone/types").BlockEditProps>;
30
+ schema?: object;
31
+ blockSchema: import("@plone/types").JSONSchema | ((args?: import("@plone/types").BlockSchemaArgs) => import("@plone/types").JSONSchema);
32
+ dataAdapter?: ({ block, data, id, onChangeBlock, value, }: {
33
+ block: string;
34
+ data: import("@plone/types").BlocksFormData;
35
+ id: string;
36
+ onChangeBlock: (id: string, newData: any) => void;
37
+ value: any;
38
+ }) => void;
39
+ restricted: ((args: {
40
+ properties: import("@plone/types").Content;
41
+ block: import("@plone/types").BlockConfigBase;
42
+ navRoot: import("@plone/types").Content;
43
+ contentType: string;
44
+ user: import("@plone/types").User;
45
+ }) => boolean) | boolean;
46
+ mostUsed: boolean;
47
+ blockHasOwnFocusManagement?: boolean;
48
+ sidebarTab: boolean | 0 | 1;
49
+ schemaEnhancer?: (args: import("@plone/types").SchemaEnhancerArgs) => import("@plone/types").JSONSchema;
50
+ variations?: import("@plone/types").BlockExtension[];
51
+ extensions?: Record<string, import("@plone/types").BlockExtension>;
52
+ blocksConfig?: Partial<BlocksConfigData>;
53
+ }[];
6
54
  declare const BlockTypesControlpanel: (props: RouteProps) => import("react/jsx-runtime").JSX.Element;
7
55
  export default BlockTypesControlpanel;
@@ -28,6 +28,12 @@ export function objectSchema({ intl, isDisabled, value }: {
28
28
  type: string;
29
29
  isDisabled: any;
30
30
  };
31
+ offset: {
32
+ title: any;
33
+ type: string;
34
+ isDisabled: any;
35
+ default: number;
36
+ };
31
37
  b_size: {
32
38
  title: any;
33
39
  type: string;
@@ -0,0 +1 @@
1
+ export default function portraitsMiddleware(): any;
@@ -0,0 +1 @@
1
+ export function getPloneBackendAPIResourceWithAuth(req: any): string;
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Pagination helpers.
3
+ * @module helpers/Pagination/Pagination
4
+ */
5
+ /**
6
+ * A value that is meant to represent an integer, but which reaches us from
7
+ * user-editable block settings. The querystring widget stores `offset`,
8
+ * `limit` and `b_size` as JSON schema `number` fields, so a value may arrive
9
+ * as a string (`'3'`), as a float (`3.7`), or not at all.
10
+ */
11
+ export type IntegerLike = number | string | null | undefined;
12
+ /**
13
+ * Compute the `b_start` index for a `@querystring-search` request: the index
14
+ * of the first item the backend should return for the requested page.
15
+ *
16
+ * `offset` shifts the whole result set, letting a listing skip the first N
17
+ * items of its query while paginating over the remainder.
18
+ *
19
+ * Every parameter is coerced to an integer and the result is always a
20
+ * non-negative integer, so a malformed block setting degrades to a sane batch
21
+ * rather than sending `NaN` to the backend. When neither `bSize` nor
22
+ * `defaultPageSize` yields a positive batch size, paging cannot be applied and
23
+ * the result is `offset` alone.
24
+ * @function computeBStart
25
+ * @param {IntegerLike} page 1-based page number. Defaults to the first page.
26
+ * @param {IntegerLike} offset Number of leading items to skip. Defaults to 0.
27
+ * @param {IntegerLike} bSize Batch size configured on the block, if any.
28
+ * @param {IntegerLike} defaultPageSize Batch size to use when bSize is unset.
29
+ * @returns {number} A non-negative integer `b_start` index.
30
+ */
31
+ export declare function computeBStart(page: IntegerLike, offset: IntegerLike, bSize: IntegerLike, defaultPageSize: IntegerLike): number;
32
+ /**
33
+ * Compute the effective `limit` for a `@querystring-search` request.
34
+ *
35
+ * A listing that skips the first `offset` items still wants `limit` items
36
+ * afterwards, so the backend has to return the skipped items on top of the
37
+ * wanted ones: `offset + limit`.
38
+ *
39
+ * A limit of zero, or one that resolves to no usable number, means "no limit"
40
+ * — matching `plone.app.querystring`'s querybuilder, whose `limit` defaults to
41
+ * 0 and is only applied when truthy. Returning `offset` in that case would cap
42
+ * the batch at the very items the listing is about to skip, leaving it empty.
43
+ * @function computeLimit
44
+ * @param {IntegerLike} offset Number of leading items to skip. Defaults to 0.
45
+ * @param {IntegerLike} limit Number of items the listing wants, if capped.
46
+ * @returns {number | null} A positive integer limit, or null for no limit.
47
+ */
48
+ export declare function computeLimit(offset: IntegerLike, limit: IntegerLike): number | null;
49
+ /**
50
+ * Compute how many items a listing can actually show.
51
+ *
52
+ * The `items_total` reported by `@querystring-search` is the length of the
53
+ * whole result set: `plone.restapi`'s HypermediaBatch derives it from the
54
+ * sequence length, so `b_start` never reduces it. The items an offset skips
55
+ * are counted in there even though the listing never renders them.
56
+ * @function computeVisibleTotal
57
+ * @param {IntegerLike} total The `items_total` reported by the backend.
58
+ * @param {IntegerLike} offset Number of leading items skipped. Defaults to 0.
59
+ * @returns {number} A non-negative integer count of reachable items.
60
+ */
61
+ export declare function computeVisibleTotal(total: IntegerLike, offset: IntegerLike): number;
62
+ /**
63
+ * Compute how many pages a listing spans.
64
+ *
65
+ * `total` is expected to be the reachable item count, so pass the result of
66
+ * `computeVisibleTotal` for an offset listing rather than the raw backend
67
+ * total. Otherwise the listing advertises pages that resolve to an empty batch.
68
+ * @function computeTotalPages
69
+ * @param {IntegerLike} total Number of items the listing can show.
70
+ * @param {IntegerLike} bSize Batch size, i.e. items per page.
71
+ * @returns {number} A non-negative integer page count, 0 when there is no
72
+ * usable batch size.
73
+ */
74
+ export declare function computeTotalPages(total: IntegerLike, bSize: IntegerLike): number;
@@ -1,63 +0,0 @@
1
- import { GET_QUERYSTRING_RESULTS } from '@plone/volto/constants/ActionTypes';
2
- import config from '@plone/volto/registry';
3
-
4
- /**
5
- * Get querystring results.
6
- * @function getQueryStringResults
7
- * @param {Object} data Data.
8
- * @returns {Object} Get querystringsearch results action.
9
- */
10
- export function getQueryStringResults(path, data, subrequest, page) {
11
- const { settings } = config;
12
-
13
- // fixes https://github.com/plone/volto/issues/1059
14
- let requestData = JSON.parse(JSON.stringify(data));
15
-
16
- if (data?.depth != null) {
17
- delete requestData.depth;
18
- requestData.query.forEach((q) => {
19
- if (q.i === 'path') {
20
- // fixes https://github.com/plone/volto/issues/8349
21
- // Skip if depth is already embedded in the path value (e.g. set via object browser)
22
- const hasEmbeddedDepth = /::\d+$/.test(q.v);
23
- if (!hasEmbeddedDepth) q.v += '::' + data.depth;
24
- }
25
- });
26
- }
27
-
28
- // fixes https://github.com/plone/volto/issues/2397
29
- if (requestData?.sort_order !== null) {
30
- if (typeof requestData.sort_order === 'boolean') {
31
- requestData.sort_order = requestData.sort_order
32
- ? 'descending'
33
- : 'ascending';
34
- }
35
- }
36
-
37
- const query = {
38
- ...requestData,
39
- ...(!requestData.b_size && {
40
- b_size: settings.defaultPageSize,
41
- }),
42
- ...(page && {
43
- b_start: requestData.b_size
44
- ? data.b_size * (page - 1)
45
- : settings.defaultPageSize * (page - 1),
46
- }),
47
- query: requestData?.query,
48
- };
49
-
50
- return {
51
- type: GET_QUERYSTRING_RESULTS,
52
- subrequest,
53
- request: {
54
- op: settings.querystringSearchGet ? 'get' : 'post',
55
- path: `${path}/@querystring-search${
56
- settings.querystringSearchGet
57
- ? `?query=${encodeURIComponent(JSON.stringify(query))}`
58
- : ''
59
- }`,
60
- data: settings.querystringSearchGet ? null : query,
61
- },
62
- };
63
- }