@strapi/i18n 0.0.0-experimental.e60ec1829240dae21c1e1d29076681c322288813 → 0.0.0-experimental.e81b49f196c3dd00856818d61a256a3ff8ec2011

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 (412) hide show
  1. package/LICENSE +18 -3
  2. package/dist/admin/components/BulkLocaleActionModal.js +262 -0
  3. package/dist/admin/components/BulkLocaleActionModal.js.map +1 -0
  4. package/dist/admin/components/BulkLocaleActionModal.mjs +260 -0
  5. package/dist/admin/components/BulkLocaleActionModal.mjs.map +1 -0
  6. package/dist/admin/components/CMHeaderActions.js +721 -0
  7. package/dist/admin/components/CMHeaderActions.js.map +1 -0
  8. package/dist/admin/components/CMHeaderActions.mjs +696 -0
  9. package/dist/admin/components/CMHeaderActions.mjs.map +1 -0
  10. package/dist/admin/components/CMListViewModalsAdditionalInformation.js +69 -0
  11. package/dist/admin/components/CMListViewModalsAdditionalInformation.js.map +1 -0
  12. package/dist/admin/components/CMListViewModalsAdditionalInformation.mjs +65 -0
  13. package/dist/admin/components/CMListViewModalsAdditionalInformation.mjs.map +1 -0
  14. package/dist/admin/components/CheckboxConfirmation.js +155 -0
  15. package/dist/admin/components/CheckboxConfirmation.js.map +1 -0
  16. package/dist/admin/components/CheckboxConfirmation.mjs +134 -0
  17. package/dist/admin/components/CheckboxConfirmation.mjs.map +1 -0
  18. package/dist/admin/components/CreateLocale.js +395 -0
  19. package/dist/admin/components/CreateLocale.js.map +1 -0
  20. package/dist/admin/components/CreateLocale.mjs +369 -0
  21. package/dist/admin/components/CreateLocale.mjs.map +1 -0
  22. package/dist/admin/components/DeleteLocale.js +90 -0
  23. package/dist/admin/components/DeleteLocale.js.map +1 -0
  24. package/dist/admin/components/DeleteLocale.mjs +69 -0
  25. package/dist/admin/components/DeleteLocale.mjs.map +1 -0
  26. package/dist/admin/components/EditLocale.js +212 -0
  27. package/dist/admin/components/EditLocale.js.map +1 -0
  28. package/dist/admin/components/EditLocale.mjs +190 -0
  29. package/dist/admin/components/EditLocale.mjs.map +1 -0
  30. package/dist/admin/components/LocaleListCell.js +82 -0
  31. package/dist/admin/components/LocaleListCell.js.map +1 -0
  32. package/dist/admin/components/LocaleListCell.mjs +80 -0
  33. package/dist/admin/components/LocaleListCell.mjs.map +1 -0
  34. package/dist/admin/components/LocalePicker.js +98 -0
  35. package/dist/admin/components/LocalePicker.js.map +1 -0
  36. package/dist/admin/components/LocalePicker.mjs +77 -0
  37. package/dist/admin/components/LocalePicker.mjs.map +1 -0
  38. package/dist/admin/components/LocaleTable.js +143 -0
  39. package/dist/admin/components/LocaleTable.js.map +1 -0
  40. package/dist/admin/components/LocaleTable.mjs +122 -0
  41. package/dist/admin/components/LocaleTable.mjs.map +1 -0
  42. package/dist/admin/constants.js +37 -0
  43. package/dist/admin/constants.js.map +1 -0
  44. package/dist/admin/constants.mjs +35 -0
  45. package/dist/admin/constants.mjs.map +1 -0
  46. package/dist/admin/contentManagerHooks/editView.js +106 -0
  47. package/dist/admin/contentManagerHooks/editView.js.map +1 -0
  48. package/dist/admin/contentManagerHooks/editView.mjs +85 -0
  49. package/dist/admin/contentManagerHooks/editView.mjs.map +1 -0
  50. package/dist/admin/contentManagerHooks/listView.js +43 -0
  51. package/dist/admin/contentManagerHooks/listView.js.map +1 -0
  52. package/dist/admin/contentManagerHooks/listView.mjs +41 -0
  53. package/dist/admin/contentManagerHooks/listView.mjs.map +1 -0
  54. package/dist/admin/contentReleasesHooks/releaseDetailsView.js +20 -0
  55. package/dist/admin/contentReleasesHooks/releaseDetailsView.js.map +1 -0
  56. package/dist/admin/contentReleasesHooks/releaseDetailsView.mjs +18 -0
  57. package/dist/admin/contentReleasesHooks/releaseDetailsView.mjs.map +1 -0
  58. package/dist/admin/hooks/useI18n.js +78 -0
  59. package/dist/admin/hooks/useI18n.js.map +1 -0
  60. package/dist/admin/hooks/useI18n.mjs +57 -0
  61. package/dist/admin/hooks/useI18n.mjs.map +1 -0
  62. package/dist/admin/index.js +225 -5
  63. package/dist/admin/index.js.map +1 -1
  64. package/dist/admin/index.mjs +201 -5
  65. package/dist/admin/index.mjs.map +1 -1
  66. package/dist/admin/middlewares/extendCTBAttributeInitialData.js +71 -0
  67. package/dist/admin/middlewares/extendCTBAttributeInitialData.js.map +1 -0
  68. package/dist/admin/middlewares/extendCTBAttributeInitialData.mjs +69 -0
  69. package/dist/admin/middlewares/extendCTBAttributeInitialData.mjs.map +1 -0
  70. package/dist/admin/middlewares/extendCTBInitialData.js +40 -0
  71. package/dist/admin/middlewares/extendCTBInitialData.js.map +1 -0
  72. package/dist/admin/middlewares/extendCTBInitialData.mjs +38 -0
  73. package/dist/admin/middlewares/extendCTBInitialData.mjs.map +1 -0
  74. package/dist/admin/middlewares/rbac-middleware.js +49 -0
  75. package/dist/admin/middlewares/rbac-middleware.js.map +1 -0
  76. package/dist/admin/middlewares/rbac-middleware.mjs +28 -0
  77. package/dist/admin/middlewares/rbac-middleware.mjs.map +1 -0
  78. package/dist/admin/pages/SettingsPage.js +107 -0
  79. package/dist/admin/pages/SettingsPage.js.map +1 -0
  80. package/dist/admin/pages/SettingsPage.mjs +85 -0
  81. package/dist/admin/pages/SettingsPage.mjs.map +1 -0
  82. package/dist/admin/pluginId.js +6 -0
  83. package/dist/admin/pluginId.js.map +1 -0
  84. package/dist/admin/pluginId.mjs +4 -0
  85. package/dist/admin/pluginId.mjs.map +1 -0
  86. package/dist/admin/services/api.js +13 -0
  87. package/dist/admin/services/api.js.map +1 -0
  88. package/dist/admin/services/api.mjs +11 -0
  89. package/dist/admin/services/api.mjs.map +1 -0
  90. package/dist/admin/services/locales.js +72 -0
  91. package/dist/admin/services/locales.js.map +1 -0
  92. package/dist/admin/services/locales.mjs +66 -0
  93. package/dist/admin/services/locales.mjs.map +1 -0
  94. package/dist/admin/services/relations.js +23 -0
  95. package/dist/admin/services/relations.js.map +1 -0
  96. package/dist/admin/services/relations.mjs +21 -0
  97. package/dist/admin/services/relations.mjs.map +1 -0
  98. package/dist/admin/src/components/BulkLocaleActionModal.d.ts +16 -0
  99. package/dist/admin/src/components/CMHeaderActions.d.ts +35 -3
  100. package/dist/admin/src/components/CreateLocale.d.ts +6 -6
  101. package/dist/admin/src/components/EditLocale.d.ts +5 -4
  102. package/dist/admin/src/components/LocaleListCell.d.ts +4 -4
  103. package/dist/admin/src/components/tests/CreateLocale.test.d.ts +1 -0
  104. package/dist/admin/src/components/tests/DeleteLocale.test.d.ts +1 -0
  105. package/dist/admin/src/components/tests/EditLocale.test.d.ts +1 -0
  106. package/dist/admin/src/components/tests/LocaleListCell.test.d.ts +1 -0
  107. package/dist/admin/src/contentReleasesHooks/releaseDetailsView.d.ts +10 -6
  108. package/dist/admin/src/pages/tests/SettingsPage.test.d.ts +1 -0
  109. package/dist/admin/src/services/api.d.ts +2 -3
  110. package/dist/admin/src/services/locales.d.ts +1 -1
  111. package/dist/admin/src/services/relations.d.ts +7 -0
  112. package/dist/admin/src/utils/baseQuery.d.ts +4 -19
  113. package/dist/admin/src/utils/clean.d.ts +4 -0
  114. package/dist/admin/src/utils/schemas.d.ts +642 -15
  115. package/dist/admin/tests/server.d.ts +1 -0
  116. package/dist/admin/tests/utils.d.ts +6 -0
  117. package/dist/admin/translations/de.json.js +66 -0
  118. package/dist/admin/translations/de.json.js.map +1 -0
  119. package/dist/admin/translations/de.json.mjs +64 -0
  120. package/dist/admin/translations/de.json.mjs.map +1 -0
  121. package/dist/admin/translations/dk.json.js +66 -0
  122. package/dist/admin/translations/dk.json.js.map +1 -0
  123. package/dist/admin/translations/dk.json.mjs +64 -0
  124. package/dist/admin/translations/dk.json.mjs.map +1 -0
  125. package/dist/admin/translations/en.json.js +81 -0
  126. package/dist/admin/translations/en.json.js.map +1 -0
  127. package/dist/admin/translations/en.json.mjs +79 -0
  128. package/dist/admin/translations/en.json.mjs.map +1 -0
  129. package/dist/admin/translations/es.json.js +66 -0
  130. package/dist/admin/translations/es.json.js.map +1 -0
  131. package/dist/admin/translations/es.json.mjs +64 -0
  132. package/dist/admin/translations/es.json.mjs.map +1 -0
  133. package/dist/admin/translations/fr.json.js +66 -0
  134. package/dist/admin/translations/fr.json.js.map +1 -0
  135. package/dist/admin/translations/fr.json.mjs +64 -0
  136. package/dist/admin/translations/fr.json.mjs.map +1 -0
  137. package/dist/admin/translations/ko.json.js +65 -0
  138. package/dist/admin/translations/ko.json.js.map +1 -0
  139. package/dist/admin/translations/ko.json.mjs +63 -0
  140. package/dist/admin/translations/ko.json.mjs.map +1 -0
  141. package/dist/admin/translations/pl.json.js +66 -0
  142. package/dist/admin/translations/pl.json.js.map +1 -0
  143. package/dist/admin/translations/pl.json.mjs +64 -0
  144. package/dist/admin/translations/pl.json.mjs.map +1 -0
  145. package/dist/admin/translations/ru.json.js +68 -0
  146. package/dist/admin/translations/ru.json.js.map +1 -0
  147. package/dist/admin/translations/ru.json.mjs +66 -0
  148. package/dist/admin/translations/ru.json.mjs.map +1 -0
  149. package/dist/admin/translations/tr.json.js +66 -0
  150. package/dist/admin/translations/tr.json.js.map +1 -0
  151. package/dist/admin/translations/tr.json.mjs +64 -0
  152. package/dist/admin/translations/tr.json.mjs.map +1 -0
  153. package/dist/admin/translations/uk.json.js +82 -0
  154. package/dist/admin/translations/uk.json.js.map +1 -0
  155. package/dist/admin/translations/uk.json.mjs +80 -0
  156. package/dist/admin/translations/uk.json.mjs.map +1 -0
  157. package/dist/admin/translations/zh-Hans.json.js +57 -0
  158. package/dist/admin/translations/zh-Hans.json.js.map +1 -0
  159. package/dist/admin/translations/zh-Hans.json.mjs +55 -0
  160. package/dist/admin/translations/zh-Hans.json.mjs.map +1 -0
  161. package/dist/admin/translations/zh.json.js +66 -0
  162. package/dist/admin/translations/zh.json.js.map +1 -0
  163. package/dist/admin/translations/zh.json.mjs +64 -0
  164. package/dist/admin/translations/zh.json.mjs.map +1 -0
  165. package/dist/admin/utils/baseQuery.js +8 -0
  166. package/dist/admin/utils/baseQuery.js.map +1 -0
  167. package/dist/admin/utils/baseQuery.mjs +6 -0
  168. package/dist/admin/utils/baseQuery.mjs.map +1 -0
  169. package/dist/admin/utils/clean.js +70 -0
  170. package/dist/admin/utils/clean.js.map +1 -0
  171. package/dist/admin/utils/clean.mjs +68 -0
  172. package/dist/admin/utils/clean.mjs.map +1 -0
  173. package/dist/admin/utils/fields.js +34 -0
  174. package/dist/admin/utils/fields.js.map +1 -0
  175. package/dist/admin/utils/fields.mjs +31 -0
  176. package/dist/admin/utils/fields.mjs.map +1 -0
  177. package/dist/admin/utils/getTranslation.js +8 -0
  178. package/dist/admin/utils/getTranslation.js.map +1 -0
  179. package/dist/admin/utils/getTranslation.mjs +6 -0
  180. package/dist/admin/utils/getTranslation.mjs.map +1 -0
  181. package/dist/admin/utils/prefixPluginTranslations.js +11 -0
  182. package/dist/admin/utils/prefixPluginTranslations.js.map +1 -0
  183. package/dist/admin/utils/prefixPluginTranslations.mjs +9 -0
  184. package/dist/admin/utils/prefixPluginTranslations.mjs.map +1 -0
  185. package/dist/admin/utils/schemas.js +74 -0
  186. package/dist/admin/utils/schemas.js.map +1 -0
  187. package/dist/admin/utils/schemas.mjs +72 -0
  188. package/dist/admin/utils/schemas.mjs.map +1 -0
  189. package/dist/admin/utils/strings.js +6 -0
  190. package/dist/admin/utils/strings.js.map +1 -0
  191. package/dist/admin/utils/strings.mjs +4 -0
  192. package/dist/admin/utils/strings.mjs.map +1 -0
  193. package/dist/server/bootstrap.js +79 -0
  194. package/dist/server/bootstrap.js.map +1 -0
  195. package/dist/server/bootstrap.mjs +77 -0
  196. package/dist/server/bootstrap.mjs.map +1 -0
  197. package/dist/server/constants/index.js +29 -0
  198. package/dist/server/constants/index.js.map +1 -0
  199. package/dist/server/constants/index.mjs +25 -0
  200. package/dist/server/constants/index.mjs.map +1 -0
  201. package/dist/server/constants/iso-locales.json.js +2423 -0
  202. package/dist/server/constants/iso-locales.json.js.map +1 -0
  203. package/dist/server/constants/iso-locales.json.mjs +2421 -0
  204. package/dist/server/constants/iso-locales.json.mjs.map +1 -0
  205. package/dist/server/content-types/index.js +10 -0
  206. package/dist/server/content-types/index.js.map +1 -0
  207. package/dist/server/content-types/index.mjs +8 -0
  208. package/dist/server/content-types/index.mjs.map +1 -0
  209. package/dist/server/content-types/locale/index.js +10 -0
  210. package/dist/server/content-types/locale/index.js.map +1 -0
  211. package/dist/server/content-types/locale/index.mjs +8 -0
  212. package/dist/server/content-types/locale/index.mjs.map +1 -0
  213. package/dist/server/content-types/locale/schema.json.js +46 -0
  214. package/dist/server/content-types/locale/schema.json.js.map +1 -0
  215. package/dist/server/content-types/locale/schema.json.mjs +38 -0
  216. package/dist/server/content-types/locale/schema.json.mjs.map +1 -0
  217. package/dist/server/controllers/content-types.js +76 -0
  218. package/dist/server/controllers/content-types.js.map +1 -0
  219. package/dist/server/controllers/content-types.mjs +74 -0
  220. package/dist/server/controllers/content-types.mjs.map +1 -0
  221. package/dist/server/controllers/index.js +14 -0
  222. package/dist/server/controllers/index.js.map +1 -0
  223. package/dist/server/controllers/index.mjs +12 -0
  224. package/dist/server/controllers/index.mjs.map +1 -0
  225. package/dist/server/controllers/iso-locales.js +13 -0
  226. package/dist/server/controllers/iso-locales.js.map +1 -0
  227. package/dist/server/controllers/iso-locales.mjs +11 -0
  228. package/dist/server/controllers/iso-locales.mjs.map +1 -0
  229. package/dist/server/controllers/locales.js +108 -0
  230. package/dist/server/controllers/locales.js.map +1 -0
  231. package/dist/server/controllers/locales.mjs +87 -0
  232. package/dist/server/controllers/locales.mjs.map +1 -0
  233. package/dist/server/controllers/validate-locale-creation.js +47 -0
  234. package/dist/server/controllers/validate-locale-creation.js.map +1 -0
  235. package/dist/server/controllers/validate-locale-creation.mjs +45 -0
  236. package/dist/server/controllers/validate-locale-creation.mjs.map +1 -0
  237. package/dist/server/domain/locale.js +11 -0
  238. package/dist/server/domain/locale.js.map +1 -0
  239. package/dist/server/domain/locale.mjs +9 -0
  240. package/dist/server/domain/locale.mjs.map +1 -0
  241. package/dist/server/graphql.js +115 -0
  242. package/dist/server/graphql.js.map +1 -0
  243. package/dist/server/graphql.mjs +113 -0
  244. package/dist/server/graphql.mjs.map +1 -0
  245. package/dist/server/index.js +18 -3520
  246. package/dist/server/index.js.map +1 -1
  247. package/dist/server/index.mjs +17 -3502
  248. package/dist/server/index.mjs.map +1 -1
  249. package/dist/server/register.js +79 -0
  250. package/dist/server/register.js.map +1 -0
  251. package/dist/server/register.mjs +77 -0
  252. package/dist/server/register.mjs.map +1 -0
  253. package/dist/server/routes/admin.js +102 -0
  254. package/dist/server/routes/admin.js.map +1 -0
  255. package/dist/server/routes/admin.mjs +100 -0
  256. package/dist/server/routes/admin.mjs.map +1 -0
  257. package/dist/server/routes/content-api.js +19 -0
  258. package/dist/server/routes/content-api.js.map +1 -0
  259. package/dist/server/routes/content-api.mjs +17 -0
  260. package/dist/server/routes/content-api.mjs.map +1 -0
  261. package/dist/server/routes/index.js +12 -0
  262. package/dist/server/routes/index.js.map +1 -0
  263. package/dist/server/routes/index.mjs +10 -0
  264. package/dist/server/routes/index.mjs.map +1 -0
  265. package/dist/server/routes/validation/locale.js +57 -0
  266. package/dist/server/routes/validation/locale.js.map +1 -0
  267. package/dist/server/routes/validation/locale.mjs +36 -0
  268. package/dist/server/routes/validation/locale.mjs.map +1 -0
  269. package/dist/server/services/content-types.js +157 -0
  270. package/dist/server/services/content-types.js.map +1 -0
  271. package/dist/server/services/content-types.mjs +155 -0
  272. package/dist/server/services/content-types.mjs.map +1 -0
  273. package/dist/server/services/index.js +22 -0
  274. package/dist/server/services/index.js.map +1 -0
  275. package/dist/server/services/index.mjs +20 -0
  276. package/dist/server/services/index.mjs.map +1 -0
  277. package/dist/server/services/iso-locales.js +12 -0
  278. package/dist/server/services/iso-locales.js.map +1 -0
  279. package/dist/server/services/iso-locales.mjs +10 -0
  280. package/dist/server/services/iso-locales.mjs.map +1 -0
  281. package/dist/server/services/locales.js +114 -0
  282. package/dist/server/services/locales.js.map +1 -0
  283. package/dist/server/services/locales.mjs +112 -0
  284. package/dist/server/services/locales.mjs.map +1 -0
  285. package/dist/server/services/localizations.js +68 -0
  286. package/dist/server/services/localizations.js.map +1 -0
  287. package/dist/server/services/localizations.mjs +66 -0
  288. package/dist/server/services/localizations.mjs.map +1 -0
  289. package/dist/server/services/metrics.js +30 -0
  290. package/dist/server/services/metrics.js.map +1 -0
  291. package/dist/server/services/metrics.mjs +28 -0
  292. package/dist/server/services/metrics.mjs.map +1 -0
  293. package/dist/server/services/permissions/actions.js +136 -0
  294. package/dist/server/services/permissions/actions.js.map +1 -0
  295. package/dist/server/services/permissions/actions.mjs +134 -0
  296. package/dist/server/services/permissions/actions.mjs.map +1 -0
  297. package/dist/server/services/permissions/engine.js +52 -0
  298. package/dist/server/services/permissions/engine.js.map +1 -0
  299. package/dist/server/services/permissions/engine.mjs +50 -0
  300. package/dist/server/services/permissions/engine.mjs.map +1 -0
  301. package/dist/server/services/permissions/sections-builder.js +45 -0
  302. package/dist/server/services/permissions/sections-builder.js.map +1 -0
  303. package/dist/server/services/permissions/sections-builder.mjs +43 -0
  304. package/dist/server/services/permissions/sections-builder.mjs.map +1 -0
  305. package/dist/server/services/permissions.js +14 -0
  306. package/dist/server/services/permissions.js.map +1 -0
  307. package/dist/server/services/permissions.mjs +12 -0
  308. package/dist/server/services/permissions.mjs.map +1 -0
  309. package/dist/server/services/sanitize/index.js +34 -0
  310. package/dist/server/services/sanitize/index.js.map +1 -0
  311. package/dist/server/services/sanitize/index.mjs +32 -0
  312. package/dist/server/services/sanitize/index.mjs.map +1 -0
  313. package/dist/server/src/bootstrap.d.ts +1 -4
  314. package/dist/server/src/bootstrap.d.ts.map +1 -1
  315. package/dist/server/src/index.d.ts +24 -20
  316. package/dist/server/src/index.d.ts.map +1 -1
  317. package/dist/server/src/register.d.ts.map +1 -1
  318. package/dist/server/src/routes/content-api.d.ts +5 -8
  319. package/dist/server/src/routes/content-api.d.ts.map +1 -1
  320. package/dist/server/src/routes/index.d.ts +3 -7
  321. package/dist/server/src/routes/index.d.ts.map +1 -1
  322. package/dist/server/src/routes/validation/index.d.ts +2 -0
  323. package/dist/server/src/routes/validation/index.d.ts.map +1 -0
  324. package/dist/server/src/routes/validation/locale.d.ts +41 -0
  325. package/dist/server/src/routes/validation/locale.d.ts.map +1 -0
  326. package/dist/server/src/services/index.d.ts +20 -10
  327. package/dist/server/src/services/index.d.ts.map +1 -1
  328. package/dist/server/src/services/localizations.d.ts +1 -1
  329. package/dist/server/src/services/localizations.d.ts.map +1 -1
  330. package/dist/server/src/services/permissions/actions.d.ts +14 -2
  331. package/dist/server/src/services/permissions/actions.d.ts.map +1 -1
  332. package/dist/server/src/services/permissions.d.ts +14 -2
  333. package/dist/server/src/services/permissions.d.ts.map +1 -1
  334. package/dist/server/src/services/sanitize/index.d.ts +11 -0
  335. package/dist/server/src/services/sanitize/index.d.ts.map +1 -0
  336. package/dist/server/src/utils/index.d.ts +2 -2
  337. package/dist/server/src/utils/index.d.ts.map +1 -1
  338. package/dist/server/utils/index.js +16 -0
  339. package/dist/server/utils/index.js.map +1 -0
  340. package/dist/server/utils/index.mjs +13 -0
  341. package/dist/server/utils/index.mjs.map +1 -0
  342. package/dist/server/validation/content-types.js +18 -0
  343. package/dist/server/validation/content-types.js.map +1 -0
  344. package/dist/server/validation/content-types.mjs +16 -0
  345. package/dist/server/validation/content-types.mjs.map +1 -0
  346. package/dist/server/validation/locales.js +23 -0
  347. package/dist/server/validation/locales.js.map +1 -0
  348. package/dist/server/validation/locales.mjs +20 -0
  349. package/dist/server/validation/locales.mjs.map +1 -0
  350. package/dist/shared/contracts/content-manager.d.ts +20 -1
  351. package/dist/shared/contracts/shared.d.ts +1 -1
  352. package/package.json +26 -24
  353. package/dist/_chunks/SettingsPage-CeqfDjsb.mjs +0 -565
  354. package/dist/_chunks/SettingsPage-CeqfDjsb.mjs.map +0 -1
  355. package/dist/_chunks/SettingsPage-Djqsdrzs.js +0 -585
  356. package/dist/_chunks/SettingsPage-Djqsdrzs.js.map +0 -1
  357. package/dist/_chunks/de-9eCAqqrB.mjs +0 -66
  358. package/dist/_chunks/de-9eCAqqrB.mjs.map +0 -1
  359. package/dist/_chunks/de-DtWiGdHl.js +0 -66
  360. package/dist/_chunks/de-DtWiGdHl.js.map +0 -1
  361. package/dist/_chunks/dk-2qBjxt-P.mjs +0 -66
  362. package/dist/_chunks/dk-2qBjxt-P.mjs.map +0 -1
  363. package/dist/_chunks/dk-D8C-casx.js +0 -66
  364. package/dist/_chunks/dk-D8C-casx.js.map +0 -1
  365. package/dist/_chunks/en-BuBc6LKZ.js +0 -69
  366. package/dist/_chunks/en-BuBc6LKZ.js.map +0 -1
  367. package/dist/_chunks/en-CnrTsjWS.mjs +0 -69
  368. package/dist/_chunks/en-CnrTsjWS.mjs.map +0 -1
  369. package/dist/_chunks/es-DS-XFGSw.js +0 -66
  370. package/dist/_chunks/es-DS-XFGSw.js.map +0 -1
  371. package/dist/_chunks/es-DlmMVaBG.mjs +0 -66
  372. package/dist/_chunks/es-DlmMVaBG.mjs.map +0 -1
  373. package/dist/_chunks/fr-3S6ke71d.mjs +0 -66
  374. package/dist/_chunks/fr-3S6ke71d.mjs.map +0 -1
  375. package/dist/_chunks/fr-BTjekDpq.js +0 -66
  376. package/dist/_chunks/fr-BTjekDpq.js.map +0 -1
  377. package/dist/_chunks/index-BDU1w_fd.mjs +0 -1058
  378. package/dist/_chunks/index-BDU1w_fd.mjs.map +0 -1
  379. package/dist/_chunks/index-DMXJeGjN.js +0 -1082
  380. package/dist/_chunks/index-DMXJeGjN.js.map +0 -1
  381. package/dist/_chunks/ko-DmcGUBQ3.js +0 -65
  382. package/dist/_chunks/ko-DmcGUBQ3.js.map +0 -1
  383. package/dist/_chunks/ko-qTjQ8IMw.mjs +0 -65
  384. package/dist/_chunks/ko-qTjQ8IMw.mjs.map +0 -1
  385. package/dist/_chunks/pl-B67TSHqT.mjs +0 -66
  386. package/dist/_chunks/pl-B67TSHqT.mjs.map +0 -1
  387. package/dist/_chunks/pl-Cn5RYonZ.js +0 -66
  388. package/dist/_chunks/pl-Cn5RYonZ.js.map +0 -1
  389. package/dist/_chunks/ru-BMBgVL3s.js +0 -68
  390. package/dist/_chunks/ru-BMBgVL3s.js.map +0 -1
  391. package/dist/_chunks/ru-hagMa57T.mjs +0 -68
  392. package/dist/_chunks/ru-hagMa57T.mjs.map +0 -1
  393. package/dist/_chunks/tr-CarUU76c.js +0 -66
  394. package/dist/_chunks/tr-CarUU76c.js.map +0 -1
  395. package/dist/_chunks/tr-Dw_jmkG-.mjs +0 -66
  396. package/dist/_chunks/tr-Dw_jmkG-.mjs.map +0 -1
  397. package/dist/_chunks/zh-57YM4amO.mjs +0 -66
  398. package/dist/_chunks/zh-57YM4amO.mjs.map +0 -1
  399. package/dist/_chunks/zh-CukOviB0.js +0 -66
  400. package/dist/_chunks/zh-CukOviB0.js.map +0 -1
  401. package/dist/_chunks/zh-Hans-DSHIXAa3.js +0 -57
  402. package/dist/_chunks/zh-Hans-DSHIXAa3.js.map +0 -1
  403. package/dist/_chunks/zh-Hans-Dyc-aR-h.mjs +0 -57
  404. package/dist/_chunks/zh-Hans-Dyc-aR-h.mjs.map +0 -1
  405. package/dist/admin/src/components/Initializer.d.ts +0 -5
  406. package/dist/server/src/migrations/content-type/disable/index.d.ts +0 -3
  407. package/dist/server/src/migrations/content-type/disable/index.d.ts.map +0 -1
  408. package/dist/server/src/migrations/content-type/enable/index.d.ts +0 -3
  409. package/dist/server/src/migrations/content-type/enable/index.d.ts.map +0 -1
  410. package/dist/server/src/services/entity-service-decorator.d.ts +0 -29
  411. package/dist/server/src/services/entity-service-decorator.d.ts.map +0 -1
  412. package/strapi-server.js +0 -3
@@ -1,1058 +0,0 @@
1
- import get from "lodash/get";
2
- import * as yup from "yup";
3
- import { jsxs, Fragment, jsx } from "react/jsx-runtime";
4
- import * as React from "react";
5
- import { Typography, Checkbox, Dialog, DialogBody, Flex, DialogFooter, Button as Button$1, Status, SingleSelect, SingleSelectOption, VisuallyHidden, useCollator, Popover, Box } from "@strapi/design-system";
6
- import { WarningCircle, Trash, Earth, EarthStriked, CaretDown } from "@strapi/icons";
7
- import { useIntl } from "react-intl";
8
- import styled from "styled-components";
9
- import { useAuth, getFetchClient, useQueryParams, useNotification } from "@strapi/admin/strapi-admin";
10
- import { unstable_useDocument, unstable_useDocumentActions } from "@strapi/content-manager/strapi-admin";
11
- import { useParams, useNavigate, matchPath } from "react-router-dom";
12
- import { createApi } from "@reduxjs/toolkit/query/react";
13
- import { isAxiosError } from "axios";
14
- import * as qs from "qs";
15
- import omit from "lodash/omit";
16
- const __variableDynamicImportRuntimeHelper = (glob, path) => {
17
- const v = glob[path];
18
- if (v) {
19
- return typeof v === "function" ? v() : Promise.resolve(v);
20
- }
21
- return new Promise((_, reject) => {
22
- (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(reject.bind(null, new Error("Unknown variable dynamic import: " + path)));
23
- });
24
- };
25
- const pluginId = "i18n";
26
- const getTranslation = (id) => `${pluginId}.${id}`;
27
- const TextAlignTypography = styled(Typography)`
28
- text-align: center;
29
- `;
30
- const CheckboxConfirmation = ({
31
- description,
32
- isCreating = false,
33
- intlLabel,
34
- name,
35
- onChange,
36
- value
37
- }) => {
38
- const { formatMessage } = useIntl();
39
- const [isOpen, setIsOpen] = React.useState(false);
40
- const handleChange = (value2) => {
41
- if (isCreating || value2) {
42
- return onChange({ target: { name, value: value2, type: "checkbox" } });
43
- }
44
- if (!value2) {
45
- return setIsOpen(true);
46
- }
47
- return null;
48
- };
49
- const handleConfirm = () => {
50
- onChange({ target: { name, value: false, type: "checkbox" } });
51
- setIsOpen(false);
52
- };
53
- const handleToggle = () => setIsOpen((prev) => !prev);
54
- const label = intlLabel.id ? formatMessage(
55
- { id: intlLabel.id, defaultMessage: intlLabel.defaultMessage },
56
- { ...intlLabel.values }
57
- ) : name;
58
- const hint = description ? formatMessage(
59
- { id: description.id, defaultMessage: description.defaultMessage },
60
- { ...description.values }
61
- ) : "";
62
- return /* @__PURE__ */ jsxs(Fragment, { children: [
63
- /* @__PURE__ */ jsx(
64
- Checkbox,
65
- {
66
- hint,
67
- id: name,
68
- name,
69
- onValueChange: handleChange,
70
- value,
71
- type: "checkbox",
72
- children: label
73
- }
74
- ),
75
- isOpen && /* @__PURE__ */ jsxs(Dialog, { onClose: handleToggle, title: "Confirmation", isOpen, children: [
76
- /* @__PURE__ */ jsx(DialogBody, { icon: /* @__PURE__ */ jsx(WarningCircle, {}), children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
77
- /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(TextAlignTypography, { id: "confirm-description", children: formatMessage({
78
- id: getTranslation("CheckboxConfirmation.Modal.content"),
79
- defaultMessage: "Disabling localization will engender the deletion of all your content but the one associated to your default locale (if existing)."
80
- }) }) }),
81
- /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Typography, { fontWeight: "semiBold", id: "confirm-description", children: formatMessage({
82
- id: getTranslation("CheckboxConfirmation.Modal.body"),
83
- defaultMessage: "Do you want to disable it?"
84
- }) }) })
85
- ] }) }),
86
- /* @__PURE__ */ jsx(
87
- DialogFooter,
88
- {
89
- startAction: /* @__PURE__ */ jsx(Button$1, { onClick: handleToggle, variant: "tertiary", children: formatMessage({
90
- id: "components.popUpWarning.button.cancel",
91
- defaultMessage: "No, cancel"
92
- }) }),
93
- endAction: /* @__PURE__ */ jsx(Button$1, { variant: "danger-light", onClick: handleConfirm, children: formatMessage({
94
- id: getTranslation("CheckboxConfirmation.Modal.button-confirm"),
95
- defaultMessage: "Yes, disable"
96
- }) })
97
- }
98
- )
99
- ] })
100
- ] });
101
- };
102
- const LOCALIZED_FIELDS = [
103
- "biginteger",
104
- "boolean",
105
- "component",
106
- "date",
107
- "datetime",
108
- "decimal",
109
- "dynamiczone",
110
- "email",
111
- "enumeration",
112
- "float",
113
- "integer",
114
- "json",
115
- "media",
116
- "number",
117
- "password",
118
- "richtext",
119
- "blocks",
120
- "string",
121
- "text",
122
- "time"
123
- ];
124
- const doesPluginOptionsHaveI18nLocalized = (opts) => typeof opts === "object" && opts !== null && "i18n" in opts && typeof opts.i18n === "object" && opts.i18n !== null && "localized" in opts.i18n && typeof opts.i18n.localized === "boolean";
125
- const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
126
- const useI18n = () => {
127
- const params = useParams();
128
- const userPermissions = useAuth("useI18n", (state) => state.permissions);
129
- const actions = React.useMemo(() => {
130
- const permissions = userPermissions.filter((permission) => permission.subject === params.slug);
131
- return permissions.reduce(
132
- (acc, permission) => {
133
- const [actionShorthand] = permission.action.split(".").slice(-1);
134
- return {
135
- ...acc,
136
- [`can${capitalize(actionShorthand)}`]: permission.properties?.locales ?? []
137
- };
138
- },
139
- { canCreate: [], canRead: [], canUpdate: [], canDelete: [], canPublish: [] }
140
- );
141
- }, [params.slug, userPermissions]);
142
- const { schema } = unstable_useDocument(
143
- {
144
- // We can non-null assert these because below we skip the query if they are not present
145
- collectionType: params.collectionType,
146
- model: params.slug
147
- },
148
- {
149
- skip: !params.slug || !params.collectionType
150
- }
151
- );
152
- if (doesPluginOptionsHaveI18nLocalized(schema?.pluginOptions)) {
153
- return {
154
- hasI18n: schema.pluginOptions.i18n.localized,
155
- ...actions
156
- };
157
- }
158
- return {
159
- hasI18n: false,
160
- ...actions
161
- };
162
- };
163
- const axiosBaseQuery = () => async (query, { signal }) => {
164
- try {
165
- const { get: get2, post, del, put } = getFetchClient();
166
- if (typeof query === "string") {
167
- const result = await get2(query, { signal });
168
- return { data: result.data };
169
- } else {
170
- const { url, method = "GET", data, config } = query;
171
- if (method === "POST") {
172
- const result2 = await post(url, data, { ...config, signal });
173
- return { data: result2.data };
174
- }
175
- if (method === "DELETE") {
176
- const result2 = await del(url, { ...config, signal });
177
- return { data: result2.data };
178
- }
179
- if (method === "PUT") {
180
- const result2 = await put(url, data, { ...config, signal });
181
- return { data: result2.data };
182
- }
183
- const result = await get2(url, { ...config, signal });
184
- return { data: result.data };
185
- }
186
- } catch (err) {
187
- if (isAxiosError(err)) {
188
- if (typeof err.response?.data === "object" && err.response?.data !== null && "error" in err.response?.data) {
189
- return { data: void 0, error: err.response?.data.error };
190
- } else {
191
- return {
192
- data: void 0,
193
- error: {
194
- name: "UnknownError",
195
- message: "There was an unknown error response from the API",
196
- details: err.response?.data,
197
- status: err.response?.status
198
- }
199
- };
200
- }
201
- }
202
- const error = err;
203
- return {
204
- data: void 0,
205
- error: {
206
- name: error.name,
207
- message: error.message,
208
- stack: error.stack
209
- }
210
- };
211
- }
212
- };
213
- const isBaseQueryError = (error) => {
214
- return error.name !== void 0;
215
- };
216
- const i18nApi = createApi({
217
- reducerPath: "i18nApi",
218
- baseQuery: axiosBaseQuery(),
219
- tagTypes: ["Locale"],
220
- endpoints: () => ({})
221
- });
222
- const localesApi = i18nApi.injectEndpoints({
223
- endpoints: (builder) => ({
224
- createLocale: builder.mutation({
225
- query: (data) => ({
226
- url: "/i18n/locales",
227
- method: "POST",
228
- data
229
- }),
230
- invalidatesTags: [{ type: "Locale", id: "LIST" }]
231
- }),
232
- deleteLocale: builder.mutation({
233
- query: (id) => ({
234
- url: `/i18n/locales/${id}`,
235
- method: "DELETE"
236
- }),
237
- invalidatesTags: (result, error, id) => [{ type: "Locale", id }]
238
- }),
239
- getLocales: builder.query({
240
- query: () => "/i18n/locales",
241
- providesTags: (res) => [
242
- { type: "Locale", id: "LIST" },
243
- ...Array.isArray(res) ? res.map((locale) => ({
244
- type: "Locale",
245
- id: locale.id
246
- })) : []
247
- ]
248
- }),
249
- getDefaultLocales: builder.query({
250
- query: () => "/i18n/iso-locales"
251
- }),
252
- updateLocale: builder.mutation({
253
- query: ({ id, ...data }) => ({
254
- url: `/i18n/locales/${id}`,
255
- method: "PUT",
256
- data
257
- }),
258
- invalidatesTags: (result, error, { id }) => [{ type: "Locale", id }]
259
- })
260
- })
261
- });
262
- const {
263
- useCreateLocaleMutation,
264
- useDeleteLocaleMutation,
265
- useGetLocalesQuery,
266
- useGetDefaultLocalesQuery,
267
- useUpdateLocaleMutation
268
- } = localesApi;
269
- const LocalePickerAction = ({
270
- document,
271
- meta,
272
- model,
273
- collectionType,
274
- documentId
275
- }) => {
276
- const { formatMessage } = useIntl();
277
- const [{ query }, setQuery] = useQueryParams();
278
- const { hasI18n, canCreate, canRead } = useI18n();
279
- const { data: locales = [] } = useGetLocalesQuery();
280
- const { schema } = unstable_useDocument({ model, collectionType, documentId });
281
- const handleSelect = React.useCallback(
282
- (value) => {
283
- setQuery({
284
- plugins: {
285
- ...query.plugins,
286
- i18n: {
287
- locale: value
288
- }
289
- }
290
- });
291
- },
292
- [query.plugins, setQuery]
293
- );
294
- React.useEffect(() => {
295
- if (!Array.isArray(locales) || !hasI18n) {
296
- return;
297
- }
298
- const currentDesiredLocale = query.plugins?.i18n?.locale;
299
- const doesLocaleExist = locales.find((loc) => loc.code === currentDesiredLocale);
300
- const defaultLocale = locales.find((locale) => locale.isDefault);
301
- if (!doesLocaleExist && defaultLocale?.code) {
302
- handleSelect(defaultLocale.code);
303
- }
304
- }, [handleSelect, hasI18n, locales, query.plugins?.i18n?.locale]);
305
- if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {
306
- return null;
307
- }
308
- const currentLocale = query.plugins?.i18n?.locale || locales.find((loc) => loc.isDefault)?.code;
309
- const allCurrentLocales = [
310
- { status: getDocumentStatus(document, meta), locale: currentLocale },
311
- ...meta?.availableLocales ?? []
312
- ];
313
- return {
314
- label: formatMessage({
315
- id: getTranslation("Settings.locales.modal.locales.label"),
316
- defaultMessage: "Locales"
317
- }),
318
- options: locales.map((locale) => {
319
- const currentLocaleDoc = allCurrentLocales.find(
320
- (doc) => "locale" in doc ? doc.locale === locale.code : false
321
- );
322
- const status = currentLocaleDoc?.status ?? "draft";
323
- const permissionsToCheck = currentLocaleDoc ? canCreate : canRead;
324
- const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
325
- return {
326
- disabled: !permissionsToCheck.includes(locale.code),
327
- value: locale.code,
328
- label: locale.name,
329
- startIcon: schema?.options?.draftAndPublish ? /* @__PURE__ */ jsx(
330
- Status,
331
- {
332
- display: "flex",
333
- paddingLeft: "6px",
334
- paddingRight: "6px",
335
- paddingTop: "2px",
336
- paddingBottom: "2px",
337
- showBullet: false,
338
- size: "S",
339
- variant: statusVariant,
340
- children: /* @__PURE__ */ jsx(Typography, { as: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
341
- }
342
- ) : null
343
- };
344
- }),
345
- onSelect: handleSelect,
346
- value: currentLocale
347
- };
348
- };
349
- const getDocumentStatus = (document, meta) => {
350
- const docStatus = document?.status;
351
- const statuses = meta?.availableStatus ?? [];
352
- if (!docStatus) {
353
- return "draft";
354
- }
355
- if (docStatus === "draft" && statuses.find((doc) => doc.publishedAt !== null)) {
356
- return "published";
357
- }
358
- return docStatus;
359
- };
360
- const DeleteLocaleAction = ({
361
- document,
362
- documentId,
363
- model,
364
- collectionType
365
- }) => {
366
- const { formatMessage } = useIntl();
367
- const navigate = useNavigate();
368
- const { toggleNotification } = useNotification();
369
- const { delete: deleteAction } = unstable_useDocumentActions();
370
- const { hasI18n, canDelete } = useI18n();
371
- if (!hasI18n) {
372
- return null;
373
- }
374
- return {
375
- disabled: document?.locale && !canDelete.includes(document.locale) || !document || !document.id,
376
- position: ["header", "table-row"],
377
- label: formatMessage({
378
- id: getTranslation("actions.delete.label"),
379
- defaultMessage: "Delete locale"
380
- }),
381
- icon: /* @__PURE__ */ jsx(StyledTrash, {}),
382
- variant: "danger",
383
- dialog: {
384
- type: "dialog",
385
- title: formatMessage({
386
- id: getTranslation("actions.delete.dialog.title"),
387
- defaultMessage: "Confirmation"
388
- }),
389
- content: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
390
- /* @__PURE__ */ jsx(WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
391
- /* @__PURE__ */ jsx(Typography, { as: "p", variant: "omega", textAlign: "center", children: formatMessage({
392
- id: getTranslation("actions.delete.dialog.body"),
393
- defaultMessage: "Are you sure?"
394
- }) })
395
- ] }),
396
- onConfirm: async () => {
397
- if (!documentId || !document?.locale) {
398
- console.error(
399
- "You're trying to delete a document without an id or locale, this is likely a bug with Strapi. Please open an issue."
400
- );
401
- toggleNotification({
402
- message: formatMessage({
403
- id: getTranslation("actions.delete.error"),
404
- defaultMessage: "An error occurred while trying to delete the document locale."
405
- }),
406
- type: "danger"
407
- });
408
- return;
409
- }
410
- const res = await deleteAction({
411
- documentId,
412
- model,
413
- collectionType,
414
- params: { locale: document.locale }
415
- });
416
- if (!("error" in res)) {
417
- navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
418
- }
419
- }
420
- }
421
- };
422
- };
423
- const StyledTrash = styled(Trash)`
424
- path {
425
- fill: currentColor;
426
- }
427
- `;
428
- const Emphasis = (chunks) => {
429
- return /* @__PURE__ */ jsx(Typography, { fontWeight: "semiBold", textColor: "danger500", children: chunks });
430
- };
431
- const DeleteModalAdditionalInfo = () => {
432
- const { hasI18n } = useI18n();
433
- const { formatMessage } = useIntl();
434
- if (!hasI18n) {
435
- return null;
436
- }
437
- return /* @__PURE__ */ jsx(Typography, { textColor: "danger500", children: formatMessage(
438
- {
439
- id: getTranslation("Settings.list.actions.deleteAdditionalInfos"),
440
- defaultMessage: "This will delete the active locale versions <em>(from Internationalization)</em>"
441
- },
442
- {
443
- em: Emphasis
444
- }
445
- ) });
446
- };
447
- const PublishModalAdditionalInfo = () => {
448
- const { hasI18n } = useI18n();
449
- const { formatMessage } = useIntl();
450
- if (!hasI18n) {
451
- return null;
452
- }
453
- return /* @__PURE__ */ jsx(Typography, { textColor: "danger500", children: formatMessage(
454
- {
455
- id: getTranslation("Settings.list.actions.publishAdditionalInfos"),
456
- defaultMessage: "This will publish the active locale versions <em>(from Internationalization)</em>"
457
- },
458
- {
459
- em: Emphasis
460
- }
461
- ) });
462
- };
463
- const UnpublishModalAdditionalInfo = () => {
464
- const { hasI18n } = useI18n();
465
- const { formatMessage } = useIntl();
466
- if (!hasI18n) {
467
- return null;
468
- }
469
- return /* @__PURE__ */ jsx(Typography, { textColor: "danger500", children: formatMessage(
470
- {
471
- id: getTranslation("Settings.list.actions.unpublishAdditionalInfos"),
472
- defaultMessage: "This will unpublish the active locale versions <em>(from Internationalization)</em>"
473
- },
474
- {
475
- em: Emphasis
476
- }
477
- ) });
478
- };
479
- const Initializer = ({ setPlugin }) => {
480
- const setPluginRef = React.useRef(setPlugin);
481
- React.useEffect(() => {
482
- setPluginRef.current(pluginId);
483
- }, []);
484
- return null;
485
- };
486
- const LocalePicker = () => {
487
- const { formatMessage } = useIntl();
488
- const [{ query }, setQuery] = useQueryParams();
489
- const { hasI18n, canRead, canCreate } = useI18n();
490
- const { data: locales = [] } = useGetLocalesQuery(void 0, {
491
- skip: !hasI18n
492
- });
493
- const handleChange = React.useCallback(
494
- (code, replace = false) => {
495
- setQuery(
496
- {
497
- page: 1,
498
- plugins: { ...query.plugins, i18n: { locale: code } }
499
- },
500
- "push",
501
- replace
502
- );
503
- },
504
- [query.plugins, setQuery]
505
- );
506
- React.useEffect(() => {
507
- if (!Array.isArray(locales) || !hasI18n) {
508
- return;
509
- }
510
- const currentDesiredLocale = query.plugins?.i18n?.locale;
511
- const doesLocaleExist = locales.find((loc) => loc.code === currentDesiredLocale);
512
- const defaultLocale = locales.find((locale) => locale.isDefault);
513
- if (!doesLocaleExist && defaultLocale?.code) {
514
- handleChange(defaultLocale.code, true);
515
- }
516
- }, [hasI18n, handleChange, locales, query.plugins?.i18n?.locale]);
517
- if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {
518
- return null;
519
- }
520
- const displayedLocales = locales.filter((locale) => {
521
- return canCreate.includes(locale.code) || canRead.includes(locale.code);
522
- });
523
- return /* @__PURE__ */ jsx(
524
- SingleSelect,
525
- {
526
- size: "S",
527
- "aria-label": formatMessage({
528
- id: getTranslation("actions.select-locale"),
529
- defaultMessage: "Select locale"
530
- }),
531
- value: query.plugins?.i18n?.locale || locales.find((locale) => locale.isDefault)?.code,
532
- onChange: handleChange,
533
- children: displayedLocales.map((locale) => /* @__PURE__ */ jsx(SingleSelectOption, { value: locale.code, children: locale.name }, locale.id))
534
- }
535
- );
536
- };
537
- const PERMISSIONS = {
538
- accessMain: [{ action: "plugin::i18n.locale.read", subject: null }],
539
- create: [{ action: "plugin::i18n.locale.create", subject: null }],
540
- delete: [{ action: "plugin::i18n.locale.delete", subject: null }],
541
- update: [{ action: "plugin::i18n.locale.update", subject: null }],
542
- read: [{ action: "plugin::i18n.locale.read", subject: null }]
543
- };
544
- const mutateEditViewHook = ({ layout }) => {
545
- if ("i18n" in layout.options && typeof layout.options.i18n === "object" && layout.options.i18n !== null && "localized" in layout.options.i18n && !layout.options.i18n.localized) {
546
- return { layout };
547
- }
548
- const components = Object.entries(layout.components).reduce(
549
- (acc, [key, componentLayout]) => {
550
- return {
551
- ...acc,
552
- [key]: {
553
- ...componentLayout,
554
- layout: componentLayout.layout.map((row) => row.map(addLabelActionToField))
555
- }
556
- };
557
- },
558
- {}
559
- );
560
- return {
561
- layout: {
562
- ...layout,
563
- components,
564
- layout: layout.layout.map((panel) => panel.map((row) => row.map(addLabelActionToField)))
565
- }
566
- };
567
- };
568
- const addLabelActionToField = (field) => {
569
- const isFieldLocalized = doesFieldHaveI18nPluginOpt(field.attribute.pluginOptions) ? field.attribute.pluginOptions.i18n.localized : true;
570
- const labelActionProps = {
571
- title: {
572
- id: isFieldLocalized ? getTranslation("Field.localized") : getTranslation("Field.not-localized"),
573
- defaultMessage: isFieldLocalized ? "This value is unique for the selected locale" : "This value is the same across all locales"
574
- },
575
- icon: isFieldLocalized ? /* @__PURE__ */ jsx(Earth, {}) : /* @__PURE__ */ jsx(EarthStriked, {})
576
- };
577
- return {
578
- ...field,
579
- labelAction: /* @__PURE__ */ jsx(LabelAction, { ...labelActionProps })
580
- };
581
- };
582
- const doesFieldHaveI18nPluginOpt = (pluginOpts) => {
583
- if (!pluginOpts) {
584
- return false;
585
- }
586
- return "i18n" in pluginOpts && typeof pluginOpts.i18n === "object" && pluginOpts.i18n !== null && "localized" in pluginOpts.i18n;
587
- };
588
- const LabelAction = ({ title, icon }) => {
589
- const { formatMessage } = useIntl();
590
- return /* @__PURE__ */ jsxs(Span, { as: "span", children: [
591
- /* @__PURE__ */ jsx(VisuallyHidden, { as: "span", children: `(${formatMessage(title)})` }),
592
- React.cloneElement(icon, {
593
- "aria-hidden": true,
594
- focusable: false
595
- // See: https://allyjs.io/tutorials/focusing-in-svg.html#making-svg-elements-focusable
596
- })
597
- ] });
598
- };
599
- const Span = styled(Flex)`
600
- svg {
601
- width: 12px;
602
- height: 12px;
603
-
604
- fill: ${({ theme }) => theme.colors.neutral500};
605
-
606
- path {
607
- fill: ${({ theme }) => theme.colors.neutral500};
608
- }
609
- }
610
- `;
611
- const LocaleListCell = ({
612
- documentId,
613
- locale: currentLocale,
614
- collectionType,
615
- model
616
- }) => {
617
- const { meta, isLoading } = unstable_useDocument({
618
- documentId,
619
- collectionType,
620
- model,
621
- params: {
622
- locale: currentLocale
623
- }
624
- });
625
- const { locale: language } = useIntl();
626
- const [visible, setVisible] = React.useState(false);
627
- const buttonRef = React.useRef(null);
628
- const { data: locales = [] } = useGetLocalesQuery();
629
- const handleTogglePopover = (e) => {
630
- e.stopPropagation();
631
- setVisible((prev) => !prev);
632
- };
633
- const formatter = useCollator(language, {
634
- sensitivity: "base"
635
- });
636
- if (!Array.isArray(locales) || isLoading) {
637
- return null;
638
- }
639
- const availableLocales = meta?.availableLocales.map((doc) => doc.locale) ?? [];
640
- const localesForDocument = locales.reduce((acc, locale) => {
641
- const createdLocale = [currentLocale, ...availableLocales].find((loc) => {
642
- return loc === locale.code;
643
- });
644
- if (createdLocale) {
645
- acc.push(locale);
646
- }
647
- return acc;
648
- }, []).map((locale) => {
649
- if (locale.isDefault) {
650
- return `${locale.name} (default)`;
651
- }
652
- return locale.name;
653
- }).toSorted((a, b) => formatter.compare(a, b));
654
- return /* @__PURE__ */ jsxs(Button, { type: "button", onClick: handleTogglePopover, ref: buttonRef, children: [
655
- /* @__PURE__ */ jsxs(
656
- ActionWrapper,
657
- {
658
- minWidth: "100%",
659
- alignItems: "center",
660
- justifyContent: "center",
661
- height: "3.2rem",
662
- width: "3.2rem",
663
- children: [
664
- /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", ellipsis: true, children: localesForDocument.join(", ") }),
665
- /* @__PURE__ */ jsx(Flex, { children: /* @__PURE__ */ jsx(CaretDown, {}) })
666
- ]
667
- }
668
- ),
669
- visible && /* @__PURE__ */ jsx(
670
- Popover,
671
- {
672
- onDismiss: () => setVisible(false),
673
- source: buttonRef,
674
- spacing: 16,
675
- centered: true,
676
- children: /* @__PURE__ */ jsx("ul", { children: localesForDocument.map((name) => /* @__PURE__ */ jsx(Box, { padding: 3, as: "li", children: /* @__PURE__ */ jsx(Typography, { children: name }) }, name)) })
677
- }
678
- )
679
- ] });
680
- };
681
- const Button = styled.button`
682
- width: 100%;
683
-
684
- svg {
685
- > g,
686
- path {
687
- fill: ${({ theme }) => theme.colors.neutral500};
688
- }
689
- }
690
- &:hover {
691
- svg {
692
- > g,
693
- path {
694
- fill: ${({ theme }) => theme.colors.neutral600};
695
- }
696
- }
697
- }
698
- &:active {
699
- svg {
700
- > g,
701
- path {
702
- fill: ${({ theme }) => theme.colors.neutral400};
703
- }
704
- }
705
- }
706
- `;
707
- const ActionWrapper = styled(Flex)`
708
- svg {
709
- height: 0.4rem;
710
- }
711
- `;
712
- const addColumnToTableHook = ({ displayedHeaders, layout }) => {
713
- const { options } = layout;
714
- const isFieldLocalized = doesPluginOptionsHaveI18nLocalized(options) ? options.i18n.localized : false;
715
- if (!isFieldLocalized) {
716
- return { displayedHeaders, layout };
717
- }
718
- return {
719
- displayedHeaders: [
720
- ...displayedHeaders,
721
- {
722
- attribute: { type: "string" },
723
- label: {
724
- id: getTranslation("list-view.table.header.label"),
725
- defaultMessage: "Available in"
726
- },
727
- searchable: false,
728
- sortable: false,
729
- name: "locales",
730
- // @ts-expect-error – ID is seen as number | string; this will change when we move the type over.
731
- cellFormatter: (props, _header, meta) => /* @__PURE__ */ jsx(LocaleListCell, { ...props, ...meta })
732
- }
733
- ],
734
- layout
735
- };
736
- };
737
- const addLocaleToReleasesHook = ({ displayedHeaders = [] }) => {
738
- return {
739
- displayedHeaders: [
740
- // TODO: Fix when migrating to v5
741
- // ...displayedHeaders,
742
- {
743
- key: "__locale__",
744
- fieldSchema: { type: "string" },
745
- metadatas: {
746
- label: {
747
- id: "content-releases.page.ReleaseDetails.table.header.label.locale",
748
- defaultMessage: "locale"
749
- },
750
- searchable: false,
751
- sortable: false
752
- },
753
- name: "locale"
754
- }
755
- ],
756
- hasI18nEnabled: true
757
- };
758
- };
759
- const extendCTBAttributeInitialDataMiddleware = () => {
760
- return ({ getState }) => (next) => (action) => {
761
- const enhanceAction = () => {
762
- try {
763
- const store = getState();
764
- const hasi18nEnabled = get(
765
- store,
766
- [
767
- "content-type-builder_dataManagerProvider",
768
- "modifiedData",
769
- "contentType",
770
- "schema",
771
- "pluginOptions",
772
- "i18n",
773
- "localized"
774
- ],
775
- false
776
- );
777
- if (hasi18nEnabled) {
778
- const pluginOptions = action.options ? { ...action.options.pluginOptions, i18n: { localized: true } } : { i18n: { localized: true } };
779
- return next({
780
- ...action,
781
- options: {
782
- pluginOptions
783
- }
784
- });
785
- }
786
- return next(action);
787
- } catch (err) {
788
- return next(action);
789
- }
790
- };
791
- if (action.type === "ContentTypeBuilder/FormModal/SET_ATTRIBUTE_DATA_SCHEMA" && action.forTarget === "contentType" && !["relation", "component"].includes(action.attributeType) && !action.isEditing) {
792
- return enhanceAction();
793
- }
794
- if (action.type === "ContentTypeBuilder/FormModal/SET_CUSTOM_FIELD_DATA_SCHEMA" && action.forTarget === "contentType" && !action.isEditing) {
795
- return enhanceAction();
796
- }
797
- if ((action.type === "ContentTypeBuilder/FormModal/RESET_PROPS_AND_SET_FORM_FOR_ADDING_AN_EXISTING_COMPO" || action.type === "ContentTypeBuilder/FormModal/RESET_PROPS_AND_SAVE_CURRENT_DATA") && action.forTarget === "contentType") {
798
- return enhanceAction();
799
- }
800
- return next(action);
801
- };
802
- };
803
- const extendCTBInitialDataMiddleware = () => {
804
- return () => (next) => (action) => {
805
- if (action.type === "ContentTypeBuilder/FormModal/SET_DATA_TO_EDIT" && action.modalType === "contentType") {
806
- const i18n = { localized: false };
807
- const pluginOptions = action.data.pluginOptions ? { ...action.data.pluginOptions, i18n } : { i18n };
808
- const data = { ...action.data, pluginOptions };
809
- if (action.actionType === "create") {
810
- return next({ ...action, data });
811
- }
812
- if (!action.data.pluginOptions?.i18n?.localized) {
813
- return next({ ...action, data });
814
- }
815
- }
816
- return next(action);
817
- };
818
- };
819
- const localeMiddleware = (ctx) => (next) => (permissions) => {
820
- const match = matchPath("/content-manager/:collectionType/:model?/:id", ctx.pathname);
821
- if (!match) {
822
- return next(permissions);
823
- }
824
- const search = qs.parse(ctx.search);
825
- if (typeof search !== "object") {
826
- return next(permissions);
827
- }
828
- if (!("plugins" in search && typeof search.plugins === "object")) {
829
- return next(permissions);
830
- }
831
- if (!("i18n" in search.plugins && typeof search.plugins.i18n === "object" && !Array.isArray(search.plugins.i18n))) {
832
- return next(permissions);
833
- }
834
- const { locale } = search.plugins.i18n;
835
- if (typeof locale !== "string") {
836
- return next(permissions);
837
- }
838
- const revisedPermissions = permissions.filter(
839
- (permission) => !permission.properties?.locales || permission.properties.locales.includes(locale)
840
- );
841
- return next(revisedPermissions);
842
- };
843
- const prefixPluginTranslations = (trad, pluginId2) => {
844
- if (!pluginId2) {
845
- throw new TypeError("pluginId can't be empty");
846
- }
847
- return Object.keys(trad).reduce((acc, current) => {
848
- acc[`${pluginId2}.${current}`] = trad[current];
849
- return acc;
850
- }, {});
851
- };
852
- const mutateCTBContentTypeSchema = (nextSchema, prevSchema) => {
853
- if (!doesPluginOptionsHaveI18nLocalized(nextSchema.pluginOptions)) {
854
- return nextSchema;
855
- }
856
- const isNextSchemaLocalized = nextSchema.pluginOptions.i18n.localized;
857
- const isPrevSchemaLocalized = doesPluginOptionsHaveI18nLocalized(
858
- prevSchema?.schema?.pluginOptions
859
- ) ? prevSchema?.schema?.pluginOptions.i18n.localized : false;
860
- if (isNextSchemaLocalized && isPrevSchemaLocalized) {
861
- return nextSchema;
862
- }
863
- if (isNextSchemaLocalized) {
864
- const attributes = addLocalisationToFields(nextSchema.attributes);
865
- return { ...nextSchema, attributes };
866
- }
867
- if (!isNextSchemaLocalized) {
868
- const pluginOptions = omit(nextSchema.pluginOptions, "i18n");
869
- const attributes = disableAttributesLocalisation(nextSchema.attributes);
870
- return { ...nextSchema, pluginOptions, attributes };
871
- }
872
- return nextSchema;
873
- };
874
- const addLocalisationToFields = (attributes) => Object.keys(attributes).reduce((acc, current) => {
875
- const currentAttribute = attributes[current];
876
- if (LOCALIZED_FIELDS.includes(currentAttribute.type)) {
877
- const i18n = { localized: true };
878
- const pluginOptions = currentAttribute.pluginOptions ? { ...currentAttribute.pluginOptions, i18n } : { i18n };
879
- acc[current] = { ...currentAttribute, pluginOptions };
880
- return acc;
881
- }
882
- acc[current] = currentAttribute;
883
- return acc;
884
- }, {});
885
- const disableAttributesLocalisation = (attributes) => Object.keys(attributes).reduce((acc, current) => {
886
- acc[current] = omit(attributes[current], "pluginOptions.i18n");
887
- return acc;
888
- }, {});
889
- const index = {
890
- register(app) {
891
- app.addMiddlewares([extendCTBAttributeInitialDataMiddleware, extendCTBInitialDataMiddleware]);
892
- app.addMiddlewares([() => i18nApi.middleware]);
893
- app.addReducers({
894
- [i18nApi.reducerPath]: i18nApi.reducer
895
- });
896
- app.addRBACMiddleware([localeMiddleware]);
897
- app.registerPlugin({
898
- id: pluginId,
899
- initializer: Initializer,
900
- isReady: false,
901
- name: pluginId
902
- });
903
- },
904
- bootstrap(app) {
905
- app.registerHook("Admin/CM/pages/ListView/inject-column-in-table", addColumnToTableHook);
906
- app.registerHook("Admin/CM/pages/EditView/mutate-edit-view-layout", mutateEditViewHook);
907
- app.registerHook(
908
- "ContentReleases/pages/ReleaseDetails/add-locale-in-releases",
909
- addLocaleToReleasesHook
910
- );
911
- app.addSettingsLink("global", {
912
- intlLabel: {
913
- id: getTranslation("plugin.name"),
914
- defaultMessage: "Internationalization"
915
- },
916
- id: "internationalization",
917
- to: "internationalization",
918
- Component: () => import("./SettingsPage-CeqfDjsb.mjs").then((mod) => ({ default: mod.ProtectedSettingsPage })),
919
- permissions: PERMISSIONS.accessMain
920
- });
921
- const contentManager = app.getPlugin("content-manager");
922
- contentManager.apis.addDocumentHeaderAction([LocalePickerAction]);
923
- contentManager.apis.addDocumentAction((actions) => {
924
- const indexOfDeleteAction = actions.findIndex((action) => action.type === "delete");
925
- actions.splice(indexOfDeleteAction, 0, DeleteLocaleAction);
926
- return actions;
927
- });
928
- contentManager.injectComponent("listView", "actions", {
929
- name: "i18n-locale-filter",
930
- Component: LocalePicker
931
- });
932
- contentManager.injectComponent("listView", "publishModalAdditionalInfos", {
933
- name: "i18n-publish-bullets-in-modal",
934
- Component: PublishModalAdditionalInfo
935
- });
936
- contentManager.injectComponent("listView", "unpublishModalAdditionalInfos", {
937
- name: "i18n-unpublish-bullets-in-modal",
938
- Component: UnpublishModalAdditionalInfo
939
- });
940
- contentManager.injectComponent("listView", "deleteModalAdditionalInfos", {
941
- name: "i18n-delete-bullets-in-modal",
942
- Component: DeleteModalAdditionalInfo
943
- });
944
- const ctbPlugin = app.getPlugin("content-type-builder");
945
- if (ctbPlugin) {
946
- const ctbFormsAPI = ctbPlugin.apis.forms;
947
- ctbFormsAPI.addContentTypeSchemaMutation(mutateCTBContentTypeSchema);
948
- ctbFormsAPI.components.add({ id: "checkboxConfirmation", component: CheckboxConfirmation });
949
- ctbFormsAPI.extendContentType({
950
- validator: () => ({
951
- i18n: yup.object().shape({
952
- localized: yup.bool()
953
- })
954
- }),
955
- form: {
956
- advanced() {
957
- return [
958
- {
959
- name: "pluginOptions.i18n.localized",
960
- description: {
961
- id: getTranslation("plugin.schema.i18n.localized.description-content-type"),
962
- defaultMessage: "Allows translating an entry into different languages"
963
- },
964
- type: "checkboxConfirmation",
965
- intlLabel: {
966
- id: getTranslation("plugin.schema.i18n.localized.label-content-type"),
967
- defaultMessage: "Localization"
968
- }
969
- }
970
- ];
971
- }
972
- }
973
- });
974
- ctbFormsAPI.extendFields(LOCALIZED_FIELDS, {
975
- validator: (args) => ({
976
- i18n: yup.object().shape({
977
- localized: yup.bool().test({
978
- name: "ensure-unique-localization",
979
- message: getTranslation("plugin.schema.i18n.ensure-unique-localization"),
980
- test(value) {
981
- if (value === void 0 || value) {
982
- return true;
983
- }
984
- const unique = get(args, ["3", "modifiedData", "unique"], null);
985
- if (unique && !value) {
986
- return false;
987
- }
988
- return true;
989
- }
990
- })
991
- })
992
- }),
993
- form: {
994
- advanced({ contentTypeSchema, forTarget, type, step }) {
995
- if (forTarget !== "contentType") {
996
- return [];
997
- }
998
- const hasI18nEnabled = get(
999
- contentTypeSchema,
1000
- ["schema", "pluginOptions", "i18n", "localized"],
1001
- false
1002
- );
1003
- if (!hasI18nEnabled) {
1004
- return [];
1005
- }
1006
- if (type === "component" && step === "1") {
1007
- return [];
1008
- }
1009
- return [
1010
- {
1011
- name: "pluginOptions.i18n.localized",
1012
- description: {
1013
- id: getTranslation("plugin.schema.i18n.localized.description-field"),
1014
- defaultMessage: "The field can have different values in each locale"
1015
- },
1016
- type: "checkbox",
1017
- intlLabel: {
1018
- id: getTranslation("plugin.schema.i18n.localized.label-field"),
1019
- defaultMessage: "Enable localization for this field"
1020
- }
1021
- }
1022
- ];
1023
- }
1024
- }
1025
- });
1026
- }
1027
- },
1028
- async registerTrads({ locales }) {
1029
- const importedTrads = await Promise.all(
1030
- locales.map((locale) => {
1031
- return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("./de-9eCAqqrB.mjs"), "./translations/dk.json": () => import("./dk-2qBjxt-P.mjs"), "./translations/en.json": () => import("./en-CnrTsjWS.mjs"), "./translations/es.json": () => import("./es-DlmMVaBG.mjs"), "./translations/fr.json": () => import("./fr-3S6ke71d.mjs"), "./translations/ko.json": () => import("./ko-qTjQ8IMw.mjs"), "./translations/pl.json": () => import("./pl-B67TSHqT.mjs"), "./translations/ru.json": () => import("./ru-hagMa57T.mjs"), "./translations/tr.json": () => import("./tr-Dw_jmkG-.mjs"), "./translations/zh-Hans.json": () => import("./zh-Hans-Dyc-aR-h.mjs"), "./translations/zh.json": () => import("./zh-57YM4amO.mjs") }), `./translations/${locale}.json`).then(({ default: data }) => {
1032
- return {
1033
- data: prefixPluginTranslations(data, pluginId),
1034
- locale
1035
- };
1036
- }).catch(() => {
1037
- return {
1038
- data: {},
1039
- locale
1040
- };
1041
- });
1042
- })
1043
- );
1044
- return Promise.resolve(importedTrads);
1045
- }
1046
- };
1047
- export {
1048
- PERMISSIONS as P,
1049
- useGetDefaultLocalesQuery as a,
1050
- useGetLocalesQuery as b,
1051
- useDeleteLocaleMutation as c,
1052
- useUpdateLocaleMutation as d,
1053
- index as e,
1054
- getTranslation as g,
1055
- isBaseQueryError as i,
1056
- useCreateLocaleMutation as u
1057
- };
1058
- //# sourceMappingURL=index-BDU1w_fd.mjs.map