@strapi/i18n 0.0.0-next.820adfc37c687bbcc4a213ae6929c541358b71e8 → 0.0.0-next.83367b80833204c0744701aef452a8d8d2ce25b6

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 (422) hide show
  1. package/dist/admin/components/BulkLocaleActionModal.js +262 -0
  2. package/dist/admin/components/BulkLocaleActionModal.js.map +1 -0
  3. package/dist/admin/components/BulkLocaleActionModal.mjs +260 -0
  4. package/dist/admin/components/BulkLocaleActionModal.mjs.map +1 -0
  5. package/dist/admin/components/CMHeaderActions.js +727 -0
  6. package/dist/admin/components/CMHeaderActions.js.map +1 -0
  7. package/dist/admin/components/CMHeaderActions.mjs +702 -0
  8. package/dist/admin/components/CMHeaderActions.mjs.map +1 -0
  9. package/dist/admin/components/CMListViewModalsAdditionalInformation.js +69 -0
  10. package/dist/admin/components/CMListViewModalsAdditionalInformation.js.map +1 -0
  11. package/dist/admin/components/CMListViewModalsAdditionalInformation.mjs +65 -0
  12. package/dist/admin/components/CMListViewModalsAdditionalInformation.mjs.map +1 -0
  13. package/dist/admin/components/CheckboxConfirmation.js +155 -0
  14. package/dist/admin/components/CheckboxConfirmation.js.map +1 -0
  15. package/dist/admin/components/CheckboxConfirmation.mjs +134 -0
  16. package/dist/admin/components/CheckboxConfirmation.mjs.map +1 -0
  17. package/dist/admin/components/CreateLocale.js +395 -0
  18. package/dist/admin/components/CreateLocale.js.map +1 -0
  19. package/dist/admin/components/CreateLocale.mjs +369 -0
  20. package/dist/admin/components/CreateLocale.mjs.map +1 -0
  21. package/dist/admin/components/DeleteLocale.js +90 -0
  22. package/dist/admin/components/DeleteLocale.js.map +1 -0
  23. package/dist/admin/components/DeleteLocale.mjs +69 -0
  24. package/dist/admin/components/DeleteLocale.mjs.map +1 -0
  25. package/dist/admin/components/EditLocale.js +212 -0
  26. package/dist/admin/components/EditLocale.js.map +1 -0
  27. package/dist/admin/components/EditLocale.mjs +190 -0
  28. package/dist/admin/components/EditLocale.mjs.map +1 -0
  29. package/dist/admin/components/LocaleListCell.js +82 -0
  30. package/dist/admin/components/LocaleListCell.js.map +1 -0
  31. package/dist/admin/components/LocaleListCell.mjs +80 -0
  32. package/dist/admin/components/LocaleListCell.mjs.map +1 -0
  33. package/dist/admin/components/LocalePicker.js +105 -0
  34. package/dist/admin/components/LocalePicker.js.map +1 -0
  35. package/dist/admin/components/LocalePicker.mjs +84 -0
  36. package/dist/admin/components/LocalePicker.mjs.map +1 -0
  37. package/dist/admin/components/LocaleTable.js +143 -0
  38. package/dist/admin/components/LocaleTable.js.map +1 -0
  39. package/dist/admin/components/LocaleTable.mjs +122 -0
  40. package/dist/admin/components/LocaleTable.mjs.map +1 -0
  41. package/dist/admin/constants.js +37 -0
  42. package/dist/admin/constants.js.map +1 -0
  43. package/dist/admin/constants.mjs +35 -0
  44. package/dist/admin/constants.mjs.map +1 -0
  45. package/dist/admin/contentManagerHooks/editView.js +109 -0
  46. package/dist/admin/contentManagerHooks/editView.js.map +1 -0
  47. package/dist/admin/contentManagerHooks/editView.mjs +88 -0
  48. package/dist/admin/contentManagerHooks/editView.mjs.map +1 -0
  49. package/dist/admin/contentManagerHooks/listView.js +43 -0
  50. package/dist/admin/contentManagerHooks/listView.js.map +1 -0
  51. package/dist/admin/contentManagerHooks/listView.mjs +41 -0
  52. package/dist/admin/contentManagerHooks/listView.mjs.map +1 -0
  53. package/dist/admin/contentReleasesHooks/releaseDetailsView.js +20 -0
  54. package/dist/admin/contentReleasesHooks/releaseDetailsView.js.map +1 -0
  55. package/dist/admin/contentReleasesHooks/releaseDetailsView.mjs +18 -0
  56. package/dist/admin/contentReleasesHooks/releaseDetailsView.mjs.map +1 -0
  57. package/dist/admin/hooks/useI18n.js +78 -0
  58. package/dist/admin/hooks/useI18n.js.map +1 -0
  59. package/dist/admin/hooks/useI18n.mjs +57 -0
  60. package/dist/admin/hooks/useI18n.mjs.map +1 -0
  61. package/dist/admin/index.js +225 -5
  62. package/dist/admin/index.js.map +1 -1
  63. package/dist/admin/index.mjs +201 -5
  64. package/dist/admin/index.mjs.map +1 -1
  65. package/dist/admin/middlewares/extendCTBAttributeInitialData.js +71 -0
  66. package/dist/admin/middlewares/extendCTBAttributeInitialData.js.map +1 -0
  67. package/dist/admin/middlewares/extendCTBAttributeInitialData.mjs +69 -0
  68. package/dist/admin/middlewares/extendCTBAttributeInitialData.mjs.map +1 -0
  69. package/dist/admin/middlewares/extendCTBInitialData.js +40 -0
  70. package/dist/admin/middlewares/extendCTBInitialData.js.map +1 -0
  71. package/dist/admin/middlewares/extendCTBInitialData.mjs +38 -0
  72. package/dist/admin/middlewares/extendCTBInitialData.mjs.map +1 -0
  73. package/dist/admin/middlewares/rbac-middleware.js +49 -0
  74. package/dist/admin/middlewares/rbac-middleware.js.map +1 -0
  75. package/dist/admin/middlewares/rbac-middleware.mjs +28 -0
  76. package/dist/admin/middlewares/rbac-middleware.mjs.map +1 -0
  77. package/dist/admin/pages/SettingsPage.js +182 -0
  78. package/dist/admin/pages/SettingsPage.js.map +1 -0
  79. package/dist/admin/pages/SettingsPage.mjs +179 -0
  80. package/dist/admin/pages/SettingsPage.mjs.map +1 -0
  81. package/dist/admin/pluginId.js +6 -0
  82. package/dist/admin/pluginId.js.map +1 -0
  83. package/dist/admin/pluginId.mjs +4 -0
  84. package/dist/admin/pluginId.mjs.map +1 -0
  85. package/dist/admin/services/api.js +14 -0
  86. package/dist/admin/services/api.js.map +1 -0
  87. package/dist/admin/services/api.mjs +12 -0
  88. package/dist/admin/services/api.mjs.map +1 -0
  89. package/dist/admin/services/locales.js +72 -0
  90. package/dist/admin/services/locales.js.map +1 -0
  91. package/dist/admin/services/locales.mjs +66 -0
  92. package/dist/admin/services/locales.mjs.map +1 -0
  93. package/dist/admin/services/relations.js +23 -0
  94. package/dist/admin/services/relations.js.map +1 -0
  95. package/dist/admin/services/relations.mjs +21 -0
  96. package/dist/admin/services/relations.mjs.map +1 -0
  97. package/dist/admin/services/settings.js +29 -0
  98. package/dist/admin/services/settings.js.map +1 -0
  99. package/dist/admin/services/settings.mjs +26 -0
  100. package/dist/admin/services/settings.mjs.map +1 -0
  101. package/dist/admin/src/components/CMHeaderActions.d.ts +1 -1
  102. package/dist/admin/src/components/LocaleListCell.d.ts +4 -4
  103. package/dist/admin/src/components/tests/CreateLocale.test.d.ts +1 -0
  104. package/dist/admin/src/components/tests/DeleteLocale.test.d.ts +1 -0
  105. package/dist/admin/src/components/tests/EditLocale.test.d.ts +1 -0
  106. package/dist/admin/src/components/tests/LocaleListCell.test.d.ts +1 -0
  107. package/dist/admin/src/contentReleasesHooks/releaseDetailsView.d.ts +1 -1
  108. package/dist/admin/src/pages/tests/SettingsPage.test.d.ts +1 -0
  109. package/dist/admin/src/services/api.d.ts +1 -1
  110. package/dist/admin/src/services/locales.d.ts +1 -1
  111. package/dist/admin/src/services/relations.d.ts +1 -1
  112. package/dist/admin/src/services/settings.d.ts +5 -0
  113. package/dist/admin/src/utils/schemas.d.ts +642 -16
  114. package/dist/admin/tests/server.d.ts +1 -0
  115. package/dist/admin/tests/utils.d.ts +6 -0
  116. package/dist/admin/translations/de.json.js +66 -0
  117. package/dist/admin/translations/de.json.js.map +1 -0
  118. package/dist/admin/translations/de.json.mjs +64 -0
  119. package/dist/admin/translations/de.json.mjs.map +1 -0
  120. package/dist/admin/translations/dk.json.js +66 -0
  121. package/dist/admin/translations/dk.json.js.map +1 -0
  122. package/dist/admin/translations/dk.json.mjs +64 -0
  123. package/dist/admin/translations/dk.json.mjs.map +1 -0
  124. package/dist/admin/translations/en.json.js +83 -0
  125. package/dist/admin/translations/en.json.js.map +1 -0
  126. package/dist/admin/translations/en.json.mjs +81 -0
  127. package/dist/admin/translations/en.json.mjs.map +1 -0
  128. package/dist/admin/translations/es.json.js +66 -0
  129. package/dist/admin/translations/es.json.js.map +1 -0
  130. package/dist/admin/translations/es.json.mjs +64 -0
  131. package/dist/admin/translations/es.json.mjs.map +1 -0
  132. package/dist/admin/translations/fr.json.js +66 -0
  133. package/dist/admin/translations/fr.json.js.map +1 -0
  134. package/dist/admin/translations/fr.json.mjs +64 -0
  135. package/dist/admin/translations/fr.json.mjs.map +1 -0
  136. package/dist/admin/translations/ko.json.js +65 -0
  137. package/dist/admin/translations/ko.json.js.map +1 -0
  138. package/dist/admin/translations/ko.json.mjs +63 -0
  139. package/dist/admin/translations/ko.json.mjs.map +1 -0
  140. package/dist/admin/translations/pl.json.js +66 -0
  141. package/dist/admin/translations/pl.json.js.map +1 -0
  142. package/dist/admin/translations/pl.json.mjs +64 -0
  143. package/dist/admin/translations/pl.json.mjs.map +1 -0
  144. package/dist/admin/translations/ru.json.js +68 -0
  145. package/dist/admin/translations/ru.json.js.map +1 -0
  146. package/dist/admin/translations/ru.json.mjs +66 -0
  147. package/dist/admin/translations/ru.json.mjs.map +1 -0
  148. package/dist/admin/translations/tr.json.js +66 -0
  149. package/dist/admin/translations/tr.json.js.map +1 -0
  150. package/dist/admin/translations/tr.json.mjs +64 -0
  151. package/dist/admin/translations/tr.json.mjs.map +1 -0
  152. package/dist/admin/translations/uk.json.js +82 -0
  153. package/dist/admin/translations/uk.json.js.map +1 -0
  154. package/dist/admin/translations/uk.json.mjs +80 -0
  155. package/dist/admin/translations/uk.json.mjs.map +1 -0
  156. package/dist/admin/translations/zh-Hans.json.js +57 -0
  157. package/dist/admin/translations/zh-Hans.json.js.map +1 -0
  158. package/dist/admin/translations/zh-Hans.json.mjs +55 -0
  159. package/dist/admin/translations/zh-Hans.json.mjs.map +1 -0
  160. package/dist/admin/translations/zh.json.js +66 -0
  161. package/dist/admin/translations/zh.json.js.map +1 -0
  162. package/dist/admin/translations/zh.json.mjs +64 -0
  163. package/dist/admin/translations/zh.json.mjs.map +1 -0
  164. package/dist/admin/utils/baseQuery.js +8 -0
  165. package/dist/admin/utils/baseQuery.js.map +1 -0
  166. package/dist/admin/utils/baseQuery.mjs +6 -0
  167. package/dist/admin/utils/baseQuery.mjs.map +1 -0
  168. package/dist/admin/utils/clean.js +70 -0
  169. package/dist/admin/utils/clean.js.map +1 -0
  170. package/dist/admin/utils/clean.mjs +68 -0
  171. package/dist/admin/utils/clean.mjs.map +1 -0
  172. package/dist/admin/utils/fields.js +34 -0
  173. package/dist/admin/utils/fields.js.map +1 -0
  174. package/dist/admin/utils/fields.mjs +31 -0
  175. package/dist/admin/utils/fields.mjs.map +1 -0
  176. package/dist/admin/utils/getTranslation.js +8 -0
  177. package/dist/admin/utils/getTranslation.js.map +1 -0
  178. package/dist/admin/utils/getTranslation.mjs +6 -0
  179. package/dist/admin/utils/getTranslation.mjs.map +1 -0
  180. package/dist/admin/utils/prefixPluginTranslations.js +11 -0
  181. package/dist/admin/utils/prefixPluginTranslations.js.map +1 -0
  182. package/dist/admin/utils/prefixPluginTranslations.mjs +9 -0
  183. package/dist/admin/utils/prefixPluginTranslations.mjs.map +1 -0
  184. package/dist/admin/utils/schemas.js +74 -0
  185. package/dist/admin/utils/schemas.js.map +1 -0
  186. package/dist/admin/utils/schemas.mjs +72 -0
  187. package/dist/admin/utils/schemas.mjs.map +1 -0
  188. package/dist/admin/utils/strings.js +6 -0
  189. package/dist/admin/utils/strings.js.map +1 -0
  190. package/dist/admin/utils/strings.mjs +4 -0
  191. package/dist/admin/utils/strings.mjs.map +1 -0
  192. package/dist/server/bootstrap.js +79 -0
  193. package/dist/server/bootstrap.js.map +1 -0
  194. package/dist/server/bootstrap.mjs +77 -0
  195. package/dist/server/bootstrap.mjs.map +1 -0
  196. package/dist/server/constants/index.js +29 -0
  197. package/dist/server/constants/index.js.map +1 -0
  198. package/dist/server/constants/index.mjs +25 -0
  199. package/dist/server/constants/index.mjs.map +1 -0
  200. package/dist/server/constants/iso-locales.json.js +2423 -0
  201. package/dist/server/constants/iso-locales.json.js.map +1 -0
  202. package/dist/server/constants/iso-locales.json.mjs +2421 -0
  203. package/dist/server/constants/iso-locales.json.mjs.map +1 -0
  204. package/dist/server/content-types/index.js +10 -0
  205. package/dist/server/content-types/index.js.map +1 -0
  206. package/dist/server/content-types/index.mjs +8 -0
  207. package/dist/server/content-types/index.mjs.map +1 -0
  208. package/dist/server/content-types/locale/index.js +10 -0
  209. package/dist/server/content-types/locale/index.js.map +1 -0
  210. package/dist/server/content-types/locale/index.mjs +8 -0
  211. package/dist/server/content-types/locale/index.mjs.map +1 -0
  212. package/dist/server/content-types/locale/schema.json.js +46 -0
  213. package/dist/server/content-types/locale/schema.json.js.map +1 -0
  214. package/dist/server/content-types/locale/schema.json.mjs +38 -0
  215. package/dist/server/content-types/locale/schema.json.mjs.map +1 -0
  216. package/dist/server/controllers/content-types.js +76 -0
  217. package/dist/server/controllers/content-types.js.map +1 -0
  218. package/dist/server/controllers/content-types.mjs +74 -0
  219. package/dist/server/controllers/content-types.mjs.map +1 -0
  220. package/dist/server/controllers/index.js +16 -0
  221. package/dist/server/controllers/index.js.map +1 -0
  222. package/dist/server/controllers/index.mjs +14 -0
  223. package/dist/server/controllers/index.mjs.map +1 -0
  224. package/dist/server/controllers/iso-locales.js +13 -0
  225. package/dist/server/controllers/iso-locales.js.map +1 -0
  226. package/dist/server/controllers/iso-locales.mjs +11 -0
  227. package/dist/server/controllers/iso-locales.mjs.map +1 -0
  228. package/dist/server/controllers/locales.js +108 -0
  229. package/dist/server/controllers/locales.js.map +1 -0
  230. package/dist/server/controllers/locales.mjs +87 -0
  231. package/dist/server/controllers/locales.mjs.map +1 -0
  232. package/dist/server/controllers/settings.js +24 -0
  233. package/dist/server/controllers/settings.js.map +1 -0
  234. package/dist/server/controllers/settings.mjs +22 -0
  235. package/dist/server/controllers/settings.mjs.map +1 -0
  236. package/dist/server/controllers/validate-locale-creation.js +47 -0
  237. package/dist/server/controllers/validate-locale-creation.js.map +1 -0
  238. package/dist/server/controllers/validate-locale-creation.mjs +45 -0
  239. package/dist/server/controllers/validate-locale-creation.mjs.map +1 -0
  240. package/dist/server/domain/locale.js +11 -0
  241. package/dist/server/domain/locale.js.map +1 -0
  242. package/dist/server/domain/locale.mjs +9 -0
  243. package/dist/server/domain/locale.mjs.map +1 -0
  244. package/dist/server/graphql.js +115 -0
  245. package/dist/server/graphql.js.map +1 -0
  246. package/dist/server/graphql.mjs +113 -0
  247. package/dist/server/graphql.mjs.map +1 -0
  248. package/dist/server/index.js +18 -3460
  249. package/dist/server/index.js.map +1 -1
  250. package/dist/server/index.mjs +17 -3443
  251. package/dist/server/index.mjs.map +1 -1
  252. package/dist/server/register.js +79 -0
  253. package/dist/server/register.js.map +1 -0
  254. package/dist/server/register.mjs +77 -0
  255. package/dist/server/register.mjs.map +1 -0
  256. package/dist/server/routes/admin.js +122 -0
  257. package/dist/server/routes/admin.js.map +1 -0
  258. package/dist/server/routes/admin.mjs +120 -0
  259. package/dist/server/routes/admin.mjs.map +1 -0
  260. package/dist/server/routes/content-api.js +19 -0
  261. package/dist/server/routes/content-api.js.map +1 -0
  262. package/dist/server/routes/content-api.mjs +17 -0
  263. package/dist/server/routes/content-api.mjs.map +1 -0
  264. package/dist/server/routes/index.js +12 -0
  265. package/dist/server/routes/index.js.map +1 -0
  266. package/dist/server/routes/index.mjs +10 -0
  267. package/dist/server/routes/index.mjs.map +1 -0
  268. package/dist/server/routes/validation/locale.js +57 -0
  269. package/dist/server/routes/validation/locale.js.map +1 -0
  270. package/dist/server/routes/validation/locale.mjs +36 -0
  271. package/dist/server/routes/validation/locale.mjs.map +1 -0
  272. package/dist/server/services/ai-localizations.js +28 -0
  273. package/dist/server/services/ai-localizations.js.map +1 -0
  274. package/dist/server/services/ai-localizations.mjs +26 -0
  275. package/dist/server/services/ai-localizations.mjs.map +1 -0
  276. package/dist/server/services/content-types.js +157 -0
  277. package/dist/server/services/content-types.js.map +1 -0
  278. package/dist/server/services/content-types.mjs +155 -0
  279. package/dist/server/services/content-types.mjs.map +1 -0
  280. package/dist/server/services/index.js +26 -0
  281. package/dist/server/services/index.js.map +1 -0
  282. package/dist/server/services/index.mjs +24 -0
  283. package/dist/server/services/index.mjs.map +1 -0
  284. package/dist/server/services/iso-locales.js +12 -0
  285. package/dist/server/services/iso-locales.js.map +1 -0
  286. package/dist/server/services/iso-locales.mjs +10 -0
  287. package/dist/server/services/iso-locales.mjs.map +1 -0
  288. package/dist/server/services/locales.js +114 -0
  289. package/dist/server/services/locales.js.map +1 -0
  290. package/dist/server/services/locales.mjs +112 -0
  291. package/dist/server/services/locales.mjs.map +1 -0
  292. package/dist/server/services/localizations.js +68 -0
  293. package/dist/server/services/localizations.js.map +1 -0
  294. package/dist/server/services/localizations.mjs +66 -0
  295. package/dist/server/services/localizations.mjs.map +1 -0
  296. package/dist/server/services/metrics.js +30 -0
  297. package/dist/server/services/metrics.js.map +1 -0
  298. package/dist/server/services/metrics.mjs +28 -0
  299. package/dist/server/services/metrics.mjs.map +1 -0
  300. package/dist/server/services/permissions/actions.js +136 -0
  301. package/dist/server/services/permissions/actions.js.map +1 -0
  302. package/dist/server/services/permissions/actions.mjs +134 -0
  303. package/dist/server/services/permissions/actions.mjs.map +1 -0
  304. package/dist/server/services/permissions/engine.js +52 -0
  305. package/dist/server/services/permissions/engine.js.map +1 -0
  306. package/dist/server/services/permissions/engine.mjs +50 -0
  307. package/dist/server/services/permissions/engine.mjs.map +1 -0
  308. package/dist/server/services/permissions/sections-builder.js +45 -0
  309. package/dist/server/services/permissions/sections-builder.js.map +1 -0
  310. package/dist/server/services/permissions/sections-builder.mjs +43 -0
  311. package/dist/server/services/permissions/sections-builder.mjs.map +1 -0
  312. package/dist/server/services/permissions.js +14 -0
  313. package/dist/server/services/permissions.js.map +1 -0
  314. package/dist/server/services/permissions.mjs +12 -0
  315. package/dist/server/services/permissions.mjs.map +1 -0
  316. package/dist/server/services/sanitize/index.js +34 -0
  317. package/dist/server/services/sanitize/index.js.map +1 -0
  318. package/dist/server/services/sanitize/index.mjs +32 -0
  319. package/dist/server/services/sanitize/index.mjs.map +1 -0
  320. package/dist/server/services/settings.js +25 -0
  321. package/dist/server/services/settings.js.map +1 -0
  322. package/dist/server/services/settings.mjs +23 -0
  323. package/dist/server/services/settings.mjs.map +1 -0
  324. package/dist/server/src/controllers/index.d.ts +4 -0
  325. package/dist/server/src/controllers/index.d.ts.map +1 -1
  326. package/dist/server/src/controllers/settings.d.ts +7 -0
  327. package/dist/server/src/controllers/settings.d.ts.map +1 -0
  328. package/dist/server/src/index.d.ts +22 -7
  329. package/dist/server/src/index.d.ts.map +1 -1
  330. package/dist/server/src/routes/admin.d.ts.map +1 -1
  331. package/dist/server/src/routes/content-api.d.ts +5 -8
  332. package/dist/server/src/routes/content-api.d.ts.map +1 -1
  333. package/dist/server/src/routes/index.d.ts +3 -7
  334. package/dist/server/src/routes/index.d.ts.map +1 -1
  335. package/dist/server/src/routes/validation/index.d.ts +2 -0
  336. package/dist/server/src/routes/validation/index.d.ts.map +1 -0
  337. package/dist/server/src/routes/validation/locale.d.ts +41 -0
  338. package/dist/server/src/routes/validation/locale.d.ts.map +1 -0
  339. package/dist/server/src/services/ai-localizations.d.ts +8 -0
  340. package/dist/server/src/services/ai-localizations.d.ts.map +1 -0
  341. package/dist/server/src/services/index.d.ts +15 -0
  342. package/dist/server/src/services/index.d.ts.map +1 -1
  343. package/dist/server/src/services/localizations.d.ts +1 -1
  344. package/dist/server/src/services/localizations.d.ts.map +1 -1
  345. package/dist/server/src/services/settings.d.ts +13 -0
  346. package/dist/server/src/services/settings.d.ts.map +1 -0
  347. package/dist/server/src/utils/index.d.ts +3 -1
  348. package/dist/server/src/utils/index.d.ts.map +1 -1
  349. package/dist/server/src/validation/settings.d.ts +12 -0
  350. package/dist/server/src/validation/settings.d.ts.map +1 -0
  351. package/dist/server/utils/index.js +16 -0
  352. package/dist/server/utils/index.js.map +1 -0
  353. package/dist/server/utils/index.mjs +13 -0
  354. package/dist/server/utils/index.mjs.map +1 -0
  355. package/dist/server/validation/content-types.js +18 -0
  356. package/dist/server/validation/content-types.js.map +1 -0
  357. package/dist/server/validation/content-types.mjs +16 -0
  358. package/dist/server/validation/content-types.mjs.map +1 -0
  359. package/dist/server/validation/locales.js +23 -0
  360. package/dist/server/validation/locales.js.map +1 -0
  361. package/dist/server/validation/locales.mjs +20 -0
  362. package/dist/server/validation/locales.mjs.map +1 -0
  363. package/dist/server/validation/settings.js +11 -0
  364. package/dist/server/validation/settings.js.map +1 -0
  365. package/dist/server/validation/settings.mjs +9 -0
  366. package/dist/server/validation/settings.mjs.map +1 -0
  367. package/dist/shared/contracts/content-manager.d.ts +1 -1
  368. package/dist/shared/contracts/settings.d.ts +40 -0
  369. package/dist/shared/contracts/shared.d.ts +1 -1
  370. package/package.json +18 -14
  371. package/dist/_chunks/SettingsPage-BAx9nmep.mjs +0 -554
  372. package/dist/_chunks/SettingsPage-BAx9nmep.mjs.map +0 -1
  373. package/dist/_chunks/SettingsPage-BTgjb2KS.js +0 -573
  374. package/dist/_chunks/SettingsPage-BTgjb2KS.js.map +0 -1
  375. package/dist/_chunks/de-9eCAqqrB.mjs +0 -66
  376. package/dist/_chunks/de-9eCAqqrB.mjs.map +0 -1
  377. package/dist/_chunks/de-DtWiGdHl.js +0 -66
  378. package/dist/_chunks/de-DtWiGdHl.js.map +0 -1
  379. package/dist/_chunks/dk-2qBjxt-P.mjs +0 -66
  380. package/dist/_chunks/dk-2qBjxt-P.mjs.map +0 -1
  381. package/dist/_chunks/dk-D8C-casx.js +0 -66
  382. package/dist/_chunks/dk-D8C-casx.js.map +0 -1
  383. package/dist/_chunks/en-BKBz3tro.js +0 -81
  384. package/dist/_chunks/en-BKBz3tro.js.map +0 -1
  385. package/dist/_chunks/en-DlXfy6Gy.mjs +0 -81
  386. package/dist/_chunks/en-DlXfy6Gy.mjs.map +0 -1
  387. package/dist/_chunks/es-DS-XFGSw.js +0 -66
  388. package/dist/_chunks/es-DS-XFGSw.js.map +0 -1
  389. package/dist/_chunks/es-DlmMVaBG.mjs +0 -66
  390. package/dist/_chunks/es-DlmMVaBG.mjs.map +0 -1
  391. package/dist/_chunks/fr-3S6ke71d.mjs +0 -66
  392. package/dist/_chunks/fr-3S6ke71d.mjs.map +0 -1
  393. package/dist/_chunks/fr-BTjekDpq.js +0 -66
  394. package/dist/_chunks/fr-BTjekDpq.js.map +0 -1
  395. package/dist/_chunks/index-3yyF237r.js +0 -1644
  396. package/dist/_chunks/index-3yyF237r.js.map +0 -1
  397. package/dist/_chunks/index-B0NijiBB.mjs +0 -1623
  398. package/dist/_chunks/index-B0NijiBB.mjs.map +0 -1
  399. package/dist/_chunks/ko-DmcGUBQ3.js +0 -65
  400. package/dist/_chunks/ko-DmcGUBQ3.js.map +0 -1
  401. package/dist/_chunks/ko-qTjQ8IMw.mjs +0 -65
  402. package/dist/_chunks/ko-qTjQ8IMw.mjs.map +0 -1
  403. package/dist/_chunks/pl-B67TSHqT.mjs +0 -66
  404. package/dist/_chunks/pl-B67TSHqT.mjs.map +0 -1
  405. package/dist/_chunks/pl-Cn5RYonZ.js +0 -66
  406. package/dist/_chunks/pl-Cn5RYonZ.js.map +0 -1
  407. package/dist/_chunks/ru-BMBgVL3s.js +0 -68
  408. package/dist/_chunks/ru-BMBgVL3s.js.map +0 -1
  409. package/dist/_chunks/ru-hagMa57T.mjs +0 -68
  410. package/dist/_chunks/ru-hagMa57T.mjs.map +0 -1
  411. package/dist/_chunks/tr-CarUU76c.js +0 -66
  412. package/dist/_chunks/tr-CarUU76c.js.map +0 -1
  413. package/dist/_chunks/tr-Dw_jmkG-.mjs +0 -66
  414. package/dist/_chunks/tr-Dw_jmkG-.mjs.map +0 -1
  415. package/dist/_chunks/zh-57YM4amO.mjs +0 -66
  416. package/dist/_chunks/zh-57YM4amO.mjs.map +0 -1
  417. package/dist/_chunks/zh-CukOviB0.js +0 -66
  418. package/dist/_chunks/zh-CukOviB0.js.map +0 -1
  419. package/dist/_chunks/zh-Hans-DSHIXAa3.js +0 -57
  420. package/dist/_chunks/zh-Hans-DSHIXAa3.js.map +0 -1
  421. package/dist/_chunks/zh-Hans-Dyc-aR-h.mjs +0 -57
  422. package/dist/_chunks/zh-Hans-Dyc-aR-h.mjs.map +0 -1
@@ -1,1623 +0,0 @@
1
- import get from "lodash/get";
2
- import * as yup from "yup";
3
- import { jsxs, jsx, Fragment } from "react/jsx-runtime";
4
- import * as React from "react";
5
- import { Typography, Dialog, Field, Checkbox, Flex, Button, Modal, Box, Status, IconButton, Tooltip, SingleSelect, SingleSelectOption, VisuallyHidden, useCollator, Popover } from "@strapi/design-system";
6
- import { WarningCircle, Pencil, CrossCircle, CheckCircle, ArrowsCounterClockwise, Trash, Plus, Download, ListPlus, Cross, Earth, EarthStriked, CaretDown } from "@strapi/icons";
7
- import { useIntl } from "react-intl";
8
- import { styled } from "styled-components";
9
- import { skipToken } from "@reduxjs/toolkit/query";
10
- import { useAuth, adminApi, useTable, Table, useQueryParams, useForm, useNotification, useAPIErrorHandler } from "@strapi/admin/strapi-admin";
11
- import { unstable_useDocument, unstable_useDocumentActions, buildValidParams } from "@strapi/content-manager/strapi-admin";
12
- import { useParams, Link, useNavigate, matchPath } from "react-router-dom";
13
- import * as qs from "qs";
14
- import { stringify } from "qs";
15
- import omit from "lodash/omit";
16
- const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
17
- const v = glob[path];
18
- if (v) {
19
- return typeof v === "function" ? v() : Promise.resolve(v);
20
- }
21
- return new Promise((_, reject) => {
22
- (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
23
- reject.bind(
24
- null,
25
- new Error(
26
- "Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
27
- )
28
- )
29
- );
30
- });
31
- };
32
- const pluginId = "i18n";
33
- const getTranslation = (id) => `${pluginId}.${id}`;
34
- const TextAlignTypography = styled(Typography)`
35
- text-align: center;
36
- `;
37
- const CheckboxConfirmation = ({
38
- description,
39
- isCreating = false,
40
- intlLabel,
41
- name,
42
- onChange,
43
- value
44
- }) => {
45
- const { formatMessage } = useIntl();
46
- const [isOpen, setIsOpen] = React.useState(false);
47
- const handleChange = (value2) => {
48
- if (isCreating || value2) {
49
- return onChange({ target: { name, value: value2, type: "checkbox" } });
50
- }
51
- if (!value2) {
52
- return setIsOpen(true);
53
- }
54
- return null;
55
- };
56
- const handleConfirm = () => {
57
- onChange({ target: { name, value: false, type: "checkbox" } });
58
- };
59
- const label = intlLabel.id ? formatMessage(
60
- { id: intlLabel.id, defaultMessage: intlLabel.defaultMessage },
61
- { ...intlLabel.values }
62
- ) : name;
63
- const hint = description ? formatMessage(
64
- { id: description.id, defaultMessage: description.defaultMessage },
65
- { ...description.values }
66
- ) : "";
67
- return /* @__PURE__ */ jsxs(Dialog.Root, { open: isOpen, onOpenChange: setIsOpen, children: [
68
- /* @__PURE__ */ jsxs(Field.Root, { hint, name, children: [
69
- /* @__PURE__ */ jsx(Checkbox, { onCheckedChange: handleChange, checked: value, children: label }),
70
- /* @__PURE__ */ jsx(Field.Hint, {})
71
- ] }),
72
- /* @__PURE__ */ jsxs(Dialog.Content, { children: [
73
- /* @__PURE__ */ jsx(Dialog.Header, { children: formatMessage({
74
- id: getTranslation("CheckboxConfirmation.Modal.title"),
75
- defaultMessage: "Disable localization"
76
- }) }),
77
- /* @__PURE__ */ jsx(Dialog.Body, { icon: /* @__PURE__ */ jsx(WarningCircle, {}), children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
78
- /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(TextAlignTypography, { children: formatMessage({
79
- id: getTranslation("CheckboxConfirmation.Modal.content"),
80
- defaultMessage: "Disabling localization will engender the deletion of all your content but the one associated to your default locale (if existing)."
81
- }) }) }),
82
- /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Typography, { fontWeight: "semiBold", children: formatMessage({
83
- id: getTranslation("CheckboxConfirmation.Modal.body"),
84
- defaultMessage: "Do you want to disable it?"
85
- }) }) })
86
- ] }) }),
87
- /* @__PURE__ */ jsxs(Dialog.Footer, { children: [
88
- /* @__PURE__ */ jsx(Dialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", children: formatMessage({
89
- id: "components.popUpWarning.button.cancel",
90
- defaultMessage: "No, cancel"
91
- }) }) }),
92
- /* @__PURE__ */ jsx(Dialog.Action, { children: /* @__PURE__ */ jsx(Button, { variant: "danger-light", onClick: handleConfirm, children: formatMessage({
93
- id: getTranslation("CheckboxConfirmation.Modal.button-confirm"),
94
- defaultMessage: "Yes, disable"
95
- }) }) })
96
- ] })
97
- ] })
98
- ] });
99
- };
100
- const LOCALIZED_FIELDS = [
101
- "biginteger",
102
- "boolean",
103
- "component",
104
- "date",
105
- "datetime",
106
- "decimal",
107
- "dynamiczone",
108
- "email",
109
- "enumeration",
110
- "float",
111
- "integer",
112
- "json",
113
- "media",
114
- "number",
115
- "password",
116
- "richtext",
117
- "blocks",
118
- "string",
119
- "text",
120
- "time"
121
- ];
122
- const doesPluginOptionsHaveI18nLocalized = (opts) => typeof opts === "object" && opts !== null && "i18n" in opts && typeof opts.i18n === "object" && opts.i18n !== null && "localized" in opts.i18n && typeof opts.i18n.localized === "boolean";
123
- const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
124
- const useI18n = () => {
125
- const params = useParams();
126
- const userPermissions = useAuth("useI18n", (state) => state.permissions);
127
- const actions = React.useMemo(() => {
128
- const permissions = userPermissions.filter((permission) => permission.subject === params.slug);
129
- return permissions.reduce(
130
- (acc, permission) => {
131
- const [actionShorthand] = permission.action.split(".").slice(-1);
132
- return {
133
- ...acc,
134
- [`can${capitalize(actionShorthand)}`]: permission.properties?.locales ?? []
135
- };
136
- },
137
- { canCreate: [], canRead: [], canUpdate: [], canDelete: [], canPublish: [] }
138
- );
139
- }, [params.slug, userPermissions]);
140
- const { schema } = unstable_useDocument(
141
- {
142
- // We can non-null assert these because below we skip the query if they are not present
143
- collectionType: params.collectionType,
144
- model: params.slug
145
- },
146
- {
147
- skip: true
148
- }
149
- );
150
- if (doesPluginOptionsHaveI18nLocalized(schema?.pluginOptions)) {
151
- return {
152
- hasI18n: schema.pluginOptions.i18n.localized,
153
- ...actions
154
- };
155
- }
156
- return {
157
- hasI18n: false,
158
- ...actions
159
- };
160
- };
161
- const i18nApi = adminApi.enhanceEndpoints({
162
- addTagTypes: ["Locale"]
163
- });
164
- const localesApi = i18nApi.injectEndpoints({
165
- endpoints: (builder) => ({
166
- createLocale: builder.mutation({
167
- query: (data) => ({
168
- url: "/i18n/locales",
169
- method: "POST",
170
- data
171
- }),
172
- invalidatesTags: [{ type: "Locale", id: "LIST" }]
173
- }),
174
- deleteLocale: builder.mutation({
175
- query: (id) => ({
176
- url: `/i18n/locales/${id}`,
177
- method: "DELETE"
178
- }),
179
- invalidatesTags: (result, error, id) => [{ type: "Locale", id }]
180
- }),
181
- getLocales: builder.query({
182
- query: () => "/i18n/locales",
183
- providesTags: (res) => [
184
- { type: "Locale", id: "LIST" },
185
- ...Array.isArray(res) ? res.map((locale) => ({
186
- type: "Locale",
187
- id: locale.id
188
- })) : []
189
- ]
190
- }),
191
- getDefaultLocales: builder.query({
192
- query: () => "/i18n/iso-locales"
193
- }),
194
- updateLocale: builder.mutation({
195
- query: ({ id, ...data }) => ({
196
- url: `/i18n/locales/${id}`,
197
- method: "PUT",
198
- data
199
- }),
200
- invalidatesTags: (result, error, { id }) => [{ type: "Locale", id }]
201
- })
202
- })
203
- });
204
- const {
205
- useCreateLocaleMutation,
206
- useDeleteLocaleMutation,
207
- useGetLocalesQuery,
208
- useGetDefaultLocalesQuery,
209
- useUpdateLocaleMutation
210
- } = localesApi;
211
- const relationsApi = i18nApi.injectEndpoints({
212
- overrideExisting: true,
213
- endpoints: (builder) => ({
214
- getManyDraftRelationCount: builder.query({
215
- query: ({ model, ...params }) => ({
216
- url: `/content-manager/collection-types/${model}/actions/countManyEntriesDraftRelations`,
217
- method: "GET",
218
- config: {
219
- params
220
- }
221
- }),
222
- transformResponse: (response) => response.data
223
- })
224
- })
225
- });
226
- const { useGetManyDraftRelationCountQuery } = relationsApi;
227
- const cleanData = (data, schema, components) => {
228
- const cleanedData = removeFields(data, [
229
- "createdAt",
230
- "createdBy",
231
- "updatedAt",
232
- "updatedBy",
233
- "id",
234
- "documentId",
235
- "publishedAt",
236
- "strapi_stage",
237
- "strapi_assignee",
238
- "locale",
239
- "status"
240
- ]);
241
- const cleanedDataWithoutPasswordAndRelation = recursiveRemoveFieldTypes(
242
- cleanedData,
243
- schema,
244
- components,
245
- ["relation", "password"]
246
- );
247
- return cleanedDataWithoutPasswordAndRelation;
248
- };
249
- const removeFields = (data, fields) => {
250
- return Object.keys(data).reduce((acc, current) => {
251
- if (fields.includes(current)) {
252
- return acc;
253
- }
254
- acc[current] = data[current];
255
- return acc;
256
- }, {});
257
- };
258
- const recursiveRemoveFieldTypes = (data, schema, components, fields) => {
259
- return Object.keys(data).reduce((acc, current) => {
260
- const attribute = schema.attributes[current] ?? { type: void 0 };
261
- if (fields.includes(attribute.type)) {
262
- return acc;
263
- }
264
- if (attribute.type === "dynamiczone") {
265
- acc[current] = data[current].map((componentValue, index2) => {
266
- const { id: _, ...rest } = recursiveRemoveFieldTypes(
267
- componentValue,
268
- components[componentValue.__component],
269
- components,
270
- fields
271
- );
272
- return {
273
- ...rest,
274
- __temp_key__: index2 + 1
275
- };
276
- });
277
- } else if (attribute.type === "component") {
278
- const { repeatable, component } = attribute;
279
- if (repeatable) {
280
- acc[current] = (data[current] ?? []).map((compoData, index2) => {
281
- const { id: _, ...rest } = recursiveRemoveFieldTypes(
282
- compoData,
283
- components[component],
284
- components,
285
- fields
286
- );
287
- return {
288
- ...rest,
289
- __temp_key__: index2 + 1
290
- };
291
- });
292
- } else {
293
- const { id: _, ...rest } = recursiveRemoveFieldTypes(
294
- data[current] ?? {},
295
- components[component],
296
- components,
297
- fields
298
- );
299
- acc[current] = rest;
300
- }
301
- } else {
302
- acc[current] = data[current];
303
- }
304
- return acc;
305
- }, {});
306
- };
307
- const isErrorMessageDescriptor = (object) => {
308
- return typeof object === "object" && object !== null && "id" in object && "defaultMessage" in object;
309
- };
310
- const EntryValidationText = ({
311
- status = "draft",
312
- validationErrors,
313
- action
314
- }) => {
315
- const { formatMessage } = useIntl();
316
- const getErrorStr = (key, value) => {
317
- if (typeof value === "string") {
318
- return `${key}: ${value}`;
319
- } else if (isErrorMessageDescriptor(value)) {
320
- return `${key}: ${formatMessage(value)}`;
321
- } else if (Array.isArray(value)) {
322
- return value.map((v) => getErrorStr(key, v)).join(" ");
323
- } else if (typeof value === "object" && !Array.isArray(value)) {
324
- return Object.entries(value).map(([k, v]) => getErrorStr(k, v)).join(" ");
325
- } else {
326
- return "";
327
- }
328
- };
329
- if (validationErrors) {
330
- const validationErrorsMessages = Object.entries(validationErrors).map(([key, value]) => {
331
- return getErrorStr(key, value);
332
- }).join(" ");
333
- return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
334
- /* @__PURE__ */ jsx(CrossCircle, { fill: "danger600" }),
335
- /* @__PURE__ */ jsx(Tooltip, { label: validationErrorsMessages, children: /* @__PURE__ */ jsx(
336
- Typography,
337
- {
338
- maxWidth: "30rem",
339
- textColor: "danger600",
340
- variant: "omega",
341
- fontWeight: "semiBold",
342
- ellipsis: true,
343
- children: validationErrorsMessages
344
- }
345
- ) })
346
- ] });
347
- }
348
- const getStatusMessage = () => {
349
- if (action === "bulk-publish") {
350
- if (status === "published") {
351
- return {
352
- icon: /* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
353
- text: formatMessage({
354
- id: "content-manager.bulk-publish.already-published",
355
- defaultMessage: "Already Published"
356
- }),
357
- textColor: "success600",
358
- fontWeight: "bold"
359
- };
360
- } else if (status === "modified") {
361
- return {
362
- icon: /* @__PURE__ */ jsx(ArrowsCounterClockwise, { fill: "alternative600" }),
363
- text: formatMessage({
364
- id: "app.utils.ready-to-publish-changes",
365
- defaultMessage: "Ready to publish changes"
366
- })
367
- };
368
- } else {
369
- return {
370
- icon: /* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
371
- text: formatMessage({
372
- id: "app.utils.ready-to-publish",
373
- defaultMessage: "Ready to publish"
374
- })
375
- };
376
- }
377
- } else {
378
- if (status === "draft") {
379
- return {
380
- icon: /* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
381
- text: formatMessage({
382
- id: "content-manager.bulk-unpublish.already-unpublished",
383
- defaultMessage: "Already Unpublished"
384
- }),
385
- textColor: "success600",
386
- fontWeight: "bold"
387
- };
388
- } else {
389
- return {
390
- icon: /* @__PURE__ */ jsx(CheckCircle, { fill: "success600" }),
391
- text: formatMessage({
392
- id: "app.utils.ready-to-unpublish-changes",
393
- defaultMessage: "Ready to unpublish"
394
- }),
395
- textColor: "success600",
396
- fontWeight: "bold"
397
- };
398
- }
399
- }
400
- };
401
- const { icon, text, textColor = "success600", fontWeight = "normal" } = getStatusMessage();
402
- return /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
403
- icon,
404
- /* @__PURE__ */ jsx(Typography, { textColor, fontWeight, children: text })
405
- ] });
406
- };
407
- const BoldChunk = (chunks) => /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: chunks });
408
- const BulkLocaleActionModal = ({
409
- headers,
410
- rows,
411
- localesMetadata,
412
- validationErrors = {},
413
- action
414
- }) => {
415
- const { formatMessage } = useIntl();
416
- const selectedRows = useTable(
417
- "BulkLocaleActionModal",
418
- (state) => state.selectedRows
419
- );
420
- const getFormattedCountMessage = () => {
421
- const currentStatusByLocale = rows.reduce((acc, { locale, status }) => {
422
- acc[locale] = status;
423
- return acc;
424
- }, {});
425
- const localesWithErrors = Object.keys(validationErrors);
426
- const publishedCount = selectedRows.filter(
427
- ({ locale }) => currentStatusByLocale[locale] === "published"
428
- ).length;
429
- const draftCount = selectedRows.filter(
430
- ({ locale }) => (currentStatusByLocale[locale] === "draft" || currentStatusByLocale[locale] === "modified") && !localesWithErrors.includes(locale)
431
- ).length;
432
- const withErrorsCount = localesWithErrors.length;
433
- const messageId = action === "bulk-publish" ? "content-manager.containers.list.selectedEntriesModal.selectedCount.publish" : "content-manager.containers.list.selectedEntriesModal.selectedCount.unpublish";
434
- const defaultMessage = action === "bulk-publish" ? "<b>{publishedCount}</b> {publishedCount, plural, =0 {entries} one {entry} other {entries}} already published. <b>{draftCount}</b> {draftCount, plural, =0 {entries} one {entry} other {entries}} ready to publish. <b>{withErrorsCount}</b> {withErrorsCount, plural, =0 {entries} one {entry} other {entries}} waiting for action." : "<b>{draftCount}</b> {draftCount, plural, =0 {entries} one {entry} other {entries}} already unpublished. <b>{publishedCount}</b> {publishedCount, plural, =0 {entries} one {entry} other {entries}} ready to unpublish.";
435
- return formatMessage(
436
- {
437
- id: messageId,
438
- defaultMessage
439
- },
440
- {
441
- withErrorsCount,
442
- draftCount,
443
- publishedCount,
444
- b: BoldChunk
445
- }
446
- );
447
- };
448
- return /* @__PURE__ */ jsxs(Modal.Body, { children: [
449
- /* @__PURE__ */ jsx(Typography, { children: getFormattedCountMessage() }),
450
- /* @__PURE__ */ jsx(Box, { marginTop: 5, children: /* @__PURE__ */ jsxs(Table.Content, { children: [
451
- /* @__PURE__ */ jsxs(Table.Head, { children: [
452
- /* @__PURE__ */ jsx(Table.HeaderCheckboxCell, {}),
453
- headers.map((head) => /* @__PURE__ */ jsx(Table.HeaderCell, { ...head }, head.name))
454
- ] }),
455
- /* @__PURE__ */ jsx(Table.Body, { children: rows.map(({ locale, status }, index2) => {
456
- const error = validationErrors?.[locale] ?? null;
457
- const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
458
- return /* @__PURE__ */ jsxs(Table.Row, { children: [
459
- /* @__PURE__ */ jsx(Table.CheckboxCell, { id: locale, "aria-label": `Select ${locale}` }),
460
- /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: Array.isArray(localesMetadata) ? localesMetadata.find((localeEntry) => localeEntry.code === locale)?.name : locale }) }),
461
- /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Box, { display: "flex", children: /* @__PURE__ */ jsx(
462
- Status,
463
- {
464
- display: "flex",
465
- paddingLeft: "6px",
466
- paddingRight: "6px",
467
- paddingTop: "2px",
468
- paddingBottom: "2px",
469
- size: "S",
470
- variant: statusVariant,
471
- children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
472
- }
473
- ) }) }),
474
- /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(EntryValidationText, { validationErrors: error, status, action }) }),
475
- /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(
476
- IconButton,
477
- {
478
- tag: Link,
479
- to: {
480
- search: stringify({ plugins: { i18n: { locale } } })
481
- },
482
- label: formatMessage(
483
- {
484
- id: getTranslation("Settings.list.actions.edit"),
485
- defaultMessage: "Edit {name} locale"
486
- },
487
- {
488
- name: locale
489
- }
490
- ),
491
- variant: "ghost",
492
- children: /* @__PURE__ */ jsx(Pencil, {})
493
- }
494
- ) })
495
- ] }, index2);
496
- }) })
497
- ] }) })
498
- ] });
499
- };
500
- const statusVariants = {
501
- draft: "secondary",
502
- published: "success",
503
- modified: "alternative"
504
- };
505
- const LocaleOption = ({
506
- isDraftAndPublishEnabled,
507
- locale,
508
- status,
509
- entryExists
510
- }) => {
511
- const { formatMessage } = useIntl();
512
- if (!entryExists) {
513
- return formatMessage(
514
- {
515
- id: getTranslation("CMEditViewLocalePicker.locale.create"),
516
- defaultMessage: "Create <bold>{locale}</bold> locale"
517
- },
518
- {
519
- bold: (locale2) => /* @__PURE__ */ jsx("b", { children: locale2 }),
520
- locale: locale.name
521
- }
522
- );
523
- }
524
- return /* @__PURE__ */ jsxs(Flex, { width: "100%", gap: 1, justifyContent: "space-between", children: [
525
- /* @__PURE__ */ jsx(Typography, { children: locale.name }),
526
- isDraftAndPublishEnabled ? /* @__PURE__ */ jsx(
527
- Status,
528
- {
529
- display: "flex",
530
- paddingLeft: "6px",
531
- paddingRight: "6px",
532
- paddingTop: "2px",
533
- paddingBottom: "2px",
534
- size: "S",
535
- variant: statusVariants[status],
536
- children: /* @__PURE__ */ jsx(Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
537
- }
538
- ) : null
539
- ] });
540
- };
541
- const LocalePickerAction = ({
542
- document,
543
- meta,
544
- model,
545
- collectionType,
546
- documentId
547
- }) => {
548
- const { formatMessage } = useIntl();
549
- const [{ query }, setQuery] = useQueryParams();
550
- const { hasI18n, canCreate, canRead } = useI18n();
551
- const { data: locales = [] } = useGetLocalesQuery();
552
- const currentDesiredLocale = query.plugins?.i18n?.locale;
553
- const { schema } = unstable_useDocument({
554
- model,
555
- collectionType,
556
- documentId,
557
- params: { locale: currentDesiredLocale }
558
- });
559
- const handleSelect = React.useCallback(
560
- (value) => {
561
- setQuery({
562
- plugins: {
563
- ...query.plugins,
564
- i18n: {
565
- locale: value
566
- }
567
- }
568
- });
569
- },
570
- [query.plugins, setQuery]
571
- );
572
- React.useEffect(() => {
573
- if (!Array.isArray(locales) || !hasI18n) {
574
- return;
575
- }
576
- const doesLocaleExist = locales.find((loc) => loc.code === currentDesiredLocale);
577
- const defaultLocale = locales.find((locale) => locale.isDefault);
578
- if (!doesLocaleExist && defaultLocale?.code) {
579
- handleSelect(defaultLocale.code);
580
- }
581
- }, [handleSelect, hasI18n, locales, currentDesiredLocale]);
582
- const currentLocale = Array.isArray(locales) ? locales.find((locale) => locale.code === currentDesiredLocale) : void 0;
583
- const allCurrentLocales = [
584
- { status: getDocumentStatus(document, meta), locale: currentLocale?.code },
585
- ...meta?.availableLocales ?? []
586
- ];
587
- if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {
588
- return null;
589
- }
590
- const displayedLocales = locales.filter((locale) => {
591
- return canRead.includes(locale.code);
592
- });
593
- return {
594
- label: formatMessage({
595
- id: getTranslation("Settings.locales.modal.locales.label"),
596
- defaultMessage: "Locales"
597
- }),
598
- options: displayedLocales.map((locale) => {
599
- const entryWithLocaleExists = allCurrentLocales.some((doc) => doc.locale === locale.code);
600
- const currentLocaleDoc = allCurrentLocales.find(
601
- (doc) => "locale" in doc ? doc.locale === locale.code : false
602
- );
603
- const permissionsToCheck = currentLocaleDoc ? canRead : canCreate;
604
- return {
605
- disabled: !permissionsToCheck.includes(locale.code),
606
- value: locale.code,
607
- label: /* @__PURE__ */ jsx(
608
- LocaleOption,
609
- {
610
- isDraftAndPublishEnabled: !!schema?.options?.draftAndPublish,
611
- locale,
612
- status: currentLocaleDoc?.status,
613
- entryExists: entryWithLocaleExists
614
- }
615
- ),
616
- startIcon: !entryWithLocaleExists ? /* @__PURE__ */ jsx(Plus, {}) : null
617
- };
618
- }),
619
- customizeContent: () => currentLocale?.name,
620
- onSelect: handleSelect,
621
- value: currentLocale
622
- };
623
- };
624
- const getDocumentStatus = (document, meta) => {
625
- const docStatus = document?.status;
626
- const statuses = meta?.availableStatus ?? [];
627
- if (!docStatus) {
628
- return "draft";
629
- }
630
- if (docStatus === "draft" && statuses.find((doc) => doc.publishedAt !== null)) {
631
- return "published";
632
- }
633
- return docStatus;
634
- };
635
- const FillFromAnotherLocaleAction = ({
636
- documentId,
637
- meta,
638
- model,
639
- collectionType
640
- }) => {
641
- const { formatMessage } = useIntl();
642
- const [{ query }] = useQueryParams();
643
- const { hasI18n } = useI18n();
644
- const currentDesiredLocale = query.plugins?.i18n?.locale;
645
- const [localeSelected, setLocaleSelected] = React.useState(null);
646
- const setValues = useForm("FillFromAnotherLocale", (state) => state.setValues);
647
- const { getDocument } = unstable_useDocumentActions();
648
- const { schema, components } = unstable_useDocument({
649
- model,
650
- documentId,
651
- collectionType,
652
- params: { locale: currentDesiredLocale }
653
- });
654
- const { data: locales = [] } = useGetLocalesQuery();
655
- const availableLocales = Array.isArray(locales) ? locales.filter((locale) => meta?.availableLocales.some((l) => l.locale === locale.code)) : [];
656
- const fillFromLocale = (onClose) => async () => {
657
- const response = await getDocument({
658
- collectionType,
659
- model,
660
- documentId,
661
- params: { locale: localeSelected }
662
- });
663
- if (!response || !schema) {
664
- return;
665
- }
666
- const { data } = response;
667
- const cleanedData = cleanData(data, schema, components);
668
- setValues(cleanedData);
669
- onClose();
670
- };
671
- if (!hasI18n) {
672
- return null;
673
- }
674
- return {
675
- type: "icon",
676
- icon: /* @__PURE__ */ jsx(Download, {}),
677
- disabled: availableLocales.length === 0,
678
- label: formatMessage({
679
- id: getTranslation("CMEditViewCopyLocale.copy-text"),
680
- defaultMessage: "Fill in from another locale"
681
- }),
682
- dialog: {
683
- type: "dialog",
684
- title: formatMessage({
685
- id: getTranslation("CMEditViewCopyLocale.dialog.title"),
686
- defaultMessage: "Confirmation"
687
- }),
688
- content: ({ onClose }) => /* @__PURE__ */ jsxs(Fragment, { children: [
689
- /* @__PURE__ */ jsx(Dialog.Body, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 3, children: [
690
- /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
691
- /* @__PURE__ */ jsx(Typography, { textAlign: "center", children: formatMessage({
692
- id: getTranslation("CMEditViewCopyLocale.dialog.body"),
693
- defaultMessage: "Your current content will be erased and filled by the content of the selected locale:"
694
- }) }),
695
- /* @__PURE__ */ jsxs(Field.Root, { width: "100%", children: [
696
- /* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
697
- id: getTranslation("CMEditViewCopyLocale.dialog.field.label"),
698
- defaultMessage: "Locale"
699
- }) }),
700
- /* @__PURE__ */ jsx(
701
- SingleSelect,
702
- {
703
- value: localeSelected,
704
- placeholder: formatMessage({
705
- id: getTranslation("CMEditViewCopyLocale.dialog.field.placeholder"),
706
- defaultMessage: "Select one locale..."
707
- }),
708
- onChange: (value) => setLocaleSelected(value),
709
- children: availableLocales.map((locale) => /* @__PURE__ */ jsx(SingleSelectOption, { value: locale.code, children: locale.name }, locale.code))
710
- }
711
- )
712
- ] })
713
- ] }) }),
714
- /* @__PURE__ */ jsx(Dialog.Footer, { children: /* @__PURE__ */ jsxs(Flex, { gap: 2, width: "100%", children: [
715
- /* @__PURE__ */ jsx(Button, { flex: "auto", variant: "tertiary", onClick: onClose, children: formatMessage({
716
- id: getTranslation("CMEditViewCopyLocale.cancel-text"),
717
- defaultMessage: "No, cancel"
718
- }) }),
719
- /* @__PURE__ */ jsx(Button, { flex: "auto", variant: "success", onClick: fillFromLocale(onClose), children: formatMessage({
720
- id: getTranslation("CMEditViewCopyLocale.submit-text"),
721
- defaultMessage: "Yes, fill in"
722
- }) })
723
- ] }) })
724
- ] })
725
- }
726
- };
727
- };
728
- const DeleteLocaleAction = ({
729
- document,
730
- documentId,
731
- model,
732
- collectionType
733
- }) => {
734
- const { formatMessage } = useIntl();
735
- const navigate = useNavigate();
736
- const { toggleNotification } = useNotification();
737
- const { delete: deleteAction } = unstable_useDocumentActions();
738
- const { hasI18n, canDelete } = useI18n();
739
- const [{ query }] = useQueryParams();
740
- const { data: locales = [] } = useGetLocalesQuery();
741
- const currentDesiredLocale = query.plugins?.i18n?.locale;
742
- const locale = !("error" in locales) && locales.find((loc) => loc.code === currentDesiredLocale);
743
- if (!hasI18n) {
744
- return null;
745
- }
746
- return {
747
- disabled: document?.locale && !canDelete.includes(document.locale) || !document || !document.id,
748
- position: ["header", "table-row"],
749
- label: formatMessage(
750
- {
751
- id: getTranslation("actions.delete.label"),
752
- defaultMessage: "Delete entry ({locale})"
753
- },
754
- { locale: locale && locale.name }
755
- ),
756
- icon: /* @__PURE__ */ jsx(StyledTrash, {}),
757
- variant: "danger",
758
- dialog: {
759
- type: "dialog",
760
- title: formatMessage({
761
- id: getTranslation("actions.delete.dialog.title"),
762
- defaultMessage: "Confirmation"
763
- }),
764
- content: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
765
- /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
766
- /* @__PURE__ */ jsx(Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
767
- id: getTranslation("actions.delete.dialog.body"),
768
- defaultMessage: "Are you sure?"
769
- }) })
770
- ] }),
771
- onConfirm: async () => {
772
- const unableToDelete = (
773
- // We are unable to delete a collection type without a document ID
774
- // & unable to delete generally if there is no document locale
775
- collectionType !== "single-types" && !documentId || !document?.locale
776
- );
777
- if (unableToDelete) {
778
- console.error(
779
- "You're trying to delete a document without an id or locale, this is likely a bug with Strapi. Please open an issue."
780
- );
781
- toggleNotification({
782
- message: formatMessage({
783
- id: getTranslation("actions.delete.error"),
784
- defaultMessage: "An error occurred while trying to delete the document locale."
785
- }),
786
- type: "danger"
787
- });
788
- return;
789
- }
790
- const res = await deleteAction({
791
- documentId,
792
- model,
793
- collectionType,
794
- params: { locale: document.locale }
795
- });
796
- if (!("error" in res)) {
797
- navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
798
- }
799
- }
800
- }
801
- };
802
- };
803
- const BulkLocaleAction = ({
804
- document: baseDocument,
805
- documentId,
806
- model,
807
- collectionType,
808
- action
809
- }) => {
810
- const baseLocale = baseDocument?.locale ?? null;
811
- const [{ query }] = useQueryParams();
812
- const params = React.useMemo(() => buildValidParams(query), [query]);
813
- const isOnPublishedTab = query.status === "published";
814
- const { formatMessage } = useIntl();
815
- const { hasI18n, canPublish } = useI18n();
816
- const { toggleNotification } = useNotification();
817
- const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
818
- const [selectedRows, setSelectedRows] = React.useState([]);
819
- const [isDraftRelationConfirmationOpen, setIsDraftRelationConfirmationOpen] = React.useState(false);
820
- const { publishMany: publishManyAction, unpublishMany: unpublishManyAction } = unstable_useDocumentActions();
821
- const {
822
- document,
823
- meta: documentMeta,
824
- schema,
825
- validate
826
- } = unstable_useDocument(
827
- {
828
- model,
829
- collectionType,
830
- documentId,
831
- params: {
832
- locale: baseLocale
833
- }
834
- },
835
- {
836
- skip: !hasI18n || !baseLocale
837
- }
838
- );
839
- const { data: localesMetadata = [] } = useGetLocalesQuery(hasI18n ? void 0 : skipToken);
840
- const headers = [
841
- {
842
- label: formatMessage({
843
- id: "global.name",
844
- defaultMessage: "Name"
845
- }),
846
- name: "name"
847
- },
848
- {
849
- label: formatMessage({
850
- id: getTranslation("CMEditViewBulkLocale.status"),
851
- defaultMessage: "Status"
852
- }),
853
- name: "status"
854
- },
855
- {
856
- label: formatMessage({
857
- id: getTranslation("CMEditViewBulkLocale.publication-status"),
858
- defaultMessage: "Publication Status"
859
- }),
860
- name: "publication-status"
861
- }
862
- ];
863
- const [rows, validationErrors] = React.useMemo(() => {
864
- if (!document || !documentMeta?.availableLocales) {
865
- return [[], {}];
866
- }
867
- const rowsFromMeta = documentMeta?.availableLocales.map((doc) => {
868
- const { locale, status } = doc;
869
- return { locale, status };
870
- });
871
- rowsFromMeta.unshift({
872
- locale: document.locale,
873
- status: document.status
874
- });
875
- const allDocuments = [document, ...documentMeta?.availableLocales ?? []];
876
- const errors = allDocuments.reduce((errs, document2) => {
877
- if (!document2) {
878
- return errs;
879
- }
880
- const validation = validate(document2);
881
- if (validation !== null) {
882
- errs[document2.locale] = validation;
883
- }
884
- return errs;
885
- }, {});
886
- return [rowsFromMeta, errors];
887
- }, [document, documentMeta?.availableLocales, validate]);
888
- const isBulkPublish = action === "bulk-publish";
889
- const localesForAction = selectedRows.reduce((acc, selectedRow) => {
890
- const isValidLocale = (
891
- // Validation errors are irrelevant if we are trying to unpublish
892
- !isBulkPublish || !Object.keys(validationErrors).includes(selectedRow.locale)
893
- );
894
- const shouldAddLocale = isBulkPublish ? selectedRow.status !== "published" && isValidLocale : selectedRow.status !== "draft" && isValidLocale;
895
- if (shouldAddLocale) {
896
- acc.push(selectedRow.locale);
897
- }
898
- return acc;
899
- }, []);
900
- const enableDraftRelationsCount = false;
901
- const {
902
- data: draftRelationsCount = 0,
903
- isLoading: isDraftRelationsLoading,
904
- error: isDraftRelationsError
905
- } = useGetManyDraftRelationCountQuery(
906
- {
907
- model,
908
- documentIds: [documentId],
909
- locale: localesForAction
910
- },
911
- {
912
- skip: !enableDraftRelationsCount
913
- }
914
- );
915
- React.useEffect(() => {
916
- if (isDraftRelationsError) {
917
- toggleNotification({
918
- type: "danger",
919
- message: formatAPIError(isDraftRelationsError)
920
- });
921
- }
922
- }, [isDraftRelationsError, toggleNotification, formatAPIError]);
923
- if (!schema?.options?.draftAndPublish) {
924
- return null;
925
- }
926
- if (!hasI18n) {
927
- return null;
928
- }
929
- if (!documentId) {
930
- return null;
931
- }
932
- const publish = async () => {
933
- await publishManyAction({
934
- model,
935
- documentIds: [documentId],
936
- params: {
937
- ...params,
938
- locale: localesForAction
939
- }
940
- });
941
- setSelectedRows([]);
942
- };
943
- const unpublish = async () => {
944
- await unpublishManyAction({
945
- model,
946
- documentIds: [documentId],
947
- params: {
948
- ...params,
949
- locale: localesForAction
950
- }
951
- });
952
- setSelectedRows([]);
953
- };
954
- const handleAction = async () => {
955
- if (draftRelationsCount > 0) {
956
- setIsDraftRelationConfirmationOpen(true);
957
- } else if (isBulkPublish) {
958
- await publish();
959
- } else {
960
- await unpublish();
961
- }
962
- };
963
- if (isDraftRelationConfirmationOpen) {
964
- return {
965
- label: formatMessage({
966
- id: "app.components.ConfirmDialog.title",
967
- defaultMessage: "Confirmation"
968
- }),
969
- variant: "danger",
970
- dialog: {
971
- onCancel: () => {
972
- setIsDraftRelationConfirmationOpen(false);
973
- },
974
- onConfirm: async () => {
975
- await publish();
976
- setIsDraftRelationConfirmationOpen(false);
977
- },
978
- type: "dialog",
979
- title: formatMessage({
980
- id: getTranslation("actions.publish.dialog.title"),
981
- defaultMessage: "Confirmation"
982
- }),
983
- content: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "center", gap: 2, children: [
984
- /* @__PURE__ */ jsx(WarningCircle, { width: "2.4rem", height: "2.4rem", fill: "danger600" }),
985
- /* @__PURE__ */ jsx(Typography, { textAlign: "center", children: formatMessage({
986
- id: getTranslation("CMEditViewBulkLocale.draft-relation-warning"),
987
- defaultMessage: "Some locales are related to draft entries. Publishing them could leave broken links in your app."
988
- }) }),
989
- /* @__PURE__ */ jsx(Typography, { textAlign: "center", children: formatMessage({
990
- id: getTranslation("CMEditViewBulkLocale.continue-confirmation"),
991
- defaultMessage: "Are you sure you want to continue?"
992
- }) })
993
- ] })
994
- }
995
- };
996
- }
997
- const hasPermission = selectedRows.map(({ locale }) => locale).every((locale) => canPublish.includes(locale));
998
- return {
999
- label: formatMessage({
1000
- id: getTranslation(`CMEditViewBulkLocale.${isBulkPublish ? "publish" : "unpublish"}-title`),
1001
- defaultMessage: `${isBulkPublish ? "Publish" : "Unpublish"} Multiple Locales`
1002
- }),
1003
- variant: isBulkPublish ? "secondary" : "danger",
1004
- icon: isBulkPublish ? /* @__PURE__ */ jsx(ListPlus, {}) : /* @__PURE__ */ jsx(Cross, {}),
1005
- disabled: isOnPublishedTab || canPublish.length === 0,
1006
- position: ["panel"],
1007
- dialog: {
1008
- type: "modal",
1009
- title: formatMessage({
1010
- id: getTranslation(`CMEditViewBulkLocale.${isBulkPublish ? "publish" : "unpublish"}-title`),
1011
- defaultMessage: `${isBulkPublish ? "Publish" : "Unpublish"} Multiple Locales`
1012
- }),
1013
- content: () => {
1014
- return /* @__PURE__ */ jsx(
1015
- Table.Root,
1016
- {
1017
- headers,
1018
- rows: rows.map((row) => ({
1019
- ...row,
1020
- id: row.locale
1021
- })),
1022
- selectedRows,
1023
- onSelectedRowsChange: (tableSelectedRows) => setSelectedRows(tableSelectedRows),
1024
- children: /* @__PURE__ */ jsx(
1025
- BulkLocaleActionModal,
1026
- {
1027
- validationErrors,
1028
- headers,
1029
- rows,
1030
- localesMetadata,
1031
- action: action ?? "bulk-publish"
1032
- }
1033
- )
1034
- }
1035
- );
1036
- },
1037
- footer: () => /* @__PURE__ */ jsx(Modal.Footer, { justifyContent: "flex-end", children: /* @__PURE__ */ jsx(
1038
- Button,
1039
- {
1040
- loading: isDraftRelationsLoading,
1041
- disabled: !hasPermission || localesForAction.length === 0,
1042
- variant: "default",
1043
- onClick: handleAction,
1044
- children: formatMessage({
1045
- id: isBulkPublish ? "app.utils.publish" : "app.utils.unpublish",
1046
- defaultMessage: isBulkPublish ? "Publish" : "Unpublish"
1047
- })
1048
- }
1049
- ) })
1050
- }
1051
- };
1052
- };
1053
- const BulkLocalePublishAction = (props) => {
1054
- return BulkLocaleAction({ action: "bulk-publish", ...props });
1055
- };
1056
- const BulkLocaleUnpublishAction = (props) => {
1057
- return BulkLocaleAction({ action: "bulk-unpublish", ...props });
1058
- };
1059
- const StyledTrash = styled(Trash)`
1060
- path {
1061
- fill: currentColor;
1062
- }
1063
- `;
1064
- const Emphasis = (chunks) => {
1065
- return /* @__PURE__ */ jsx(Typography, { fontWeight: "semiBold", textColor: "danger500", children: chunks });
1066
- };
1067
- const DeleteModalAdditionalInfo = () => {
1068
- const { hasI18n } = useI18n();
1069
- const { formatMessage } = useIntl();
1070
- if (!hasI18n) {
1071
- return null;
1072
- }
1073
- return /* @__PURE__ */ jsx(Typography, { textColor: "danger500", children: formatMessage(
1074
- {
1075
- id: getTranslation("Settings.list.actions.deleteAdditionalInfos"),
1076
- defaultMessage: "This will delete the active locale versions <em>(from Internationalization)</em>"
1077
- },
1078
- {
1079
- em: Emphasis
1080
- }
1081
- ) });
1082
- };
1083
- const PublishModalAdditionalInfo = () => {
1084
- const { hasI18n } = useI18n();
1085
- const { formatMessage } = useIntl();
1086
- if (!hasI18n) {
1087
- return null;
1088
- }
1089
- return /* @__PURE__ */ jsx(Typography, { textColor: "danger500", children: formatMessage(
1090
- {
1091
- id: getTranslation("Settings.list.actions.publishAdditionalInfos"),
1092
- defaultMessage: "This will publish the active locale versions <em>(from Internationalization)</em>"
1093
- },
1094
- {
1095
- em: Emphasis
1096
- }
1097
- ) });
1098
- };
1099
- const UnpublishModalAdditionalInfo = () => {
1100
- const { hasI18n } = useI18n();
1101
- const { formatMessage } = useIntl();
1102
- if (!hasI18n) {
1103
- return null;
1104
- }
1105
- return /* @__PURE__ */ jsx(Typography, { textColor: "danger500", children: formatMessage(
1106
- {
1107
- id: getTranslation("Settings.list.actions.unpublishAdditionalInfos"),
1108
- defaultMessage: "This will unpublish the active locale versions <em>(from Internationalization)</em>"
1109
- },
1110
- {
1111
- em: Emphasis
1112
- }
1113
- ) });
1114
- };
1115
- const LocalePicker = () => {
1116
- const { formatMessage } = useIntl();
1117
- const [{ query }, setQuery] = useQueryParams();
1118
- const { hasI18n, canRead, canCreate } = useI18n();
1119
- const { data: locales = [] } = useGetLocalesQuery(void 0, {
1120
- skip: !hasI18n
1121
- });
1122
- const handleChange = React.useCallback(
1123
- (code, replace = false) => {
1124
- setQuery(
1125
- {
1126
- page: 1,
1127
- plugins: { ...query.plugins, i18n: { locale: code } }
1128
- },
1129
- "push",
1130
- replace
1131
- );
1132
- },
1133
- [query.plugins, setQuery]
1134
- );
1135
- React.useEffect(() => {
1136
- if (!Array.isArray(locales) || !hasI18n) {
1137
- return;
1138
- }
1139
- const currentDesiredLocale = query.plugins?.i18n?.locale;
1140
- const doesLocaleExist = locales.find((loc) => loc.code === currentDesiredLocale);
1141
- const defaultLocale = locales.find((locale) => locale.isDefault);
1142
- if (!doesLocaleExist && defaultLocale?.code) {
1143
- handleChange(defaultLocale.code, true);
1144
- }
1145
- }, [hasI18n, handleChange, locales, query.plugins?.i18n?.locale]);
1146
- if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {
1147
- return null;
1148
- }
1149
- const displayedLocales = locales.filter((locale) => {
1150
- return canCreate.includes(locale.code) || canRead.includes(locale.code);
1151
- });
1152
- return /* @__PURE__ */ jsx(
1153
- SingleSelect,
1154
- {
1155
- size: "S",
1156
- "aria-label": formatMessage({
1157
- id: getTranslation("actions.select-locale"),
1158
- defaultMessage: "Select locale"
1159
- }),
1160
- value: query.plugins?.i18n?.locale || locales.find((locale) => locale.isDefault)?.code,
1161
- onChange: handleChange,
1162
- children: displayedLocales.map((locale) => /* @__PURE__ */ jsx(SingleSelectOption, { value: locale.code, children: locale.name }, locale.id))
1163
- }
1164
- );
1165
- };
1166
- const PERMISSIONS = {
1167
- accessMain: [{ action: "plugin::i18n.locale.read", subject: null }],
1168
- create: [{ action: "plugin::i18n.locale.create", subject: null }],
1169
- delete: [{ action: "plugin::i18n.locale.delete", subject: null }],
1170
- update: [{ action: "plugin::i18n.locale.update", subject: null }],
1171
- read: [{ action: "plugin::i18n.locale.read", subject: null }]
1172
- };
1173
- const mutateEditViewHook = ({ layout }) => {
1174
- if (!("i18n" in layout.options) || typeof layout.options.i18n === "object" && layout.options.i18n !== null && "localized" in layout.options.i18n && !layout.options.i18n.localized) {
1175
- return { layout };
1176
- }
1177
- const components = Object.entries(layout.components).reduce(
1178
- (acc, [key, componentLayout]) => {
1179
- return {
1180
- ...acc,
1181
- [key]: {
1182
- ...componentLayout,
1183
- layout: componentLayout.layout.map((row) => row.map(addLabelActionToField))
1184
- }
1185
- };
1186
- },
1187
- {}
1188
- );
1189
- return {
1190
- layout: {
1191
- ...layout,
1192
- components,
1193
- layout: layout.layout.map((panel) => panel.map((row) => row.map(addLabelActionToField)))
1194
- }
1195
- };
1196
- };
1197
- const addLabelActionToField = (field) => {
1198
- const isFieldLocalized = doesFieldHaveI18nPluginOpt(field.attribute.pluginOptions) ? field.attribute.pluginOptions.i18n.localized : true;
1199
- const labelActionProps = {
1200
- title: {
1201
- id: isFieldLocalized ? getTranslation("Field.localized") : getTranslation("Field.not-localized"),
1202
- defaultMessage: isFieldLocalized ? "This value is unique for the selected locale" : "This value is the same across all locales"
1203
- },
1204
- icon: isFieldLocalized ? /* @__PURE__ */ jsx(Earth, {}) : /* @__PURE__ */ jsx(EarthStriked, {})
1205
- };
1206
- return {
1207
- ...field,
1208
- labelAction: /* @__PURE__ */ jsx(LabelAction, { ...labelActionProps })
1209
- };
1210
- };
1211
- const doesFieldHaveI18nPluginOpt = (pluginOpts) => {
1212
- if (!pluginOpts) {
1213
- return false;
1214
- }
1215
- return "i18n" in pluginOpts && typeof pluginOpts.i18n === "object" && pluginOpts.i18n !== null && "localized" in pluginOpts.i18n;
1216
- };
1217
- const LabelAction = ({ title, icon }) => {
1218
- const { formatMessage } = useIntl();
1219
- return /* @__PURE__ */ jsxs(Span, { tag: "span", children: [
1220
- /* @__PURE__ */ jsx(VisuallyHidden, { tag: "span", children: formatMessage(title) }),
1221
- React.cloneElement(icon, {
1222
- "aria-hidden": true,
1223
- focusable: false
1224
- // See: https://allyjs.io/tutorials/focusing-in-svg.html#making-svg-elements-focusable
1225
- })
1226
- ] });
1227
- };
1228
- const Span = styled(Flex)`
1229
- svg {
1230
- width: 12px;
1231
- height: 12px;
1232
-
1233
- fill: ${({ theme }) => theme.colors.neutral500};
1234
-
1235
- path {
1236
- fill: ${({ theme }) => theme.colors.neutral500};
1237
- }
1238
- }
1239
- `;
1240
- const LocaleListCell = ({
1241
- documentId,
1242
- locale: currentLocale,
1243
- collectionType,
1244
- model
1245
- }) => {
1246
- const { meta, isLoading } = unstable_useDocument({
1247
- documentId,
1248
- collectionType,
1249
- model,
1250
- params: {
1251
- locale: currentLocale
1252
- }
1253
- });
1254
- const { locale: language } = useIntl();
1255
- const { data: locales = [] } = useGetLocalesQuery();
1256
- const formatter = useCollator(language, {
1257
- sensitivity: "base"
1258
- });
1259
- if (!Array.isArray(locales) || isLoading) {
1260
- return null;
1261
- }
1262
- const availableLocales = meta?.availableLocales.map((doc) => doc.locale) ?? [];
1263
- const localesForDocument = locales.reduce((acc, locale) => {
1264
- const createdLocale = [currentLocale, ...availableLocales].find((loc) => {
1265
- return loc === locale.code;
1266
- });
1267
- if (createdLocale) {
1268
- acc.push(locale);
1269
- }
1270
- return acc;
1271
- }, []).map((locale) => {
1272
- if (locale.isDefault) {
1273
- return `${locale.name} (default)`;
1274
- }
1275
- return locale.name;
1276
- }).toSorted((a, b) => formatter.compare(a, b));
1277
- return /* @__PURE__ */ jsxs(Popover.Root, { children: [
1278
- /* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx(Button, { variant: "ghost", type: "button", onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxs(Flex, { minWidth: "100%", alignItems: "center", justifyContent: "center", fontWeight: "regular", children: [
1279
- /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", ellipsis: true, marginRight: 2, children: localesForDocument.join(", ") }),
1280
- /* @__PURE__ */ jsx(Flex, { children: /* @__PURE__ */ jsx(CaretDown, { width: "1.2rem", height: "1.2rem" }) })
1281
- ] }) }) }),
1282
- /* @__PURE__ */ jsx(Popover.Content, { sideOffset: 16, children: /* @__PURE__ */ jsx("ul", { children: localesForDocument.map((name) => /* @__PURE__ */ jsx(Box, { padding: 3, tag: "li", children: /* @__PURE__ */ jsx(Typography, { children: name }) }, name)) }) })
1283
- ] });
1284
- };
1285
- const addColumnToTableHook = ({ displayedHeaders, layout }) => {
1286
- const { options } = layout;
1287
- const isFieldLocalized = doesPluginOptionsHaveI18nLocalized(options) ? options.i18n.localized : false;
1288
- if (!isFieldLocalized) {
1289
- return { displayedHeaders, layout };
1290
- }
1291
- return {
1292
- displayedHeaders: [
1293
- ...displayedHeaders,
1294
- {
1295
- attribute: { type: "string" },
1296
- label: {
1297
- id: getTranslation("list-view.table.header.label"),
1298
- defaultMessage: "Available in"
1299
- },
1300
- searchable: false,
1301
- sortable: false,
1302
- name: "locales",
1303
- // @ts-expect-error – ID is seen as number | string; this will change when we move the type over.
1304
- cellFormatter: (props, _header, meta) => /* @__PURE__ */ jsx(LocaleListCell, { ...props, ...meta })
1305
- }
1306
- ],
1307
- layout
1308
- };
1309
- };
1310
- const addLocaleToReleasesHook = ({ displayedHeaders = [] }) => {
1311
- return {
1312
- displayedHeaders: [
1313
- ...displayedHeaders,
1314
- {
1315
- label: {
1316
- id: "content-releases.page.ReleaseDetails.table.header.label.locale",
1317
- defaultMessage: "locale"
1318
- },
1319
- name: "locale"
1320
- }
1321
- ],
1322
- hasI18nEnabled: true
1323
- };
1324
- };
1325
- const extendCTBAttributeInitialDataMiddleware = () => {
1326
- return ({ getState }) => (next) => (action) => {
1327
- const enhanceAction = () => {
1328
- try {
1329
- const store = getState();
1330
- const hasi18nEnabled = get(
1331
- store,
1332
- [
1333
- "content-type-builder_dataManagerProvider",
1334
- "modifiedData",
1335
- "contentType",
1336
- "schema",
1337
- "pluginOptions",
1338
- "i18n",
1339
- "localized"
1340
- ],
1341
- false
1342
- );
1343
- if (hasi18nEnabled) {
1344
- const pluginOptions = action.options ? { ...action.options.pluginOptions, i18n: { localized: true } } : { i18n: { localized: true } };
1345
- return next({
1346
- ...action,
1347
- options: {
1348
- pluginOptions
1349
- }
1350
- });
1351
- }
1352
- return next(action);
1353
- } catch (err) {
1354
- return next(action);
1355
- }
1356
- };
1357
- if (action.type === "ContentTypeBuilder/FormModal/SET_ATTRIBUTE_DATA_SCHEMA" && action.forTarget === "contentType" && !["relation", "component"].includes(action.attributeType) && !action.isEditing) {
1358
- return enhanceAction();
1359
- }
1360
- if (action.type === "ContentTypeBuilder/FormModal/SET_CUSTOM_FIELD_DATA_SCHEMA" && action.forTarget === "contentType" && !action.isEditing) {
1361
- return enhanceAction();
1362
- }
1363
- if ((action.type === "ContentTypeBuilder/FormModal/RESET_PROPS_AND_SET_FORM_FOR_ADDING_AN_EXISTING_COMPO" || action.type === "ContentTypeBuilder/FormModal/RESET_PROPS_AND_SAVE_CURRENT_DATA") && action.forTarget === "contentType") {
1364
- return enhanceAction();
1365
- }
1366
- return next(action);
1367
- };
1368
- };
1369
- const extendCTBInitialDataMiddleware = () => {
1370
- return () => (next) => (action) => {
1371
- if (action.type === "ContentTypeBuilder/FormModal/SET_DATA_TO_EDIT" && action.modalType === "contentType") {
1372
- const i18n = { localized: false };
1373
- const pluginOptions = action.data.pluginOptions ? { ...action.data.pluginOptions, i18n } : { i18n };
1374
- const data = { ...action.data, pluginOptions };
1375
- if (action.actionType === "create") {
1376
- return next({ ...action, data });
1377
- }
1378
- if (!action.data.pluginOptions?.i18n?.localized) {
1379
- return next({ ...action, data });
1380
- }
1381
- }
1382
- return next(action);
1383
- };
1384
- };
1385
- const localeMiddleware = (ctx) => (next) => (permissions) => {
1386
- const match = matchPath("/content-manager/:collectionType/:model?/:id", ctx.pathname);
1387
- if (!match) {
1388
- return next(permissions);
1389
- }
1390
- const search = qs.parse(ctx.search);
1391
- if (typeof search !== "object") {
1392
- return next(permissions);
1393
- }
1394
- if (!("plugins" in search && typeof search.plugins === "object")) {
1395
- return next(permissions);
1396
- }
1397
- if (!("i18n" in search.plugins && typeof search.plugins.i18n === "object" && !Array.isArray(search.plugins.i18n))) {
1398
- return next(permissions);
1399
- }
1400
- const { locale } = search.plugins.i18n;
1401
- if (typeof locale !== "string") {
1402
- return next(permissions);
1403
- }
1404
- const revisedPermissions = permissions.filter(
1405
- (permission) => !permission.properties?.locales || permission.properties.locales.includes(locale)
1406
- );
1407
- return next(revisedPermissions);
1408
- };
1409
- const prefixPluginTranslations = (trad, pluginId2) => {
1410
- return Object.keys(trad).reduce((acc, current) => {
1411
- acc[`${pluginId2}.${current}`] = trad[current];
1412
- return acc;
1413
- }, {});
1414
- };
1415
- const mutateCTBContentTypeSchema = (nextSchema, prevSchema) => {
1416
- if (!doesPluginOptionsHaveI18nLocalized(nextSchema.pluginOptions)) {
1417
- return nextSchema;
1418
- }
1419
- const isNextSchemaLocalized = nextSchema.pluginOptions.i18n.localized;
1420
- const isPrevSchemaLocalized = doesPluginOptionsHaveI18nLocalized(
1421
- prevSchema?.schema?.pluginOptions
1422
- ) ? prevSchema?.schema?.pluginOptions.i18n.localized : false;
1423
- if (isNextSchemaLocalized && isPrevSchemaLocalized) {
1424
- return nextSchema;
1425
- }
1426
- if (isNextSchemaLocalized) {
1427
- const attributes = addLocalisationToFields(nextSchema.attributes);
1428
- return { ...nextSchema, attributes };
1429
- }
1430
- if (!isNextSchemaLocalized) {
1431
- const pluginOptions = omit(nextSchema.pluginOptions, "i18n");
1432
- const attributes = disableAttributesLocalisation(nextSchema.attributes);
1433
- return { ...nextSchema, pluginOptions, attributes };
1434
- }
1435
- return nextSchema;
1436
- };
1437
- const addLocalisationToFields = (attributes) => Object.keys(attributes).reduce((acc, current) => {
1438
- const currentAttribute = attributes[current];
1439
- if (LOCALIZED_FIELDS.includes(currentAttribute.type)) {
1440
- const i18n = { localized: true };
1441
- const pluginOptions = currentAttribute.pluginOptions ? { ...currentAttribute.pluginOptions, i18n } : { i18n };
1442
- acc[current] = { ...currentAttribute, pluginOptions };
1443
- return acc;
1444
- }
1445
- acc[current] = currentAttribute;
1446
- return acc;
1447
- }, {});
1448
- const disableAttributesLocalisation = (attributes) => Object.keys(attributes).reduce((acc, current) => {
1449
- acc[current] = omit(attributes[current], "pluginOptions.i18n");
1450
- return acc;
1451
- }, {});
1452
- const index = {
1453
- register(app) {
1454
- app.addMiddlewares([extendCTBAttributeInitialDataMiddleware, extendCTBInitialDataMiddleware]);
1455
- app.addMiddlewares([() => i18nApi.middleware]);
1456
- app.addReducers({
1457
- [i18nApi.reducerPath]: i18nApi.reducer
1458
- });
1459
- app.addRBACMiddleware([localeMiddleware]);
1460
- app.registerPlugin({
1461
- id: pluginId,
1462
- name: pluginId
1463
- });
1464
- },
1465
- bootstrap(app) {
1466
- app.registerHook("Admin/CM/pages/ListView/inject-column-in-table", addColumnToTableHook);
1467
- app.registerHook("Admin/CM/pages/EditView/mutate-edit-view-layout", mutateEditViewHook);
1468
- app.registerHook(
1469
- "ContentReleases/pages/ReleaseDetails/add-locale-in-releases",
1470
- addLocaleToReleasesHook
1471
- );
1472
- app.addSettingsLink("global", {
1473
- intlLabel: {
1474
- id: getTranslation("plugin.name"),
1475
- defaultMessage: "Internationalization"
1476
- },
1477
- id: "internationalization",
1478
- to: "internationalization",
1479
- Component: () => import("./SettingsPage-BAx9nmep.mjs").then((mod) => ({ default: mod.ProtectedSettingsPage })),
1480
- permissions: PERMISSIONS.accessMain
1481
- });
1482
- const contentManager = app.getPlugin("content-manager");
1483
- contentManager.apis.addDocumentHeaderAction([LocalePickerAction, FillFromAnotherLocaleAction]);
1484
- contentManager.apis.addDocumentAction((actions) => {
1485
- const indexOfDeleteAction = actions.findIndex((action) => action.type === "delete");
1486
- actions.splice(indexOfDeleteAction, 0, DeleteLocaleAction);
1487
- return actions;
1488
- });
1489
- contentManager.apis.addDocumentAction((actions) => {
1490
- actions.splice(2, 0, BulkLocalePublishAction);
1491
- actions.splice(5, 0, BulkLocaleUnpublishAction);
1492
- return actions;
1493
- });
1494
- contentManager.injectComponent("listView", "actions", {
1495
- name: "i18n-locale-filter",
1496
- Component: LocalePicker
1497
- });
1498
- contentManager.injectComponent("listView", "publishModalAdditionalInfos", {
1499
- name: "i18n-publish-bullets-in-modal",
1500
- Component: PublishModalAdditionalInfo
1501
- });
1502
- contentManager.injectComponent("listView", "unpublishModalAdditionalInfos", {
1503
- name: "i18n-unpublish-bullets-in-modal",
1504
- Component: UnpublishModalAdditionalInfo
1505
- });
1506
- contentManager.injectComponent("listView", "deleteModalAdditionalInfos", {
1507
- name: "i18n-delete-bullets-in-modal",
1508
- Component: DeleteModalAdditionalInfo
1509
- });
1510
- const ctbPlugin = app.getPlugin("content-type-builder");
1511
- if (ctbPlugin) {
1512
- const ctbFormsAPI = ctbPlugin.apis.forms;
1513
- ctbFormsAPI.addContentTypeSchemaMutation(mutateCTBContentTypeSchema);
1514
- ctbFormsAPI.components.add({ id: "checkboxConfirmation", component: CheckboxConfirmation });
1515
- ctbFormsAPI.extendContentType({
1516
- validator: () => ({
1517
- i18n: yup.object().shape({
1518
- localized: yup.bool()
1519
- })
1520
- }),
1521
- form: {
1522
- advanced() {
1523
- return [
1524
- {
1525
- name: "pluginOptions.i18n.localized",
1526
- description: {
1527
- id: getTranslation("plugin.schema.i18n.localized.description-content-type"),
1528
- defaultMessage: "Allows translating an entry into different languages"
1529
- },
1530
- type: "checkboxConfirmation",
1531
- intlLabel: {
1532
- id: getTranslation("plugin.schema.i18n.localized.label-content-type"),
1533
- defaultMessage: "Localization"
1534
- }
1535
- }
1536
- ];
1537
- }
1538
- }
1539
- });
1540
- ctbFormsAPI.extendFields(LOCALIZED_FIELDS, {
1541
- validator: (args) => ({
1542
- i18n: yup.object().shape({
1543
- localized: yup.bool().test({
1544
- name: "ensure-unique-localization",
1545
- message: getTranslation("plugin.schema.i18n.ensure-unique-localization"),
1546
- test(value) {
1547
- if (value === void 0 || value) {
1548
- return true;
1549
- }
1550
- const unique = get(args, ["3", "modifiedData", "unique"], null);
1551
- if (unique && !value) {
1552
- return false;
1553
- }
1554
- return true;
1555
- }
1556
- })
1557
- })
1558
- }),
1559
- form: {
1560
- advanced({ contentTypeSchema, forTarget, type, step }) {
1561
- if (forTarget !== "contentType") {
1562
- return [];
1563
- }
1564
- const hasI18nEnabled = get(
1565
- contentTypeSchema,
1566
- ["schema", "pluginOptions", "i18n", "localized"],
1567
- false
1568
- );
1569
- if (!hasI18nEnabled) {
1570
- return [];
1571
- }
1572
- if (type === "component" && step === "1") {
1573
- return [];
1574
- }
1575
- return [
1576
- {
1577
- name: "pluginOptions.i18n.localized",
1578
- description: {
1579
- id: getTranslation("plugin.schema.i18n.localized.description-field"),
1580
- defaultMessage: "The field can have different values in each locale"
1581
- },
1582
- type: "checkbox",
1583
- intlLabel: {
1584
- id: getTranslation("plugin.schema.i18n.localized.label-field"),
1585
- defaultMessage: "Enable localization for this field"
1586
- }
1587
- }
1588
- ];
1589
- }
1590
- }
1591
- });
1592
- }
1593
- },
1594
- async registerTrads({ locales }) {
1595
- const importedTrads = await Promise.all(
1596
- locales.map((locale) => {
1597
- return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("./de-9eCAqqrB.mjs"), "./translations/dk.json": () => import("./dk-2qBjxt-P.mjs"), "./translations/en.json": () => import("./en-DlXfy6Gy.mjs"), "./translations/es.json": () => import("./es-DlmMVaBG.mjs"), "./translations/fr.json": () => import("./fr-3S6ke71d.mjs"), "./translations/ko.json": () => import("./ko-qTjQ8IMw.mjs"), "./translations/pl.json": () => import("./pl-B67TSHqT.mjs"), "./translations/ru.json": () => import("./ru-hagMa57T.mjs"), "./translations/tr.json": () => import("./tr-Dw_jmkG-.mjs"), "./translations/zh-Hans.json": () => import("./zh-Hans-Dyc-aR-h.mjs"), "./translations/zh.json": () => import("./zh-57YM4amO.mjs") }), `./translations/${locale}.json`, 3).then(({ default: data }) => {
1598
- return {
1599
- data: prefixPluginTranslations(data, pluginId),
1600
- locale
1601
- };
1602
- }).catch(() => {
1603
- return {
1604
- data: {},
1605
- locale
1606
- };
1607
- });
1608
- })
1609
- );
1610
- return Promise.resolve(importedTrads);
1611
- }
1612
- };
1613
- export {
1614
- PERMISSIONS as P,
1615
- useGetDefaultLocalesQuery as a,
1616
- useDeleteLocaleMutation as b,
1617
- useUpdateLocaleMutation as c,
1618
- useGetLocalesQuery as d,
1619
- getTranslation as g,
1620
- index as i,
1621
- useCreateLocaleMutation as u
1622
- };
1623
- //# sourceMappingURL=index-B0NijiBB.mjs.map