@strapi/i18n 0.0.0-next.614aaf36aaf7e94667b876f02949c3651d9715da → 0.0.0-next.62638801ce303ba9d03355a9f041541cc6668ae0

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 (426) 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 +995 -0
  6. package/dist/admin/components/CMHeaderActions.js.map +1 -0
  7. package/dist/admin/components/CMHeaderActions.mjs +969 -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 +399 -0
  18. package/dist/admin/components/CreateLocale.js.map +1 -0
  19. package/dist/admin/components/CreateLocale.mjs +373 -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 +102 -0
  30. package/dist/admin/components/LocaleListCell.js.map +1 -0
  31. package/dist/admin/components/LocaleListCell.mjs +100 -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 +44 -0
  50. package/dist/admin/contentManagerHooks/listView.js.map +1 -0
  51. package/dist/admin/contentManagerHooks/listView.mjs +42 -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/useAILocalizationJobsPolling.js +110 -0
  58. package/dist/admin/hooks/useAILocalizationJobsPolling.js.map +1 -0
  59. package/dist/admin/hooks/useAILocalizationJobsPolling.mjs +89 -0
  60. package/dist/admin/hooks/useAILocalizationJobsPolling.mjs.map +1 -0
  61. package/dist/admin/hooks/useI18n.js +78 -0
  62. package/dist/admin/hooks/useI18n.js.map +1 -0
  63. package/dist/admin/hooks/useI18n.mjs +57 -0
  64. package/dist/admin/hooks/useI18n.mjs.map +1 -0
  65. package/dist/admin/index.js +221 -16
  66. package/dist/admin/index.js.map +1 -1
  67. package/dist/admin/index.mjs +203 -15
  68. package/dist/admin/index.mjs.map +1 -1
  69. package/dist/admin/middlewares/extendCTBAttributeInitialData.js +71 -0
  70. package/dist/admin/middlewares/extendCTBAttributeInitialData.js.map +1 -0
  71. package/dist/admin/middlewares/extendCTBAttributeInitialData.mjs +69 -0
  72. package/dist/admin/middlewares/extendCTBAttributeInitialData.mjs.map +1 -0
  73. package/dist/admin/middlewares/extendCTBInitialData.js +40 -0
  74. package/dist/admin/middlewares/extendCTBInitialData.js.map +1 -0
  75. package/dist/admin/middlewares/extendCTBInitialData.mjs +38 -0
  76. package/dist/admin/middlewares/extendCTBInitialData.mjs.map +1 -0
  77. package/dist/admin/middlewares/rbac-middleware.js +49 -0
  78. package/dist/admin/middlewares/rbac-middleware.js.map +1 -0
  79. package/dist/admin/middlewares/rbac-middleware.mjs +28 -0
  80. package/dist/admin/middlewares/rbac-middleware.mjs.map +1 -0
  81. package/dist/admin/pages/SettingsPage.js +182 -0
  82. package/dist/admin/pages/SettingsPage.js.map +1 -0
  83. package/dist/admin/pages/SettingsPage.mjs +179 -0
  84. package/dist/admin/pages/SettingsPage.mjs.map +1 -0
  85. package/dist/admin/pluginId.js +6 -0
  86. package/dist/admin/pluginId.js.map +1 -0
  87. package/dist/admin/pluginId.mjs +4 -0
  88. package/dist/admin/pluginId.mjs.map +1 -0
  89. package/dist/admin/services/aiLocalizationJobs.js +26 -0
  90. package/dist/admin/services/aiLocalizationJobs.js.map +1 -0
  91. package/dist/admin/services/aiLocalizationJobs.mjs +24 -0
  92. package/dist/admin/services/aiLocalizationJobs.mjs.map +1 -0
  93. package/dist/admin/services/api.js +15 -0
  94. package/dist/admin/services/api.js.map +1 -0
  95. package/dist/admin/services/api.mjs +13 -0
  96. package/dist/admin/services/api.mjs.map +1 -0
  97. package/dist/admin/services/locales.js +72 -0
  98. package/dist/admin/services/locales.js.map +1 -0
  99. package/dist/admin/services/locales.mjs +66 -0
  100. package/dist/admin/services/locales.mjs.map +1 -0
  101. package/dist/admin/services/relations.js +23 -0
  102. package/dist/admin/services/relations.js.map +1 -0
  103. package/dist/admin/services/relations.mjs +21 -0
  104. package/dist/admin/services/relations.mjs.map +1 -0
  105. package/dist/admin/services/settings.js +30 -0
  106. package/dist/admin/services/settings.js.map +1 -0
  107. package/dist/admin/services/settings.mjs +27 -0
  108. package/dist/admin/services/settings.mjs.map +1 -0
  109. package/dist/admin/src/components/CMHeaderActions.d.ts +17 -4
  110. package/dist/admin/src/components/LocaleListCell.d.ts +2 -1
  111. package/dist/admin/src/hooks/useAILocalizationJobsPolling.d.ts +9 -0
  112. package/dist/admin/src/services/aiLocalizationJobs.d.ts +6 -0
  113. package/dist/admin/src/services/api.d.ts +1 -1
  114. package/dist/admin/src/services/locales.d.ts +1 -1
  115. package/dist/admin/src/services/relations.d.ts +1 -1
  116. package/dist/admin/src/services/settings.d.ts +5 -0
  117. package/dist/admin/src/utils/schemas.d.ts +642 -16
  118. package/dist/admin/{chunks/de-nEMWvIiY.js → translations/de.json.js} +2 -2
  119. package/dist/admin/translations/de.json.js.map +1 -0
  120. package/dist/admin/{chunks/de-Cm8mYdaO.mjs → translations/de.json.mjs} +1 -1
  121. package/dist/admin/translations/de.json.mjs.map +1 -0
  122. package/dist/admin/{chunks/dk-CYATLPVe.js → translations/dk.json.js} +2 -2
  123. package/dist/admin/translations/dk.json.js.map +1 -0
  124. package/dist/admin/{chunks/dk-BeUFOegB.mjs → translations/dk.json.mjs} +1 -1
  125. package/dist/admin/translations/dk.json.mjs.map +1 -0
  126. package/dist/admin/{chunks/en-CG5cUCbD.js → translations/en.json.js} +12 -2
  127. package/dist/admin/translations/en.json.js.map +1 -0
  128. package/dist/admin/{chunks/en-eWSaCeOb.mjs → translations/en.json.mjs} +11 -1
  129. package/dist/admin/translations/en.json.mjs.map +1 -0
  130. package/dist/admin/{chunks/es-CWsogTGm.js → translations/es.json.js} +2 -2
  131. package/dist/admin/translations/es.json.js.map +1 -0
  132. package/dist/admin/{chunks/es-DqF_IdAc.mjs → translations/es.json.mjs} +1 -1
  133. package/dist/admin/translations/es.json.mjs.map +1 -0
  134. package/dist/admin/{chunks/fr-CC7UFcYd.js → translations/fr.json.js} +2 -2
  135. package/dist/admin/translations/fr.json.js.map +1 -0
  136. package/dist/admin/{chunks/fr-CyARbZ3c.mjs → translations/fr.json.mjs} +1 -1
  137. package/dist/admin/translations/fr.json.mjs.map +1 -0
  138. package/dist/admin/{chunks/ko-XwGmfhoq.js → translations/ko.json.js} +2 -2
  139. package/dist/admin/translations/ko.json.js.map +1 -0
  140. package/dist/admin/{chunks/ko-Ax4NSedM.mjs → translations/ko.json.mjs} +1 -1
  141. package/dist/admin/translations/ko.json.mjs.map +1 -0
  142. package/dist/admin/{chunks/pl-B_vzY_ZB.js → translations/pl.json.js} +2 -2
  143. package/dist/admin/translations/pl.json.js.map +1 -0
  144. package/dist/admin/{chunks/pl-B-aqvMqL.mjs → translations/pl.json.mjs} +1 -1
  145. package/dist/admin/translations/pl.json.mjs.map +1 -0
  146. package/dist/admin/{chunks/ru-WzHcJV1f.js → translations/ru.json.js} +2 -2
  147. package/dist/admin/translations/ru.json.js.map +1 -0
  148. package/dist/admin/{chunks/ru-VkPjQ-Sk.mjs → translations/ru.json.mjs} +1 -1
  149. package/dist/admin/translations/ru.json.mjs.map +1 -0
  150. package/dist/admin/{chunks/tr-CcWp6u3w.js → translations/tr.json.js} +2 -2
  151. package/dist/admin/translations/tr.json.js.map +1 -0
  152. package/dist/admin/{chunks/tr-DcTR88c9.mjs → translations/tr.json.mjs} +1 -1
  153. package/dist/admin/translations/tr.json.mjs.map +1 -0
  154. package/dist/admin/{chunks/uk-CO6JHYRC.js → translations/uk.json.js} +2 -2
  155. package/dist/admin/translations/uk.json.js.map +1 -0
  156. package/dist/admin/{chunks/uk-CMz6iPag.mjs → translations/uk.json.mjs} +1 -1
  157. package/dist/admin/translations/uk.json.mjs.map +1 -0
  158. package/dist/admin/{chunks/zh-Hans-DnU2bhri.js → translations/zh-Hans.json.js} +2 -2
  159. package/dist/admin/translations/zh-Hans.json.js.map +1 -0
  160. package/dist/admin/{chunks/zh-Hans-L3wsRegj.mjs → translations/zh-Hans.json.mjs} +1 -1
  161. package/dist/admin/translations/zh-Hans.json.mjs.map +1 -0
  162. package/dist/admin/{chunks/zh-C9So4SGq.js → translations/zh.json.js} +2 -2
  163. package/dist/admin/translations/zh.json.js.map +1 -0
  164. package/dist/admin/{chunks/zh-RZyMiPIs.mjs → translations/zh.json.mjs} +1 -1
  165. package/dist/admin/translations/zh.json.mjs.map +1 -0
  166. package/dist/admin/utils/baseQuery.js +8 -0
  167. package/dist/admin/utils/baseQuery.js.map +1 -0
  168. package/dist/admin/utils/baseQuery.mjs +6 -0
  169. package/dist/admin/utils/baseQuery.mjs.map +1 -0
  170. package/dist/admin/utils/clean.js +70 -0
  171. package/dist/admin/utils/clean.js.map +1 -0
  172. package/dist/admin/utils/clean.mjs +68 -0
  173. package/dist/admin/utils/clean.mjs.map +1 -0
  174. package/dist/admin/utils/fields.js +34 -0
  175. package/dist/admin/utils/fields.js.map +1 -0
  176. package/dist/admin/utils/fields.mjs +31 -0
  177. package/dist/admin/utils/fields.mjs.map +1 -0
  178. package/dist/admin/utils/getTranslation.js +8 -0
  179. package/dist/admin/utils/getTranslation.js.map +1 -0
  180. package/dist/admin/utils/getTranslation.mjs +6 -0
  181. package/dist/admin/utils/getTranslation.mjs.map +1 -0
  182. package/dist/admin/utils/prefixPluginTranslations.js +11 -0
  183. package/dist/admin/utils/prefixPluginTranslations.js.map +1 -0
  184. package/dist/admin/utils/prefixPluginTranslations.mjs +9 -0
  185. package/dist/admin/utils/prefixPluginTranslations.mjs.map +1 -0
  186. package/dist/admin/utils/schemas.js +74 -0
  187. package/dist/admin/utils/schemas.js.map +1 -0
  188. package/dist/admin/utils/schemas.mjs +72 -0
  189. package/dist/admin/utils/schemas.mjs.map +1 -0
  190. package/dist/admin/utils/strings.js +6 -0
  191. package/dist/admin/utils/strings.js.map +1 -0
  192. package/dist/admin/utils/strings.mjs +4 -0
  193. package/dist/admin/utils/strings.mjs.map +1 -0
  194. package/dist/server/bootstrap.js +95 -0
  195. package/dist/server/bootstrap.js.map +1 -0
  196. package/dist/server/bootstrap.mjs +93 -0
  197. package/dist/server/bootstrap.mjs.map +1 -0
  198. package/dist/server/constants/index.js +29 -0
  199. package/dist/server/constants/index.js.map +1 -0
  200. package/dist/server/constants/index.mjs +25 -0
  201. package/dist/server/constants/index.mjs.map +1 -0
  202. package/dist/server/constants/iso-locales.json.js +2427 -0
  203. package/dist/server/constants/iso-locales.json.js.map +1 -0
  204. package/dist/server/constants/iso-locales.json.mjs +2425 -0
  205. package/dist/server/constants/iso-locales.json.mjs.map +1 -0
  206. package/dist/server/content-types/index.js +10 -0
  207. package/dist/server/content-types/index.js.map +1 -0
  208. package/dist/server/content-types/index.mjs +8 -0
  209. package/dist/server/content-types/index.mjs.map +1 -0
  210. package/dist/server/content-types/locale/index.js +10 -0
  211. package/dist/server/content-types/locale/index.js.map +1 -0
  212. package/dist/server/content-types/locale/index.mjs +8 -0
  213. package/dist/server/content-types/locale/index.mjs.map +1 -0
  214. package/dist/server/content-types/locale/schema.json.js +46 -0
  215. package/dist/server/content-types/locale/schema.json.js.map +1 -0
  216. package/dist/server/content-types/locale/schema.json.mjs +38 -0
  217. package/dist/server/content-types/locale/schema.json.mjs.map +1 -0
  218. package/dist/server/controllers/ai-localization-jobs.js +47 -0
  219. package/dist/server/controllers/ai-localization-jobs.js.map +1 -0
  220. package/dist/server/controllers/ai-localization-jobs.mjs +45 -0
  221. package/dist/server/controllers/ai-localization-jobs.mjs.map +1 -0
  222. package/dist/server/controllers/content-types.js +76 -0
  223. package/dist/server/controllers/content-types.js.map +1 -0
  224. package/dist/server/controllers/content-types.mjs +74 -0
  225. package/dist/server/controllers/content-types.mjs.map +1 -0
  226. package/dist/server/controllers/index.js +18 -0
  227. package/dist/server/controllers/index.js.map +1 -0
  228. package/dist/server/controllers/index.mjs +16 -0
  229. package/dist/server/controllers/index.mjs.map +1 -0
  230. package/dist/server/controllers/iso-locales.js +13 -0
  231. package/dist/server/controllers/iso-locales.js.map +1 -0
  232. package/dist/server/controllers/iso-locales.mjs +11 -0
  233. package/dist/server/controllers/iso-locales.mjs.map +1 -0
  234. package/dist/server/controllers/locales.js +108 -0
  235. package/dist/server/controllers/locales.js.map +1 -0
  236. package/dist/server/controllers/locales.mjs +87 -0
  237. package/dist/server/controllers/locales.mjs.map +1 -0
  238. package/dist/server/controllers/settings.js +24 -0
  239. package/dist/server/controllers/settings.js.map +1 -0
  240. package/dist/server/controllers/settings.mjs +22 -0
  241. package/dist/server/controllers/settings.mjs.map +1 -0
  242. package/dist/server/controllers/validate-locale-creation.js +47 -0
  243. package/dist/server/controllers/validate-locale-creation.js.map +1 -0
  244. package/dist/server/controllers/validate-locale-creation.mjs +45 -0
  245. package/dist/server/controllers/validate-locale-creation.mjs.map +1 -0
  246. package/dist/server/domain/locale.js +11 -0
  247. package/dist/server/domain/locale.js.map +1 -0
  248. package/dist/server/domain/locale.mjs +9 -0
  249. package/dist/server/domain/locale.mjs.map +1 -0
  250. package/dist/server/graphql.js +115 -0
  251. package/dist/server/graphql.js.map +1 -0
  252. package/dist/server/graphql.mjs +113 -0
  253. package/dist/server/graphql.mjs.map +1 -0
  254. package/dist/server/index.js +10 -3712
  255. package/dist/server/index.js.map +1 -1
  256. package/dist/server/index.mjs +7 -3691
  257. package/dist/server/index.mjs.map +1 -1
  258. package/dist/server/models/ai-localization-job.js +60 -0
  259. package/dist/server/models/ai-localization-job.js.map +1 -0
  260. package/dist/server/models/ai-localization-job.mjs +57 -0
  261. package/dist/server/models/ai-localization-job.mjs.map +1 -0
  262. package/dist/server/register.js +81 -0
  263. package/dist/server/register.js.map +1 -0
  264. package/dist/server/register.mjs +79 -0
  265. package/dist/server/register.mjs.map +1 -0
  266. package/dist/server/routes/admin.js +142 -0
  267. package/dist/server/routes/admin.js.map +1 -0
  268. package/dist/server/routes/admin.mjs +140 -0
  269. package/dist/server/routes/admin.mjs.map +1 -0
  270. package/dist/server/routes/content-api.js +19 -0
  271. package/dist/server/routes/content-api.js.map +1 -0
  272. package/dist/server/routes/content-api.mjs +17 -0
  273. package/dist/server/routes/content-api.mjs.map +1 -0
  274. package/dist/server/routes/index.js +12 -0
  275. package/dist/server/routes/index.js.map +1 -0
  276. package/dist/server/routes/index.mjs +10 -0
  277. package/dist/server/routes/index.mjs.map +1 -0
  278. package/dist/server/routes/validation/locale.js +57 -0
  279. package/dist/server/routes/validation/locale.js.map +1 -0
  280. package/dist/server/routes/validation/locale.mjs +36 -0
  281. package/dist/server/routes/validation/locale.mjs.map +1 -0
  282. package/dist/server/services/ai-localization-jobs.js +64 -0
  283. package/dist/server/services/ai-localization-jobs.js.map +1 -0
  284. package/dist/server/services/ai-localization-jobs.mjs +62 -0
  285. package/dist/server/services/ai-localization-jobs.mjs.map +1 -0
  286. package/dist/server/services/ai-localizations.js +268 -0
  287. package/dist/server/services/ai-localizations.js.map +1 -0
  288. package/dist/server/services/ai-localizations.mjs +266 -0
  289. package/dist/server/services/ai-localizations.mjs.map +1 -0
  290. package/dist/server/services/content-types.js +157 -0
  291. package/dist/server/services/content-types.js.map +1 -0
  292. package/dist/server/services/content-types.mjs +155 -0
  293. package/dist/server/services/content-types.mjs.map +1 -0
  294. package/dist/server/services/index.js +28 -0
  295. package/dist/server/services/index.js.map +1 -0
  296. package/dist/server/services/index.mjs +26 -0
  297. package/dist/server/services/index.mjs.map +1 -0
  298. package/dist/server/services/iso-locales.js +12 -0
  299. package/dist/server/services/iso-locales.js.map +1 -0
  300. package/dist/server/services/iso-locales.mjs +10 -0
  301. package/dist/server/services/iso-locales.mjs.map +1 -0
  302. package/dist/server/services/locales.js +114 -0
  303. package/dist/server/services/locales.js.map +1 -0
  304. package/dist/server/services/locales.mjs +112 -0
  305. package/dist/server/services/locales.mjs.map +1 -0
  306. package/dist/server/services/localizations.js +68 -0
  307. package/dist/server/services/localizations.js.map +1 -0
  308. package/dist/server/services/localizations.mjs +66 -0
  309. package/dist/server/services/localizations.mjs.map +1 -0
  310. package/dist/server/services/metrics.js +30 -0
  311. package/dist/server/services/metrics.js.map +1 -0
  312. package/dist/server/services/metrics.mjs +28 -0
  313. package/dist/server/services/metrics.mjs.map +1 -0
  314. package/dist/server/services/permissions/actions.js +136 -0
  315. package/dist/server/services/permissions/actions.js.map +1 -0
  316. package/dist/server/services/permissions/actions.mjs +134 -0
  317. package/dist/server/services/permissions/actions.mjs.map +1 -0
  318. package/dist/server/services/permissions/engine.js +52 -0
  319. package/dist/server/services/permissions/engine.js.map +1 -0
  320. package/dist/server/services/permissions/engine.mjs +50 -0
  321. package/dist/server/services/permissions/engine.mjs.map +1 -0
  322. package/dist/server/services/permissions/sections-builder.js +45 -0
  323. package/dist/server/services/permissions/sections-builder.js.map +1 -0
  324. package/dist/server/services/permissions/sections-builder.mjs +43 -0
  325. package/dist/server/services/permissions/sections-builder.mjs.map +1 -0
  326. package/dist/server/services/permissions.js +14 -0
  327. package/dist/server/services/permissions.js.map +1 -0
  328. package/dist/server/services/permissions.mjs +12 -0
  329. package/dist/server/services/permissions.mjs.map +1 -0
  330. package/dist/server/services/sanitize/index.js +34 -0
  331. package/dist/server/services/sanitize/index.js.map +1 -0
  332. package/dist/server/services/sanitize/index.mjs +32 -0
  333. package/dist/server/services/sanitize/index.mjs.map +1 -0
  334. package/dist/server/services/settings.js +25 -0
  335. package/dist/server/services/settings.js.map +1 -0
  336. package/dist/server/services/settings.mjs +23 -0
  337. package/dist/server/services/settings.mjs.map +1 -0
  338. package/dist/server/src/bootstrap.d.ts.map +1 -1
  339. package/dist/server/src/controllers/ai-localization-jobs.d.ts +17 -0
  340. package/dist/server/src/controllers/ai-localization-jobs.d.ts.map +1 -0
  341. package/dist/server/src/controllers/index.d.ts +10 -0
  342. package/dist/server/src/controllers/index.d.ts.map +1 -1
  343. package/dist/server/src/controllers/settings.d.ts +7 -0
  344. package/dist/server/src/controllers/settings.d.ts.map +1 -0
  345. package/dist/server/src/index.d.ts +47 -8
  346. package/dist/server/src/index.d.ts.map +1 -1
  347. package/dist/server/src/models/ai-localization-job.d.ts +5 -0
  348. package/dist/server/src/models/ai-localization-job.d.ts.map +1 -0
  349. package/dist/server/src/models/index.d.ts +5 -0
  350. package/dist/server/src/models/index.d.ts.map +1 -0
  351. package/dist/server/src/register.d.ts +1 -1
  352. package/dist/server/src/register.d.ts.map +1 -1
  353. package/dist/server/src/routes/admin.d.ts.map +1 -1
  354. package/dist/server/src/routes/content-api.d.ts +5 -8
  355. package/dist/server/src/routes/content-api.d.ts.map +1 -1
  356. package/dist/server/src/routes/index.d.ts +3 -7
  357. package/dist/server/src/routes/index.d.ts.map +1 -1
  358. package/dist/server/src/routes/validation/index.d.ts +2 -0
  359. package/dist/server/src/routes/validation/index.d.ts.map +1 -0
  360. package/dist/server/src/routes/validation/locale.d.ts +41 -0
  361. package/dist/server/src/routes/validation/locale.d.ts.map +1 -0
  362. package/dist/server/src/services/ai-localization-jobs.d.ts +26 -0
  363. package/dist/server/src/services/ai-localization-jobs.d.ts.map +1 -0
  364. package/dist/server/src/services/ai-localizations.d.ts +18 -0
  365. package/dist/server/src/services/ai-localizations.d.ts.map +1 -0
  366. package/dist/server/src/services/index.d.ts +33 -0
  367. package/dist/server/src/services/index.d.ts.map +1 -1
  368. package/dist/server/src/services/settings.d.ts +13 -0
  369. package/dist/server/src/services/settings.d.ts.map +1 -0
  370. package/dist/server/src/utils/index.d.ts +7 -1
  371. package/dist/server/src/utils/index.d.ts.map +1 -1
  372. package/dist/server/src/validation/settings.d.ts +12 -0
  373. package/dist/server/src/validation/settings.d.ts.map +1 -0
  374. package/dist/server/utils/index.js +16 -0
  375. package/dist/server/utils/index.js.map +1 -0
  376. package/dist/server/utils/index.mjs +13 -0
  377. package/dist/server/utils/index.mjs.map +1 -0
  378. package/dist/server/validation/content-types.js +18 -0
  379. package/dist/server/validation/content-types.js.map +1 -0
  380. package/dist/server/validation/content-types.mjs +16 -0
  381. package/dist/server/validation/content-types.mjs.map +1 -0
  382. package/dist/server/validation/locales.js +23 -0
  383. package/dist/server/validation/locales.js.map +1 -0
  384. package/dist/server/validation/locales.mjs +20 -0
  385. package/dist/server/validation/locales.mjs.map +1 -0
  386. package/dist/server/validation/settings.js +11 -0
  387. package/dist/server/validation/settings.js.map +1 -0
  388. package/dist/server/validation/settings.mjs +9 -0
  389. package/dist/server/validation/settings.mjs.map +1 -0
  390. package/dist/shared/contracts/ai-localization-jobs.d.ts +27 -0
  391. package/dist/shared/contracts/ai-localization-jobs.d.ts.map +1 -0
  392. package/dist/shared/contracts/settings.d.ts +40 -0
  393. package/dist/shared/contracts/shared.d.ts.map +1 -0
  394. package/package.json +13 -10
  395. package/dist/admin/chunks/SettingsPage-BOEeBbiM.mjs +0 -797
  396. package/dist/admin/chunks/SettingsPage-BOEeBbiM.mjs.map +0 -1
  397. package/dist/admin/chunks/SettingsPage-Mg2Ygywx.js +0 -820
  398. package/dist/admin/chunks/SettingsPage-Mg2Ygywx.js.map +0 -1
  399. package/dist/admin/chunks/de-Cm8mYdaO.mjs.map +0 -1
  400. package/dist/admin/chunks/de-nEMWvIiY.js.map +0 -1
  401. package/dist/admin/chunks/dk-BeUFOegB.mjs.map +0 -1
  402. package/dist/admin/chunks/dk-CYATLPVe.js.map +0 -1
  403. package/dist/admin/chunks/en-CG5cUCbD.js.map +0 -1
  404. package/dist/admin/chunks/en-eWSaCeOb.mjs.map +0 -1
  405. package/dist/admin/chunks/es-CWsogTGm.js.map +0 -1
  406. package/dist/admin/chunks/es-DqF_IdAc.mjs.map +0 -1
  407. package/dist/admin/chunks/fr-CC7UFcYd.js.map +0 -1
  408. package/dist/admin/chunks/fr-CyARbZ3c.mjs.map +0 -1
  409. package/dist/admin/chunks/index--VTS8j_L.mjs +0 -2008
  410. package/dist/admin/chunks/index--VTS8j_L.mjs.map +0 -1
  411. package/dist/admin/chunks/index-hJ67XV0K.js +0 -2037
  412. package/dist/admin/chunks/index-hJ67XV0K.js.map +0 -1
  413. package/dist/admin/chunks/ko-Ax4NSedM.mjs.map +0 -1
  414. package/dist/admin/chunks/ko-XwGmfhoq.js.map +0 -1
  415. package/dist/admin/chunks/pl-B-aqvMqL.mjs.map +0 -1
  416. package/dist/admin/chunks/pl-B_vzY_ZB.js.map +0 -1
  417. package/dist/admin/chunks/ru-VkPjQ-Sk.mjs.map +0 -1
  418. package/dist/admin/chunks/ru-WzHcJV1f.js.map +0 -1
  419. package/dist/admin/chunks/tr-CcWp6u3w.js.map +0 -1
  420. package/dist/admin/chunks/tr-DcTR88c9.mjs.map +0 -1
  421. package/dist/admin/chunks/uk-CMz6iPag.mjs.map +0 -1
  422. package/dist/admin/chunks/uk-CO6JHYRC.js.map +0 -1
  423. package/dist/admin/chunks/zh-C9So4SGq.js.map +0 -1
  424. package/dist/admin/chunks/zh-Hans-DnU2bhri.js.map +0 -1
  425. package/dist/admin/chunks/zh-Hans-L3wsRegj.mjs.map +0 -1
  426. package/dist/admin/chunks/zh-RZyMiPIs.mjs.map +0 -1
@@ -0,0 +1,969 @@
1
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import { skipToken } from '@reduxjs/toolkit/query';
4
+ import { useQueryParams, useForm, useNotification, useAPIErrorHandler, Table } from '@strapi/admin/strapi-admin';
5
+ import { useAIAvailability } from '@strapi/admin/strapi-admin/ee';
6
+ import { unstable_useDocument, unstable_useDocumentActions, buildValidParams } from '@strapi/content-manager/strapi-admin';
7
+ import { Status, SingleSelectOption, Box, Typography, Flex, Link, Dialog, Field, SingleSelect, Button, Modal } from '@strapi/design-system';
8
+ import { Loader, Trash, Sparkle, Earth, WarningCircle, Plus, ListPlus, Cross } from '@strapi/icons';
9
+ import { useIntl } from 'react-intl';
10
+ import { NavLink, useNavigate } from 'react-router-dom';
11
+ import { styled } from 'styled-components';
12
+ import { useAILocalizationJobsPolling } from '../hooks/useAILocalizationJobsPolling.mjs';
13
+ import { useI18n } from '../hooks/useI18n.mjs';
14
+ import { useGetAILocalizationJobsByDocumentQuery } from '../services/aiLocalizationJobs.mjs';
15
+ import { useGetLocalesQuery } from '../services/locales.mjs';
16
+ import { useGetManyDraftRelationCountQuery } from '../services/relations.mjs';
17
+ import { useGetSettingsQuery } from '../services/settings.mjs';
18
+ import { cleanData } from '../utils/clean.mjs';
19
+ import { getTranslation } from '../utils/getTranslation.mjs';
20
+ import { capitalize } from '../utils/strings.mjs';
21
+ import { BulkLocaleActionModal } from './BulkLocaleActionModal.mjs';
22
+
23
+ const statusVariants = {
24
+ draft: 'secondary',
25
+ published: 'success',
26
+ modified: 'alternative'
27
+ };
28
+ const LocaleOption = ({ isDraftAndPublishEnabled, locale, status, entryExists })=>{
29
+ const { formatMessage } = useIntl();
30
+ if (!entryExists) {
31
+ return formatMessage({
32
+ id: getTranslation('CMEditViewLocalePicker.locale.create'),
33
+ defaultMessage: 'Create <bold>{locale}</bold> locale'
34
+ }, {
35
+ bold: (locale)=>/*#__PURE__*/ jsx("b", {
36
+ children: locale
37
+ }),
38
+ locale: locale.name
39
+ });
40
+ }
41
+ return /*#__PURE__*/ jsxs(Flex, {
42
+ width: "100%",
43
+ gap: 1,
44
+ justifyContent: "space-between",
45
+ children: [
46
+ /*#__PURE__*/ jsx(Typography, {
47
+ children: locale.name
48
+ }),
49
+ isDraftAndPublishEnabled ? /*#__PURE__*/ jsx(Status, {
50
+ display: "flex",
51
+ paddingLeft: "6px",
52
+ paddingRight: "6px",
53
+ paddingTop: "2px",
54
+ paddingBottom: "2px",
55
+ size: "S",
56
+ variant: statusVariants[status],
57
+ children: /*#__PURE__*/ jsx(Typography, {
58
+ tag: "span",
59
+ variant: "pi",
60
+ fontWeight: "bold",
61
+ children: capitalize(status)
62
+ })
63
+ }) : null
64
+ ]
65
+ });
66
+ };
67
+ const LocaleOptionStartIcon = ({ entryWithLocaleExists, translationStatus, index })=>{
68
+ const isAiAvailable = useAIAvailability();
69
+ if (!entryWithLocaleExists) {
70
+ return /*#__PURE__*/ jsx(Plus, {});
71
+ }
72
+ if (isAiAvailable && index !== 0 && translationStatus === 'failed') {
73
+ return /*#__PURE__*/ jsx(WarningCircle, {
74
+ fill: "warning600"
75
+ });
76
+ }
77
+ return null;
78
+ };
79
+ const LocalePickerAction = ({ document, meta, model, collectionType, documentId })=>{
80
+ const { formatMessage } = useIntl();
81
+ const [{ query }, setQuery] = useQueryParams();
82
+ const { hasI18n, canCreate, canRead } = useI18n();
83
+ const { data: locales = [] } = useGetLocalesQuery();
84
+ const currentDesiredLocale = query.plugins?.i18n?.locale;
85
+ const { schema } = unstable_useDocument({
86
+ model,
87
+ collectionType,
88
+ documentId,
89
+ params: {
90
+ locale: currentDesiredLocale
91
+ }
92
+ });
93
+ const { data: jobData } = useGetAILocalizationJobsByDocumentQuery({
94
+ documentId: documentId,
95
+ model: model,
96
+ collectionType: collectionType
97
+ });
98
+ const { data: settings } = useGetSettingsQuery();
99
+ const isAiAvailable = useAIAvailability();
100
+ const setValues = useForm('LocalePickerAction', (state)=>state.setValues);
101
+ const handleSelect = React.useCallback((value)=>{
102
+ setQuery({
103
+ plugins: {
104
+ ...query.plugins,
105
+ i18n: {
106
+ locale: value
107
+ }
108
+ }
109
+ }, 'push', true);
110
+ }, [
111
+ query.plugins,
112
+ setQuery
113
+ ]);
114
+ const nonTranslatedFields = React.useMemo(()=>{
115
+ if (!schema?.attributes) return [];
116
+ return Object.keys(schema.attributes).filter((field)=>{
117
+ const attribute = schema.attributes[field];
118
+ return attribute?.pluginOptions?.i18n?.localized === false;
119
+ });
120
+ }, [
121
+ schema?.attributes
122
+ ]);
123
+ const sourceLocaleData = React.useMemo(()=>{
124
+ if (!Array.isArray(locales) || !meta?.availableLocales) return null;
125
+ const defaultLocale = locales.find((locale)=>locale.isDefault);
126
+ const existingLocales = meta.availableLocales.map((loc)=>loc.locale);
127
+ const sourceLocaleCode = defaultLocale && existingLocales.includes(defaultLocale.code) && defaultLocale.code !== currentDesiredLocale ? defaultLocale.code : existingLocales.find((locale)=>locale !== currentDesiredLocale);
128
+ if (!sourceLocaleCode) return null;
129
+ // Find the document data from availableLocales (now includes non-translatable fields)
130
+ const sourceLocaleDoc = meta.availableLocales.find((loc)=>loc.locale === sourceLocaleCode);
131
+ return sourceLocaleDoc ? {
132
+ locale: sourceLocaleCode,
133
+ data: sourceLocaleDoc
134
+ } : null;
135
+ }, [
136
+ locales,
137
+ meta?.availableLocales,
138
+ currentDesiredLocale
139
+ ]);
140
+ /**
141
+ * Prefilling form with non-translatable fields from already existing locale
142
+ */ React.useEffect(()=>{
143
+ // Only run when creating a new locale (no document ID yet) and when we have non-translatable fields
144
+ if (!document?.id && nonTranslatedFields.length > 0 && sourceLocaleData?.data) {
145
+ const dataToSet = nonTranslatedFields.reduce((acc, field)=>{
146
+ acc[field] = sourceLocaleData.data[field];
147
+ return acc;
148
+ }, {});
149
+ if (Object.keys(dataToSet).length > 0) {
150
+ setValues(dataToSet);
151
+ }
152
+ }
153
+ }, [
154
+ document?.id,
155
+ nonTranslatedFields,
156
+ sourceLocaleData?.data,
157
+ setValues
158
+ ]);
159
+ React.useEffect(()=>{
160
+ if (!Array.isArray(locales) || !hasI18n) {
161
+ return;
162
+ }
163
+ /**
164
+ * Handle the case where the current locale query param doesn't exist
165
+ * in the list of available locales, so we redirect to the default locale.
166
+ */ const doesLocaleExist = locales.find((loc)=>loc.code === currentDesiredLocale);
167
+ const defaultLocale = locales.find((locale)=>locale.isDefault);
168
+ if (!doesLocaleExist && defaultLocale?.code) {
169
+ handleSelect(defaultLocale.code);
170
+ }
171
+ }, [
172
+ handleSelect,
173
+ hasI18n,
174
+ locales,
175
+ currentDesiredLocale
176
+ ]);
177
+ const currentLocale = Array.isArray(locales) ? locales.find((locale)=>locale.code === currentDesiredLocale) : undefined;
178
+ // Use meta.availableLocales instead of document.localizations
179
+ // meta.availableLocales contains all locales for the document, even when creating new locales
180
+ const availableLocales = meta?.availableLocales ?? [];
181
+ const documentLocalizations = document?.localizations ?? [];
182
+ // Prefer meta.availableLocales as it's more reliable, fallback to document.localizations
183
+ const allLocalizations = availableLocales.length > 0 ? availableLocales : documentLocalizations;
184
+ const allCurrentLocales = [
185
+ {
186
+ status: getDocumentStatus(document, meta),
187
+ locale: currentLocale?.code
188
+ },
189
+ ...allLocalizations
190
+ ];
191
+ if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {
192
+ return null;
193
+ }
194
+ const displayedLocales = locales.filter((locale)=>{
195
+ /**
196
+ * If you can read we allow you to see the locale exists
197
+ * otherwise the locale is hidden.
198
+ */ return canRead.includes(locale.code);
199
+ });
200
+ const localesSortingDefaultFirst = displayedLocales.sort((a, b)=>a.isDefault ? -1 : b.isDefault ? 1 : 0);
201
+ return {
202
+ label: formatMessage({
203
+ id: getTranslation('Settings.locales.modal.locales.label'),
204
+ defaultMessage: 'Locales'
205
+ }),
206
+ options: localesSortingDefaultFirst.map((locale, index)=>{
207
+ const entryWithLocaleExists = allCurrentLocales.some((doc)=>doc.locale === locale.code);
208
+ const currentLocaleDoc = allCurrentLocales.find((doc)=>'locale' in doc ? doc.locale === locale.code : false);
209
+ const permissionsToCheck = currentLocaleDoc ? canRead : canCreate;
210
+ if (isAiAvailable && settings?.data?.aiLocalizations) {
211
+ return {
212
+ _render: ()=>/*#__PURE__*/ jsxs(React.Fragment, {
213
+ children: [
214
+ /*#__PURE__*/ jsx(SingleSelectOption, {
215
+ disabled: !permissionsToCheck.includes(locale.code),
216
+ startIcon: /*#__PURE__*/ jsx(LocaleOptionStartIcon, {
217
+ entryWithLocaleExists: entryWithLocaleExists,
218
+ translationStatus: jobData?.data?.status,
219
+ index: index
220
+ }),
221
+ value: locale.code,
222
+ children: /*#__PURE__*/ jsx(LocaleOption, {
223
+ isDraftAndPublishEnabled: !!schema?.options?.draftAndPublish,
224
+ locale: locale,
225
+ status: currentLocaleDoc?.status,
226
+ entryExists: entryWithLocaleExists
227
+ })
228
+ }, locale.code),
229
+ localesSortingDefaultFirst.length > 1 && index === 0 && /*#__PURE__*/ jsx(Box, {
230
+ paddingRight: 4,
231
+ paddingLeft: 4,
232
+ paddingTop: 2,
233
+ paddingBottom: 2,
234
+ children: /*#__PURE__*/ jsx(Typography, {
235
+ variant: "sigma",
236
+ children: formatMessage({
237
+ id: getTranslation('CMEditViewLocalePicker.locale.ai-translations'),
238
+ defaultMessage: 'AI Translations'
239
+ })
240
+ })
241
+ })
242
+ ]
243
+ }, index)
244
+ };
245
+ }
246
+ return {
247
+ disabled: !permissionsToCheck.includes(locale.code),
248
+ value: locale.code,
249
+ label: /*#__PURE__*/ jsx(LocaleOption, {
250
+ isDraftAndPublishEnabled: !!schema?.options?.draftAndPublish,
251
+ locale: locale,
252
+ status: currentLocaleDoc?.status,
253
+ entryExists: entryWithLocaleExists,
254
+ translationStatus: jobData?.data?.status
255
+ }),
256
+ startIcon: /*#__PURE__*/ jsx(LocaleOptionStartIcon, {
257
+ entryWithLocaleExists: entryWithLocaleExists
258
+ })
259
+ };
260
+ }),
261
+ customizeContent: ()=>currentLocale?.name,
262
+ onSelect: handleSelect,
263
+ value: currentLocale
264
+ };
265
+ };
266
+ const getDocumentStatus = (document, meta)=>{
267
+ const docStatus = document?.status;
268
+ const statuses = meta?.availableStatus ?? [];
269
+ /**
270
+ * Creating an entry
271
+ */ if (!docStatus) {
272
+ return 'draft';
273
+ }
274
+ /**
275
+ * We're viewing a draft, but the document could have a published version
276
+ */ if (docStatus === 'draft' && statuses.find((doc)=>doc.publishedAt !== null)) {
277
+ return 'published';
278
+ }
279
+ return docStatus;
280
+ };
281
+ /* -------------------------------------------------------------------------------------------------
282
+ * AISettingsStatusAction
283
+ * -----------------------------------------------------------------------------------------------*/ const AITranslationStatusIcon = styled(Status)`
284
+ display: flex;
285
+ gap: ${({ theme })=>theme.spaces[1]};
286
+ justify-content: center;
287
+ align-items: center;
288
+ height: 100%;
289
+
290
+ // Disabled state
291
+ ${({ $isAISettingEnabled, theme })=>!$isAISettingEnabled && `
292
+ background-color: ${theme.colors.neutral150};
293
+ `}
294
+
295
+ svg {
296
+ ${({ $isAISettingEnabled, theme })=>!$isAISettingEnabled && `
297
+ fill: ${theme.colors.neutral300};
298
+ `}
299
+ }
300
+ `;
301
+ const SpinningLoader = styled(Loader)`
302
+ @keyframes spin {
303
+ from {
304
+ transform: rotate(0deg);
305
+ }
306
+ to {
307
+ transform: rotate(360deg);
308
+ }
309
+ }
310
+
311
+ animation: spin 2s linear infinite;
312
+ `;
313
+ const AITranslationStatusAction = ({ documentId, model, collectionType })=>{
314
+ const { formatMessage } = useIntl();
315
+ const isAIAvailable = useAIAvailability();
316
+ const { data: settings } = useGetSettingsQuery();
317
+ const isAISettingEnabled = settings?.data?.aiLocalizations;
318
+ const { hasI18n } = useI18n();
319
+ // Poll for AI localizations jobs when AI is enabled and we have a documentId
320
+ const { status } = useAILocalizationJobsPolling({
321
+ documentId,
322
+ model,
323
+ collectionType
324
+ });
325
+ const statusVariant = (()=>{
326
+ if (status === 'failed') {
327
+ return 'warning';
328
+ }
329
+ if (isAISettingEnabled) {
330
+ return 'alternative';
331
+ }
332
+ return 'neutral';
333
+ })();
334
+ // Do not display this action when i18n is not available
335
+ if (!hasI18n) {
336
+ return null;
337
+ }
338
+ // Do not display this action when AI is not available
339
+ if (!isAIAvailable) {
340
+ return null;
341
+ }
342
+ return {
343
+ _status: {
344
+ message: /*#__PURE__*/ jsx(Box, {
345
+ height: "100%",
346
+ "aria-label": formatMessage({
347
+ id: getTranslation('CMEditViewAITranslation.status-aria-label'),
348
+ defaultMessage: 'AI Translation Status'
349
+ }),
350
+ children: /*#__PURE__*/ jsx(AITranslationStatusIcon, {
351
+ $isAISettingEnabled: Boolean(isAISettingEnabled),
352
+ variant: statusVariant,
353
+ size: "S",
354
+ children: status === 'processing' ? /*#__PURE__*/ jsx(SpinningLoader, {}) : /*#__PURE__*/ jsx(Sparkle, {})
355
+ })
356
+ }),
357
+ tooltip: /*#__PURE__*/ jsxs(Flex, {
358
+ direction: "column",
359
+ padding: 4,
360
+ alignItems: "flex-start",
361
+ width: "25rem",
362
+ children: [
363
+ /*#__PURE__*/ jsx(Typography, {
364
+ variant: "pi",
365
+ fontWeight: "600",
366
+ children: formatMessage({
367
+ id: getTranslation('CMEditViewAITranslation.status-title'),
368
+ defaultMessage: '{enabled, select, true {AI translation enabled} false {AI translation disabled} other {AI translation disabled}}'
369
+ }, {
370
+ enabled: isAISettingEnabled
371
+ })
372
+ }),
373
+ /*#__PURE__*/ jsx(Typography, {
374
+ variant: "pi",
375
+ paddingTop: 1,
376
+ paddingBottom: 3,
377
+ children: formatMessage({
378
+ id: getTranslation('CMEditViewAITranslation.status-description'),
379
+ defaultMessage: 'Our AI translates content in all locales each time you save a modification in the default locale.'
380
+ })
381
+ }),
382
+ /*#__PURE__*/ jsx(Link, {
383
+ fontSize: "inherit",
384
+ tag: NavLink,
385
+ to: "/settings/internationalization",
386
+ style: {
387
+ alignSelf: 'flex-end'
388
+ },
389
+ children: /*#__PURE__*/ jsx(Typography, {
390
+ variant: "pi",
391
+ textAlign: "right",
392
+ children: formatMessage({
393
+ id: getTranslation('CMEditViewAITranslation.settings-link'),
394
+ defaultMessage: '{enabled, select, true {Disable it in settings} false {Enable it in settings} other {Enable it in settings}}'
395
+ }, {
396
+ enabled: isAISettingEnabled
397
+ })
398
+ })
399
+ })
400
+ ]
401
+ })
402
+ }
403
+ };
404
+ };
405
+ /* -------------------------------------------------------------------------------------------------
406
+ * FillFromAnotherLocaleAction
407
+ * -----------------------------------------------------------------------------------------------*/ const FillFromAnotherLocaleAction = ({ documentId, meta, model, collectionType })=>{
408
+ const { formatMessage } = useIntl();
409
+ const [{ query }] = useQueryParams();
410
+ const { hasI18n } = useI18n();
411
+ const currentDesiredLocale = query.plugins?.i18n?.locale;
412
+ const [localeSelected, setLocaleSelected] = React.useState(null);
413
+ const setValues = useForm('FillFromAnotherLocale', (state)=>state.setValues);
414
+ const { getDocument } = unstable_useDocumentActions();
415
+ const { schema, components } = unstable_useDocument({
416
+ model,
417
+ documentId,
418
+ collectionType,
419
+ params: {
420
+ locale: currentDesiredLocale
421
+ }
422
+ });
423
+ const { data: locales = [] } = useGetLocalesQuery();
424
+ const isAIAvailable = useAIAvailability();
425
+ const { data: settings } = useGetSettingsQuery();
426
+ const isAISettingEnabled = settings?.data?.aiLocalizations;
427
+ const availableLocales = Array.isArray(locales) ? locales.filter((locale)=>meta?.availableLocales.some((l)=>l.locale === locale.code)) : [];
428
+ const fillFromLocale = (onClose)=>async ()=>{
429
+ const response = await getDocument({
430
+ collectionType,
431
+ model,
432
+ documentId,
433
+ params: {
434
+ locale: localeSelected
435
+ }
436
+ });
437
+ if (!response || !schema) {
438
+ return;
439
+ }
440
+ const { data } = response;
441
+ const cleanedData = cleanData(data, schema, components);
442
+ setValues(cleanedData);
443
+ onClose();
444
+ };
445
+ if (!hasI18n) {
446
+ return null;
447
+ }
448
+ // Do not display this action when AI is available and AI translations are enabled
449
+ if (isAIAvailable && isAISettingEnabled) {
450
+ return null;
451
+ }
452
+ return {
453
+ type: 'icon',
454
+ icon: /*#__PURE__*/ jsx(Earth, {}),
455
+ disabled: availableLocales.length === 0,
456
+ label: formatMessage({
457
+ id: getTranslation('CMEditViewCopyLocale.copy-text'),
458
+ defaultMessage: 'Fill in from another locale'
459
+ }),
460
+ dialog: {
461
+ type: 'dialog',
462
+ title: formatMessage({
463
+ id: getTranslation('CMEditViewCopyLocale.dialog.title'),
464
+ defaultMessage: 'Confirmation'
465
+ }),
466
+ content: ({ onClose })=>/*#__PURE__*/ jsxs(Fragment, {
467
+ children: [
468
+ /*#__PURE__*/ jsx(Dialog.Body, {
469
+ children: /*#__PURE__*/ jsxs(Flex, {
470
+ direction: "column",
471
+ gap: 3,
472
+ children: [
473
+ /*#__PURE__*/ jsx(WarningCircle, {
474
+ width: "24px",
475
+ height: "24px",
476
+ fill: "danger600"
477
+ }),
478
+ /*#__PURE__*/ jsx(Typography, {
479
+ textAlign: "center",
480
+ children: formatMessage({
481
+ id: getTranslation('CMEditViewCopyLocale.dialog.body'),
482
+ defaultMessage: 'Your current content will be erased and filled by the content of the selected locale:'
483
+ })
484
+ }),
485
+ /*#__PURE__*/ jsxs(Field.Root, {
486
+ width: "100%",
487
+ children: [
488
+ /*#__PURE__*/ jsx(Field.Label, {
489
+ children: formatMessage({
490
+ id: getTranslation('CMEditViewCopyLocale.dialog.field.label'),
491
+ defaultMessage: 'Locale'
492
+ })
493
+ }),
494
+ /*#__PURE__*/ jsx(SingleSelect, {
495
+ value: localeSelected,
496
+ placeholder: formatMessage({
497
+ id: getTranslation('CMEditViewCopyLocale.dialog.field.placeholder'),
498
+ defaultMessage: 'Select one locale...'
499
+ }),
500
+ // @ts-expect-error – the DS will handle numbers, but we're not allowing the API.
501
+ onChange: (value)=>setLocaleSelected(value),
502
+ children: availableLocales.map((locale)=>/*#__PURE__*/ jsx(SingleSelectOption, {
503
+ value: locale.code,
504
+ children: locale.name
505
+ }, locale.code))
506
+ })
507
+ ]
508
+ })
509
+ ]
510
+ })
511
+ }),
512
+ /*#__PURE__*/ jsx(Dialog.Footer, {
513
+ children: /*#__PURE__*/ jsxs(Flex, {
514
+ gap: 2,
515
+ width: "100%",
516
+ children: [
517
+ /*#__PURE__*/ jsx(Button, {
518
+ flex: "auto",
519
+ variant: "tertiary",
520
+ onClick: onClose,
521
+ children: formatMessage({
522
+ id: getTranslation('CMEditViewCopyLocale.cancel-text'),
523
+ defaultMessage: 'No, cancel'
524
+ })
525
+ }),
526
+ /*#__PURE__*/ jsx(Button, {
527
+ flex: "auto",
528
+ variant: "success",
529
+ onClick: fillFromLocale(onClose),
530
+ children: formatMessage({
531
+ id: getTranslation('CMEditViewCopyLocale.submit-text'),
532
+ defaultMessage: 'Yes, fill in'
533
+ })
534
+ })
535
+ ]
536
+ })
537
+ })
538
+ ]
539
+ })
540
+ }
541
+ };
542
+ };
543
+ /* -------------------------------------------------------------------------------------------------
544
+ * DeleteLocaleAction
545
+ * -----------------------------------------------------------------------------------------------*/ const DeleteLocaleAction = ({ document, documentId, model, collectionType })=>{
546
+ const { formatMessage } = useIntl();
547
+ const navigate = useNavigate();
548
+ const { toggleNotification } = useNotification();
549
+ const { delete: deleteAction, isLoading } = unstable_useDocumentActions();
550
+ const { hasI18n, canDelete } = useI18n();
551
+ // Get the current locale object, using the URL instead of document so it works while creating
552
+ const [{ query }] = useQueryParams();
553
+ const { data: locales = [] } = useGetLocalesQuery();
554
+ const currentDesiredLocale = query.plugins?.i18n?.locale;
555
+ const locale = !('error' in locales) && locales.find((loc)=>loc.code === currentDesiredLocale);
556
+ if (!hasI18n) {
557
+ return null;
558
+ }
559
+ return {
560
+ disabled: document?.locale && !canDelete.includes(document.locale) || !document || !document.id,
561
+ position: [
562
+ 'header',
563
+ 'table-row'
564
+ ],
565
+ label: formatMessage({
566
+ id: getTranslation('actions.delete.label'),
567
+ defaultMessage: 'Delete entry ({locale})'
568
+ }, {
569
+ locale: locale && locale.name
570
+ }),
571
+ icon: /*#__PURE__*/ jsx(StyledTrash, {}),
572
+ variant: 'danger',
573
+ dialog: {
574
+ type: 'dialog',
575
+ title: formatMessage({
576
+ id: getTranslation('actions.delete.dialog.title'),
577
+ defaultMessage: 'Confirmation'
578
+ }),
579
+ content: /*#__PURE__*/ jsxs(Flex, {
580
+ direction: "column",
581
+ gap: 2,
582
+ children: [
583
+ /*#__PURE__*/ jsx(WarningCircle, {
584
+ width: "24px",
585
+ height: "24px",
586
+ fill: "danger600"
587
+ }),
588
+ /*#__PURE__*/ jsx(Typography, {
589
+ tag: "p",
590
+ variant: "omega",
591
+ textAlign: "center",
592
+ children: formatMessage({
593
+ id: getTranslation('actions.delete.dialog.body'),
594
+ defaultMessage: 'Are you sure?'
595
+ })
596
+ })
597
+ ]
598
+ }),
599
+ loading: isLoading,
600
+ onConfirm: async ()=>{
601
+ const unableToDelete = // We are unable to delete a collection type without a document ID
602
+ // & unable to delete generally if there is no document locale
603
+ collectionType !== 'single-types' && !documentId || !document?.locale;
604
+ if (unableToDelete) {
605
+ console.error("You're trying to delete a document without an id or locale, this is likely a bug with Strapi. Please open an issue.");
606
+ toggleNotification({
607
+ message: formatMessage({
608
+ id: getTranslation('actions.delete.error'),
609
+ defaultMessage: 'An error occurred while trying to delete the document locale.'
610
+ }),
611
+ type: 'danger'
612
+ });
613
+ return;
614
+ }
615
+ const res = await deleteAction({
616
+ documentId,
617
+ model,
618
+ collectionType,
619
+ params: {
620
+ locale: document.locale
621
+ }
622
+ });
623
+ if (!('error' in res)) {
624
+ navigate({
625
+ pathname: `../${collectionType}/${model}`
626
+ }, {
627
+ replace: true
628
+ });
629
+ }
630
+ }
631
+ }
632
+ };
633
+ };
634
+ /* -------------------------------------------------------------------------------------------------
635
+ * BulkLocaleAction
636
+ *
637
+ * This component is used to handle bulk publish and unpublish actions on locales.
638
+ * -----------------------------------------------------------------------------------------------*/ const BulkLocaleAction = ({ document, documentId, model, collectionType, action, meta })=>{
639
+ const locale = document?.locale ?? null;
640
+ const [{ query }] = useQueryParams();
641
+ const params = React.useMemo(()=>buildValidParams(query), [
642
+ query
643
+ ]);
644
+ const isOnPublishedTab = query.status === 'published';
645
+ const { formatMessage } = useIntl();
646
+ const { hasI18n, canPublish } = useI18n();
647
+ const { toggleNotification } = useNotification();
648
+ const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
649
+ const [selectedRows, setSelectedRows] = React.useState([]);
650
+ const [isDraftRelationConfirmationOpen, setIsDraftRelationConfirmationOpen] = React.useState(false);
651
+ const { publishMany: publishManyAction, unpublishMany: unpublishManyAction } = unstable_useDocumentActions();
652
+ const { schema, validate } = unstable_useDocument({
653
+ model,
654
+ collectionType,
655
+ documentId,
656
+ params: {
657
+ locale
658
+ }
659
+ }, {
660
+ // No need to fetch the document, the data is already available in the `document` prop
661
+ skip: true
662
+ });
663
+ const { data: localesMetadata = [] } = useGetLocalesQuery(hasI18n ? undefined : skipToken);
664
+ const headers = [
665
+ {
666
+ label: formatMessage({
667
+ id: 'global.name',
668
+ defaultMessage: 'Name'
669
+ }),
670
+ name: 'name'
671
+ },
672
+ {
673
+ label: formatMessage({
674
+ id: getTranslation('CMEditViewBulkLocale.status'),
675
+ defaultMessage: 'Status'
676
+ }),
677
+ name: 'status'
678
+ },
679
+ {
680
+ label: formatMessage({
681
+ id: getTranslation('CMEditViewBulkLocale.publication-status'),
682
+ defaultMessage: 'Publication Status'
683
+ }),
684
+ name: 'publication-status'
685
+ }
686
+ ];
687
+ // Extract the rows for the bulk locale publish modal and any validation
688
+ // errors per locale
689
+ const [rows, validationErrors] = React.useMemo(()=>{
690
+ if (!document) {
691
+ return [
692
+ [],
693
+ {}
694
+ ];
695
+ }
696
+ const metaLocalizations = (meta?.availableLocales ?? []).map((locale)=>({
697
+ locale: locale.locale,
698
+ status: locale.status ?? 'draft'
699
+ }));
700
+ const documentLocalizations = (document.localizations ?? []).map((doc)=>({
701
+ locale: doc.locale ?? undefined,
702
+ status: doc.status ?? 'draft'
703
+ }));
704
+ const localesMap = new Map();
705
+ metaLocalizations.forEach(({ locale, status })=>{
706
+ if (locale) {
707
+ localesMap.set(locale, {
708
+ locale,
709
+ status
710
+ });
711
+ }
712
+ });
713
+ documentLocalizations.forEach(({ locale, status })=>{
714
+ if (locale) {
715
+ localesMap.set(locale, {
716
+ locale,
717
+ status
718
+ });
719
+ }
720
+ });
721
+ // Build the rows for the bulk locale publish modal by combining the current
722
+ // document with all the available locales from the document meta
723
+ const locales = [];
724
+ if (document?.locale) {
725
+ locales.push({
726
+ locale: document.locale,
727
+ status: document.status ?? 'draft'
728
+ });
729
+ }
730
+ locales.push(...Array.from(localesMap.entries()).filter(([locale])=>locale !== document?.locale).map(([, value])=>value));
731
+ if (locales.length === 0 && document?.locale) {
732
+ locales.push({
733
+ locale: document.locale,
734
+ status: document.status ?? 'draft'
735
+ });
736
+ }
737
+ // Build the validation errors for each locale.
738
+ const allDocuments = [
739
+ document,
740
+ ...document.localizations ?? []
741
+ ];
742
+ const errors = allDocuments.reduce((errs, document)=>{
743
+ if (!document) {
744
+ return errs;
745
+ }
746
+ // Validate each locale entry via the useDocument validate function and store any errors in a dictionary
747
+ const validation = validate(document);
748
+ if (validation !== null) {
749
+ errs[document.locale] = validation;
750
+ }
751
+ return errs;
752
+ }, {});
753
+ return [
754
+ locales,
755
+ errors
756
+ ];
757
+ }, [
758
+ document,
759
+ meta?.availableLocales,
760
+ validate
761
+ ]);
762
+ const isBulkPublish = action === 'bulk-publish';
763
+ const localesForAction = selectedRows.reduce((acc, selectedRow)=>{
764
+ const isValidLocale = // Validation errors are irrelevant if we are trying to unpublish
765
+ !isBulkPublish || !Object.keys(validationErrors).includes(selectedRow.locale);
766
+ const shouldAddLocale = isBulkPublish ? selectedRow.status !== 'published' && isValidLocale : selectedRow.status !== 'draft' && isValidLocale;
767
+ if (shouldAddLocale) {
768
+ acc.push(selectedRow.locale);
769
+ }
770
+ return acc;
771
+ }, []);
772
+ // TODO skipping this for now as there is a bug with the draft relation count that will be worked on separately
773
+ // see https://www.notion.so/strapi/Count-draft-relations-56901b492efb45ab90d42fe975b32bd8?pvs=4
774
+ const enableDraftRelationsCount = false;
775
+ const { data: draftRelationsCount = 0, isLoading: isDraftRelationsLoading, error: isDraftRelationsError } = useGetManyDraftRelationCountQuery({
776
+ model,
777
+ documentIds: [
778
+ documentId
779
+ ],
780
+ locale: localesForAction
781
+ }, {
782
+ skip: !enableDraftRelationsCount
783
+ });
784
+ React.useEffect(()=>{
785
+ if (isDraftRelationsError) {
786
+ toggleNotification({
787
+ type: 'danger',
788
+ message: formatAPIError(isDraftRelationsError)
789
+ });
790
+ }
791
+ }, [
792
+ isDraftRelationsError,
793
+ toggleNotification,
794
+ formatAPIError
795
+ ]);
796
+ if (!schema?.options?.draftAndPublish) {
797
+ return null;
798
+ }
799
+ if (!hasI18n) {
800
+ return null;
801
+ }
802
+ if (!documentId) {
803
+ return null;
804
+ }
805
+ // This document action can be enabled given that draft and publish and i18n are
806
+ // enabled and we can publish the current locale.
807
+ const publish = async ()=>{
808
+ await publishManyAction({
809
+ model,
810
+ documentIds: [
811
+ documentId
812
+ ],
813
+ params: {
814
+ ...params,
815
+ locale: localesForAction
816
+ }
817
+ });
818
+ setSelectedRows([]);
819
+ };
820
+ const unpublish = async ()=>{
821
+ await unpublishManyAction({
822
+ model,
823
+ documentIds: [
824
+ documentId
825
+ ],
826
+ params: {
827
+ ...params,
828
+ locale: localesForAction
829
+ }
830
+ });
831
+ setSelectedRows([]);
832
+ };
833
+ const handleAction = async ()=>{
834
+ if (draftRelationsCount > 0) {
835
+ setIsDraftRelationConfirmationOpen(true);
836
+ } else if (isBulkPublish) {
837
+ await publish();
838
+ } else {
839
+ await unpublish();
840
+ }
841
+ };
842
+ if (isDraftRelationConfirmationOpen) {
843
+ return {
844
+ label: formatMessage({
845
+ id: 'app.components.ConfirmDialog.title',
846
+ defaultMessage: 'Confirmation'
847
+ }),
848
+ variant: 'danger',
849
+ dialog: {
850
+ onCancel: ()=>{
851
+ setIsDraftRelationConfirmationOpen(false);
852
+ },
853
+ onConfirm: async ()=>{
854
+ await publish();
855
+ setIsDraftRelationConfirmationOpen(false);
856
+ },
857
+ type: 'dialog',
858
+ title: formatMessage({
859
+ id: getTranslation('actions.publish.dialog.title'),
860
+ defaultMessage: 'Confirmation'
861
+ }),
862
+ content: /*#__PURE__*/ jsxs(Flex, {
863
+ direction: "column",
864
+ alignItems: "center",
865
+ gap: 2,
866
+ children: [
867
+ /*#__PURE__*/ jsx(WarningCircle, {
868
+ width: "2.4rem",
869
+ height: "2.4rem",
870
+ fill: "danger600"
871
+ }),
872
+ /*#__PURE__*/ jsx(Typography, {
873
+ textAlign: "center",
874
+ children: formatMessage({
875
+ id: getTranslation('CMEditViewBulkLocale.draft-relation-warning'),
876
+ defaultMessage: 'Some locales are related to draft entries. Publishing them could leave broken links in your app.'
877
+ })
878
+ }),
879
+ /*#__PURE__*/ jsx(Typography, {
880
+ textAlign: "center",
881
+ children: formatMessage({
882
+ id: getTranslation('CMEditViewBulkLocale.continue-confirmation'),
883
+ defaultMessage: 'Are you sure you want to continue?'
884
+ })
885
+ })
886
+ ]
887
+ })
888
+ }
889
+ };
890
+ }
891
+ const hasPermission = selectedRows.map(({ locale })=>locale).every((locale)=>canPublish.includes(locale));
892
+ return {
893
+ label: formatMessage({
894
+ id: getTranslation(`CMEditViewBulkLocale.${isBulkPublish ? 'publish' : 'unpublish'}-title`),
895
+ defaultMessage: `${isBulkPublish ? 'Publish' : 'Unpublish'} Multiple Locales`
896
+ }),
897
+ variant: isBulkPublish ? 'secondary' : 'danger',
898
+ icon: isBulkPublish ? /*#__PURE__*/ jsx(ListPlus, {}) : /*#__PURE__*/ jsx(Cross, {}),
899
+ disabled: isOnPublishedTab || canPublish.length === 0,
900
+ position: [
901
+ 'panel'
902
+ ],
903
+ dialog: {
904
+ type: 'modal',
905
+ title: formatMessage({
906
+ id: getTranslation(`CMEditViewBulkLocale.${isBulkPublish ? 'publish' : 'unpublish'}-title`),
907
+ defaultMessage: `${isBulkPublish ? 'Publish' : 'Unpublish'} Multiple Locales`
908
+ }),
909
+ content: ()=>{
910
+ return /*#__PURE__*/ jsx(Table.Root, {
911
+ headers: headers,
912
+ rows: rows.map((row)=>({
913
+ ...row,
914
+ id: row.locale
915
+ })),
916
+ selectedRows: selectedRows,
917
+ onSelectedRowsChange: (tableSelectedRows)=>setSelectedRows(tableSelectedRows),
918
+ children: /*#__PURE__*/ jsx(BulkLocaleActionModal, {
919
+ validationErrors: validationErrors,
920
+ headers: headers,
921
+ rows: rows,
922
+ localesMetadata: localesMetadata,
923
+ action: action ?? 'bulk-publish'
924
+ })
925
+ });
926
+ },
927
+ footer: ()=>/*#__PURE__*/ jsx(Modal.Footer, {
928
+ justifyContent: "flex-end",
929
+ children: /*#__PURE__*/ jsx(Button, {
930
+ loading: isDraftRelationsLoading,
931
+ disabled: !hasPermission || localesForAction.length === 0,
932
+ variant: "default",
933
+ onClick: handleAction,
934
+ children: formatMessage({
935
+ id: isBulkPublish ? 'app.utils.publish' : 'app.utils.unpublish',
936
+ defaultMessage: isBulkPublish ? 'Publish' : 'Unpublish'
937
+ })
938
+ })
939
+ })
940
+ }
941
+ };
942
+ };
943
+ /* -------------------------------------------------------------------------------------------------
944
+ * BulkLocalePublishAction
945
+ * -----------------------------------------------------------------------------------------------*/ const BulkLocalePublishAction = (props)=>{
946
+ return BulkLocaleAction({
947
+ action: 'bulk-publish',
948
+ ...props
949
+ });
950
+ };
951
+ /* -------------------------------------------------------------------------------------------------
952
+ * BulkLocaleUnpublishAction
953
+ * -----------------------------------------------------------------------------------------------*/ const BulkLocaleUnpublishAction = (props)=>{
954
+ return BulkLocaleAction({
955
+ action: 'bulk-unpublish',
956
+ ...props
957
+ });
958
+ };
959
+ /**
960
+ * Because the icon system is completely broken, we have to do
961
+ * this to remove the fill from the cog.
962
+ */ const StyledTrash = styled(Trash)`
963
+ path {
964
+ fill: currentColor;
965
+ }
966
+ `;
967
+
968
+ export { AITranslationStatusAction, BulkLocalePublishAction, BulkLocaleUnpublishAction, DeleteLocaleAction, FillFromAnotherLocaleAction, LocalePickerAction };
969
+ //# sourceMappingURL=CMHeaderActions.mjs.map