@plone/volto 18.32.0 → 18.32.2

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/.eslintignore +1 -0
  2. package/CHANGELOG.md +40 -0
  3. package/README.md +0 -4
  4. package/locales/af/LC_MESSAGES/volto.po +5 -0
  5. package/locales/af.json +1 -1
  6. package/locales/ar/LC_MESSAGES/volto.po +5 -0
  7. package/locales/ar.json +1 -1
  8. package/locales/bg/LC_MESSAGES/volto.po +5 -0
  9. package/locales/bg.json +1 -1
  10. package/locales/bn/LC_MESSAGES/volto.po +5 -0
  11. package/locales/bn.json +1 -1
  12. package/locales/ca/LC_MESSAGES/volto.po +5 -0
  13. package/locales/ca.json +1 -1
  14. package/locales/cs/LC_MESSAGES/volto.po +5 -0
  15. package/locales/cs.json +1 -1
  16. package/locales/cy/LC_MESSAGES/volto.po +5 -0
  17. package/locales/cy.json +1 -1
  18. package/locales/da/LC_MESSAGES/volto.po +5 -0
  19. package/locales/da.json +1 -1
  20. package/locales/de/LC_MESSAGES/volto.po +5 -0
  21. package/locales/de.json +1 -1
  22. package/locales/el/LC_MESSAGES/volto.po +5 -0
  23. package/locales/el.json +1 -1
  24. package/locales/en/LC_MESSAGES/volto.po +5 -0
  25. package/locales/en.json +1 -1
  26. package/locales/en_AU/LC_MESSAGES/volto.po +5 -0
  27. package/locales/en_AU.json +1 -1
  28. package/locales/en_GB/LC_MESSAGES/volto.po +5 -0
  29. package/locales/en_GB.json +1 -1
  30. package/locales/eo/LC_MESSAGES/volto.po +5 -0
  31. package/locales/eo.json +1 -1
  32. package/locales/es/LC_MESSAGES/volto.po +5 -0
  33. package/locales/es.json +1 -1
  34. package/locales/et/LC_MESSAGES/volto.po +5 -0
  35. package/locales/et.json +1 -1
  36. package/locales/eu/LC_MESSAGES/volto.po +5 -0
  37. package/locales/eu.json +1 -1
  38. package/locales/fa/LC_MESSAGES/volto.po +5 -0
  39. package/locales/fa.json +1 -1
  40. package/locales/fi/LC_MESSAGES/volto.po +5 -0
  41. package/locales/fi.json +1 -1
  42. package/locales/fr/LC_MESSAGES/volto.po +5 -0
  43. package/locales/fr.json +1 -1
  44. package/locales/fu/LC_MESSAGES/volto.po +5 -0
  45. package/locales/fu.json +1 -1
  46. package/locales/gl/LC_MESSAGES/volto.po +5 -0
  47. package/locales/gl.json +1 -1
  48. package/locales/he/LC_MESSAGES/volto.po +5 -0
  49. package/locales/he.json +1 -1
  50. package/locales/hi/LC_MESSAGES/volto.po +5 -0
  51. package/locales/hi.json +1 -1
  52. package/locales/hr/LC_MESSAGES/volto.po +5 -0
  53. package/locales/hr.json +1 -1
  54. package/locales/hu/LC_MESSAGES/volto.po +5 -0
  55. package/locales/hu.json +1 -1
  56. package/locales/hy/LC_MESSAGES/volto.po +5 -0
  57. package/locales/hy.json +1 -1
  58. package/locales/id/LC_MESSAGES/volto.po +5 -0
  59. package/locales/id.json +1 -1
  60. package/locales/it/LC_MESSAGES/volto.po +5 -0
  61. package/locales/it.json +1 -1
  62. package/locales/ja/LC_MESSAGES/volto.po +5 -0
  63. package/locales/ja.json +1 -1
  64. package/locales/ka/LC_MESSAGES/volto.po +5 -0
  65. package/locales/ka.json +1 -1
  66. package/locales/kn/LC_MESSAGES/volto.po +5 -0
  67. package/locales/kn.json +1 -1
  68. package/locales/ko/LC_MESSAGES/volto.po +5 -0
  69. package/locales/ko.json +1 -1
  70. package/locales/lt/LC_MESSAGES/volto.po +5 -0
  71. package/locales/lt.json +1 -1
  72. package/locales/lv/LC_MESSAGES/volto.po +5 -0
  73. package/locales/lv.json +1 -1
  74. package/locales/mi/LC_MESSAGES/volto.po +5 -0
  75. package/locales/mi.json +1 -1
  76. package/locales/mk/LC_MESSAGES/volto.po +5 -0
  77. package/locales/mk.json +1 -1
  78. package/locales/my/LC_MESSAGES/volto.po +5 -0
  79. package/locales/my.json +1 -1
  80. package/locales/nb_NO/LC_MESSAGES/volto.po +5 -0
  81. package/locales/nb_NO.json +1 -1
  82. package/locales/nl/LC_MESSAGES/volto.po +5 -0
  83. package/locales/nl.json +1 -1
  84. package/locales/nn/LC_MESSAGES/volto.po +5 -0
  85. package/locales/nn.json +1 -1
  86. package/locales/pl/LC_MESSAGES/volto.po +5 -0
  87. package/locales/pl.json +1 -1
  88. package/locales/pt/LC_MESSAGES/volto.po +5 -0
  89. package/locales/pt.json +1 -1
  90. package/locales/pt_BR/LC_MESSAGES/volto.po +5 -0
  91. package/locales/pt_BR.json +1 -1
  92. package/locales/rm/LC_MESSAGES/volto.po +5 -0
  93. package/locales/rm.json +1 -1
  94. package/locales/ro/LC_MESSAGES/volto.po +5 -0
  95. package/locales/ro.json +1 -1
  96. package/locales/ru/LC_MESSAGES/volto.po +5 -0
  97. package/locales/ru.json +1 -1
  98. package/locales/sk/LC_MESSAGES/volto.po +5 -0
  99. package/locales/sk.json +1 -1
  100. package/locales/sl/LC_MESSAGES/volto.po +5 -0
  101. package/locales/sl.json +1 -1
  102. package/locales/sm/LC_MESSAGES/volto.po +5 -0
  103. package/locales/sm.json +1 -1
  104. package/locales/sq/LC_MESSAGES/volto.po +5 -0
  105. package/locales/sq.json +1 -1
  106. package/locales/sr/LC_MESSAGES/volto.po +5 -0
  107. package/locales/sr.json +1 -1
  108. package/locales/sr@cyrl/LC_MESSAGES/volto.po +5 -0
  109. package/locales/sr@cyrl.json +1 -1
  110. package/locales/sr@latn/LC_MESSAGES/volto.po +5 -0
  111. package/locales/sr@latn.json +1 -1
  112. package/locales/sv/LC_MESSAGES/volto.po +5 -0
  113. package/locales/sv.json +1 -1
  114. package/locales/ta/LC_MESSAGES/volto.po +5 -0
  115. package/locales/ta.json +1 -1
  116. package/locales/te/LC_MESSAGES/volto.po +5 -0
  117. package/locales/te.json +1 -1
  118. package/locales/th/LC_MESSAGES/volto.po +5 -0
  119. package/locales/th.json +1 -1
  120. package/locales/to/LC_MESSAGES/volto.po +5 -0
  121. package/locales/to.json +1 -1
  122. package/locales/tr/LC_MESSAGES/volto.po +5 -0
  123. package/locales/tr.json +1 -1
  124. package/locales/uk/LC_MESSAGES/volto.po +5 -0
  125. package/locales/uk.json +1 -1
  126. package/locales/vi/LC_MESSAGES/volto.po +5 -0
  127. package/locales/vi.json +1 -1
  128. package/locales/volto.pot +5 -0
  129. package/locales/zh_CN/LC_MESSAGES/volto.po +5 -0
  130. package/locales/zh_CN.json +1 -1
  131. package/locales/zh_Hant/LC_MESSAGES/volto.po +5 -0
  132. package/locales/zh_Hant.json +1 -1
  133. package/locales/zh_Hant_HK/LC_MESSAGES/volto.po +5 -0
  134. package/locales/zh_Hant_HK.json +1 -1
  135. package/package.json +6 -5
  136. package/src/components/manage/Blocks/Block/BlocksForm.jsx +10 -7
  137. package/src/components/manage/Blocks/Block/BlocksForm.test.jsx +2 -9
  138. package/src/components/manage/Blocks/Block/Order/Item.jsx +9 -3
  139. package/src/components/manage/Blocks/Block/Order/Order.jsx +116 -67
  140. package/src/components/manage/Blocks/Block/Order/utilities.js +28 -11
  141. package/src/components/manage/Blocks/Listing/Edit.jsx +1 -0
  142. package/src/components/manage/Controlpanels/ContentTypeSchema.jsx +1 -1
  143. package/src/components/manage/Sharing/Sharing.jsx +10 -12
  144. package/src/components/manage/Sidebar/ObjectBrowserBody.jsx +5 -1
  145. package/src/components/manage/UniversalLink/UniversalLink.test.jsx +16 -0
  146. package/src/components/manage/UniversalLink/UniversalLink.tsx +1 -0
  147. package/src/components/theme/App/App.jsx +3 -1
  148. package/src/components/theme/ConnectionRefused/ConnectionRefused.jsx +3 -2
  149. package/src/components/theme/PasswordReset/PasswordReset.jsx +108 -191
  150. package/src/components/theme/View/RenderBlocks.jsx +8 -10
  151. package/src/components/theme/View/RenderBlocks.test.jsx +14 -4
  152. package/src/config/index.js +1 -1
  153. package/src/helpers/AuthToken/AuthToken.js +1 -6
  154. package/src/helpers/Blocks/Blocks.js +109 -24
  155. package/src/helpers/Blocks/Blocks.test.js +100 -0
  156. package/src/helpers/FormValidation/validators.ts +16 -4
  157. package/types/components/manage/Blocks/Block/Order/utilities.d.ts +2 -1
  158. package/types/components/theme/ConnectionRefused/ConnectionRefused.d.ts +2 -2
  159. package/types/components/theme/PasswordReset/PasswordReset.d.ts +6 -2
  160. package/types/config/Views.d.ts +1 -1
  161. package/types/helpers/Blocks/Blocks.d.ts +4 -0
  162. package/types/helpers/FormValidation/validators.d.ts +11 -1
  163. package/types/routes.d.ts +7 -5
@@ -5,7 +5,6 @@
5
5
 
6
6
  import Cookies from 'universal-cookie';
7
7
  import jwtDecode from 'jwt-decode';
8
-
9
8
  import { loginRenew } from '@plone/volto/actions/userSession/userSession';
10
9
  import { getCookieOptions } from '@plone/volto/helpers/Cookies/cookies';
11
10
  import { push } from 'connected-react-router';
@@ -35,7 +34,6 @@ export function persistAuthToken(store, req) {
35
34
  } else {
36
35
  currentValue = cookies.get('auth_token');
37
36
  }
38
-
39
37
  /**
40
38
  * handleChange method.
41
39
  * @method handleChange
@@ -46,7 +44,6 @@ export function persistAuthToken(store, req) {
46
44
  const previousValue = currentValue;
47
45
  const state = store.getState();
48
46
  currentValue = state.userSession.token;
49
-
50
47
  if (
51
48
  module.hot &&
52
49
  module.hot.data &&
@@ -55,11 +52,11 @@ export function persistAuthToken(store, req) {
55
52
  ) {
56
53
  currentValue = previousValue;
57
54
  }
58
-
59
55
  if (previousValue !== currentValue || initial) {
60
56
  if (!currentValue) {
61
57
  if (previousValue) {
62
58
  cookies.remove('auth_token', { path: '/' });
59
+ cookies.remove('__ac', { path: '/' });
63
60
  }
64
61
  } else {
65
62
  if (previousValue !== currentValue) {
@@ -97,11 +94,9 @@ export function persistAuthToken(store, req) {
97
94
  }
98
95
  }
99
96
  }
100
-
101
97
  store.subscribe(handleChange);
102
98
  handleChange(true);
103
99
  }
104
-
105
100
  if (module?.hot) {
106
101
  module.hot.dispose((data) => {
107
102
  data.reloaded = true;
@@ -80,6 +80,14 @@ export function blockHasValue(data) {
80
80
  return check(data);
81
81
  }
82
82
 
83
+ /**
84
+ * Block id is valid (not undefined/null or the string "undefined" from object[undefined])
85
+ * @param {*} id Block id
86
+ * @return {boolean}
87
+ */
88
+ const isValidBlockId = (id) =>
89
+ id != null && id !== 'undefined' && (typeof id !== 'string' || id.length > 0);
90
+
83
91
  /**
84
92
  * Get block pairs of [id, block] from content properties
85
93
  * @function getBlocks
@@ -89,12 +97,26 @@ export function blockHasValue(data) {
89
97
  export const getBlocks = (properties) => {
90
98
  const blocksFieldName = getBlocksFieldname(properties);
91
99
  const blocksLayoutFieldname = getBlocksLayoutFieldname(properties);
92
- return (
93
- properties[blocksLayoutFieldname]?.items?.map((n) => [
94
- n,
95
- properties[blocksFieldName][n],
96
- ]) || []
97
- );
100
+ const blocks = properties?.[blocksFieldName];
101
+ const items = properties?.[blocksLayoutFieldname]?.items;
102
+ if (!items) return [];
103
+ return items
104
+ .filter((n) => isValidBlockId(n))
105
+ .map((n) => [n, blocks?.[n]])
106
+ .filter(([, block]) => block != null);
107
+ };
108
+
109
+ /**
110
+ * Get layout item IDs that are valid but have no block data (orphaned refs).
111
+ * @param {Object} properties Content form properties
112
+ * @return {string[]} IDs that should be removed from layout
113
+ */
114
+ export const getInvalidBlockLayoutIds = (properties) => {
115
+ const blocksFieldName = getBlocksFieldname(properties);
116
+ const blocksLayoutFieldName = getBlocksLayoutFieldname(properties);
117
+ const blocks = properties?.[blocksFieldName] ?? {};
118
+ const layoutItems = properties?.[blocksLayoutFieldName]?.items ?? [];
119
+ return layoutItems.filter((id) => isValidBlockId(id) && blocks[id] == null);
98
120
  };
99
121
 
100
122
  /**
@@ -129,12 +151,28 @@ export function deleteBlock(formData, blockId, intl) {
129
151
 
130
152
  let newFormData = {
131
153
  ...formData,
132
- [blocksLayoutFieldname]: {
133
- items: without(formData[blocksLayoutFieldname].items, blockId),
134
- },
135
- [blocksFieldname]: omit(formData[blocksFieldname], [blockId]),
136
154
  };
137
155
 
156
+ let container = findParent(newFormData, {
157
+ blockId,
158
+ });
159
+
160
+ if (container) {
161
+ container[blocksLayoutFieldname].items = without(
162
+ container[blocksLayoutFieldname].items,
163
+ blockId,
164
+ );
165
+ container[blocksFieldname] = omit(container[blocksFieldname], [blockId]);
166
+ } else {
167
+ newFormData[blocksLayoutFieldname].items = without(
168
+ newFormData[blocksLayoutFieldname].items,
169
+ blockId,
170
+ );
171
+ newFormData[blocksFieldname] = omit(newFormData[blocksFieldname], [
172
+ blockId,
173
+ ]);
174
+ }
175
+
138
176
  if (newFormData[blocksLayoutFieldname].items.length === 0) {
139
177
  newFormData = addBlock(
140
178
  newFormData,
@@ -817,7 +855,9 @@ export const getBlocksHierarchy = (properties) => {
817
855
  title: properties[blocksFieldName][n]?.['@type'],
818
856
  data: properties[blocksFieldName][n],
819
857
  children: isBlockContainer(properties[blocksFieldName][n])
820
- ? getBlocksHierarchy(properties[blocksFieldName][n])
858
+ ? properties[blocksFieldName][n].data
859
+ ? getBlocksHierarchy(properties[blocksFieldName][n].data)
860
+ : getBlocksHierarchy(properties[blocksFieldName][n])
821
861
  : [],
822
862
  }));
823
863
  };
@@ -911,8 +951,13 @@ export function moveBlockEnhanced(formData, { source, destination }) {
911
951
  const destinationContainer = findContainer(clonedFormData, {
912
952
  containerId: destination.parent,
913
953
  });
954
+ const sourceContainer = findContainer(clonedFormData, {
955
+ containerId: source.parent,
956
+ });
957
+
914
958
  destinationContainer[blocksFieldName][source.id] =
915
- formData[blocksFieldName][source.parent][blocksFieldName][source.id];
959
+ sourceContainer[blocksFieldName]?.[source.id] ||
960
+ sourceContainer.data?.[blocksFieldName][source.id];
916
961
 
917
962
  destinationContainer[blocksLayoutFieldname].items = insertInArray(
918
963
  destinationContainer[blocksLayoutFieldname].items,
@@ -921,9 +966,6 @@ export function moveBlockEnhanced(formData, { source, destination }) {
921
966
  );
922
967
 
923
968
  // Remove the source block from the source parent
924
- const sourceContainer = findContainer(clonedFormData, {
925
- containerId: source.parent,
926
- });
927
969
  delete sourceContainer[blocksFieldName][source.id];
928
970
  sourceContainer[blocksLayoutFieldname].items = removeFromArray(
929
971
  sourceContainer[blocksLayoutFieldname].items,
@@ -957,23 +999,25 @@ export function moveBlockEnhanced(formData, { source, destination }) {
957
999
  * @returns {object|undefined} - The container object if found, otherwise undefined.
958
1000
  */
959
1001
  export const findContainer = (formData, { containerId }) => {
1002
+ const block =
1003
+ formData.blocks[containerId]?.data || formData.blocks[containerId];
960
1004
  if (
961
- formData.blocks[containerId] &&
962
- Object.keys(formData.blocks[containerId]).includes('blocks') &&
963
- Object.keys(formData.blocks[containerId]).includes('blocks_layout')
1005
+ block &&
1006
+ Object.keys(block).includes('blocks') &&
1007
+ Object.keys(block).includes('blocks_layout')
964
1008
  ) {
965
- return formData.blocks[containerId];
1009
+ return block;
966
1010
  }
967
1011
 
968
1012
  let container;
969
1013
  Object.keys(formData.blocks).every((blockId) => {
970
- const block = formData.blocks[blockId];
1014
+ const subBlock = formData.blocks[blockId].data || formData.blocks[blockId];
971
1015
  if (
972
- formData.blocks[blockId] &&
973
- Object.keys(formData.blocks[blockId]).includes('blocks') &&
974
- Object.keys(formData.blocks[blockId]).includes('blocks_layout')
1016
+ subBlock &&
1017
+ Object.keys(subBlock).includes('blocks') &&
1018
+ Object.keys(subBlock).includes('blocks_layout')
975
1019
  ) {
976
- container = findContainer(block, { containerId });
1020
+ container = findContainer(subBlock, { containerId });
977
1021
  }
978
1022
  if (container) {
979
1023
  return false;
@@ -985,6 +1029,47 @@ export const findContainer = (formData, { containerId }) => {
985
1029
  return container;
986
1030
  };
987
1031
 
1032
+ /**
1033
+ * Finds parent container of the specified blockId in the given formData.
1034
+ *
1035
+ * @param {object} formData - The form data object.
1036
+ * @param {object} options - The options object.
1037
+ * @param {string} options.blockId - The ID of the block to find.
1038
+ * @returns {object|undefined} - The container object if found, otherwise undefined.
1039
+ */
1040
+ export const findParent = (formData, { blockId }) => {
1041
+ const block = formData.data || formData;
1042
+
1043
+ if (block && block.blocks && Object.keys(block.blocks).includes(blockId)) {
1044
+ return block;
1045
+ }
1046
+
1047
+ let found = false;
1048
+
1049
+ if (block && block.blocks) {
1050
+ Object.keys(block.blocks).every((subBlockId) => {
1051
+ const subBlock =
1052
+ block.blocks[subBlockId].data || block.blocks[subBlockId];
1053
+ if (subBlock && subBlock.blocks) {
1054
+ if (Object.keys(subBlock.blocks).includes(blockId)) {
1055
+ found = subBlock;
1056
+ }
1057
+ const parent = findParent(subBlock, { blockId });
1058
+ if (parent) {
1059
+ found = parent;
1060
+ }
1061
+ }
1062
+ if (found) {
1063
+ return false;
1064
+ } else {
1065
+ return true;
1066
+ }
1067
+ });
1068
+ }
1069
+
1070
+ return found;
1071
+ };
1072
+
988
1073
  const _dummyIntl = {
989
1074
  formatMessage() {},
990
1075
  };
@@ -7,6 +7,7 @@ import {
7
7
  getBlocks,
8
8
  getBlocksFieldname,
9
9
  getBlocksLayoutFieldname,
10
+ getInvalidBlockLayoutIds,
10
11
  hasBlocksData,
11
12
  insertBlock,
12
13
  moveBlock,
@@ -482,6 +483,105 @@ describe('Blocks', () => {
482
483
  ['a', { value: 1 }],
483
484
  ]);
484
485
  });
486
+
487
+ it('filters out invalid block IDs (null, undefined, string "undefined")', () => {
488
+ const validBlock = { '@type': 'search', value: 'test' };
489
+ const result = getBlocks({
490
+ blocks: {
491
+ 'valid-id-123': validBlock,
492
+ // These shouldn't exist but test edge case
493
+ [null]: { '@type': 'invalid' },
494
+ [undefined]: { '@type': 'invalid' },
495
+ undefined: { '@type': 'invalid' },
496
+ },
497
+ blocks_layout: {
498
+ items: [
499
+ 'valid-id-123',
500
+ null, // Invalid: null ID
501
+ undefined, // Invalid: undefined ID
502
+ 'undefined', // Invalid: string "undefined"
503
+ 'missing-block', // Valid ID but block doesn't exist (filtered by block !== undefined)
504
+ ],
505
+ },
506
+ });
507
+
508
+ // Should only return the valid block, filtering out:
509
+ // - null ID
510
+ // - undefined ID
511
+ // - string "undefined" ID
512
+ // - missing block (block is undefined)
513
+ expect(result).toStrictEqual([['valid-id-123', validBlock]]);
514
+ expect(result.length).toBe(1);
515
+
516
+ // Verify no invalid IDs in the result
517
+ const ids = result.map(([id]) => id);
518
+ expect(ids).not.toContain(null);
519
+ expect(ids).not.toContain(undefined);
520
+ expect(ids).not.toContain('undefined');
521
+ });
522
+
523
+ it('filters out invalid block IDs even when blocks object has invalid keys', () => {
524
+ // Simulate edge case where blocks object has invalid keys
525
+ const blocks = {
526
+ 'valid-id': { '@type': 'search' },
527
+ };
528
+ // JavaScript allows this, creating string keys
529
+ blocks[null] = { '@type': 'invalid' };
530
+ blocks[undefined] = { '@type': 'invalid' };
531
+
532
+ const result = getBlocks({
533
+ blocks,
534
+ blocks_layout: {
535
+ items: ['valid-id', null, undefined, 'undefined'],
536
+ },
537
+ });
538
+
539
+ // Should only return valid block
540
+ expect(result).toStrictEqual([['valid-id', { '@type': 'search' }]]);
541
+ expect(result.length).toBe(1);
542
+ });
543
+ });
544
+
545
+ describe('getInvalidBlockLayoutIds', () => {
546
+ it('returns layout IDs that are valid but have no block data', () => {
547
+ const result = getInvalidBlockLayoutIds({
548
+ blocks: {
549
+ a: { '@type': 'custom', text: 'a' },
550
+ b: { '@type': 'custom', text: 'b' },
551
+ },
552
+ blocks_layout: {
553
+ items: ['a', 'b', 'MISSING-1', 'MISSING-2'],
554
+ },
555
+ });
556
+ expect(result).toStrictEqual(['MISSING-1', 'MISSING-2']);
557
+ });
558
+
559
+ it('returns empty when all layout items have block data', () => {
560
+ const result = getInvalidBlockLayoutIds({
561
+ blocks: { a: { '@type': 'custom' }, b: { '@type': 'custom' } },
562
+ blocks_layout: { items: ['a', 'b'] },
563
+ });
564
+ expect(result).toStrictEqual([]);
565
+ });
566
+
567
+ it('filters out invalid IDs (null, undefined, "undefined")', () => {
568
+ const result = getInvalidBlockLayoutIds({
569
+ blocks: {},
570
+ blocks_layout: {
571
+ items: [null, undefined, 'undefined', 'valid-missing'],
572
+ },
573
+ });
574
+ expect(result).toStrictEqual(['valid-missing']);
575
+ });
576
+
577
+ it('returns empty when items is missing or empty', () => {
578
+ expect(
579
+ getInvalidBlockLayoutIds({ blocks: {}, blocks_layout: {} }),
580
+ ).toStrictEqual([]);
581
+ expect(
582
+ getInvalidBlockLayoutIds({ blocks: {}, blocks_layout: { items: [] } }),
583
+ ).toStrictEqual([]);
584
+ });
485
585
  });
486
586
 
487
587
  describe('addBlock', () => {
@@ -15,6 +15,17 @@ type Validator = {
15
15
  formatMessage: Function;
16
16
  };
17
17
 
18
+ type Choice = {
19
+ token: string;
20
+ label: string;
21
+ };
22
+ type ChoiceValidator = {
23
+ value: string | Choice;
24
+ field: Record<string, any>;
25
+ formData: any;
26
+ formatMessage: Function;
27
+ };
28
+
18
29
  export const isMaxPropertyValid = ({
19
30
  value,
20
31
  fieldSpec,
@@ -211,12 +222,13 @@ export const defaultLanguageControlPanelValidator = ({
211
222
  value,
212
223
  formData,
213
224
  formatMessage,
214
- }: Validator) => {
225
+ }: ChoiceValidator) => {
226
+ const token = typeof value === 'object' ? value.token : value;
215
227
  const isValid =
216
- value &&
228
+ token &&
217
229
  (formData.available_languages.find(
218
- (lang: { token: string }) => lang.token === value,
230
+ (lang: { token: string }) => lang.token === token,
219
231
  ) ||
220
- formData.available_languages.includes(value));
232
+ formData.available_languages.includes(token));
221
233
  return !isValid ? formatMessage(messages.defaultLanguage) : null;
222
234
  };
@@ -1,8 +1,9 @@
1
1
  export function getProjection(items: any, activeId: any, overId: any, dragOffset: any, indentationWidth: any, arrayMove: any): {
2
+ parentId: any;
3
+ parentType: any;
2
4
  depth: any;
3
5
  maxDepth: any;
4
6
  minDepth: any;
5
- parentId: any;
6
7
  };
7
8
  export function flattenTree(items: any): any;
8
9
  export function findItem(items: any, itemId: any): any;
@@ -1,2 +1,2 @@
1
- export default ConnectionRefused;
2
- declare function ConnectionRefused(): import("react/jsx-runtime").JSX.Element;
1
+ declare const _default: (props: any) => import("react/jsx-runtime").JSX.Element;
2
+ export default _default;
@@ -1,2 +1,6 @@
1
- declare const _default: any;
2
- export default _default;
1
+ export default PasswordReset;
2
+ /**
3
+ * @function PasswordReset
4
+ * @returns {JSX.Element}
5
+ */
6
+ declare function PasswordReset(): JSX.Element;
@@ -42,7 +42,7 @@ export const errorViews: {
42
42
  403: (props: any) => import("react/jsx-runtime").JSX.Element;
43
43
  408: () => string;
44
44
  500: (props: any) => import("react/jsx-runtime").JSX.Element;
45
- ECONNREFUSED: () => import("react/jsx-runtime").JSX.Element;
45
+ ECONNREFUSED: (props: any) => import("react/jsx-runtime").JSX.Element;
46
46
  corsError: () => string;
47
47
  };
48
48
  export namespace layoutViewsNamesMapping {
@@ -176,6 +176,7 @@ export function findBlocks(blocks: {}, types: any, result?: any[]): any[];
176
176
  */
177
177
  export function moveBlockEnhanced(formData: any, { source, destination }: number): any;
178
178
  export function getBlocks(properties: any): any[];
179
+ export function getInvalidBlockLayoutIds(properties: any): string[];
179
180
  export function applyBlockInitialValue({ id, value, blocksConfig, formData, intl, }: {
180
181
  id: any;
181
182
  value: any;
@@ -193,3 +194,6 @@ export function getBlocksHierarchy(properties: any): any;
193
194
  export function findContainer(formData: object, { containerId }: {
194
195
  containerId: string;
195
196
  }): object | undefined;
197
+ export function findParent(formData: object, { blockId }: {
198
+ blockId: string;
199
+ }): object | undefined;
@@ -10,6 +10,16 @@ type Validator = {
10
10
  formData: any;
11
11
  formatMessage: Function;
12
12
  };
13
+ type Choice = {
14
+ token: string;
15
+ label: string;
16
+ };
17
+ type ChoiceValidator = {
18
+ value: string | Choice;
19
+ field: Record<string, any>;
20
+ formData: any;
21
+ formatMessage: Function;
22
+ };
13
23
  export declare const isMaxPropertyValid: ({ value, fieldSpec, criterion, formatMessage, }: MinMaxValidator) => any;
14
24
  export declare const isMinPropertyValid: ({ value, fieldSpec, criterion, formatMessage, }: MinMaxValidator) => any;
15
25
  export declare const minLengthValidator: ({ value, field, formatMessage, }: Validator) => any;
@@ -26,5 +36,5 @@ export declare const endEventDateRangeValidator: ({ value, field, formData, form
26
36
  export declare const patternValidator: ({ value, field, formatMessage, }: Validator) => any;
27
37
  export declare const maxItemsValidator: ({ value, field, formatMessage, }: Validator) => any;
28
38
  export declare const minItemsValidator: ({ value, field, formatMessage, }: Validator) => any;
29
- export declare const defaultLanguageControlPanelValidator: ({ value, formData, formatMessage, }: Validator) => any;
39
+ export declare const defaultLanguageControlPanelValidator: ({ value, formData, formatMessage, }: ChoiceValidator) => any;
30
40
  export {};
package/types/routes.d.ts CHANGED
@@ -12,22 +12,23 @@ export const multilingualRoutes: ({
12
12
  exact?: undefined;
13
13
  } | {
14
14
  path: string;
15
- component: any;
15
+ component: () => import("react/jsx-runtime").JSX.Element;
16
16
  exact: boolean;
17
17
  })[];
18
18
  export const defaultRoutes: ({
19
19
  path: string;
20
20
  component: any;
21
21
  exact?: undefined;
22
+ } | {
23
+ component: (props: any) => import("react/jsx-runtime").JSX.Element;
22
24
  } | {
23
25
  path: string;
24
26
  component: any;
25
27
  exact: boolean;
26
- } | {
27
- component: (props: any) => import("react/jsx-runtime").JSX.Element;
28
28
  } | {
29
29
  path: string[];
30
30
  component: any;
31
+ exact?: undefined;
31
32
  })[];
32
33
  export default routes;
33
34
  /**
@@ -46,14 +47,15 @@ declare const routes: {
46
47
  path: string;
47
48
  component: any;
48
49
  exact?: undefined;
50
+ } | {
51
+ component: (props: any) => import("react/jsx-runtime").JSX.Element;
49
52
  } | {
50
53
  path: string;
51
54
  component: any;
52
55
  exact: boolean;
53
- } | {
54
- component: (props: any) => import("react/jsx-runtime").JSX.Element;
55
56
  } | {
56
57
  path: string[];
57
58
  component: any;
59
+ exact?: undefined;
58
60
  })[];
59
61
  }[];