@strapi/content-manager 5.42.1 → 5.43.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 -5
- package/dist/admin/hooks/useDocumentActions.js.map +1 -1
- package/dist/admin/hooks/useDocumentActions.mjs +6 -6
- package/dist/admin/hooks/useDocumentActions.mjs.map +1 -1
- package/dist/admin/hooks/usePersistentQueryParams.js +37 -19
- package/dist/admin/hooks/usePersistentQueryParams.js.map +1 -1
- package/dist/admin/hooks/usePersistentQueryParams.mjs +38 -20
- package/dist/admin/hooks/usePersistentQueryParams.mjs.map +1 -1
- package/dist/admin/pages/EditView/EditViewPage.js +29 -4
- package/dist/admin/pages/EditView/EditViewPage.js.map +1 -1
- package/dist/admin/pages/EditView/EditViewPage.mjs +10 -4
- package/dist/admin/pages/EditView/EditViewPage.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/DocumentActions.js +30 -20
- package/dist/admin/pages/EditView/components/DocumentActions.js.map +1 -1
- package/dist/admin/pages/EditView/components/DocumentActions.mjs +30 -20
- package/dist/admin/pages/EditView/components/DocumentActions.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js +2 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs +2 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js +19 -0
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs +19 -0
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.js +4 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.mjs +4 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js +34 -9
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs +34 -9
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs.map +1 -1
- package/dist/admin/pages/ListConfiguration/ListConfigurationPage.js +22 -5
- package/dist/admin/pages/ListConfiguration/ListConfigurationPage.js.map +1 -1
- package/dist/admin/pages/ListConfiguration/ListConfigurationPage.mjs +26 -9
- package/dist/admin/pages/ListConfiguration/ListConfigurationPage.mjs.map +1 -1
- package/dist/admin/pages/ListView/ListViewPage.js +19 -8
- package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
- package/dist/admin/pages/ListView/ListViewPage.mjs +19 -8
- package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/BulkActions/Actions.js +1 -1
- package/dist/admin/pages/ListView/components/BulkActions/Actions.js.map +1 -1
- package/dist/admin/pages/ListView/components/BulkActions/Actions.mjs +1 -1
- package/dist/admin/pages/ListView/components/BulkActions/Actions.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/BulkActions/PublishAction.js +37 -25
- package/dist/admin/pages/ListView/components/BulkActions/PublishAction.js.map +1 -1
- package/dist/admin/pages/ListView/components/BulkActions/PublishAction.mjs +38 -26
- package/dist/admin/pages/ListView/components/BulkActions/PublishAction.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/TableCells/CellContent.js +3 -0
- package/dist/admin/pages/ListView/components/TableCells/CellContent.js.map +1 -1
- package/dist/admin/pages/ListView/components/TableCells/CellContent.mjs +3 -0
- package/dist/admin/pages/ListView/components/TableCells/CellContent.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/TableCells/CellValue.js +3 -2
- package/dist/admin/pages/ListView/components/TableCells/CellValue.js.map +1 -1
- package/dist/admin/pages/ListView/components/TableCells/CellValue.mjs +3 -2
- package/dist/admin/pages/ListView/components/TableCells/CellValue.mjs.map +1 -1
- package/dist/admin/services/documents.js +32 -7
- package/dist/admin/services/documents.js.map +1 -1
- package/dist/admin/services/documents.mjs +32 -8
- package/dist/admin/services/documents.mjs.map +1 -1
- package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
- package/dist/admin/src/hooks/usePersistentQueryParams.d.ts +6 -1
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +3 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.d.ts +2 -0
- package/dist/admin/src/pages/ListConfiguration/ListConfigurationPage.d.ts +1 -1
- package/dist/admin/src/pages/ListView/components/TableCells/CellValue.d.ts +2 -1
- package/dist/admin/src/preview/services/preview.d.ts +1 -1
- package/dist/admin/src/services/api.d.ts +1 -1
- package/dist/admin/src/services/components.d.ts +2 -2
- package/dist/admin/src/services/contentTypes.d.ts +3 -3
- package/dist/admin/src/services/documents.d.ts +22 -17
- package/dist/admin/src/services/homepage.d.ts +1 -1
- package/dist/admin/src/services/init.d.ts +1 -1
- package/dist/admin/src/services/relations.d.ts +2 -2
- package/dist/admin/src/services/uid.d.ts +3 -3
- package/dist/admin/translations/nl.json.js +180 -11
- package/dist/admin/translations/nl.json.js.map +1 -1
- package/dist/admin/translations/nl.json.mjs +180 -11
- package/dist/admin/translations/nl.json.mjs.map +1 -1
- package/dist/server/controllers/collection-types.js +32 -1
- package/dist/server/controllers/collection-types.js.map +1 -1
- package/dist/server/controllers/collection-types.mjs +33 -2
- package/dist/server/controllers/collection-types.mjs.map +1 -1
- package/dist/server/routes/admin.js +21 -0
- package/dist/server/routes/admin.js.map +1 -1
- package/dist/server/routes/admin.mjs +21 -0
- package/dist/server/routes/admin.mjs.map +1 -1
- package/dist/server/src/controllers/collection-types.d.ts +1 -0
- package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
- package/dist/server/src/controllers/index.d.ts +1 -0
- package/dist/server/src/controllers/index.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +1 -0
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/routes/admin.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -3,6 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { createContext, useIsMobile } from '@strapi/admin/strapi-admin';
|
|
4
4
|
import { Divider, VisuallyHidden, IconButton } from '@strapi/design-system';
|
|
5
5
|
import { Expand } from '@strapi/icons';
|
|
6
|
+
import { flushSync } from 'react-dom';
|
|
6
7
|
import { useIntl } from 'react-intl';
|
|
7
8
|
import { createEditor, Transforms, Editor } from 'slate';
|
|
8
9
|
import { withHistory } from 'slate-history';
|
|
@@ -127,6 +128,23 @@ const BlocksEditor = /*#__PURE__*/ React.forwardRef(({ disabled = false, name, o
|
|
|
127
128
|
]);
|
|
128
129
|
const { key, incrementSlateUpdatesCount } = useResetKey(value);
|
|
129
130
|
const debounceTimeout = React.useRef(null);
|
|
131
|
+
const flushPendingFormSync = React.useCallback(()=>{
|
|
132
|
+
if (!debounceTimeout.current) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
clearTimeout(debounceTimeout.current);
|
|
136
|
+
debounceTimeout.current = null;
|
|
137
|
+
incrementSlateUpdatesCount();
|
|
138
|
+
// Ensure Strapi Form state updates before the next event (e.g. Save click) reads values.
|
|
139
|
+
flushSync(()=>{
|
|
140
|
+
onChange(name, normalizeBlocksState(editor, editor.children));
|
|
141
|
+
});
|
|
142
|
+
}, [
|
|
143
|
+
editor,
|
|
144
|
+
incrementSlateUpdatesCount,
|
|
145
|
+
name,
|
|
146
|
+
onChange
|
|
147
|
+
]);
|
|
130
148
|
const handleSlateChange = React.useCallback((state)=>{
|
|
131
149
|
const isAstChange = editor.operations.some((op)=>op.type !== 'set_selection');
|
|
132
150
|
if (isAstChange) {
|
|
@@ -212,6 +230,7 @@ const BlocksEditor = /*#__PURE__*/ React.forwardRef(({ disabled = false, name, o
|
|
|
212
230
|
name: name,
|
|
213
231
|
setLiveText: setLiveText,
|
|
214
232
|
isExpandedMode: isExpandedMode,
|
|
233
|
+
flushPendingFormSync: flushPendingFormSync,
|
|
215
234
|
children: /*#__PURE__*/ jsxs(EditorLayout, {
|
|
216
235
|
error: error,
|
|
217
236
|
disabled: disabled,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlocksEditor.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { createContext, type FieldValue, useIsMobile } from '@strapi/admin/strapi-admin';\nimport { IconButton, Divider, VisuallyHidden } from '@strapi/design-system';\nimport { Expand } from '@strapi/icons';\nimport { MessageDescriptor, useIntl } from 'react-intl';\nimport { Editor, type Descendant, createEditor, Transforms, Element } from 'slate';\nimport { withHistory } from 'slate-history';\nimport { type RenderElementProps, Slate, withReact, ReactEditor, useSlate } from 'slate-react';\nimport { styled, type CSSProperties } from 'styled-components';\n\nimport { getTranslation } from '../../../../../utils/translations';\n\nimport { codeBlocks } from './Blocks/Code';\nimport { headingBlocks } from './Blocks/Heading';\nimport { imageBlocks } from './Blocks/Image';\nimport { linkBlocks } from './Blocks/Link';\nimport { listBlocks } from './Blocks/List';\nimport { paragraphBlocks } from './Blocks/Paragraph';\nimport { quoteBlocks } from './Blocks/Quote';\nimport { BlocksContent, type BlocksContentProps } from './BlocksContent';\nimport { BlocksToolbar } from './BlocksToolbar';\nimport { EditorLayout } from './EditorLayout';\nimport { type ModifiersStore, modifiers } from './Modifiers';\nimport { withStrapiSchema } from './plugins/withStrapiSchema';\nimport { isNonNullable } from './utils/types';\n\nimport type { Schema } from '@strapi/types';\n\n/* -------------------------------------------------------------------------------------------------\n * BlocksEditorProvider\n * -----------------------------------------------------------------------------------------------*/\n\ninterface BaseBlock {\n renderElement: (props: RenderElementProps) => React.JSX.Element;\n /** Function to check if a given node is of this type of block */\n matchNode: (node: Schema.Attribute.BlocksNode) => boolean;\n handleConvert?: (editor: Editor) => void | (() => React.JSX.Element);\n handleEnterKey?: (editor: Editor) => void;\n handleBackspaceKey?: (editor: Editor, event: React.KeyboardEvent<HTMLElement>) => void;\n handleTab?: (editor: Editor) => void;\n handleShiftTab?: (editor: Editor) => void;\n snippets?: string[];\n /** Adjust the vertical positioning of the drag-to-reorder grip icon */\n dragHandleTopMargin?: CSSProperties['marginTop'];\n /** A Slate plugin: function that will wrap the editor creation */\n plugin?: (editor: Editor) => Editor;\n /**\n * Function that checks if an element should be draggable\n * @default () => true */\n isDraggable?: (element: Element) => boolean;\n}\n\ninterface NonSelectorBlock extends BaseBlock {\n isInBlocksSelector: false;\n}\n\ninterface SelectorBlock extends BaseBlock {\n isInBlocksSelector: true;\n icon: React.ComponentType;\n label: MessageDescriptor;\n}\n\ntype NonSelectorBlockKey = 'list-item' | 'link';\n\nconst selectorBlockKeys = [\n 'paragraph',\n 'heading-one',\n 'heading-two',\n 'heading-three',\n 'heading-four',\n 'heading-five',\n 'heading-six',\n 'list-ordered',\n 'list-unordered',\n 'image',\n 'quote',\n 'code',\n] as const;\n\ntype SelectorBlockKey = (typeof selectorBlockKeys)[number];\n\nconst isSelectorBlockKey = (key: unknown): key is SelectorBlockKey => {\n return typeof key === 'string' && selectorBlockKeys.includes(key as SelectorBlockKey);\n};\n\ntype BlocksStore = {\n [K in SelectorBlockKey]: SelectorBlock;\n} & {\n [K in NonSelectorBlockKey]: NonSelectorBlock;\n};\n\ninterface BlocksEditorContextValue {\n blocks: BlocksStore;\n modifiers: ModifiersStore;\n disabled: boolean;\n name: string;\n setLiveText: (text: string) => void;\n isExpandedMode: boolean;\n}\n\nconst [BlocksEditorProvider, usePartialBlocksEditorContext] =\n createContext<BlocksEditorContextValue>('BlocksEditor');\n\nfunction useBlocksEditorContext(\n consumerName: string\n): BlocksEditorContextValue & { editor: Editor } {\n const context = usePartialBlocksEditorContext(consumerName, (state) => state);\n const editor = useSlate();\n\n return {\n ...context,\n editor,\n };\n}\n\n/* -------------------------------------------------------------------------------------------------\n * BlocksEditor\n * -----------------------------------------------------------------------------------------------*/\n\nconst EditorDivider = styled(Divider)`\n background: ${({ theme }) => theme.colors.neutral200};\n`;\n\n/**\n * Forces an update of the Slate editor when the value prop changes from outside of Slate.\n * The root cause is that Slate is not a controlled component: https://github.com/ianstormtaylor/slate/issues/4612\n * Why not use JSON.stringify(value) as the key?\n * Because it would force a rerender of the entire editor every time the user types a character.\n * Why not use the entity id as the key, since it's unique for each locale?\n * Because it would not solve the problem when using the \"fill in from other locale\" feature\n */\nfunction useResetKey(value?: Schema.Attribute.BlocksValue): {\n key: number;\n incrementSlateUpdatesCount: () => void;\n} {\n // Keep track how many times Slate detected a change from a user interaction in the editor\n const slateUpdatesCount = React.useRef(0);\n // Keep track of how many times the value prop was updated, whether from within editor or from outside\n const valueUpdatesCount = React.useRef(0);\n // Use a key to force a rerender of the Slate editor when needed\n const [key, setKey] = React.useState(0);\n\n React.useEffect(() => {\n valueUpdatesCount.current += 1;\n\n // If the 2 refs are not equal, it means the value was updated from outside\n if (valueUpdatesCount.current !== slateUpdatesCount.current) {\n // So we change the key to force a rerender of the Slate editor,\n // which will pick up the new value through its initialValue prop\n setKey((previousKey) => previousKey + 1);\n\n // Then bring the 2 refs back in sync\n slateUpdatesCount.current = valueUpdatesCount.current;\n }\n }, [value]);\n\n const incrementSlateUpdatesCount = React.useCallback(() => {\n slateUpdatesCount.current += 1;\n }, []);\n\n return { key, incrementSlateUpdatesCount };\n}\n\nconst pipe =\n (...fns: ((baseEditor: Editor) => Editor)[]) =>\n (value: Editor) =>\n fns.reduce<Editor>((prev, fn) => fn(prev), value);\n\n/**\n * Normalize the blocks state to null if the editor state is considered empty,\n * otherwise return the state\n */\nconst normalizeBlocksState = (\n editor: Editor,\n value: Schema.Attribute.BlocksValue | Descendant[]\n): Schema.Attribute.BlocksValue | Descendant[] | null => {\n const isEmpty =\n value.length === 1 && Editor.isEmpty(editor, value[0] as Schema.Attribute.BlocksNode);\n\n return isEmpty ? null : value;\n};\n\ninterface BlocksEditorProps\n extends Pick<FieldValue<Schema.Attribute.BlocksValue>, 'onChange' | 'value' | 'error'>,\n BlocksContentProps {\n disabled?: boolean;\n name: string;\n}\n\nconst BlocksEditor = React.forwardRef<{ focus: () => void }, BlocksEditorProps>(\n ({ disabled = false, name, onChange, value, error, ...contentProps }, forwardedRef) => {\n const { formatMessage } = useIntl();\n const isMobile = useIsMobile();\n\n const blocks = React.useMemo(\n () => ({\n ...paragraphBlocks,\n ...headingBlocks,\n ...listBlocks,\n ...linkBlocks,\n ...imageBlocks,\n ...quoteBlocks,\n ...codeBlocks,\n }),\n []\n ) satisfies BlocksStore;\n\n const blockRegisteredPlugins = Object.values(blocks)\n .map((block) => block.plugin)\n .filter(isNonNullable);\n\n const [editor] = React.useState(() =>\n pipe(withHistory, withStrapiSchema, withReact, ...blockRegisteredPlugins)(createEditor())\n );\n const [liveText, setLiveText] = React.useState('');\n const ariaDescriptionId = React.useId();\n const [isExpandedMode, handleToggleExpand] = React.useReducer((prev) => !prev, false);\n\n /**\n * Editable is not able to hold the ref, https://github.com/ianstormtaylor/slate/issues/4082\n * so with \"useImperativeHandle\" we can use ReactEditor methods to expose to the parent above\n * also not passing forwarded ref here, gives console warning.\n */\n React.useImperativeHandle(\n forwardedRef,\n () => ({\n focus() {\n ReactEditor.focus(editor);\n },\n }),\n [editor]\n );\n\n const { key, incrementSlateUpdatesCount } = useResetKey(value);\n\n const debounceTimeout = React.useRef<NodeJS.Timeout | null>(null);\n\n const handleSlateChange = React.useCallback(\n (state: Descendant[]) => {\n const isAstChange = editor.operations.some((op) => op.type !== 'set_selection');\n\n if (isAstChange) {\n /**\n * Slate handles the state of the editor internally. We just need to keep Strapi's form\n * state in sync with it in order to make sure that things like the \"modified\" state\n * isn't broken. Updating the whole state on every change is very expensive however,\n * so we debounce calls to onChange to mitigate input lag.\n */\n if (debounceTimeout.current) {\n clearTimeout(debounceTimeout.current);\n }\n\n // Set a new debounce timeout\n debounceTimeout.current = setTimeout(() => {\n incrementSlateUpdatesCount();\n\n // Normalize the state (empty editor becomes null)\n onChange(name, normalizeBlocksState(editor, state) as Schema.Attribute.BlocksValue);\n debounceTimeout.current = null;\n }, 300);\n }\n },\n [editor, incrementSlateUpdatesCount, name, onChange]\n );\n\n // Clean up the timeout on unmount\n React.useEffect(() => {\n return () => {\n if (debounceTimeout.current) {\n clearTimeout(debounceTimeout.current);\n }\n };\n }, []);\n\n // Ensure the editor is in sync after discard\n React.useEffect(() => {\n // Never deselect while the editor is actively focused (typing / editing),\n if (ReactEditor.isFocused(editor)) {\n return;\n }\n\n // Normalize empty states for comparison to avoid losing focus on the editor when content is deleted\n const normalizedValue = value?.length ? value : null;\n const normalizedEditorState = normalizeBlocksState(editor, editor.children);\n\n // Compare the field value with the editor state to check for a stale selection\n if (\n normalizedValue &&\n normalizedEditorState &&\n JSON.stringify(normalizedEditorState) !== JSON.stringify(normalizedValue)\n ) {\n // When there is a diff, unset selection to avoid an invalid state\n Transforms.deselect(editor);\n }\n }, [editor, value]);\n\n return (\n <>\n <VisuallyHidden id={ariaDescriptionId}>\n {formatMessage({\n id: getTranslation('components.Blocks.dnd.instruction'),\n defaultMessage: `To reorder blocks, press Command or Control along with Shift and the Up or Down arrow keys`,\n })}\n </VisuallyHidden>\n <VisuallyHidden aria-live=\"assertive\">{liveText}</VisuallyHidden>\n <Slate\n editor={editor}\n initialValue={\n value?.length ? value : [{ type: 'paragraph', children: [{ type: 'text', text: '' }] }]\n }\n onChange={handleSlateChange}\n key={key}\n >\n <BlocksEditorProvider\n blocks={blocks}\n modifiers={modifiers}\n disabled={disabled}\n name={name}\n setLiveText={setLiveText}\n isExpandedMode={isExpandedMode}\n >\n <EditorLayout\n error={error}\n disabled={disabled}\n onToggleExpand={handleToggleExpand}\n ariaDescriptionId={ariaDescriptionId}\n >\n <BlocksToolbar />\n <EditorDivider width=\"100%\" />\n <BlocksContent {...contentProps} />\n {!isExpandedMode && !isMobile && (\n <IconButton\n position=\"absolute\"\n bottom=\"1.2rem\"\n right=\"1.2rem\"\n shadow=\"filterShadow\"\n label={formatMessage({\n id: getTranslation('components.Blocks.expand'),\n defaultMessage: 'Expand',\n })}\n onClick={handleToggleExpand}\n >\n <Expand />\n </IconButton>\n )}\n </EditorLayout>\n </BlocksEditorProvider>\n </Slate>\n </>\n );\n }\n);\n\nexport {\n type BlocksStore,\n type SelectorBlockKey,\n BlocksEditor,\n BlocksEditorProvider,\n useBlocksEditorContext,\n isSelectorBlockKey,\n normalizeBlocksState,\n};\n"],"names":["selectorBlockKeys","isSelectorBlockKey","key","includes","BlocksEditorProvider","usePartialBlocksEditorContext","createContext","useBlocksEditorContext","consumerName","context","state","editor","useSlate","EditorDivider","styled","Divider","theme","colors","neutral200","useResetKey","value","slateUpdatesCount","React","useRef","valueUpdatesCount","setKey","useState","useEffect","current","previousKey","incrementSlateUpdatesCount","useCallback","pipe","fns","reduce","prev","fn","normalizeBlocksState","isEmpty","length","Editor","BlocksEditor","forwardRef","disabled","name","onChange","error","contentProps","forwardedRef","formatMessage","useIntl","isMobile","useIsMobile","blocks","useMemo","paragraphBlocks","headingBlocks","listBlocks","linkBlocks","imageBlocks","quoteBlocks","codeBlocks","blockRegisteredPlugins","Object","values","map","block","plugin","filter","isNonNullable","withHistory","withStrapiSchema","withReact","createEditor","liveText","setLiveText","ariaDescriptionId","useId","isExpandedMode","handleToggleExpand","useReducer","useImperativeHandle","focus","ReactEditor","debounceTimeout","handleSlateChange","isAstChange","operations","some","op","type","clearTimeout","setTimeout","isFocused","normalizedValue","normalizedEditorState","children","JSON","stringify","Transforms","deselect","_jsxs","_Fragment","_jsx","VisuallyHidden","id","getTranslation","defaultMessage","aria-live","Slate","initialValue","text","modifiers","EditorLayout","onToggleExpand","BlocksToolbar","width","BlocksContent","IconButton","position","bottom","right","shadow","label","onClick","Expand"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,MAAMA,iBAAAA,GAAoB;AACxB,IAAA,WAAA;AACA,IAAA,aAAA;AACA,IAAA,aAAA;AACA,IAAA,eAAA;AACA,IAAA,cAAA;AACA,IAAA,cAAA;AACA,IAAA,aAAA;AACA,IAAA,cAAA;AACA,IAAA,gBAAA;AACA,IAAA,OAAA;AACA,IAAA,OAAA;AACA,IAAA;AACD,CAAA;AAID,MAAMC,qBAAqB,CAACC,GAAAA,GAAAA;AAC1B,IAAA,OAAO,OAAOA,GAAAA,KAAQ,QAAA,IAAYF,iBAAAA,CAAkBG,QAAQ,CAACD,GAAAA,CAAAA;AAC/D;AAiBA,MAAM,CAACE,oBAAAA,EAAsBC,6BAAAA,CAA8B,GACzDC,aAAAA,CAAwC,cAAA;AAE1C,SAASC,uBACPC,YAAoB,EAAA;AAEpB,IAAA,MAAMC,OAAAA,GAAUJ,6BAAAA,CAA8BG,YAAAA,EAAc,CAACE,KAAAA,GAAUA,KAAAA,CAAAA;AACvE,IAAA,MAAMC,MAAAA,GAASC,QAAAA,EAAAA;IAEf,OAAO;AACL,QAAA,GAAGH,OAAO;AACVE,QAAAA;AACF,KAAA;AACF;AAEA;;AAEkG,qGAElG,MAAME,aAAAA,GAAgBC,MAAAA,CAAOC,OAAAA,CAAQ;cACvB,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACC,UAAU,CAAC;AACvD,CAAC;AAED;;;;;;;IAQA,SAASC,YAAYC,KAAoC,EAAA;;IAKvD,MAAMC,iBAAAA,GAAoBC,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAA;;IAEvC,MAAMC,iBAAAA,GAAoBF,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAA;;AAEvC,IAAA,MAAM,CAACrB,GAAAA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UwC,iBAAAA;AAGV,gBAAA,QAAA,gBAAAkB,GAAA,CAACnG,oBAAAA,EAAAA;oBACCiD,MAAAA,EAAQA,MAAAA;oBACR2D,SAAAA,EAAWA,SAAAA;oBACXrE,QAAAA,EAAUA,QAAAA;oBACVC,IAAAA,EAAMA,IAAAA;oBACN+B,WAAAA,EAAaA,WAAAA;oBACbG,cAAAA,EAAgBA,cAAAA;AAEhB,oBAAA,QAAA,gBAAAuB,IAAA,CAACY,YAAAA,EAAAA;wBACCnE,KAAAA,EAAOA,KAAAA;wBACPH,QAAAA,EAAUA,QAAAA;wBACVuE,cAAAA,EAAgBnC,kBAAAA;wBAChBH,iBAAAA,EAAmBA,iBAAAA;;0CAEnB2B,GAAA,CAACY,aAAAA,EAAAA,EAAAA,CAAAA;0CACDZ,GAAA,CAAC1F,aAAAA,EAAAA;gCAAcuG,KAAAA,EAAM;;0CACrBb,GAAA,CAACc,aAAAA,EAAAA;AAAe,gCAAA,GAAGtE;;4BAClB,CAAC+B,cAAAA,IAAkB,CAAC3B,QAAAA,kBACnBoD,GAAA,CAACe,UAAAA,EAAAA;gCACCC,QAAAA,EAAS,UAAA;gCACTC,MAAAA,EAAO,QAAA;gCACPC,KAAAA,EAAM,QAAA;gCACNC,MAAAA,EAAO,cAAA;AACPC,gCAAAA,KAAAA,EAAO1E,aAAAA,CAAc;AACnBwD,oCAAAA,EAAAA,EAAIC,cAAAA,CAAe,0BAAA,CAAA;oCACnBC,cAAAA,EAAgB;AAClB,iCAAA,CAAA;gCACAiB,OAAAA,EAAS7C,kBAAAA;AAET,gCAAA,QAAA,gBAAAwB,GAAA,CAACsB,MAAAA,EAAAA,EAAAA;;;;;AA/BJ3H,aAAAA,EAAAA,GAAAA;;;AAuCb,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"BlocksEditor.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { createContext, type FieldValue, useIsMobile } from '@strapi/admin/strapi-admin';\nimport { IconButton, Divider, VisuallyHidden } from '@strapi/design-system';\nimport { Expand } from '@strapi/icons';\nimport { flushSync } from 'react-dom';\nimport { MessageDescriptor, useIntl } from 'react-intl';\nimport { Editor, type Descendant, createEditor, Transforms, Element } from 'slate';\nimport { withHistory } from 'slate-history';\nimport { type RenderElementProps, Slate, withReact, ReactEditor, useSlate } from 'slate-react';\nimport { styled, type CSSProperties } from 'styled-components';\n\nimport { getTranslation } from '../../../../../utils/translations';\n\nimport { codeBlocks } from './Blocks/Code';\nimport { headingBlocks } from './Blocks/Heading';\nimport { imageBlocks } from './Blocks/Image';\nimport { linkBlocks } from './Blocks/Link';\nimport { listBlocks } from './Blocks/List';\nimport { paragraphBlocks } from './Blocks/Paragraph';\nimport { quoteBlocks } from './Blocks/Quote';\nimport { BlocksContent, type BlocksContentProps } from './BlocksContent';\nimport { BlocksToolbar } from './BlocksToolbar';\nimport { EditorLayout } from './EditorLayout';\nimport { type ModifiersStore, modifiers } from './Modifiers';\nimport { withStrapiSchema } from './plugins/withStrapiSchema';\nimport { isNonNullable } from './utils/types';\n\nimport type { Schema } from '@strapi/types';\n\n/* -------------------------------------------------------------------------------------------------\n * BlocksEditorProvider\n * -----------------------------------------------------------------------------------------------*/\n\ninterface BaseBlock {\n renderElement: (props: RenderElementProps) => React.JSX.Element;\n /** Function to check if a given node is of this type of block */\n matchNode: (node: Schema.Attribute.BlocksNode) => boolean;\n handleConvert?: (editor: Editor) => void | (() => React.JSX.Element);\n handleEnterKey?: (editor: Editor) => void;\n handleBackspaceKey?: (editor: Editor, event: React.KeyboardEvent<HTMLElement>) => void;\n handleTab?: (editor: Editor) => void;\n handleShiftTab?: (editor: Editor) => void;\n snippets?: string[];\n /** Adjust the vertical positioning of the drag-to-reorder grip icon */\n dragHandleTopMargin?: CSSProperties['marginTop'];\n /** A Slate plugin: function that will wrap the editor creation */\n plugin?: (editor: Editor) => Editor;\n /**\n * Function that checks if an element should be draggable\n * @default () => true */\n isDraggable?: (element: Element) => boolean;\n}\n\ninterface NonSelectorBlock extends BaseBlock {\n isInBlocksSelector: false;\n}\n\ninterface SelectorBlock extends BaseBlock {\n isInBlocksSelector: true;\n icon: React.ComponentType;\n label: MessageDescriptor;\n}\n\ntype NonSelectorBlockKey = 'list-item' | 'link';\n\nconst selectorBlockKeys = [\n 'paragraph',\n 'heading-one',\n 'heading-two',\n 'heading-three',\n 'heading-four',\n 'heading-five',\n 'heading-six',\n 'list-ordered',\n 'list-unordered',\n 'image',\n 'quote',\n 'code',\n] as const;\n\ntype SelectorBlockKey = (typeof selectorBlockKeys)[number];\n\nconst isSelectorBlockKey = (key: unknown): key is SelectorBlockKey => {\n return typeof key === 'string' && selectorBlockKeys.includes(key as SelectorBlockKey);\n};\n\ntype BlocksStore = {\n [K in SelectorBlockKey]: SelectorBlock;\n} & {\n [K in NonSelectorBlockKey]: NonSelectorBlock;\n};\n\ninterface BlocksEditorContextValue {\n blocks: BlocksStore;\n modifiers: ModifiersStore;\n disabled: boolean;\n name: string;\n setLiveText: (text: string) => void;\n isExpandedMode: boolean;\n /** Push debounced Slate → form sync immediately (e.g. on Editable blur before Save). */\n flushPendingFormSync: () => void;\n}\n\nconst [BlocksEditorProvider, usePartialBlocksEditorContext] =\n createContext<BlocksEditorContextValue>('BlocksEditor');\n\nfunction useBlocksEditorContext(\n consumerName: string\n): BlocksEditorContextValue & { editor: Editor } {\n const context = usePartialBlocksEditorContext(consumerName, (state) => state);\n const editor = useSlate();\n\n return {\n ...context,\n editor,\n };\n}\n\n/* -------------------------------------------------------------------------------------------------\n * BlocksEditor\n * -----------------------------------------------------------------------------------------------*/\n\nconst EditorDivider = styled(Divider)`\n background: ${({ theme }) => theme.colors.neutral200};\n`;\n\n/**\n * Forces an update of the Slate editor when the value prop changes from outside of Slate.\n * The root cause is that Slate is not a controlled component: https://github.com/ianstormtaylor/slate/issues/4612\n * Why not use JSON.stringify(value) as the key?\n * Because it would force a rerender of the entire editor every time the user types a character.\n * Why not use the entity id as the key, since it's unique for each locale?\n * Because it would not solve the problem when using the \"fill in from other locale\" feature\n */\nfunction useResetKey(value?: Schema.Attribute.BlocksValue): {\n key: number;\n incrementSlateUpdatesCount: () => void;\n} {\n // Keep track how many times Slate detected a change from a user interaction in the editor\n const slateUpdatesCount = React.useRef(0);\n // Keep track of how many times the value prop was updated, whether from within editor or from outside\n const valueUpdatesCount = React.useRef(0);\n // Use a key to force a rerender of the Slate editor when needed\n const [key, setKey] = React.useState(0);\n\n React.useEffect(() => {\n valueUpdatesCount.current += 1;\n\n // If the 2 refs are not equal, it means the value was updated from outside\n if (valueUpdatesCount.current !== slateUpdatesCount.current) {\n // So we change the key to force a rerender of the Slate editor,\n // which will pick up the new value through its initialValue prop\n setKey((previousKey) => previousKey + 1);\n\n // Then bring the 2 refs back in sync\n slateUpdatesCount.current = valueUpdatesCount.current;\n }\n }, [value]);\n\n const incrementSlateUpdatesCount = React.useCallback(() => {\n slateUpdatesCount.current += 1;\n }, []);\n\n return { key, incrementSlateUpdatesCount };\n}\n\nconst pipe =\n (...fns: ((baseEditor: Editor) => Editor)[]) =>\n (value: Editor) =>\n fns.reduce<Editor>((prev, fn) => fn(prev), value);\n\n/**\n * Normalize the blocks state to null if the editor state is considered empty,\n * otherwise return the state\n */\nconst normalizeBlocksState = (\n editor: Editor,\n value: Schema.Attribute.BlocksValue | Descendant[]\n): Schema.Attribute.BlocksValue | Descendant[] | null => {\n const isEmpty =\n value.length === 1 && Editor.isEmpty(editor, value[0] as Schema.Attribute.BlocksNode);\n\n return isEmpty ? null : value;\n};\n\ninterface BlocksEditorProps\n extends Pick<FieldValue<Schema.Attribute.BlocksValue>, 'onChange' | 'value' | 'error'>,\n BlocksContentProps {\n disabled?: boolean;\n name: string;\n}\n\nconst BlocksEditor = React.forwardRef<{ focus: () => void }, BlocksEditorProps>(\n ({ disabled = false, name, onChange, value, error, ...contentProps }, forwardedRef) => {\n const { formatMessage } = useIntl();\n const isMobile = useIsMobile();\n\n const blocks = React.useMemo(\n () => ({\n ...paragraphBlocks,\n ...headingBlocks,\n ...listBlocks,\n ...linkBlocks,\n ...imageBlocks,\n ...quoteBlocks,\n ...codeBlocks,\n }),\n []\n ) satisfies BlocksStore;\n\n const blockRegisteredPlugins = Object.values(blocks)\n .map((block) => block.plugin)\n .filter(isNonNullable);\n\n const [editor] = React.useState(() =>\n pipe(withHistory, withStrapiSchema, withReact, ...blockRegisteredPlugins)(createEditor())\n );\n const [liveText, setLiveText] = React.useState('');\n const ariaDescriptionId = React.useId();\n const [isExpandedMode, handleToggleExpand] = React.useReducer((prev) => !prev, false);\n\n /**\n * Editable is not able to hold the ref, https://github.com/ianstormtaylor/slate/issues/4082\n * so with \"useImperativeHandle\" we can use ReactEditor methods to expose to the parent above\n * also not passing forwarded ref here, gives console warning.\n */\n React.useImperativeHandle(\n forwardedRef,\n () => ({\n focus() {\n ReactEditor.focus(editor);\n },\n }),\n [editor]\n );\n\n const { key, incrementSlateUpdatesCount } = useResetKey(value);\n\n const debounceTimeout = React.useRef<NodeJS.Timeout | null>(null);\n\n const flushPendingFormSync = React.useCallback(() => {\n if (!debounceTimeout.current) {\n return;\n }\n clearTimeout(debounceTimeout.current);\n debounceTimeout.current = null;\n incrementSlateUpdatesCount();\n // Ensure Strapi Form state updates before the next event (e.g. Save click) reads values.\n flushSync(() => {\n onChange(\n name,\n normalizeBlocksState(editor, editor.children) as Schema.Attribute.BlocksValue\n );\n });\n }, [editor, incrementSlateUpdatesCount, name, onChange]);\n\n const handleSlateChange = React.useCallback(\n (state: Descendant[]) => {\n const isAstChange = editor.operations.some((op) => op.type !== 'set_selection');\n\n if (isAstChange) {\n /**\n * Slate handles the state of the editor internally. We just need to keep Strapi's form\n * state in sync with it in order to make sure that things like the \"modified\" state\n * isn't broken. Updating the whole state on every change is very expensive however,\n * so we debounce calls to onChange to mitigate input lag.\n */\n if (debounceTimeout.current) {\n clearTimeout(debounceTimeout.current);\n }\n\n // Set a new debounce timeout\n debounceTimeout.current = setTimeout(() => {\n incrementSlateUpdatesCount();\n\n // Normalize the state (empty editor becomes null)\n onChange(name, normalizeBlocksState(editor, state) as Schema.Attribute.BlocksValue);\n debounceTimeout.current = null;\n }, 300);\n }\n },\n [editor, incrementSlateUpdatesCount, name, onChange]\n );\n\n // Clean up the timeout on unmount\n React.useEffect(() => {\n return () => {\n if (debounceTimeout.current) {\n clearTimeout(debounceTimeout.current);\n }\n };\n }, []);\n\n // Ensure the editor is in sync after discard\n React.useEffect(() => {\n // Never deselect while the editor is actively focused (typing / editing),\n if (ReactEditor.isFocused(editor)) {\n return;\n }\n\n // Normalize empty states for comparison to avoid losing focus on the editor when content is deleted\n const normalizedValue = value?.length ? value : null;\n const normalizedEditorState = normalizeBlocksState(editor, editor.children);\n\n // Compare the field value with the editor state to check for a stale selection\n if (\n normalizedValue &&\n normalizedEditorState &&\n JSON.stringify(normalizedEditorState) !== JSON.stringify(normalizedValue)\n ) {\n // When there is a diff, unset selection to avoid an invalid state\n Transforms.deselect(editor);\n }\n }, [editor, value]);\n\n return (\n <>\n <VisuallyHidden id={ariaDescriptionId}>\n {formatMessage({\n id: getTranslation('components.Blocks.dnd.instruction'),\n defaultMessage: `To reorder blocks, press Command or Control along with Shift and the Up or Down arrow keys`,\n })}\n </VisuallyHidden>\n <VisuallyHidden aria-live=\"assertive\">{liveText}</VisuallyHidden>\n <Slate\n editor={editor}\n initialValue={\n value?.length ? value : [{ type: 'paragraph', children: [{ type: 'text', text: '' }] }]\n }\n onChange={handleSlateChange}\n key={key}\n >\n <BlocksEditorProvider\n blocks={blocks}\n modifiers={modifiers}\n disabled={disabled}\n name={name}\n setLiveText={setLiveText}\n isExpandedMode={isExpandedMode}\n flushPendingFormSync={flushPendingFormSync}\n >\n <EditorLayout\n error={error}\n disabled={disabled}\n onToggleExpand={handleToggleExpand}\n ariaDescriptionId={ariaDescriptionId}\n >\n <BlocksToolbar />\n <EditorDivider width=\"100%\" />\n <BlocksContent {...contentProps} />\n {!isExpandedMode && !isMobile && (\n <IconButton\n position=\"absolute\"\n bottom=\"1.2rem\"\n right=\"1.2rem\"\n shadow=\"filterShadow\"\n label={formatMessage({\n id: getTranslation('components.Blocks.expand'),\n defaultMessage: 'Expand',\n })}\n onClick={handleToggleExpand}\n >\n <Expand />\n </IconButton>\n )}\n </EditorLayout>\n </BlocksEditorProvider>\n </Slate>\n </>\n );\n }\n);\n\nexport {\n type BlocksStore,\n type SelectorBlockKey,\n BlocksEditor,\n BlocksEditorProvider,\n useBlocksEditorContext,\n isSelectorBlockKey,\n normalizeBlocksState,\n};\n"],"names":["selectorBlockKeys","isSelectorBlockKey","key","includes","BlocksEditorProvider","usePartialBlocksEditorContext","createContext","useBlocksEditorContext","consumerName","context","state","editor","useSlate","EditorDivider","styled","Divider","theme","colors","neutral200","useResetKey","value","slateUpdatesCount","React","useRef","valueUpdatesCount","setKey","useState","useEffect","current","previousKey","incrementSlateUpdatesCount","useCallback","pipe","fns","reduce","prev","fn","normalizeBlocksState","isEmpty","length","Editor","BlocksEditor","forwardRef","disabled","name","onChange","error","contentProps","forwardedRef","formatMessage","useIntl","isMobile","useIsMobile","blocks","useMemo","paragraphBlocks","headingBlocks","listBlocks","linkBlocks","imageBlocks","quoteBlocks","codeBlocks","blockRegisteredPlugins","Object","values","map","block","plugin","filter","isNonNullable","withHistory","withStrapiSchema","withReact","createEditor","liveText","setLiveText","ariaDescriptionId","useId","isExpandedMode","handleToggleExpand","useReducer","useImperativeHandle","focus","ReactEditor","debounceTimeout","flushPendingFormSync","clearTimeout","flushSync","children","handleSlateChange","isAstChange","operations","some","op","type","setTimeout","isFocused","normalizedValue","normalizedEditorState","JSON","stringify","Transforms","deselect","_jsxs","_Fragment","_jsx","VisuallyHidden","id","getTranslation","defaultMessage","aria-live","Slate","initialValue","text","modifiers","EditorLayout","onToggleExpand","BlocksToolbar","width","BlocksContent","IconButton","position","bottom","right","shadow","label","onClick","Expand"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;A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AA,EAAO,cAAA;AACPC,gCAAAA,KAAAA,EAAO5E,aAAAA,CAAc;AACnB0D,oCAAAA,EAAAA,EAAIC,cAAAA,CAAe,0BAAA,CAAA;oCACnBC,cAAAA,EAAgB;AAClB,iCAAA,CAAA;gCACAiB,OAAAA,EAAS/C,kBAAAA;AAET,gCAAA,QAAA,gBAAA0B,GAAA,CAACsB,MAAAA,EAAAA,EAAAA;;;;;AAhCJ7H,aAAAA,EAAAA,GAAAA;;;AAwCb,CAAA;;;;"}
|
|
@@ -51,7 +51,10 @@ const ComponentCategory = ({ category, components = [], variant = 'primary', onA
|
|
|
51
51
|
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
|
|
52
52
|
variant: "pi",
|
|
53
53
|
fontWeight: "bold",
|
|
54
|
-
children:
|
|
54
|
+
children: formatMessage({
|
|
55
|
+
id: uid,
|
|
56
|
+
defaultMessage: displayName ?? uid
|
|
57
|
+
})
|
|
55
58
|
})
|
|
56
59
|
]
|
|
57
60
|
})
|
package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComponentCategory.js","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Accordion, Box, Flex, FlexComponent, Typography } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { styled } from 'styled-components';\n\nimport { ComponentIcon } from '../../../../../components/ComponentIcon';\n\ninterface ComponentCategoryProps {\n category: string;\n components?: Array<{\n uid: string;\n displayName: string;\n icon?: string;\n }>;\n onAddComponent: (\n componentUid: string\n ) => React.MouseEventHandler<HTMLButtonElement> & React.MouseEventHandler<HTMLDivElement>;\n variant?: Accordion.Variant;\n}\n\nconst ComponentCategory = ({\n category,\n components = [],\n variant = 'primary',\n onAddComponent,\n}: ComponentCategoryProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <Accordion.Item value={category}>\n <Accordion.Header variant={variant}>\n <Accordion.Trigger>\n {formatMessage({ id: category, defaultMessage: category })}\n </Accordion.Trigger>\n </Accordion.Header>\n <ResponsiveAccordionContent>\n <Grid paddingTop={4} paddingBottom={4} paddingLeft={3} paddingRight={3}>\n {components.map(({ uid, displayName, icon }) => (\n <ComponentBox\n key={uid}\n tag=\"button\"\n type=\"button\"\n background=\"neutral100\"\n justifyContent=\"center\"\n onClick={onAddComponent(uid)}\n hasRadius\n height=\"8.4rem\"\n shrink={0}\n borderColor=\"neutral200\"\n >\n <Flex direction=\"column\" gap={1} alignItems=\"center\" justifyContent=\"center\">\n <ComponentIcon color=\"currentColor\" background=\"primary200\" icon={icon} />\n\n <Typography variant=\"pi\" fontWeight=\"bold\">\n {displayName}\n </Typography>\n </Flex>\n </ComponentBox>\n ))}\n </Grid>\n </ResponsiveAccordionContent>\n </Accordion.Item>\n );\n};\n\nconst ResponsiveAccordionContent = styled(Accordion.Content)`\n container-type: inline-size;\n`;\n\n/**\n * TODO:\n * JSDOM cannot handle container queries.\n * This is a temporary workaround so that tests do not fail in the CI when jestdom throws an error\n * for failing to parse the stylesheet.\n */\nconst Grid =\n process.env.NODE_ENV !== 'test'\n ? styled(Box)`\n display: grid;\n grid-template-columns: repeat(auto-fill, 100%);\n grid-gap: 12px;\n\n ${({ theme }) => theme.breakpoints.medium} {\n grid-template-columns: repeat(auto-fill, 14rem);\n grid-gap: 4px;\n }\n `\n : styled(Box)`\n display: grid;\n grid-template-columns: repeat(auto-fill, 100%);\n grid-gap: 12px;\n\n ${({ theme }) => theme.breakpoints.medium} {\n grid-gap: 4px;\n }\n `;\n\nconst ComponentBox = styled<FlexComponent<'button'>>(Flex)`\n color: ${({ theme }) => theme.colors.neutral600};\n cursor: pointer;\n\n @media (prefers-reduced-motion: no-preference) {\n transition: color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};\n }\n\n &:focus,\n &:hover {\n border: 1px solid ${({ theme }) => theme.colors.primary200};\n background: ${({ theme }) => theme.colors.primary100};\n color: ${({ theme }) => theme.colors.primary600};\n }\n`;\n\nexport { ComponentCategory };\nexport type { ComponentCategoryProps };\n"],"names":["ComponentCategory","category","components","variant","onAddComponent","formatMessage","useIntl","_jsxs","Accordion","Item","value","_jsx","Header","Trigger","id","defaultMessage","ResponsiveAccordionContent","Grid","paddingTop","paddingBottom","paddingLeft","paddingRight","map","uid","displayName","icon","ComponentBox","tag","type","background","justifyContent","onClick","hasRadius","height","shrink","borderColor","Flex","direction","gap","alignItems","ComponentIcon","color","Typography","fontWeight","styled","Content","process","env","NODE_ENV","Box","theme","breakpoints","medium","colors","neutral600","props","motion","easings","easeOutQuad","primary200","primary100","primary600"],"mappings":";;;;;;;;;AAqBA,MAAMA,iBAAAA,GAAoB,CAAC,EACzBC,QAAQ,EACRC,UAAAA,GAAa,EAAE,EACfC,OAAAA,GAAU,SAAS,EACnBC,cAAc,EACS,GAAA;IACvB,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;IAE1B,qBACEC,eAAA,CAACC,uBAAUC,IAAI,EAAA;QAACC,KAAAA,EAAOT,QAAAA;;AACrB,0BAAAU,cAAA,CAACH,uBAAUI,MAAM,EAAA;gBAACT,OAAAA,EAASA,OAAAA;wCACzBQ,cAAA,CAACH,uBAAUK,OAAO,EAAA;8BACfR,aAAAA,CAAc;wBAAES,EAAAA,EAAIb,QAAAA;wBAAUc,cAAAA,EAAgBd;AAAS,qBAAA;;;0BAG5DU,cAAA,CAACK,0BAAAA,EAAAA;AACC,gBAAA,QAAA,gBAAAL,cAAA,CAACM,IAAAA,EAAAA;oBAAKC,UAAAA,EAAY,CAAA;oBAAGC,aAAAA,EAAe,CAAA;oBAAGC,WAAAA,EAAa,CAAA;oBAAGC,YAAAA,EAAc,CAAA;8BAClEnB,UAAAA,CAAWoB,GAAG,CAAC,CAAC,EAAEC,GAAG,EAAEC,WAAW,EAAEC,IAAI,EAAE,iBACzCd,cAAA,CAACe,YAAAA,EAAAA;4BAECC,GAAAA,EAAI,QAAA;4BACJC,IAAAA,EAAK,QAAA;4BACLC,UAAAA,EAAW,YAAA;4BACXC,cAAAA,EAAe,QAAA;AACfC,4BAAAA,OAAAA,EAAS3B,cAAAA,CAAemB,GAAAA,CAAAA;4BACxBS,SAAS,EAAA,IAAA;4BACTC,MAAAA,EAAO,QAAA;4BACPC,MAAAA,EAAQ,CAAA;4BACRC,WAAAA,EAAY,YAAA;AAEZ,4BAAA,QAAA,gBAAA5B,eAAA,CAAC6B,iBAAAA,EAAAA;gCAAKC,SAAAA,EAAU,QAAA;gCAASC,GAAAA,EAAK,CAAA;gCAAGC,UAAAA,EAAW,QAAA;gCAAST,cAAAA,EAAe,QAAA;;kDAClEnB,cAAA,CAAC6B,2BAAAA,EAAAA;wCAAcC,KAAAA,EAAM,cAAA;wCAAeZ,UAAAA,EAAW,YAAA;wCAAaJ,IAAAA,EAAMA;;kDAElEd,cAAA,CAAC+B,uBAAAA,EAAAA;wCAAWvC,OAAAA,EAAQ,IAAA;wCAAKwC,UAAAA,EAAW,MAAA;
|
|
1
|
+
{"version":3,"file":"ComponentCategory.js","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Accordion, Box, Flex, FlexComponent, Typography } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { styled } from 'styled-components';\n\nimport { ComponentIcon } from '../../../../../components/ComponentIcon';\n\ninterface ComponentCategoryProps {\n category: string;\n components?: Array<{\n uid: string;\n displayName: string;\n icon?: string;\n }>;\n onAddComponent: (\n componentUid: string\n ) => React.MouseEventHandler<HTMLButtonElement> & React.MouseEventHandler<HTMLDivElement>;\n variant?: Accordion.Variant;\n}\n\nconst ComponentCategory = ({\n category,\n components = [],\n variant = 'primary',\n onAddComponent,\n}: ComponentCategoryProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <Accordion.Item value={category}>\n <Accordion.Header variant={variant}>\n <Accordion.Trigger>\n {formatMessage({ id: category, defaultMessage: category })}\n </Accordion.Trigger>\n </Accordion.Header>\n <ResponsiveAccordionContent>\n <Grid paddingTop={4} paddingBottom={4} paddingLeft={3} paddingRight={3}>\n {components.map(({ uid, displayName, icon }) => (\n <ComponentBox\n key={uid}\n tag=\"button\"\n type=\"button\"\n background=\"neutral100\"\n justifyContent=\"center\"\n onClick={onAddComponent(uid)}\n hasRadius\n height=\"8.4rem\"\n shrink={0}\n borderColor=\"neutral200\"\n >\n <Flex direction=\"column\" gap={1} alignItems=\"center\" justifyContent=\"center\">\n <ComponentIcon color=\"currentColor\" background=\"primary200\" icon={icon} />\n\n <Typography variant=\"pi\" fontWeight=\"bold\">\n {formatMessage({ id: uid, defaultMessage: displayName ?? uid })}\n </Typography>\n </Flex>\n </ComponentBox>\n ))}\n </Grid>\n </ResponsiveAccordionContent>\n </Accordion.Item>\n );\n};\n\nconst ResponsiveAccordionContent = styled(Accordion.Content)`\n container-type: inline-size;\n`;\n\n/**\n * TODO:\n * JSDOM cannot handle container queries.\n * This is a temporary workaround so that tests do not fail in the CI when jestdom throws an error\n * for failing to parse the stylesheet.\n */\nconst Grid =\n process.env.NODE_ENV !== 'test'\n ? styled(Box)`\n display: grid;\n grid-template-columns: repeat(auto-fill, 100%);\n grid-gap: 12px;\n\n ${({ theme }) => theme.breakpoints.medium} {\n grid-template-columns: repeat(auto-fill, 14rem);\n grid-gap: 4px;\n }\n `\n : styled(Box)`\n display: grid;\n grid-template-columns: repeat(auto-fill, 100%);\n grid-gap: 12px;\n\n ${({ theme }) => theme.breakpoints.medium} {\n grid-gap: 4px;\n }\n `;\n\nconst ComponentBox = styled<FlexComponent<'button'>>(Flex)`\n color: ${({ theme }) => theme.colors.neutral600};\n cursor: pointer;\n\n @media (prefers-reduced-motion: no-preference) {\n transition: color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};\n }\n\n &:focus,\n &:hover {\n border: 1px solid ${({ theme }) => theme.colors.primary200};\n background: ${({ theme }) => theme.colors.primary100};\n color: ${({ theme }) => theme.colors.primary600};\n }\n`;\n\nexport { ComponentCategory };\nexport type { ComponentCategoryProps };\n"],"names":["ComponentCategory","category","components","variant","onAddComponent","formatMessage","useIntl","_jsxs","Accordion","Item","value","_jsx","Header","Trigger","id","defaultMessage","ResponsiveAccordionContent","Grid","paddingTop","paddingBottom","paddingLeft","paddingRight","map","uid","displayName","icon","ComponentBox","tag","type","background","justifyContent","onClick","hasRadius","height","shrink","borderColor","Flex","direction","gap","alignItems","ComponentIcon","color","Typography","fontWeight","styled","Content","process","env","NODE_ENV","Box","theme","breakpoints","medium","colors","neutral600","props","motion","easings","easeOutQuad","primary200","primary100","primary600"],"mappings":";;;;;;;;;AAqBA,MAAMA,iBAAAA,GAAoB,CAAC,EACzBC,QAAQ,EACRC,UAAAA,GAAa,EAAE,EACfC,OAAAA,GAAU,SAAS,EACnBC,cAAc,EACS,GAAA;IACvB,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;IAE1B,qBACEC,eAAA,CAACC,uBAAUC,IAAI,EAAA;QAACC,KAAAA,EAAOT,QAAAA;;AACrB,0BAAAU,cAAA,CAACH,uBAAUI,MAAM,EAAA;gBAACT,OAAAA,EAASA,OAAAA;wCACzBQ,cAAA,CAACH,uBAAUK,OAAO,EAAA;8BACfR,aAAAA,CAAc;wBAAES,EAAAA,EAAIb,QAAAA;wBAAUc,cAAAA,EAAgBd;AAAS,qBAAA;;;0BAG5DU,cAAA,CAACK,0BAAAA,EAAAA;AACC,gBAAA,QAAA,gBAAAL,cAAA,CAACM,IAAAA,EAAAA;oBAAKC,UAAAA,EAAY,CAAA;oBAAGC,aAAAA,EAAe,CAAA;oBAAGC,WAAAA,EAAa,CAAA;oBAAGC,YAAAA,EAAc,CAAA;8BAClEnB,UAAAA,CAAWoB,GAAG,CAAC,CAAC,EAAEC,GAAG,EAAEC,WAAW,EAAEC,IAAI,EAAE,iBACzCd,cAAA,CAACe,YAAAA,EAAAA;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KAAAA,CAAMC,WAAW,CAACC,MAAM,CAAC;;;MAG5C,CAAC;AAEP,MAAM1B,YAAAA,GAAekB,uBAAAA,CAAgCR,iBAAAA,CAAK;SACjD,EAAE,CAAC,EAAEc,KAAK,EAAE,GAAKA,KAAAA,CAAMG,MAAM,CAACC,UAAU,CAAC;;;;4BAItB,EAAE,CAACC,KAAAA,GAAUA,KAAAA,CAAML,KAAK,CAACM,MAAM,CAACC,OAAO,CAACC,WAAW,CAAC;;;;;sBAK1D,EAAE,CAAC,EAAER,KAAK,EAAE,GAAKA,KAAAA,CAAMG,MAAM,CAACM,UAAU,CAAC;gBAC/C,EAAE,CAAC,EAAET,KAAK,EAAE,GAAKA,KAAAA,CAAMG,MAAM,CAACO,UAAU,CAAC;WAC9C,EAAE,CAAC,EAAEV,KAAK,EAAE,GAAKA,KAAAA,CAAMG,MAAM,CAACQ,UAAU,CAAC;;AAEpD,CAAC;;;;"}
|
|
@@ -49,7 +49,10 @@ const ComponentCategory = ({ category, components = [], variant = 'primary', onA
|
|
|
49
49
|
/*#__PURE__*/ jsx(Typography, {
|
|
50
50
|
variant: "pi",
|
|
51
51
|
fontWeight: "bold",
|
|
52
|
-
children:
|
|
52
|
+
children: formatMessage({
|
|
53
|
+
id: uid,
|
|
54
|
+
defaultMessage: displayName ?? uid
|
|
55
|
+
})
|
|
53
56
|
})
|
|
54
57
|
]
|
|
55
58
|
})
|
package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComponentCategory.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Accordion, Box, Flex, FlexComponent, Typography } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { styled } from 'styled-components';\n\nimport { ComponentIcon } from '../../../../../components/ComponentIcon';\n\ninterface ComponentCategoryProps {\n category: string;\n components?: Array<{\n uid: string;\n displayName: string;\n icon?: string;\n }>;\n onAddComponent: (\n componentUid: string\n ) => React.MouseEventHandler<HTMLButtonElement> & React.MouseEventHandler<HTMLDivElement>;\n variant?: Accordion.Variant;\n}\n\nconst ComponentCategory = ({\n category,\n components = [],\n variant = 'primary',\n onAddComponent,\n}: ComponentCategoryProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <Accordion.Item value={category}>\n <Accordion.Header variant={variant}>\n <Accordion.Trigger>\n {formatMessage({ id: category, defaultMessage: category })}\n </Accordion.Trigger>\n </Accordion.Header>\n <ResponsiveAccordionContent>\n <Grid paddingTop={4} paddingBottom={4} paddingLeft={3} paddingRight={3}>\n {components.map(({ uid, displayName, icon }) => (\n <ComponentBox\n key={uid}\n tag=\"button\"\n type=\"button\"\n background=\"neutral100\"\n justifyContent=\"center\"\n onClick={onAddComponent(uid)}\n hasRadius\n height=\"8.4rem\"\n shrink={0}\n borderColor=\"neutral200\"\n >\n <Flex direction=\"column\" gap={1} alignItems=\"center\" justifyContent=\"center\">\n <ComponentIcon color=\"currentColor\" background=\"primary200\" icon={icon} />\n\n <Typography variant=\"pi\" fontWeight=\"bold\">\n {displayName}\n </Typography>\n </Flex>\n </ComponentBox>\n ))}\n </Grid>\n </ResponsiveAccordionContent>\n </Accordion.Item>\n );\n};\n\nconst ResponsiveAccordionContent = styled(Accordion.Content)`\n container-type: inline-size;\n`;\n\n/**\n * TODO:\n * JSDOM cannot handle container queries.\n * This is a temporary workaround so that tests do not fail in the CI when jestdom throws an error\n * for failing to parse the stylesheet.\n */\nconst Grid =\n process.env.NODE_ENV !== 'test'\n ? styled(Box)`\n display: grid;\n grid-template-columns: repeat(auto-fill, 100%);\n grid-gap: 12px;\n\n ${({ theme }) => theme.breakpoints.medium} {\n grid-template-columns: repeat(auto-fill, 14rem);\n grid-gap: 4px;\n }\n `\n : styled(Box)`\n display: grid;\n grid-template-columns: repeat(auto-fill, 100%);\n grid-gap: 12px;\n\n ${({ theme }) => theme.breakpoints.medium} {\n grid-gap: 4px;\n }\n `;\n\nconst ComponentBox = styled<FlexComponent<'button'>>(Flex)`\n color: ${({ theme }) => theme.colors.neutral600};\n cursor: pointer;\n\n @media (prefers-reduced-motion: no-preference) {\n transition: color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};\n }\n\n &:focus,\n &:hover {\n border: 1px solid ${({ theme }) => theme.colors.primary200};\n background: ${({ theme }) => theme.colors.primary100};\n color: ${({ theme }) => theme.colors.primary600};\n }\n`;\n\nexport { ComponentCategory };\nexport type { ComponentCategoryProps };\n"],"names":["ComponentCategory","category","components","variant","onAddComponent","formatMessage","useIntl","_jsxs","Accordion","Item","value","_jsx","Header","Trigger","id","defaultMessage","ResponsiveAccordionContent","Grid","paddingTop","paddingBottom","paddingLeft","paddingRight","map","uid","displayName","icon","ComponentBox","tag","type","background","justifyContent","onClick","hasRadius","height","shrink","borderColor","Flex","direction","gap","alignItems","ComponentIcon","color","Typography","fontWeight","styled","Content","process","env","NODE_ENV","Box","theme","breakpoints","medium","colors","neutral600","props","motion","easings","easeOutQuad","primary200","primary100","primary600"],"mappings":";;;;;;;AAqBA,MAAMA,iBAAAA,GAAoB,CAAC,EACzBC,QAAQ,EACRC,UAAAA,GAAa,EAAE,EACfC,OAAAA,GAAU,SAAS,EACnBC,cAAc,EACS,GAAA;IACvB,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;IAE1B,qBACEC,IAAA,CAACC,UAAUC,IAAI,EAAA;QAACC,KAAAA,EAAOT,QAAAA;;AACrB,0BAAAU,GAAA,CAACH,UAAUI,MAAM,EAAA;gBAACT,OAAAA,EAASA,OAAAA;wCACzBQ,GAAA,CAACH,UAAUK,OAAO,EAAA;8BACfR,aAAAA,CAAc;wBAAES,EAAAA,EAAIb,QAAAA;wBAAUc,cAAAA,EAAgBd;AAAS,qBAAA;;;0BAG5DU,GAAA,CAACK,0BAAAA,EAAAA;AACC,gBAAA,QAAA,gBAAAL,GAAA,CAACM,IAAAA,EAAAA;oBAAKC,UAAAA,EAAY,CAAA;oBAAGC,aAAAA,EAAe,CAAA;oBAAGC,WAAAA,EAAa,CAAA;oBAAGC,YAAAA,EAAc,CAAA;8BAClEnB,UAAAA,CAAWoB,GAAG,CAAC,CAAC,EAAEC,GAAG,EAAEC,WAAW,EAAEC,IAAI,EAAE,iBACzCd,GAAA,CAACe,YAAAA,EAAAA;4BAECC,GAAAA,EAAI,QAAA;4BACJC,IAAAA,EAAK,QAAA;4BACLC,UAAAA,EAAW,YAAA;4BACXC,cAAAA,EAAe,QAAA;AACfC,4BAAAA,OAAAA,EAAS3B,cAAAA,CAAemB,GAAAA,CAAAA;4BACxBS,SAAS,EAAA,IAAA;4BACTC,MAAAA,EAAO,QAAA;4BACPC,MAAAA,EAAQ,CAAA;4BACRC,WAAAA,EAAY,YAAA;AAEZ,4BAAA,QAAA,gBAAA5B,IAAA,CAAC6B,IAAAA,EAAAA;gCAAKC,SAAAA,EAAU,QAAA;gCAASC,GAAAA,EAAK,CAAA;gCAAGC,UAAAA,EAAW,QAAA;gCAAST,cAAAA,EAAe,QAAA;;kDAClEnB,GAAA,CAAC6B,aAAAA,EAAAA;wCAAcC,KAAAA,EAAM,cAAA;wCAAeZ,UAAAA,EAAW,YAAA;wCAAaJ,IAAAA,EAAMA;;kDAElEd,GAAA,CAAC+B,UAAAA,EAAAA;wCAAWvC,OAAAA,EAAQ,IAAA;wCAAKwC,UAAAA,EAAW,MAAA;
|
|
1
|
+
{"version":3,"file":"ComponentCategory.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Accordion, Box, Flex, FlexComponent, Typography } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { styled } from 'styled-components';\n\nimport { ComponentIcon } from '../../../../../components/ComponentIcon';\n\ninterface ComponentCategoryProps {\n category: string;\n components?: Array<{\n uid: string;\n displayName: string;\n icon?: string;\n }>;\n onAddComponent: (\n componentUid: string\n ) => React.MouseEventHandler<HTMLButtonElement> & React.MouseEventHandler<HTMLDivElement>;\n variant?: Accordion.Variant;\n}\n\nconst ComponentCategory = ({\n category,\n components = [],\n variant = 'primary',\n onAddComponent,\n}: ComponentCategoryProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <Accordion.Item value={category}>\n <Accordion.Header variant={variant}>\n <Accordion.Trigger>\n {formatMessage({ id: category, defaultMessage: category })}\n </Accordion.Trigger>\n </Accordion.Header>\n <ResponsiveAccordionContent>\n <Grid paddingTop={4} paddingBottom={4} paddingLeft={3} paddingRight={3}>\n {components.map(({ uid, displayName, icon }) => (\n <ComponentBox\n key={uid}\n tag=\"button\"\n type=\"button\"\n background=\"neutral100\"\n justifyContent=\"center\"\n onClick={onAddComponent(uid)}\n hasRadius\n height=\"8.4rem\"\n shrink={0}\n borderColor=\"neutral200\"\n >\n <Flex direction=\"column\" gap={1} alignItems=\"center\" justifyContent=\"center\">\n <ComponentIcon color=\"currentColor\" background=\"primary200\" icon={icon} />\n\n <Typography variant=\"pi\" fontWeight=\"bold\">\n {formatMessage({ id: uid, defaultMessage: displayName ?? uid })}\n </Typography>\n </Flex>\n </ComponentBox>\n ))}\n </Grid>\n </ResponsiveAccordionContent>\n </Accordion.Item>\n );\n};\n\nconst ResponsiveAccordionContent = styled(Accordion.Content)`\n container-type: inline-size;\n`;\n\n/**\n * TODO:\n * JSDOM cannot handle container queries.\n * This is a temporary workaround so that tests do not fail in the CI when jestdom throws an error\n * for failing to parse the stylesheet.\n */\nconst Grid =\n process.env.NODE_ENV !== 'test'\n ? styled(Box)`\n display: grid;\n grid-template-columns: repeat(auto-fill, 100%);\n grid-gap: 12px;\n\n ${({ theme }) => theme.breakpoints.medium} {\n grid-template-columns: repeat(auto-fill, 14rem);\n grid-gap: 4px;\n }\n `\n : styled(Box)`\n display: grid;\n grid-template-columns: repeat(auto-fill, 100%);\n grid-gap: 12px;\n\n ${({ theme }) => theme.breakpoints.medium} {\n grid-gap: 4px;\n }\n `;\n\nconst ComponentBox = styled<FlexComponent<'button'>>(Flex)`\n color: ${({ theme }) => theme.colors.neutral600};\n cursor: pointer;\n\n @media (prefers-reduced-motion: no-preference) {\n transition: color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};\n }\n\n &:focus,\n &:hover {\n border: 1px solid ${({ theme }) => theme.colors.primary200};\n background: ${({ theme }) => theme.colors.primary100};\n color: ${({ theme }) => theme.colors.primary600};\n }\n`;\n\nexport { ComponentCategory };\nexport type { ComponentCategoryProps };\n"],"names":["ComponentCategory","category","components","variant","onAddComponent","formatMessage","useIntl","_jsxs","Accordion","Item","value","_jsx","Header","Trigger","id","defaultMessage","ResponsiveAccordionContent","Grid","paddingTop","paddingBottom","paddingLeft","paddingRight","map","uid","displayName","icon","ComponentBox","tag","type","background","justifyContent","onClick","hasRadius","height","shrink","borderColor","Flex","direction","gap","alignItems","ComponentIcon","color","Typography","fontWeight","styled","Content","process","env","NODE_ENV","Box","theme","breakpoints","medium","colors","neutral600","props","motion","easings","easeOutQuad","primary200","primary100","primary600"],"mappings":";;;;;;;AAqBA,MAAMA,iBAAAA,GAAoB,CAAC,EACzBC,QAAQ,EACRC,UAAAA,GAAa,EAAE,EACfC,OAAAA,GAAU,SAAS,EACnBC,cAAc,EACS,GAAA;IACvB,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;IAE1B,qBACEC,IAAA,CAACC,UAAUC,IAAI,EAAA;QAACC,KAAAA,EAAOT,QAAAA;;AACrB,0BAAAU,GAAA,CAACH,UAAUI,MAAM,EAAA;gBAACT,OAAAA,EAASA,OAAAA;wCACzBQ,GAAA,CAACH,UAAUK,OAAO,EAAA;8BACfR,aAAAA,CAAc;wBAAES,EAAAA,EAAIb,QAAAA;wBAAUc,cAAAA,EAAgBd;AAAS,qBAAA;;;0BAG5DU,GAAA,CAACK,0BAAAA,EAAAA;AACC,gBAAA,QAAA,gBAAAL,GAAA,CAACM,IAAAA,EAAAA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,GACrBJ,MAAAA,CAAOK,GAAAA,CAAI;;;;;QAKT,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAAA,CAAMC,WAAW,CAACC,MAAM,CAAC;;;;MAI5C,CAAC,GACDR,MAAAA,CAAOK,GAAAA,CAAI;;;;;QAKT,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAAA,CAAMC,WAAW,CAACC,MAAM,CAAC;;;MAG5C,CAAC;AAEP,MAAM1B,YAAAA,GAAekB,MAAAA,CAAgCR,IAAAA,CAAK;SACjD,EAAE,CAAC,EAAEc,KAAK,EAAE,GAAKA,KAAAA,CAAMG,MAAM,CAACC,UAAU,CAAC;;;;4BAItB,EAAE,CAACC,KAAAA,GAAUA,KAAAA,CAAML,KAAK,CAACM,MAAM,CAACC,OAAO,CAACC,WAAW,CAAC;;;;;sBAK1D,EAAE,CAAC,EAAER,KAAK,EAAE,GAAKA,KAAAA,CAAMG,MAAM,CAACM,UAAU,CAAC;gBAC/C,EAAE,CAAC,EAAET,KAAK,EAAE,GAAKA,KAAAA,CAAMG,MAAM,CAACO,UAAU,CAAC;WAC9C,EAAE,CAAC,EAAEV,KAAK,EAAE,GAAKA,KAAAA,CAAMG,MAAM,CAACQ,UAAU,CAAC;;AAEpD,CAAC;;;;"}
|
|
@@ -46,11 +46,24 @@ const DynamicComponent = ({ componentUid, disabled, index, name, onRemoveCompone
|
|
|
46
46
|
const mainFieldValue = strapiAdmin.useForm('DynamicComponent', (state)=>objects.getIn(state.values, `${name}.${index}.${mainField}`));
|
|
47
47
|
const displayedValue = mainField === 'id' || !mainFieldValue ? '' : String(mainFieldValue).trim();
|
|
48
48
|
const displayTitle = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
icon
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
const { icon, displayName } = React__namespace.useMemo(()=>{
|
|
50
|
+
const [category] = componentUid.split('.');
|
|
51
|
+
const { icon, displayName } = (dynamicComponentsByCategory[category] ?? []).find((component)=>component.uid === componentUid) ?? {
|
|
52
|
+
icon: null,
|
|
53
|
+
displayName: null
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
icon,
|
|
57
|
+
displayName: formatMessage({
|
|
58
|
+
id: componentUid,
|
|
59
|
+
defaultMessage: displayName || componentUid
|
|
60
|
+
})
|
|
61
|
+
};
|
|
62
|
+
}, [
|
|
63
|
+
componentUid,
|
|
64
|
+
dynamicComponentsByCategory,
|
|
65
|
+
formatMessage
|
|
66
|
+
]);
|
|
54
67
|
const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop.useDragAndDrop(!disabled, {
|
|
55
68
|
type: `${dragAndDrop.ItemTypes.DYNAMIC_ZONE}_${name}`,
|
|
56
69
|
index,
|
|
@@ -188,11 +201,17 @@ const DynamicComponent = ({ componentUid, disabled, index, name, onRemoveCompone
|
|
|
188
201
|
children: Object.entries(dynamicComponentsByCategory).map(([category, components])=>/*#__PURE__*/ jsxRuntime.jsxs(React__namespace.Fragment, {
|
|
189
202
|
children: [
|
|
190
203
|
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Label, {
|
|
191
|
-
children:
|
|
204
|
+
children: formatMessage({
|
|
205
|
+
id: category,
|
|
206
|
+
defaultMessage: category
|
|
207
|
+
})
|
|
192
208
|
}),
|
|
193
209
|
components.map(({ displayName, uid })=>/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Item, {
|
|
194
210
|
onSelect: ()=>onAddComponent(uid, index),
|
|
195
|
-
children:
|
|
211
|
+
children: formatMessage({
|
|
212
|
+
id: uid,
|
|
213
|
+
defaultMessage: displayName ?? uid
|
|
214
|
+
})
|
|
196
215
|
}, uid))
|
|
197
216
|
]
|
|
198
217
|
}, category))
|
|
@@ -211,11 +230,17 @@ const DynamicComponent = ({ componentUid, disabled, index, name, onRemoveCompone
|
|
|
211
230
|
children: Object.entries(dynamicComponentsByCategory).map(([category, components])=>/*#__PURE__*/ jsxRuntime.jsxs(React__namespace.Fragment, {
|
|
212
231
|
children: [
|
|
213
232
|
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Label, {
|
|
214
|
-
children:
|
|
233
|
+
children: formatMessage({
|
|
234
|
+
id: category,
|
|
235
|
+
defaultMessage: category
|
|
236
|
+
})
|
|
215
237
|
}),
|
|
216
238
|
components.map(({ displayName, uid })=>/*#__PURE__*/ jsxRuntime.jsx(designSystem.Menu.Item, {
|
|
217
239
|
onSelect: ()=>onAddComponent(uid, index + 1),
|
|
218
|
-
children:
|
|
240
|
+
children: formatMessage({
|
|
241
|
+
id: uid,
|
|
242
|
+
defaultMessage: displayName ?? uid
|
|
243
|
+
})
|
|
219
244
|
}, uid))
|
|
220
245
|
]
|
|
221
246
|
}, category))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicComponent.js","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useForm, useIsDesktop } from '@strapi/admin/strapi-admin';\nimport {\n Accordion,\n Box,\n Flex,\n Grid,\n IconButton,\n useComposedRefs,\n Menu,\n BoxComponent,\n} from '@strapi/design-system';\nimport { Drag, More, Trash, ArrowUp, ArrowDown } from '@strapi/icons';\nimport { getEmptyImage } from 'react-dnd-html5-backend';\nimport { useIntl } from 'react-intl';\nimport { styled } from 'styled-components';\n\nimport { COMPONENT_ICONS } from '../../../../../components/ComponentIcon';\nimport { ItemTypes } from '../../../../../constants/dragAndDrop';\nimport { useDocumentContext } from '../../../../../hooks/useDocumentContext';\nimport { type EditFieldLayout, useDocumentLayout } from '../../../../../hooks/useDocumentLayout';\nimport { type UseDragAndDropOptions, useDragAndDrop } from '../../../../../hooks/useDragAndDrop';\nimport { getIn } from '../../../../../utils/objects';\nimport { getTranslation } from '../../../../../utils/translations';\nimport { ResponsiveGridItem, ResponsiveGridRoot } from '../../FormLayout';\nimport { InputRenderer, type InputRendererProps } from '../../InputRenderer';\n\nimport type { ComponentPickerProps } from './ComponentPicker';\n\ninterface DynamicComponentProps\n extends Pick<UseDragAndDropOptions, 'onGrabItem' | 'onDropItem' | 'onCancel'>,\n Pick<ComponentPickerProps, 'dynamicComponentsByCategory'> {\n componentUid: string;\n disabled?: boolean;\n index: number;\n name: string;\n onAddComponent: (componentUid: string, index: number) => void;\n onRemoveComponentClick: (index: number) => void;\n onMoveComponent: (dragIndex: number, hoverIndex: number) => void;\n totalLength: number;\n children?: (props: InputRendererProps) => React.ReactNode;\n}\n\nconst DynamicComponent = ({\n componentUid,\n disabled,\n index,\n name,\n onRemoveComponentClick,\n onMoveComponent,\n onGrabItem,\n onDropItem,\n onCancel,\n dynamicComponentsByCategory = {},\n onAddComponent,\n totalLength,\n children,\n}: DynamicComponentProps) => {\n const { formatMessage } = useIntl();\n const { currentDocumentMeta } = useDocumentContext('DynamicComponent');\n const isDesktop = useIsDesktop();\n\n const {\n edit: { components },\n } = useDocumentLayout(currentDocumentMeta.model);\n\n const { mainField = 'id' } = components[componentUid]?.settings ?? {};\n\n const mainFieldValue = useForm('DynamicComponent', (state) =>\n getIn(state.values, `${name}.${index}.${mainField}`)\n );\n\n const displayedValue = mainField === 'id' || !mainFieldValue ? '' : String(mainFieldValue).trim();\n const displayTitle = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;\n\n const [category] = componentUid.split('.');\n const { icon, displayName } = (dynamicComponentsByCategory[category] ?? []).find(\n (component) => component.uid === componentUid\n ) ?? { icon: null, displayName: null };\n\n const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] =\n useDragAndDrop(!disabled, {\n type: `${ItemTypes.DYNAMIC_ZONE}_${name}`,\n index,\n item: {\n index,\n displayedValue: `${displayName} ${displayTitle}`,\n icon,\n },\n onMoveItem: onMoveComponent,\n onDropItem,\n onGrabItem,\n onCancel,\n });\n\n React.useEffect(() => {\n dragPreviewRef(getEmptyImage(), { captureDraggingState: false });\n }, [dragPreviewRef, index]);\n\n /**\n * We don't need the accordion's to communicate with each other,\n * so a unique value for their state is enough.\n */\n const accordionValue = React.useId();\n\n const componentPath = `${name}.${index}`;\n const hasValue = useForm(\n 'DynamicComponent',\n (state) => getIn(state.values, componentPath) != null\n );\n const isNewItem = useForm(\n 'DynamicComponent',\n (state) => getIn(state.values, componentPath)?.id == null\n );\n const rawError = useForm('DynamicComponent', (state) => getIn(state.errors, componentPath));\n\n const [collapseToOpen, setCollapseToOpen] = React.useState<string>(\n isNewItem ? accordionValue : ''\n );\n\n React.useEffect(() => {\n if (rawError && hasValue) {\n setCollapseToOpen(accordionValue);\n }\n }, [rawError, hasValue, accordionValue]);\n\n const composedBoxRefs = useComposedRefs(boxRef, dropRef);\n\n const canMoveUp = index > 0;\n const canMoveDown = index < totalLength - 1;\n const handleRemoveCurrentComponent = React.useCallback(() => {\n onRemoveComponentClick(index);\n }, [onRemoveComponentClick, index]);\n\n const accordionActions = disabled ? null : (\n <>\n <IconButton\n variant=\"ghost\"\n label={formatMessage(\n {\n id: getTranslation('components.DynamicZone.delete-label'),\n defaultMessage: 'Delete {name}',\n },\n { name: displayTitle }\n )}\n onClick={handleRemoveCurrentComponent}\n >\n <Trash />\n </IconButton>\n {isDesktop && (\n <IconButton\n variant=\"ghost\"\n onClick={(e) => e.stopPropagation()}\n data-handler-id={handlerId}\n ref={dragRef}\n label={formatMessage({\n id: getTranslation('components.DragHandle-label'),\n defaultMessage: 'Drag',\n })}\n onKeyDown={handleKeyDown}\n >\n <Drag />\n </IconButton>\n )}\n {!isDesktop && (\n <>\n {canMoveUp && (\n <IconButton\n variant=\"ghost\"\n onClick={(e) => {\n e.stopPropagation();\n onMoveComponent(index - 1, index);\n }}\n disabled={!canMoveUp}\n label={formatMessage({\n id: getTranslation('components.DynamicZone.move-up'),\n defaultMessage: 'Move up',\n })}\n >\n <ArrowUp />\n </IconButton>\n )}\n {canMoveDown && (\n <IconButton\n variant=\"ghost\"\n onClick={(e) => {\n e.stopPropagation();\n onMoveComponent(index + 1, index);\n }}\n disabled={!canMoveDown}\n label={formatMessage({\n id: getTranslation('components.DynamicZone.move-down'),\n defaultMessage: 'Move down',\n })}\n >\n <ArrowDown />\n </IconButton>\n )}\n </>\n )}\n <Menu.Root>\n <Menu.Trigger size=\"S\" endIcon={null} paddingLeft={0} paddingRight={0}>\n <IconButton\n variant=\"ghost\"\n label={formatMessage({\n id: getTranslation('components.DynamicZone.more-actions'),\n defaultMessage: 'More actions',\n })}\n tag=\"span\"\n >\n <More aria-hidden focusable={false} />\n </IconButton>\n </Menu.Trigger>\n <Menu.Content>\n <Menu.SubRoot>\n <Menu.SubTrigger>\n {formatMessage({\n id: getTranslation('components.DynamicZone.add-item-above'),\n defaultMessage: 'Add component above',\n })}\n </Menu.SubTrigger>\n <Menu.SubContent>\n {Object.entries(dynamicComponentsByCategory).map(([category, components]) => (\n <React.Fragment key={category}>\n <Menu.Label>{category}</Menu.Label>\n {components.map(({ displayName, uid }) => (\n <Menu.Item key={uid} onSelect={() => onAddComponent(uid, index)}>\n {displayName}\n </Menu.Item>\n ))}\n </React.Fragment>\n ))}\n </Menu.SubContent>\n </Menu.SubRoot>\n <Menu.SubRoot>\n <Menu.SubTrigger>\n {formatMessage({\n id: getTranslation('components.DynamicZone.add-item-below'),\n defaultMessage: 'Add component below',\n })}\n </Menu.SubTrigger>\n <Menu.SubContent>\n {Object.entries(dynamicComponentsByCategory).map(([category, components]) => (\n <React.Fragment key={category}>\n <Menu.Label>{category}</Menu.Label>\n {components.map(({ displayName, uid }) => (\n <Menu.Item key={uid} onSelect={() => onAddComponent(uid, index + 1)}>\n {displayName}\n </Menu.Item>\n ))}\n </React.Fragment>\n ))}\n </Menu.SubContent>\n </Menu.SubRoot>\n </Menu.Content>\n </Menu.Root>\n </>\n );\n\n const accordionTitle = displayTitle ? `${displayName} ${displayTitle}` : displayName;\n\n return (\n <ComponentContainer tag=\"li\" width=\"100%\">\n <Flex justifyContent=\"center\">\n <Rectangle background=\"neutral200\" />\n </Flex>\n <StyledBox ref={composedBoxRefs} hasRadius>\n {isDragging ? (\n <Preview />\n ) : (\n <Accordion.Root value={collapseToOpen} onValueChange={setCollapseToOpen}>\n <Accordion.Item value={accordionValue}>\n <Accordion.Header>\n <Accordion.Trigger\n icon={\n icon && COMPONENT_ICONS[icon]\n ? COMPONENT_ICONS[icon]\n : COMPONENT_ICONS.dashboard\n }\n >\n {accordionTitle}\n </Accordion.Trigger>\n <Accordion.Actions>{accordionActions}</Accordion.Actions>\n </Accordion.Header>\n <Accordion.Content>\n <AccordionContentRadius background=\"neutral0\">\n <DynamicComponentFields\n componentUid={componentUid}\n index={index}\n layout={components[componentUid]?.layout}\n name={name}\n >\n {children}\n </DynamicComponentFields>\n </AccordionContentRadius>\n </Accordion.Content>\n </Accordion.Item>\n </Accordion.Root>\n )}\n </StyledBox>\n </ComponentContainer>\n );\n};\n\n// TODO: Delete once https://github.com/strapi/design-system/pull/858\n// is merged and released.\nconst StyledBox = styled<BoxComponent>(Box)`\n > div:first-child {\n box-shadow: ${({ theme }) => theme.shadows.tableShadow};\n }\n`;\n\nconst AccordionContentRadius = styled<BoxComponent>(Box)`\n border-radius: 0 0 ${({ theme }) => theme.spaces[1]} ${({ theme }) => theme.spaces[1]};\n`;\n\nconst Rectangle = styled<BoxComponent>(Box)`\n width: ${({ theme }) => theme.spaces[2]};\n height: ${({ theme }) => theme.spaces[4]};\n`;\n\nconst Preview = styled.span`\n display: block;\n background-color: ${({ theme }) => theme.colors.primary100};\n outline: 1px dashed ${({ theme }) => theme.colors.primary500};\n outline-offset: -1px;\n padding: ${({ theme }) => theme.spaces[6]};\n`;\n\nconst ComponentContainer = styled<BoxComponent<'li'>>(Box)`\n list-style: none;\n padding: 0;\n margin: 0;\n`;\n\ninterface DynamicComponentFieldsProps extends Pick<DynamicComponentProps, 'children'> {\n componentUid: string;\n index: number;\n layout?: EditFieldLayout[][];\n name: string;\n}\n\nconst DynamicComponentFields = React.memo(\n ({ children, componentUid, index, layout, name }: DynamicComponentFieldsProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <Box padding={{ initial: 4, medium: 6 }}>\n <Grid.Root gap={4}>\n {layout?.map((row, rowInd) => {\n return (\n <Grid.Item col={12} key={rowInd} xs={12} direction=\"column\" alignItems=\"stretch\">\n <ResponsiveGridRoot gap={4}>\n {row.map(({ size, ...field }) => {\n const fieldName = `${name}.${index}.${field.name}`;\n\n const fieldWithTranslatedLabel = {\n ...field,\n label: formatMessage({\n id: `content-manager.components.${componentUid}.${field.name}`,\n defaultMessage: field.label,\n }),\n };\n\n return (\n <ResponsiveGridItem\n col={size}\n key={fieldName}\n s={12}\n xs={12}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n {children ? (\n children({\n ...fieldWithTranslatedLabel,\n name: fieldName,\n })\n ) : (\n <InputRenderer {...fieldWithTranslatedLabel} name={fieldName} />\n )}\n </ResponsiveGridItem>\n );\n })}\n </ResponsiveGridRoot>\n </Grid.Item>\n );\n })}\n </Grid.Root>\n </Box>\n );\n }\n);\n\nDynamicComponentFields.displayName = 'DynamicComponentFields';\n\nconst MemoizedDynamicComponent = React.memo(DynamicComponent);\n\nexport { MemoizedDynamicComponent as DynamicComponent };\nexport type { DynamicComponentProps };\n"],"names":["DynamicComponent","componentUid","disabled","index","name","onRemoveComponentClick","onMoveComponent","onGrabItem","onDropItem","onCancel","dynamicComponentsByCategory","onAddComponent","totalLength","children","formatMessage","useIntl","currentDocumentMeta","useDocumentContext","isDesktop","useIsDesktop","edit","components","useDocumentLayout","model","mainField","settings","mainFieldValue","useForm","state","getIn","values","displayedValue","String","trim","displayTitle","length","category","split","icon","displayName","find","component","uid","handlerId","isDragging","handleKeyDown","boxRef","dropRef","dragRef","dragPreviewRef","useDragAndDrop","type","ItemTypes","DYNAMIC_ZONE","item","onMoveItem","React","useEffect","getEmptyImage","captureDraggingState","accordionValue","useId","componentPath","hasValue","isNewItem","id","rawError","errors","collapseToOpen","setCollapseToOpen","useState","composedBoxRefs","useComposedRefs","canMoveUp","canMoveDown","handleRemoveCurrentComponent","useCallback","accordionActions","_jsxs","_Fragment","_jsx","IconButton","variant","label","getTranslation","defaultMessage","onClick","Trash","e","stopPropagation","data-handler-id","ref","onKeyDown","Drag","ArrowUp","ArrowDown","Menu","Root","Trigger","size","endIcon","paddingLeft","paddingRight","tag","More","aria-hidden","focusable","Content","SubRoot","SubTrigger","SubContent","Object","entries","map","Fragment","Label","Item","onSelect","accordionTitle","ComponentContainer","width","Flex","justifyContent","Rectangle","background","StyledBox","hasRadius","Preview","Accordion","value","onValueChange","Header","COMPONENT_ICONS","dashboard","Actions","AccordionContentRadius","DynamicComponentFields","layout","styled","Box","theme","shadows","tableShadow","spaces","span","colors","primary100","primary500","memo","padding","initial","medium","Grid","gap","row","rowInd","col","xs","direction","alignItems","ResponsiveGridRoot","field","fieldName","fieldWithTranslatedLabel","ResponsiveGridItem","s","InputRenderer","MemoizedDynamicComponent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAMA,gBAAAA,GAAmB,CAAC,EACxBC,YAAY,EACZC,QAAQ,EACRC,KAAK,EACLC,IAAI,EACJC,sBAAsB,EACtBC,eAAe,EACfC,UAAU,EACVC,UAAU,EACVC,QAAQ,EACRC,2BAAAA,GAA8B,EAAE,EAChCC,cAAc,EACdC,WAAW,EACXC,QAAQ,EACc,GAAA;IACtB,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;AAC1B,IAAA,MAAM,EAAEC,mBAAmB,EAAE,GAAGC,qCAAAA,CAAmB,kBAAA,CAAA;AACnD,IAAA,MAAMC,SAAAA,GAAYC,wBAAAA,EAAAA;IAElB,MAAM,EACJC,MAAM,EAAEC,UAAU,EAAE,EACrB,GAAGC,mCAAAA,CAAkBN,mBAAAA,CAAoBO,KAAK,CAAA;IAE/C,MAAM,EAAEC,SAAAA,GAAY,IAAI,EAAE,GA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AA,EAAG,EAAA;gCACHR,EAAAA,EAAI,EAAA;gCACJC,SAAAA,EAAU,QAAA;gCACVC,UAAAA,EAAW,SAAA;AAEVlJ,gCAAAA,QAAAA,EAAAA,QAAAA,GACCA,QAAAA,CAAS;AACP,oCAAA,GAAGsJ,wBAAwB;oCAC3B/J,IAAAA,EAAM8J;AACR,iCAAA,CAAA,iBAEAlF,cAAA,CAACsF,2BAAAA,EAAAA;AAAe,oCAAA,GAAGH,wBAAwB;oCAAE/J,IAAAA,EAAM8J;;AAZhDA,6BAAAA,EAAAA,SAAAA,CAAAA;AAgBX,wBAAA,CAAA;;AAhCqBP,iBAAAA,EAAAA,MAAAA,CAAAA;AAoC7B,YAAA,CAAA;;;AAIR,CAAA,CAAA;AAGFnB,sBAAAA,CAAuBjG,WAAW,GAAG,wBAAA;AAErC,MAAMgI,wBAAAA,iBAA2B/G,gBAAAA,CAAM4F,IAAI,CAACpJ,gBAAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"DynamicComponent.js","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useForm, useIsDesktop } from '@strapi/admin/strapi-admin';\nimport {\n Accordion,\n Box,\n Flex,\n Grid,\n IconButton,\n useComposedRefs,\n Menu,\n BoxComponent,\n} from '@strapi/design-system';\nimport { Drag, More, Trash, ArrowUp, ArrowDown } from '@strapi/icons';\nimport { getEmptyImage } from 'react-dnd-html5-backend';\nimport { useIntl } from 'react-intl';\nimport { styled } from 'styled-components';\n\nimport { COMPONENT_ICONS } from '../../../../../components/ComponentIcon';\nimport { ItemTypes } from '../../../../../constants/dragAndDrop';\nimport { useDocumentContext } from '../../../../../hooks/useDocumentContext';\nimport { type EditFieldLayout, useDocumentLayout } from '../../../../../hooks/useDocumentLayout';\nimport { type UseDragAndDropOptions, useDragAndDrop } from '../../../../../hooks/useDragAndDrop';\nimport { getIn } from '../../../../../utils/objects';\nimport { getTranslation } from '../../../../../utils/translations';\nimport { ResponsiveGridItem, ResponsiveGridRoot } from '../../FormLayout';\nimport { InputRenderer, type InputRendererProps } from '../../InputRenderer';\n\nimport type { ComponentPickerProps } from './ComponentPicker';\n\ninterface DynamicComponentProps\n extends Pick<UseDragAndDropOptions, 'onGrabItem' | 'onDropItem' | 'onCancel'>,\n Pick<ComponentPickerProps, 'dynamicComponentsByCategory'> {\n componentUid: string;\n disabled?: boolean;\n index: number;\n name: string;\n onAddComponent: (componentUid: string, index: number) => void;\n onRemoveComponentClick: (index: number) => void;\n onMoveComponent: (dragIndex: number, hoverIndex: number) => void;\n totalLength: number;\n children?: (props: InputRendererProps) => React.ReactNode;\n}\n\nconst DynamicComponent = ({\n componentUid,\n disabled,\n index,\n name,\n onRemoveComponentClick,\n onMoveComponent,\n onGrabItem,\n onDropItem,\n onCancel,\n dynamicComponentsByCategory = {},\n onAddComponent,\n totalLength,\n children,\n}: DynamicComponentProps) => {\n const { formatMessage } = useIntl();\n const { currentDocumentMeta } = useDocumentContext('DynamicComponent');\n const isDesktop = useIsDesktop();\n\n const {\n edit: { components },\n } = useDocumentLayout(currentDocumentMeta.model);\n\n const { mainField = 'id' } = components[componentUid]?.settings ?? {};\n\n const mainFieldValue = useForm('DynamicComponent', (state) =>\n getIn(state.values, `${name}.${index}.${mainField}`)\n );\n\n const displayedValue = mainField === 'id' || !mainFieldValue ? '' : String(mainFieldValue).trim();\n const displayTitle = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;\n\n const { icon, displayName } = React.useMemo(() => {\n const [category] = componentUid.split('.');\n const { icon, displayName } = (dynamicComponentsByCategory[category] ?? []).find(\n (component) => component.uid === componentUid\n ) ?? { icon: null, displayName: null };\n\n return {\n icon,\n displayName: formatMessage({\n id: componentUid,\n defaultMessage: displayName || componentUid,\n }),\n };\n }, [componentUid, dynamicComponentsByCategory, formatMessage]);\n\n const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] =\n useDragAndDrop(!disabled, {\n type: `${ItemTypes.DYNAMIC_ZONE}_${name}`,\n index,\n item: {\n index,\n displayedValue: `${displayName} ${displayTitle}`,\n icon,\n },\n onMoveItem: onMoveComponent,\n onDropItem,\n onGrabItem,\n onCancel,\n });\n\n React.useEffect(() => {\n dragPreviewRef(getEmptyImage(), { captureDraggingState: false });\n }, [dragPreviewRef, index]);\n\n /**\n * We don't need the accordion's to communicate with each other,\n * so a unique value for their state is enough.\n */\n const accordionValue = React.useId();\n\n const componentPath = `${name}.${index}`;\n const hasValue = useForm(\n 'DynamicComponent',\n (state) => getIn(state.values, componentPath) != null\n );\n const isNewItem = useForm(\n 'DynamicComponent',\n (state) => getIn(state.values, componentPath)?.id == null\n );\n const rawError = useForm('DynamicComponent', (state) => getIn(state.errors, componentPath));\n\n const [collapseToOpen, setCollapseToOpen] = React.useState<string>(\n isNewItem ? accordionValue : ''\n );\n\n React.useEffect(() => {\n if (rawError && hasValue) {\n setCollapseToOpen(accordionValue);\n }\n }, [rawError, hasValue, accordionValue]);\n\n const composedBoxRefs = useComposedRefs(boxRef, dropRef);\n\n const canMoveUp = index > 0;\n const canMoveDown = index < totalLength - 1;\n const handleRemoveCurrentComponent = React.useCallback(() => {\n onRemoveComponentClick(index);\n }, [onRemoveComponentClick, index]);\n\n const accordionActions = disabled ? null : (\n <>\n <IconButton\n variant=\"ghost\"\n label={formatMessage(\n {\n id: getTranslation('components.DynamicZone.delete-label'),\n defaultMessage: 'Delete {name}',\n },\n { name: displayTitle }\n )}\n onClick={handleRemoveCurrentComponent}\n >\n <Trash />\n </IconButton>\n {isDesktop && (\n <IconButton\n variant=\"ghost\"\n onClick={(e) => e.stopPropagation()}\n data-handler-id={handlerId}\n ref={dragRef}\n label={formatMessage({\n id: getTranslation('components.DragHandle-label'),\n defaultMessage: 'Drag',\n })}\n onKeyDown={handleKeyDown}\n >\n <Drag />\n </IconButton>\n )}\n {!isDesktop && (\n <>\n {canMoveUp && (\n <IconButton\n variant=\"ghost\"\n onClick={(e) => {\n e.stopPropagation();\n onMoveComponent(index - 1, index);\n }}\n disabled={!canMoveUp}\n label={formatMessage({\n id: getTranslation('components.DynamicZone.move-up'),\n defaultMessage: 'Move up',\n })}\n >\n <ArrowUp />\n </IconButton>\n )}\n {canMoveDown && (\n <IconButton\n variant=\"ghost\"\n onClick={(e) => {\n e.stopPropagation();\n onMoveComponent(index + 1, index);\n }}\n disabled={!canMoveDown}\n label={formatMessage({\n id: getTranslation('components.DynamicZone.move-down'),\n defaultMessage: 'Move down',\n })}\n >\n <ArrowDown />\n </IconButton>\n )}\n </>\n )}\n <Menu.Root>\n <Menu.Trigger size=\"S\" endIcon={null} paddingLeft={0} paddingRight={0}>\n <IconButton\n variant=\"ghost\"\n label={formatMessage({\n id: getTranslation('components.DynamicZone.more-actions'),\n defaultMessage: 'More actions',\n })}\n tag=\"span\"\n >\n <More aria-hidden focusable={false} />\n </IconButton>\n </Menu.Trigger>\n <Menu.Content>\n <Menu.SubRoot>\n <Menu.SubTrigger>\n {formatMessage({\n id: getTranslation('components.DynamicZone.add-item-above'),\n defaultMessage: 'Add component above',\n })}\n </Menu.SubTrigger>\n <Menu.SubContent>\n {Object.entries(dynamicComponentsByCategory).map(([category, components]) => (\n <React.Fragment key={category}>\n <Menu.Label>\n {formatMessage({ id: category, defaultMessage: category })}\n </Menu.Label>\n {components.map(({ displayName, uid }) => (\n <Menu.Item key={uid} onSelect={() => onAddComponent(uid, index)}>\n {formatMessage({ id: uid, defaultMessage: displayName ?? uid })}\n </Menu.Item>\n ))}\n </React.Fragment>\n ))}\n </Menu.SubContent>\n </Menu.SubRoot>\n <Menu.SubRoot>\n <Menu.SubTrigger>\n {formatMessage({\n id: getTranslation('components.DynamicZone.add-item-below'),\n defaultMessage: 'Add component below',\n })}\n </Menu.SubTrigger>\n <Menu.SubContent>\n {Object.entries(dynamicComponentsByCategory).map(([category, components]) => (\n <React.Fragment key={category}>\n <Menu.Label>\n {formatMessage({ id: category, defaultMessage: category })}\n </Menu.Label>\n {components.map(({ displayName, uid }) => (\n <Menu.Item key={uid} onSelect={() => onAddComponent(uid, index + 1)}>\n {formatMessage({ id: uid, defaultMessage: displayName ?? uid })}\n </Menu.Item>\n ))}\n </React.Fragment>\n ))}\n </Menu.SubContent>\n </Menu.SubRoot>\n </Menu.Content>\n </Menu.Root>\n </>\n );\n\n const accordionTitle = displayTitle ? `${displayName} ${displayTitle}` : displayName;\n\n return (\n <ComponentContainer tag=\"li\" width=\"100%\">\n <Flex justifyContent=\"center\">\n <Rectangle background=\"neutral200\" />\n </Flex>\n <StyledBox ref={composedBoxRefs} hasRadius>\n {isDragging ? (\n <Preview />\n ) : (\n <Accordion.Root value={collapseToOpen} onValueChange={setCollapseToOpen}>\n <Accordion.Item value={accordionValue}>\n <Accordion.Header>\n <Accordion.Trigger\n icon={\n icon && COMPONENT_ICONS[icon]\n ? COMPONENT_ICONS[icon]\n : COMPONENT_ICONS.dashboard\n }\n >\n {accordionTitle}\n </Accordion.Trigger>\n <Accordion.Actions>{accordionActions}</Accordion.Actions>\n </Accordion.Header>\n <Accordion.Content>\n <AccordionContentRadius background=\"neutral0\">\n <DynamicComponentFields\n componentUid={componentUid}\n index={index}\n layout={components[componentUid]?.layout}\n name={name}\n >\n {children}\n </DynamicComponentFields>\n </AccordionContentRadius>\n </Accordion.Content>\n </Accordion.Item>\n </Accordion.Root>\n )}\n </StyledBox>\n </ComponentContainer>\n );\n};\n\n// TODO: Delete once https://github.com/strapi/design-system/pull/858\n// is merged and released.\nconst StyledBox = styled<BoxComponent>(Box)`\n > div:first-child {\n box-shadow: ${({ theme }) => theme.shadows.tableShadow};\n }\n`;\n\nconst AccordionContentRadius = styled<BoxComponent>(Box)`\n border-radius: 0 0 ${({ theme }) => theme.spaces[1]} ${({ theme }) => theme.spaces[1]};\n`;\n\nconst Rectangle = styled<BoxComponent>(Box)`\n width: ${({ theme }) => theme.spaces[2]};\n height: ${({ theme }) => theme.spaces[4]};\n`;\n\nconst Preview = styled.span`\n display: block;\n background-color: ${({ theme }) => theme.colors.primary100};\n outline: 1px dashed ${({ theme }) => theme.colors.primary500};\n outline-offset: -1px;\n padding: ${({ theme }) => theme.spaces[6]};\n`;\n\nconst ComponentContainer = styled<BoxComponent<'li'>>(Box)`\n list-style: none;\n padding: 0;\n margin: 0;\n`;\n\ninterface DynamicComponentFieldsProps extends Pick<DynamicComponentProps, 'children'> {\n componentUid: string;\n index: number;\n layout?: EditFieldLayout[][];\n name: string;\n}\n\nconst DynamicComponentFields = React.memo(\n ({ children, componentUid, index, layout, name }: DynamicComponentFieldsProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <Box padding={{ initial: 4, medium: 6 }}>\n <Grid.Root gap={4}>\n {layout?.map((row, rowInd) => {\n return (\n <Grid.Item col={12} key={rowInd} xs={12} direction=\"column\" alignItems=\"stretch\">\n <ResponsiveGridRoot gap={4}>\n {row.map(({ size, ...field }) => {\n const fieldName = `${name}.${index}.${field.name}`;\n\n const fieldWithTranslatedLabel = {\n ...field,\n label: formatMessage({\n id: `content-manager.components.${componentUid}.${field.name}`,\n defaultMessage: field.label,\n }),\n };\n\n return (\n <ResponsiveGridItem\n col={size}\n key={fieldName}\n s={12}\n xs={12}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n {children ? (\n children({\n ...fieldWithTranslatedLabel,\n name: fieldName,\n })\n ) : (\n <InputRenderer {...fieldWithTranslatedLabel} name={fieldName} />\n )}\n </ResponsiveGridItem>\n );\n })}\n </ResponsiveGridRoot>\n </Grid.Item>\n );\n })}\n </Grid.Root>\n </Box>\n );\n }\n);\n\nDynamicComponentFields.displayName = 'DynamicComponentFields';\n\nconst MemoizedDynamicComponent = React.memo(DynamicComponent);\n\nexport { MemoizedDynamicComponent as DynamicComponent };\nexport type { DynamicComponentProps };\n"],"names":["DynamicComponent","componentUid","disabled","index","name","onRemoveComponentClick","onMoveComponent","onGrabItem","onDropItem","onCancel","dynamicComponentsByCategory","onAddComponent","totalLength","children","formatMessage","useIntl","currentDocumentMeta","useDocumentContext","isDesktop","useIsDesktop","edit","components","useDocumentLayout","model","mainField","settings","mainFieldValue","useForm","state","getIn","values","displayedValue","String","trim","displayTitle","length","icon","displayName","React","useMemo","category","split","find","component","uid","id","defaultMessage","handlerId","isDragging","handleKeyDown","boxRef","dropRef","dragRef","dragPreviewRef","useDragAndDrop","type","ItemTypes","DYNAMIC_ZONE","item","onMoveItem","useEffect","getEmptyImage","captureDraggingState","accordionValue","useId","componentPath","hasValue","isNewItem","rawError","errors","collapseToOpen","setCollapseToOpen","useState","composedBoxRefs","useComposedRefs","canMoveUp","canMoveDown","handleRemoveCurrentComponent","useCallback","accordionActions","_jsxs","_Fragment","_jsx","IconButton","variant","label","getTranslation","onClick","Trash","e","stopPropagation","data-handler-id","ref","onKeyDown","Drag","ArrowUp","ArrowDown","Menu","Root","Trigger","size","endIcon","paddingLeft","paddingRight","tag","More","aria-hidden","focusable","Content","SubRoot","SubTrigger","SubContent","Object","entries","map","Fragment","Label","Item","onSelect","accordionTitle","ComponentContainer","width","Flex","justifyContent","Rectangle","background","StyledBox","hasRadius","Preview","Accordion","value","onValueChange","Header","COMPONENT_ICONS","dashboard","Actions","AccordionContentRadius","DynamicComponentFields","layout","styled","Box","theme","shadows","tableShadow","spaces","span","colors","primary100","primary500","memo","padding","initial","medium","Grid","gap","row","rowInd","col","xs","direction","alignItems","ResponsiveGridRoot","field","fieldName","fieldWithTranslatedLabel","ResponsiveGridItem","s","InputRenderer","MemoizedDynamicComponent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAMA,gBAAAA,GAAmB,CAAC,EACxBC,YAAY,EACZC,QAAQ,EACRC,KAAK,EACLC,IAAI,EACJC,sBAAsB,EACtBC,eAAe,EACfC,UAAU,EACVC,UAAU,EACVC,QAAQ,EACRC,2BAAAA,GAA8B,EAAE,EAChCC,cAAc,EACdC,WAAW,EACXC,QAAQ,EACc,GAAA;IACtB,MAAM,EAAEC,aAAa,EAA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A,EAAAA;AAAe,oCAAA,GAAGH,wBAAwB;oCAAEhK,IAAAA,EAAM+J;;AAZhDA,6BAAAA,EAAAA,SAAAA,CAAAA;AAgBX,wBAAA,CAAA;;AAhCqBP,iBAAAA,EAAAA,MAAAA,CAAAA;AAoC7B,YAAA,CAAA;;;AAIR,CAAA,CAAA;AAGFnB,sBAAAA,CAAuBpG,WAAW,GAAG,wBAAA;AAErC,MAAMmI,wBAAAA,iBAA2BlI,gBAAAA,CAAM+G,IAAI,CAACrJ,gBAAAA;;;;"}
|
|
@@ -25,11 +25,24 @@ const DynamicComponent = ({ componentUid, disabled, index, name, onRemoveCompone
|
|
|
25
25
|
const mainFieldValue = useForm('DynamicComponent', (state)=>getIn(state.values, `${name}.${index}.${mainField}`));
|
|
26
26
|
const displayedValue = mainField === 'id' || !mainFieldValue ? '' : String(mainFieldValue).trim();
|
|
27
27
|
const displayTitle = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
icon
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
const { icon, displayName } = React.useMemo(()=>{
|
|
29
|
+
const [category] = componentUid.split('.');
|
|
30
|
+
const { icon, displayName } = (dynamicComponentsByCategory[category] ?? []).find((component)=>component.uid === componentUid) ?? {
|
|
31
|
+
icon: null,
|
|
32
|
+
displayName: null
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
icon,
|
|
36
|
+
displayName: formatMessage({
|
|
37
|
+
id: componentUid,
|
|
38
|
+
defaultMessage: displayName || componentUid
|
|
39
|
+
})
|
|
40
|
+
};
|
|
41
|
+
}, [
|
|
42
|
+
componentUid,
|
|
43
|
+
dynamicComponentsByCategory,
|
|
44
|
+
formatMessage
|
|
45
|
+
]);
|
|
33
46
|
const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop(!disabled, {
|
|
34
47
|
type: `${ItemTypes.DYNAMIC_ZONE}_${name}`,
|
|
35
48
|
index,
|
|
@@ -167,11 +180,17 @@ const DynamicComponent = ({ componentUid, disabled, index, name, onRemoveCompone
|
|
|
167
180
|
children: Object.entries(dynamicComponentsByCategory).map(([category, components])=>/*#__PURE__*/ jsxs(React.Fragment, {
|
|
168
181
|
children: [
|
|
169
182
|
/*#__PURE__*/ jsx(Menu.Label, {
|
|
170
|
-
children:
|
|
183
|
+
children: formatMessage({
|
|
184
|
+
id: category,
|
|
185
|
+
defaultMessage: category
|
|
186
|
+
})
|
|
171
187
|
}),
|
|
172
188
|
components.map(({ displayName, uid })=>/*#__PURE__*/ jsx(Menu.Item, {
|
|
173
189
|
onSelect: ()=>onAddComponent(uid, index),
|
|
174
|
-
children:
|
|
190
|
+
children: formatMessage({
|
|
191
|
+
id: uid,
|
|
192
|
+
defaultMessage: displayName ?? uid
|
|
193
|
+
})
|
|
175
194
|
}, uid))
|
|
176
195
|
]
|
|
177
196
|
}, category))
|
|
@@ -190,11 +209,17 @@ const DynamicComponent = ({ componentUid, disabled, index, name, onRemoveCompone
|
|
|
190
209
|
children: Object.entries(dynamicComponentsByCategory).map(([category, components])=>/*#__PURE__*/ jsxs(React.Fragment, {
|
|
191
210
|
children: [
|
|
192
211
|
/*#__PURE__*/ jsx(Menu.Label, {
|
|
193
|
-
children:
|
|
212
|
+
children: formatMessage({
|
|
213
|
+
id: category,
|
|
214
|
+
defaultMessage: category
|
|
215
|
+
})
|
|
194
216
|
}),
|
|
195
217
|
components.map(({ displayName, uid })=>/*#__PURE__*/ jsx(Menu.Item, {
|
|
196
218
|
onSelect: ()=>onAddComponent(uid, index + 1),
|
|
197
|
-
children:
|
|
219
|
+
children: formatMessage({
|
|
220
|
+
id: uid,
|
|
221
|
+
defaultMessage: displayName ?? uid
|
|
222
|
+
})
|
|
198
223
|
}, uid))
|
|
199
224
|
]
|
|
200
225
|
}, category))
|