@strapi/i18n 0.0.0-next.929f36e7cd2888f97e66b5159baa15234a283fca → 0.0.0-next.92e60e369ae0e382a5d486de347f6d286ab22987

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 (203) hide show
  1. package/dist/admin/components/BulkLocaleActionModal.js +2 -2
  2. package/dist/admin/components/BulkLocaleActionModal.js.map +1 -1
  3. package/dist/admin/components/BulkLocaleActionModal.mjs +2 -2
  4. package/dist/admin/components/BulkLocaleActionModal.mjs.map +1 -1
  5. package/dist/admin/components/CMHeaderActions.js +294 -20
  6. package/dist/admin/components/CMHeaderActions.js.map +1 -1
  7. package/dist/admin/components/CMHeaderActions.mjs +298 -25
  8. package/dist/admin/components/CMHeaderActions.mjs.map +1 -1
  9. package/dist/admin/components/CreateLocale.js +8 -4
  10. package/dist/admin/components/CreateLocale.js.map +1 -1
  11. package/dist/admin/components/CreateLocale.mjs +9 -5
  12. package/dist/admin/components/CreateLocale.mjs.map +1 -1
  13. package/dist/admin/components/EditLocale.js +1 -1
  14. package/dist/admin/components/EditLocale.js.map +1 -1
  15. package/dist/admin/components/EditLocale.mjs +1 -1
  16. package/dist/admin/components/EditLocale.mjs.map +1 -1
  17. package/dist/admin/components/LocaleListCell.js +65 -45
  18. package/dist/admin/components/LocaleListCell.js.map +1 -1
  19. package/dist/admin/components/LocaleListCell.mjs +66 -46
  20. package/dist/admin/components/LocaleListCell.mjs.map +1 -1
  21. package/dist/admin/components/LocalePicker.js +18 -11
  22. package/dist/admin/components/LocalePicker.js.map +1 -1
  23. package/dist/admin/components/LocalePicker.mjs +19 -12
  24. package/dist/admin/components/LocalePicker.mjs.map +1 -1
  25. package/dist/admin/contentManagerHooks/editView.js +6 -3
  26. package/dist/admin/contentManagerHooks/editView.js.map +1 -1
  27. package/dist/admin/contentManagerHooks/editView.mjs +7 -4
  28. package/dist/admin/contentManagerHooks/editView.mjs.map +1 -1
  29. package/dist/admin/contentManagerHooks/listView.js +2 -1
  30. package/dist/admin/contentManagerHooks/listView.js.map +1 -1
  31. package/dist/admin/contentManagerHooks/listView.mjs +2 -1
  32. package/dist/admin/contentManagerHooks/listView.mjs.map +1 -1
  33. package/dist/admin/hooks/useAILocalizationJobsPolling.js +110 -0
  34. package/dist/admin/hooks/useAILocalizationJobsPolling.js.map +1 -0
  35. package/dist/admin/hooks/useAILocalizationJobsPolling.mjs +89 -0
  36. package/dist/admin/hooks/useAILocalizationJobsPolling.mjs.map +1 -0
  37. package/dist/admin/hooks/useI18n.js +4 -4
  38. package/dist/admin/hooks/useI18n.js.map +1 -1
  39. package/dist/admin/hooks/useI18n.mjs +4 -4
  40. package/dist/admin/hooks/useI18n.mjs.map +1 -1
  41. package/dist/admin/index.js +1 -1
  42. package/dist/admin/index.js.map +1 -1
  43. package/dist/admin/index.mjs +2 -2
  44. package/dist/admin/index.mjs.map +1 -1
  45. package/dist/admin/middlewares/extendCTBAttributeInitialData.js +34 -24
  46. package/dist/admin/middlewares/extendCTBAttributeInitialData.js.map +1 -1
  47. package/dist/admin/middlewares/extendCTBAttributeInitialData.mjs +34 -24
  48. package/dist/admin/middlewares/extendCTBAttributeInitialData.mjs.map +1 -1
  49. package/dist/admin/pages/SettingsPage.js +121 -46
  50. package/dist/admin/pages/SettingsPage.js.map +1 -1
  51. package/dist/admin/pages/SettingsPage.mjs +124 -30
  52. package/dist/admin/pages/SettingsPage.mjs.map +1 -1
  53. package/dist/admin/services/aiLocalizationJobs.js +26 -0
  54. package/dist/admin/services/aiLocalizationJobs.js.map +1 -0
  55. package/dist/admin/services/aiLocalizationJobs.mjs +24 -0
  56. package/dist/admin/services/aiLocalizationJobs.mjs.map +1 -0
  57. package/dist/admin/services/api.js +4 -1
  58. package/dist/admin/services/api.js.map +1 -1
  59. package/dist/admin/services/api.mjs +4 -1
  60. package/dist/admin/services/api.mjs.map +1 -1
  61. package/dist/admin/services/locales.js +4 -2
  62. package/dist/admin/services/locales.js.map +1 -1
  63. package/dist/admin/services/locales.mjs +4 -2
  64. package/dist/admin/services/locales.mjs.map +1 -1
  65. package/dist/admin/services/settings.js +30 -0
  66. package/dist/admin/services/settings.js.map +1 -0
  67. package/dist/admin/services/settings.mjs +27 -0
  68. package/dist/admin/services/settings.mjs.map +1 -0
  69. package/dist/admin/src/components/CMHeaderActions.d.ts +17 -4
  70. package/dist/admin/src/components/LocaleListCell.d.ts +2 -1
  71. package/dist/admin/src/hooks/useAILocalizationJobsPolling.d.ts +9 -0
  72. package/dist/admin/src/services/aiLocalizationJobs.d.ts +6 -0
  73. package/dist/admin/src/services/api.d.ts +1 -1
  74. package/dist/admin/src/services/locales.d.ts +1 -1
  75. package/dist/admin/src/services/relations.d.ts +1 -1
  76. package/dist/admin/src/services/settings.d.ts +5 -0
  77. package/dist/admin/src/utils/schemas.d.ts +642 -16
  78. package/dist/admin/translations/en.json.js +10 -0
  79. package/dist/admin/translations/en.json.js.map +1 -1
  80. package/dist/admin/translations/en.json.mjs +10 -0
  81. package/dist/admin/translations/en.json.mjs.map +1 -1
  82. package/dist/admin/utils/clean.js +2 -2
  83. package/dist/admin/utils/clean.js.map +1 -1
  84. package/dist/admin/utils/clean.mjs +2 -2
  85. package/dist/admin/utils/clean.mjs.map +1 -1
  86. package/dist/admin/utils/fields.js +6 -1
  87. package/dist/admin/utils/fields.js.map +1 -1
  88. package/dist/admin/utils/fields.mjs +6 -1
  89. package/dist/admin/utils/fields.mjs.map +1 -1
  90. package/dist/admin/utils/getTranslation.js.map +1 -1
  91. package/dist/admin/utils/getTranslation.mjs.map +1 -1
  92. package/dist/admin/utils/prefixPluginTranslations.js.map +1 -1
  93. package/dist/admin/utils/prefixPluginTranslations.mjs.map +1 -1
  94. package/dist/admin/utils/schemas.js +19 -13
  95. package/dist/admin/utils/schemas.js.map +1 -1
  96. package/dist/admin/utils/schemas.mjs +19 -13
  97. package/dist/admin/utils/schemas.mjs.map +1 -1
  98. package/dist/server/bootstrap.js +24 -8
  99. package/dist/server/bootstrap.js.map +1 -1
  100. package/dist/server/bootstrap.mjs +24 -8
  101. package/dist/server/bootstrap.mjs.map +1 -1
  102. package/dist/server/constants/iso-locales.json.js +4 -0
  103. package/dist/server/constants/iso-locales.json.js.map +1 -1
  104. package/dist/server/constants/iso-locales.json.mjs +4 -0
  105. package/dist/server/constants/iso-locales.json.mjs.map +1 -1
  106. package/dist/server/controllers/ai-localization-jobs.js +47 -0
  107. package/dist/server/controllers/ai-localization-jobs.js.map +1 -0
  108. package/dist/server/controllers/ai-localization-jobs.mjs +45 -0
  109. package/dist/server/controllers/ai-localization-jobs.mjs.map +1 -0
  110. package/dist/server/controllers/index.js +5 -1
  111. package/dist/server/controllers/index.js.map +1 -1
  112. package/dist/server/controllers/index.mjs +5 -1
  113. package/dist/server/controllers/index.mjs.map +1 -1
  114. package/dist/server/controllers/settings.js +24 -0
  115. package/dist/server/controllers/settings.js.map +1 -0
  116. package/dist/server/controllers/settings.mjs +22 -0
  117. package/dist/server/controllers/settings.mjs.map +1 -0
  118. package/dist/server/models/ai-localization-job.js +60 -0
  119. package/dist/server/models/ai-localization-job.js.map +1 -0
  120. package/dist/server/models/ai-localization-job.mjs +57 -0
  121. package/dist/server/models/ai-localization-job.mjs.map +1 -0
  122. package/dist/server/register.js +3 -1
  123. package/dist/server/register.js.map +1 -1
  124. package/dist/server/register.mjs +3 -1
  125. package/dist/server/register.mjs.map +1 -1
  126. package/dist/server/routes/admin.js +40 -0
  127. package/dist/server/routes/admin.js.map +1 -1
  128. package/dist/server/routes/admin.mjs +40 -0
  129. package/dist/server/routes/admin.mjs.map +1 -1
  130. package/dist/server/routes/content-api.js +11 -7
  131. package/dist/server/routes/content-api.js.map +1 -1
  132. package/dist/server/routes/content-api.mjs +11 -7
  133. package/dist/server/routes/content-api.mjs.map +1 -1
  134. package/dist/server/routes/index.mjs +2 -2
  135. package/dist/server/routes/validation/locale.js +57 -0
  136. package/dist/server/routes/validation/locale.js.map +1 -0
  137. package/dist/server/routes/validation/locale.mjs +36 -0
  138. package/dist/server/routes/validation/locale.mjs.map +1 -0
  139. package/dist/server/services/ai-localization-jobs.js +64 -0
  140. package/dist/server/services/ai-localization-jobs.js.map +1 -0
  141. package/dist/server/services/ai-localization-jobs.mjs +62 -0
  142. package/dist/server/services/ai-localization-jobs.mjs.map +1 -0
  143. package/dist/server/services/ai-localizations.js +268 -0
  144. package/dist/server/services/ai-localizations.js.map +1 -0
  145. package/dist/server/services/ai-localizations.mjs +266 -0
  146. package/dist/server/services/ai-localizations.mjs.map +1 -0
  147. package/dist/server/services/content-types.js.map +1 -1
  148. package/dist/server/services/content-types.mjs.map +1 -1
  149. package/dist/server/services/index.js +7 -1
  150. package/dist/server/services/index.js.map +1 -1
  151. package/dist/server/services/index.mjs +7 -1
  152. package/dist/server/services/index.mjs.map +1 -1
  153. package/dist/server/services/settings.js +25 -0
  154. package/dist/server/services/settings.js.map +1 -0
  155. package/dist/server/services/settings.mjs +23 -0
  156. package/dist/server/services/settings.mjs.map +1 -0
  157. package/dist/server/src/bootstrap.d.ts.map +1 -1
  158. package/dist/server/src/controllers/ai-localization-jobs.d.ts +17 -0
  159. package/dist/server/src/controllers/ai-localization-jobs.d.ts.map +1 -0
  160. package/dist/server/src/controllers/index.d.ts +10 -0
  161. package/dist/server/src/controllers/index.d.ts.map +1 -1
  162. package/dist/server/src/controllers/settings.d.ts +7 -0
  163. package/dist/server/src/controllers/settings.d.ts.map +1 -0
  164. package/dist/server/src/index.d.ts +47 -8
  165. package/dist/server/src/index.d.ts.map +1 -1
  166. package/dist/server/src/models/ai-localization-job.d.ts +5 -0
  167. package/dist/server/src/models/ai-localization-job.d.ts.map +1 -0
  168. package/dist/server/src/models/index.d.ts +5 -0
  169. package/dist/server/src/models/index.d.ts.map +1 -0
  170. package/dist/server/src/register.d.ts +1 -1
  171. package/dist/server/src/register.d.ts.map +1 -1
  172. package/dist/server/src/routes/admin.d.ts.map +1 -1
  173. package/dist/server/src/routes/content-api.d.ts +5 -8
  174. package/dist/server/src/routes/content-api.d.ts.map +1 -1
  175. package/dist/server/src/routes/index.d.ts +3 -7
  176. package/dist/server/src/routes/index.d.ts.map +1 -1
  177. package/dist/server/src/routes/validation/index.d.ts +2 -0
  178. package/dist/server/src/routes/validation/index.d.ts.map +1 -0
  179. package/dist/server/src/routes/validation/locale.d.ts +41 -0
  180. package/dist/server/src/routes/validation/locale.d.ts.map +1 -0
  181. package/dist/server/src/services/ai-localization-jobs.d.ts +26 -0
  182. package/dist/server/src/services/ai-localization-jobs.d.ts.map +1 -0
  183. package/dist/server/src/services/ai-localizations.d.ts +18 -0
  184. package/dist/server/src/services/ai-localizations.d.ts.map +1 -0
  185. package/dist/server/src/services/index.d.ts +33 -0
  186. package/dist/server/src/services/index.d.ts.map +1 -1
  187. package/dist/server/src/services/settings.d.ts +13 -0
  188. package/dist/server/src/services/settings.d.ts.map +1 -0
  189. package/dist/server/src/utils/index.d.ts +7 -1
  190. package/dist/server/src/utils/index.d.ts.map +1 -1
  191. package/dist/server/src/validation/settings.d.ts +12 -0
  192. package/dist/server/src/validation/settings.d.ts.map +1 -0
  193. package/dist/server/utils/index.js.map +1 -1
  194. package/dist/server/utils/index.mjs.map +1 -1
  195. package/dist/server/validation/settings.js +11 -0
  196. package/dist/server/validation/settings.js.map +1 -0
  197. package/dist/server/validation/settings.mjs +9 -0
  198. package/dist/server/validation/settings.mjs.map +1 -0
  199. package/dist/shared/contracts/ai-localization-jobs.d.ts +27 -0
  200. package/dist/shared/contracts/ai-localization-jobs.d.ts.map +1 -0
  201. package/dist/shared/contracts/settings.d.ts +40 -0
  202. package/dist/shared/contracts/shared.d.ts.map +1 -0
  203. package/package.json +13 -10
@@ -1 +1 @@
1
- {"version":3,"file":"CreateLocale.mjs","sources":["../../../admin/src/components/CreateLocale.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n Form,\n type InputProps,\n InputRenderer,\n useField,\n type FormHelpers,\n useForm,\n useAPIErrorHandler,\n useNotification,\n useAuth,\n} from '@strapi/admin/strapi-admin';\nimport {\n Box,\n Button,\n ButtonProps,\n Divider,\n Field,\n Flex,\n Grid,\n Modal,\n SingleSelect,\n SingleSelectOption,\n Tabs,\n Typography,\n useId,\n} from '@strapi/design-system';\nimport { Check, Plus } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\nimport * as yup from 'yup';\n\nimport { CreateLocale } from '../../../shared/contracts/locales';\nimport { useCreateLocaleMutation, useGetDefaultLocalesQuery } from '../services/locales';\nimport { isBaseQueryError } from '../utils/baseQuery';\nimport { getTranslation } from '../utils/getTranslation';\n\n/* -------------------------------------------------------------------------------------------------\n * CreateLocale\n * -----------------------------------------------------------------------------------------------*/\n\ninterface CreateLocaleProps extends Pick<ButtonProps, 'disabled' | 'variant'> {}\n\nconst CreateLocale = ({ disabled, variant = 'default' }: CreateLocaleProps) => {\n const { formatMessage } = useIntl();\n const [visible, setVisible] = React.useState(false);\n\n return (\n <Modal.Root open={visible} onOpenChange={setVisible}>\n <Modal.Trigger>\n <Button\n variant={variant}\n disabled={disabled}\n startIcon={<Plus />}\n onClick={() => setVisible(true)}\n size=\"S\"\n >\n {formatMessage({\n id: getTranslation('Settings.list.actions.add'),\n defaultMessage: 'Add new locale',\n })}\n </Button>\n </Modal.Trigger>\n <CreateModal onClose={() => setVisible(false)} />\n </Modal.Root>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * CreateModal\n * -----------------------------------------------------------------------------------------------*/\n\nconst LOCALE_SCHEMA = yup.object().shape({\n code: yup.string().nullable().required({\n id: 'Settings.locales.modal.create.code.error',\n defaultMessage: 'Please select a locale',\n }),\n name: yup\n .string()\n .nullable()\n .max(50, {\n id: 'Settings.locales.modal.create.name.error.min',\n defaultMessage: 'The locale display name can only be less than 50 characters.',\n })\n .required({\n id: 'Settings.locales.modal.create.name.error.required',\n defaultMessage: 'Please give the locale a display name',\n }),\n isDefault: yup.boolean(),\n});\n\ntype FormValues = CreateLocale.Request['body'];\n\nconst initialFormValues = {\n code: '',\n name: '',\n isDefault: false,\n} satisfies FormValues;\n\ntype ModalCreateProps = {\n onClose: () => void;\n};\n\nconst CreateModal = ({ onClose }: ModalCreateProps) => {\n const titleId = useId();\n const { toggleNotification } = useNotification();\n const {\n _unstableFormatAPIError: formatAPIError,\n _unstableFormatValidationErrors: formatValidationErrors,\n } = useAPIErrorHandler();\n const [createLocale] = useCreateLocaleMutation();\n const { formatMessage } = useIntl();\n const refetchPermissions = useAuth('CreateModal', (state) => state.refetchPermissions);\n\n const handleSubmit = async (values: FormValues, helpers: FormHelpers<FormValues>) => {\n try {\n const res = await createLocale(values);\n\n if ('error' in res) {\n if (isBaseQueryError(res.error) && res.error.name === 'ValidationError') {\n helpers.setErrors(formatValidationErrors(res.error));\n } else {\n toggleNotification({ type: 'danger', message: formatAPIError(res.error) });\n }\n\n return;\n }\n\n toggleNotification({\n type: 'success',\n message: formatMessage({\n id: getTranslation('Settings.locales.modal.create.success'),\n defaultMessage: 'Created locale',\n }),\n });\n\n refetchPermissions();\n onClose();\n } catch (err) {\n toggleNotification({\n type: 'danger',\n message: formatMessage({\n id: 'notification.error',\n defaultMessage: 'An error occurred, please try again',\n }),\n });\n }\n };\n\n return (\n <Modal.Content>\n <Form\n method=\"POST\"\n initialValues={initialFormValues}\n validationSchema={LOCALE_SCHEMA}\n onSubmit={handleSubmit}\n >\n <Modal.Header>\n <Modal.Title>\n {formatMessage({\n id: getTranslation('Settings.list.actions.add'),\n defaultMessage: 'Add new locale',\n })}\n </Modal.Title>\n </Modal.Header>\n <Modal.Body>\n <Tabs.Root variant=\"simple\" defaultValue=\"basic\">\n <Flex justifyContent=\"space-between\">\n <Typography tag=\"h2\" variant=\"beta\" id={titleId}>\n {formatMessage({\n id: getTranslation('Settings.locales.modal.title'),\n defaultMessage: 'Configuration',\n })}\n </Typography>\n <Tabs.List aria-labelledby={titleId}>\n <Tabs.Trigger value=\"basic\">\n {formatMessage({\n id: getTranslation('Settings.locales.modal.base'),\n defaultMessage: 'Basic settings',\n })}\n </Tabs.Trigger>\n <Tabs.Trigger value=\"advanced\">\n {formatMessage({\n id: getTranslation('Settings.locales.modal.advanced'),\n defaultMessage: 'Advanced settings',\n })}\n </Tabs.Trigger>\n </Tabs.List>\n </Flex>\n\n <Divider />\n\n <Box paddingTop={7} paddingBottom={7}>\n <Tabs.Content value=\"basic\">\n <BaseForm />\n </Tabs.Content>\n <Tabs.Content value=\"advanced\">\n <AdvancedForm />\n </Tabs.Content>\n </Box>\n </Tabs.Root>\n </Modal.Body>\n <Modal.Footer>\n <Modal.Close>\n <Button variant=\"tertiary\">\n {formatMessage({ id: 'app.components.Button.cancel', defaultMessage: 'Cancel' })}\n </Button>\n </Modal.Close>\n <SubmitButton />\n </Modal.Footer>\n </Form>\n </Modal.Content>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * SubmitButton\n * -----------------------------------------------------------------------------------------------*/\n\nconst SubmitButton = () => {\n const { formatMessage } = useIntl();\n const isSubmitting = useForm('SubmitButton', (state) => state.isSubmitting);\n const modified = useForm('SubmitButton', (state) => state.modified);\n\n return (\n <Button type=\"submit\" startIcon={<Check />} disabled={isSubmitting || !modified}>\n {formatMessage({ id: 'global.save', defaultMessage: 'Save' })}\n </Button>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * BaseForm\n * -----------------------------------------------------------------------------------------------*/\n\ninterface BaseFormProps {\n mode?: 'create' | 'edit';\n}\n\nconst BaseForm = ({ mode = 'create' }: BaseFormProps) => {\n const { formatMessage } = useIntl();\n const { toggleNotification } = useNotification();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();\n\n const { data: defaultLocales, error } = useGetDefaultLocalesQuery();\n\n React.useEffect(() => {\n if (error) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(error),\n });\n }\n }, [error, formatAPIError, toggleNotification]);\n\n if (!Array.isArray(defaultLocales)) {\n return null;\n }\n\n const options = defaultLocales.map((locale) => ({\n label: locale.name,\n value: locale.code,\n }));\n\n const translatedForm = [\n {\n disabled: mode !== 'create',\n label: {\n id: getTranslation('Settings.locales.modal.create.code.label'),\n defaultMessage: 'Locales',\n },\n name: 'code',\n options,\n placeholder: {\n id: 'components.placeholder.select',\n defaultMessage: 'Select',\n },\n required: true,\n size: 6,\n type: 'enumeration' as const,\n },\n {\n hint: {\n id: getTranslation('Settings.locales.modal.create.name.label.description'),\n defaultMessage: 'Locale will be displayed under that name in the administration panel',\n },\n label: {\n id: getTranslation('Settings.locales.modal.create.name.label'),\n defaultMessage: 'Locale display name',\n },\n name: 'name',\n required: true,\n size: 6,\n type: 'string' as const,\n },\n ].map((field) => ({\n ...field,\n hint: field.hint ? formatMessage(field.hint) : undefined,\n label: formatMessage(field.label),\n placeholder: field.placeholder ? formatMessage(field.placeholder) : undefined,\n }));\n\n return (\n <Grid.Root gap={4}>\n {translatedForm.map(({ size, ...field }) => (\n <Grid.Item key={field.name} col={size} direction=\"column\" alignItems=\"stretch\">\n <FormRenderer {...field} />\n </Grid.Item>\n ))}\n </Grid.Root>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * AdvancedForm\n * -----------------------------------------------------------------------------------------------*/\n\ntype AdvancedFormProps = {\n isDefaultLocale?: boolean;\n};\n\nconst AdvancedForm = ({ isDefaultLocale }: AdvancedFormProps) => {\n const { formatMessage } = useIntl();\n\n const form = [\n {\n disabled: isDefaultLocale,\n hint: {\n id: getTranslation('Settings.locales.modal.advanced.setAsDefault.hint'),\n defaultMessage: 'One default locale is required, change it by selecting another one',\n },\n label: {\n id: getTranslation('Settings.locales.modal.advanced.setAsDefault'),\n defaultMessage: 'Set as default locale',\n },\n name: 'isDefault',\n size: 6,\n type: 'boolean' as const,\n },\n ].map((field) => ({\n ...field,\n hint: field.hint ? formatMessage(field.hint) : undefined,\n label: formatMessage(field.label),\n })) satisfies InputProps[];\n\n return (\n <Grid.Root gap={4}>\n {form.map(({ size, ...field }) => (\n <Grid.Item key={field.name} col={size} direction=\"column\" alignItems=\"stretch\">\n <FormRenderer {...field} />\n </Grid.Item>\n ))}\n </Grid.Root>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * FormRenderer\n * -----------------------------------------------------------------------------------------------*/\n\nconst FormRenderer = (field: InputProps) => {\n switch (field.type) {\n /**\n * This will override the default input renderer\n * choice for `enumeration`.\n */\n case 'enumeration':\n return <EnumerationInput {...field} />;\n default:\n return <InputRenderer {...field} />;\n }\n};\n\nconst EnumerationInput = ({\n disabled,\n hint,\n label,\n name,\n options,\n placeholder,\n required,\n}: Extract<InputProps, { type: 'enumeration' }>) => {\n const { value, error, onChange } = useField(name);\n const { data: defaultLocales = [] } = useGetDefaultLocalesQuery();\n\n const handleChange = (value: string) => {\n if (Array.isArray(defaultLocales)) {\n // We know it exists because the options are created from the list of default locales\n const locale = defaultLocales.find((locale) => locale.code === value)!;\n\n onChange(name, value);\n // This lets us automatically fill the name field with the locale name\n onChange('name', locale.name);\n } else {\n onChange(name, value);\n }\n };\n\n return (\n <Field.Root error={error} hint={hint} name={name} required={required}>\n <Field.Label>{label}</Field.Label>\n <SingleSelect\n disabled={disabled}\n // @ts-expect-error – This will dissapear when the DS removes support for numbers to be returned by SingleSelect.\n onChange={handleChange}\n placeholder={placeholder}\n value={value}\n >\n {options.map((option) => (\n <SingleSelectOption value={option.value} key={option.value}>\n {option.label}\n </SingleSelectOption>\n ))}\n </SingleSelect>\n <Field.Error />\n <Field.Hint />\n </Field.Root>\n );\n};\n\nexport { CreateLocale, BaseForm, AdvancedForm, SubmitButton, LOCALE_SCHEMA };\n"],"names":["CreateLocale","disabled","variant","formatMessage","useIntl","visible","setVisible","React","useState","_jsxs","Modal","Root","open","onOpenChange","_jsx","Trigger","Button","startIcon","Plus","onClick","size","id","getTranslation","defaultMessage","CreateModal","onClose","LOCALE_SCHEMA","yup","object","shape","code","string","nullable","required","name","max","isDefault","boolean","initialFormValues","titleId","useId","toggleNotification","useNotification","_unstableFormatAPIError","formatAPIError","_unstableFormatValidationErrors","formatValidationErrors","useAPIErrorHandler","createLocale","useCreateLocaleMutation","refetchPermissions","useAuth","state","handleSubmit","values","helpers","res","isBaseQueryError","error","setErrors","type","message","err","Content","Form","method","initialValues","validationSchema","onSubmit","Header","Title","Body","Tabs","defaultValue","Flex","justifyContent","Typography","tag","List","aria-labelledby","value","Divider","Box","paddingTop","paddingBottom","BaseForm","AdvancedForm","Footer","Close","SubmitButton","isSubmitting","useForm","modified","Check","mode","data","defaultLocales","useGetDefaultLocalesQuery","useEffect","Array","isArray","options","map","locale","label","translatedForm","placeholder","hint","field","undefined","Grid","gap","Item","col","direction","alignItems","FormRenderer","isDefaultLocale","form","EnumerationInput","InputRenderer","onChange","useField","handleChange","find","Field","Label","SingleSelect","option","SingleSelectOption","Error","Hint"],"mappings":";;;;;;;;;;;AA2CA,MAAMA,eAAe,CAAC,EAAEC,QAAQ,EAAEC,OAAAA,GAAU,SAAS,EAAqB,GAAA;IACxE,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;AAC1B,IAAA,MAAM,CAACC,OAASC,EAAAA,UAAAA,CAAW,GAAGC,KAAAA,CAAMC,QAAQ,CAAC,KAAA,CAAA;IAE7C,qBACEC,IAAA,CAACC,MAAMC,IAAI,EAAA;QAACC,IAAMP,EAAAA,OAAAA;QAASQ,YAAcP,EAAAA,UAAAA;;AACvC,0BAAAQ,GAAA,CAACJ,MAAMK,OAAO,EAAA;AACZ,gBAAA,QAAA,gBAAAD,GAACE,CAAAA,MAAAA,EAAAA;oBACCd,OAASA,EAAAA,OAAAA;oBACTD,QAAUA,EAAAA,QAAAA;AACVgB,oBAAAA,SAAAA,gBAAWH,GAACI,CAAAA,IAAAA,EAAAA,EAAAA,CAAAA;AACZC,oBAAAA,OAAAA,EAAS,IAAMb,UAAW,CAAA,IAAA,CAAA;oBAC1Bc,IAAK,EAAA,GAAA;8BAEJjB,aAAc,CAAA;AACbkB,wBAAAA,EAAAA,EAAIC,cAAe,CAAA,2BAAA,CAAA;wBACnBC,cAAgB,EAAA;AAClB,qBAAA;;;0BAGJ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,QAAAA;;gBAEVwH,QAAUE,EAAAA,YAAAA;gBACVjB,WAAaA,EAAAA,WAAAA;gBACb1B,KAAOA,EAAAA,KAAAA;AAENqB,gBAAAA,QAAAA,EAAAA,OAAAA,CAAQC,GAAG,CAAC,CAAC0B,MAAAA,iBACZlH,GAACmH,CAAAA,kBAAAA,EAAAA;AAAmBjD,wBAAAA,KAAAA,EAAOgD,OAAOhD,KAAK;AACpCgD,wBAAAA,QAAAA,EAAAA,MAAAA,CAAOxB;AADoCwB,qBAAAA,EAAAA,MAAAA,CAAOhD,KAAK,CAAA;;AAK9D,0BAAAlE,GAAA,CAAC+G,MAAMK,KAAK,EAAA,EAAA,CAAA;AACZ,0BAAApH,GAAA,CAAC+G,MAAMM,IAAI,EAAA,EAAA;;;AAGjB,CAAA;;;;"}
1
+ {"version":3,"file":"CreateLocale.mjs","sources":["../../../admin/src/components/CreateLocale.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n Form,\n type InputProps,\n InputRenderer,\n useField,\n type FormHelpers,\n useForm,\n useAPIErrorHandler,\n useNotification,\n useAuth,\n} from '@strapi/admin/strapi-admin';\nimport {\n Box,\n Button,\n ButtonProps,\n Combobox,\n ComboboxOption,\n Divider,\n Field,\n Flex,\n Grid,\n Modal,\n Tabs,\n Typography,\n useId,\n} from '@strapi/design-system';\nimport { Check, Plus } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\nimport * as yup from 'yup';\n\nimport { CreateLocale } from '../../../shared/contracts/locales';\nimport { useCreateLocaleMutation, useGetDefaultLocalesQuery } from '../services/locales';\nimport { isBaseQueryError } from '../utils/baseQuery';\nimport { getTranslation } from '../utils/getTranslation';\n\n/* -------------------------------------------------------------------------------------------------\n * CreateLocale\n * -----------------------------------------------------------------------------------------------*/\n\ninterface CreateLocaleProps extends Pick<ButtonProps, 'disabled' | 'variant'> {}\n\nconst CreateLocale = ({ disabled, variant = 'default' }: CreateLocaleProps) => {\n const { formatMessage } = useIntl();\n const [visible, setVisible] = React.useState(false);\n\n return (\n <Modal.Root open={visible} onOpenChange={setVisible}>\n <Modal.Trigger>\n <Button\n variant={variant}\n disabled={disabled}\n startIcon={<Plus />}\n onClick={() => setVisible(true)}\n size=\"S\"\n >\n {formatMessage({\n id: getTranslation('Settings.list.actions.add'),\n defaultMessage: 'Add new locale',\n })}\n </Button>\n </Modal.Trigger>\n <CreateModal onClose={() => setVisible(false)} />\n </Modal.Root>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * CreateModal\n * -----------------------------------------------------------------------------------------------*/\n\nconst LOCALE_SCHEMA = yup.object().shape({\n code: yup.string().nullable().required({\n id: 'Settings.locales.modal.create.code.error',\n defaultMessage: 'Please select a locale',\n }),\n name: yup\n .string()\n .nullable()\n .max(50, {\n id: 'Settings.locales.modal.create.name.error.min',\n defaultMessage: 'The locale display name can only be less than 50 characters.',\n })\n .required({\n id: 'Settings.locales.modal.create.name.error.required',\n defaultMessage: 'Please give the locale a display name',\n }),\n isDefault: yup.boolean(),\n});\n\ntype FormValues = CreateLocale.Request['body'];\n\nconst initialFormValues = {\n code: '',\n name: '',\n isDefault: false,\n} satisfies FormValues;\n\ntype ModalCreateProps = {\n onClose: () => void;\n};\n\nconst CreateModal = ({ onClose }: ModalCreateProps) => {\n const titleId = useId();\n const { toggleNotification } = useNotification();\n const {\n _unstableFormatAPIError: formatAPIError,\n _unstableFormatValidationErrors: formatValidationErrors,\n } = useAPIErrorHandler();\n const [createLocale] = useCreateLocaleMutation();\n const { formatMessage } = useIntl();\n const refetchPermissions = useAuth('CreateModal', (state) => state.refetchPermissions);\n\n const handleSubmit = async (values: FormValues, helpers: FormHelpers<FormValues>) => {\n try {\n const res = await createLocale(values);\n\n if ('error' in res) {\n if (isBaseQueryError(res.error) && res.error.name === 'ValidationError') {\n helpers.setErrors(formatValidationErrors(res.error));\n } else {\n toggleNotification({ type: 'danger', message: formatAPIError(res.error) });\n }\n\n return;\n }\n\n toggleNotification({\n type: 'success',\n message: formatMessage({\n id: getTranslation('Settings.locales.modal.create.success'),\n defaultMessage: 'Locale successfully added',\n }),\n });\n\n refetchPermissions();\n onClose();\n } catch (err) {\n toggleNotification({\n type: 'danger',\n message: formatMessage({\n id: 'notification.error',\n defaultMessage: 'An error occurred, please try again',\n }),\n });\n }\n };\n\n return (\n <Modal.Content>\n <Form\n method=\"POST\"\n initialValues={initialFormValues}\n validationSchema={LOCALE_SCHEMA}\n onSubmit={handleSubmit}\n >\n <Modal.Header>\n <Modal.Title>\n {formatMessage({\n id: getTranslation('Settings.list.actions.add'),\n defaultMessage: 'Add new locale',\n })}\n </Modal.Title>\n </Modal.Header>\n <Modal.Body>\n <Tabs.Root variant=\"simple\" defaultValue=\"basic\">\n <Flex justifyContent=\"space-between\">\n <Typography tag=\"h2\" variant=\"beta\" id={titleId}>\n {formatMessage({\n id: getTranslation('Settings.locales.modal.title'),\n defaultMessage: 'Configuration',\n })}\n </Typography>\n <Tabs.List aria-labelledby={titleId}>\n <Tabs.Trigger value=\"basic\">\n {formatMessage({\n id: getTranslation('Settings.locales.modal.base'),\n defaultMessage: 'Basic settings',\n })}\n </Tabs.Trigger>\n <Tabs.Trigger value=\"advanced\">\n {formatMessage({\n id: getTranslation('Settings.locales.modal.advanced'),\n defaultMessage: 'Advanced settings',\n })}\n </Tabs.Trigger>\n </Tabs.List>\n </Flex>\n\n <Divider />\n\n <Box paddingTop={7} paddingBottom={7}>\n <Tabs.Content value=\"basic\">\n <BaseForm />\n </Tabs.Content>\n <Tabs.Content value=\"advanced\">\n <AdvancedForm />\n </Tabs.Content>\n </Box>\n </Tabs.Root>\n </Modal.Body>\n <Modal.Footer>\n <Modal.Close>\n <Button variant=\"tertiary\">\n {formatMessage({ id: 'app.components.Button.cancel', defaultMessage: 'Cancel' })}\n </Button>\n </Modal.Close>\n <SubmitButton />\n </Modal.Footer>\n </Form>\n </Modal.Content>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * SubmitButton\n * -----------------------------------------------------------------------------------------------*/\n\nconst SubmitButton = () => {\n const { formatMessage } = useIntl();\n const isSubmitting = useForm('SubmitButton', (state) => state.isSubmitting);\n const modified = useForm('SubmitButton', (state) => state.modified);\n\n return (\n <Button type=\"submit\" startIcon={<Check />} disabled={isSubmitting || !modified}>\n {formatMessage({ id: 'global.save', defaultMessage: 'Save' })}\n </Button>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * BaseForm\n * -----------------------------------------------------------------------------------------------*/\n\ninterface BaseFormProps {\n mode?: 'create' | 'edit';\n}\n\nconst BaseForm = ({ mode = 'create' }: BaseFormProps) => {\n const { formatMessage } = useIntl();\n const { toggleNotification } = useNotification();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();\n\n const { data: defaultLocales, error } = useGetDefaultLocalesQuery();\n\n React.useEffect(() => {\n if (error) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(error),\n });\n }\n }, [error, formatAPIError, toggleNotification]);\n\n if (!Array.isArray(defaultLocales)) {\n return null;\n }\n\n const options = defaultLocales.map((locale) => ({\n label: locale.name,\n value: locale.code,\n }));\n\n const translatedForm = [\n {\n disabled: mode !== 'create',\n label: {\n id: getTranslation('Settings.locales.modal.create.code.label'),\n defaultMessage: 'Locales',\n },\n name: 'code',\n options,\n placeholder: {\n id: 'components.placeholder.select',\n defaultMessage: 'Select',\n },\n required: true,\n size: 6,\n type: 'enumeration' as const,\n },\n {\n hint: {\n id: getTranslation('Settings.locales.modal.create.name.label.description'),\n defaultMessage: 'Locale will be displayed under that name in the administration panel',\n },\n label: {\n id: getTranslation('Settings.locales.modal.create.name.label'),\n defaultMessage: 'Locale display name',\n },\n name: 'name',\n required: true,\n size: 6,\n type: 'string' as const,\n },\n ].map((field) => ({\n ...field,\n hint: field.hint ? formatMessage(field.hint) : undefined,\n label: formatMessage(field.label),\n placeholder: field.placeholder ? formatMessage(field.placeholder) : undefined,\n }));\n\n return (\n <Grid.Root gap={4}>\n {translatedForm.map(({ size, ...field }) => (\n <Grid.Item key={field.name} col={size} direction=\"column\" alignItems=\"stretch\">\n <FormRenderer {...field} />\n </Grid.Item>\n ))}\n </Grid.Root>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * AdvancedForm\n * -----------------------------------------------------------------------------------------------*/\n\ntype AdvancedFormProps = {\n isDefaultLocale?: boolean;\n};\n\nconst AdvancedForm = ({ isDefaultLocale }: AdvancedFormProps) => {\n const { formatMessage } = useIntl();\n\n const form = [\n {\n disabled: isDefaultLocale,\n hint: {\n id: getTranslation('Settings.locales.modal.advanced.setAsDefault.hint'),\n defaultMessage: 'One default locale is required, change it by selecting another one',\n },\n label: {\n id: getTranslation('Settings.locales.modal.advanced.setAsDefault'),\n defaultMessage: 'Set as default locale',\n },\n name: 'isDefault',\n size: 6,\n type: 'boolean' as const,\n },\n ].map((field) => ({\n ...field,\n hint: field.hint ? formatMessage(field.hint) : undefined,\n label: formatMessage(field.label),\n })) satisfies InputProps[];\n\n return (\n <Grid.Root gap={4}>\n {form.map(({ size, ...field }) => (\n <Grid.Item key={field.name} col={size} direction=\"column\" alignItems=\"stretch\">\n <FormRenderer {...field} />\n </Grid.Item>\n ))}\n </Grid.Root>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * FormRenderer\n * -----------------------------------------------------------------------------------------------*/\n\nconst FormRenderer = (field: InputProps) => {\n switch (field.type) {\n /**\n * This will override the default input renderer\n * choice for `enumeration`.\n */\n case 'enumeration':\n return <EnumerationInput {...field} />;\n default:\n return <InputRenderer {...field} />;\n }\n};\n\nconst EnumerationInput = ({\n disabled,\n hint,\n label,\n name,\n options,\n placeholder,\n required,\n}: Extract<InputProps, { type: 'enumeration' }>) => {\n const { value, error, onChange } = useField(name);\n const { data: defaultLocales = [] } = useGetDefaultLocalesQuery();\n\n const handleChange = (value: string) => {\n if (Array.isArray(defaultLocales)) {\n // We know it exists because the options are created from the list of default locales\n const locale = defaultLocales.find((locale) => locale.code === value)!;\n\n onChange(name, value);\n // This lets us automatically fill the name field with the locale name\n onChange('name', locale.name);\n } else {\n onChange(name, value);\n }\n };\n\n return (\n <Field.Root error={error} hint={hint} name={name} required={required}>\n <Field.Label>{label}</Field.Label>\n <Combobox\n disabled={disabled}\n onChange={handleChange}\n onClear={() => handleChange('')}\n placeholder={placeholder}\n value={value}\n autocomplete={{ type: 'list', filter: 'contains' }}\n >\n {options.map((option) => (\n <ComboboxOption value={option.value} key={option.value}>\n {option.label}\n </ComboboxOption>\n ))}\n </Combobox>\n <Field.Error />\n <Field.Hint />\n </Field.Root>\n );\n};\n\nexport { CreateLocale, BaseForm, AdvancedForm, SubmitButton, LOCALE_SCHEMA };\n"],"names":["CreateLocale","disabled","variant","formatMessage","useIntl","visible","setVisible","React","useState","_jsxs","Modal","Root","open","onOpenChange","_jsx","Trigger","Button","startIcon","Plus","onClick","size","id","getTranslation","defaultMessage","CreateModal","onClose","LOCALE_SCHEMA","yup","object","shape","code","string","nullable","required","name","max","isDefault","boolean","initialFormValues","titleId","useId","toggleNotification","useNotification","_unstableFormatAPIError","formatAPIError","_unstableFormatValidationErrors","formatValidationErrors","useAPIErrorHandler","createLocale","useCreateLocaleMutation","refetchPermissions","useAuth","state","handleSubmit","values","helpers","res","isBaseQueryError","error","setErrors","type","message","err","Content","Form","method","initialValues","validationSchema","onSubmit","Header","Title","Body","Tabs","defaultValue","Flex","justifyContent","Typography","tag","List","aria-labelledby","value","Divider","Box","paddingTop","paddingBottom","BaseForm","AdvancedForm","Footer","Close","SubmitButton","isSubmitting","useForm","modified","Check","mode","data","defaultLocales","useGetDefaultLocalesQuery","useEffect","Array","isArray","options","map","locale","label","translatedForm","placeholder","hint","field","undefined","Grid","gap","Item","col","direction","alignItems","FormRenderer","isDefaultLocale","form","EnumerationInput","InputRenderer","onChange","useField","handleChange","find","Field","Label","Combobox","onClear","autocomplete","filter","option","ComboboxOption","Error","Hint"],"mappings":";;;;;;;;;;;AA2CA,MAAMA,eAAe,CAAC,EAAEC,QAAQ,EAAEC,OAAAA,GAAU,SAAS,EAAqB,GAAA;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Q,KAAK,EAAA,EAAA,CAAA;AACZ,0BAAAvH,GAAA,CAAC+G,MAAMS,IAAI,EAAA,EAAA;;;AAGjB,CAAA;;;;"}
@@ -88,7 +88,7 @@ const EditLocale = (props)=>{
88
88
  type: 'success',
89
89
  message: formatMessage({
90
90
  id: getTranslation.getTranslation('Settings.locales.modal.edit.success'),
91
- defaultMessage: 'Updated locale'
91
+ defaultMessage: 'Locale successfully edited'
92
92
  })
93
93
  });
94
94
  refetchPermissions();
@@ -1 +1 @@
1
- {"version":3,"file":"EditLocale.js","sources":["../../../admin/src/components/EditLocale.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useNotification,\n useAPIErrorHandler,\n Form,\n FormHelpers,\n useAuth,\n} from '@strapi/admin/strapi-admin';\nimport {\n Box,\n Button,\n Divider,\n Flex,\n IconButton,\n Modal,\n Tabs,\n Typography,\n useId,\n} from '@strapi/design-system';\nimport { Pencil } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\n\nimport { Locale, UpdateLocale } from '../../../shared/contracts/locales';\nimport { useUpdateLocaleMutation } from '../services/locales';\nimport { isBaseQueryError } from '../utils/baseQuery';\nimport { getTranslation } from '../utils/getTranslation';\n\nimport { AdvancedForm, BaseForm, LOCALE_SCHEMA, SubmitButton } from './CreateLocale';\n\n/* -------------------------------------------------------------------------------------------------\n * EditLocale\n * -----------------------------------------------------------------------------------------------*/\n\ninterface EditLocaleProps extends Omit<EditModalProps, 'open' | 'onOpenChange'> {}\n\nconst EditLocale = (props: EditLocaleProps) => {\n const { formatMessage } = useIntl();\n const [visible, setVisible] = React.useState(false);\n\n return (\n <>\n <IconButton\n onClick={() => setVisible(true)}\n label={formatMessage(\n {\n id: getTranslation('Settings.list.actions.edit'),\n defaultMessage: 'Edit {name} locale',\n },\n {\n name: props.name,\n }\n )}\n variant=\"ghost\"\n >\n <Pencil />\n </IconButton>\n <EditModal {...props} open={visible} onOpenChange={setVisible} />\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * EditModal\n * -----------------------------------------------------------------------------------------------*/\n\ninterface EditModalProps extends Pick<Locale, 'id' | 'isDefault' | 'name' | 'code'> {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n}\n\ntype FormValues = UpdateLocale.Request['body'] & { code: string };\n\n/**\n * @internal\n * @description Exported to be used when someone clicks on a table row.\n */\nconst EditModal = ({ id, code, isDefault, name, open, onOpenChange }: EditModalProps) => {\n const { toggleNotification } = useNotification();\n const {\n _unstableFormatAPIError: formatAPIError,\n _unstableFormatValidationErrors: formatValidationErrors,\n } = useAPIErrorHandler();\n const refetchPermissions = useAuth('EditModal', (state) => state.refetchPermissions);\n const { formatMessage } = useIntl();\n const titleId = useId();\n\n const [updateLocale] = useUpdateLocaleMutation();\n const handleSubmit = async (\n { code: _code, ...data }: FormValues,\n helpers: FormHelpers<FormValues>\n ) => {\n try {\n /**\n * We don't need to send the code, because the\n * code can never be changed.\n */\n const res = await updateLocale({\n id,\n ...data,\n });\n\n if ('error' in res) {\n if (isBaseQueryError(res.error) && res.error.name === 'ValidationError') {\n helpers.setErrors(formatValidationErrors(res.error));\n } else {\n toggleNotification({ type: 'danger', message: formatAPIError(res.error) });\n }\n\n return;\n }\n\n toggleNotification({\n type: 'success',\n message: formatMessage({\n id: getTranslation('Settings.locales.modal.edit.success'),\n defaultMessage: 'Updated locale',\n }),\n });\n\n refetchPermissions();\n onOpenChange(false);\n } catch (err) {\n toggleNotification({\n type: 'danger',\n message: formatMessage({\n id: 'notification.error',\n defaultMessage: 'An error occurred, please try again',\n }),\n });\n }\n };\n\n return (\n <Modal.Root open={open} onOpenChange={onOpenChange}>\n <Modal.Content>\n <Form\n method=\"PUT\"\n onSubmit={handleSubmit}\n initialValues={{\n code,\n name,\n isDefault,\n }}\n validationSchema={LOCALE_SCHEMA}\n >\n <Modal.Header>\n <Modal.Title>\n {formatMessage(\n {\n id: getTranslation('Settings.list.actions.edit'),\n defaultMessage: 'Edit a locale',\n },\n {\n name,\n }\n )}\n </Modal.Title>\n </Modal.Header>\n <Modal.Body>\n <Tabs.Root variant=\"simple\" defaultValue=\"basic\">\n <Flex justifyContent=\"space-between\">\n <Typography tag=\"h2\" variant=\"beta\" id={titleId}>\n {formatMessage({\n id: getTranslation('Settings.locales.modal.title'),\n defaultMessage: 'Configuration',\n })}\n </Typography>\n <Tabs.List aria-labelledby={titleId}>\n <Tabs.Trigger value=\"basic\">\n {formatMessage({\n id: getTranslation('Settings.locales.modal.base'),\n defaultMessage: 'Basic settings',\n })}\n </Tabs.Trigger>\n <Tabs.Trigger value=\"advanced\">\n {formatMessage({\n id: getTranslation('Settings.locales.modal.advanced'),\n defaultMessage: 'Advanced settings',\n })}\n </Tabs.Trigger>\n </Tabs.List>\n </Flex>\n <Divider />\n <Box paddingTop={7} paddingBottom={7}>\n <Tabs.Content value=\"basic\">\n <BaseForm mode=\"edit\" />\n </Tabs.Content>\n <Tabs.Content value=\"advanced\">\n <AdvancedForm isDefaultLocale={isDefault} />\n </Tabs.Content>\n </Box>\n </Tabs.Root>\n </Modal.Body>\n <Modal.Footer>\n <Modal.Close>\n <Button variant=\"tertiary\">\n {formatMessage({ id: 'app.components.Button.cancel', defaultMessage: 'Cancel' })}\n </Button>\n </Modal.Close>\n <SubmitButton />\n </Modal.Footer>\n </Form>\n </Modal.Content>\n </Modal.Root>\n );\n};\n\nexport { EditLocale, EditModal };\n"],"names":["EditLocale","props","formatMessage","useIntl","visible","setVisible","React","useState","_jsxs","_Fragment","_jsx","IconButton","onClick","label","id","getTranslation","defaultMessage","name","variant","Pencil","EditModal","open","onOpenChange","code","isDefault","toggleNotification","useNotification","_unstableFormatAPIError","formatAPIError","_unstableFormatValidationErrors","formatValidationErrors","useAPIErrorHandler","refetchPermissions","useAuth","state","titleId","useId","updateLocale","useUpdateLocaleMutation","handleSubmit","_code","data","helpers","res","isBaseQueryError","error","setErrors","type","message","err","Modal","Root","Content","Form","method","onSubmit","initialValues","validationSchema","LOCALE_SCHEMA","Header","Title","Body","Tabs","defaultValue","Flex","justifyContent","Typography","tag","List","aria-labelledby","Trigger","value","Divider","Box","paddingTop","paddingBottom","BaseForm","mode","AdvancedForm","isDefaultLocale","Footer","Close","Button","SubmitButton"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAMA,aAAa,CAACC,KAAAA,GAAAA;IAClB,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;AAC1B,IAAA,MAAM,CAACC,OAASC,EAAAA,UAAAA,CAAW,GAAGC,gBAAAA,CAAMC,QAAQ,CAAC,KAAA,CAAA;IAE7C,qBACEC,eAAA,CAAAC,mBAAA,EAAA;;0BACEC,cAACC,CAAAA,uBAAAA,EAAAA;AACCC,gBAAAA,OAAAA,EAAS,IAAMP,UAAW,CAAA,IAAA,CAAA;AAC1BQ,gBAAAA,KAAAA,EAAOX,aACL,CAAA;AACEY,oBAAAA,EAAAA,EAAIC,6BAAe,CAAA,4BAAA,CAAA;oBACnBC,cAAgB,EAAA;iBAElB,EAAA;AACEC,oBAAAA,IAAAA,EAAMhB,MAAMgB;AACd,iBAAA,CAAA;gBAEFC,OAAQ,EAAA,OAAA;AAER,gBAAA,QAAA,gBAAAR,cAACS,CAAAA,YAAAA,EAAAA,EAAAA;;0BAEHT,cAACU,CAAAA,SAAAA,EAAAA;AAAW,gBAAA,GAAGnB,KAAK;gBAAEoB,IAAMjB,EAAAA,OAAAA;gBAASkB,YAAcjB,EAAAA;;;;AAGzD;AAaA;;;AAGC,IACKe,MAAAA,SAAAA,GAAY,CAAC,EAAEN,EAAE,EAAES,IAAI,EAAEC,SAAS,EAAEP,IAAI,EAAEI,IAAI,EAAEC,YAAY,EAAkB,GAAA;IAClF,MAAM,EAAEG,kBAAkB,EAAE,GAAGC,2BAAAA,EAAAA;AAC/B,IAAA,MAAM,EACJC,uBAAyBC,EAAAA,cAAc,EACvCC,+BAAiCC,EAAAA,sBAAsB,EACxD,GAAGC,8BAAAA,EAAAA;AACJ,IAAA,MAA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;"}
1
+ {"version":3,"file":"EditLocale.js","sources":["../../../admin/src/components/EditLocale.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useNotification,\n useAPIErrorHandler,\n Form,\n FormHelpers,\n useAuth,\n} from '@strapi/admin/strapi-admin';\nimport {\n Box,\n Button,\n Divider,\n Flex,\n IconButton,\n Modal,\n Tabs,\n Typography,\n useId,\n} from '@strapi/design-system';\nimport { Pencil } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\n\nimport { Locale, UpdateLocale } from '../../../shared/contracts/locales';\nimport { useUpdateLocaleMutation } from '../services/locales';\nimport { isBaseQueryError } from '../utils/baseQuery';\nimport { getTranslation } from '../utils/getTranslation';\n\nimport { AdvancedForm, BaseForm, LOCALE_SCHEMA, SubmitButton } from './CreateLocale';\n\n/* -------------------------------------------------------------------------------------------------\n * EditLocale\n * -----------------------------------------------------------------------------------------------*/\n\ninterface EditLocaleProps extends Omit<EditModalProps, 'open' | 'onOpenChange'> {}\n\nconst EditLocale = (props: EditLocaleProps) => {\n const { formatMessage } = useIntl();\n const [visible, setVisible] = React.useState(false);\n\n return (\n <>\n <IconButton\n onClick={() => setVisible(true)}\n label={formatMessage(\n {\n id: getTranslation('Settings.list.actions.edit'),\n defaultMessage: 'Edit {name} locale',\n },\n {\n name: props.name,\n }\n )}\n variant=\"ghost\"\n >\n <Pencil />\n </IconButton>\n <EditModal {...props} open={visible} onOpenChange={setVisible} />\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * EditModal\n * -----------------------------------------------------------------------------------------------*/\n\ninterface EditModalProps extends Pick<Locale, 'id' | 'isDefault' | 'name' | 'code'> {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n}\n\ntype FormValues = UpdateLocale.Request['body'] & { code: string };\n\n/**\n * @internal\n * @description Exported to be used when someone clicks on a table row.\n */\nconst EditModal = ({ id, code, isDefault, name, open, onOpenChange }: EditModalProps) => {\n const { toggleNotification } = useNotification();\n const {\n _unstableFormatAPIError: formatAPIError,\n _unstableFormatValidationErrors: formatValidationErrors,\n } = useAPIErrorHandler();\n const refetchPermissions = useAuth('EditModal', (state) => state.refetchPermissions);\n const { formatMessage } = useIntl();\n const titleId = useId();\n\n const [updateLocale] = useUpdateLocaleMutation();\n const handleSubmit = async (\n { code: _code, ...data }: FormValues,\n helpers: FormHelpers<FormValues>\n ) => {\n try {\n /**\n * We don't need to send the code, because the\n * code can never be changed.\n */\n const res = await updateLocale({\n id,\n ...data,\n });\n\n if ('error' in res) {\n if (isBaseQueryError(res.error) && res.error.name === 'ValidationError') {\n helpers.setErrors(formatValidationErrors(res.error));\n } else {\n toggleNotification({ type: 'danger', message: formatAPIError(res.error) });\n }\n\n return;\n }\n\n toggleNotification({\n type: 'success',\n message: formatMessage({\n id: getTranslation('Settings.locales.modal.edit.success'),\n defaultMessage: 'Locale successfully edited',\n }),\n });\n\n refetchPermissions();\n onOpenChange(false);\n } catch (err) {\n toggleNotification({\n type: 'danger',\n message: formatMessage({\n id: 'notification.error',\n defaultMessage: 'An error occurred, please try again',\n }),\n });\n }\n };\n\n return (\n <Modal.Root open={open} onOpenChange={onOpenChange}>\n <Modal.Content>\n <Form\n method=\"PUT\"\n onSubmit={handleSubmit}\n initialValues={{\n code,\n name,\n isDefault,\n }}\n validationSchema={LOCALE_SCHEMA}\n >\n <Modal.Header>\n <Modal.Title>\n {formatMessage(\n {\n id: getTranslation('Settings.list.actions.edit'),\n defaultMessage: 'Edit a locale',\n },\n {\n name,\n }\n )}\n </Modal.Title>\n </Modal.Header>\n <Modal.Body>\n <Tabs.Root variant=\"simple\" defaultValue=\"basic\">\n <Flex justifyContent=\"space-between\">\n <Typography tag=\"h2\" variant=\"beta\" id={titleId}>\n {formatMessage({\n id: getTranslation('Settings.locales.modal.title'),\n defaultMessage: 'Configuration',\n })}\n </Typography>\n <Tabs.List aria-labelledby={titleId}>\n <Tabs.Trigger value=\"basic\">\n {formatMessage({\n id: getTranslation('Settings.locales.modal.base'),\n defaultMessage: 'Basic settings',\n })}\n </Tabs.Trigger>\n <Tabs.Trigger value=\"advanced\">\n {formatMessage({\n id: getTranslation('Settings.locales.modal.advanced'),\n defaultMessage: 'Advanced settings',\n })}\n </Tabs.Trigger>\n </Tabs.List>\n </Flex>\n <Divider />\n <Box paddingTop={7} paddingBottom={7}>\n <Tabs.Content value=\"basic\">\n <BaseForm mode=\"edit\" />\n </Tabs.Content>\n <Tabs.Content value=\"advanced\">\n <AdvancedForm isDefaultLocale={isDefault} />\n </Tabs.Content>\n </Box>\n </Tabs.Root>\n </Modal.Body>\n <Modal.Footer>\n <Modal.Close>\n <Button variant=\"tertiary\">\n {formatMessage({ id: 'app.components.Button.cancel', defaultMessage: 'Cancel' })}\n </Button>\n </Modal.Close>\n <SubmitButton />\n </Modal.Footer>\n </Form>\n </Modal.Content>\n </Modal.Root>\n );\n};\n\nexport { EditLocale, EditModal };\n"],"names":["EditLocale","props","formatMessage","useIntl","visible","setVisible","React","useState","_jsxs","_Fragment","_jsx","IconButton","onClick","label","id","getTranslation","defaultMessage","name","variant","Pencil","EditModal","open","onOpenChange","code","isDefault","toggleNotification","useNotification","_unstableFormatAPIError","formatAPIError","_unstableFormatValidationErrors","formatValidationErrors","useAPIErrorHandler","refetchPermissions","useAuth","state","titleId","useId","updateLocale","useUpdateLocaleMutation","handleSubmit","_code","data","helpers","res","isBaseQueryError","error","setErrors","type","message","err","Modal","Root","Content","Form","method","onSubmit","initialValues","validationSchema","LOCALE_SCHEMA","Header","Title","Body","Tabs","defaultValue","Flex","justifyContent","Typography","tag","List","aria-labelledby","Trigger","value","Divider","Box","paddingTop","paddingBottom","BaseForm","mode","AdvancedForm","isDefaultLocale","Footer","Close","Button","SubmitButton"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAMA,aAAa,CAACC,KAAAA,GAAAA;IAClB,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;AAC1B,IAAA,MAAM,CAACC,OAASC,EAAAA,UAA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jBrE,aAAc,CAAA;AACbY,wDAAAA,EAAAA,EAAIC,6BAAe,CAAA,iCAAA,CAAA;wDACnBC,cAAgB,EAAA;AAClB,qDAAA;;;;;;8CAINN,cAAC8D,CAAAA,oBAAAA,EAAAA,EAAAA,CAAAA;8CACDhE,eAACiE,CAAAA,gBAAAA,EAAAA;oCAAIC,UAAY,EAAA,CAAA;oCAAGC,aAAe,EAAA,CAAA;;AACjC,sDAAAjE,cAAA,CAACoD,kBAAKV,OAAO,EAAA;4CAACmB,KAAM,EAAA,OAAA;AAClB,4CAAA,QAAA,gBAAA7D,cAACkE,CAAAA,qBAAAA,EAAAA;gDAASC,IAAK,EAAA;;;AAEjB,sDAAAnE,cAAA,CAACoD,kBAAKV,OAAO,EAAA;4CAACmB,KAAM,EAAA,UAAA;AAClB,4CAAA,QAAA,gBAAA7D,cAACoE,CAAAA,yBAAAA,EAAAA;gDAAaC,eAAiBvD,EAAAA;;;;;;;;AAKvC,kCAAAhB,eAAA,CAAC0C,mBAAM8B,MAAM,EAAA;;AACX,0CAAAtE,cAAA,CAACwC,mBAAM+B,KAAK,EAAA;AACV,gCAAA,QAAA,gBAAAvE,cAACwE,CAAAA,mBAAAA,EAAAA;oCAAOhE,OAAQ,EAAA,UAAA;8CACbhB,aAAc,CAAA;wCAAEY,EAAI,EAAA,8BAAA;wCAAgCE,cAAgB,EAAA;AAAS,qCAAA;;;0CAGlFN,cAACyE,CAAAA,yBAAAA,EAAAA,EAAAA;;;;;;;AAMb;;;;;"}
@@ -67,7 +67,7 @@ const EditLocale = (props)=>{
67
67
  type: 'success',
68
68
  message: formatMessage({
69
69
  id: getTranslation('Settings.locales.modal.edit.success'),
70
- defaultMessage: 'Updated locale'
70
+ defaultMessage: 'Locale successfully edited'
71
71
  })
72
72
  });
73
73
  refetchPermissions();
@@ -1 +1 @@
1
- {"version":3,"file":"EditLocale.mjs","sources":["../../../admin/src/components/EditLocale.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useNotification,\n useAPIErrorHandler,\n Form,\n FormHelpers,\n useAuth,\n} from '@strapi/admin/strapi-admin';\nimport {\n Box,\n Button,\n Divider,\n Flex,\n IconButton,\n Modal,\n Tabs,\n Typography,\n useId,\n} from '@strapi/design-system';\nimport { Pencil } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\n\nimport { Locale, UpdateLocale } from '../../../shared/contracts/locales';\nimport { useUpdateLocaleMutation } from '../services/locales';\nimport { isBaseQueryError } from '../utils/baseQuery';\nimport { getTranslation } from '../utils/getTranslation';\n\nimport { AdvancedForm, BaseForm, LOCALE_SCHEMA, SubmitButton } from './CreateLocale';\n\n/* -------------------------------------------------------------------------------------------------\n * EditLocale\n * -----------------------------------------------------------------------------------------------*/\n\ninterface EditLocaleProps extends Omit<EditModalProps, 'open' | 'onOpenChange'> {}\n\nconst EditLocale = (props: EditLocaleProps) => {\n const { formatMessage } = useIntl();\n const [visible, setVisible] = React.useState(false);\n\n return (\n <>\n <IconButton\n onClick={() => setVisible(true)}\n label={formatMessage(\n {\n id: getTranslation('Settings.list.actions.edit'),\n defaultMessage: 'Edit {name} locale',\n },\n {\n name: props.name,\n }\n )}\n variant=\"ghost\"\n >\n <Pencil />\n </IconButton>\n <EditModal {...props} open={visible} onOpenChange={setVisible} />\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * EditModal\n * -----------------------------------------------------------------------------------------------*/\n\ninterface EditModalProps extends Pick<Locale, 'id' | 'isDefault' | 'name' | 'code'> {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n}\n\ntype FormValues = UpdateLocale.Request['body'] & { code: string };\n\n/**\n * @internal\n * @description Exported to be used when someone clicks on a table row.\n */\nconst EditModal = ({ id, code, isDefault, name, open, onOpenChange }: EditModalProps) => {\n const { toggleNotification } = useNotification();\n const {\n _unstableFormatAPIError: formatAPIError,\n _unstableFormatValidationErrors: formatValidationErrors,\n } = useAPIErrorHandler();\n const refetchPermissions = useAuth('EditModal', (state) => state.refetchPermissions);\n const { formatMessage } = useIntl();\n const titleId = useId();\n\n const [updateLocale] = useUpdateLocaleMutation();\n const handleSubmit = async (\n { code: _code, ...data }: FormValues,\n helpers: FormHelpers<FormValues>\n ) => {\n try {\n /**\n * We don't need to send the code, because the\n * code can never be changed.\n */\n const res = await updateLocale({\n id,\n ...data,\n });\n\n if ('error' in res) {\n if (isBaseQueryError(res.error) && res.error.name === 'ValidationError') {\n helpers.setErrors(formatValidationErrors(res.error));\n } else {\n toggleNotification({ type: 'danger', message: formatAPIError(res.error) });\n }\n\n return;\n }\n\n toggleNotification({\n type: 'success',\n message: formatMessage({\n id: getTranslation('Settings.locales.modal.edit.success'),\n defaultMessage: 'Updated locale',\n }),\n });\n\n refetchPermissions();\n onOpenChange(false);\n } catch (err) {\n toggleNotification({\n type: 'danger',\n message: formatMessage({\n id: 'notification.error',\n defaultMessage: 'An error occurred, please try again',\n }),\n });\n }\n };\n\n return (\n <Modal.Root open={open} onOpenChange={onOpenChange}>\n <Modal.Content>\n <Form\n method=\"PUT\"\n onSubmit={handleSubmit}\n initialValues={{\n code,\n name,\n isDefault,\n }}\n validationSchema={LOCALE_SCHEMA}\n >\n <Modal.Header>\n <Modal.Title>\n {formatMessage(\n {\n id: getTranslation('Settings.list.actions.edit'),\n defaultMessage: 'Edit a locale',\n },\n {\n name,\n }\n )}\n </Modal.Title>\n </Modal.Header>\n <Modal.Body>\n <Tabs.Root variant=\"simple\" defaultValue=\"basic\">\n <Flex justifyContent=\"space-between\">\n <Typography tag=\"h2\" variant=\"beta\" id={titleId}>\n {formatMessage({\n id: getTranslation('Settings.locales.modal.title'),\n defaultMessage: 'Configuration',\n })}\n </Typography>\n <Tabs.List aria-labelledby={titleId}>\n <Tabs.Trigger value=\"basic\">\n {formatMessage({\n id: getTranslation('Settings.locales.modal.base'),\n defaultMessage: 'Basic settings',\n })}\n </Tabs.Trigger>\n <Tabs.Trigger value=\"advanced\">\n {formatMessage({\n id: getTranslation('Settings.locales.modal.advanced'),\n defaultMessage: 'Advanced settings',\n })}\n </Tabs.Trigger>\n </Tabs.List>\n </Flex>\n <Divider />\n <Box paddingTop={7} paddingBottom={7}>\n <Tabs.Content value=\"basic\">\n <BaseForm mode=\"edit\" />\n </Tabs.Content>\n <Tabs.Content value=\"advanced\">\n <AdvancedForm isDefaultLocale={isDefault} />\n </Tabs.Content>\n </Box>\n </Tabs.Root>\n </Modal.Body>\n <Modal.Footer>\n <Modal.Close>\n <Button variant=\"tertiary\">\n {formatMessage({ id: 'app.components.Button.cancel', defaultMessage: 'Cancel' })}\n </Button>\n </Modal.Close>\n <SubmitButton />\n </Modal.Footer>\n </Form>\n </Modal.Content>\n </Modal.Root>\n );\n};\n\nexport { EditLocale, EditModal };\n"],"names":["EditLocale","props","formatMessage","useIntl","visible","setVisible","React","useState","_jsxs","_Fragment","_jsx","IconButton","onClick","label","id","getTranslation","defaultMessage","name","variant","Pencil","EditModal","open","onOpenChange","code","isDefault","toggleNotification","useNotification","_unstableFormatAPIError","formatAPIError","_unstableFormatValidationErrors","formatValidationErrors","useAPIErrorHandler","refetchPermissions","useAuth","state","titleId","useId","updateLocale","useUpdateLocaleMutation","handleSubmit","_code","data","helpers","res","isBaseQueryError","error","setErrors","type","message","err","Modal","Root","Content","Form","method","onSubmit","initialValues","validationSchema","LOCALE_SCHEMA","Header","Title","Body","Tabs","defaultValue","Flex","justifyContent","Typography","tag","List","aria-labelledby","Trigger","value","Divider","Box","paddingTop","paddingBottom","BaseForm","mode","AdvancedForm","isDefaultLocale","Footer","Close","Button","SubmitButton"],"mappings":";;;;;;;;;;;AAoCA,MAAMA,aAAa,CAACC,KAAAA,GAAAA;IAClB,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;AAC1B,IAAA,MAAM,CAACC,OAASC,EAAAA,UAAAA,CAAW,GAAGC,KAAAA,CAAMC,QAAQ,CAAC,KAAA,CAAA;IAE7C,qBACEC,IAAA,CAAAC,QAAA,EAAA;;0BACEC,GAACC,CAAAA,UAAAA,EAAAA;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A;8CACDhE,IAACiE,CAAAA,GAAAA,EAAAA;oCAAIC,UAAY,EAAA,CAAA;oCAAGC,aAAe,EAAA,CAAA;;AACjC,sDAAAjE,GAAA,CAACoD,KAAKV,OAAO,EAAA;4CAACmB,KAAM,EAAA,OAAA;AAClB,4CAAA,QAAA,gBAAA7D,GAACkE,CAAAA,QAAAA,EAAAA;gDAASC,IAAK,EAAA;;;AAEjB,sDAAAnE,GAAA,CAACoD,KAAKV,OAAO,EAAA;4CAACmB,KAAM,EAAA,UAAA;AAClB,4CAAA,QAAA,gBAAA7D,GAACoE,CAAAA,YAAAA,EAAAA;gDAAaC,eAAiBvD,EAAAA;;;;;;;;AAKvC,kCAAAhB,IAAA,CAAC0C,MAAM8B,MAAM,EAAA;;AACX,0CAAAtE,GAAA,CAACwC,MAAM+B,KAAK,EAAA;AACV,gCAAA,QAAA,gBAAAvE,GAACwE,CAAAA,MAAAA,EAAAA;oCAAOhE,OAAQ,EAAA,UAAA;8CACbhB,aAAc,CAAA;wCAAEY,EAAI,EAAA,8BAAA;wCAAgCE,cAAgB,EAAA;AAAS,qCAAA;;;0CAGlFN,GAACyE,CAAAA,YAAAA,EAAAA,EAAAA;;;;;;;AAMb;;;;"}
1
+ {"version":3,"file":"EditLocale.mjs","sources":["../../../admin/src/components/EditLocale.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useNotification,\n useAPIErrorHandler,\n Form,\n FormHelpers,\n useAuth,\n} from '@strapi/admin/strapi-admin';\nimport {\n Box,\n Button,\n Divider,\n Flex,\n IconButton,\n Modal,\n Tabs,\n Typography,\n useId,\n} from '@strapi/design-system';\nimport { Pencil } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\n\nimport { Locale, UpdateLocale } from '../../../shared/contracts/locales';\nimport { useUpdateLocaleMutation } from '../services/locales';\nimport { isBaseQueryError } from '../utils/baseQuery';\nimport { getTranslation } from '../utils/getTranslation';\n\nimport { AdvancedForm, BaseForm, LOCALE_SCHEMA, SubmitButton } from './CreateLocale';\n\n/* -------------------------------------------------------------------------------------------------\n * EditLocale\n * -----------------------------------------------------------------------------------------------*/\n\ninterface EditLocaleProps extends Omit<EditModalProps, 'open' | 'onOpenChange'> {}\n\nconst EditLocale = (props: EditLocaleProps) => {\n const { formatMessage } = useIntl();\n const [visible, setVisible] = React.useState(false);\n\n return (\n <>\n <IconButton\n onClick={() => setVisible(true)}\n label={formatMessage(\n {\n id: getTranslation('Settings.list.actions.edit'),\n defaultMessage: 'Edit {name} locale',\n },\n {\n name: props.name,\n }\n )}\n variant=\"ghost\"\n >\n <Pencil />\n </IconButton>\n <EditModal {...props} open={visible} onOpenChange={setVisible} />\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * EditModal\n * -----------------------------------------------------------------------------------------------*/\n\ninterface EditModalProps extends Pick<Locale, 'id' | 'isDefault' | 'name' | 'code'> {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n}\n\ntype FormValues = UpdateLocale.Request['body'] & { code: string };\n\n/**\n * @internal\n * @description Exported to be used when someone clicks on a table row.\n */\nconst EditModal = ({ id, code, isDefault, name, open, onOpenChange }: EditModalProps) => {\n const { toggleNotification } = useNotification();\n const {\n _unstableFormatAPIError: formatAPIError,\n _unstableFormatValidationErrors: formatValidationErrors,\n } = useAPIErrorHandler();\n const refetchPermissions = useAuth('EditModal', (state) => state.refetchPermissions);\n const { formatMessage } = useIntl();\n const titleId = useId();\n\n const [updateLocale] = useUpdateLocaleMutation();\n const handleSubmit = async (\n { code: _code, ...data }: FormValues,\n helpers: FormHelpers<FormValues>\n ) => {\n try {\n /**\n * We don't need to send the code, because the\n * code can never be changed.\n */\n const res = await updateLocale({\n id,\n ...data,\n });\n\n if ('error' in res) {\n if (isBaseQueryError(res.error) && res.error.name === 'ValidationError') {\n helpers.setErrors(formatValidationErrors(res.error));\n } else {\n toggleNotification({ type: 'danger', message: formatAPIError(res.error) });\n }\n\n return;\n }\n\n toggleNotification({\n type: 'success',\n message: formatMessage({\n id: getTranslation('Settings.locales.modal.edit.success'),\n defaultMessage: 'Locale successfully edited',\n }),\n });\n\n refetchPermissions();\n onOpenChange(false);\n } catch (err) {\n toggleNotification({\n type: 'danger',\n message: formatMessage({\n id: 'notification.error',\n defaultMessage: 'An error occurred, please try again',\n }),\n });\n }\n };\n\n return (\n <Modal.Root open={open} onOpenChange={onOpenChange}>\n <Modal.Content>\n <Form\n method=\"PUT\"\n onSubmit={handleSubmit}\n initialValues={{\n code,\n name,\n isDefault,\n }}\n validationSchema={LOCALE_SCHEMA}\n >\n <Modal.Header>\n <Modal.Title>\n {formatMessage(\n {\n id: getTranslation('Settings.list.actions.edit'),\n defaultMessage: 'Edit a locale',\n },\n {\n name,\n }\n )}\n </Modal.Title>\n </Modal.Header>\n <Modal.Body>\n <Tabs.Root variant=\"simple\" defaultValue=\"basic\">\n <Flex justifyContent=\"space-between\">\n <Typography tag=\"h2\" variant=\"beta\" id={titleId}>\n {formatMessage({\n id: getTranslation('Settings.locales.modal.title'),\n defaultMessage: 'Configuration',\n })}\n </Typography>\n <Tabs.List aria-labelledby={titleId}>\n <Tabs.Trigger value=\"basic\">\n {formatMessage({\n id: getTranslation('Settings.locales.modal.base'),\n defaultMessage: 'Basic settings',\n })}\n </Tabs.Trigger>\n <Tabs.Trigger value=\"advanced\">\n {formatMessage({\n id: getTranslation('Settings.locales.modal.advanced'),\n defaultMessage: 'Advanced settings',\n })}\n </Tabs.Trigger>\n </Tabs.List>\n </Flex>\n <Divider />\n <Box paddingTop={7} paddingBottom={7}>\n <Tabs.Content value=\"basic\">\n <BaseForm mode=\"edit\" />\n </Tabs.Content>\n <Tabs.Content value=\"advanced\">\n <AdvancedForm isDefaultLocale={isDefault} />\n </Tabs.Content>\n </Box>\n </Tabs.Root>\n </Modal.Body>\n <Modal.Footer>\n <Modal.Close>\n <Button variant=\"tertiary\">\n {formatMessage({ id: 'app.components.Button.cancel', defaultMessage: 'Cancel' })}\n </Button>\n </Modal.Close>\n <SubmitButton />\n </Modal.Footer>\n </Form>\n </Modal.Content>\n </Modal.Root>\n );\n};\n\nexport { EditLocale, EditModal };\n"],"names":["EditLocale","props","formatMessage","useIntl","visible","setVisible","React","useState","_jsxs","_Fragment","_jsx","IconButton","onClick","label","id","getTranslation","defaultMessage","name","variant","Pencil","EditModal","open","onOpenChange","code","isDefault","toggleNotification","useNotification","_unstableFormatAPIError","formatAPIError","_unstableFormatValidationErrors","formatValidationErrors","useAPIErrorHandler","refetchPermissions","useAuth","state","titleId","useId","updateLocale","useUpdateLocaleMutation","handleSubmit","_code","data","helpers","res","isBaseQueryError","error","setErrors","type","message","err","Modal","Root","Content","Form","method","onSubmit","initialValues","validationSchema","LOCALE_SCHEMA","Header","Title","Body","Tabs","defaultValue","Flex","justifyContent","Typography","tag","List","aria-labelledby","Trigger","value","Divider","Box","paddingTop","paddingBottom","BaseForm","mode","AdvancedForm","isDefaultLocale","Footer","Close","Button","SubmitButton"],"mappings":";;;;;;;;;;;AAoCA,MAAMA,aAAa,CAACC,KAAAA,GAAAA;IAClB,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;AAC1B,IAAA,MAAM,CAACC,OAASC,EAAAA,UAAAA,CAAW,GAAGC,KAAAA,CAAMC,QAAQ,CAAC,KAAA,CAAA;IAE7C,qBACEC,IAAA,CAAAC,QAAA,EAAA;;0BACEC,GAACC,CAAAA,UAAAA,EAAAA;AACCC,gBAAAA,OAAAA,EAAS,IAAMP,UAAW,CAAA,IAAA,CAAA;AAC1BQ,gBAAAA,KAAAA,EAAOX,aACL,CAAA;AACEY,oBAAAA,EAAAA,EAAIC,cAAe,CAAA,4BAAA,CAAA;oBACnBC,cAAgB,EAAA;iBAElB,EAAA;AACEC,oBAAAA,IAAAA,EAAMhB,MAAMgB;AACd,iBAAA,CAAA;gBAEFC,OAAQ,EAAA,OAAA;AAER,gBAAA,QAAA,gBAAAR,GAACS,CAAAA,MAAAA,EAAAA,EAAAA;;0BAEHT,GAACU,CAAAA,SAAAA,EAAAA;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EAAAA;gDAAaC,eAAiBvD,EAAAA;;;;;;;;AAKvC,kCAAAhB,IAAA,CAAC0C,MAAM8B,MAAM,EAAA;;AACX,0CAAAtE,GAAA,CAACwC,MAAM+B,KAAK,EAAA;AACV,gCAAA,QAAA,gBAAAvE,GAACwE,CAAAA,MAAAA,EAAAA;oCAAOhE,OAAQ,EAAA,UAAA;8CACbhB,aAAc,CAAA;wCAAEY,EAAI,EAAA,8BAAA;wCAAgCE,cAAgB,EAAA;AAAS,qCAAA;;;0CAGlFN,GAACyE,CAAAA,YAAAA,EAAAA,EAAAA;;;;;;;AAMb;;;;"}
@@ -1,14 +1,19 @@
1
1
  'use strict';
2
2
 
3
3
  var jsxRuntime = require('react/jsx-runtime');
4
+ var strapiAdmin = require('@strapi/admin/strapi-admin');
4
5
  var designSystem = require('@strapi/design-system');
5
- var icons = require('@strapi/icons');
6
+ var qs = require('qs');
6
7
  var reactIntl = require('react-intl');
8
+ var reactRouterDom = require('react-router-dom');
7
9
  var locales = require('../services/locales.js');
10
+ var getTranslation = require('../utils/getTranslation.js');
8
11
 
9
- const LocaleListCell = ({ locale: currentLocale, localizations })=>{
10
- const { locale: language } = reactIntl.useIntl();
12
+ const LocaleListCell = ({ locale: currentLocale, localizations, documentId })=>{
13
+ const { locale: language, formatMessage } = reactIntl.useIntl();
11
14
  const { data: locales$1 = [] } = locales.useGetLocalesQuery();
15
+ const navigate = reactRouterDom.useNavigate();
16
+ const [{ query }] = strapiAdmin.useQueryParams();
12
17
  const formatter = designSystem.useCollator(language, {
13
18
  sensitivity: 'base'
14
19
  });
@@ -24,55 +29,70 @@ const LocaleListCell = ({ locale: currentLocale, localizations })=>{
24
29
  return loc === locale.code;
25
30
  });
26
31
  if (createdLocale) {
27
- acc.push(locale);
32
+ const name = locale.isDefault ? `${locale.name} (default)` : locale.name;
33
+ acc.push({
34
+ code: locale.code,
35
+ name
36
+ });
28
37
  }
29
38
  return acc;
30
- }, []).map((locale)=>{
31
- if (locale.isDefault) {
32
- return `${locale.name} (default)`;
39
+ }, []).toSorted((a, b)=>formatter.compare(a.name, b.name));
40
+ const getDisplayText = ()=>{
41
+ const displayedLocales = localesForDocument.slice(0, 2);
42
+ const remainingCount = localesForDocument.length - 2;
43
+ const baseText = displayedLocales.map(({ name })=>name).join(', ');
44
+ if (remainingCount <= 0) {
45
+ return baseText;
33
46
  }
34
- return locale.name;
35
- }).toSorted((a, b)=>formatter.compare(a, b));
36
- return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Popover.Root, {
47
+ return formatMessage({
48
+ id: getTranslation.getTranslation('CMListView.popover.display-locales.more'),
49
+ defaultMessage: '{locales} + {count} more'
50
+ }, {
51
+ locales: baseText,
52
+ count: remainingCount
53
+ });
54
+ };
55
+ const handleLocaleClick = (localeCode)=>{
56
+ navigate({
57
+ pathname: documentId,
58
+ search: qs.stringify({
59
+ plugins: {
60
+ ...query.plugins,
61
+ i18n: {
62
+ locale: localeCode
63
+ }
64
+ }
65
+ })
66
+ });
67
+ };
68
+ return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Menu.Root, {
37
69
  children: [
38
- /*#__PURE__*/ jsxRuntime.jsx(designSystem.Popover.Trigger, {
39
- children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
40
- variant: "ghost",
41
- type: "button",
42
- onClick: (e)=>e.stopPropagation(),
43
- children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
44
- minWidth: "100%",
45
- alignItems: "center",
46
- justifyContent: "center",
47
- fontWeight: "regular",
48
- children: [
49
- /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
50
- textColor: "neutral800",
51
- ellipsis: true,
52
- marginRight: 2,
53
- children: localesForDocument.join(', ')
54
- }),
55
- /*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
56
- children: /*#__PURE__*/ jsxRuntime.jsx(icons.CaretDown, {
57
- width: "1.2rem",
58
- height: "1.2rem"
59
- })
60
- })
61
- ]
70
+ /*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Trigger, {
71
+ children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
72
+ minWidth: "100%",
73
+ alignItems: "center",
74
+ justifyContent: "center",
75
+ fontWeight: "regular",
76
+ children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
77
+ textColor: "neutral800",
78
+ ellipsis: true,
79
+ marginRight: 2,
80
+ children: getDisplayText()
62
81
  })
63
82
  })
64
83
  }),
65
- /*#__PURE__*/ jsxRuntime.jsx(designSystem.Popover.Content, {
66
- sideOffset: 16,
67
- children: /*#__PURE__*/ jsxRuntime.jsx("ul", {
68
- children: localesForDocument.map((name)=>/*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
69
- padding: 3,
70
- tag: "li",
71
- children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
72
- children: name
73
- })
74
- }, name))
75
- })
84
+ /*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Content, {
85
+ children: localesForDocument.map(({ code, name })=>/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Item, {
86
+ onClick: (e)=>{
87
+ e.stopPropagation();
88
+ handleLocaleClick(code);
89
+ },
90
+ children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
91
+ textColor: "neutral800",
92
+ fontWeight: "regular",
93
+ children: name
94
+ })
95
+ }, code))
76
96
  })
77
97
  ]
78
98
  });
@@ -1 +1 @@
1
- {"version":3,"file":"LocaleListCell.js","sources":["../../../admin/src/components/LocaleListCell.tsx"],"sourcesContent":["import { Box, Flex, Popover, Typography, useCollator, Button } from '@strapi/design-system';\nimport { CaretDown } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\n\nimport { Locale } from '../../../shared/contracts/locales';\nimport { useGetLocalesQuery } from '../services/locales';\n\ninterface LocaleListCellProps {\n localizations: { locale: string }[];\n locale: string;\n}\n\nconst LocaleListCell = ({ locale: currentLocale, localizations }: LocaleListCellProps) => {\n const { locale: language } = useIntl();\n const { data: locales = [] } = useGetLocalesQuery();\n const formatter = useCollator(language, {\n sensitivity: 'base',\n });\n\n if (!Array.isArray(locales) || !localizations) {\n return null;\n }\n\n const availableLocales = localizations.map((loc) => loc.locale);\n\n const localesForDocument = locales\n .reduce<Locale[]>((acc, locale) => {\n const createdLocale = [currentLocale, ...availableLocales].find((loc) => {\n return loc === locale.code;\n });\n\n if (createdLocale) {\n acc.push(locale);\n }\n\n return acc;\n }, [])\n .map((locale) => {\n if (locale.isDefault) {\n return `${locale.name} (default)`;\n }\n\n return locale.name;\n })\n .toSorted((a, b) => formatter.compare(a, b));\n\n return (\n <Popover.Root>\n <Popover.Trigger>\n <Button variant=\"ghost\" type=\"button\" onClick={(e) => e.stopPropagation()}>\n <Flex minWidth=\"100%\" alignItems=\"center\" justifyContent=\"center\" fontWeight=\"regular\">\n <Typography textColor=\"neutral800\" ellipsis marginRight={2}>\n {localesForDocument.join(', ')}\n </Typography>\n <Flex>\n <CaretDown width=\"1.2rem\" height=\"1.2rem\" />\n </Flex>\n </Flex>\n </Button>\n </Popover.Trigger>\n <Popover.Content sideOffset={16}>\n <ul>\n {localesForDocument.map((name) => (\n <Box key={name} padding={3} tag=\"li\">\n <Typography>{name}</Typography>\n </Box>\n ))}\n </ul>\n </Popover.Content>\n </Popover.Root>\n );\n};\n\nexport { LocaleListCell };\nexport type { LocaleListCellProps };\n"],"names":["LocaleListCell","locale","currentLocale","localizations","language","useIntl","data","locales","useGetLocalesQuery","formatter","useCollator","sensitivity","Array","isArray","availableLocales","map","loc","localesForDocument","reduce","acc","createdLocale","find","code","push","isDefault","name","toSorted","a","b","compare","_jsxs","Popover","Root","_jsx","Trigger","Button","variant","type","onClick","e","stopPropagation","Flex","minWidth","alignItems","justifyContent","fontWeight","Typography","textColor","ellipsis","marginRight","join","CaretDown","width","height","Content","sideOffset","ul","Box","padding","tag"],"mappings":";;;;;;;;AAYA,MAAMA,iBAAiB,CAAC,EAAEC,QAAQC,aAAa,EAAEC,aAAa,EA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ources":["../../../admin/src/components/LocaleListCell.tsx"],"sourcesContent":["import { useQueryParams } from '@strapi/admin/strapi-admin';\nimport { Flex, Menu, Typography, useCollator } from '@strapi/design-system';\nimport { stringify } from 'qs';\nimport { useIntl } from 'react-intl';\nimport { useNavigate } from 'react-router-dom';\n\nimport { useGetLocalesQuery } from '../services/locales';\nimport { getTranslation } from '../utils/getTranslation';\n\nimport type { I18nBaseQuery } from '../types';\n\ninterface LocaleListCellProps {\n localizations: { locale: string }[];\n locale: string;\n documentId: string;\n}\n\nconst LocaleListCell = ({\n locale: currentLocale,\n localizations,\n documentId,\n}: LocaleListCellProps) => {\n const { locale: language, formatMessage } = useIntl();\n const { data: locales = [] } = useGetLocalesQuery();\n const navigate = useNavigate();\n const [{ query }] = useQueryParams<I18nBaseQuery>();\n const formatter = useCollator(language, {\n sensitivity: 'base',\n });\n\n if (!Array.isArray(locales) || !localizations) {\n return null;\n }\n\n const availableLocales = localizations.map((loc) => loc.locale);\n\n const localesForDocument = locales\n .reduce<Array<{ code: string; name: string }>>((acc, locale) => {\n const createdLocale = [currentLocale, ...availableLocales].find((loc) => {\n return loc === locale.code;\n });\n\n if (createdLocale) {\n const name = locale.isDefault ? `${locale.name} (default)` : locale.name;\n acc.push({ code: locale.code, name });\n }\n\n return acc;\n }, [])\n .toSorted((a, b) => formatter.compare(a.name, b.name));\n\n const getDisplayText = () => {\n const displayedLocales = localesForDocument.slice(0, 2);\n const remainingCount = localesForDocument.length - 2;\n\n const baseText = displayedLocales.map(({ name }) => name).join(', ');\n\n if (remainingCount <= 0) {\n return baseText;\n }\n\n return formatMessage(\n {\n id: getTranslation('CMListView.popover.display-locales.more'),\n defaultMessage: '{locales} + {count} more',\n },\n { locales: baseText, count: remainingCount }\n );\n };\n\n const handleLocaleClick = (localeCode: string) => {\n navigate({\n pathname: documentId,\n search: stringify({\n plugins: {\n ...query.plugins,\n i18n: { locale: localeCode },\n },\n }),\n });\n };\n\n return (\n <Menu.Root>\n <Menu.Trigger>\n <Flex minWidth=\"100%\" alignItems=\"center\" justifyContent=\"center\" fontWeight=\"regular\">\n <Typography textColor=\"neutral800\" ellipsis marginRight={2}>\n {getDisplayText()}\n </Typography>\n </Flex>\n </Menu.Trigger>\n <Menu.Content>\n {localesForDocument.map(({ code, name }) => (\n <Menu.Item\n key={code}\n onClick={(e: React.MouseEvent) => {\n e.stopPropagation();\n handleLocaleClick(code);\n }}\n >\n <Typography textColor=\"neutral800\" fontWeight=\"regular\">\n {name}\n </Typography>\n </Menu.Item>\n ))}\n </Menu.Content>\n </Menu.Root>\n );\n};\n\nexport { LocaleListCell };\nexport type { LocaleListCellProps };\n"],"names":["LocaleListCell","locale","currentLocale","localizations","documentId","language","formatMessage","useIntl","data","locales","useGetLocalesQuery","navigate","useNavigate","query","useQueryParams","formatter","useCollator","sensitivity","Array","isArray","availableLocales","map","loc","localesForDocument","reduce","acc","createdLocale","find","code","name","isDefault","push","toSorted","a","b","compare","getDisplayText","displayedLocales","slice","remainingCount","length","baseText","join","id","getTranslation","defaultMessage","count","handleLocaleClick","localeCode","pathname","search","stringify","plugins","i18n","_jsxs","Menu","Root","_jsx","Trigger","Flex","minWidth","alignItems","justifyContent","fontWeight","Typography","textColor","ellipsis","marginRight","Content","Item","onClick","e","stopPropagation"],"mappings":";;;;;;;;;;;AAiBMA,MAAAA,cAAAA,GAAiB,CAAC,EACtBC,MAAAA,EAAQC,aAAa,EACrBC,aAAa,EACbC,UAAU,EACU,GAAA;AACpB,IAAA,MAAM,EAAEH,MAAQI,EAAAA,QAAQ,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;AAC5C,IAAA,MAAM,EAAEC,IAAAA,EAAMC,SAAU,GAAA,EAAE,EAAE,GAAGC,0BAAAA,EAAAA;AAC/B,IAAA,MAAMC,QAAWC,GAAAA,0BAAAA,EAAAA;AACjB,IAAA,MAAM,CAAC,EAAEC,KAAK,EAAE,CAAC,GAAGC,0BAAAA,EAAAA;IACpB,MAAMC,SAAAA,GAAYC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AAC,CAAC,EAAEO,IAAI,EAAEC,IAAI,EAAE,iBACrC4B,cAACF,CAAAA,iBAAAA,CAAKc,IAAI,EAAA;AAERC,wBAAAA,OAAAA,EAAS,CAACC,CAAAA,GAAAA;AACRA,4BAAAA,CAAAA,CAAEC,eAAe,EAAA;4BACjBzB,iBAAkBnB,CAAAA,IAAAA,CAAAA;AACpB,yBAAA;AAEA,wBAAA,QAAA,gBAAA6B,cAACO,CAAAA,uBAAAA,EAAAA;4BAAWC,SAAU,EAAA,YAAA;4BAAaF,UAAW,EAAA,SAAA;AAC3ClC,4BAAAA,QAAAA,EAAAA;;AAPED,qBAAAA,EAAAA,IAAAA,CAAAA;;;;AAcjB;;;;"}
@@ -1,12 +1,17 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { useCollator, Popover, Button, Flex, Typography, Box } from '@strapi/design-system';
3
- import { CaretDown } from '@strapi/icons';
2
+ import { useQueryParams } from '@strapi/admin/strapi-admin';
3
+ import { useCollator, Menu, Flex, Typography } from '@strapi/design-system';
4
+ import { stringify } from 'qs';
4
5
  import { useIntl } from 'react-intl';
6
+ import { useNavigate } from 'react-router-dom';
5
7
  import { useGetLocalesQuery } from '../services/locales.mjs';
8
+ import { getTranslation } from '../utils/getTranslation.mjs';
6
9
 
7
- const LocaleListCell = ({ locale: currentLocale, localizations })=>{
8
- const { locale: language } = useIntl();
10
+ const LocaleListCell = ({ locale: currentLocale, localizations, documentId })=>{
11
+ const { locale: language, formatMessage } = useIntl();
9
12
  const { data: locales = [] } = useGetLocalesQuery();
13
+ const navigate = useNavigate();
14
+ const [{ query }] = useQueryParams();
10
15
  const formatter = useCollator(language, {
11
16
  sensitivity: 'base'
12
17
  });
@@ -22,55 +27,70 @@ const LocaleListCell = ({ locale: currentLocale, localizations })=>{
22
27
  return loc === locale.code;
23
28
  });
24
29
  if (createdLocale) {
25
- acc.push(locale);
30
+ const name = locale.isDefault ? `${locale.name} (default)` : locale.name;
31
+ acc.push({
32
+ code: locale.code,
33
+ name
34
+ });
26
35
  }
27
36
  return acc;
28
- }, []).map((locale)=>{
29
- if (locale.isDefault) {
30
- return `${locale.name} (default)`;
37
+ }, []).toSorted((a, b)=>formatter.compare(a.name, b.name));
38
+ const getDisplayText = ()=>{
39
+ const displayedLocales = localesForDocument.slice(0, 2);
40
+ const remainingCount = localesForDocument.length - 2;
41
+ const baseText = displayedLocales.map(({ name })=>name).join(', ');
42
+ if (remainingCount <= 0) {
43
+ return baseText;
31
44
  }
32
- return locale.name;
33
- }).toSorted((a, b)=>formatter.compare(a, b));
34
- return /*#__PURE__*/ jsxs(Popover.Root, {
45
+ return formatMessage({
46
+ id: getTranslation('CMListView.popover.display-locales.more'),
47
+ defaultMessage: '{locales} + {count} more'
48
+ }, {
49
+ locales: baseText,
50
+ count: remainingCount
51
+ });
52
+ };
53
+ const handleLocaleClick = (localeCode)=>{
54
+ navigate({
55
+ pathname: documentId,
56
+ search: stringify({
57
+ plugins: {
58
+ ...query.plugins,
59
+ i18n: {
60
+ locale: localeCode
61
+ }
62
+ }
63
+ })
64
+ });
65
+ };
66
+ return /*#__PURE__*/ jsxs(Menu.Root, {
35
67
  children: [
36
- /*#__PURE__*/ jsx(Popover.Trigger, {
37
- children: /*#__PURE__*/ jsx(Button, {
38
- variant: "ghost",
39
- type: "button",
40
- onClick: (e)=>e.stopPropagation(),
41
- children: /*#__PURE__*/ jsxs(Flex, {
42
- minWidth: "100%",
43
- alignItems: "center",
44
- justifyContent: "center",
45
- fontWeight: "regular",
46
- children: [
47
- /*#__PURE__*/ jsx(Typography, {
48
- textColor: "neutral800",
49
- ellipsis: true,
50
- marginRight: 2,
51
- children: localesForDocument.join(', ')
52
- }),
53
- /*#__PURE__*/ jsx(Flex, {
54
- children: /*#__PURE__*/ jsx(CaretDown, {
55
- width: "1.2rem",
56
- height: "1.2rem"
57
- })
58
- })
59
- ]
68
+ /*#__PURE__*/ jsx(Menu.Trigger, {
69
+ children: /*#__PURE__*/ jsx(Flex, {
70
+ minWidth: "100%",
71
+ alignItems: "center",
72
+ justifyContent: "center",
73
+ fontWeight: "regular",
74
+ children: /*#__PURE__*/ jsx(Typography, {
75
+ textColor: "neutral800",
76
+ ellipsis: true,
77
+ marginRight: 2,
78
+ children: getDisplayText()
60
79
  })
61
80
  })
62
81
  }),
63
- /*#__PURE__*/ jsx(Popover.Content, {
64
- sideOffset: 16,
65
- children: /*#__PURE__*/ jsx("ul", {
66
- children: localesForDocument.map((name)=>/*#__PURE__*/ jsx(Box, {
67
- padding: 3,
68
- tag: "li",
69
- children: /*#__PURE__*/ jsx(Typography, {
70
- children: name
71
- })
72
- }, name))
73
- })
82
+ /*#__PURE__*/ jsx(Menu.Content, {
83
+ children: localesForDocument.map(({ code, name })=>/*#__PURE__*/ jsx(Menu.Item, {
84
+ onClick: (e)=>{
85
+ e.stopPropagation();
86
+ handleLocaleClick(code);
87
+ },
88
+ children: /*#__PURE__*/ jsx(Typography, {
89
+ textColor: "neutral800",
90
+ fontWeight: "regular",
91
+ children: name
92
+ })
93
+ }, code))
74
94
  })
75
95
  ]
76
96
  });