@strapi/content-manager 5.52.1 → 5.52.3

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 (92) hide show
  1. package/dist/admin/components/ConfigurationForm/Fields.js +6 -3
  2. package/dist/admin/components/ConfigurationForm/Fields.js.map +1 -1
  3. package/dist/admin/components/ConfigurationForm/Fields.mjs +6 -3
  4. package/dist/admin/components/ConfigurationForm/Fields.mjs.map +1 -1
  5. package/dist/admin/history/components/VersionInputRenderer.js +5 -1
  6. package/dist/admin/history/components/VersionInputRenderer.js.map +1 -1
  7. package/dist/admin/history/components/VersionInputRenderer.mjs +5 -1
  8. package/dist/admin/history/components/VersionInputRenderer.mjs.map +1 -1
  9. package/dist/admin/hooks/usePersistentQueryParams.js +10 -2
  10. package/dist/admin/hooks/usePersistentQueryParams.js.map +1 -1
  11. package/dist/admin/hooks/usePersistentQueryParams.mjs +11 -3
  12. package/dist/admin/hooks/usePersistentQueryParams.mjs.map +1 -1
  13. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +29 -11
  14. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
  15. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +29 -11
  16. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
  17. package/dist/admin/pages/ListView/ListViewPage.js +3 -3
  18. package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
  19. package/dist/admin/pages/ListView/ListViewPage.mjs +4 -4
  20. package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
  21. package/dist/admin/pages/ListView/components/TableCells/Relations.js +11 -2
  22. package/dist/admin/pages/ListView/components/TableCells/Relations.js.map +1 -1
  23. package/dist/admin/pages/ListView/components/TableCells/Relations.mjs +11 -2
  24. package/dist/admin/pages/ListView/components/TableCells/Relations.mjs.map +1 -1
  25. package/dist/admin/src/utils/relations.d.ts +4 -3
  26. package/dist/admin/translations/cs.json.js +1 -0
  27. package/dist/admin/translations/cs.json.js.map +1 -1
  28. package/dist/admin/translations/cs.json.mjs +1 -0
  29. package/dist/admin/translations/cs.json.mjs.map +1 -1
  30. package/dist/admin/translations/de.json.js +1 -0
  31. package/dist/admin/translations/de.json.js.map +1 -1
  32. package/dist/admin/translations/de.json.mjs +1 -0
  33. package/dist/admin/translations/de.json.mjs.map +1 -1
  34. package/dist/admin/translations/en.json.js +1 -0
  35. package/dist/admin/translations/en.json.js.map +1 -1
  36. package/dist/admin/translations/en.json.mjs +1 -0
  37. package/dist/admin/translations/en.json.mjs.map +1 -1
  38. package/dist/admin/translations/fr.json.js +1 -0
  39. package/dist/admin/translations/fr.json.js.map +1 -1
  40. package/dist/admin/translations/fr.json.mjs +1 -0
  41. package/dist/admin/translations/fr.json.mjs.map +1 -1
  42. package/dist/admin/translations/ja.json.js +1 -0
  43. package/dist/admin/translations/ja.json.js.map +1 -1
  44. package/dist/admin/translations/ja.json.mjs +1 -0
  45. package/dist/admin/translations/ja.json.mjs.map +1 -1
  46. package/dist/admin/translations/ko.json.js +1 -0
  47. package/dist/admin/translations/ko.json.js.map +1 -1
  48. package/dist/admin/translations/ko.json.mjs +1 -0
  49. package/dist/admin/translations/ko.json.mjs.map +1 -1
  50. package/dist/admin/translations/nl.json.js +1 -0
  51. package/dist/admin/translations/nl.json.js.map +1 -1
  52. package/dist/admin/translations/nl.json.mjs +1 -0
  53. package/dist/admin/translations/nl.json.mjs.map +1 -1
  54. package/dist/admin/translations/pl.json.js +1 -0
  55. package/dist/admin/translations/pl.json.js.map +1 -1
  56. package/dist/admin/translations/pl.json.mjs +1 -0
  57. package/dist/admin/translations/pl.json.mjs.map +1 -1
  58. package/dist/admin/translations/pt-BR.json.js +5 -5
  59. package/dist/admin/translations/pt-BR.json.mjs +5 -5
  60. package/dist/admin/translations/sk.json.js +1 -0
  61. package/dist/admin/translations/sk.json.js.map +1 -1
  62. package/dist/admin/translations/sk.json.mjs +1 -0
  63. package/dist/admin/translations/sk.json.mjs.map +1 -1
  64. package/dist/admin/utils/relations.js +9 -4
  65. package/dist/admin/utils/relations.js.map +1 -1
  66. package/dist/admin/utils/relations.mjs +9 -4
  67. package/dist/admin/utils/relations.mjs.map +1 -1
  68. package/dist/server/controllers/collection-types.js +1 -1
  69. package/dist/server/controllers/collection-types.js.map +1 -1
  70. package/dist/server/controllers/collection-types.mjs +1 -1
  71. package/dist/server/controllers/collection-types.mjs.map +1 -1
  72. package/dist/server/history/services/history.js +22 -4
  73. package/dist/server/history/services/history.js.map +1 -1
  74. package/dist/server/history/services/history.mjs +22 -4
  75. package/dist/server/history/services/history.mjs.map +1 -1
  76. package/dist/server/mcp/schemas/data-schema.js +6 -1
  77. package/dist/server/mcp/schemas/data-schema.js.map +1 -1
  78. package/dist/server/mcp/schemas/data-schema.mjs +6 -1
  79. package/dist/server/mcp/schemas/data-schema.mjs.map +1 -1
  80. package/dist/server/services/permission-checker.js +0 -4
  81. package/dist/server/services/permission-checker.js.map +1 -1
  82. package/dist/server/services/permission-checker.mjs +0 -4
  83. package/dist/server/services/permission-checker.mjs.map +1 -1
  84. package/dist/server/src/history/services/history.d.ts.map +1 -1
  85. package/dist/server/src/index.d.ts +4 -4
  86. package/dist/server/src/index.d.ts.map +1 -1
  87. package/dist/server/src/mcp/schemas/data-schema.d.ts.map +1 -1
  88. package/dist/server/src/services/index.d.ts +4 -4
  89. package/dist/server/src/services/index.d.ts.map +1 -1
  90. package/dist/server/src/services/permission-checker.d.ts +2 -2
  91. package/dist/server/src/services/permission-checker.d.ts.map +1 -1
  92. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"VersionInputRenderer.mjs","sources":["../../../../admin/src/history/components/VersionInputRenderer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useStrapiApp,\n useForm,\n InputRenderer as FormInputRenderer,\n useField,\n Form,\n} from '@strapi/admin/strapi-admin';\nimport { Alert, Box, Field, Flex, Link, Tooltip, Typography } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { NavLink } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { COLLECTION_TYPES } from '../../constants/collections';\nimport { useDocumentRBAC } from '../../features/DocumentRBAC';\nimport { useDoc } from '../../hooks/useDocument';\nimport { useDocLayout } from '../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../hooks/useLazyComponents';\nimport { useTypedSelector } from '../../modules/hooks';\nimport { DocumentStatus } from '../../pages/EditView/components/DocumentStatus';\nimport { BlocksInput } from '../../pages/EditView/components/FormInputs/BlocksInput/BlocksInput';\nimport { ComponentInput } from '../../pages/EditView/components/FormInputs/Component/Input';\nimport {\n DynamicZone,\n useDynamicZone,\n} from '../../pages/EditView/components/FormInputs/DynamicZone/Field';\nimport { NotAllowedInput } from '../../pages/EditView/components/FormInputs/NotAllowed';\nimport { UIDInput } from '../../pages/EditView/components/FormInputs/UID';\nimport { Wysiwyg } from '../../pages/EditView/components/FormInputs/Wysiwyg/Field';\nimport { useFieldHint } from '../../pages/EditView/components/InputRenderer';\nimport { getRelationLabel } from '../../utils/relations';\nimport { useHistoryContext } from '../pages/History';\n\nimport { getRemaingFieldsLayout } from './VersionContent';\n\nimport type { EditFieldLayout } from '../../hooks/useDocumentLayout';\nimport type { RelationsFieldProps } from '../../pages/EditView/components/FormInputs/Relations/Relations';\nimport type { RelationResult } from '../../services/relations';\nimport type { Schema } from '@strapi/types';\nimport type { DistributiveOmit } from 'react-redux';\n\nconst StyledAlert = styled(Alert).attrs({ closeLabel: 'Close', onClose: () => {}, shadow: 'none' })`\n button {\n display: none;\n }\n`;\n\n/* -------------------------------------------------------------------------------------------------\n * CustomRelationInput\n * -----------------------------------------------------------------------------------------------*/\n\nconst LinkEllipsis = styled(Link)`\n display: block;\n\n & > span {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n display: block;\n }\n`;\n\nconst CustomRelationInput = (props: RelationsFieldProps) => {\n const { formatMessage } = useIntl();\n const field = useField<\n { results: RelationResult[]; meta: { missingCount: number } } | RelationResult[]\n >(props.name);\n\n /**\n * Ideally the server would return the correct shape, however, for admin user relations\n * it sanitizes everything out when it finds an object for the relation value.\n */\n let formattedFieldValue;\n if (field) {\n formattedFieldValue = Array.isArray(field.value)\n ? { results: field.value, meta: { missingCount: 0 } }\n : field.value;\n }\n\n // Be defensive about the shape: admin-user relations are sanitized to a\n // plain user object on the server, and historical version data can carry\n // shapes that pre-date the `{ results, meta }` contract. Treat anything\n // without an array `results` as \"no relations\".\n const hasResultsShape =\n !!formattedFieldValue &&\n typeof formattedFieldValue === 'object' &&\n Array.isArray((formattedFieldValue as { results?: unknown }).results);\n const missingCount =\n hasResultsShape &&\n typeof (formattedFieldValue as { meta?: { missingCount?: number } }).meta?.missingCount ===\n 'number'\n ? (formattedFieldValue as { meta: { missingCount: number } }).meta.missingCount\n : 0;\n\n if (\n !hasResultsShape ||\n ((formattedFieldValue as { results: unknown[] }).results.length === 0 && missingCount === 0)\n ) {\n return (\n <>\n <Field.Label action={props.labelAction}>{props.label}</Field.Label>\n <Box marginTop={1}>\n <StyledAlert variant=\"default\">\n {formatMessage({\n id: 'content-manager.history.content.no-relations',\n defaultMessage: 'No relations.',\n })}\n </StyledAlert>\n </Box>\n </>\n );\n }\n\n const { results, meta } = formattedFieldValue as {\n results: RelationResult[];\n meta: { missingCount: number };\n };\n\n return (\n <Box>\n <Field.Label>{props.label}</Field.Label>\n {results.length > 0 && (\n <Flex direction=\"column\" gap={2} marginTop={1} alignItems=\"stretch\">\n {results.map((relationData) => {\n // @ts-expect-error - targetModel does exist on the attribute. But it's not typed.\n const { targetModel } = props.attribute;\n const href = `../${COLLECTION_TYPES}/${targetModel}/${relationData.documentId}`;\n const label = getRelationLabel(relationData, props.mainField);\n const isAdminUserRelation = targetModel === 'admin::user';\n\n return (\n <Flex\n key={relationData.documentId ?? relationData.id}\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={4}\n paddingRight={4}\n hasRadius\n borderColor=\"neutral200\"\n background=\"neutral150\"\n justifyContent=\"space-between\"\n >\n <Box minWidth={0} paddingTop={1} paddingBottom={1} paddingRight={4}>\n <Tooltip label={label}>\n {isAdminUserRelation ? (\n <Typography>{label}</Typography>\n ) : (\n <LinkEllipsis tag={NavLink} to={href}>\n {label}\n </LinkEllipsis>\n )}\n </Tooltip>\n </Box>\n <DocumentStatus status={relationData.status as string} />\n </Flex>\n );\n })}\n </Flex>\n )}\n {meta.missingCount > 0 && (\n <StyledAlert\n marginTop={1}\n variant=\"warning\"\n title={formatMessage(\n {\n id: 'content-manager.history.content.missing-relations.title',\n defaultMessage:\n '{number, plural, =1 {Missing relation} other {{number} missing relations}}',\n },\n { number: meta.missingCount }\n )}\n >\n {formatMessage(\n {\n id: 'content-manager.history.content.missing-relations.message',\n defaultMessage:\n \"{number, plural, =1 {It has} other {They have}} been deleted and can't be restored.\",\n },\n { number: meta.missingCount }\n )}\n </StyledAlert>\n )}\n </Box>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * CustomMediaInput\n * -----------------------------------------------------------------------------------------------*/\n\n// Create an object with value at key path (i.e. 'a.b.c')\nconst createInitialValuesForPath = (keyPath: string, value: unknown) => {\n const keys = keyPath.split('.');\n // The root level object\n const root: Record<string, unknown> = {};\n\n // Make the first node the root\n let node = root;\n keys.forEach((key, index) => {\n // Skip prototype pollution keys\n if (key === '__proto__' || key === 'constructor') return;\n // If it's the last key, set the node value\n if (index === keys.length - 1) {\n node[key] = value;\n } else {\n // Ensure the key exists and is an object\n const nextNode =\n typeof node[key] === 'object' && node[key] !== null && Array.isArray(node[key]) === false\n ? (node[key] as Record<string, unknown>)\n : {};\n node[key] = nextNode;\n node = nextNode;\n }\n });\n\n return root;\n};\n\nconst CustomMediaInput = (props: VersionInputRendererProps) => {\n const { value } = useField<{ results: unknown[]; meta: { missingCount: number } }>(props.name);\n const results = value?.results ?? [];\n const meta = value?.meta ?? { missingCount: 0 };\n\n const { formatMessage } = useIntl();\n\n const fields = useStrapiApp('CustomMediaInput', (state) => state.fields);\n const MediaLibrary = fields.media as React.ComponentType<\n VersionInputRendererProps & { multiple: boolean }\n >;\n\n return (\n <Flex direction=\"column\" gap={2} alignItems=\"stretch\">\n <Form\n method=\"PUT\"\n disabled={true}\n initialValues={createInitialValuesForPath(props.name, results)}\n >\n <MediaLibrary {...props} disabled={true} multiple={results.length > 1} />\n </Form>\n {meta.missingCount > 0 && (\n <StyledAlert\n variant=\"warning\"\n closeLabel=\"Close\"\n onClose={() => {}}\n title={formatMessage(\n {\n id: 'content-manager.history.content.missing-assets.title',\n defaultMessage:\n '{number, plural, =1 {Missing asset} other {{number} missing assets}}',\n },\n { number: meta.missingCount }\n )}\n >\n {formatMessage(\n {\n id: 'content-manager.history.content.missing-assets.message',\n defaultMessage:\n \"{number, plural, =1 {It has} other {They have}} been deleted in the Media Library and can't be restored.\",\n },\n { number: meta.missingCount }\n )}\n </StyledAlert>\n )}\n </Flex>\n );\n};\n\ntype VersionInputRendererProps = DistributiveOmit<EditFieldLayout, 'size'> & {\n /**\n * In the context of content history, deleted fields need to ignore RBAC\n * @default false\n */\n shouldIgnoreRBAC?: boolean;\n};\n\n/**\n * Checks if the i18n plugin added a label action to the field and modifies it\n * to adapt the wording for the history page.\n */\nconst getLabelAction = (labelAction: VersionInputRendererProps['labelAction']) => {\n if (!React.isValidElement(labelAction)) {\n return labelAction;\n }\n\n // TODO: find a better way to do this rather than access internals\n const labelActionTitleId = labelAction.props.title.id;\n\n if (labelActionTitleId === 'i18n.Field.localized') {\n return React.cloneElement(labelAction, {\n ...labelAction.props,\n title: {\n id: 'history.content.localized',\n defaultMessage:\n 'This value is specific to this locale. If you restore this version, the content will not be replaced for other locales.',\n },\n });\n }\n\n if (labelActionTitleId === 'i18n.Field.not-localized') {\n return React.cloneElement(labelAction, {\n ...labelAction.props,\n title: {\n id: 'history.content.not-localized',\n defaultMessage:\n 'This value is common to all locales. If you restore this version and save the changes, the content will be replaced for all locales.',\n },\n });\n }\n\n // Label action is unrelated to i18n, don't touch it.\n return labelAction;\n};\n\n/**\n * Resolve the layout, configuration metadata and schema attributes needed to\n * render a component field on the history page. Returns `null` when any of\n * those are missing — happens when the component schema referenced by the\n * version was deleted via the Content-Type Builder, in which case the caller\n * should render a fallback instead of crashing on the destructuring.\n */\nconst resolveComponentRenderResources = (\n componentUID: string,\n componentsLayout: { [uid: string]: { layout: unknown } | undefined },\n configurationComponents: { [uid: string]: { metadatas: unknown } | undefined },\n components: { [uid: string]: { attributes: unknown } | undefined }\n) => {\n const componentLayout = componentsLayout[componentUID];\n const componentConfiguration = configurationComponents[componentUID];\n const componentSchema = components[componentUID];\n\n if (!componentLayout || !componentConfiguration || !componentSchema) {\n return null;\n }\n\n return {\n layout: componentLayout.layout,\n metadatas: componentConfiguration.metadatas,\n schemaAttributes: componentSchema.attributes,\n };\n};\n\n/**\n * @internal\n *\n * @description An abstraction around the regular form input renderer designed specifically\n * to be used on the History page in the content-manager. It understands how to render specific\n * inputs within the context of a history version (i.e. relations, media, ignored RBAC, etc...)\n */\nconst VersionInputRenderer = ({\n visible,\n hint: providedHint,\n shouldIgnoreRBAC = false,\n labelAction,\n ...props\n}: VersionInputRendererProps) => {\n const customLabelAction = getLabelAction(labelAction);\n\n const { formatMessage } = useIntl();\n const version = useHistoryContext('VersionContent', (state) => state.selectedVersion);\n const configuration = useHistoryContext('VersionContent', (state) => state.configuration);\n const fieldSizes = useTypedSelector((state) => state['content-manager'].app.fieldSizes);\n\n const { id, components } = useDoc();\n const isFormDisabled = useForm('InputRenderer', (state) => state.disabled);\n\n const isInDynamicZone = useDynamicZone('isInDynamicZone', (state) => state.isInDynamicZone);\n\n const canCreateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canCreateFields);\n const canReadFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canReadFields);\n const canUpdateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUpdateFields);\n const canUserAction = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUserAction);\n\n const editableFields = id ? canUpdateFields : canCreateFields;\n const readableFields = id ? canReadFields : canCreateFields;\n /**\n * Component fields are always readable and editable,\n * however the fields within them may not be.\n */\n const canUserReadField = canUserAction(props.name, readableFields, props.type);\n const canUserEditField = canUserAction(props.name, editableFields, props.type);\n\n const fields = useStrapiApp('InputRenderer', (app) => app.fields);\n const { lazyComponentStore } = useLazyComponents(\n attributeHasCustomFieldProperty(props.attribute) ? [props.attribute.customField] : undefined\n );\n\n const hint = useFieldHint(providedHint, props.attribute);\n const {\n edit: { components: componentsLayout },\n } = useDocLayout();\n\n if (!visible) {\n return null;\n }\n\n /**\n * Don't render the field if the user can't read it.\n */\n if (!shouldIgnoreRBAC && !canUserReadField && !isInDynamicZone) {\n return <NotAllowedInput hint={hint} {...props} />;\n }\n\n const fieldIsDisabled =\n (!canUserEditField && !isInDynamicZone) || props.disabled || isFormDisabled;\n\n /**\n * Attributes found on the current content-type schema cannot be restored. We handle\n * this by displaying a warning alert to the user instead of the input for that field type.\n */\n const addedAttributes = version.meta.unknownAttributes.added;\n if (Object.keys(addedAttributes).includes(props.name)) {\n return (\n <Flex direction=\"column\" alignItems=\"flex-start\" gap={1}>\n <Field.Label>{props.label}</Field.Label>\n <StyledAlert\n width=\"100%\"\n closeLabel=\"Close\"\n onClose={() => {}}\n variant=\"warning\"\n title={formatMessage({\n id: 'content-manager.history.content.new-field.title',\n defaultMessage: 'New field',\n })}\n >\n {formatMessage({\n id: 'content-manager.history.content.new-field.message',\n defaultMessage:\n \"This field didn't exist when this version was saved. If you restore this version, it will be empty.\",\n })}\n </StyledAlert>\n </Flex>\n );\n }\n\n /**\n * Because a custom field has a unique prop but the type could be confused with either\n * the useField hook or the type of the field we need to handle it separately and first.\n */\n if (attributeHasCustomFieldProperty(props.attribute)) {\n const CustomInput = lazyComponentStore[props.attribute.customField];\n\n if (CustomInput) {\n return (\n <CustomInput\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n return (\n <FormInputRenderer\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n // @ts-expect-error – this workaround lets us display that the custom field is missing.\n type={props.attribute.customField}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * Since media fields use a custom input via the upload plugin provided by the useLibrary hook,\n * we need to handle the them before other custom inputs coming from the useLibrary hook.\n */\n if (props.type === 'media') {\n return (\n <CustomMediaInput {...props} labelAction={customLabelAction} disabled={fieldIsDisabled} />\n );\n }\n /**\n * This is where we handle ONLY the fields from the `useLibrary` hook.\n */\n const addedInputTypes = Object.keys(fields);\n if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {\n const CustomInput = fields[props.type];\n return (\n <CustomInput\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLibrary hook.\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * These include the content-manager specific fields, failing that we fall back\n * to the more generic form input renderer.\n */\n switch (props.type) {\n case 'blocks':\n return <BlocksInput {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n case 'component': {\n const renderResources = resolveComponentRenderResources(\n props.attribute.component,\n componentsLayout,\n configuration.components,\n components\n );\n\n // The component schema referenced by this version is no longer present\n // (deleted via the Content-Type Builder). Render the label only so the\n // rest of the page still loads instead of crashing on the lookups below.\n if (!renderResources) {\n return <Field.Label>{props.label}</Field.Label>;\n }\n\n const { layout, metadatas, schemaAttributes } = renderResources as {\n layout: Array<EditFieldLayout[]>;\n metadatas: Parameters<typeof getRemaingFieldsLayout>[0]['metadatas'];\n schemaAttributes: Parameters<typeof getRemaingFieldsLayout>[0]['schemaAttributes'];\n };\n\n // Components can only have one panel, so only save the first layout item\n const [remainingFieldsLayout] = getRemaingFieldsLayout({\n layout: [layout],\n metadatas,\n fieldSizes,\n schemaAttributes,\n });\n\n return (\n <ComponentInput\n {...props}\n layout={[...layout, ...(remainingFieldsLayout || [])]}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n >\n {(inputProps) => <VersionInputRenderer {...inputProps} shouldIgnoreRBAC={true} />}\n </ComponentInput>\n );\n }\n case 'dynamiczone':\n return (\n <DynamicZone\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n >\n {(inputProps) => <VersionInputRenderer {...inputProps} shouldIgnoreRBAC={true} />}\n </DynamicZone>\n );\n case 'relation':\n return (\n <CustomRelationInput\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n case 'richtext':\n return (\n <Wysiwyg\n {...props}\n hint={hint}\n type={props.type}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n case 'uid':\n return (\n <UIDInput\n {...props}\n hint={hint}\n type={props.type}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n /**\n * Enumerations are a special case because they require options.\n */\n case 'enumeration':\n return (\n <FormInputRenderer\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n options={props.attribute.enum.map((value) => ({ value }))}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n default:\n // These props are not needed for the generic form input renderer.\n const { unique: _unique, mainField: _mainField, ...restProps } = props;\n return (\n <FormInputRenderer\n {...restProps}\n hint={hint}\n labelAction={customLabelAction}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n }\n};\n\nconst attributeHasCustomFieldProperty = (\n attribute: Schema.Attribute.AnyAttribute\n): attribute is Schema.Attribute.AnyAttribute & Schema.Attribute.CustomField<string> =>\n 'customField' in attribute && typeof attribute.customField === 'string';\n\nexport type { VersionInputRendererProps };\nexport { VersionInputRenderer, CustomRelationInput, resolveComponentRenderResources };\n"],"names":["StyledAlert","styled","Alert","attrs","closeLabel","onClose","shadow","LinkEllipsis","Link","CustomRelationInput","props","formatMessage","useIntl","field","useField","name","formattedFieldValue","Array","isArray","value","results","meta","missingCount","hasResultsShape","length","_jsxs","_Fragment","_jsx","Field","Label","action","labelAction","label","Box","marginTop","variant","id","defaultMessage","Flex","direction","gap","alignItems","map","relationData","targetModel","attribute","href","COLLECTION_TYPES","documentId","getRelationLabel","mainField","isAdminUserRelation","paddingTop","paddingBottom","paddingLeft","paddingRight","hasRadius","borderColor","background","justifyContent","minWidth","Tooltip","Typography","tag","NavLink","to","DocumentStatus","status","title","number","createInitialValuesForPath","keyPath","keys","split","root","node","forEach","key","index","nextNode","CustomMediaInput","fields","useStrapiApp","state","MediaLibrary","media","Form","method","disabled","initialValues","multiple","getLabelAction","React","isValidElement","labelActionTitleId","cloneElement","resolveComponentRenderResources","componentUID","componentsLayout","configurationComponents","components","componentLayout","componentConfiguration","componentSchema","layout","metadatas","schemaAttributes","attributes","VersionInputRenderer","visible","hint","providedHint","shouldIgnoreRBAC","customLabelAction","version","useHistoryContext","selectedVersion","configuration","fieldSizes","useTypedSelector","app","useDoc","isFormDisabled","useForm","isInDynamicZone","useDynamicZone","canCreateFields","useDocumentRBAC","rbac","canReadFields","canUpdateFields","canUserAction","editableFields","readableFields","canUserReadField","type","canUserEditField","lazyComponentStore","useLazyComponents","attributeHasCustomFieldProperty","customField","undefined","useFieldHint","edit","useDocLayout","NotAllowedInput","fieldIsDisabled","addedAttributes","unknownAttributes","added","Object","includes","width","CustomInput","FormInputRenderer","addedInputTypes","BlocksInput","renderResources","component","remainingFieldsLayout","getRemaingFieldsLayout","ComponentInput","inputProps","DynamicZone","Wysiwyg","UIDInput","options","enum","unique","_unique","_mainField","restProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAMA,WAAAA,GAAcC,MAAAA,CAAOC,KAAAA,CAAAA,CAAOC,KAAK,CAAC;IAAEC,UAAAA,EAAY,OAAA;AAASC,IAAAA,OAAAA,EAAS,IAAA,CA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AAA,IAAiBA,aAAa,OAAOA,SAAAA,CAAU+F,WAAW,KAAK,QAAA;;;;"}
1
+ {"version":3,"file":"VersionInputRenderer.mjs","sources":["../../../../admin/src/history/components/VersionInputRenderer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useStrapiApp,\n useForm,\n InputRenderer as FormInputRenderer,\n useField,\n Form,\n} from '@strapi/admin/strapi-admin';\nimport { Alert, Box, Field, Flex, Link, Tooltip, Typography } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { NavLink } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { COLLECTION_TYPES } from '../../constants/collections';\nimport { useDocumentRBAC } from '../../features/DocumentRBAC';\nimport { useDoc } from '../../hooks/useDocument';\nimport { useDocLayout } from '../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../hooks/useLazyComponents';\nimport { useTypedSelector } from '../../modules/hooks';\nimport { DocumentStatus } from '../../pages/EditView/components/DocumentStatus';\nimport { BlocksInput } from '../../pages/EditView/components/FormInputs/BlocksInput/BlocksInput';\nimport { ComponentInput } from '../../pages/EditView/components/FormInputs/Component/Input';\nimport {\n DynamicZone,\n useDynamicZone,\n} from '../../pages/EditView/components/FormInputs/DynamicZone/Field';\nimport { NotAllowedInput } from '../../pages/EditView/components/FormInputs/NotAllowed';\nimport { UIDInput } from '../../pages/EditView/components/FormInputs/UID';\nimport { Wysiwyg } from '../../pages/EditView/components/FormInputs/Wysiwyg/Field';\nimport { useFieldHint } from '../../pages/EditView/components/InputRenderer';\nimport { getRelationLabel } from '../../utils/relations';\nimport { useHistoryContext } from '../pages/History';\n\nimport { getRemaingFieldsLayout } from './VersionContent';\n\nimport type { EditFieldLayout } from '../../hooks/useDocumentLayout';\nimport type { RelationsFieldProps } from '../../pages/EditView/components/FormInputs/Relations/Relations';\nimport type { RelationResult } from '../../services/relations';\nimport type { Schema } from '@strapi/types';\nimport type { DistributiveOmit } from 'react-redux';\n\nconst StyledAlert = styled(Alert).attrs({ closeLabel: 'Close', onClose: () => {}, shadow: 'none' })`\n button {\n display: none;\n }\n`;\n\n/* -------------------------------------------------------------------------------------------------\n * CustomRelationInput\n * -----------------------------------------------------------------------------------------------*/\n\nconst LinkEllipsis = styled(Link)`\n display: block;\n\n & > span {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n display: block;\n }\n`;\n\nconst CustomRelationInput = (props: RelationsFieldProps) => {\n const { formatMessage } = useIntl();\n const emptyLabel = formatMessage({\n id: 'content-manager.containers.empty-label',\n defaultMessage: 'Untitled',\n });\n const field = useField<\n { results: RelationResult[]; meta: { missingCount: number } } | RelationResult[]\n >(props.name);\n\n /**\n * Ideally the server would return the correct shape, however, for admin user relations\n * it sanitizes everything out when it finds an object for the relation value.\n */\n let formattedFieldValue;\n if (field) {\n formattedFieldValue = Array.isArray(field.value)\n ? { results: field.value, meta: { missingCount: 0 } }\n : field.value;\n }\n\n // Be defensive about the shape: admin-user relations are sanitized to a\n // plain user object on the server, and historical version data can carry\n // shapes that pre-date the `{ results, meta }` contract. Treat anything\n // without an array `results` as \"no relations\".\n const hasResultsShape =\n !!formattedFieldValue &&\n typeof formattedFieldValue === 'object' &&\n Array.isArray((formattedFieldValue as { results?: unknown }).results);\n const missingCount =\n hasResultsShape &&\n typeof (formattedFieldValue as { meta?: { missingCount?: number } }).meta?.missingCount ===\n 'number'\n ? (formattedFieldValue as { meta: { missingCount: number } }).meta.missingCount\n : 0;\n\n if (\n !hasResultsShape ||\n ((formattedFieldValue as { results: unknown[] }).results.length === 0 && missingCount === 0)\n ) {\n return (\n <>\n <Field.Label action={props.labelAction}>{props.label}</Field.Label>\n <Box marginTop={1}>\n <StyledAlert variant=\"default\">\n {formatMessage({\n id: 'content-manager.history.content.no-relations',\n defaultMessage: 'No relations.',\n })}\n </StyledAlert>\n </Box>\n </>\n );\n }\n\n const { results, meta } = formattedFieldValue as {\n results: RelationResult[];\n meta: { missingCount: number };\n };\n\n return (\n <Box>\n <Field.Label>{props.label}</Field.Label>\n {results.length > 0 && (\n <Flex direction=\"column\" gap={2} marginTop={1} alignItems=\"stretch\">\n {results.map((relationData) => {\n // @ts-expect-error - targetModel does exist on the attribute. But it's not typed.\n const { targetModel } = props.attribute;\n const href = `../${COLLECTION_TYPES}/${targetModel}/${relationData.documentId}`;\n const label = getRelationLabel(relationData, props.mainField, emptyLabel);\n const isAdminUserRelation = targetModel === 'admin::user';\n\n return (\n <Flex\n key={relationData.documentId ?? relationData.id}\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={4}\n paddingRight={4}\n hasRadius\n borderColor=\"neutral200\"\n background=\"neutral150\"\n justifyContent=\"space-between\"\n >\n <Box minWidth={0} paddingTop={1} paddingBottom={1} paddingRight={4}>\n <Tooltip label={label}>\n {isAdminUserRelation ? (\n <Typography>{label}</Typography>\n ) : (\n <LinkEllipsis tag={NavLink} to={href}>\n {label}\n </LinkEllipsis>\n )}\n </Tooltip>\n </Box>\n <DocumentStatus status={relationData.status as string} />\n </Flex>\n );\n })}\n </Flex>\n )}\n {meta.missingCount > 0 && (\n <StyledAlert\n marginTop={1}\n variant=\"warning\"\n title={formatMessage(\n {\n id: 'content-manager.history.content.missing-relations.title',\n defaultMessage:\n '{number, plural, =1 {Missing relation} other {{number} missing relations}}',\n },\n { number: meta.missingCount }\n )}\n >\n {formatMessage(\n {\n id: 'content-manager.history.content.missing-relations.message',\n defaultMessage:\n \"{number, plural, =1 {It has} other {They have}} been deleted and can't be restored.\",\n },\n { number: meta.missingCount }\n )}\n </StyledAlert>\n )}\n </Box>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * CustomMediaInput\n * -----------------------------------------------------------------------------------------------*/\n\n// Create an object with value at key path (i.e. 'a.b.c')\nconst createInitialValuesForPath = (keyPath: string, value: unknown) => {\n const keys = keyPath.split('.');\n // The root level object\n const root: Record<string, unknown> = {};\n\n // Make the first node the root\n let node = root;\n keys.forEach((key, index) => {\n // Skip prototype pollution keys\n if (key === '__proto__' || key === 'constructor') return;\n // If it's the last key, set the node value\n if (index === keys.length - 1) {\n node[key] = value;\n } else {\n // Ensure the key exists and is an object\n const nextNode =\n typeof node[key] === 'object' && node[key] !== null && Array.isArray(node[key]) === false\n ? (node[key] as Record<string, unknown>)\n : {};\n node[key] = nextNode;\n node = nextNode;\n }\n });\n\n return root;\n};\n\nconst CustomMediaInput = (props: VersionInputRendererProps) => {\n const { value } = useField<{ results: unknown[]; meta: { missingCount: number } }>(props.name);\n const results = value?.results ?? [];\n const meta = value?.meta ?? { missingCount: 0 };\n\n const { formatMessage } = useIntl();\n\n const fields = useStrapiApp('CustomMediaInput', (state) => state.fields);\n const MediaLibrary = fields.media as React.ComponentType<\n VersionInputRendererProps & { multiple: boolean }\n >;\n\n return (\n <Flex direction=\"column\" gap={2} alignItems=\"stretch\">\n <Form\n method=\"PUT\"\n disabled={true}\n initialValues={createInitialValuesForPath(props.name, results)}\n >\n <MediaLibrary {...props} disabled={true} multiple={results.length > 1} />\n </Form>\n {meta.missingCount > 0 && (\n <StyledAlert\n variant=\"warning\"\n closeLabel=\"Close\"\n onClose={() => {}}\n title={formatMessage(\n {\n id: 'content-manager.history.content.missing-assets.title',\n defaultMessage:\n '{number, plural, =1 {Missing asset} other {{number} missing assets}}',\n },\n { number: meta.missingCount }\n )}\n >\n {formatMessage(\n {\n id: 'content-manager.history.content.missing-assets.message',\n defaultMessage:\n \"{number, plural, =1 {It has} other {They have}} been deleted in the Media Library and can't be restored.\",\n },\n { number: meta.missingCount }\n )}\n </StyledAlert>\n )}\n </Flex>\n );\n};\n\ntype VersionInputRendererProps = DistributiveOmit<EditFieldLayout, 'size'> & {\n /**\n * In the context of content history, deleted fields need to ignore RBAC\n * @default false\n */\n shouldIgnoreRBAC?: boolean;\n};\n\n/**\n * Checks if the i18n plugin added a label action to the field and modifies it\n * to adapt the wording for the history page.\n */\nconst getLabelAction = (labelAction: VersionInputRendererProps['labelAction']) => {\n if (!React.isValidElement(labelAction)) {\n return labelAction;\n }\n\n // TODO: find a better way to do this rather than access internals\n const labelActionTitleId = labelAction.props.title.id;\n\n if (labelActionTitleId === 'i18n.Field.localized') {\n return React.cloneElement(labelAction, {\n ...labelAction.props,\n title: {\n id: 'history.content.localized',\n defaultMessage:\n 'This value is specific to this locale. If you restore this version, the content will not be replaced for other locales.',\n },\n });\n }\n\n if (labelActionTitleId === 'i18n.Field.not-localized') {\n return React.cloneElement(labelAction, {\n ...labelAction.props,\n title: {\n id: 'history.content.not-localized',\n defaultMessage:\n 'This value is common to all locales. If you restore this version and save the changes, the content will be replaced for all locales.',\n },\n });\n }\n\n // Label action is unrelated to i18n, don't touch it.\n return labelAction;\n};\n\n/**\n * Resolve the layout, configuration metadata and schema attributes needed to\n * render a component field on the history page. Returns `null` when any of\n * those are missing — happens when the component schema referenced by the\n * version was deleted via the Content-Type Builder, in which case the caller\n * should render a fallback instead of crashing on the destructuring.\n */\nconst resolveComponentRenderResources = (\n componentUID: string,\n componentsLayout: { [uid: string]: { layout: unknown } | undefined },\n configurationComponents: { [uid: string]: { metadatas: unknown } | undefined },\n components: { [uid: string]: { attributes: unknown } | undefined }\n) => {\n const componentLayout = componentsLayout[componentUID];\n const componentConfiguration = configurationComponents[componentUID];\n const componentSchema = components[componentUID];\n\n if (!componentLayout || !componentConfiguration || !componentSchema) {\n return null;\n }\n\n return {\n layout: componentLayout.layout,\n metadatas: componentConfiguration.metadatas,\n schemaAttributes: componentSchema.attributes,\n };\n};\n\n/**\n * @internal\n *\n * @description An abstraction around the regular form input renderer designed specifically\n * to be used on the History page in the content-manager. It understands how to render specific\n * inputs within the context of a history version (i.e. relations, media, ignored RBAC, etc...)\n */\nconst VersionInputRenderer = ({\n visible,\n hint: providedHint,\n shouldIgnoreRBAC = false,\n labelAction,\n ...props\n}: VersionInputRendererProps) => {\n const customLabelAction = getLabelAction(labelAction);\n\n const { formatMessage } = useIntl();\n const version = useHistoryContext('VersionContent', (state) => state.selectedVersion);\n const configuration = useHistoryContext('VersionContent', (state) => state.configuration);\n const fieldSizes = useTypedSelector((state) => state['content-manager'].app.fieldSizes);\n\n const { id, components } = useDoc();\n const isFormDisabled = useForm('InputRenderer', (state) => state.disabled);\n\n const isInDynamicZone = useDynamicZone('isInDynamicZone', (state) => state.isInDynamicZone);\n\n const canCreateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canCreateFields);\n const canReadFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canReadFields);\n const canUpdateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUpdateFields);\n const canUserAction = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUserAction);\n\n const editableFields = id ? canUpdateFields : canCreateFields;\n const readableFields = id ? canReadFields : canCreateFields;\n /**\n * Component fields are always readable and editable,\n * however the fields within them may not be.\n */\n const canUserReadField = canUserAction(props.name, readableFields, props.type);\n const canUserEditField = canUserAction(props.name, editableFields, props.type);\n\n const fields = useStrapiApp('InputRenderer', (app) => app.fields);\n const { lazyComponentStore } = useLazyComponents(\n attributeHasCustomFieldProperty(props.attribute) ? [props.attribute.customField] : undefined\n );\n\n const hint = useFieldHint(providedHint, props.attribute);\n const {\n edit: { components: componentsLayout },\n } = useDocLayout();\n\n if (!visible) {\n return null;\n }\n\n /**\n * Don't render the field if the user can't read it.\n */\n if (!shouldIgnoreRBAC && !canUserReadField && !isInDynamicZone) {\n return <NotAllowedInput hint={hint} {...props} />;\n }\n\n const fieldIsDisabled =\n (!canUserEditField && !isInDynamicZone) || props.disabled || isFormDisabled;\n\n /**\n * Attributes found on the current content-type schema cannot be restored. We handle\n * this by displaying a warning alert to the user instead of the input for that field type.\n */\n const addedAttributes = version.meta.unknownAttributes.added;\n if (Object.keys(addedAttributes).includes(props.name)) {\n return (\n <Flex direction=\"column\" alignItems=\"flex-start\" gap={1}>\n <Field.Label>{props.label}</Field.Label>\n <StyledAlert\n width=\"100%\"\n closeLabel=\"Close\"\n onClose={() => {}}\n variant=\"warning\"\n title={formatMessage({\n id: 'content-manager.history.content.new-field.title',\n defaultMessage: 'New field',\n })}\n >\n {formatMessage({\n id: 'content-manager.history.content.new-field.message',\n defaultMessage:\n \"This field didn't exist when this version was saved. If you restore this version, it will be empty.\",\n })}\n </StyledAlert>\n </Flex>\n );\n }\n\n /**\n * Because a custom field has a unique prop but the type could be confused with either\n * the useField hook or the type of the field we need to handle it separately and first.\n */\n if (attributeHasCustomFieldProperty(props.attribute)) {\n const CustomInput = lazyComponentStore[props.attribute.customField];\n\n if (CustomInput) {\n return (\n <CustomInput\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n return (\n <FormInputRenderer\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n // @ts-expect-error – this workaround lets us display that the custom field is missing.\n type={props.attribute.customField}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * Since media fields use a custom input via the upload plugin provided by the useLibrary hook,\n * we need to handle the them before other custom inputs coming from the useLibrary hook.\n */\n if (props.type === 'media') {\n return (\n <CustomMediaInput {...props} labelAction={customLabelAction} disabled={fieldIsDisabled} />\n );\n }\n /**\n * This is where we handle ONLY the fields from the `useLibrary` hook.\n */\n const addedInputTypes = Object.keys(fields);\n if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {\n const CustomInput = fields[props.type];\n return (\n <CustomInput\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLibrary hook.\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * These include the content-manager specific fields, failing that we fall back\n * to the more generic form input renderer.\n */\n switch (props.type) {\n case 'blocks':\n return <BlocksInput {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n case 'component': {\n const renderResources = resolveComponentRenderResources(\n props.attribute.component,\n componentsLayout,\n configuration.components,\n components\n );\n\n // The component schema referenced by this version is no longer present\n // (deleted via the Content-Type Builder). Render the label only so the\n // rest of the page still loads instead of crashing on the lookups below.\n if (!renderResources) {\n return <Field.Label>{props.label}</Field.Label>;\n }\n\n const { layout, metadatas, schemaAttributes } = renderResources as {\n layout: Array<EditFieldLayout[]>;\n metadatas: Parameters<typeof getRemaingFieldsLayout>[0]['metadatas'];\n schemaAttributes: Parameters<typeof getRemaingFieldsLayout>[0]['schemaAttributes'];\n };\n\n // Components can only have one panel, so only save the first layout item\n const [remainingFieldsLayout] = getRemaingFieldsLayout({\n layout: [layout],\n metadatas,\n fieldSizes,\n schemaAttributes,\n });\n\n return (\n <ComponentInput\n {...props}\n layout={[...layout, ...(remainingFieldsLayout || [])]}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n >\n {(inputProps) => <VersionInputRenderer {...inputProps} shouldIgnoreRBAC={true} />}\n </ComponentInput>\n );\n }\n case 'dynamiczone':\n return (\n <DynamicZone\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n >\n {(inputProps) => <VersionInputRenderer {...inputProps} shouldIgnoreRBAC={true} />}\n </DynamicZone>\n );\n case 'relation':\n return (\n <CustomRelationInput\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n case 'richtext':\n return (\n <Wysiwyg\n {...props}\n hint={hint}\n type={props.type}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n case 'uid':\n return (\n <UIDInput\n {...props}\n hint={hint}\n type={props.type}\n labelAction={customLabelAction}\n disabled={fieldIsDisabled}\n />\n );\n /**\n * Enumerations are a special case because they require options.\n */\n case 'enumeration':\n return (\n <FormInputRenderer\n {...props}\n hint={hint}\n labelAction={customLabelAction}\n options={props.attribute.enum.map((value) => ({ value }))}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n default:\n // These props are not needed for the generic form input renderer.\n const { unique: _unique, mainField: _mainField, ...restProps } = props;\n return (\n <FormInputRenderer\n {...restProps}\n hint={hint}\n labelAction={customLabelAction}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n }\n};\n\nconst attributeHasCustomFieldProperty = (\n attribute: Schema.Attribute.AnyAttribute\n): attribute is Schema.Attribute.AnyAttribute & Schema.Attribute.CustomField<string> =>\n 'customField' in attribute && typeof attribute.customField === 'string';\n\nexport type { VersionInputRendererProps };\nexport { VersionInputRenderer, CustomRelationInput, resolveComponentRenderResources };\n"],"names":["StyledAlert","styled","Alert","attrs","closeLabel","onClose","shadow","LinkEllipsis","Link","CustomRelationInput","props","formatMessage","useIntl","emptyLabel","id","defaultMessage","field","useField","name","formattedFieldValue","Array","isArray","value","results","meta","missingCount","hasResultsShape","length","_jsxs","_Fragment","_jsx","Field","Label","action","labelAction","label","Box","marginTop","variant","Flex","direction","gap","alignItems","map","relationData","targetModel","attribute","href","COLLECTION_TYPES","documentId","getRelationLabel","mainField","isAdminUserRelation","paddingTop","paddingBottom","paddingLeft","paddingRight","hasRadius","borderColor","background","justifyContent","minWidth","Tooltip","Typography","tag","NavLink","to","DocumentStatus","status","title","number","createInitialValuesForPath","keyPath","keys","split","root","node","forEach","key","index","nextNode","CustomMediaInput","fields","useStrapiApp","state","MediaLibrary","media","Form","method","disabled","initialValues","multiple","getLabelAction","React","isValidElement","labelActionTitleId","cloneElement","resolveComponentRenderResources","componentUID","componentsLayout","configurationComponents","components","componentLayout","componentConfiguration","componentSchema","layout","metadatas","schemaAttributes","attributes","VersionInputRenderer","visible","hint","providedHint","shouldIgnoreRBAC","customLabelAction","version","useHistoryContext","selectedVersion","configuration","fieldSizes","useTypedSelector","app","useDoc","isFormDisabled","useForm","isInDynamicZone","useDynamicZone","canCreateFields","useDocumentRBAC","rbac","canReadFields","canUpdateFields","canUserAction","editableFields","readableFields","canUserReadField","type","canUserEditField","lazyComponentStore","useLazyComponents","attributeHasCustomFieldProperty","customField","undefined","useFieldHint","edit","useDocLayout","NotAllowedInput","fieldIsDisabled","addedAttributes","unknownAttributes","added","Object","includes","width","CustomInput","FormInputRenderer","addedInputTypes","BlocksInput","renderResources","component","remainingFieldsLayout","getRemaingFieldsLayout","ComponentInput","inputProps","DynamicZone","Wysiwyg","UIDInput","options","enum","unique","_unique","_mainField","restProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAMA,WAAAA,GAAcC,MAAAA,CAAOC,KAAAA,CAAAA,CAAOC,KAAK,CAAC;IAAEC,UAAAA,EAAY,OAAA;AAASC,IAAAA,OAAAA,EAAS,IAAA,CAAO,CAAA;IAAGC,MAAAA,EAAQ;AAAO,CAAA,CAAE;;;;AAInG,CAAC;AAED;;AAEkG,qGAElG,MAAMC,YAAAA,GAAeN,MAAAA,CAAOO,IAAAA,CAAK;;;;;;;;;AASjC,CAAC;AAED,MAAMC,sBAAsB,CAACC,KAAAA,GAAAA;IAC3B,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;AAC1B,IAAA,MAAMC,aAAaF,aAAAA,CAAc;QAC/BG,EAAAA,EAAI,wCAAA;QACJC,cAAAA,EAAgB;AAClB,KAAA,CAAA;IACA,MAAMC,KAAAA,GAAQC,QAAAA,CAEZP,KAAAA,CAAMQ,IAAI,CAAA;AAEZ;;;AAGC,MACD,IAAIC,mBAAAA;AACJ,IAAA,IAAIH,KAAAA,EAAO;AACTG,QAAAA,mBAAAA,GAAsBC,KAAAA,CAAMC,OAAO,CAACL,KAAAA,CAAMM,KAAK,CAAA,GAC3C;AAAEC,YAAAA,OAAAA,EAASP,MAAMM,KAAK;YAAEE,IAAAA,EAAM;gBAAEC,YAAAA,EAAc;AAAE;AAAE,SAAA,GAClDT,MAAMM,KAAK;AACjB,IAAA;;;;;AAMA,IAAA,MAAMI,eAAAA,GACJ,CAAC,CAACP,mBAAAA,IACF,OAAOA,mBAAAA,KAAwB,QAAA,IAC/BC,KAAAA,CAAMC,OAAO,CAAC,mBA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,KAAAA,CAAMmI,WAAW,GAAG,cAAA,GAAiBnI,MAAM8H,IAAI;gBACrD/C,QAAAA,EAAU0D;;AAGhB,QAAA;;YAEE,MAAM,EAAEsB,QAAQC,OAAO,EAAEvH,WAAWwH,UAAU,EAAE,GAAGC,SAAAA,EAAW,GAAGlK,KAAAA;AACjE,YAAA,qBACEoB,GAAA,CAAC6H,aAAAA,EAAAA;AACE,gBAAA,GAAGiB,SAAS;gBACb7D,IAAAA,EAAMA,IAAAA;gBACN7E,WAAAA,EAAagF,iBAAAA;;AAEbsB,gBAAAA,IAAAA,EAAM9H,KAAAA,CAAMmI,WAAW,GAAG,cAAA,GAAiBnI,MAAM8H,IAAI;gBACrD/C,QAAAA,EAAU0D;;AAGlB;AACF;AAEA,MAAMP,+BAAAA,GAAkC,CACtC9F,SAAAA,GAEA,aAAA,IAAiBA,aAAa,OAAOA,SAAAA,CAAU+F,WAAW,KAAK,QAAA;;;;"}
@@ -51,10 +51,18 @@ const usePersistentPartialQueryParams = (config)=>{
51
51
  Object.assign(mergedFilteredQuery, filteredQuery);
52
52
  }
53
53
  if (Object.keys(mergedFilteredQuery).length > 0) {
54
- setQuery({
54
+ const nextQuery = {
55
55
  ...mergedFilteredQuery,
56
56
  ...query
57
- }, 'push', true);
57
+ };
58
+ if (nextQuery.filters !== undefined) {
59
+ //`setQuery` never encodes the values, and it cannot be fixed as it would introduce breaking changes.
60
+ // This ensures that, when reading the persisted values and writing them in the URI, they are encoded properly.
61
+ // We are only encoding the filters because we know they can hold values with special characters. We didn't bother
62
+ // with the other query params because as of today, they are not expected to hold such values.
63
+ nextQuery.filters = strapiAdmin.deepEncodeQueryValues(nextQuery.filters);
64
+ }
65
+ setQuery(nextQuery, 'push', true);
58
66
  }
59
67
  setIsHydrated(true);
60
68
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -1 +1 @@
1
- {"version":3,"file":"usePersistentQueryParams.js","sources":["../../../admin/src/hooks/usePersistentQueryParams.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { usePersistentStateScope, useQueryParams } from '@strapi/admin/strapi-admin';\nimport get from 'lodash/get';\nimport set from 'lodash/set';\n\ntype PropertyPath = Parameters<typeof get>[1];\n\ninterface PersistentQueryConfigEntry {\n paths: PropertyPath[];\n scoped?: boolean;\n}\n\nconst filterObjectKeys = (obj: object, keys: PropertyPath[]) => {\n const result: Record<string, unknown> = {};\n\n for (const path of keys) {\n const value = get(obj, path);\n\n if (value !== undefined) {\n set(result, path, value);\n }\n }\n\n return result;\n};\n\nexport type PersistentQueryConfig = Record<string, PersistentQueryConfigEntry>;\n\nconst normalizeConfigEntry = (\n key: string,\n entry: PersistentQueryConfigEntry,\n scope: string | false | undefined\n) => {\n const { paths } = entry;\n const isScoped = entry.scoped === true && !!scope;\n\n return {\n key: isScoped ? `${key}:${scope}` : key,\n paths,\n };\n};\n\nexport const usePersistentPartialQueryParams = (config: PersistentQueryConfig) => {\n const scope = usePersistentStateScope();\n const [{ query }, setQuery] = useQueryParams();\n const clonedConfig = JSON.stringify(config);\n const [isHydrated, setIsHydrated] = useState(false);\n\n // load query params from local storge\n useEffect(() => {\n const mergedFilteredQuery: Record<string, unknown> = {};\n\n for (const [keyPrefix, entry] of Object.entries(config)) {\n const { key, paths } = normalizeConfigEntry(keyPrefix, entry, scope);\n\n const savedQueryParams = window.localStorage.getItem(key);\n if (!savedQueryParams) continue;\n\n let parsedSavedParams: Record<string, unknown>;\n try {\n parsedSavedParams = JSON.parse(savedQueryParams);\n } catch {\n continue;\n }\n if (Object.keys(parsedSavedParams).length === 0) continue;\n\n const filteredQuery = filterObjectKeys(parsedSavedParams, paths);\n Object.assign(mergedFilteredQuery, filteredQuery);\n }\n\n if (Object.keys(mergedFilteredQuery).length > 0) {\n setQuery({ ...mergedFilteredQuery, ...query }, 'push', true);\n }\n setIsHydrated(true);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [clonedConfig, scope]);\n\n // update local storage\n useEffect(() => {\n for (const [keyPrefix, entry] of Object.entries(config)) {\n const { key, paths } = normalizeConfigEntry(keyPrefix, entry, scope);\n\n const paramsToPersist = filterObjectKeys(query, paths);\n if (Object.keys(paramsToPersist).length === 0) {\n window.localStorage.removeItem(key);\n continue;\n }\n\n window.localStorage.setItem(key, JSON.stringify(paramsToPersist));\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [query, clonedConfig, scope]);\n\n return { isHydrated };\n};\n"],"names":["filterObjectKeys","obj","keys","result","path","value","get","undefined","set","normalizeConfigEntry","key","entry","scope","paths","isScoped","scoped","usePersistentPartialQueryParams","config","usePersistentStateScope","query","setQuery","useQueryParams","clonedConfig","JSON","stringify","isHydrated","setIsHydrated","useState","useEffect","mergedFilteredQuery","keyPrefix","Object","entries","savedQueryParams","window","localStorage","getItem","parsedSavedParams","parse","length","filteredQuery","assign","paramsToPersist","removeItem","setItem"],"mappings":";;;;;;;;;;;;AAaA,MAAMA,gBAAAA,GAAmB,CAACC,GAAAA,EAAaC,IAAAA,GAAAA;AACrC,IAAA,MAAMC,SAAkC,EAAC;IAEzC,KAAK,MAAMC,QAAQF,IAAAA,CAAM;QACvB,MAAMG,KAAAA,GAAQC,qBAAIL,GAAAA,EAAKG,IAAAA,CAAAA;AAEvB,QAAA,IAAIC,UAAUE,SAAAA,EAAW;AACvBC,YAAAA,oBAAAA,CAAIL,QAAQC,IAAAA,EAAMC,KAAAA,CAAAA;AACpB,QAAA;AACF,IAAA;IAEA,OAAOF,MAAAA;AACT,CAAA;AAIA,MAAMM,oBAAAA,GAAuB,CAC3BC,GAAAA,EACAC,KAAAA,EACAC,KAAAA,GAAAA;IAEA,MAAM,EAAEC,KAAK,EAAE,GAAGF,KAAAA;AAClB,IAAA,MAAMG,WAAWH,KAAAA,CAAMI,MAAM,KAAK,IAAA,IAAQ,CAAC,CAACH,KAAAA;IAE5C,OAAO;AACLF,QAAAA,GAAAA,EAAKI,WAAW,CAAA,EAAGJ,GAAAA,CAAI,CAAC,EAAEE,OAAO,GAA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CAAAA,CAAqBU,MAAM,GAAG,CAAA,EAAG;YAC/CnB,QAAAA,CAAS;AAAE,gBAAA,GAAGS,mBAAmB;AAAE,gBAAA,GAAGV;AAAM,aAAA,EAAG,MAAA,EAAQ,IAAA,CAAA;AACzD,QAAA;QACAO,aAAAA,CAAc,IAAA,CAAA;;IAEhB,CAAA,EAAG;AAACJ,QAAAA,YAAAA;AAAcV,QAAAA;AAAM,KAAA,CAAA;;IAGxBgB,eAAAA,CAAU,IAAA;QACR,KAAK,MAAM,CAACE,SAAAA,EAAWnB,KAAAA,CAAM,IAAIoB,MAAAA,CAAOC,OAAO,CAACf,MAAAA,CAAAA,CAAS;YACvD,MAAM,EAAEP,GAAG,EAAEG,KAAK,EAAE,GAAGJ,oBAAAA,CAAqBqB,WAAWnB,KAAAA,EAAOC,KAAAA,CAAAA;YAE9D,MAAM8B,eAAAA,GAAkB1C,iBAAiBmB,KAAAA,EAAON,KAAAA,CAAAA;AAChD,YAAA,IAAIkB,OAAO7B,IAAI,CAACwC,eAAAA,CAAAA,CAAiBH,MAAM,KAAK,CAAA,EAAG;gBAC7CL,MAAAA,CAAOC,YAAY,CAACQ,UAAU,CAACjC,GAAAA,CAAAA;AAC/B,gBAAA;AACF,YAAA;AAEAwB,YAAAA,MAAAA,CAAOC,YAAY,CAACS,OAAO,CAAClC,GAAAA,EAAKa,IAAAA,CAAKC,SAAS,CAACkB,eAAAA,CAAAA,CAAAA;AAClD,QAAA;;IAEF,CAAA,EAAG;AAACvB,QAAAA,KAAAA;AAAOG,QAAAA,YAAAA;AAAcV,QAAAA;AAAM,KAAA,CAAA;IAE/B,OAAO;AAAEa,QAAAA;AAAW,KAAA;AACtB;;;;"}
1
+ {"version":3,"file":"usePersistentQueryParams.js","sources":["../../../admin/src/hooks/usePersistentQueryParams.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport {\n deepEncodeQueryValues,\n usePersistentStateScope,\n useQueryParams,\n} from '@strapi/admin/strapi-admin';\nimport get from 'lodash/get';\nimport set from 'lodash/set';\n\ntype PropertyPath = Parameters<typeof get>[1];\n\ninterface PersistentQueryConfigEntry {\n paths: PropertyPath[];\n scoped?: boolean;\n}\n\nconst filterObjectKeys = (obj: object, keys: PropertyPath[]) => {\n const result: Record<string, unknown> = {};\n\n for (const path of keys) {\n const value = get(obj, path);\n\n if (value !== undefined) {\n set(result, path, value);\n }\n }\n\n return result;\n};\n\nexport type PersistentQueryConfig = Record<string, PersistentQueryConfigEntry>;\n\nconst normalizeConfigEntry = (\n key: string,\n entry: PersistentQueryConfigEntry,\n scope: string | false | undefined\n) => {\n const { paths } = entry;\n const isScoped = entry.scoped === true && !!scope;\n\n return {\n key: isScoped ? `${key}:${scope}` : key,\n paths,\n };\n};\n\nexport const usePersistentPartialQueryParams = (config: PersistentQueryConfig) => {\n const scope = usePersistentStateScope();\n const [{ query }, setQuery] = useQueryParams();\n const clonedConfig = JSON.stringify(config);\n const [isHydrated, setIsHydrated] = useState(false);\n\n // load query params from local storge\n useEffect(() => {\n const mergedFilteredQuery: Record<string, unknown> = {};\n\n for (const [keyPrefix, entry] of Object.entries(config)) {\n const { key, paths } = normalizeConfigEntry(keyPrefix, entry, scope);\n\n const savedQueryParams = window.localStorage.getItem(key);\n if (!savedQueryParams) continue;\n\n let parsedSavedParams: Record<string, unknown>;\n try {\n parsedSavedParams = JSON.parse(savedQueryParams);\n } catch {\n continue;\n }\n if (Object.keys(parsedSavedParams).length === 0) continue;\n\n const filteredQuery = filterObjectKeys(parsedSavedParams, paths);\n Object.assign(mergedFilteredQuery, filteredQuery);\n }\n\n if (Object.keys(mergedFilteredQuery).length > 0) {\n const nextQuery: Record<string, unknown> = { ...mergedFilteredQuery, ...query };\n\n if (nextQuery.filters !== undefined) {\n //`setQuery` never encodes the values, and it cannot be fixed as it would introduce breaking changes.\n // This ensures that, when reading the persisted values and writing them in the URI, they are encoded properly.\n // We are only encoding the filters because we know they can hold values with special characters. We didn't bother\n // with the other query params because as of today, they are not expected to hold such values.\n nextQuery.filters = deepEncodeQueryValues(nextQuery.filters);\n }\n\n setQuery(nextQuery, 'push', true);\n }\n setIsHydrated(true);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [clonedConfig, scope]);\n\n // update local storage\n useEffect(() => {\n for (const [keyPrefix, entry] of Object.entries(config)) {\n const { key, paths } = normalizeConfigEntry(keyPrefix, entry, scope);\n\n const paramsToPersist = filterObjectKeys(query, paths);\n if (Object.keys(paramsToPersist).length === 0) {\n window.localStorage.removeItem(key);\n continue;\n }\n\n window.localStorage.setItem(key, JSON.stringify(paramsToPersist));\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [query, clonedConfig, scope]);\n\n return { isHydrated };\n};\n"],"names":["filterObjectKeys","obj","keys","result","path","value","get","undefined","set","normalizeConfigEntry","key","entry","scope","paths","isScoped","scoped","usePersistentPartialQueryParams","config","usePersistentStateScope","query","setQuery","useQueryParams","clonedConfig","JSON","stringify","isHydrated","setIsHydrated","useState","useEffect","mergedFilteredQuery","keyPrefix","Object","entries","savedQueryParams","window","localStorage","getItem","parsedSavedParams","parse","length","filteredQuery","assign","nextQuery","filters","deepEncodeQueryValues","paramsToPersist","removeItem","setItem"],"mappings":";;;;;;;;;;;;AAiBA,MAAMA,gBAAAA,GAAmB,CAACC,GAAAA,EAAaC,IAAAA,GAAAA;AACrC,IAAA,MAAMC,SAAkC,EAAC;IAEzC,KAAK,MAAMC,QAAQF,IAAAA,CAAM;QACvB,MAAMG,KAAAA,GAAQC,qBAAIL,GAAAA,EAAKG,IAAAA,CAAAA;AAEvB,QAAA,IAAIC,UAAUE,SAAAA,EAAW;AACvBC,YAAAA,oBAAAA,CAAIL,QAAQC,IAAAA,EAAMC,KAAAA,CAAAA;AACpB,QAAA;AACF,IAAA;IAEA,OAAOF,MAAAA;AACT,CAAA;AAIA,MAAMM,oBAAAA,GAAuB,CAC3BC,GAAAA,EACAC,KAAAA,EACAC,KAAAA,GAAAA;IAEA,MAAM,EAAEC,KAAK,EAA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,GAAAA,EAAKa,IAAAA,CAAKC,SAAS,CAACqB,eAAAA,CAAAA,CAAAA;AAClD,QAAA;;IAEF,CAAA,EAAG;AAAC1B,QAAAA,KAAAA;AAAOG,QAAAA,YAAAA;AAAcV,QAAAA;AAAM,KAAA,CAAA;IAE/B,OAAO;AAAEa,QAAAA;AAAW,KAAA;AACtB;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { useState, useEffect } from 'react';
2
- import { usePersistentStateScope, useQueryParams } from '@strapi/admin/strapi-admin';
2
+ import { usePersistentStateScope, useQueryParams, deepEncodeQueryValues } from '@strapi/admin/strapi-admin';
3
3
  import get from 'lodash/get';
4
4
  import set from 'lodash/set';
5
5
 
@@ -44,10 +44,18 @@ const usePersistentPartialQueryParams = (config)=>{
44
44
  Object.assign(mergedFilteredQuery, filteredQuery);
45
45
  }
46
46
  if (Object.keys(mergedFilteredQuery).length > 0) {
47
- setQuery({
47
+ const nextQuery = {
48
48
  ...mergedFilteredQuery,
49
49
  ...query
50
- }, 'push', true);
50
+ };
51
+ if (nextQuery.filters !== undefined) {
52
+ //`setQuery` never encodes the values, and it cannot be fixed as it would introduce breaking changes.
53
+ // This ensures that, when reading the persisted values and writing them in the URI, they are encoded properly.
54
+ // We are only encoding the filters because we know they can hold values with special characters. We didn't bother
55
+ // with the other query params because as of today, they are not expected to hold such values.
56
+ nextQuery.filters = deepEncodeQueryValues(nextQuery.filters);
57
+ }
58
+ setQuery(nextQuery, 'push', true);
51
59
  }
52
60
  setIsHydrated(true);
53
61
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -1 +1 @@
1
- {"version":3,"file":"usePersistentQueryParams.mjs","sources":["../../../admin/src/hooks/usePersistentQueryParams.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { usePersistentStateScope, useQueryParams } from '@strapi/admin/strapi-admin';\nimport get from 'lodash/get';\nimport set from 'lodash/set';\n\ntype PropertyPath = Parameters<typeof get>[1];\n\ninterface PersistentQueryConfigEntry {\n paths: PropertyPath[];\n scoped?: boolean;\n}\n\nconst filterObjectKeys = (obj: object, keys: PropertyPath[]) => {\n const result: Record<string, unknown> = {};\n\n for (const path of keys) {\n const value = get(obj, path);\n\n if (value !== undefined) {\n set(result, path, value);\n }\n }\n\n return result;\n};\n\nexport type PersistentQueryConfig = Record<string, PersistentQueryConfigEntry>;\n\nconst normalizeConfigEntry = (\n key: string,\n entry: PersistentQueryConfigEntry,\n scope: string | false | undefined\n) => {\n const { paths } = entry;\n const isScoped = entry.scoped === true && !!scope;\n\n return {\n key: isScoped ? `${key}:${scope}` : key,\n paths,\n };\n};\n\nexport const usePersistentPartialQueryParams = (config: PersistentQueryConfig) => {\n const scope = usePersistentStateScope();\n const [{ query }, setQuery] = useQueryParams();\n const clonedConfig = JSON.stringify(config);\n const [isHydrated, setIsHydrated] = useState(false);\n\n // load query params from local storge\n useEffect(() => {\n const mergedFilteredQuery: Record<string, unknown> = {};\n\n for (const [keyPrefix, entry] of Object.entries(config)) {\n const { key, paths } = normalizeConfigEntry(keyPrefix, entry, scope);\n\n const savedQueryParams = window.localStorage.getItem(key);\n if (!savedQueryParams) continue;\n\n let parsedSavedParams: Record<string, unknown>;\n try {\n parsedSavedParams = JSON.parse(savedQueryParams);\n } catch {\n continue;\n }\n if (Object.keys(parsedSavedParams).length === 0) continue;\n\n const filteredQuery = filterObjectKeys(parsedSavedParams, paths);\n Object.assign(mergedFilteredQuery, filteredQuery);\n }\n\n if (Object.keys(mergedFilteredQuery).length > 0) {\n setQuery({ ...mergedFilteredQuery, ...query }, 'push', true);\n }\n setIsHydrated(true);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [clonedConfig, scope]);\n\n // update local storage\n useEffect(() => {\n for (const [keyPrefix, entry] of Object.entries(config)) {\n const { key, paths } = normalizeConfigEntry(keyPrefix, entry, scope);\n\n const paramsToPersist = filterObjectKeys(query, paths);\n if (Object.keys(paramsToPersist).length === 0) {\n window.localStorage.removeItem(key);\n continue;\n }\n\n window.localStorage.setItem(key, JSON.stringify(paramsToPersist));\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [query, clonedConfig, scope]);\n\n return { isHydrated };\n};\n"],"names":["filterObjectKeys","obj","keys","result","path","value","get","undefined","set","normalizeConfigEntry","key","entry","scope","paths","isScoped","scoped","usePersistentPartialQueryParams","config","usePersistentStateScope","query","setQuery","useQueryParams","clonedConfig","JSON","stringify","isHydrated","setIsHydrated","useState","useEffect","mergedFilteredQuery","keyPrefix","Object","entries","savedQueryParams","window","localStorage","getItem","parsedSavedParams","parse","length","filteredQuery","assign","paramsToPersist","removeItem","setItem"],"mappings":";;;;;AAaA,MAAMA,gBAAAA,GAAmB,CAACC,GAAAA,EAAaC,IAAAA,GAAAA;AACrC,IAAA,MAAMC,SAAkC,EAAC;IAEzC,KAAK,MAAMC,QAAQF,IAAAA,CAAM;QACvB,MAAMG,KAAAA,GAAQC,IAAIL,GAAAA,EAAKG,IAAAA,CAAAA;AAEvB,QAAA,IAAIC,UAAUE,SAAAA,EAAW;AACvBC,YAAAA,GAAAA,CAAIL,QAAQC,IAAAA,EAAMC,KAAAA,CAAAA;AACpB,QAAA;AACF,IAAA;IAEA,OAAOF,MAAAA;AACT,CAAA;AAIA,MAAMM,oBAAAA,GAAuB,CAC3BC,GAAAA,EACAC,KAAAA,EACAC,KAAAA,GAAAA;IAEA,MAAM,EAAEC,KAAK,EAAE,GAAGF,KAAAA;AAClB,IAAA,MAAMG,WAAWH,KAAAA,CAAMI,MAAM,KAAK,IAAA,IAAQ,CAAC,CAACH,KAAAA;IAE5C,OAAO;AACLF,QAAAA,GAAAA,EAAKI,WAAW,CAAA,EAAGJ,GAAAA,CAAI,CAAC,EAAEE,OAAO,GAAGF,GAAAA;AACpCG,QAAAA;AACF,KAAA;AACF,CAAA;AAEO,MAAMG,kCAAkC,CAACC,MAAAA,GAAAA;AAC9C,IAAA,MAAML,KAAAA,GAAQM,uBAAAA,EAAAA;AACd,IAAA,MAAM,CAAC,EAAEC,KAA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aAAAA,CAAc,IAAA,CAAA;;IAEhB,CAAA,EAAG;AAACJ,QAAAA,YAAAA;AAAcV,QAAAA;AAAM,KAAA,CAAA;;IAGxBgB,SAAAA,CAAU,IAAA;QACR,KAAK,MAAM,CAACE,SAAAA,EAAWnB,KAAAA,CAAM,IAAIoB,MAAAA,CAAOC,OAAO,CAACf,MAAAA,CAAAA,CAAS;YACvD,MAAM,EAAEP,GAAG,EAAEG,KAAK,EAAE,GAAGJ,oBAAAA,CAAqBqB,WAAWnB,KAAAA,EAAOC,KAAAA,CAAAA;YAE9D,MAAM8B,eAAAA,GAAkB1C,iBAAiBmB,KAAAA,EAAON,KAAAA,CAAAA;AAChD,YAAA,IAAIkB,OAAO7B,IAAI,CAACwC,eAAAA,CAAAA,CAAiBH,MAAM,KAAK,CAAA,EAAG;gBAC7CL,MAAAA,CAAOC,YAAY,CAACQ,UAAU,CAACjC,GAAAA,CAAAA;AAC/B,gBAAA;AACF,YAAA;AAEAwB,YAAAA,MAAAA,CAAOC,YAAY,CAACS,OAAO,CAAClC,GAAAA,EAAKa,IAAAA,CAAKC,SAAS,CAACkB,eAAAA,CAAAA,CAAAA;AAClD,QAAA;;IAEF,CAAA,EAAG;AAACvB,QAAAA,KAAAA;AAAOG,QAAAA,YAAAA;AAAcV,QAAAA;AAAM,KAAA,CAAA;IAE/B,OAAO;AAAEa,QAAAA;AAAW,KAAA;AACtB;;;;"}
1
+ {"version":3,"file":"usePersistentQueryParams.mjs","sources":["../../../admin/src/hooks/usePersistentQueryParams.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport {\n deepEncodeQueryValues,\n usePersistentStateScope,\n useQueryParams,\n} from '@strapi/admin/strapi-admin';\nimport get from 'lodash/get';\nimport set from 'lodash/set';\n\ntype PropertyPath = Parameters<typeof get>[1];\n\ninterface PersistentQueryConfigEntry {\n paths: PropertyPath[];\n scoped?: boolean;\n}\n\nconst filterObjectKeys = (obj: object, keys: PropertyPath[]) => {\n const result: Record<string, unknown> = {};\n\n for (const path of keys) {\n const value = get(obj, path);\n\n if (value !== undefined) {\n set(result, path, value);\n }\n }\n\n return result;\n};\n\nexport type PersistentQueryConfig = Record<string, PersistentQueryConfigEntry>;\n\nconst normalizeConfigEntry = (\n key: string,\n entry: PersistentQueryConfigEntry,\n scope: string | false | undefined\n) => {\n const { paths } = entry;\n const isScoped = entry.scoped === true && !!scope;\n\n return {\n key: isScoped ? `${key}:${scope}` : key,\n paths,\n };\n};\n\nexport const usePersistentPartialQueryParams = (config: PersistentQueryConfig) => {\n const scope = usePersistentStateScope();\n const [{ query }, setQuery] = useQueryParams();\n const clonedConfig = JSON.stringify(config);\n const [isHydrated, setIsHydrated] = useState(false);\n\n // load query params from local storge\n useEffect(() => {\n const mergedFilteredQuery: Record<string, unknown> = {};\n\n for (const [keyPrefix, entry] of Object.entries(config)) {\n const { key, paths } = normalizeConfigEntry(keyPrefix, entry, scope);\n\n const savedQueryParams = window.localStorage.getItem(key);\n if (!savedQueryParams) continue;\n\n let parsedSavedParams: Record<string, unknown>;\n try {\n parsedSavedParams = JSON.parse(savedQueryParams);\n } catch {\n continue;\n }\n if (Object.keys(parsedSavedParams).length === 0) continue;\n\n const filteredQuery = filterObjectKeys(parsedSavedParams, paths);\n Object.assign(mergedFilteredQuery, filteredQuery);\n }\n\n if (Object.keys(mergedFilteredQuery).length > 0) {\n const nextQuery: Record<string, unknown> = { ...mergedFilteredQuery, ...query };\n\n if (nextQuery.filters !== undefined) {\n //`setQuery` never encodes the values, and it cannot be fixed as it would introduce breaking changes.\n // This ensures that, when reading the persisted values and writing them in the URI, they are encoded properly.\n // We are only encoding the filters because we know they can hold values with special characters. We didn't bother\n // with the other query params because as of today, they are not expected to hold such values.\n nextQuery.filters = deepEncodeQueryValues(nextQuery.filters);\n }\n\n setQuery(nextQuery, 'push', true);\n }\n setIsHydrated(true);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [clonedConfig, scope]);\n\n // update local storage\n useEffect(() => {\n for (const [keyPrefix, entry] of Object.entries(config)) {\n const { key, paths } = normalizeConfigEntry(keyPrefix, entry, scope);\n\n const paramsToPersist = filterObjectKeys(query, paths);\n if (Object.keys(paramsToPersist).length === 0) {\n window.localStorage.removeItem(key);\n continue;\n }\n\n window.localStorage.setItem(key, JSON.stringify(paramsToPersist));\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [query, clonedConfig, scope]);\n\n return { isHydrated };\n};\n"],"names":["filterObjectKeys","obj","keys","result","path","value","get","undefined","set","normalizeConfigEntry","key","entry","scope","paths","isScoped","scoped","usePersistentPartialQueryParams","config","usePersistentStateScope","query","setQuery","useQueryParams","clonedConfig","JSON","stringify","isHydrated","setIsHydrated","useState","useEffect","mergedFilteredQuery","keyPrefix","Object","entries","savedQueryParams","window","localStorage","getItem","parsedSavedParams","parse","length","filteredQuery","assign","nextQuery","filters","deepEncodeQueryValues","paramsToPersist","removeItem","setItem"],"mappings":";;;;;AAiBA,MAAMA,gBAAAA,GAAmB,CAACC,GAAAA,EAAaC,IAAAA,GAAAA;AACrC,IAAA,MAAMC,SAAkC,EAAC;IAEzC,KAAK,MAAMC,QAAQF,IAAAA,CAAM;QACvB,MAAMG,KAAAA,GAAQC,IAAIL,GAAAA,EAAKG,IAAAA,CAAAA;AAEvB,QAAA,IAAIC,UAAUE,SAAAA,EAAW;AACvBC,YAAAA,GAAAA,CAAIL,QAAQC,IAAAA,EAAMC,KAAAA,CAAAA;AACpB,QAAA;AACF,IAAA;IAEA,OAAOF,MAAAA;AACT,CAAA;AAIA,MAAMM,oBAAAA,GAAuB,CAC3BC,GAAAA,EACAC,KAAAA,EACAC,KAAAA,GAAAA;IAEA,MAAM,EAAEC,KAAK,EAAE,GAAGF,KAAAA;AAClB,IAAA,MAAMG,WAAWH,KAAAA,CAAMI,MAAM,KAAK,IAAA,IAAQ,CAAC,CAACH,KAAAA;IAE5C,OAAO;AACLF,QAAAA,GAAAA,EAAKI,WAAW,CAAA,EAAGJ,GAAAA,CAAI,CAAC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AO;AAAEa,QAAAA;AAAW,KAAA;AACtB;;;;"}
@@ -111,6 +111,10 @@ const EMPTY_RELATION_RESULTS = [];
111
111
  // Use the documentId from the actual document, not the params (meta)
112
112
  const documentId = currentDocument.document?.documentId;
113
113
  const { formatMessage } = reactIntl.useIntl();
114
+ const emptyLabel = formatMessage({
115
+ id: 'content-manager.containers.empty-label',
116
+ defaultMessage: 'Untitled'
117
+ });
114
118
  const isMorph = props.attribute.relation.toLowerCase().includes('morph');
115
119
  const isDisabled = isMorph || disabled;
116
120
  // @ts-expect-error – `targetModel` exists on supported non-morph relations (morph is disabled).
@@ -178,7 +182,8 @@ const EMPTY_RELATION_RESULTS = [];
178
182
  const ctx = {
179
183
  field: field.value,
180
184
  href: `../${collections.COLLECTION_TYPES}/${targetModel}`,
181
- mainField: props.mainField
185
+ mainField: props.mainField,
186
+ emptyLabel
182
187
  };
183
188
  /**
184
189
  * Tidy up our data.
@@ -193,9 +198,11 @@ const EMPTY_RELATION_RESULTS = [];
193
198
  */ const connectItems = (field.value?.connect ?? []).map((rel)=>{
194
199
  const urlLocaleParam = rel.locale ? `?plugins[i18n][locale]=${rel.locale}` : '';
195
200
  if (rel.href) return rel;
201
+ const mainFieldValue = props.mainField ? rel[props.mainField.name] : undefined;
202
+ const hasEmptyMainField = mainFieldValue === '' || mainFieldValue === null;
196
203
  return {
197
204
  ...rel,
198
- label: rel.label ?? relations$1.getRelationLabel(rel, props.mainField),
205
+ label: hasEmptyMainField ? relations$1.getRelationLabel(rel, props.mainField, emptyLabel) : rel.label ?? relations$1.getRelationLabel(rel, props.mainField, emptyLabel),
199
206
  href: `../${collections.COLLECTION_TYPES}/${targetModel}/${rel.documentId}${urlLocaleParam}`
200
207
  };
201
208
  });
@@ -214,7 +221,8 @@ const EMPTY_RELATION_RESULTS = [];
214
221
  serverData,
215
222
  field.value,
216
223
  targetModel,
217
- props.mainField
224
+ props.mainField,
225
+ emptyLabel
218
226
  ]);
219
227
  const handleDisconnect = useHandleDisconnect(props.name, 'RelationsField');
220
228
  const handleConnect = React__namespace.useCallback((relation)=>{
@@ -233,7 +241,7 @@ const EMPTY_RELATION_RESULTS = [];
233
241
  */ __temp_key__: fractionalIndexing.generateNKeysBetween(lastItemInList?.__temp_key__ ?? null, null, 1)[0],
234
242
  // Fallback to `id` if there is no `mainField` value, which will overwrite the above `id` property with the exact same data.
235
243
  [props.mainField?.name ?? 'documentId']: relation[props.mainField?.name ?? 'documentId'],
236
- label: relations$1.getRelationLabel(relation, props.mainField),
244
+ label: relations$1.getRelationLabel(relation, props.mainField, emptyLabel),
237
245
  href: `../${collections.COLLECTION_TYPES}/${targetModel}/${relation.documentId}?${relation.locale ? `plugins[i18n][locale]=${relation.locale}` : ''}`
238
246
  };
239
247
  if (ONE_WAY_RELATIONS.includes(props.attribute.relation)) {
@@ -250,6 +258,7 @@ const EMPTY_RELATION_RESULTS = [];
250
258
  ]);
251
259
  }
252
260
  }, [
261
+ emptyLabel,
253
262
  field,
254
263
  handleDisconnect,
255
264
  onChangeRelationField,
@@ -337,12 +346,12 @@ const EMPTY_RELATION_RESULTS = [];
337
346
  /**
338
347
  * @description Adds a label and href to the relation object we use this to render
339
348
  * a better UI where we can link to the relation and display a human-readable label.
340
- */ const addLabelAndHref = ({ mainField, href })=>(relations)=>relations.map((relation)=>{
349
+ */ const addLabelAndHref = ({ mainField, href, emptyLabel })=>(relations)=>relations.map((relation)=>{
341
350
  return {
342
351
  ...relation,
343
352
  // Fallback to `id` if there is no `mainField` value, which will overwrite the above `documentId` property with the exact same data.
344
353
  [mainField?.name ?? 'documentId']: relation[mainField?.name ?? 'documentId'],
345
- label: relations$1.getRelationLabel(relation, mainField),
354
+ label: relations$1.getRelationLabel(relation, mainField, emptyLabel),
346
355
  href: `${href}/${relation.documentId}?${relation.locale ? `plugins[i18n][locale]=${relation.locale}` : ''}`
347
356
  };
348
357
  });
@@ -497,6 +506,10 @@ const MemoizedRelationsComboboxInput = /*#__PURE__*/ React__namespace.memo(Relat
497
506
  const RelationModalWithContext = ({ relation, name, placeholder, hasNextPage, isLoadingSearchRelations, isLoadingPermissions, handleChange, mainField, setSearchParams, fieldValue, data, ...props })=>{
498
507
  const [textValue, setTextValue] = React__namespace.useState('');
499
508
  const { formatMessage } = reactIntl.useIntl();
509
+ const emptyLabel = formatMessage({
510
+ id: 'content-manager.containers.empty-label',
511
+ defaultMessage: 'Untitled'
512
+ });
500
513
  const canCreate = DocumentRBAC.useDocumentRBAC('RelationModalWrapper', (state)=>state.canCreate);
501
514
  const fieldRef = strapiAdmin.useFocusInputField(name);
502
515
  const componentUID = ComponentContext.useComponent('RelationsField', (state)=>state.uid);
@@ -586,7 +599,7 @@ const RelationModalWithContext = ({ relation, name, placeholder, hasNextPage, is
586
599
  },
587
600
  ...props,
588
601
  children: options?.map((opt)=>{
589
- const textValue = relations$1.getRelationLabel(opt, mainField);
602
+ const textValue = relations$1.getRelationLabel(opt, mainField, emptyLabel);
590
603
  return /*#__PURE__*/ jsxRuntime.jsx(designSystem.ComboboxOption, {
591
604
  value: opt.id.toString(),
592
605
  textValue: textValue,
@@ -879,6 +892,10 @@ const ListItem = /*#__PURE__*/ React__namespace.memo(({ data, index, style })=>{
879
892
  const { ariaDescribedBy, canDrag = false, disabled = false, handleCancel, handleDisconnect, handleDropItem, handleGrabItem, handleMoveItem, name, relations, targetModel, documentParams, mainField } = data;
880
893
  const isDesktop = strapiAdmin.useIsDesktop();
881
894
  const { formatMessage } = reactIntl.useIntl();
895
+ const emptyLabel = formatMessage({
896
+ id: 'content-manager.containers.empty-label',
897
+ defaultMessage: 'Untitled'
898
+ });
882
899
  const { href, id, label: originalLabel, status: originalStatus, documentId, apiData, locale } = relations[index];
883
900
  /**
884
901
  * The code above attempts to retrieve the updated value of a relation that has not yet been saved.
@@ -894,7 +911,7 @@ const ListItem = /*#__PURE__*/ React__namespace.memo(({ data, index, style })=>{
894
911
  }, {
895
912
  skip: !isTemporary
896
913
  });
897
- const label = isTemporary && document ? relations$1.getRelationLabel(document, mainField) : originalLabel;
914
+ const label = isTemporary && document ? relations$1.getRelationLabel(document, mainField, emptyLabel) : originalLabel;
898
915
  const status = isTemporary && document ? document?.status : originalStatus;
899
916
  const [{ handlerId, isDragging, handleKeyDown }, relationRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop.useDragAndDrop(canDrag && !disabled, {
900
917
  type: `${dragAndDrop.ItemTypes.RELATION}_${name}`,
@@ -918,18 +935,19 @@ const ListItem = /*#__PURE__*/ React__namespace.memo(({ data, index, style })=>{
918
935
  dragPreviewRef
919
936
  ]);
920
937
  const safeDocumentId = documentId ?? apiData?.documentId;
921
- const safeLocale = locale ?? apiData?.locale ?? null;
938
+ const relationLocale = locale ?? apiData?.locale;
922
939
  const documentMeta = React__namespace.useMemo(()=>({
923
940
  documentId: safeDocumentId,
924
941
  model: targetModel,
925
942
  collectionType: RelationModal.getCollectionType(href),
926
943
  params: {
927
- locale: safeLocale
944
+ locale: relationLocale ?? documentParams?.locale ?? null
928
945
  }
929
946
  }), [
930
947
  safeDocumentId,
931
948
  href,
932
- safeLocale,
949
+ relationLocale,
950
+ documentParams,
933
951
  targetModel
934
952
  ]);
935
953
  return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {