@strapi/i18n 0.0.0-next.e1a19b9e52cdcb526515883c8289522a64c9871a → 0.0.0-next.e2e3ca14971ee768e1a227a209362264fd0132d4

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 (167) 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 +11 -5
  10. package/dist/admin/components/CreateLocale.js.map +1 -1
  11. package/dist/admin/components/CreateLocale.mjs +12 -6
  12. package/dist/admin/components/CreateLocale.mjs.map +1 -1
  13. package/dist/admin/components/LocaleListCell.js +65 -45
  14. package/dist/admin/components/LocaleListCell.js.map +1 -1
  15. package/dist/admin/components/LocaleListCell.mjs +66 -46
  16. package/dist/admin/components/LocaleListCell.mjs.map +1 -1
  17. package/dist/admin/components/LocalePicker.js +18 -11
  18. package/dist/admin/components/LocalePicker.js.map +1 -1
  19. package/dist/admin/components/LocalePicker.mjs +19 -12
  20. package/dist/admin/components/LocalePicker.mjs.map +1 -1
  21. package/dist/admin/contentManagerHooks/editView.js +6 -3
  22. package/dist/admin/contentManagerHooks/editView.js.map +1 -1
  23. package/dist/admin/contentManagerHooks/editView.mjs +7 -4
  24. package/dist/admin/contentManagerHooks/editView.mjs.map +1 -1
  25. package/dist/admin/contentManagerHooks/listView.js +2 -1
  26. package/dist/admin/contentManagerHooks/listView.js.map +1 -1
  27. package/dist/admin/contentManagerHooks/listView.mjs +2 -1
  28. package/dist/admin/contentManagerHooks/listView.mjs.map +1 -1
  29. package/dist/admin/hooks/useAILocalizationJobsPolling.js +110 -0
  30. package/dist/admin/hooks/useAILocalizationJobsPolling.js.map +1 -0
  31. package/dist/admin/hooks/useAILocalizationJobsPolling.mjs +89 -0
  32. package/dist/admin/hooks/useAILocalizationJobsPolling.mjs.map +1 -0
  33. package/dist/admin/hooks/useI18n.js +4 -4
  34. package/dist/admin/hooks/useI18n.js.map +1 -1
  35. package/dist/admin/hooks/useI18n.mjs +4 -4
  36. package/dist/admin/hooks/useI18n.mjs.map +1 -1
  37. package/dist/admin/index.js +1 -0
  38. package/dist/admin/index.js.map +1 -1
  39. package/dist/admin/index.mjs +2 -1
  40. package/dist/admin/index.mjs.map +1 -1
  41. package/dist/admin/pages/SettingsPage.js +121 -46
  42. package/dist/admin/pages/SettingsPage.js.map +1 -1
  43. package/dist/admin/pages/SettingsPage.mjs +124 -30
  44. package/dist/admin/pages/SettingsPage.mjs.map +1 -1
  45. package/dist/admin/services/aiLocalizationJobs.js +26 -0
  46. package/dist/admin/services/aiLocalizationJobs.js.map +1 -0
  47. package/dist/admin/services/aiLocalizationJobs.mjs +24 -0
  48. package/dist/admin/services/aiLocalizationJobs.mjs.map +1 -0
  49. package/dist/admin/services/api.js +3 -1
  50. package/dist/admin/services/api.js.map +1 -1
  51. package/dist/admin/services/api.mjs +3 -1
  52. package/dist/admin/services/api.mjs.map +1 -1
  53. package/dist/admin/services/locales.js.map +1 -1
  54. package/dist/admin/services/locales.mjs.map +1 -1
  55. package/dist/admin/services/settings.js +30 -0
  56. package/dist/admin/services/settings.js.map +1 -0
  57. package/dist/admin/services/settings.mjs +27 -0
  58. package/dist/admin/services/settings.mjs.map +1 -0
  59. package/dist/admin/src/components/CMHeaderActions.d.ts +17 -4
  60. package/dist/admin/src/components/LocaleListCell.d.ts +2 -1
  61. package/dist/admin/src/hooks/useAILocalizationJobsPolling.d.ts +9 -0
  62. package/dist/admin/src/services/aiLocalizationJobs.d.ts +6 -0
  63. package/dist/admin/src/services/api.d.ts +1 -1
  64. package/dist/admin/src/services/locales.d.ts +1 -1
  65. package/dist/admin/src/services/relations.d.ts +1 -1
  66. package/dist/admin/src/services/settings.d.ts +5 -0
  67. package/dist/admin/translations/en.json.js +10 -0
  68. package/dist/admin/translations/en.json.js.map +1 -1
  69. package/dist/admin/translations/en.json.mjs +10 -0
  70. package/dist/admin/translations/en.json.mjs.map +1 -1
  71. package/dist/admin/utils/clean.js +2 -2
  72. package/dist/admin/utils/clean.js.map +1 -1
  73. package/dist/admin/utils/clean.mjs +2 -2
  74. package/dist/admin/utils/clean.mjs.map +1 -1
  75. package/dist/admin/utils/getTranslation.js.map +1 -1
  76. package/dist/admin/utils/getTranslation.mjs.map +1 -1
  77. package/dist/admin/utils/prefixPluginTranslations.js.map +1 -1
  78. package/dist/admin/utils/prefixPluginTranslations.mjs.map +1 -1
  79. package/dist/server/bootstrap.js +24 -8
  80. package/dist/server/bootstrap.js.map +1 -1
  81. package/dist/server/bootstrap.mjs +24 -8
  82. package/dist/server/bootstrap.mjs.map +1 -1
  83. package/dist/server/constants/iso-locales.json.js +4 -0
  84. package/dist/server/constants/iso-locales.json.js.map +1 -1
  85. package/dist/server/constants/iso-locales.json.mjs +4 -0
  86. package/dist/server/constants/iso-locales.json.mjs.map +1 -1
  87. package/dist/server/controllers/ai-localization-jobs.js +47 -0
  88. package/dist/server/controllers/ai-localization-jobs.js.map +1 -0
  89. package/dist/server/controllers/ai-localization-jobs.mjs +45 -0
  90. package/dist/server/controllers/ai-localization-jobs.mjs.map +1 -0
  91. package/dist/server/controllers/index.js +5 -1
  92. package/dist/server/controllers/index.js.map +1 -1
  93. package/dist/server/controllers/index.mjs +5 -1
  94. package/dist/server/controllers/index.mjs.map +1 -1
  95. package/dist/server/controllers/settings.js +24 -0
  96. package/dist/server/controllers/settings.js.map +1 -0
  97. package/dist/server/controllers/settings.mjs +22 -0
  98. package/dist/server/controllers/settings.mjs.map +1 -0
  99. package/dist/server/models/ai-localization-job.js +60 -0
  100. package/dist/server/models/ai-localization-job.js.map +1 -0
  101. package/dist/server/models/ai-localization-job.mjs +57 -0
  102. package/dist/server/models/ai-localization-job.mjs.map +1 -0
  103. package/dist/server/register.js +3 -1
  104. package/dist/server/register.js.map +1 -1
  105. package/dist/server/register.mjs +3 -1
  106. package/dist/server/register.mjs.map +1 -1
  107. package/dist/server/routes/admin.js +40 -0
  108. package/dist/server/routes/admin.js.map +1 -1
  109. package/dist/server/routes/admin.mjs +40 -0
  110. package/dist/server/routes/admin.mjs.map +1 -1
  111. package/dist/server/services/ai-localization-jobs.js +64 -0
  112. package/dist/server/services/ai-localization-jobs.js.map +1 -0
  113. package/dist/server/services/ai-localization-jobs.mjs +62 -0
  114. package/dist/server/services/ai-localization-jobs.mjs.map +1 -0
  115. package/dist/server/services/ai-localizations.js +268 -0
  116. package/dist/server/services/ai-localizations.js.map +1 -0
  117. package/dist/server/services/ai-localizations.mjs +266 -0
  118. package/dist/server/services/ai-localizations.mjs.map +1 -0
  119. package/dist/server/services/content-types.js.map +1 -1
  120. package/dist/server/services/content-types.mjs.map +1 -1
  121. package/dist/server/services/index.js +7 -1
  122. package/dist/server/services/index.js.map +1 -1
  123. package/dist/server/services/index.mjs +7 -1
  124. package/dist/server/services/index.mjs.map +1 -1
  125. package/dist/server/services/settings.js +25 -0
  126. package/dist/server/services/settings.js.map +1 -0
  127. package/dist/server/services/settings.mjs +23 -0
  128. package/dist/server/services/settings.mjs.map +1 -0
  129. package/dist/server/src/bootstrap.d.ts.map +1 -1
  130. package/dist/server/src/controllers/ai-localization-jobs.d.ts +17 -0
  131. package/dist/server/src/controllers/ai-localization-jobs.d.ts.map +1 -0
  132. package/dist/server/src/controllers/index.d.ts +10 -0
  133. package/dist/server/src/controllers/index.d.ts.map +1 -1
  134. package/dist/server/src/controllers/settings.d.ts +7 -0
  135. package/dist/server/src/controllers/settings.d.ts.map +1 -0
  136. package/dist/server/src/index.d.ts +44 -1
  137. package/dist/server/src/index.d.ts.map +1 -1
  138. package/dist/server/src/models/ai-localization-job.d.ts +5 -0
  139. package/dist/server/src/models/ai-localization-job.d.ts.map +1 -0
  140. package/dist/server/src/models/index.d.ts +5 -0
  141. package/dist/server/src/models/index.d.ts.map +1 -0
  142. package/dist/server/src/register.d.ts +1 -1
  143. package/dist/server/src/register.d.ts.map +1 -1
  144. package/dist/server/src/routes/admin.d.ts.map +1 -1
  145. package/dist/server/src/services/ai-localization-jobs.d.ts +26 -0
  146. package/dist/server/src/services/ai-localization-jobs.d.ts.map +1 -0
  147. package/dist/server/src/services/ai-localizations.d.ts +18 -0
  148. package/dist/server/src/services/ai-localizations.d.ts.map +1 -0
  149. package/dist/server/src/services/index.d.ts +33 -0
  150. package/dist/server/src/services/index.d.ts.map +1 -1
  151. package/dist/server/src/services/settings.d.ts +13 -0
  152. package/dist/server/src/services/settings.d.ts.map +1 -0
  153. package/dist/server/src/utils/index.d.ts +7 -1
  154. package/dist/server/src/utils/index.d.ts.map +1 -1
  155. package/dist/server/src/validation/settings.d.ts +12 -0
  156. package/dist/server/src/validation/settings.d.ts.map +1 -0
  157. package/dist/server/utils/index.js.map +1 -1
  158. package/dist/server/utils/index.mjs.map +1 -1
  159. package/dist/server/validation/settings.js +11 -0
  160. package/dist/server/validation/settings.js.map +1 -0
  161. package/dist/server/validation/settings.mjs +9 -0
  162. package/dist/server/validation/settings.mjs.map +1 -0
  163. package/dist/shared/contracts/ai-localization-jobs.d.ts +27 -0
  164. package/dist/shared/contracts/ai-localization-jobs.d.ts.map +1 -0
  165. package/dist/shared/contracts/settings.d.ts +40 -0
  166. package/dist/shared/contracts/shared.d.ts.map +1 -0
  167. package/package.json +11 -9
@@ -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: '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 <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;;;0BAGJT,GAACU,CAAA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EVwH,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} xs={12} m={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} xs={12} m={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","xs","m","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,GAA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AAA,CAAOpD,KAAK,CAAA;;AAK1D,0BAAAlE,GAAA,CAACgH,MAAMQ,KAAK,EAAA,EAAA,CAAA;AACZ,0BAAAxH,GAAA,CAACgH,MAAMS,IAAI,EAAA,EAAA;;;AAGjB,CAAA;;;;"}
@@ -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,EAAuB,GAAA;AACnF,IAAA,MAAM,EAAEF,MAAAA,EAAQG,QAAQ,EAAE,GAAGC,iBAAAA,EAAAA;AAC7B,IAAA,MAAM,EAAEC,IAAAA,EAAMC,SAAU,GAAA,EAAE,EAAE,GAAGC,0BAAAA,EAAAA;IAC/B,MAAMC,SAAAA,GAAYC,yBAAYN,QA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ACC,CAAMA,GAAAA,CAAAA,CAAEC,eAAe,EAAA;AACrE,oBAAA,QAAA,gBAAAV,eAACW,CAAAA,iBAAAA,EAAAA;wBAAKC,QAAS,EAAA,MAAA;wBAAOC,UAAW,EAAA,QAAA;wBAASC,cAAe,EAAA,QAAA;wBAASC,UAAW,EAAA,SAAA;;0CAC3EZ,cAACa,CAAAA,uBAAAA,EAAAA;gCAAWC,SAAU,EAAA,YAAA;gCAAaC,QAAQ,EAAA,IAAA;gCAACC,WAAa,EAAA,CAAA;AACtDhC,gCAAAA,QAAAA,EAAAA,kBAAAA,CAAmBiC,IAAI,CAAC,IAAA;;0CAE3BjB,cAACQ,CAAAA,iBAAAA,EAAAA;AACC,gCAAA,QAAA,gBAAAR,cAACkB,CAAAA,eAAAA,EAAAA;oCAAUC,KAAM,EAAA,QAAA;oCAASC,MAAO,EAAA;;;;;;;AAKzC,0BAAApB,cAAA,CAACF,qBAAQuB,OAAO,EAAA;gBAACC,UAAY,EAAA,EAAA;AAC3B,gBAAA,QAAA,gBAAAtB,cAACuB,CAAAA,IAAAA,EAAAA;AACEvC,oBAAAA,QAAAA,EAAAA,kBAAAA,CAAmBF,GAAG,CAAC,CAACU,IAAAA,iBACvBQ,cAACwB,CAAAA,gBAAAA,EAAAA;4BAAeC,OAAS,EAAA,CAAA;4BAAGC,GAAI,EAAA,IAAA;AAC9B,4BAAA,QAAA,gBAAA1B,cAACa,CAAAA,uBAAAA,EAAAA;AAAYrB,gCAAAA,QAAAA,EAAAA;;AADLA,yBAAAA,EAAAA,IAAAA,CAAAA;;;;;AAQtB;;;;"}
1
+ {"version":3,"file":"LocaleListCell.js","sources":["../../../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,yBAAYX,QAAU,EAAA;QACtCY,WAAa,EAAA;AACf,KAAA,CAAA;AAEA,IAAA,IAAI,CAACC,KAAMC,CAAAA,OAAO,CAACV,SAAAA,CAAAA,IAAY,CAACN,aAAe,EAAA;QAC7C,OAAO,IAAA;AACT;AAEA,IAAA,MAAMiB,mBAAmBjB,aAAckB,CAAA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AA,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
  });
@@ -1 +1 @@
1
- {"version":3,"file":"LocaleListCell.mjs","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,EAAuB,GAAA;AACnF,IAAA,MAAM,EAAEF,MAAAA,EAAQG,QAAQ,EAAE,GAAGC,OAAAA,EAAAA;AAC7B,IAAA,MAAM,EAAEC,IAAAA,EAAMC,OAAU,GAAA,EAAE,EAAE,GAAGC,kBAAAA,EAAAA;IAC/B,MAAMC,SAAAA,GAAYC,YAAYN,QAAU,EAAA;QACtCO,WAAa,EAAA;AACf,KAAA,CAAA;AAEA,IAAA,IAAI,CAACC,KAAMC,CAAAA,OAAO,CAACN,OAAAA,CAAAA,IAAY,CAACJ,aAAe,EAAA;QAC7C,OAAO,IAAA;AACT;AAEA,IAAA,MAAMW,mBAAmBX,aAAcY,CAAAA,G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C3EZ,GAACa,CAAAA,UAAAA,EAAAA;gCAAWC,SAAU,EAAA,YAAA;gCAAaC,QAAQ,EAAA,IAAA;gCAACC,WAAa,EAAA,CAAA;AACtDhC,gCAAAA,QAAAA,EAAAA,kBAAAA,CAAmBiC,IAAI,CAAC,IAAA;;0CAE3BjB,GAACQ,CAAAA,IAAAA,EAAAA;AACC,gCAAA,QAAA,gBAAAR,GAACkB,CAAAA,SAAAA,EAAAA;oCAAUC,KAAM,EAAA,QAAA;oCAASC,MAAO,EAAA;;;;;;;AAKzC,0BAAApB,GAAA,CAACF,QAAQuB,OAAO,EAAA;gBAACC,UAAY,EAAA,EAAA;AAC3B,gBAAA,QAAA,gBAAAtB,GAACuB,CAAAA,IAAAA,EAAAA;AACEvC,oBAAAA,QAAAA,EAAAA,kBAAAA,CAAmBF,GAAG,CAAC,CAACU,IAAAA,iBACvBQ,GAACwB,CAAAA,GAAAA,EAAAA;4BAAeC,OAAS,EAAA,CAAA;4BAAGC,GAAI,EAAA,IAAA;AAC9B,4BAAA,QAAA,gBAAA1B,GAACa,CAAAA,UAAAA,EAAAA;AAAYrB,gCAAAA,QAAAA,EAAAA;;AADLA,yBAAAA,EAAAA,IAAAA,CAAAA;;;;;AAQtB;;;;"}
1
+ {"version":3,"file":"LocaleListCell.mjs","sources":["../../../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,OAAAA,EAAAA;AAC5C,IAAA,MAAM,EAAEC,IAAAA,EAAMC,OAAU,GAAA,EAAE,EAAE,GAAGC,kBAAAA,EAAAA;AAC/B,IAAA,MAAMC,QAAWC,GAAAA,WAAAA,EAAAA;AACjB,IAAA,MAAM,CAAC,EAAEC,KAAK,EAAE,CAAC,GAAGC,cAAAA,EAAAA;IACpB,MAAMC,SAAAA,GAAYC,YAAYX,QAAU,EAAA;QACtCY,WAAa,EAAA;AACf,KAAA,CAAA;AAEA,IAAA,IAAI,CAACC,KAAMC,CAAAA,OAAO,CAACV,OAAAA,CAAAA,IAAY,CAACN,aAAe,EAAA;QAC7C,OAAO,IAAA;AACT;AAEA,IAAA,MAAMiB,mBAAmBjB,aAAckB,CAAAA,GAAG,CAAC,CAACC,GAAAA,GAAQA,IAAIrB,MAAM,CAAA;AAE9D,IAAA,MAAMsB,kBAAqBd,GAAAA,OAAAA,CACxBe,MAAM,CAAwC,CAACC,GAAKxB,EAAAA,MAAAA,GAAAA;AACnD,QAAA,MAAMyB,aAAgB,GAAA;AAACxB,YAAAA,aAAAA;AAAkBk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16 +68,26 @@ const LocalePicker = ()=>{
68
68
  locales$1,
69
69
  query.plugins?.i18n?.locale
70
70
  ]);
71
+ const sortedLocaleOptions = React__namespace.useMemo(()=>{
72
+ const displayedLocales = Array.isArray(locales$1) ? locales$1.filter((locale)=>{
73
+ /**
74
+ * If you can create or read we allow you to see the locale exists
75
+ * this is because in the ListView, you may be able to create a new entry
76
+ * in a locale you can't read.
77
+ */ return canCreate.includes(locale.code) || canRead.includes(locale.code);
78
+ }) : [];
79
+ return displayedLocales.sort((a, b)=>a.name.localeCompare(b.name)).map((locale)=>/*#__PURE__*/ jsxRuntime.jsx(designSystem.SingleSelectOption, {
80
+ value: locale.code,
81
+ children: locale.name
82
+ }, locale.id));
83
+ }, [
84
+ locales$1,
85
+ canCreate,
86
+ canRead
87
+ ]);
71
88
  if (!hasI18n || !Array.isArray(locales$1) || locales$1.length === 0) {
72
89
  return null;
73
90
  }
74
- const displayedLocales = locales$1.filter((locale)=>{
75
- /**
76
- * If you can create or read we allow you to see the locale exists
77
- * this is because in the ListView, you may be able to create a new entry
78
- * in a locale you can't read.
79
- */ return canCreate.includes(locale.code) || canRead.includes(locale.code);
80
- });
81
91
  return /*#__PURE__*/ jsxRuntime.jsx(designSystem.SingleSelect, {
82
92
  size: "S",
83
93
  "aria-label": formatMessage({
@@ -87,10 +97,7 @@ const LocalePicker = ()=>{
87
97
  value: query.plugins?.i18n?.locale || locales$1.find((locale)=>locale.isDefault)?.code,
88
98
  // @ts-expect-error – This can be removed in V2 of the DS.
89
99
  onChange: handleChange,
90
- children: displayedLocales.map((locale)=>/*#__PURE__*/ jsxRuntime.jsx(designSystem.SingleSelectOption, {
91
- value: locale.code,
92
- children: locale.name
93
- }, locale.id))
100
+ children: sortedLocaleOptions
94
101
  });
95
102
  };
96
103
 
@@ -1 +1 @@
1
- {"version":3,"file":"LocalePicker.js","sources":["../../../admin/src/components/LocalePicker.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useQueryParams } from '@strapi/admin/strapi-admin';\nimport { SingleSelect, SingleSelectOption } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\n\nimport { useI18n } from '../hooks/useI18n';\nimport { useGetLocalesQuery } from '../services/locales';\nimport { getTranslation } from '../utils/getTranslation';\n\nimport type { I18nBaseQuery } from '../types';\n\ninterface Query extends I18nBaseQuery {\n page?: number;\n}\n\nconst LocalePicker = () => {\n const { formatMessage } = useIntl();\n const [{ query }, setQuery] = useQueryParams<Query>();\n\n const { hasI18n, canRead, canCreate } = useI18n();\n const { data: locales = [] } = useGetLocalesQuery(undefined, {\n skip: !hasI18n,\n });\n\n const handleChange = React.useCallback(\n (code: string, replace = false) => {\n setQuery(\n {\n page: 1,\n plugins: { ...query.plugins, i18n: { locale: code } },\n },\n 'push',\n replace\n );\n },\n [query.plugins, setQuery]\n );\n\n React.useEffect(() => {\n if (!Array.isArray(locales) || !hasI18n) {\n return;\n }\n /**\n * Handle the case where the current locale query param doesn't exist\n * in the list of available locales, so we redirect to the default locale.\n */\n const currentDesiredLocale = query.plugins?.i18n?.locale;\n const doesLocaleExist = locales.find((loc) => loc.code === currentDesiredLocale);\n const defaultLocale = locales.find((locale) => locale.isDefault);\n if (!doesLocaleExist && defaultLocale?.code) {\n handleChange(defaultLocale.code, true);\n }\n }, [hasI18n, handleChange, locales, query.plugins?.i18n?.locale]);\n\n if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {\n return null;\n }\n\n const displayedLocales = locales.filter((locale) => {\n /**\n * If you can create or read we allow you to see the locale exists\n * this is because in the ListView, you may be able to create a new entry\n * in a locale you can't read.\n */\n return canCreate.includes(locale.code) || canRead.includes(locale.code);\n });\n\n return (\n <SingleSelect\n size=\"S\"\n aria-label={formatMessage({\n id: getTranslation('actions.select-locale'),\n defaultMessage: 'Select locale',\n })}\n value={query.plugins?.i18n?.locale || locales.find((locale) => locale.isDefault)?.code}\n // @ts-expect-error – This can be removed in V2 of the DS.\n onChange={handleChange}\n >\n {displayedLocales.map((locale) => (\n <SingleSelectOption key={locale.id} value={locale.code}>\n {locale.name}\n </SingleSelectOption>\n ))}\n </SingleSelect>\n );\n};\n\nexport { LocalePicker };\n"],"names":["LocalePicker","formatMessage","useIntl","query","setQuery","useQueryParams","hasI18n","canRead","canCreate","useI18n","data","locales","useGetLocalesQuery","undefined","skip","handleChange","React","useCallback","code","replace","page","plugins","i18n","locale","useEffect","Array","isArray","currentDesiredLocale","doesLocaleExist","find","loc","defaultLocale","isDefault","length","displayedLocales","filter","includes","_jsx","SingleSelect","size","aria-label","id","getTranslation","defaultMessage","value","onChange","map","SingleSelectOption","name"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAMA,YAAe,GAAA,IAAA;IACnB,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;AAC1B,IAAA,MAAM,CAAC,EAAEC,KAAK,EAAE,EAAEC,SAAS,GAAGC,0BAAAA,EAAAA;AAE9B,IAAA,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAEC,SAAS,EAAE,GAAGC,eAAAA,EAAAA;AACxC,IAAA,MAAM,EAAEC,IAAMC,EAAAA,SAAAA,GAAU,EAAE,EAAE,GAAGC,2BAAmBC,SAAW,EAAA;AAC3DC,QAAAA,IAAAA,EAAM,CAACR;AACT,KAAA,CAAA;AAEA,IAAA,MAAMS,eAAeC,gBAAMC,CAAAA,WAAW,CACpC,CAACC,IAAAA,EAAcC,UAAU,KAAK,GAAA;QAC5Bf,QACE,CAAA;YACEgB,IAAM,EAAA,CAAA;YACNC,OAAS,EAAA;AAAE,gBAAA,GAAGlB,MAAMkB,OAAO;gBAAEC,IAAM,EAAA;oBAAEC,MAAQL,EAAAA;AAAK;AAAE;AACtD,SAAA,EACA,MACAC,EAAAA,OAAAA,CAAAA;KAGJ,EAAA;AAAChB,QAAAA,KAAAA,CAAMkB,OAAO;AAAEjB,QAAAA;AAAS,KAAA,CAAA;AAG3BY,IAAAA,gBAAAA,CAAMQ,SAAS,CAAC,IAAA;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AAe,CAAA,uBAAA,CAAA;YACnBC,cAAgB,EAAA;AAClB,SAAA,CAAA;AACAC,QAAAA,KAAAA,EAAOzC,KAAMkB,CAAAA,OAAO,EAAEC,IAAAA,EAAMC,MAAUZ,IAAAA,SAAAA,CAAQkB,IAAI,CAAC,CAACN,MAAAA,GAAWA,MAAOS,CAAAA,SAAS,CAAGd,EAAAA,IAAAA;;QAElF2B,QAAU9B,EAAAA,YAAAA;AAETmB,QAAAA,QAAAA,EAAAA,gBAAAA,CAAiBY,GAAG,CAAC,CAACvB,MAAAA,iBACrBc,cAACU,CAAAA,+BAAAA,EAAAA;AAAmCH,gBAAAA,KAAAA,EAAOrB,OAAOL,IAAI;AACnDK,gBAAAA,QAAAA,EAAAA,MAAAA,CAAOyB;AADezB,aAAAA,EAAAA,MAAAA,CAAOkB,EAAE,CAAA;;AAM1C;;;;"}
1
+ {"version":3,"file":"LocalePicker.js","sources":["../../../admin/src/components/LocalePicker.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useQueryParams } from '@strapi/admin/strapi-admin';\nimport { SingleSelect, SingleSelectOption } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\n\nimport { useI18n } from '../hooks/useI18n';\nimport { useGetLocalesQuery } from '../services/locales';\nimport { getTranslation } from '../utils/getTranslation';\n\nimport type { I18nBaseQuery } from '../types';\n\ninterface Query extends I18nBaseQuery {\n page?: number;\n}\n\nconst LocalePicker = () => {\n const { formatMessage } = useIntl();\n const [{ query }, setQuery] = useQueryParams<Query>();\n\n const { hasI18n, canRead, canCreate } = useI18n();\n const { data: locales = [] } = useGetLocalesQuery(undefined, {\n skip: !hasI18n,\n });\n\n const handleChange = React.useCallback(\n (code: string, replace = false) => {\n setQuery(\n {\n page: 1,\n plugins: { ...query.plugins, i18n: { locale: code } },\n },\n 'push',\n replace\n );\n },\n [query.plugins, setQuery]\n );\n\n React.useEffect(() => {\n if (!Array.isArray(locales) || !hasI18n) {\n return;\n }\n /**\n * Handle the case where the current locale query param doesn't exist\n * in the list of available locales, so we redirect to the default locale.\n */\n const currentDesiredLocale = query.plugins?.i18n?.locale;\n const doesLocaleExist = locales.find((loc) => loc.code === currentDesiredLocale);\n const defaultLocale = locales.find((locale) => locale.isDefault);\n if (!doesLocaleExist && defaultLocale?.code) {\n handleChange(defaultLocale.code, true);\n }\n }, [hasI18n, handleChange, locales, query.plugins?.i18n?.locale]);\n\n const sortedLocaleOptions = React.useMemo(() => {\n const displayedLocales = Array.isArray(locales)\n ? locales.filter((locale) => {\n /**\n * If you can create or read we allow you to see the locale exists\n * this is because in the ListView, you may be able to create a new entry\n * in a locale you can't read.\n */\n return canCreate.includes(locale.code) || canRead.includes(locale.code);\n })\n : [];\n\n return displayedLocales\n .sort((a, b) => a.name.localeCompare(b.name))\n .map((locale) => (\n <SingleSelectOption key={locale.id} value={locale.code}>\n {locale.name}\n </SingleSelectOption>\n ));\n }, [locales, canCreate, canRead]);\n\n if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {\n return null;\n }\n\n return (\n <SingleSelect\n size=\"S\"\n aria-label={formatMessage({\n id: getTranslation('actions.select-locale'),\n defaultMessage: 'Select locale',\n })}\n value={query.plugins?.i18n?.locale || locales.find((locale) => locale.isDefault)?.code}\n // @ts-expect-error – This can be removed in V2 of the DS.\n onChange={handleChange}\n >\n {sortedLocaleOptions}\n </SingleSelect>\n );\n};\n\nexport { LocalePicker };\n"],"names":["LocalePicker","formatMessage","useIntl","query","setQuery","useQueryParams","hasI18n","canRead","canCreate","useI18n","data","locales","useGetLocalesQuery","undefined","skip","handleChange","React","useCallback","code","replace","page","plugins","i18n","locale","useEffect","Array","isArray","currentDesiredLocale","doesLocaleExist","find","loc","defaultLocale","isDefault","sortedLocaleOptions","useMemo","displayedLocales","filter","includes","sort","a","b","name","localeCompare","map","_jsx","SingleSelectOption","value","id","length","SingleSelect","size","aria-label","getTranslation","defaultMessage","onChange"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAMA,Y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