@strapi/content-manager 5.12.6 → 5.13.0-beta.0
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.
- package/dist/admin/hooks/useDocumentActions.js +5 -1
- package/dist/admin/hooks/useDocumentActions.js.map +1 -1
- package/dist/admin/hooks/useDocumentActions.mjs +5 -1
- package/dist/admin/hooks/useDocumentActions.mjs.map +1 -1
- package/dist/admin/hooks/useDocumentContext.js.map +1 -1
- package/dist/admin/hooks/useDocumentContext.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/DocumentActions.js +206 -21
- package/dist/admin/pages/EditView/components/DocumentActions.js.map +1 -1
- package/dist/admin/pages/EditView/components/DocumentActions.mjs +208 -23
- package/dist/admin/pages/EditView/components/DocumentActions.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js +2 -0
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs +2 -0
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js +199 -137
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs +199 -137
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +89 -50
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +91 -52
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
- package/dist/admin/services/homepage.js +9 -5
- package/dist/admin/services/homepage.js.map +1 -1
- package/dist/admin/services/homepage.mjs +9 -5
- package/dist/admin/services/homepage.mjs.map +1 -1
- package/dist/admin/src/hooks/useDocumentContext.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.d.ts +26 -5
- package/dist/admin/translations/en.json.js +2 -1
- package/dist/admin/translations/en.json.js.map +1 -1
- package/dist/admin/translations/en.json.mjs +2 -1
- package/dist/admin/translations/en.json.mjs.map +1 -1
- package/dist/server/controllers/index.js +3 -1
- package/dist/server/controllers/index.js.map +1 -1
- package/dist/server/controllers/index.mjs +3 -1
- package/dist/server/controllers/index.mjs.map +1 -1
- package/dist/server/homepage/controllers/homepage.js +57 -0
- package/dist/server/homepage/controllers/homepage.js.map +1 -0
- package/dist/server/homepage/controllers/homepage.mjs +36 -0
- package/dist/server/homepage/controllers/homepage.mjs.map +1 -0
- package/dist/server/homepage/controllers/index.js +10 -0
- package/dist/server/homepage/controllers/index.js.map +1 -0
- package/dist/server/homepage/controllers/index.mjs +8 -0
- package/dist/server/homepage/controllers/index.mjs.map +1 -0
- package/dist/server/homepage/index.js +14 -0
- package/dist/server/homepage/index.js.map +1 -0
- package/dist/server/homepage/index.mjs +12 -0
- package/dist/server/homepage/index.mjs.map +1 -0
- package/dist/server/homepage/routes/homepage.js +25 -0
- package/dist/server/homepage/routes/homepage.js.map +1 -0
- package/dist/server/homepage/routes/homepage.mjs +23 -0
- package/dist/server/homepage/routes/homepage.mjs.map +1 -0
- package/dist/server/homepage/routes/index.js +13 -0
- package/dist/server/homepage/routes/index.js.map +1 -0
- package/dist/server/homepage/routes/index.mjs +11 -0
- package/dist/server/homepage/routes/index.mjs.map +1 -0
- package/dist/server/homepage/services/homepage.js +157 -0
- package/dist/server/homepage/services/homepage.js.map +1 -0
- package/dist/server/homepage/services/homepage.mjs +155 -0
- package/dist/server/homepage/services/homepage.mjs.map +1 -0
- package/dist/server/homepage/services/index.js +10 -0
- package/dist/server/homepage/services/index.js.map +1 -0
- package/dist/server/homepage/services/index.mjs +8 -0
- package/dist/server/homepage/services/index.mjs.map +1 -0
- package/dist/server/preview/services/preview.js +0 -1
- package/dist/server/preview/services/preview.js.map +1 -1
- package/dist/server/preview/services/preview.mjs +0 -1
- package/dist/server/preview/services/preview.mjs.map +1 -1
- package/dist/server/routes/index.js +3 -1
- package/dist/server/routes/index.js.map +1 -1
- package/dist/server/routes/index.mjs +3 -1
- package/dist/server/routes/index.mjs.map +1 -1
- package/dist/server/services/index.js +3 -1
- package/dist/server/services/index.js.map +1 -1
- package/dist/server/services/index.mjs +3 -1
- package/dist/server/services/index.mjs.map +1 -1
- package/dist/server/src/controllers/index.d.ts.map +1 -1
- package/dist/server/src/homepage/controllers/homepage.d.ts +7 -0
- package/dist/server/src/homepage/controllers/homepage.d.ts.map +1 -0
- package/dist/server/src/homepage/controllers/index.d.ts +2 -0
- package/dist/server/src/homepage/controllers/index.d.ts.map +1 -0
- package/dist/server/src/homepage/index.d.ts +16 -0
- package/dist/server/src/homepage/index.d.ts.map +1 -0
- package/dist/server/src/homepage/routes/homepage.d.ts +4 -0
- package/dist/server/src/homepage/routes/homepage.d.ts.map +1 -0
- package/dist/server/src/homepage/routes/index.d.ts +8 -0
- package/dist/server/src/homepage/routes/index.d.ts.map +1 -0
- package/dist/server/src/{services → homepage/services}/homepage.d.ts +1 -1
- package/dist/server/src/homepage/services/homepage.d.ts.map +1 -0
- package/dist/server/src/homepage/services/index.d.ts +9 -0
- package/dist/server/src/homepage/services/index.d.ts.map +1 -0
- package/dist/server/src/index.d.ts +7 -0
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/preview/services/preview.d.ts.map +1 -1
- package/dist/server/src/routes/index.d.ts +1 -0
- package/dist/server/src/routes/index.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +6 -0
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/server/src/services/homepage.d.ts.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Repeatable.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/Component/Repeatable.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useField, useNotification, useForm } from '@strapi/admin/strapi-admin';\nimport {\n Box,\n Flex,\n TextButton,\n VisuallyHidden,\n Accordion,\n IconButton,\n useComposedRefs,\n BoxComponent,\n} from '@strapi/design-system';\nimport { Plus, Drag, Trash } from '@strapi/icons';\nimport { getEmptyImage } from 'react-dnd-html5-backend';\nimport { useIntl } from 'react-intl';\nimport { useLocation } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { ItemTypes } from '../../../../../constants/dragAndDrop';\nimport { useDocumentContext } from '../../../../../hooks/useDocumentContext';\nimport { useDragAndDrop, type UseDragAndDropOptions } from '../../../../../hooks/useDragAndDrop';\nimport { usePrev } from '../../../../../hooks/usePrev';\nimport { getIn } from '../../../../../utils/objects';\nimport { getTranslation } from '../../../../../utils/translations';\nimport { transformDocument } from '../../../utils/data';\nimport { createDefaultForm } from '../../../utils/forms';\nimport { ResponsiveGridItem, ResponsiveGridRoot } from '../../FormLayout';\nimport { ComponentProvider, useComponent } from '../ComponentContext';\n\nimport { Initializer } from './Initializer';\n\nimport type { ComponentInputProps } from './Input';\nimport type { Schema } from '@strapi/types';\n\n/* -------------------------------------------------------------------------------------------------\n * RepeatableComponent\n * -----------------------------------------------------------------------------------------------*/\n\ntype RepeatableComponentProps = Omit<ComponentInputProps, 'required' | 'label'>;\n\nconst RepeatableComponent = ({\n attribute,\n disabled,\n name,\n mainField,\n children,\n layout,\n}: RepeatableComponentProps) => {\n const { toggleNotification } = useNotification();\n const { formatMessage } = useIntl();\n const { search: searchString } = useLocation();\n const search = React.useMemo(() => new URLSearchParams(searchString), [searchString]);\n const { currentDocument } = useDocumentContext('RepeatableComponent');\n const components = currentDocument.components;\n\n const {\n value = [],\n error,\n rawError,\n } = useField<Schema.Attribute.ComponentValue<`${string}.${string}`, true>>(name);\n const addFieldRow = useForm('RepeatableComponent', (state) => state.addFieldRow);\n const moveFieldRow = useForm('RepeatableComponent', (state) => state.moveFieldRow);\n const removeFieldRow = useForm('RepeatableComponent', (state) => state.removeFieldRow);\n const { max = Infinity } = attribute;\n\n const [collapseToOpen, setCollapseToOpen] = React.useState<string>('');\n const [liveText, setLiveText] = React.useState('');\n\n React.useEffect(() => {\n const hasNestedErrors = rawError && Array.isArray(rawError) && rawError.length > 0;\n const hasNestedValue = value && Array.isArray(value) && value.length > 0;\n\n if (hasNestedErrors && hasNestedValue) {\n const errorOpenItems = rawError\n .map((_: unknown, idx: number) => {\n return value[idx] ? value[idx].__temp_key__ : null;\n })\n .filter((value) => !!value);\n\n if (errorOpenItems && errorOpenItems.length > 0) {\n setCollapseToOpen((collapseToOpen) => {\n if (!errorOpenItems.includes(collapseToOpen)) {\n return errorOpenItems[0];\n }\n\n return collapseToOpen;\n });\n }\n }\n }, [rawError, value]);\n\n /**\n * Get the temp key of the component that has the field that is currently focussed\n * as defined by the `field` query param. We can then force this specific component\n * to be in its \"open\" state.\n */\n const componentTmpKeyWithFocussedField = React.useMemo(() => {\n if (search.has('field')) {\n const fieldParam = search.get('field');\n\n if (!fieldParam) {\n return undefined;\n }\n\n const [, path] = fieldParam.split(`${name}.`);\n\n if (getIn(value, path, undefined) !== undefined) {\n const [subpath] = path.split('.');\n\n return getIn(value, subpath, undefined)?.__temp_key__;\n }\n }\n\n return undefined;\n }, [search, name, value]);\n\n const prevValue = usePrev(value);\n\n React.useEffect(() => {\n /**\n * When we add a new item to the array, we want to open the collapse.\n */\n if (prevValue && prevValue.length < value.length) {\n setCollapseToOpen(value[value.length - 1].__temp_key__);\n }\n }, [value, prevValue]);\n\n React.useEffect(() => {\n if (typeof componentTmpKeyWithFocussedField === 'string') {\n setCollapseToOpen(componentTmpKeyWithFocussedField);\n }\n }, [componentTmpKeyWithFocussedField]);\n\n const toggleCollapses = () => {\n setCollapseToOpen('');\n };\n\n const handleClick = () => {\n if (value.length < max) {\n const schema = components[attribute.component];\n const form = createDefaultForm(schema, components);\n const data = transformDocument(schema, components)(form);\n\n addFieldRow(name, data);\n // setCollapseToOpen(nextTempKey);\n } else if (value.length >= max) {\n toggleNotification({\n type: 'info',\n message: formatMessage({\n id: getTranslation('components.notification.info.maximum-requirement'),\n }),\n });\n }\n };\n\n const handleMoveComponentField: ComponentProps['onMoveItem'] = (newIndex, currentIndex) => {\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.reorder'),\n defaultMessage: '{item}, moved. New position in list: {position}.',\n },\n {\n item: `${name}.${currentIndex}`,\n position: getItemPos(newIndex),\n }\n )\n );\n\n moveFieldRow(name, currentIndex, newIndex);\n };\n\n const handleValueChange = (key: string) => {\n setCollapseToOpen(key);\n };\n\n const getItemPos = (index: number) => `${index + 1} of ${value.length}`;\n\n const handleCancel = (index: number) => {\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.cancel-item'),\n defaultMessage: '{item}, dropped. Re-order cancelled.',\n },\n {\n item: `${name}.${index}`,\n }\n )\n );\n };\n\n const handleGrabItem = (index: number) => {\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.grab-item'),\n defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`,\n },\n {\n item: `${name}.${index}`,\n position: getItemPos(index),\n }\n )\n );\n };\n\n const handleDropItem = (index: number) => {\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.drop-item'),\n defaultMessage: `{item}, dropped. Final position in list: {position}.`,\n },\n {\n item: `${name}.${index}`,\n position: getItemPos(index),\n }\n )\n );\n };\n\n const ariaDescriptionId = React.useId();\n\n const level = useComponent('RepeatableComponent', (state) => state.level);\n\n if (value.length === 0) {\n return <Initializer disabled={disabled} name={name} onClick={handleClick} />;\n }\n\n return (\n <Box hasRadius>\n <VisuallyHidden id={ariaDescriptionId}>\n {formatMessage({\n id: getTranslation('dnd.instructions'),\n defaultMessage: `Press spacebar to grab and re-order`,\n })}\n </VisuallyHidden>\n <VisuallyHidden aria-live=\"assertive\">{liveText}</VisuallyHidden>\n <AccordionRoot\n $error={error}\n value={collapseToOpen}\n onValueChange={handleValueChange}\n aria-describedby={ariaDescriptionId}\n >\n {value.map(({ __temp_key__: key, id }, index) => {\n const nameWithIndex = `${name}.${index}`;\n return (\n <ComponentProvider\n key={key}\n // id is always a number in a component\n id={id as number}\n uid={attribute.component}\n level={level + 1}\n type=\"repeatable\"\n >\n <Component\n disabled={disabled}\n name={nameWithIndex}\n attribute={attribute}\n index={index}\n mainField={mainField}\n onMoveItem={handleMoveComponentField}\n onDeleteComponent={() => {\n removeFieldRow(name, index);\n toggleCollapses();\n }}\n toggleCollapses={toggleCollapses}\n onCancel={handleCancel}\n onDropItem={handleDropItem}\n onGrabItem={handleGrabItem}\n __temp_key__={key}\n >\n {layout.map((row, index) => {\n return (\n <ResponsiveGridRoot gap={4} key={index}>\n {row.map(({ size, ...field }) => {\n /**\n * Layouts are built from schemas so they don't understand the complete\n * schema tree, for components we append the parent name to the field name\n * because this is the structure for the data & permissions also understand\n * the nesting involved.\n */\n const completeFieldName = `${nameWithIndex}.${field.name}`;\n\n const translatedLabel = formatMessage({\n id: `content-manager.components.${attribute.component}.${field.name}`,\n defaultMessage: field.label,\n });\n\n return (\n <ResponsiveGridItem\n col={size}\n key={completeFieldName}\n s={12}\n xs={12}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n {children({\n ...field,\n label: translatedLabel,\n name: completeFieldName,\n document: currentDocument,\n })}\n </ResponsiveGridItem>\n );\n })}\n </ResponsiveGridRoot>\n );\n })}\n </Component>\n </ComponentProvider>\n );\n })}\n <TextButtonCustom disabled={disabled} onClick={handleClick} startIcon={<Plus />}>\n {formatMessage({\n id: getTranslation('containers.EditView.add.new-entry'),\n defaultMessage: 'Add an entry',\n })}\n </TextButtonCustom>\n </AccordionRoot>\n </Box>\n );\n};\n\nconst AccordionRoot = styled(Accordion.Root)<{ $error?: string }>`\n border: 1px solid\n ${({ theme, $error }) => ($error ? theme.colors.danger600 : theme.colors.neutral200)};\n`;\n\nconst TextButtonCustom = styled(TextButton)`\n width: 100%;\n display: flex;\n justify-content: center;\n border-top: 1px solid ${({ theme }) => theme.colors.neutral200};\n padding-inline: ${(props) => props.theme.spaces[6]};\n padding-block: ${(props) => props.theme.spaces[3]};\n\n &:not([disabled]) {\n cursor: pointer;\n\n &:hover {\n background-color: ${(props) => props.theme.colors.primary100};\n }\n }\n\n span {\n font-weight: 600;\n font-size: 1.4rem;\n line-height: 2.4rem;\n }\n\n @media (prefers-reduced-motion: no-preference) {\n transition: background-color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};\n }\n`;\n\n/* -------------------------------------------------------------------------------------------------\n * Field\n * -----------------------------------------------------------------------------------------------*/\n\ninterface ComponentProps\n extends Pick<UseDragAndDropOptions, 'onGrabItem' | 'onDropItem' | 'onCancel' | 'onMoveItem'>,\n Pick<RepeatableComponentProps, 'mainField'> {\n attribute: Schema.Attribute.Component<`${string}.${string}`, boolean>;\n disabled?: boolean;\n index: number;\n name: string;\n onDeleteComponent?: React.MouseEventHandler<HTMLButtonElement>;\n toggleCollapses: () => void;\n children: React.ReactNode;\n __temp_key__: string;\n}\n\nconst Component = ({\n disabled,\n index,\n name,\n mainField = {\n name: 'id',\n type: 'integer',\n },\n children,\n onDeleteComponent,\n toggleCollapses,\n __temp_key__,\n ...dragProps\n}: ComponentProps) => {\n const { formatMessage } = useIntl();\n\n const displayValue = useForm('RepeatableComponent', (state) => {\n return getIn(state.values, [...name.split('.'), mainField.name]);\n });\n\n const accordionRef = React.useRef<HTMLButtonElement>(null!);\n\n /**\n * The last item in the fieldName array will be the index of this component.\n * Drag and drop should be isolated to the parent component so nested repeatable\n * components are not affected by the drag and drop of the parent component in\n * their own re-ordering context.\n */\n const componentKey = name.split('.').slice(0, -1).join('.');\n\n const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] =\n useDragAndDrop(!disabled, {\n type: `${ItemTypes.COMPONENT}_${componentKey}`,\n index,\n item: {\n index,\n displayedValue: displayValue,\n },\n onStart() {\n // Close all collapses\n toggleCollapses();\n },\n ...dragProps,\n });\n\n React.useEffect(() => {\n dragPreviewRef(getEmptyImage(), { captureDraggingState: false });\n }, [dragPreviewRef, index]);\n\n const composedAccordionRefs = useComposedRefs<HTMLButtonElement>(accordionRef, dragRef);\n const composedBoxRefs = useComposedRefs<HTMLDivElement>(\n boxRef as React.RefObject<HTMLDivElement>,\n dropRef\n );\n\n return (\n <>\n {isDragging ? (\n <Preview />\n ) : (\n <Accordion.Item ref={composedBoxRefs} value={__temp_key__}>\n <Accordion.Header>\n <Accordion.Trigger>{displayValue}</Accordion.Trigger>\n <Accordion.Actions>\n <IconButton\n variant=\"ghost\"\n onClick={onDeleteComponent}\n label={formatMessage({\n id: getTranslation('containers.Edit.delete'),\n defaultMessage: 'Delete',\n })}\n >\n <Trash />\n </IconButton>\n <IconButton\n ref={composedAccordionRefs}\n variant=\"ghost\"\n onClick={(e) => e.stopPropagation()}\n data-handler-id={handlerId}\n label={formatMessage({\n id: getTranslation('components.DragHandle-label'),\n defaultMessage: 'Drag',\n })}\n onKeyDown={handleKeyDown}\n >\n <Drag />\n </IconButton>\n </Accordion.Actions>\n </Accordion.Header>\n <Accordion.Content>\n <Flex\n direction=\"column\"\n alignItems=\"stretch\"\n background=\"neutral100\"\n padding={6}\n gap={6}\n >\n {children}\n </Flex>\n </Accordion.Content>\n </Accordion.Item>\n )}\n </>\n );\n};\n\nconst Preview = () => {\n return <StyledSpan tag=\"span\" padding={6} background=\"primary100\" />;\n};\n\nconst StyledSpan = styled<BoxComponent<'span'>>(Box)`\n display: block;\n outline: 1px dashed ${({ theme }) => theme.colors.primary500};\n outline-offset: -1px;\n`;\n\nexport { RepeatableComponent };\nexport type { RepeatableComponentProps };\n"],"names":["RepeatableComponent","attribute","disabled","name","mainField","children","layout","toggleNotification","useNotification","formatMessage","useIntl","search","searchString","useLocation","React","useMemo","URLSearchParams","currentDocument","useDocumentContext","components","value","error","rawError","useField","addFieldRow","useForm","state","moveFieldRow","removeFieldRow","max","Infinity","collapseToOpen","setCollapseToOpen","useState","liveText","setLiveText","useEffect","hasNestedErrors","Array","isArray","length","hasNestedValue","errorOpenItems","map","_","idx","__temp_key__","filter","includes","componentTmpKeyWithFocussedField","has","fieldParam","get","undefined","path","split","getIn","subpath","prevValue","usePrev","toggleCollapses","handleClick","schema","component","form","createDefaultForm","data","transformDocument","type","message","id","getTranslation","handleMoveComponentField","newIndex","currentIndex","defaultMessage","item","position","getItemPos","handleValueChange","key","index","handleCancel","handleGrabItem","handleDropItem","ariaDescriptionId","useId","level","useComponent","_jsx","Initializer","onClick","_jsxs","Box","hasRadius","VisuallyHidden","aria-live","AccordionRoot","$error","onValueChange","aria-describedby","nameWithIndex","ComponentProvider","uid","Component","onMoveItem","onDeleteComponent","onCancel","onDropItem","onGrabItem","row","ResponsiveGridRoot","gap","size","field","completeFieldName","translatedLabel","label","ResponsiveGridItem","col","s","xs","direction","alignItems","document","TextButtonCustom","startIcon","Plus","styled","Accordion","Root","theme","colors","danger600","neutral200","TextButton","props","spaces","primary100","motion","easings","easeOutQuad","dragProps","displayValue","values","accordionRef","useRef","componentKey","slice","join","handlerId","isDragging","handleKeyDown","boxRef","dropRef","dragRef","dragPreviewRef","useDragAndDrop","ItemTypes","COMPONENT","displayedValue","onStart","getEmptyImage","captureDraggingState","composedAccordionRefs","useComposedRefs","composedBoxRefs","_Fragment","Preview","Item","ref","Header","Trigger","Actions","IconButton","variant","Trash","e","stopPropagation","data-handler-id","onKeyDown","Drag","Content","Flex","background","padding","StyledSpan","tag","primary500"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyCA,MAAMA,mBAAsB,GAAA,CAAC,EAC3BC,SAAS,EACTC,QAAQ,EACRC,IAAI,EACJC,SAAS,EACTC,QAAQ,EACRC,MAAM,EACmB,GAAA;IACzB,MAAM,EAAEC,kBAAkB,EAAE,GAAGC,eAAAA,EAAAA;IAC/B,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;AAC1B,IAAA,MAAM,EAAEC,MAAAA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X,oCAAA,QAAA,gBAAA/D,GAAC4F,CAAAA,IAAAA,EAAAA,EAAAA;;;;;;AAIP,8BAAA5F,GAAA,CAACwC,UAAUqD,OAAO,EAAA;AAChB,oBAAA,QAAA,gBAAA7F,GAAC8F,CAAAA,IAAAA,EAAAA;wBACC7D,SAAU,EAAA,QAAA;wBACVC,UAAW,EAAA,SAAA;wBACX6D,UAAW,EAAA,YAAA;wBACXC,OAAS,EAAA,CAAA;wBACTzE,GAAK,EAAA,CAAA;AAEJ3G,wBAAAA,QAAAA,EAAAA;;;;;;AAOf,CAAA;AAEA,MAAMmK,OAAU,GAAA,IAAA;AACd,IAAA,qBAAO/E,GAACiG,CAAAA,UAAAA,EAAAA;QAAWC,GAAI,EAAA,MAAA;QAAOF,OAAS,EAAA,CAAA;QAAGD,UAAW,EAAA;;AACvD,CAAA;AAEA,MAAME,UAAAA,GAAa1D,MAA6BnC,CAAAA,GAAAA,CAAI;;sBAE9B,EAAE,CAAC,EAAEsC,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAACwD,UAAU,CAAC;;AAE/D,CAAC;;;;"}
|
1
|
+
{"version":3,"file":"Repeatable.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/Component/Repeatable.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useField, useNotification, useForm } from '@strapi/admin/strapi-admin';\nimport {\n Box,\n Flex,\n TextButton,\n VisuallyHidden,\n Accordion,\n IconButton,\n useComposedRefs,\n BoxComponent,\n} from '@strapi/design-system';\nimport { Plus, Drag, Trash } from '@strapi/icons';\nimport { getEmptyImage } from 'react-dnd-html5-backend';\nimport { useIntl } from 'react-intl';\nimport { useLocation } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { ItemTypes } from '../../../../../constants/dragAndDrop';\nimport { useDocumentContext } from '../../../../../hooks/useDocumentContext';\nimport { useDragAndDrop, type UseDragAndDropOptions } from '../../../../../hooks/useDragAndDrop';\nimport { usePrev } from '../../../../../hooks/usePrev';\nimport { getIn } from '../../../../../utils/objects';\nimport { getTranslation } from '../../../../../utils/translations';\nimport { transformDocument } from '../../../utils/data';\nimport { createDefaultForm } from '../../../utils/forms';\nimport { ResponsiveGridItem, ResponsiveGridRoot } from '../../FormLayout';\nimport { ComponentProvider, useComponent } from '../ComponentContext';\n\nimport { Initializer } from './Initializer';\n\nimport type { ComponentInputProps } from './Input';\nimport type { Schema } from '@strapi/types';\n\n/* -------------------------------------------------------------------------------------------------\n * RepeatableComponent\n * -----------------------------------------------------------------------------------------------*/\n\ntype RepeatableComponentProps = Omit<ComponentInputProps, 'required' | 'label'>;\n\nconst RepeatableComponent = ({\n attribute,\n disabled,\n name,\n mainField,\n children,\n layout,\n}: RepeatableComponentProps) => {\n const { toggleNotification } = useNotification();\n const { formatMessage } = useIntl();\n const { search: searchString } = useLocation();\n const search = React.useMemo(() => new URLSearchParams(searchString), [searchString]);\n const { currentDocument } = useDocumentContext('RepeatableComponent');\n const components = currentDocument.components;\n\n const {\n value = [],\n error,\n rawError,\n } = useField<Schema.Attribute.ComponentValue<`${string}.${string}`, true>>(name);\n const addFieldRow = useForm('RepeatableComponent', (state) => state.addFieldRow);\n const moveFieldRow = useForm('RepeatableComponent', (state) => state.moveFieldRow);\n const removeFieldRow = useForm('RepeatableComponent', (state) => state.removeFieldRow);\n const { max = Infinity } = attribute;\n\n const [collapseToOpen, setCollapseToOpen] = React.useState<string>('');\n const [liveText, setLiveText] = React.useState('');\n\n React.useEffect(() => {\n const hasNestedErrors = rawError && Array.isArray(rawError) && rawError.length > 0;\n const hasNestedValue = value && Array.isArray(value) && value.length > 0;\n\n if (hasNestedErrors && hasNestedValue) {\n const errorOpenItems = rawError\n .map((_: unknown, idx: number) => {\n return value[idx] ? value[idx].__temp_key__ : null;\n })\n .filter((value) => !!value);\n\n if (errorOpenItems && errorOpenItems.length > 0) {\n setCollapseToOpen((collapseToOpen) => {\n if (!errorOpenItems.includes(collapseToOpen)) {\n return errorOpenItems[0];\n }\n\n return collapseToOpen;\n });\n }\n }\n }, [rawError, value]);\n\n /**\n * Get the temp key of the component that has the field that is currently focussed\n * as defined by the `field` query param. We can then force this specific component\n * to be in its \"open\" state.\n */\n const componentTmpKeyWithFocussedField = React.useMemo(() => {\n if (search.has('field')) {\n const fieldParam = search.get('field');\n\n if (!fieldParam) {\n return undefined;\n }\n\n const [, path] = fieldParam.split(`${name}.`);\n\n if (getIn(value, path, undefined) !== undefined) {\n const [subpath] = path.split('.');\n\n return getIn(value, subpath, undefined)?.__temp_key__;\n }\n }\n\n return undefined;\n }, [search, name, value]);\n\n const prevValue = usePrev(value);\n\n React.useEffect(() => {\n /**\n * When we add a new item to the array, we want to open the collapse.\n */\n if (prevValue && prevValue.length < value.length) {\n setCollapseToOpen(value[value.length - 1].__temp_key__);\n }\n }, [value, prevValue]);\n\n React.useEffect(() => {\n if (typeof componentTmpKeyWithFocussedField === 'string') {\n setCollapseToOpen(componentTmpKeyWithFocussedField);\n }\n }, [componentTmpKeyWithFocussedField]);\n\n const toggleCollapses = () => {\n setCollapseToOpen('');\n };\n\n const handleClick = () => {\n if (value.length < max) {\n const schema = components[attribute.component];\n const form = createDefaultForm(schema, components);\n const data = transformDocument(schema, components)(form);\n\n addFieldRow(name, data);\n // setCollapseToOpen(nextTempKey);\n } else if (value.length >= max) {\n toggleNotification({\n type: 'info',\n message: formatMessage({\n id: getTranslation('components.notification.info.maximum-requirement'),\n }),\n });\n }\n };\n\n const handleMoveComponentField: ComponentProps['onMoveItem'] = (newIndex, currentIndex) => {\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.reorder'),\n defaultMessage: '{item}, moved. New position in list: {position}.',\n },\n {\n item: `${name}.${currentIndex}`,\n position: getItemPos(newIndex),\n }\n )\n );\n\n moveFieldRow(name, currentIndex, newIndex);\n };\n\n const handleValueChange = (key: string) => {\n setCollapseToOpen(key);\n };\n\n const getItemPos = (index: number) => `${index + 1} of ${value.length}`;\n\n const handleCancel = (index: number) => {\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.cancel-item'),\n defaultMessage: '{item}, dropped. Re-order cancelled.',\n },\n {\n item: `${name}.${index}`,\n }\n )\n );\n };\n\n const handleGrabItem = (index: number) => {\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.grab-item'),\n defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`,\n },\n {\n item: `${name}.${index}`,\n position: getItemPos(index),\n }\n )\n );\n };\n\n const handleDropItem = (index: number) => {\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.drop-item'),\n defaultMessage: `{item}, dropped. Final position in list: {position}.`,\n },\n {\n item: `${name}.${index}`,\n position: getItemPos(index),\n }\n )\n );\n };\n\n const ariaDescriptionId = React.useId();\n\n const level = useComponent('RepeatableComponent', (state) => state.level);\n\n if (value.length === 0) {\n return <Initializer disabled={disabled} name={name} onClick={handleClick} />;\n }\n\n return (\n <Box hasRadius>\n <VisuallyHidden id={ariaDescriptionId}>\n {formatMessage({\n id: getTranslation('dnd.instructions'),\n defaultMessage: `Press spacebar to grab and re-order`,\n })}\n </VisuallyHidden>\n <VisuallyHidden aria-live=\"assertive\">{liveText}</VisuallyHidden>\n <AccordionRoot\n $error={error}\n value={collapseToOpen}\n onValueChange={handleValueChange}\n aria-describedby={ariaDescriptionId}\n >\n {value.map(({ __temp_key__: key, id }, index) => {\n const nameWithIndex = `${name}.${index}`;\n return (\n <ComponentProvider\n key={key}\n // id is always a number in a component\n id={id as number}\n uid={attribute.component}\n level={level + 1}\n type=\"repeatable\"\n >\n <Component\n disabled={disabled}\n name={nameWithIndex}\n attribute={attribute}\n index={index}\n mainField={mainField}\n onMoveItem={handleMoveComponentField}\n onDeleteComponent={() => {\n removeFieldRow(name, index);\n toggleCollapses();\n }}\n toggleCollapses={toggleCollapses}\n onCancel={handleCancel}\n onDropItem={handleDropItem}\n onGrabItem={handleGrabItem}\n __temp_key__={key}\n >\n {layout.map((row, index) => {\n return (\n <ResponsiveGridRoot gap={4} key={index}>\n {row.map(({ size, ...field }) => {\n /**\n * Layouts are built from schemas so they don't understand the complete\n * schema tree, for components we append the parent name to the field name\n * because this is the structure for the data & permissions also understand\n * the nesting involved.\n */\n const completeFieldName = `${nameWithIndex}.${field.name}`;\n\n const translatedLabel = formatMessage({\n id: `content-manager.components.${attribute.component}.${field.name}`,\n defaultMessage: field.label,\n });\n\n return (\n <ResponsiveGridItem\n col={size}\n key={completeFieldName}\n s={12}\n xs={12}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n {children({\n ...field,\n label: translatedLabel,\n name: completeFieldName,\n document: currentDocument,\n })}\n </ResponsiveGridItem>\n );\n })}\n </ResponsiveGridRoot>\n );\n })}\n </Component>\n </ComponentProvider>\n );\n })}\n <TextButtonCustom disabled={disabled} onClick={handleClick} startIcon={<Plus />}>\n {formatMessage({\n id: getTranslation('containers.EditView.add.new-entry'),\n defaultMessage: 'Add an entry',\n })}\n </TextButtonCustom>\n </AccordionRoot>\n </Box>\n );\n};\n\nconst AccordionRoot = styled(Accordion.Root)<{ $error?: string }>`\n border: 1px solid\n ${({ theme, $error }) => ($error ? theme.colors.danger600 : theme.colors.neutral200)};\n`;\n\nconst TextButtonCustom = styled(TextButton)`\n width: 100%;\n display: flex;\n justify-content: center;\n border-top: 1px solid ${({ theme }) => theme.colors.neutral200};\n padding-inline: ${(props) => props.theme.spaces[6]};\n padding-block: ${(props) => props.theme.spaces[3]};\n\n &:not([disabled]) {\n cursor: pointer;\n\n &:hover {\n background-color: ${(props) => props.theme.colors.primary100};\n }\n }\n\n span {\n font-weight: 600;\n font-size: 1.4rem;\n line-height: 2.4rem;\n }\n\n @media (prefers-reduced-motion: no-preference) {\n transition: background-color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};\n }\n`;\n\n/* -------------------------------------------------------------------------------------------------\n * Field\n * -----------------------------------------------------------------------------------------------*/\n\ninterface ComponentProps\n extends Pick<UseDragAndDropOptions, 'onGrabItem' | 'onDropItem' | 'onCancel' | 'onMoveItem'>,\n Pick<RepeatableComponentProps, 'mainField'> {\n attribute: Schema.Attribute.Component<`${string}.${string}`, boolean>;\n disabled?: boolean;\n index: number;\n name: string;\n onDeleteComponent?: React.MouseEventHandler<HTMLButtonElement>;\n toggleCollapses: () => void;\n children: React.ReactNode;\n __temp_key__: string;\n}\n\nconst Component = ({\n disabled,\n index,\n name,\n mainField = {\n name: 'id',\n type: 'integer',\n },\n children,\n onDeleteComponent,\n toggleCollapses,\n __temp_key__,\n ...dragProps\n}: ComponentProps) => {\n const { formatMessage } = useIntl();\n\n const displayValue = useForm('RepeatableComponent', (state) => {\n return getIn(state.values, [...name.split('.'), mainField.name]);\n });\n\n const accordionRef = React.useRef<HTMLButtonElement>(null!);\n\n /**\n * The last item in the fieldName array will be the index of this component.\n * Drag and drop should be isolated to the parent component so nested repeatable\n * components are not affected by the drag and drop of the parent component in\n * their own re-ordering context.\n */\n const componentKey = name.split('.').slice(0, -1).join('.');\n\n const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] =\n useDragAndDrop(!disabled, {\n type: `${ItemTypes.COMPONENT}_${componentKey}`,\n index,\n item: {\n index,\n displayedValue: displayValue,\n },\n onStart() {\n // Close all collapses\n toggleCollapses();\n },\n ...dragProps,\n });\n\n React.useEffect(() => {\n dragPreviewRef(getEmptyImage(), { captureDraggingState: false });\n }, [dragPreviewRef, index]);\n\n const composedAccordionRefs = useComposedRefs<HTMLButtonElement>(accordionRef, dragRef);\n const composedBoxRefs = useComposedRefs<HTMLDivElement>(\n boxRef as React.RefObject<HTMLDivElement>,\n dropRef\n );\n\n return (\n <>\n {isDragging ? (\n <Preview />\n ) : (\n <Accordion.Item ref={composedBoxRefs} value={__temp_key__}>\n <Accordion.Header>\n <Accordion.Trigger>{displayValue}</Accordion.Trigger>\n <Accordion.Actions>\n <IconButton\n disabled={disabled}\n variant=\"ghost\"\n onClick={onDeleteComponent}\n label={formatMessage({\n id: getTranslation('containers.Edit.delete'),\n defaultMessage: 'Delete',\n })}\n >\n <Trash />\n </IconButton>\n <IconButton\n disabled={disabled}\n ref={composedAccordionRefs}\n variant=\"ghost\"\n onClick={(e) => e.stopPropagation()}\n data-handler-id={handlerId}\n label={formatMessage({\n id: getTranslation('components.DragHandle-label'),\n defaultMessage: 'Drag',\n })}\n onKeyDown={handleKeyDown}\n >\n <Drag />\n </IconButton>\n </Accordion.Actions>\n </Accordion.Header>\n <Accordion.Content>\n <Flex\n direction=\"column\"\n alignItems=\"stretch\"\n background=\"neutral100\"\n padding={6}\n gap={6}\n >\n {children}\n </Flex>\n </Accordion.Content>\n </Accordion.Item>\n )}\n </>\n );\n};\n\nconst Preview = () => {\n return <StyledSpan tag=\"span\" padding={6} background=\"primary100\" />;\n};\n\nconst StyledSpan = styled<BoxComponent<'span'>>(Box)`\n display: block;\n outline: 1px dashed ${({ theme }) => theme.colors.primary500};\n outline-offset: -1px;\n`;\n\nexport { RepeatableComponent };\nexport type { RepeatableComponentProps };\n"],"names":["RepeatableComponent","attribute","disabled","name","mainField","children","layout","toggleNotification","useNotification","formatMessage","useIntl","search","searchString","useLocation","React","useMemo","URLSearchParams","currentDocument","useDocumentContext","components","value","error","rawError","useField","addFieldRow","useForm","state","moveFieldRow","removeFieldRow","max","Infinity","collapseToOpen","setCollapseToOpen","useState","liveText","setLiveText","useEffect","hasNestedErrors","Array","isArray","length","hasNestedValue","errorOpenItems","map","_","idx","__temp_key__","filter","includes","componentTmpKeyWithFocussedField","has","fieldParam","get","undefined","path","split","getIn","subpath","prevValue","usePrev","toggleCollapses","handleClick","schema","component","form","createDefaultForm","data","transformDocument","type","message","id","getTranslation","handleMoveComponentField","newIndex","currentIndex","defaultMessage","item","position","getItemPos","handleValueChange","key","index","handleCancel","handleGrabItem","handleDropItem","ariaDescriptionId","useId","level","useComponent","_jsx","Initializer","onClick","_jsxs","Box","hasRadius","VisuallyHidden","aria-live","AccordionRoot","$error","onValueChange","aria-describedby","nameWithIndex","ComponentProvider","uid","Component","onMoveItem","onDeleteComponent","onCancel","onDropItem","onGrabItem","row","ResponsiveGridRoot","gap","size","field","completeFieldName","translatedLabel","label","ResponsiveGridItem","col","s","xs","direction","alignItems","document","TextButtonCustom","startIcon","Plus","styled","Accordion","Root","theme","colors","danger600","neutral200","TextButton","props","spaces","primary100","motion","easings","easeOutQuad","dragProps","displayValue","values","accordionRef","useRef","componentKey","slice","join","handlerId","isDragging","handleKeyDown","boxRef","dropRef","dragRef","dragPreviewRef","useDragAndDrop","ItemTypes","COMPONENT","displayedValue","onStart","getEmptyImage","captureDraggingState","composedAccordionRefs","useComposedRefs","composedBoxRefs","_Fragment","Preview","Item","ref","Header","Trigger","Actions","IconButton","variant","Trash","e","stopPropagation","data-handler-id","onKeyDown","Drag","Content","Flex","background","padding","StyledSpan","tag","primary500"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyCA,MAAMA,mBAAsB,GAAA,CAAC,EAC3BC,SAAS,EACTC,QAAQ,EACRC,IAAI,EACJC,SAAS,EACTC,QAAQ,EACRC,MAAM,EACmB,GAAA;IACzB,MAAM,EAAEC,kBAAkB,EAAE,GAAGC,eAAAA,EAAAA;IAC/B,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;AAC1B,IAAA,MAAM,EAAEC,MAAAA,EAAQC,YAAY,EAAE,GAAGC,WAAAA,EAAAA;AACjC,IAAA,MAAMF,SAASG,KAAMC,CAAAA,OAAO,CAAC,IAAM,IAAIC,gBAAgBJ,YAAe,CAAA,EAAA;AAACA,QAAAA;AAAa,KAAA,CAAA;AACpF,IAAA,MAAM,EAAEK,eAAe,EAAE,GAAGC,kBAAmB,CAAA,qBAAA,CAAA;IAC/C,MAAMC,UAAAA,GAAaF,gBAAgBE,UAAU;IAE7C,MAAM,EACJC,QAAQ,EAAE,EACVC,KAAK,EACLC,QAAQ,EACT,GAAGC,QAAuEpB,CAAAA,IAAAA,CAAAA;AAC3E,IAAA,MAAMqB,cAAcC,OAA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;AAEA,MAAMmK,OAAU,GAAA,IAAA;AACd,IAAA,qBAAO/E,GAACiG,CAAAA,UAAAA,EAAAA;QAAWC,GAAI,EAAA,MAAA;QAAOF,OAAS,EAAA,CAAA;QAAGD,UAAW,EAAA;;AACvD,CAAA;AAEA,MAAME,UAAAA,GAAa1D,MAA6BnC,CAAAA,GAAAA,CAAI;;sBAE9B,EAAE,CAAC,EAAEsC,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAACwD,UAAU,CAAC;;AAE/D,CAAC;;;;"}
|
@@ -51,23 +51,37 @@ const StyledModalContent = styledComponents.styled(designSystem.Modal.Content)`
|
|
51
51
|
height: 90%;
|
52
52
|
max-height: 100%;
|
53
53
|
`;
|
54
|
+
const getFullPageUrl = (currentDocumentMeta)=>{
|
55
|
+
const isSingleType = currentDocumentMeta.collectionType === collections.SINGLE_TYPES;
|
56
|
+
const queryParams = currentDocumentMeta.params?.locale ? `?plugins[i18n][locale]=${currentDocumentMeta.params.locale}` : '';
|
57
|
+
return `/content-manager/${currentDocumentMeta.collectionType}/${currentDocumentMeta.model}${isSingleType ? '' : '/' + currentDocumentMeta.documentId}${queryParams}`;
|
58
|
+
};
|
54
59
|
function reducer(state, action) {
|
55
60
|
switch(action.type){
|
56
61
|
case 'GO_TO_RELATION':
|
57
62
|
if (state.hasUnsavedChanges && !action.payload.shouldBypassConfirmation) {
|
58
63
|
return {
|
59
64
|
...state,
|
60
|
-
confirmDialogIntent: action.payload.document
|
65
|
+
confirmDialogIntent: action.payload.document,
|
66
|
+
fieldToConnect: action.payload.fieldToConnect,
|
67
|
+
fieldToConnectUID: action.payload.fieldToConnectUID
|
61
68
|
};
|
62
69
|
}
|
70
|
+
const lastItemDocumentHistory = state.documentHistory.at(-1);
|
71
|
+
const hasToResetDocumentHistory = lastItemDocumentHistory && !lastItemDocumentHistory.documentId;
|
63
72
|
return {
|
64
73
|
...state,
|
65
|
-
|
74
|
+
// Reset document history if the last item has documentId undefined
|
75
|
+
documentHistory: hasToResetDocumentHistory ? [
|
76
|
+
action.payload.document
|
77
|
+
] : [
|
66
78
|
...state.documentHistory,
|
67
79
|
action.payload.document
|
68
80
|
],
|
69
81
|
confirmDialogIntent: null,
|
70
|
-
isModalOpen: true
|
82
|
+
isModalOpen: true,
|
83
|
+
fieldToConnect: hasToResetDocumentHistory ? undefined : action.payload.fieldToConnect,
|
84
|
+
fieldToConnectUID: hasToResetDocumentHistory ? undefined : action.payload.fieldToConnectUID
|
71
85
|
};
|
72
86
|
case 'GO_BACK':
|
73
87
|
if (state.hasUnsavedChanges && !action.payload.shouldBypassConfirmation) {
|
@@ -95,6 +109,21 @@ function reducer(state, action) {
|
|
95
109
|
isModalOpen: false,
|
96
110
|
confirmDialogIntent: null
|
97
111
|
};
|
112
|
+
case 'GO_TO_CREATED_RELATION':
|
113
|
+
return {
|
114
|
+
...state,
|
115
|
+
// Reset document history if the last item has documentId undefined
|
116
|
+
documentHistory: state.documentHistory ? [
|
117
|
+
...state.documentHistory.slice(0, -1),
|
118
|
+
action.payload.document
|
119
|
+
] : [
|
120
|
+
action.payload.document
|
121
|
+
],
|
122
|
+
confirmDialogIntent: null,
|
123
|
+
isModalOpen: true,
|
124
|
+
fieldToConnect: undefined,
|
125
|
+
fieldToConnectUID: undefined
|
126
|
+
};
|
98
127
|
case 'CANCEL_CONFIRM_DIALOG':
|
99
128
|
return {
|
100
129
|
...state,
|
@@ -124,21 +153,17 @@ function reducer(state, action) {
|
|
124
153
|
}
|
125
154
|
}
|
126
155
|
const [RelationModalProvider, useRelationModal] = strapiAdmin.createContext('RelationModal');
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
};
|
132
|
-
/**
|
133
|
-
* Component responsible of rendering its children wrapped in a modal, form and context if needed
|
134
|
-
*/ const RelationModalRenderer = ({ children, trigger, relation })=>{
|
135
|
-
const { formatMessage } = reactIntl.useIntl();
|
136
|
-
const navigate = reactRouterDom.useNavigate();
|
156
|
+
function isRenderProp(children) {
|
157
|
+
return typeof children === 'function';
|
158
|
+
}
|
159
|
+
const RootRelationRenderer = (props)=>{
|
160
|
+
const { children } = props;
|
137
161
|
const [state, dispatch] = React__namespace.useReducer(reducer, {
|
138
162
|
documentHistory: [],
|
139
163
|
confirmDialogIntent: null,
|
140
164
|
isModalOpen: false,
|
141
|
-
hasUnsavedChanges: false
|
165
|
+
hasUnsavedChanges: false,
|
166
|
+
fieldToConnect: undefined
|
142
167
|
});
|
143
168
|
const rootDocument = useDocument.useDoc();
|
144
169
|
const [{ query }] = strapiAdmin.useQueryParams();
|
@@ -153,11 +178,9 @@ const getFullPageUrl = (currentDocumentMeta)=>{
|
|
153
178
|
};
|
154
179
|
const currentDocumentMeta = state.documentHistory.at(-1) ?? rootDocumentMeta;
|
155
180
|
const currentDocument = useDocument.useDocument(currentDocumentMeta);
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
return trigger;
|
160
|
-
}
|
181
|
+
// TODO: check if we can remove the single type check
|
182
|
+
const isSingleType = currentDocumentMeta.collectionType === collections.SINGLE_TYPES;
|
183
|
+
const isCreating = !currentDocumentMeta.documentId && !isSingleType;
|
161
184
|
/**
|
162
185
|
* There is no parent relation, so the relation modal doesn't exist. Create it and set up all the
|
163
186
|
* pieces that will be used by potential child relations: the context, header, form, and footer.
|
@@ -167,113 +190,156 @@ const getFullPageUrl = (currentDocumentMeta)=>{
|
|
167
190
|
rootDocumentMeta: rootDocumentMeta,
|
168
191
|
currentDocumentMeta: currentDocumentMeta,
|
169
192
|
currentDocument: currentDocument,
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
193
|
+
isCreating: isCreating,
|
194
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(RelationModal, {
|
195
|
+
children: isRenderProp(children) ? children({
|
196
|
+
dispatch
|
197
|
+
}) : props.relation && /*#__PURE__*/ jsxRuntime.jsx(RelationModalTrigger, {
|
198
|
+
relation: props.relation,
|
199
|
+
children: children
|
200
|
+
})
|
201
|
+
})
|
202
|
+
});
|
203
|
+
};
|
204
|
+
const NestedRelationRenderer = (props)=>{
|
205
|
+
const { children } = props;
|
206
|
+
const dispatch = useRelationModal('NestedRelation', (state)=>state.dispatch);
|
207
|
+
return isRenderProp(children) ? children({
|
208
|
+
dispatch
|
209
|
+
}) : props.relation && /*#__PURE__*/ jsxRuntime.jsx(RelationModalTrigger, {
|
210
|
+
relation: props.relation,
|
211
|
+
children: children
|
212
|
+
}); /* This is the trigger that will be rendered in the parent relation */
|
213
|
+
};
|
214
|
+
/**
|
215
|
+
* Component responsible for rendering its children wrapped in a modal, form and context if needed
|
216
|
+
*/ const RelationModalRenderer = (props)=>{
|
217
|
+
// We're in a nested relation if the relation modal context is not undefined
|
218
|
+
const isNested = useRelationModal('RelationContextWrapper', (state)=>state != undefined, false);
|
219
|
+
return isNested ? /*#__PURE__*/ jsxRuntime.jsx(NestedRelationRenderer, {
|
220
|
+
...props
|
221
|
+
}) : /*#__PURE__*/ jsxRuntime.jsx(RootRelationRenderer, {
|
222
|
+
...props
|
223
|
+
});
|
224
|
+
};
|
225
|
+
/* -------------------------------------------------------------------------------------------------
|
226
|
+
* RelationModal
|
227
|
+
* -----------------------------------------------------------------------------------------------*/ const generateCreateUrl = (currentDocumentMeta)=>{
|
228
|
+
return `/content-manager/${currentDocumentMeta.collectionType}/${currentDocumentMeta.model}/create${currentDocumentMeta.params?.locale ? `?plugins[i18n][locale]=${currentDocumentMeta.params.locale}` : ''}`;
|
229
|
+
};
|
230
|
+
const RelationModal = ({ children })=>{
|
231
|
+
const { formatMessage } = reactIntl.useIntl();
|
232
|
+
const navigate = reactRouterDom.useNavigate();
|
233
|
+
const state = useRelationModal('RelationModalForm', (state)=>state.state);
|
234
|
+
const dispatch = useRelationModal('RelationModalForm', (state)=>state.dispatch);
|
235
|
+
const currentDocumentMeta = useRelationModal('RelationModalForm', (state)=>state.currentDocumentMeta);
|
236
|
+
const currentDocument = useRelationModal('RelationModalForm', (state)=>state.currentDocument);
|
237
|
+
const isCreating = useRelationModal('RelationModalForm', (state)=>state.isCreating);
|
238
|
+
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Modal.Root, {
|
239
|
+
open: state.isModalOpen,
|
240
|
+
onOpenChange: (open)=>{
|
241
|
+
if (!open) {
|
242
|
+
dispatch({
|
243
|
+
type: 'CLOSE_MODAL',
|
244
|
+
payload: {
|
245
|
+
shouldBypassConfirmation: false
|
246
|
+
}
|
247
|
+
});
|
248
|
+
}
|
249
|
+
},
|
250
|
+
children: [
|
251
|
+
children,
|
252
|
+
/*#__PURE__*/ jsxRuntime.jsxs(StyledModalContent, {
|
253
|
+
children: [
|
254
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Header, {
|
255
|
+
gap: 2,
|
256
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
257
|
+
justifyContent: "space-between",
|
258
|
+
alignItems: "center",
|
259
|
+
width: "100%",
|
260
|
+
children: [
|
261
|
+
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
262
|
+
gap: 2,
|
263
|
+
children: [
|
264
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
265
|
+
withTooltip: false,
|
266
|
+
label: formatMessage({
|
267
|
+
id: 'global.back',
|
268
|
+
defaultMessage: 'Back'
|
222
269
|
}),
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
270
|
+
variant: "ghost",
|
271
|
+
disabled: state.documentHistory.length < 2,
|
272
|
+
onClick: ()=>{
|
273
|
+
dispatch({
|
274
|
+
type: 'GO_BACK',
|
275
|
+
payload: {
|
276
|
+
shouldBypassConfirmation: false
|
277
|
+
}
|
278
|
+
});
|
279
|
+
},
|
280
|
+
marginRight: 1,
|
281
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.ArrowLeft, {})
|
282
|
+
}),
|
283
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
|
284
|
+
tag: "span",
|
285
|
+
fontWeight: 600,
|
286
|
+
children: isCreating ? formatMessage({
|
287
|
+
id: 'content-manager.relation.create',
|
288
|
+
defaultMessage: 'Create a relation'
|
289
|
+
}) : formatMessage({
|
290
|
+
id: 'content-manager.components.RelationInputModal.modal-title',
|
291
|
+
defaultMessage: 'Edit a relation'
|
230
292
|
})
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
293
|
+
})
|
294
|
+
]
|
295
|
+
}),
|
296
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
297
|
+
onClick: ()=>{
|
298
|
+
dispatch({
|
299
|
+
type: 'GO_FULL_PAGE'
|
300
|
+
});
|
301
|
+
if (!state.hasUnsavedChanges) {
|
302
|
+
if (isCreating) {
|
303
|
+
navigate(generateCreateUrl(currentDocumentMeta));
|
304
|
+
} else {
|
239
305
|
navigate(getFullPageUrl(currentDocumentMeta));
|
240
306
|
}
|
241
|
-
}
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
})
|
249
|
-
|
250
|
-
|
251
|
-
}),
|
252
|
-
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Body, {
|
253
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Form, {
|
254
|
-
method: "PUT",
|
255
|
-
initialValues: currentDocument.getInitialFormValues(),
|
256
|
-
validate: (values, options)=>{
|
257
|
-
const yupSchema = validation.createYupSchema(currentDocument.schema?.attributes, currentDocument.components, {
|
258
|
-
status: currentDocument.document?.status,
|
259
|
-
...options
|
260
|
-
});
|
261
|
-
return yupSchema.validate(values, {
|
262
|
-
abortEarly: false
|
263
|
-
});
|
264
|
-
},
|
265
|
-
children: children
|
266
|
-
})
|
307
|
+
}
|
308
|
+
},
|
309
|
+
variant: "tertiary",
|
310
|
+
label: formatMessage({
|
311
|
+
id: 'content-manager.components.RelationInputModal.button-fullpage',
|
312
|
+
defaultMessage: 'Go to entry'
|
313
|
+
}),
|
314
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.ArrowsOut, {})
|
315
|
+
})
|
316
|
+
]
|
267
317
|
})
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
318
|
+
}),
|
319
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Body, {
|
320
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Form, {
|
321
|
+
method: isCreating ? 'POST' : 'PUT',
|
322
|
+
initialValues: currentDocument.getInitialFormValues(isCreating),
|
323
|
+
validate: (values, options)=>{
|
324
|
+
const yupSchema = validation.createYupSchema(currentDocument.schema?.attributes, currentDocument.components, {
|
325
|
+
status: currentDocument.document?.status,
|
326
|
+
...options
|
327
|
+
});
|
328
|
+
return yupSchema.validate(values, {
|
329
|
+
abortEarly: false
|
330
|
+
});
|
331
|
+
},
|
332
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(RelationModalBody, {})
|
333
|
+
})
|
334
|
+
})
|
335
|
+
]
|
336
|
+
})
|
337
|
+
]
|
272
338
|
});
|
273
339
|
};
|
274
340
|
/**
|
275
341
|
* All the main content (not header and footer) of the relation modal, plus the confirmation dialog.
|
276
|
-
* Will be wrapped in a Modal.Body by the
|
342
|
+
* Will be wrapped in a Modal.Body by the RelationModal component.
|
277
343
|
* Cannot be moved directly inside RelationModal because it needs access to the context via hooks.
|
278
344
|
*/ const RelationModalBody = ()=>{
|
279
345
|
const navigate = reactRouterDom.useNavigate();
|
@@ -284,6 +350,7 @@ const getFullPageUrl = (currentDocumentMeta)=>{
|
|
284
350
|
const dispatch = useRelationModal('RelationModalForm', (state)=>state.dispatch);
|
285
351
|
const rootDocumentMeta = useRelationModal('RelationModalForm', (state)=>state.rootDocumentMeta);
|
286
352
|
const currentDocumentMeta = useRelationModal('RelationModalForm', (state)=>state.currentDocumentMeta);
|
353
|
+
const isCreating = useRelationModal('RelationModalForm', (state)=>state.isCreating);
|
287
354
|
/**
|
288
355
|
* One-way sync the modified state from the form to the modal state.
|
289
356
|
* It is needed because we need to consume state from the form context in order to lift it up
|
@@ -325,7 +392,11 @@ const getFullPageUrl = (currentDocumentMeta)=>{
|
|
325
392
|
if (isRootDocumentUrl) {
|
326
393
|
handleCloseModal(true);
|
327
394
|
} else {
|
328
|
-
|
395
|
+
if (isCreating) {
|
396
|
+
navigate(generateCreateUrl(currentDocumentMeta));
|
397
|
+
} else {
|
398
|
+
navigate(fullPageUrl);
|
399
|
+
}
|
329
400
|
}
|
330
401
|
};
|
331
402
|
const handleConfirm = ()=>{
|
@@ -355,7 +426,7 @@ const getFullPageUrl = (currentDocumentMeta)=>{
|
|
355
426
|
};
|
356
427
|
return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
357
428
|
children: [
|
358
|
-
/*#__PURE__*/ jsxRuntime.jsx(
|
429
|
+
/*#__PURE__*/ jsxRuntime.jsx(RelationModalForm, {}),
|
359
430
|
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Dialog.Root, {
|
360
431
|
open: state.confirmDialogIntent != null,
|
361
432
|
children: /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.ConfirmDialog, {
|
@@ -373,7 +444,7 @@ const getFullPageUrl = (currentDocumentMeta)=>{
|
|
373
444
|
]
|
374
445
|
});
|
375
446
|
};
|
376
|
-
const
|
447
|
+
const RelationModalTrigger = ({ children, relation })=>{
|
377
448
|
const dispatch = useRelationModal('ModalTrigger', (state)=>state.dispatch);
|
378
449
|
return /*#__PURE__*/ jsxRuntime.jsx(StyledTextButton, {
|
379
450
|
onClick: ()=>{
|
@@ -388,16 +459,6 @@ const ModalTrigger = ({ children, relation })=>{
|
|
388
459
|
children: children
|
389
460
|
});
|
390
461
|
};
|
391
|
-
const RelationModal = /*#__PURE__*/ React__namespace.memo(({ relation, children })=>{
|
392
|
-
return /*#__PURE__*/ jsxRuntime.jsx(RelationModalRenderer, {
|
393
|
-
relation: relation,
|
394
|
-
trigger: /*#__PURE__*/ jsxRuntime.jsx(ModalTrigger, {
|
395
|
-
relation: relation,
|
396
|
-
children: children
|
397
|
-
}),
|
398
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(RelationModalBody, {})
|
399
|
-
});
|
400
|
-
});
|
401
462
|
const StyledTextButton = styledComponents.styled(designSystem.TextButton)`
|
402
463
|
max-width: 100%;
|
403
464
|
& > span {
|
@@ -411,13 +472,14 @@ const StyledTextButton = styledComponents.styled(designSystem.TextButton)`
|
|
411
472
|
/**
|
412
473
|
* The mini edit view for a relation that is displayed inside a modal.
|
413
474
|
* It's complete with its header, document actions and form layout.
|
414
|
-
*/ const
|
475
|
+
*/ const RelationModalForm = ()=>{
|
415
476
|
const { formatMessage } = reactIntl.useIntl();
|
416
|
-
const currentDocumentMeta = useRelationModal('
|
417
|
-
const
|
477
|
+
const currentDocumentMeta = useRelationModal('RelationModalForm', (state)=>state.currentDocumentMeta);
|
478
|
+
const isCreating = useRelationModal('RelationModalForm', (state)=>state.isCreating);
|
479
|
+
const currentDocument = useRelationModal('RelationModalForm', (state)=>state.currentDocument);
|
418
480
|
const documentLayoutResponse = useDocumentLayout.useDocumentLayout(currentDocumentMeta.model);
|
419
|
-
const plugins = strapiAdmin.useStrapiApp('
|
420
|
-
const initialValues = currentDocument.getInitialFormValues();
|
481
|
+
const plugins = strapiAdmin.useStrapiApp('RelationModalForm', (state)=>state.plugins);
|
482
|
+
const initialValues = isCreating ? currentDocument.getInitialFormValues(isCreating) : currentDocument.getInitialFormValues();
|
421
483
|
const { permissions = [], isLoading: isLoadingPermissions, error } = strapiAdmin.useRBAC(plugin.PERMISSIONS.map((action)=>({
|
422
484
|
action,
|
423
485
|
subject: currentDocumentMeta.model
|
@@ -432,7 +494,7 @@ const StyledTextButton = styledComponents.styled(designSystem.TextButton)`
|
|
432
494
|
})
|
433
495
|
});
|
434
496
|
}
|
435
|
-
if (error || !currentDocumentMeta.model || documentLayoutResponse.error || !currentDocument.document || !currentDocument.meta || !currentDocument.schema || !initialValues) {
|
497
|
+
if (error || !currentDocumentMeta.model || documentLayoutResponse.error || !isCreating && !currentDocument.document || !isCreating && !currentDocument.meta || !currentDocument.schema || !initialValues) {
|
436
498
|
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
|
437
499
|
alignItems: "center",
|
438
500
|
height: "100%",
|
@@ -541,7 +603,7 @@ const StyledTextButton = styledComponents.styled(designSystem.TextButton)`
|
|
541
603
|
});
|
542
604
|
};
|
543
605
|
|
544
|
-
exports.
|
606
|
+
exports.RelationModalRenderer = RelationModalRenderer;
|
545
607
|
exports.getCollectionType = getCollectionType;
|
546
608
|
exports.reducer = reducer;
|
547
609
|
exports.useRelationModal = useRelationModal;
|