@strapi/i18n 0.0.0-next.4afb25b82502b04f05bbc122b43e1e3a806e7600 → 0.0.0-next.4e3b7c0d7fa4aea6cd9c7de5f63e77d79e147a0f

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