@plone/volto 19.0.0-alpha.9 → 19.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (527) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc +26 -15
  3. package/AGENTS.md +47 -0
  4. package/CHANGELOG.md +525 -12
  5. package/README.md +22 -19
  6. package/babel.js +1 -9
  7. package/cypress/support/guillotina.js +1 -0
  8. package/cypress.config.js +1 -0
  9. package/global-test-setup.js +1 -2
  10. package/locales/af/LC_MESSAGES/volto.po +5516 -0
  11. package/locales/af.json +1 -1
  12. package/locales/ar/LC_MESSAGES/volto.po +5516 -0
  13. package/locales/ar.json +1 -1
  14. package/locales/bg/LC_MESSAGES/volto.po +5516 -0
  15. package/locales/bg.json +1 -1
  16. package/locales/bn/LC_MESSAGES/volto.po +5516 -0
  17. package/locales/bn.json +1 -1
  18. package/locales/ca/LC_MESSAGES/volto.po +546 -354
  19. package/locales/ca.json +1 -1
  20. package/locales/cs/LC_MESSAGES/volto.po +5516 -0
  21. package/locales/cs.json +1 -1
  22. package/locales/cy/LC_MESSAGES/volto.po +5516 -0
  23. package/locales/cy.json +1 -1
  24. package/locales/da/LC_MESSAGES/volto.po +5516 -0
  25. package/locales/da.json +1 -1
  26. package/locales/de/LC_MESSAGES/volto.po +217 -24
  27. package/locales/de.json +1 -1
  28. package/locales/el/LC_MESSAGES/volto.po +5516 -0
  29. package/locales/el.json +1 -1
  30. package/locales/en/LC_MESSAGES/volto.po +206 -10
  31. package/locales/en.json +1 -1
  32. package/locales/en_AU/LC_MESSAGES/volto.po +5516 -0
  33. package/locales/en_AU.json +1 -1
  34. package/locales/en_GB/LC_MESSAGES/volto.po +5516 -0
  35. package/locales/en_GB.json +1 -1
  36. package/locales/eo/LC_MESSAGES/volto.po +5516 -0
  37. package/locales/eo.json +1 -1
  38. package/locales/es/LC_MESSAGES/volto.po +331 -140
  39. package/locales/es.json +1 -1
  40. package/locales/et/LC_MESSAGES/volto.po +5516 -0
  41. package/locales/et.json +1 -1
  42. package/locales/eu/LC_MESSAGES/volto.po +408 -217
  43. package/locales/eu.json +1 -1
  44. package/locales/fa/LC_MESSAGES/volto.po +5516 -0
  45. package/locales/fa.json +1 -1
  46. package/locales/fi/LC_MESSAGES/volto.po +207 -15
  47. package/locales/fi.json +1 -1
  48. package/locales/fr/LC_MESSAGES/volto.po +364 -173
  49. package/locales/fr.json +1 -1
  50. package/locales/fu/LC_MESSAGES/volto.po +5516 -0
  51. package/locales/fu.json +1 -1
  52. package/locales/gl/LC_MESSAGES/volto.po +5516 -0
  53. package/locales/gl.json +1 -1
  54. package/locales/he/LC_MESSAGES/volto.po +5516 -0
  55. package/locales/he.json +1 -1
  56. package/locales/hi/LC_MESSAGES/volto.po +215 -18
  57. package/locales/hi.json +1 -1
  58. package/locales/hr/LC_MESSAGES/volto.po +5516 -0
  59. package/locales/hr.json +1 -1
  60. package/locales/hu/LC_MESSAGES/volto.po +5516 -0
  61. package/locales/hu.json +1 -1
  62. package/locales/hy/LC_MESSAGES/volto.po +5516 -0
  63. package/locales/hy.json +1 -1
  64. package/locales/id/LC_MESSAGES/volto.po +5516 -0
  65. package/locales/id.json +1 -1
  66. package/locales/it/LC_MESSAGES/volto.po +231 -34
  67. package/locales/it.json +1 -1
  68. package/locales/ja/LC_MESSAGES/volto.po +249 -56
  69. package/locales/ja.json +1 -1
  70. package/locales/ka/LC_MESSAGES/volto.po +5516 -0
  71. package/locales/ka.json +1 -1
  72. package/locales/kn/LC_MESSAGES/volto.po +5516 -0
  73. package/locales/kn.json +1 -1
  74. package/locales/ko/LC_MESSAGES/volto.po +5516 -0
  75. package/locales/ko.json +1 -1
  76. package/locales/lt/LC_MESSAGES/volto.po +5516 -0
  77. package/locales/lt.json +1 -1
  78. package/locales/lv/LC_MESSAGES/volto.po +5516 -0
  79. package/locales/lv.json +1 -1
  80. package/locales/mi/LC_MESSAGES/volto.po +5516 -0
  81. package/locales/mi.json +1 -1
  82. package/locales/mk/LC_MESSAGES/volto.po +5516 -0
  83. package/locales/mk.json +1 -1
  84. package/locales/my/LC_MESSAGES/volto.po +5516 -0
  85. package/locales/my.json +1 -1
  86. package/locales/nb_NO/LC_MESSAGES/volto.po +5516 -0
  87. package/locales/nb_NO.json +1 -1
  88. package/locales/nl/LC_MESSAGES/volto.po +259 -66
  89. package/locales/nl.json +1 -1
  90. package/locales/nn/LC_MESSAGES/volto.po +5516 -0
  91. package/locales/nn.json +1 -1
  92. package/locales/pl/LC_MESSAGES/volto.po +5516 -0
  93. package/locales/pl.json +1 -1
  94. package/locales/pt/LC_MESSAGES/volto.po +858 -666
  95. package/locales/pt.json +1 -1
  96. package/locales/pt_BR/LC_MESSAGES/volto.po +211 -20
  97. package/locales/pt_BR.json +1 -1
  98. package/locales/rm/LC_MESSAGES/volto.po +5516 -0
  99. package/locales/rm.json +1 -1
  100. package/locales/ro/LC_MESSAGES/volto.po +243 -52
  101. package/locales/ro.json +1 -1
  102. package/locales/ru/LC_MESSAGES/volto.po +206 -14
  103. package/locales/ru.json +1 -1
  104. package/locales/sk/LC_MESSAGES/volto.po +5516 -0
  105. package/locales/sk.json +1 -1
  106. package/locales/sl/LC_MESSAGES/volto.po +5516 -0
  107. package/locales/sl.json +1 -1
  108. package/locales/sm/LC_MESSAGES/volto.po +5516 -0
  109. package/locales/sm.json +1 -1
  110. package/locales/sq/LC_MESSAGES/volto.po +5516 -0
  111. package/locales/sq.json +1 -1
  112. package/locales/sr/LC_MESSAGES/volto.po +5516 -0
  113. package/locales/sr.json +1 -1
  114. package/locales/sr@cyrl/LC_MESSAGES/volto.po +5516 -0
  115. package/locales/sr@cyrl.json +1 -1
  116. package/locales/sr@latn/LC_MESSAGES/volto.po +5516 -0
  117. package/locales/sr@latn.json +1 -1
  118. package/locales/sv/LC_MESSAGES/volto.po +5516 -0
  119. package/locales/sv.json +1 -1
  120. package/locales/ta/LC_MESSAGES/volto.po +5516 -0
  121. package/locales/ta.json +1 -1
  122. package/locales/te/LC_MESSAGES/volto.po +5516 -0
  123. package/locales/te.json +1 -1
  124. package/locales/th/LC_MESSAGES/volto.po +5516 -0
  125. package/locales/th.json +1 -1
  126. package/locales/to/LC_MESSAGES/volto.po +5516 -0
  127. package/locales/to.json +1 -1
  128. package/locales/tr/LC_MESSAGES/volto.po +5516 -0
  129. package/locales/tr.json +1 -1
  130. package/locales/uk/LC_MESSAGES/volto.po +5516 -0
  131. package/locales/uk.json +1 -1
  132. package/locales/vi/LC_MESSAGES/volto.po +5516 -0
  133. package/locales/vi.json +1 -1
  134. package/locales/volto.pot +200 -9
  135. package/locales/zh_CN/LC_MESSAGES/volto.po +206 -14
  136. package/locales/zh_CN.json +1 -1
  137. package/locales/zh_Hant/LC_MESSAGES/volto.po +5516 -0
  138. package/locales/zh_Hant.json +1 -1
  139. package/locales/zh_Hant_HK/LC_MESSAGES/volto.po +5516 -0
  140. package/locales/zh_Hant_HK.json +1 -1
  141. package/package.json +69 -146
  142. package/razzle.config.js +16 -25
  143. package/src/actions/blockTypes/blockTypes.ts +24 -0
  144. package/src/actions/controlpanels/controlpanels.js +7 -12
  145. package/src/actions/controlpanels/controlpanels.test.js +2 -3
  146. package/src/components/manage/Actions/Actions.test.jsx +1 -5
  147. package/src/components/manage/Add/Add.jsx +15 -10
  148. package/src/components/manage/Add/Add.test.jsx +10 -3
  149. package/src/components/manage/Aliases/Aliases.test.jsx +5 -2
  150. package/src/components/manage/BlockChooser/BlockChooser.jsx +8 -10
  151. package/src/components/manage/Blocks/Block/BlocksForm.jsx +10 -7
  152. package/src/components/manage/Blocks/Block/BlocksForm.test.jsx +3 -14
  153. package/src/components/manage/Blocks/Block/Edit.jsx +19 -10
  154. package/src/components/manage/Blocks/Block/Order/Item.jsx +33 -14
  155. package/src/components/manage/Blocks/Block/Order/Item.test.jsx +90 -0
  156. package/src/components/manage/Blocks/Block/Order/Order.jsx +116 -67
  157. package/src/components/manage/Blocks/Block/Order/utilities.js +28 -11
  158. package/src/components/manage/Blocks/Block/Settings.test.jsx +1 -5
  159. package/src/components/manage/Blocks/Grid/View.jsx +14 -11
  160. package/src/components/manage/Blocks/Grid/context.js +3 -0
  161. package/src/components/manage/Blocks/HTML/Edit.test.jsx +1 -5
  162. package/src/components/manage/Blocks/Image/ImageSidebar.test.jsx +2 -5
  163. package/src/components/manage/Blocks/LeadImage/LeadImageSidebar.test.jsx +2 -5
  164. package/src/components/manage/Blocks/Listing/Edit.jsx +1 -0
  165. package/src/components/manage/Blocks/Listing/ListingBody.jsx +4 -0
  166. package/src/components/manage/Blocks/Maps/MapsSidebar.test.jsx +1 -5
  167. package/src/components/manage/Blocks/Search/components/DateRangeFacet.test.jsx +1 -6
  168. package/src/components/manage/Blocks/Search/components/SelectFacet.jsx +22 -1
  169. package/src/components/manage/Blocks/Search/components/SelectFacet.test.jsx +1 -6
  170. package/src/components/manage/Blocks/Search/components/SortOn.jsx +8 -2
  171. package/src/components/manage/Blocks/Search/components/ToggleFacet.jsx +14 -0
  172. package/src/components/manage/Blocks/Teaser/DefaultBody.jsx +10 -2
  173. package/src/components/manage/Blocks/Teaser/View.jsx +0 -1
  174. package/src/components/manage/Blocks/Teaser/utils.js +13 -0
  175. package/src/components/manage/Blocks/Teaser/utils.test.js +34 -0
  176. package/src/components/manage/Blocks/Title/Edit.jsx +5 -0
  177. package/src/components/manage/Blocks/Video/Body.jsx +69 -43
  178. package/src/components/manage/Blocks/Video/Body.test.jsx +122 -5
  179. package/src/components/manage/Blocks/Video/Edit.jsx +20 -2
  180. package/src/components/manage/Blocks/Video/Edit.test.jsx +6 -0
  181. package/src/components/manage/Blocks/Video/VideoSidebar.test.jsx +1 -5
  182. package/src/components/manage/Blocks/Video/View.jsx +1 -0
  183. package/src/components/manage/Blocks/Video/View.test.jsx +29 -15
  184. package/src/components/manage/Blocks/Video/schema.js +14 -1
  185. package/src/components/manage/Contents/Contents.jsx +854 -747
  186. package/src/components/manage/Contents/Contents.test.jsx +9 -10
  187. package/src/components/manage/Contents/ContentsBreadcrumbs.jsx +4 -3
  188. package/src/components/manage/Contents/ContentsIndexHeader.jsx +47 -81
  189. package/src/components/manage/Contents/ContentsIndexHeader.test.jsx +10 -3
  190. package/src/components/manage/Contents/ContentsItem.jsx +226 -278
  191. package/src/components/manage/Contents/ContentsItem.test.jsx +10 -6
  192. package/src/components/manage/Contents/ContentsPropertiesModal.test.jsx +1 -5
  193. package/src/components/manage/Contents/ContentsRenameModal.test.jsx +1 -5
  194. package/src/components/manage/Contents/ContentsTagsModal.test.jsx +1 -5
  195. package/src/components/manage/Contents/ContentsWorkflowModal.test.jsx +1 -5
  196. package/src/components/manage/Contents/DropZoneContent.jsx +339 -0
  197. package/src/components/manage/Contents/__mocks__/index.tsx +2 -18
  198. package/src/components/manage/Controlpanels/AddonsControlpanel.jsx +7 -0
  199. package/src/components/manage/Controlpanels/AddonsControlpanel.test.jsx +7 -4
  200. package/src/components/manage/Controlpanels/Aliases.test.jsx +8 -9
  201. package/src/components/manage/Controlpanels/BlockType.tsx +165 -0
  202. package/src/components/manage/Controlpanels/BlockTypes.tsx +145 -0
  203. package/src/components/manage/Controlpanels/ContentType.jsx +131 -222
  204. package/src/components/manage/Controlpanels/ContentType.test.jsx +13 -14
  205. package/src/components/manage/Controlpanels/ContentTypeLayout.test.jsx +12 -9
  206. package/src/components/manage/Controlpanels/ContentTypeSchema.jsx +1 -1
  207. package/src/components/manage/Controlpanels/ContentTypes.jsx +9 -2
  208. package/src/components/manage/Controlpanels/ContentTypes.test.jsx +7 -4
  209. package/src/components/manage/Controlpanels/Controlpanel.jsx +122 -218
  210. package/src/components/manage/Controlpanels/Controlpanel.test.jsx +8 -33
  211. package/src/components/manage/Controlpanels/Controlpanels.jsx +28 -5
  212. package/src/components/manage/Controlpanels/Controlpanels.test.jsx +23 -8
  213. package/src/components/manage/Controlpanels/DatabaseInformation.jsx +9 -0
  214. package/src/components/manage/Controlpanels/Groups/GroupsControlpanel.test.jsx +7 -4
  215. package/src/components/manage/Controlpanels/ModerateComments.jsx +8 -0
  216. package/src/components/manage/Controlpanels/ModerateComments.test.jsx +7 -4
  217. package/src/components/manage/Controlpanels/Relations/Relations.jsx +1 -1
  218. package/src/components/manage/Controlpanels/Rules/AddRule.test.jsx +8 -9
  219. package/src/components/manage/Controlpanels/Rules/ConfigureRule.test.jsx +9 -6
  220. package/src/components/manage/Controlpanels/Rules/EditRule.test.jsx +8 -9
  221. package/src/components/manage/Controlpanels/Rules/Rules.test.jsx +7 -4
  222. package/src/components/manage/Controlpanels/UndoControlpanel.test.jsx +8 -9
  223. package/src/components/manage/Controlpanels/Users/UserGroupMembershipControlPanel.test.jsx +10 -4
  224. package/src/components/manage/Controlpanels/Users/UsersControlpanel.jsx +628 -631
  225. package/src/components/manage/Controlpanels/Users/UsersControlpanel.ssr.test.jsx +624 -0
  226. package/src/components/manage/Controlpanels/Users/UsersControlpanel.test.jsx +70 -10
  227. package/src/components/manage/Delete/Delete.test.jsx +13 -8
  228. package/src/components/manage/Diff/Diff.jsx +201 -298
  229. package/src/components/manage/Diff/Diff.test.jsx +8 -10
  230. package/src/components/manage/Diff/DiffField.test.jsx +1 -6
  231. package/src/components/manage/Display/Display.test.jsx +2 -11
  232. package/src/components/manage/Edit/Edit.test.jsx +12 -11
  233. package/src/components/manage/Form/BlockDataForm.test.jsx +1 -5
  234. package/src/components/manage/Form/Field.jsx +1 -69
  235. package/src/components/manage/Form/Form.jsx +17 -4
  236. package/src/components/manage/Form/Form.test.jsx +130 -5
  237. package/src/components/manage/Form/InlineForm.test.jsx +1 -5
  238. package/src/components/manage/Form/ModalForm.jsx +175 -97
  239. package/src/components/manage/Form/ModalForm.test.jsx +27 -5
  240. package/src/components/manage/Form/__mocks__/index.tsx +9 -27
  241. package/src/components/manage/History/History.test.jsx +15 -8
  242. package/src/components/manage/LinksToItem/LinksToItem.test.jsx +7 -4
  243. package/src/components/manage/Multilingual/CompareLanguages.jsx +6 -6
  244. package/src/components/manage/Multilingual/CreateTranslation.jsx +16 -13
  245. package/src/components/manage/Multilingual/ManageTranslations.jsx +5 -5
  246. package/src/components/manage/Multilingual/ManageTranslations.test.jsx +15 -12
  247. package/src/components/manage/Multilingual/TranslationObject.jsx +11 -8
  248. package/src/components/manage/Preferences/ChangePassword.test.jsx +8 -9
  249. package/src/components/manage/Preferences/PersonalPreferences.jsx +8 -5
  250. package/src/components/manage/Preferences/PersonalPreferences.test.jsx +10 -23
  251. package/src/components/manage/Rules/Rules.test.jsx +5 -2
  252. package/src/components/manage/Sharing/Sharing.jsx +21 -15
  253. package/src/components/manage/Sharing/Sharing.test.jsx +9 -6
  254. package/src/components/manage/Sidebar/ObjectBrowser.jsx +10 -0
  255. package/src/components/manage/Sidebar/ObjectBrowserBody.jsx +25 -5
  256. package/src/components/manage/Sidebar/ObjectBrowserBody.test.jsx +52 -0
  257. package/src/components/manage/Sidebar/Sidebar.jsx +2 -0
  258. package/src/components/manage/Sidebar/Sidebar.test.jsx +4 -1
  259. package/src/components/manage/Sidebar/SidebarPortal.test.tsx +42 -0
  260. package/src/components/manage/Sidebar/SidebarPortal.tsx +48 -0
  261. package/src/components/manage/TemplateChooser/TemplateChooser.test.jsx +1 -0
  262. package/src/components/manage/Toast/Toast.jsx +32 -0
  263. package/src/components/manage/Toast/Toast.test.jsx +9 -5
  264. package/src/components/manage/Toolbar/PersonalTools.test.jsx +15 -0
  265. package/src/components/manage/Toolbar/Toolbar.jsx +103 -11
  266. package/src/components/manage/Toolbar/Toolbar.test.jsx +15 -10
  267. package/src/components/manage/Toolbar/Types.crash.test.jsx +48 -0
  268. package/src/components/manage/Toolbar/Types.jsx +6 -4
  269. package/src/components/manage/UniversalLink/UniversalLink.test.jsx +16 -0
  270. package/src/components/manage/UniversalLink/UniversalLink.tsx +1 -0
  271. package/src/components/manage/Widgets/AlignWidget.stories.jsx +9 -0
  272. package/src/components/manage/Widgets/AlignWidget.test.tsx +95 -0
  273. package/src/components/manage/Widgets/{AlignWidget.jsx → AlignWidget.tsx} +23 -7
  274. package/src/components/manage/Widgets/ArrayWidget.jsx +111 -88
  275. package/src/components/manage/Widgets/ArrayWidget.test.jsx +1 -12
  276. package/src/components/manage/Widgets/BlockAlignment.stories.tsx +104 -0
  277. package/src/components/manage/Widgets/BlockAlignment.test.tsx +104 -0
  278. package/src/components/manage/Widgets/BlockAlignment.tsx +88 -0
  279. package/src/components/manage/Widgets/BlockWidth.stories.tsx +69 -0
  280. package/src/components/manage/Widgets/BlockWidth.test.tsx +62 -0
  281. package/src/components/manage/Widgets/BlockWidth.tsx +101 -0
  282. package/src/components/manage/Widgets/ButtonsWidget.stories.jsx +61 -0
  283. package/src/components/manage/Widgets/ButtonsWidget.test.tsx +138 -0
  284. package/src/components/manage/Widgets/ButtonsWidget.tsx +195 -0
  285. package/src/components/manage/Widgets/CheckboxGroupWidget.test.jsx +1 -6
  286. package/src/components/manage/Widgets/DatetimeWidget.jsx +98 -54
  287. package/src/components/manage/Widgets/DatetimeWidget.test.jsx +56 -6
  288. package/src/components/manage/Widgets/FileWidget.jsx +7 -0
  289. package/src/components/manage/Widgets/FormFieldWrapper.jsx +143 -163
  290. package/src/components/manage/Widgets/ImageWidget.jsx +18 -5
  291. package/src/components/manage/Widgets/ObjectBrowserWidget.jsx +6 -0
  292. package/src/components/manage/Widgets/ObjectListWidget.test.jsx +2 -11
  293. package/src/components/manage/Widgets/ObjectWidget.test.jsx +1 -5
  294. package/src/components/manage/Widgets/QueryWidget.jsx +137 -9
  295. package/src/components/manage/Widgets/QuerystringWidget.test.jsx +3 -1
  296. package/src/components/manage/Widgets/RadioGroupWidget.test.jsx +1 -6
  297. package/src/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.test.jsx +1 -6
  298. package/src/components/manage/Widgets/RecurrenceWidget/WeekdayOfTheMonthIndexField.jsx +56 -50
  299. package/src/components/manage/Widgets/RegistryImageWidget.jsx +1 -1
  300. package/src/components/manage/Widgets/RegistryImageWidget.test.jsx +1 -0
  301. package/src/components/manage/Widgets/SchemaWidget.test.jsx +1 -6
  302. package/src/components/manage/Widgets/SchemaWidgetFieldset.test.jsx +1 -6
  303. package/src/components/manage/Widgets/SelectAutoComplete.test.jsx +1 -6
  304. package/src/components/manage/Widgets/SelectStyling.jsx +52 -20
  305. package/src/components/manage/Widgets/SelectWidget.test.jsx +1 -6
  306. package/src/components/manage/Widgets/Size.stories.tsx +69 -0
  307. package/src/components/manage/Widgets/Size.test.tsx +59 -0
  308. package/src/components/manage/Widgets/Size.tsx +78 -0
  309. package/src/components/manage/Widgets/TextWidget.jsx +4 -0
  310. package/src/components/manage/Widgets/TimeWidget.test.jsx +1 -6
  311. package/src/components/manage/Widgets/TokenWidget.jsx +142 -186
  312. package/src/components/manage/Widgets/TokenWidget.test.jsx +1 -6
  313. package/src/components/manage/Widgets/UrlWidget.jsx +47 -18
  314. package/src/components/manage/Widgets/VocabularyTermsWidget.test.jsx +2 -11
  315. package/src/components/manage/Widgets/__mocks__/index.tsx +33 -51
  316. package/src/components/manage/Widgets/index.tsx +21 -0
  317. package/src/components/manage/Workflow/Workflow.test.jsx +2 -11
  318. package/src/components/theme/AlternateHrefLangs/AlternateHrefLangs.jsx +1 -0
  319. package/src/components/theme/AlternateHrefLangs/AlternateHrefLangs.test.jsx +30 -0
  320. package/src/components/theme/App/App.jsx +5 -1
  321. package/src/components/theme/App/App.test.jsx +13 -10
  322. package/src/components/theme/Comments/CommentEditModal.test.jsx +1 -5
  323. package/src/components/theme/Comments/Comments.test.jsx +2 -11
  324. package/src/components/theme/ConnectionRefused/ConnectionRefused.jsx +3 -2
  325. package/src/components/theme/ContactForm/ContactForm.test.jsx +14 -13
  326. package/src/components/theme/Image/Image.jsx +14 -5
  327. package/src/components/theme/Image/Image.test.jsx +247 -146
  328. package/src/components/theme/InjectPloneComponentsCSS/InjectPloneComponentsCSS.tsx +7 -0
  329. package/src/components/theme/LanguageSelector/LanguageSelector.tsx +3 -3
  330. package/src/components/theme/MultilingualRedirector/MultilingualRedirector.jsx +42 -12
  331. package/src/components/theme/MultilingualRedirector/MultilingualRedirector.test.jsx +6 -3
  332. package/src/components/theme/PasswordReset/PasswordReset.jsx +108 -191
  333. package/src/components/theme/PasswordReset/RequestPasswordReset.test.jsx +1 -5
  334. package/src/components/theme/Register/Register.test.jsx +1 -5
  335. package/src/components/theme/Search/Search.jsx +230 -327
  336. package/src/components/theme/Search/Search.test.jsx +14 -14
  337. package/src/components/theme/Sitemap/Sitemap.jsx +22 -30
  338. package/src/components/theme/Sitemap/Sitemap.stories.jsx +82 -0
  339. package/src/components/theme/Sitemap/Sitemap.test.jsx +18 -0
  340. package/src/components/theme/SlotRenderer/SlotRenderer.tsx +12 -6
  341. package/src/components/theme/Unauthorized/Unauthorized.jsx +27 -24
  342. package/src/components/theme/Unauthorized/Unauthorized.test.jsx +31 -2
  343. package/src/components/theme/VideoEmbed/VideoEmbed.jsx +100 -0
  344. package/src/components/theme/View/EventDatesInfo.test.jsx +1 -6
  345. package/src/components/theme/View/EventView.stories.jsx +89 -0
  346. package/src/components/theme/View/EventView.test.jsx +1 -6
  347. package/src/components/theme/View/FileView.stories.jsx +50 -0
  348. package/src/components/theme/View/ImageView.jsx +2 -1
  349. package/src/components/theme/View/ImageView.test.jsx +3 -0
  350. package/src/components/theme/View/LinkView.stories.jsx +57 -0
  351. package/src/components/theme/View/ListingView.stories.jsx +70 -0
  352. package/src/components/theme/View/NewsItemView.stories.jsx +58 -0
  353. package/src/components/theme/View/RenderBlocks.jsx +8 -10
  354. package/src/components/theme/View/RenderBlocks.stories.jsx +112 -0
  355. package/src/components/theme/View/RenderBlocks.test.jsx +14 -4
  356. package/src/components/theme/View/SummaryView.stories.jsx +71 -0
  357. package/src/components/theme/View/TabularView.stories.jsx +66 -0
  358. package/src/components/theme/View/View.jsx +8 -1
  359. package/src/components/theme/View/View.test.jsx +37 -24
  360. package/src/components/theme/Widgets/DateWidget.jsx +4 -5
  361. package/src/components/theme/Widgets/DatetimeWidget.jsx +4 -5
  362. package/src/components/theme/Widgets/ImageWidget.test.jsx +31 -11
  363. package/src/components/theme/Widgets/RichTextWidget.jsx +1 -1
  364. package/src/config/Blocks.jsx +3 -0
  365. package/src/config/ControlPanels.js +2 -0
  366. package/src/config/Loadables.jsx +1 -5
  367. package/src/config/Widgets.jsx +7 -0
  368. package/src/config/index.js +10 -1
  369. package/src/config/slots.js +19 -0
  370. package/src/config/validation.ts +8 -0
  371. package/src/constants/ActionTypes.js +1 -0
  372. package/src/express-middleware/devproxy.js +3 -1
  373. package/src/express-middleware/files.js +1 -0
  374. package/src/express-middleware/files.test.js +59 -0
  375. package/src/express-middleware/images.js +1 -0
  376. package/src/express-middleware/images.test.js +50 -0
  377. package/src/helpers/Api/Api.js +2 -2
  378. package/src/helpers/AuthToken/AuthToken.js +1 -6
  379. package/src/helpers/Blocks/Blocks.js +113 -28
  380. package/src/helpers/Blocks/Blocks.test.js +100 -0
  381. package/src/helpers/Content/Content.js +23 -0
  382. package/src/helpers/Content/Content.test.js +39 -0
  383. package/src/helpers/Extensions/withBlockSchemaEnhancer.jsx +4 -1
  384. package/src/helpers/FormValidation/FormValidation.test.js +31 -0
  385. package/src/helpers/FormValidation/validators.ts +52 -6
  386. package/src/helpers/I18n/I18n.test.ts +44 -0
  387. package/src/helpers/I18n/I18n.ts +31 -0
  388. package/src/helpers/Loadable/__mocks__/Loadable.jsx +7 -22
  389. package/src/helpers/MessageLabels/MessageLabels.js +5 -0
  390. package/src/helpers/Robots/Robots.js +1 -1
  391. package/src/helpers/Robots/Robots.test.js +34 -0
  392. package/src/helpers/Url/Url.js +1 -0
  393. package/src/helpers/Utils/Date.js +26 -1
  394. package/src/helpers/Utils/Date.test.js +237 -0
  395. package/src/helpers/Utils/Utils.jsx +17 -0
  396. package/src/helpers/Utils/Utils.test.jsx +39 -0
  397. package/src/helpers/Utils/withSaveAsDraft.jsx +33 -9
  398. package/src/helpers/index.js +1 -0
  399. package/src/hooks/user/useUser.js +1 -1
  400. package/src/internalChecks.test.ts +11 -0
  401. package/src/middleware/api.js +14 -5
  402. package/src/reducers/blockTypes/blockTypes.js +38 -0
  403. package/src/reducers/content/content.js +3 -18
  404. package/src/reducers/diff/diff.js +5 -1
  405. package/src/reducers/diff/diff.test.js +60 -4
  406. package/src/reducers/index.js +2 -0
  407. package/src/reducers/querystring/querystring.js +8 -1
  408. package/src/reducers/users/users.js +1 -1
  409. package/src/routes.js +10 -0
  410. package/src/server.jsx +14 -6
  411. package/src/start-client.jsx +21 -3
  412. package/test-addons-loader.js +3 -0
  413. package/test-setup-globals.js +56 -2
  414. package/theme/themes/default/elements/segment.variables +9 -16
  415. package/theme/themes/default/globals/site.variables +3 -3
  416. package/theme/themes/pastanaga/collections/form.overrides +22 -1
  417. package/theme/themes/pastanaga/elements/button.overrides +30 -3
  418. package/theme/themes/pastanaga/elements/segment.variables +1 -4
  419. package/theme/themes/pastanaga/extras/block-types.less +17 -0
  420. package/theme/themes/pastanaga/extras/contents.less +63 -4
  421. package/theme/themes/pastanaga/extras/main.less +16 -4
  422. package/theme/themes/pastanaga/extras/toolbar.less +10 -5
  423. package/theme/themes/pastanaga/extras/videoembed.less +22 -0
  424. package/theme/themes/pastanaga/extras/widgets.less +79 -0
  425. package/theme/themes/pastanaga/globals/site.variables +0 -3
  426. package/tsconfig.declarations.json +1 -1
  427. package/tsconfig.json +1 -1
  428. package/types/actions/blockTypes/blockTypes.d.ts +7 -0
  429. package/types/components/index.d.ts +1 -1
  430. package/types/components/manage/Blocks/Block/Order/Item.test.d.ts +1 -0
  431. package/types/components/manage/Blocks/Block/Order/utilities.d.ts +2 -1
  432. package/types/components/manage/Blocks/Grid/context.d.ts +1 -0
  433. package/types/components/manage/Blocks/Teaser/utils.d.ts +5 -0
  434. package/types/components/manage/Blocks/Video/Body.d.ts +4 -2
  435. package/types/components/manage/Blocks/Video/schema.d.ts +4 -0
  436. package/types/components/manage/Contents/Contents.d.ts +1 -1
  437. package/types/components/manage/Contents/ContentsIndexHeader.d.ts +6 -11
  438. package/types/components/manage/Contents/ContentsItem.d.ts +3 -10
  439. package/types/components/manage/Contents/DropZoneContent.d.ts +2 -0
  440. package/types/components/manage/Contents/__mocks__/index.d.ts +2 -2
  441. package/types/components/manage/Controlpanels/BlockType.d.ts +7 -0
  442. package/types/components/manage/Controlpanels/BlockTypes.d.ts +7 -0
  443. package/types/components/manage/Controlpanels/ContentType.d.ts +2 -2
  444. package/types/components/manage/Controlpanels/Controlpanel.d.ts +2 -5
  445. package/types/components/manage/Controlpanels/Relations/RelationsMatrix.d.ts +1 -1
  446. package/types/components/manage/Controlpanels/Users/UsersControlpanel.ssr.test.d.ts +1 -0
  447. package/types/components/manage/Controlpanels/index.d.ts +2 -2
  448. package/types/components/manage/Diff/Diff.d.ts +7 -2
  449. package/types/components/manage/Form/__mocks__/index.d.ts +8 -8
  450. package/types/components/manage/Multilingual/ManageTranslations.d.ts +1 -1
  451. package/types/components/manage/Sidebar/ObjectBrowser.d.ts +1 -1
  452. package/types/components/manage/Sidebar/ObjectBrowserBody.test.d.ts +1 -0
  453. package/types/components/manage/Sidebar/SidebarPortal.d.ts +7 -15
  454. package/types/components/manage/Toolbar/Types.crash.test.d.ts +1 -0
  455. package/types/components/manage/Widgets/AlignWidget.d.ts +8 -10
  456. package/types/components/manage/Widgets/AlignWidget.stories.d.ts +1 -0
  457. package/types/components/manage/Widgets/BlockAlignment.d.ts +7 -0
  458. package/types/components/manage/Widgets/BlockAlignment.stories.d.ts +8 -0
  459. package/types/components/manage/Widgets/BlockWidth.d.ts +7 -0
  460. package/types/components/manage/Widgets/BlockWidth.stories.d.ts +6 -0
  461. package/types/components/manage/Widgets/ButtonsWidget.d.ts +48 -1
  462. package/types/components/manage/Widgets/ButtonsWidget.stories.d.ts +3 -0
  463. package/types/components/manage/Widgets/FormFieldWrapper.d.ts +28 -5
  464. package/types/components/manage/Widgets/ImageWidget.d.ts +1 -1
  465. package/types/components/manage/Widgets/InternalUrlWidget.d.ts +1 -1
  466. package/types/components/manage/Widgets/ObjectBrowserWidget.d.ts +2 -0
  467. package/types/components/manage/Widgets/QueryWidget.d.ts +5 -2
  468. package/types/components/manage/Widgets/RecurrenceWidget/WeekdayOfTheMonthIndexField.d.ts +22 -5
  469. package/types/components/manage/Widgets/SelectStyling.d.ts +1 -0
  470. package/types/components/manage/Widgets/Size.d.ts +7 -0
  471. package/types/components/manage/Widgets/Size.stories.d.ts +6 -0
  472. package/types/components/manage/Widgets/UrlWidget.d.ts +1 -1
  473. package/types/components/manage/Widgets/__mocks__/index.d.ts +33 -33
  474. package/types/components/manage/Widgets/index.d.ts +11 -6
  475. package/types/components/theme/ConnectionRefused/ConnectionRefused.d.ts +2 -2
  476. package/types/components/theme/InjectPloneComponentsCSS/InjectPloneComponentsCSS.d.ts +3 -0
  477. package/types/components/theme/PasswordReset/PasswordReset.d.ts +6 -2
  478. package/types/components/theme/Search/Search.d.ts +1 -1
  479. package/types/components/theme/Sitemap/Sitemap.stories.d.ts +13 -0
  480. package/types/components/theme/SlotRenderer/SlotRenderer.d.ts +4 -5
  481. package/types/components/theme/Unauthorized/Unauthorized.d.ts +2 -2
  482. package/types/components/theme/VideoEmbed/VideoEmbed.d.ts +2 -0
  483. package/types/components/theme/View/EventView.stories.d.ts +19 -0
  484. package/types/components/theme/View/FileView.stories.d.ts +18 -0
  485. package/types/components/theme/View/LinkView.stories.d.ts +18 -0
  486. package/types/components/theme/View/ListingView.stories.d.ts +24 -0
  487. package/types/components/theme/View/NewsItemView.stories.d.ts +23 -0
  488. package/types/components/theme/View/RenderBlocks.stories.d.ts +23 -0
  489. package/types/components/theme/View/SummaryView.stories.d.ts +23 -0
  490. package/types/components/theme/View/TabularView.stories.d.ts +23 -0
  491. package/types/config/ControlPanels.d.ts +1 -0
  492. package/types/config/Views.d.ts +1 -1
  493. package/types/config/Widgets.d.ts +6 -0
  494. package/types/config/slots.d.ts +7 -0
  495. package/types/constants/ActionTypes.d.ts +1 -0
  496. package/types/helpers/Blocks/Blocks.d.ts +4 -0
  497. package/types/helpers/Content/Content.d.ts +7 -0
  498. package/types/helpers/Extensions/withBlockSchemaEnhancer.d.ts +4 -5
  499. package/types/helpers/FormValidation/validators.d.ts +18 -1
  500. package/types/helpers/I18n/I18n.d.ts +20 -0
  501. package/types/helpers/Loadable/__mocks__/Loadable.d.ts +2 -2
  502. package/types/helpers/MessageLabels/MessageLabels.d.ts +100 -94
  503. package/types/helpers/Utils/Utils.d.ts +1 -0
  504. package/types/helpers/index.d.ts +1 -0
  505. package/types/reducers/blockTypes/blockTypes.d.ts +16 -0
  506. package/types/reducers/index.d.ts +2 -0
  507. package/types/routes.d.ts +7 -5
  508. package/vitest.config.mjs +84 -42
  509. package/webpack-plugins/webpack-less-plugin.js +1 -1
  510. package/webpack-plugins/webpack-scss-plugin.js +172 -0
  511. package/jest-addons-loader.js +0 -3
  512. package/jest-extender-plugin.js +0 -39
  513. package/jest-setup-afterenv.js +0 -2
  514. package/jest-svgsystem-transform.js +0 -10
  515. package/patches/patchit.sh +0 -2
  516. package/patches/razzle-jest.patch +0 -10
  517. package/src/components/manage/Contents/__mocks__/index.vitest.tsx +0 -5
  518. package/src/components/manage/Form/__mocks__/index.vitest.tsx +0 -73
  519. package/src/components/manage/Sidebar/SidebarPortal.jsx +0 -47
  520. package/src/components/manage/Sidebar/SidebarPortal.test.jsx +0 -26
  521. package/src/components/manage/Widgets/AlignWidget.test.jsx +0 -59
  522. package/src/components/manage/Widgets/ButtonsWidget.jsx +0 -41
  523. package/src/components/manage/Widgets/ButtonsWidget.test.jsx +0 -70
  524. package/src/components/manage/Widgets/__mocks__/index.vitest.tsx +0 -41
  525. package/src/helpers/Loadable/__mocks__/Loadable.vitest.jsx +0 -39
  526. package/test-setup-globals-vitest.js +0 -46
  527. package/theme/themes/pastanaga/extras/utils.less +0 -63
@@ -29,6 +29,7 @@ import {
29
29
  SortableMultiValue,
30
30
  SortableMultiValueLabel,
31
31
  MultiValueContainer,
32
+ MultiValueRemove,
32
33
  } from '@plone/volto/components/manage/Widgets/SelectStyling';
33
34
 
34
35
  import FormFieldWrapper from '@plone/volto/components/manage/Widgets/FormFieldWrapper';
@@ -276,11 +277,11 @@ class ArrayWidget extends Component {
276
277
  render() {
277
278
  const choices = normalizeChoices(this.props?.choices || []);
278
279
  const selectedOption = normalizeArrayValue(choices, this.props.value);
280
+ const selectedIds = selectedOption.map((option) => option.value);
279
281
 
280
282
  const CreatableSelect = this.props.reactSelectCreateable.default;
281
- const { SortableContainer } = this.props.reactSortableHOC;
282
283
  const Select = this.props.reactSelect.default;
283
- const SortableSelect =
284
+ const SelectComponent =
284
285
  // It will be only creatable if the named vocabulary is in the widget definition
285
286
  // (hint) like:
286
287
  // list_field_voc_unconstrained = schema.List(
@@ -298,95 +299,112 @@ class ArrayWidget extends Component {
298
299
  this.props?.choices &&
299
300
  !getVocabFromHint(this.props) &&
300
301
  !this.props.creatable
301
- ? SortableContainer(Select)
302
- : SortableContainer(CreatableSelect);
302
+ ? Select
303
+ : CreatableSelect;
304
+ const { DndContext, closestCenter } = this.props.dndKitCore;
305
+ const { SortableContext, horizontalListSortingStrategy } =
306
+ this.props.dndKitSortable;
303
307
 
304
308
  return (
305
309
  <FormFieldWrapper {...this.props}>
306
- <SortableSelect
307
- useDragHandle
308
- // react-sortable-hoc props:
309
- axis="xy"
310
- onSortEnd={(sortProp) => {
311
- this.onSortEnd(selectedOption, sortProp);
312
- }}
313
- menuShouldScrollIntoView={false}
314
- distance={4}
315
- // small fix for https://github.com/clauderic/react-sortable-hoc/pull/352:
316
- getHelperDimensions={({ node }) => node.getBoundingClientRect()}
317
- id={`field-${this.props.id}`}
318
- aria-labelledby={`fieldset-${this.props.fieldSet}-field-label-${this.props.id}`}
319
- key={this.props.id}
320
- isDisabled={this.props.disabled || this.props.isDisabled}
321
- className="react-select-container"
322
- classNamePrefix="react-select"
323
- /* eslint-disable jsx-a11y/no-autofocus */
324
- autoFocus={this.props.focus}
325
- /* eslint-enable jsx-a11y/no-autofocus */
326
- options={
327
- this.props.vocabBaseUrl
328
- ? choices
329
- : this.props.choices
330
- ? [
331
- ...choices,
332
- ...(this.props.noValueOption &&
333
- (this.props.default === undefined ||
334
- this.props.default === null)
335
- ? [
336
- {
337
- label: this.props.intl.formatMessage(
338
- messages.no_value,
339
- ),
340
- value: 'no-value',
341
- },
342
- ]
343
- : []),
344
- ]
345
- : [
346
- {
347
- label: this.props.intl.formatMessage(messages.no_value),
348
- value: 'no-value',
349
- },
350
- ]
351
- }
352
- styles={customSelectStyles}
353
- theme={selectTheme}
354
- components={{
355
- ...(this.props.choices?.length > 25 && {
356
- MenuList,
357
- }),
358
- MultiValueContainer,
359
- MultiValue: SortableMultiValue,
360
- MultiValueLabel: SortableMultiValueLabel,
361
- DropdownIndicator,
362
- ClearIndicator,
363
- Option,
310
+ <DndContext
311
+ collisionDetection={closestCenter}
312
+ onDragEnd={({ active, over }) => {
313
+ if (!over || active.id === over.id) {
314
+ return;
315
+ }
316
+ const oldIndex = selectedIds.indexOf(active.id);
317
+ const newIndex = selectedIds.indexOf(over.id);
318
+ if (oldIndex < 0 || newIndex < 0) {
319
+ return;
320
+ }
321
+ this.onSortEnd(selectedOption, { oldIndex, newIndex });
364
322
  }}
365
- value={selectedOption || []}
366
- placeholder={
367
- this.props.placeholder ??
368
- this.props.intl.formatMessage(messages.select)
369
- }
370
- onChange={this.handleChange}
371
- isValidNewOption={(
372
- inputValue,
373
- selectValue,
374
- selectOptions,
375
- accessors,
376
- ) =>
377
- !(
378
- !inputValue ||
379
- selectValue.some((option) =>
380
- compareOption(inputValue, option, accessors),
381
- ) ||
382
- selectOptions.some((option) =>
383
- compareOption(inputValue, option, accessors),
384
- )
385
- )
386
- }
387
- isClearable
388
- isMulti
389
- />
323
+ >
324
+ <SortableContext
325
+ items={selectedIds}
326
+ strategy={horizontalListSortingStrategy}
327
+ >
328
+ <SelectComponent
329
+ menuShouldScrollIntoView={false}
330
+ id={`field-${this.props.id}`}
331
+ aria-labelledby={`fieldset-${this.props.fieldSet}-field-label-${this.props.id}`}
332
+ key={this.props.id}
333
+ isDisabled={this.props.disabled || this.props.isDisabled}
334
+ className="react-select-container"
335
+ classNamePrefix="react-select"
336
+ /* eslint-disable jsx-a11y/no-autofocus */
337
+ autoFocus={this.props.focus}
338
+ /* eslint-enable jsx-a11y/no-autofocus */
339
+ options={
340
+ this.props.vocabBaseUrl
341
+ ? choices
342
+ : this.props.choices
343
+ ? [
344
+ ...choices,
345
+ ...(this.props.noValueOption &&
346
+ (this.props.default === undefined ||
347
+ this.props.default === null)
348
+ ? [
349
+ {
350
+ label: this.props.intl.formatMessage(
351
+ messages.no_value,
352
+ ),
353
+ value: 'no-value',
354
+ },
355
+ ]
356
+ : []),
357
+ ]
358
+ : [
359
+ {
360
+ label: this.props.intl.formatMessage(
361
+ messages.no_value,
362
+ ),
363
+ value: 'no-value',
364
+ },
365
+ ]
366
+ }
367
+ styles={customSelectStyles}
368
+ theme={selectTheme}
369
+ components={{
370
+ ...(this.props.choices?.length > 25 && {
371
+ MenuList,
372
+ }),
373
+ MultiValueContainer,
374
+ MultiValue: SortableMultiValue,
375
+ MultiValueLabel: SortableMultiValueLabel,
376
+ MultiValueRemove,
377
+ DropdownIndicator,
378
+ ClearIndicator,
379
+ Option,
380
+ }}
381
+ value={selectedOption || []}
382
+ placeholder={
383
+ this.props.placeholder ??
384
+ this.props.intl.formatMessage(messages.select)
385
+ }
386
+ onChange={this.handleChange}
387
+ isValidNewOption={(
388
+ inputValue,
389
+ selectValue,
390
+ selectOptions,
391
+ accessors,
392
+ ) =>
393
+ !(
394
+ !inputValue ||
395
+ selectValue.some((option) =>
396
+ compareOption(inputValue, option, accessors),
397
+ ) ||
398
+ selectOptions.some((option) =>
399
+ compareOption(inputValue, option, accessors),
400
+ )
401
+ )
402
+ }
403
+ isClearable
404
+ isMulti
405
+ />
406
+ </SortableContext>
407
+ </DndContext>
390
408
  </FormFieldWrapper>
391
409
  );
392
410
  }
@@ -396,7 +414,12 @@ export const ArrayWidgetComponent = injectIntl(ArrayWidget);
396
414
 
397
415
  export default compose(
398
416
  injectIntl,
399
- injectLazyLibs(['reactSelect', 'reactSelectCreateable', 'reactSortableHOC']),
417
+ injectLazyLibs([
418
+ 'reactSelect',
419
+ 'reactSelectCreateable',
420
+ 'dndKitCore',
421
+ 'dndKitSortable',
422
+ ]),
400
423
  connect(
401
424
  (state, props) => {
402
425
  const vocabBaseUrl =
@@ -8,18 +8,7 @@ import ArrayWidget from './ArrayWidget';
8
8
 
9
9
  const mockStore = configureStore();
10
10
 
11
- vi.mock('@plone/volto/helpers/Loadable/Loadable', async () => {
12
- return await import(
13
- '@plone/volto/helpers/Loadable/__mocks__/Loadable.vitest.jsx'
14
- );
15
- });
16
-
17
- // Mock react-sortable-hoc to prevent the container error
18
- vi.mock('react-sortable-hoc', () => ({
19
- ...vi.importActual('react-sortable-hoc'),
20
- SortableContainer: (component) => component,
21
- SortableElement: (component) => component,
22
- }));
11
+ vi.mock('@plone/volto/helpers/Loadable/Loadable');
23
12
 
24
13
  beforeAll(async () => {
25
14
  const { __setLoadables } = await import(
@@ -0,0 +1,104 @@
1
+ import React from 'react';
2
+ import type { Meta, StoryFn, StoryObj } from '@storybook/react';
3
+
4
+ import BlockAlignment from './BlockAlignment';
5
+ import type { ButtonsWidgetProps } from './ButtonsWidget';
6
+ import {
7
+ RealStoreWrapper as Wrapper,
8
+ FormUndoWrapper,
9
+ } from '@plone/volto/storybook';
10
+
11
+ const meta: Meta<typeof BlockAlignment> = {
12
+ title: 'Edit Widgets/BlockAlignment',
13
+ component: BlockAlignment,
14
+ decorators: [
15
+ (Story) => (
16
+ <div className="ui segment form attached" style={{ width: '400px' }}>
17
+ <h4>Block alignment widget</h4>
18
+ <Story />
19
+ </div>
20
+ ),
21
+ ],
22
+ };
23
+
24
+ export default meta;
25
+
26
+ type Story = StoryObj<typeof BlockAlignment>;
27
+
28
+ type TemplateParameters = {
29
+ initialValue?: ButtonsWidgetProps['value'];
30
+ };
31
+
32
+ const Template: StoryFn<typeof BlockAlignment> = (args, context) => {
33
+ const { initialValue } =
34
+ (context.parameters as TemplateParameters | undefined) ?? {};
35
+ const { value: _ignoredValue, onChange: argsOnChange, ...restArgs } = args;
36
+
37
+ return (
38
+ <Wrapper location={{ pathname: '/folder2/folder21/doc212' }}>
39
+ <FormUndoWrapper
40
+ initialState={{ value: initialValue ?? _ignoredValue }}
41
+ showControls
42
+ >
43
+ {({ state, onChange }) => (
44
+ <div className="ui segment form attached" style={{ width: '400px' }}>
45
+ <BlockAlignment
46
+ {...(restArgs as ButtonsWidgetProps)}
47
+ value={state.value}
48
+ onChange={(id, nextValue) => {
49
+ argsOnChange?.(id, nextValue);
50
+ onChange({ value: nextValue });
51
+ }}
52
+ />
53
+ <pre>Value: {JSON.stringify(state.value, null, 2)}</pre>
54
+ </div>
55
+ )}
56
+ </FormUndoWrapper>
57
+ </Wrapper>
58
+ );
59
+ };
60
+
61
+ export const DefaultAlignment: Story = {
62
+ render: Template,
63
+ args: {
64
+ id: 'alignment',
65
+ title: 'Block alignment',
66
+ block: 'block',
67
+ fieldSet: 'default',
68
+ },
69
+ };
70
+
71
+ export const CustomActions: Story = {
72
+ render: Template,
73
+ args: {
74
+ ...(DefaultAlignment.args ?? {}),
75
+ actions: [
76
+ {
77
+ name: 'wide',
78
+ label: 'Wide',
79
+ style: {
80
+ '--block-alignment': 'var(--align-wide)',
81
+ },
82
+ },
83
+ {
84
+ name: 'full',
85
+ label: 'Full',
86
+ style: {
87
+ '--block-alignment': 'var(--align-full)',
88
+ },
89
+ },
90
+ ],
91
+ actionsInfoMap: {
92
+ wide: ['W', 'Wide alignment'],
93
+ full: ['F', 'Full width alignment'],
94
+ },
95
+ },
96
+ };
97
+
98
+ export const FilteredActions: Story = {
99
+ render: Template,
100
+ args: {
101
+ ...(DefaultAlignment.args ?? {}),
102
+ filterActions: ['center'],
103
+ },
104
+ };
@@ -0,0 +1,104 @@
1
+ import React from 'react';
2
+ import { describe, it, expect, vi } from 'vitest';
3
+ import { render, screen, fireEvent } from '@testing-library/react';
4
+ import configureStore from 'redux-mock-store';
5
+ import { Provider } from 'react-intl-redux';
6
+
7
+ import BlockAlignment from './BlockAlignment';
8
+ import type { ButtonsWidgetProps } from './ButtonsWidget';
9
+
10
+ const mockStore = configureStore();
11
+
12
+ const renderWidget = (props: Partial<ButtonsWidgetProps> = {}) => {
13
+ const { onChange: providedOnChange, ...restProps } = props;
14
+ const onChange = providedOnChange ?? vi.fn();
15
+ const widgetProps: ButtonsWidgetProps = {
16
+ id: 'alignment',
17
+ title: 'Block alignment',
18
+ fieldSet: 'default',
19
+ onChange,
20
+ value: undefined,
21
+ default: undefined,
22
+ disabled: false,
23
+ isDisabled: false,
24
+ ...restProps,
25
+ };
26
+
27
+ return {
28
+ onChange,
29
+ ...render(
30
+ <Provider
31
+ store={mockStore({
32
+ intl: {
33
+ locale: 'en',
34
+ messages: {},
35
+ },
36
+ })}
37
+ >
38
+ <BlockAlignment {...widgetProps} />
39
+ </Provider>,
40
+ ),
41
+ };
42
+ };
43
+
44
+ describe('BlockAlignment', () => {
45
+ it('renders default alignment buttons', () => {
46
+ renderWidget();
47
+
48
+ expect(screen.getByRole('radio', { name: 'Left' })).toBeInTheDocument();
49
+ expect(screen.getByRole('radio', { name: 'Center' })).toBeInTheDocument();
50
+ expect(screen.getByRole('radio', { name: 'Right' })).toBeInTheDocument();
51
+ });
52
+
53
+ it('filters actions when filterActions is provided', () => {
54
+ renderWidget({ filterActions: ['center'] });
55
+
56
+ expect(screen.getByRole('radio', { name: 'Center' })).toBeInTheDocument();
57
+ expect(
58
+ screen.queryByRole('button', { name: 'Left' }),
59
+ ).not.toBeInTheDocument();
60
+ expect(
61
+ screen.queryByRole('button', { name: 'Right' }),
62
+ ).not.toBeInTheDocument();
63
+ });
64
+
65
+ it('merges custom actions info map entries', () => {
66
+ renderWidget({
67
+ actions: ['left', 'custom'],
68
+ actionsInfoMap: {
69
+ custom: ['Custom', 'Custom alignment'],
70
+ },
71
+ });
72
+
73
+ expect(screen.getByRole('radio', { name: 'Left' })).toBeInTheDocument();
74
+ expect(
75
+ screen.getByRole('radio', { name: 'Custom alignment' }),
76
+ ).toBeInTheDocument();
77
+ });
78
+
79
+ it('renders when style definitions are provided as actions', () => {
80
+ renderWidget({
81
+ actions: [
82
+ {
83
+ name: 'wide',
84
+ label: 'Wide',
85
+ style: {
86
+ '--block-alignment': 'var(--align-wide)',
87
+ },
88
+ },
89
+ ],
90
+ });
91
+
92
+ expect(screen.getByRole('radio', { name: 'wide' })).toBeInTheDocument();
93
+ });
94
+
95
+ it('invokes onChange with styles when default actions are used', () => {
96
+ const { onChange } = renderWidget();
97
+
98
+ fireEvent.click(screen.getByRole('radio', { name: 'Center' }));
99
+
100
+ expect(onChange).toHaveBeenCalledWith('alignment', {
101
+ '--block-alignment': 'var(--align-center)',
102
+ });
103
+ });
104
+ });
@@ -0,0 +1,88 @@
1
+ import React from 'react';
2
+ import { defineMessages, useIntl } from 'react-intl';
3
+ import ButtonsWidget, {
4
+ type ActionInfo,
5
+ type ButtonsWidgetProps,
6
+ } from './ButtonsWidget';
7
+ import imageFitSVG from '@plone/volto/icons/image-fit.svg';
8
+ import imageLeftSVG from '@plone/volto/icons/image-left.svg';
9
+ import imageRightSVG from '@plone/volto/icons/image-right.svg';
10
+ import type { IntlShape } from 'react-intl';
11
+ import type { StyleDefinition } from '@plone/types';
12
+
13
+ const messages = defineMessages({
14
+ left: {
15
+ id: 'Left',
16
+ defaultMessage: 'Left',
17
+ },
18
+ right: {
19
+ id: 'Right',
20
+ defaultMessage: 'Right',
21
+ },
22
+ center: {
23
+ id: 'Center',
24
+ defaultMessage: 'Center',
25
+ },
26
+ });
27
+
28
+ export const defaultActionsInfo = ({
29
+ intl,
30
+ }: {
31
+ intl: IntlShape;
32
+ }): Record<string, ActionInfo> => ({
33
+ left: [imageLeftSVG, intl.formatMessage(messages.left)],
34
+ right: [imageRightSVG, intl.formatMessage(messages.right)],
35
+ center: [imageFitSVG, intl.formatMessage(messages.center)],
36
+ });
37
+
38
+ const DEFAULT_ACTIONS: StyleDefinition[] = [
39
+ {
40
+ style: {
41
+ '--block-alignment': 'var(--align-left)',
42
+ },
43
+ name: 'left',
44
+ label: 'Left',
45
+ },
46
+ {
47
+ style: {
48
+ '--block-alignment': 'var(--align-center)',
49
+ },
50
+ name: 'center',
51
+ label: 'Center',
52
+ },
53
+ {
54
+ style: {
55
+ '--block-alignment': 'var(--align-right)',
56
+ },
57
+ name: 'right',
58
+ label: 'Right',
59
+ },
60
+ ];
61
+
62
+ const BlockAlignmentWidget = (props: ButtonsWidgetProps) => {
63
+ const intl = useIntl();
64
+
65
+ const { actions = DEFAULT_ACTIONS, actionsInfoMap, filterActions } = props;
66
+ const filteredActions =
67
+ filterActions && filterActions.length > 0
68
+ ? actions.filter((action) => {
69
+ const actionName = typeof action === 'string' ? action : action.name;
70
+ return filterActions.includes(actionName);
71
+ })
72
+ : actions;
73
+
74
+ const actionsInfo = {
75
+ ...defaultActionsInfo({ intl }),
76
+ ...actionsInfoMap,
77
+ };
78
+
79
+ return (
80
+ <ButtonsWidget
81
+ {...props}
82
+ actions={filteredActions}
83
+ actionsInfoMap={actionsInfo}
84
+ />
85
+ );
86
+ };
87
+
88
+ export default BlockAlignmentWidget;
@@ -0,0 +1,69 @@
1
+ import React from 'react';
2
+ import type { Meta, StoryFn, StoryObj } from '@storybook/react';
3
+
4
+ import BlockWidth from './BlockWidth';
5
+ import type { ButtonsWidgetProps } from './ButtonsWidget';
6
+ import {
7
+ RealStoreWrapper as Wrapper,
8
+ FormUndoWrapper,
9
+ } from '@plone/volto/storybook';
10
+
11
+ const meta: Meta<typeof BlockWidth> = {
12
+ title: 'Edit Widgets/BlockWidth',
13
+ component: BlockWidth,
14
+ decorators: [
15
+ (Story) => (
16
+ <div className="ui segment form attached" style={{ width: '400px' }}>
17
+ <h4>Block width widget</h4>
18
+ <Story />
19
+ </div>
20
+ ),
21
+ ],
22
+ };
23
+
24
+ export default meta;
25
+
26
+ type Story = StoryObj<typeof BlockWidth>;
27
+
28
+ type TemplateParameters = {
29
+ initialValue?: ButtonsWidgetProps['value'];
30
+ };
31
+
32
+ const Template: StoryFn<typeof BlockWidth> = (args, context) => {
33
+ const { initialValue } =
34
+ (context.parameters as TemplateParameters | undefined) ?? {};
35
+ const { value: _ignoredValue, onChange: argsOnChange, ...restArgs } = args;
36
+
37
+ return (
38
+ <Wrapper location={{ pathname: '/folder2/folder21/doc212' }}>
39
+ <FormUndoWrapper
40
+ initialState={{ value: initialValue ?? _ignoredValue }}
41
+ showControls
42
+ >
43
+ {({ state, onChange }) => (
44
+ <div className="ui segment form attached" style={{ width: '400px' }}>
45
+ <BlockWidth
46
+ {...(restArgs as ButtonsWidgetProps)}
47
+ value={state.value}
48
+ onChange={(id, nextValue) => {
49
+ argsOnChange?.(id, nextValue);
50
+ onChange({ value: nextValue });
51
+ }}
52
+ />
53
+ <pre>Value: {JSON.stringify(state.value, null, 2)}</pre>
54
+ </div>
55
+ )}
56
+ </FormUndoWrapper>
57
+ </Wrapper>
58
+ );
59
+ };
60
+
61
+ export const DefaultWidth: Story = {
62
+ render: Template,
63
+ args: {
64
+ id: 'blockWidth',
65
+ title: 'Block width',
66
+ block: 'block',
67
+ fieldSet: 'default',
68
+ },
69
+ };
@@ -0,0 +1,62 @@
1
+ import React from 'react';
2
+ import { describe, it, expect, vi } from 'vitest';
3
+ import { render, screen, fireEvent } from '@testing-library/react';
4
+ import configureStore from 'redux-mock-store';
5
+ import { Provider } from 'react-intl-redux';
6
+
7
+ import BlockWidth from './BlockWidth';
8
+ import type { ButtonsWidgetProps } from './ButtonsWidget';
9
+
10
+ const mockStore = configureStore();
11
+
12
+ const renderWidget = (props: Partial<ButtonsWidgetProps> = {}) => {
13
+ const onChange = props.onChange ?? vi.fn();
14
+ const widgetProps: ButtonsWidgetProps = {
15
+ id: 'blockWidth',
16
+ title: 'Block width',
17
+ fieldSet: 'default',
18
+ onChange,
19
+ value: undefined,
20
+ default: undefined,
21
+ disabled: false,
22
+ isDisabled: false,
23
+ ...props,
24
+ };
25
+
26
+ return {
27
+ onChange,
28
+ ...render(
29
+ <Provider
30
+ store={mockStore({
31
+ intl: {
32
+ locale: 'en',
33
+ messages: {},
34
+ },
35
+ })}
36
+ >
37
+ <BlockWidth {...widgetProps} />
38
+ </Provider>,
39
+ ),
40
+ };
41
+ };
42
+
43
+ describe('BlockWidth', () => {
44
+ it('renders the default action buttons provided by the widget', () => {
45
+ renderWidget();
46
+
47
+ expect(screen.getByRole('radio', { name: 'Narrow' })).toBeInTheDocument();
48
+ expect(screen.getByRole('radio', { name: 'Default' })).toBeInTheDocument();
49
+ expect(screen.getByRole('radio', { name: 'Layout' })).toBeInTheDocument();
50
+ expect(screen.getByRole('radio', { name: 'Full' })).toBeInTheDocument();
51
+ });
52
+
53
+ it('emits the correct value for the default actions', () => {
54
+ const { onChange } = renderWidget();
55
+
56
+ fireEvent.click(screen.getByRole('radio', { name: 'Layout' }));
57
+
58
+ expect(onChange).toHaveBeenCalledWith('blockWidth', {
59
+ '--block-width': 'var(--layout-container-width)',
60
+ });
61
+ });
62
+ });