@strapi/i18n 0.0.0-next.8f63e1055db761e0213cb6610f80c55658196ae1 → 0.0.0-next.913e7071c9410ff8af2e776e25f9fb1c38cb59dd

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