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