@strapi/i18n 0.0.0-next.990615b2ed4dd2f0589b4fda91418246d7b9450e → 0.0.0-next.9c630ba4333dffc2c1c8150d9226dfbb67b02e09

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 (193) hide show
  1. package/dist/admin/components/CMHeaderActions.js +240 -4
  2. package/dist/admin/components/CMHeaderActions.js.map +1 -1
  3. package/dist/admin/components/CMHeaderActions.mjs +244 -9
  4. package/dist/admin/components/CMHeaderActions.mjs.map +1 -1
  5. package/dist/admin/components/CreateLocale.js +1 -1
  6. package/dist/admin/components/CreateLocale.js.map +1 -1
  7. package/dist/admin/components/CreateLocale.mjs +1 -1
  8. package/dist/admin/components/CreateLocale.mjs.map +1 -1
  9. package/dist/admin/components/EditLocale.js +1 -1
  10. package/dist/admin/components/EditLocale.js.map +1 -1
  11. package/dist/admin/components/EditLocale.mjs +1 -1
  12. package/dist/admin/components/EditLocale.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 -1
  38. package/dist/admin/index.js.map +1 -1
  39. package/dist/admin/index.mjs +2 -2
  40. package/dist/admin/index.mjs.map +1 -1
  41. package/dist/admin/middlewares/extendCTBAttributeInitialData.js +34 -24
  42. package/dist/admin/middlewares/extendCTBAttributeInitialData.js.map +1 -1
  43. package/dist/admin/middlewares/extendCTBAttributeInitialData.mjs +34 -24
  44. package/dist/admin/middlewares/extendCTBAttributeInitialData.mjs.map +1 -1
  45. package/dist/admin/pages/SettingsPage.js +121 -46
  46. package/dist/admin/pages/SettingsPage.js.map +1 -1
  47. package/dist/admin/pages/SettingsPage.mjs +124 -30
  48. package/dist/admin/pages/SettingsPage.mjs.map +1 -1
  49. package/dist/admin/services/aiLocalizationJobs.js +26 -0
  50. package/dist/admin/services/aiLocalizationJobs.js.map +1 -0
  51. package/dist/admin/services/aiLocalizationJobs.mjs +24 -0
  52. package/dist/admin/services/aiLocalizationJobs.mjs.map +1 -0
  53. package/dist/admin/services/api.js +4 -1
  54. package/dist/admin/services/api.js.map +1 -1
  55. package/dist/admin/services/api.mjs +4 -1
  56. package/dist/admin/services/api.mjs.map +1 -1
  57. package/dist/admin/services/locales.js +4 -2
  58. package/dist/admin/services/locales.js.map +1 -1
  59. package/dist/admin/services/locales.mjs +4 -2
  60. package/dist/admin/services/locales.mjs.map +1 -1
  61. package/dist/admin/services/settings.js +29 -0
  62. package/dist/admin/services/settings.js.map +1 -0
  63. package/dist/admin/services/settings.mjs +26 -0
  64. package/dist/admin/services/settings.mjs.map +1 -0
  65. package/dist/admin/src/components/CMHeaderActions.d.ts +17 -4
  66. package/dist/admin/src/components/LocaleListCell.d.ts +2 -1
  67. package/dist/admin/src/hooks/useAILocalizationJobsPolling.d.ts +9 -0
  68. package/dist/admin/src/services/aiLocalizationJobs.d.ts +6 -0
  69. package/dist/admin/src/services/api.d.ts +1 -1
  70. package/dist/admin/src/services/locales.d.ts +1 -1
  71. package/dist/admin/src/services/relations.d.ts +1 -1
  72. package/dist/admin/src/services/settings.d.ts +5 -0
  73. package/dist/admin/src/utils/schemas.d.ts +642 -16
  74. package/dist/admin/translations/en.json.js +10 -0
  75. package/dist/admin/translations/en.json.js.map +1 -1
  76. package/dist/admin/translations/en.json.mjs +10 -0
  77. package/dist/admin/translations/en.json.mjs.map +1 -1
  78. package/dist/admin/utils/clean.js +2 -2
  79. package/dist/admin/utils/clean.js.map +1 -1
  80. package/dist/admin/utils/clean.mjs +2 -2
  81. package/dist/admin/utils/clean.mjs.map +1 -1
  82. package/dist/admin/utils/fields.js +6 -1
  83. package/dist/admin/utils/fields.js.map +1 -1
  84. package/dist/admin/utils/fields.mjs +6 -1
  85. package/dist/admin/utils/fields.mjs.map +1 -1
  86. package/dist/admin/utils/schemas.js +19 -13
  87. package/dist/admin/utils/schemas.js.map +1 -1
  88. package/dist/admin/utils/schemas.mjs +19 -13
  89. package/dist/admin/utils/schemas.mjs.map +1 -1
  90. package/dist/server/bootstrap.js +2 -0
  91. package/dist/server/bootstrap.js.map +1 -1
  92. package/dist/server/bootstrap.mjs +2 -0
  93. package/dist/server/bootstrap.mjs.map +1 -1
  94. package/dist/server/constants/iso-locales.json.js +4 -0
  95. package/dist/server/constants/iso-locales.json.js.map +1 -1
  96. package/dist/server/constants/iso-locales.json.mjs +4 -0
  97. package/dist/server/constants/iso-locales.json.mjs.map +1 -1
  98. package/dist/server/controllers/ai-localization-jobs.js +47 -0
  99. package/dist/server/controllers/ai-localization-jobs.js.map +1 -0
  100. package/dist/server/controllers/ai-localization-jobs.mjs +45 -0
  101. package/dist/server/controllers/ai-localization-jobs.mjs.map +1 -0
  102. package/dist/server/controllers/index.js +5 -1
  103. package/dist/server/controllers/index.js.map +1 -1
  104. package/dist/server/controllers/index.mjs +5 -1
  105. package/dist/server/controllers/index.mjs.map +1 -1
  106. package/dist/server/controllers/settings.js +24 -0
  107. package/dist/server/controllers/settings.js.map +1 -0
  108. package/dist/server/controllers/settings.mjs +22 -0
  109. package/dist/server/controllers/settings.mjs.map +1 -0
  110. package/dist/server/models/ai-localization-job.js +60 -0
  111. package/dist/server/models/ai-localization-job.js.map +1 -0
  112. package/dist/server/models/ai-localization-job.mjs +57 -0
  113. package/dist/server/models/ai-localization-job.mjs.map +1 -0
  114. package/dist/server/register.js +3 -1
  115. package/dist/server/register.js.map +1 -1
  116. package/dist/server/register.mjs +3 -1
  117. package/dist/server/register.mjs.map +1 -1
  118. package/dist/server/routes/admin.js +40 -0
  119. package/dist/server/routes/admin.js.map +1 -1
  120. package/dist/server/routes/admin.mjs +40 -0
  121. package/dist/server/routes/admin.mjs.map +1 -1
  122. package/dist/server/routes/content-api.js +11 -7
  123. package/dist/server/routes/content-api.js.map +1 -1
  124. package/dist/server/routes/content-api.mjs +11 -7
  125. package/dist/server/routes/content-api.mjs.map +1 -1
  126. package/dist/server/routes/index.mjs +2 -2
  127. package/dist/server/routes/validation/locale.js +57 -0
  128. package/dist/server/routes/validation/locale.js.map +1 -0
  129. package/dist/server/routes/validation/locale.mjs +36 -0
  130. package/dist/server/routes/validation/locale.mjs.map +1 -0
  131. package/dist/server/services/ai-localization-jobs.js +64 -0
  132. package/dist/server/services/ai-localization-jobs.js.map +1 -0
  133. package/dist/server/services/ai-localization-jobs.mjs +62 -0
  134. package/dist/server/services/ai-localization-jobs.mjs.map +1 -0
  135. package/dist/server/services/ai-localizations.js +272 -0
  136. package/dist/server/services/ai-localizations.js.map +1 -0
  137. package/dist/server/services/ai-localizations.mjs +270 -0
  138. package/dist/server/services/ai-localizations.mjs.map +1 -0
  139. package/dist/server/services/index.js +7 -1
  140. package/dist/server/services/index.js.map +1 -1
  141. package/dist/server/services/index.mjs +7 -1
  142. package/dist/server/services/index.mjs.map +1 -1
  143. package/dist/server/services/settings.js +25 -0
  144. package/dist/server/services/settings.js.map +1 -0
  145. package/dist/server/services/settings.mjs +23 -0
  146. package/dist/server/services/settings.mjs.map +1 -0
  147. package/dist/server/src/bootstrap.d.ts.map +1 -1
  148. package/dist/server/src/controllers/ai-localization-jobs.d.ts +17 -0
  149. package/dist/server/src/controllers/ai-localization-jobs.d.ts.map +1 -0
  150. package/dist/server/src/controllers/index.d.ts +10 -0
  151. package/dist/server/src/controllers/index.d.ts.map +1 -1
  152. package/dist/server/src/controllers/settings.d.ts +7 -0
  153. package/dist/server/src/controllers/settings.d.ts.map +1 -0
  154. package/dist/server/src/index.d.ts +47 -8
  155. package/dist/server/src/index.d.ts.map +1 -1
  156. package/dist/server/src/models/ai-localization-job.d.ts +5 -0
  157. package/dist/server/src/models/ai-localization-job.d.ts.map +1 -0
  158. package/dist/server/src/models/index.d.ts +5 -0
  159. package/dist/server/src/models/index.d.ts.map +1 -0
  160. package/dist/server/src/register.d.ts +1 -1
  161. package/dist/server/src/register.d.ts.map +1 -1
  162. package/dist/server/src/routes/admin.d.ts.map +1 -1
  163. package/dist/server/src/routes/content-api.d.ts +5 -8
  164. package/dist/server/src/routes/content-api.d.ts.map +1 -1
  165. package/dist/server/src/routes/index.d.ts +3 -7
  166. package/dist/server/src/routes/index.d.ts.map +1 -1
  167. package/dist/server/src/routes/validation/index.d.ts +2 -0
  168. package/dist/server/src/routes/validation/index.d.ts.map +1 -0
  169. package/dist/server/src/routes/validation/locale.d.ts +41 -0
  170. package/dist/server/src/routes/validation/locale.d.ts.map +1 -0
  171. package/dist/server/src/services/ai-localization-jobs.d.ts +26 -0
  172. package/dist/server/src/services/ai-localization-jobs.d.ts.map +1 -0
  173. package/dist/server/src/services/ai-localizations.d.ts +18 -0
  174. package/dist/server/src/services/ai-localizations.d.ts.map +1 -0
  175. package/dist/server/src/services/index.d.ts +33 -0
  176. package/dist/server/src/services/index.d.ts.map +1 -1
  177. package/dist/server/src/services/settings.d.ts +13 -0
  178. package/dist/server/src/services/settings.d.ts.map +1 -0
  179. package/dist/server/src/utils/index.d.ts +7 -1
  180. package/dist/server/src/utils/index.d.ts.map +1 -1
  181. package/dist/server/src/validation/settings.d.ts +12 -0
  182. package/dist/server/src/validation/settings.d.ts.map +1 -0
  183. package/dist/server/utils/index.js.map +1 -1
  184. package/dist/server/utils/index.mjs.map +1 -1
  185. package/dist/server/validation/settings.js +11 -0
  186. package/dist/server/validation/settings.js.map +1 -0
  187. package/dist/server/validation/settings.mjs +9 -0
  188. package/dist/server/validation/settings.mjs.map +1 -0
  189. package/dist/shared/contracts/ai-localization-jobs.d.ts +27 -0
  190. package/dist/shared/contracts/ai-localization-jobs.d.ts.map +1 -0
  191. package/dist/shared/contracts/settings.d.ts +40 -0
  192. package/dist/shared/contracts/shared.d.ts.map +1 -0
  193. package/package.json +12 -9
@@ -1 +1 @@
1
- {"version":3,"file":"CreateLocale.js","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","InputRender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AAAA,MAAAA,CAAOxB;AADoCwB,qBAAAA,EAAAA,MAAAA,CAAOhD,KAAK,CAAA;;AAK9D,0BAAAlE,cAAA,CAAC+G,mBAAMK,KAAK,EAAA,EAAA,CAAA;AACZ,0BAAApH,cAAA,CAAC+G,mBAAMM,IAAI,EAAA,EAAA;;;AAGjB,CAAA;;;;;;;;"}
1
+ {"version":3,"file":"CreateLocale.js","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,iBAAAA,EAAAA;AAC1B,IAAA,MAAM,CAACC,OAASC,EAAAA,UAAAA,CAAW,GAAGC,gBAAAA,CAAMC,QAAQ,CAAC,KAAA,CAAA;IAE7C,qBACEC,eAAA,CAACC,mBAAMC,IAAI,EAAA;QAACC,IAAMP,EAAAA,OAAAA;QAASQ,YAAcP,EAAAA,UAAA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AAA,QAAAA,CAASvF,IAAM8C,EAAAA,KAAAA,CAAAA;;YAEfyC,QAAS,CAAA,MAAA,EAAQlB,OAAOrE,IAAI,CAAA;SACvB,MAAA;AACLuF,YAAAA,QAAAA,CAASvF,IAAM8C,EAAAA,KAAAA,CAAAA;AACjB;AACF,KAAA;IAEA,qBACEvE,eAAA,CAACoH,mBAAMlH,IAAI,EAAA;QAAC+C,KAAOA,EAAAA,KAAAA;QAAOiD,IAAMA,EAAAA,IAAAA;QAAMzE,IAAMA,EAAAA,IAAAA;QAAMD,QAAUA,EAAAA,QAAAA;;AAC1D,0BAAAnB,cAAA,CAAC+G,mBAAMC,KAAK,EAAA;AAAEtB,gBAAAA,QAAAA,EAAAA;;0BACd1F,cAACiH,CAAAA,yBAAAA,EAAAA;gBACC9H,QAAUA,EAAAA,QAAAA;;gBAEVwH,QAAUE,EAAAA,YAAAA;gBACVjB,WAAaA,EAAAA,WAAAA;gBACb1B,KAAOA,EAAAA,KAAAA;AAENqB,gBAAAA,QAAAA,EAAAA,OAAAA,CAAQC,GAAG,CAAC,CAAC0B,MAAAA,iBACZlH,cAACmH,CAAAA,+BAAAA,EAAAA;AAAmBjD,wBAAAA,KAAAA,EAAOgD,OAAOhD,KAAK;AACpCgD,wBAAAA,QAAAA,EAAAA,MAAAA,CAAOxB;AADoCwB,qBAAAA,EAAAA,MAAAA,CAAOhD,KAAK,CAAA;;AAK9D,0BAAAlE,cAAA,CAAC+G,mBAAMK,KAAK,EAAA,EAAA,CAAA;AACZ,0BAAApH,cAAA,CAAC+G,mBAAMM,IAAI,EAAA,EAAA;;;AAGjB,CAAA;;;;;;;;"}
@@ -81,7 +81,7 @@ const CreateModal = ({ onClose })=>{
81
81
  type: 'success',
82
82
  message: formatMessage({
83
83
  id: getTranslation('Settings.locales.modal.create.success'),
84
- defaultMessage: 'Created locale'
84
+ defaultMessage: 'Locale successfully added'
85
85
  })
86
86
  });
87
87
  refetchPermissions();
@@ -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,IAA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AAA;QAAMD,QAAUA,EAAAA,QAAAA;;AAC1D,0BAAAnB,GAAA,CAAC+G,MAAMC,KAAK,EAAA;AAAEtB,gBAAAA,QAAAA,EAAAA;;0BACd1F,GAACiH,CAAAA,YAAAA,EAAAA;gBACC9H,QAAUA,EAAAA,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 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,CAAAA,WAAAA,EAAAA;AAAYC,gBAAAA,OAAAA,EAAS,IAAMnB,UAAW,CAAA,KAAA;;;;AAG7C;AAEA;;AAEkG,2GAE5FoB,aAAgBC,GAAAA,GAAAA,CAAIC,MAAM,EAAA,CAAGC,KAAK,CAAC;AACvCC,IAAAA,IAAAA,EAAMH,IAAII,MAAM,EAAA,CAAGC,QAAQ,EAAA,CAAGC,QAAQ,CAAC;QACrCZ,EAAI,EAAA,0CAAA;QACJE,cAAgB,EAAA;AAClB,KAAA,CAAA;AACAW,IAAAA,IAAAA,EAA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AAK9D,0BAAAlE,GAAA,CAAC+G,MAAMK,KAAK,EAAA,EAAA,CAAA;AACZ,0BAAApH,GAAA,CAAC+G,MAAMM,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,GAAG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A,EAAAA,EAAAA;;;;;;;AAMb;;;;;"}
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,I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AAA;oDAACC,KAAM,EAAA,UAAA;8DACjBrE,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;;0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CAAAA,OAAAA,EAAAA,EAAAA,CAAAA;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;;0B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A,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,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
  });