@strapi/content-manager 5.33.2 → 5.33.4
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/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.js +23 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.mjs +23 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.js +14 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.mjs +14 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Link.js +157 -7
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Link.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Link.mjs +154 -5
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Link.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.js +28 -20
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.mjs +25 -17
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js +6 -3
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs +7 -4
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js +12 -12
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs +13 -13
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js +2 -2
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/types.js +4 -8
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/types.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/types.mjs +4 -7
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/types.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js +2 -12
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs +2 -12
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js +48 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs +49 -2
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js +47 -13
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs +49 -15
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.js +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.mjs +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +10 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +10 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.js +5 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.mjs +5 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/InputRenderer.js +6 -2
- package/dist/admin/pages/EditView/components/InputRenderer.js.map +1 -1
- package/dist/admin/pages/EditView/components/InputRenderer.mjs +6 -2
- package/dist/admin/pages/EditView/components/InputRenderer.mjs.map +1 -1
- package/dist/admin/pages/EditView/utils/data.js +22 -0
- package/dist/admin/pages/EditView/utils/data.js.map +1 -1
- package/dist/admin/pages/EditView/utils/data.mjs +22 -1
- package/dist/admin/pages/EditView/utils/data.mjs.map +1 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Link.d.ts +9 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.d.ts +9 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/types.d.ts +2 -4
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +2 -1
- package/dist/admin/src/pages/EditView/utils/data.d.ts +6 -1
- package/package.json +9 -9
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withImages.js +0 -17
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withImages.js.map +0 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withImages.mjs +0 -15
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withImages.mjs.map +0 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withLinks.js +0 -75
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withLinks.js.map +0 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withLinks.mjs +0 -73
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withLinks.mjs.map +0 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/links.js +0 -88
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/links.js.map +0 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/links.mjs +0 -84
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/links.mjs.map +0 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withImages.d.ts +0 -11
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withLinks.d.ts +0 -9
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/links.d.ts +0 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Editor.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/Wysiwyg/Editor.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport CodeMirror, { EditorFromTextArea } from 'codemirror5';\nimport { styled } from 'styled-components';\n\nimport { PreviewWysiwyg } from './PreviewWysiwyg';\nimport { newlineAndIndentContinueMarkdownList } from './utils/continueList';\n\nimport type { FieldValue, InputProps } from '@strapi/admin/strapi-admin';\n\nimport 'codemirror5/addon/display/placeholder';\n\ninterface EditorApi {\n focus: () => void;\n scrollIntoView: (args?: Parameters<HTMLElement['scrollIntoView']>[0]) => void;\n}\n\ninterface EditorProps extends Omit<FieldValue, 'initialValue'>, Omit<InputProps, 'type' | 'label'> {\n editorRef: React.MutableRefObject<EditorFromTextArea>;\n isPreviewMode?: boolean;\n isExpandMode?: boolean;\n textareaRef: React.RefObject<HTMLTextAreaElement>;\n}\n\nconst Editor = React.forwardRef<EditorApi, EditorProps>(\n (\n {\n disabled,\n editorRef,\n error,\n isPreviewMode,\n isExpandMode,\n name,\n onChange,\n placeholder,\n textareaRef,\n value,\n },\n forwardedRef\n ) => {\n const onChangeRef = React.useRef(onChange);\n\n React.useEffect(() => {\n if (editorRef.current) {\n // Ensure the editor and its wrapper are cleaned up whenever this view is re-rendered\n // e.g. in case of re-ordering wysiwyg components in a DynamicZone\n editorRef.current.toTextArea();\n }\n editorRef.current = CodeMirror.fromTextArea(textareaRef.current!, {\n lineWrapping: true,\n extraKeys: {\n Enter: 'newlineAndIndentContinueMarkdownList',\n Tab: false,\n 'Shift-Tab': false,\n },\n readOnly: false,\n smartIndent: false,\n placeholder,\n spellcheck: true,\n inputStyle: 'contenteditable',\n });\n\n // @ts-expect-error – doesn't think command exists?\n CodeMirror.commands.newlineAndIndentContinueMarkdownList =\n newlineAndIndentContinueMarkdownList;\n editorRef.current.on('change', (doc) => {\n onChangeRef.current(name, doc.getValue());\n });\n }, [editorRef, textareaRef, name, placeholder]);\n\n React.useEffect(() => {\n if (value && !editorRef.current.hasFocus()) {\n editorRef.current.setValue(value);\n }\n }, [editorRef, value]);\n\n React.useEffect(() => {\n if (isPreviewMode || disabled) {\n editorRef.current.setOption('readOnly', 'nocursor');\n } else {\n editorRef.current.setOption('readOnly', false);\n }\n }, [disabled, isPreviewMode, editorRef]);\n\n React.useEffect(() => {\n if (error) {\n editorRef.current.setOption('screenReaderLabel', error);\n } else {\n // to replace with translation\n editorRef.current.setOption('screenReaderLabel', 'Editor');\n }\n }, [editorRef, error]);\n\n React.useImperativeHandle(\n forwardedRef,\n () => ({\n focus() {\n editorRef.current.getInputField().focus();\n },\n scrollIntoView(args?: Parameters<HTMLElement['scrollIntoView']>[0]) {\n editorRef.current.getInputField().scrollIntoView(args);\n },\n }),\n [editorRef]\n );\n\n return (\n <EditorAndPreviewWrapper>\n <EditorStylesContainer $isExpandMode={isExpandMode} $disabled={disabled || isPreviewMode}>\n <textarea ref={textareaRef} />\n </EditorStylesContainer>\n {isPreviewMode && <PreviewWysiwyg data={value} />}\n </EditorAndPreviewWrapper>\n );\n }\n);\n\nconst EditorAndPreviewWrapper = styled.div`\n position: relative;\n height: calc(100% - 48px);\n`;\n\nconst EditorStylesContainer = styled.div<{ $disabled?: boolean; $isExpandMode?: boolean }>`\n cursor: ${({ $disabled }) => ($disabled ? 'not-allowed !important' : 'auto')};\n height: 100%;\n /* BASICS */\n .CodeMirror-placeholder {\n color: ${({ theme }) => theme.colors.neutral600} !important;\n }\n\n .CodeMirror {\n /* Set height, width, borders, and global font properties here */\n font-size: 1.4rem;\n height: ${({ $isExpandMode }) =>\n $isExpandMode\n ? '100%'\n : '410px'}; // 512px(total height) - 48px (header) - 52px(footer) - 2px border\n color: ${({ theme }) => theme.colors.neutral800};\n direction: ltr;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,\n 'Open Sans', 'Helvetica Neue', sans-serif;\n }\n\n /* PADDING */\n\n .CodeMirror-lines {\n padding: ${({ theme }) => `${theme.spaces[3]} ${theme.spaces[4]}`};\n /* Vertical padding around content */\n }\n\n .CodeMirror-scrollbar-filler,\n .CodeMirror-gutter-filler {\n /* The little square between H and V scrollbars */\n background-color: ${({ theme }) => `${theme.colors.neutral0}`};\n }\n\n /* GUTTER */\n\n .CodeMirror-gutters {\n border-right: 1px solid #ddd;\n background-color: #f7f7f7;\n white-space: nowrap;\n }\n .CodeMirror-linenumbers {\n }\n .CodeMirror-linenumber {\n padding: 0 3px 0 5px;\n min-width: 20px;\n text-align: right;\n color: #999;\n white-space: nowrap;\n }\n\n .CodeMirror-guttermarker {\n color: black;\n }\n .CodeMirror-guttermarker-subtle {\n color: #999;\n }\n\n /* CURSOR */\n\n .CodeMirror-cursor {\n border-left: 1px solid black;\n border-right: none;\n width: 0;\n }\n /* Shown when moving in bi-directional text */\n .CodeMirror div.CodeMirror-secondarycursor {\n border-left: 1px solid silver;\n }\n .cm-fat-cursor .CodeMirror-cursor {\n width: auto;\n border: 0 !important;\n background: #7e7;\n }\n .cm-fat-cursor div.CodeMirror-cursors {\n /* z-index: 1; */\n }\n\n .cm-fat-cursor-mark {\n background-color: rgba(20, 255, 20, 0.5);\n -webkit-animation: blink 1.06s steps(1) infinite;\n -moz-animation: blink 1.06s steps(1) infinite;\n animation: blink 1.06s steps(1) infinite;\n }\n .cm-animate-fat-cursor {\n width: auto;\n border: 0;\n -webkit-animation: blink 1.06s steps(1) infinite;\n -moz-animation: blink 1.06s steps(1) infinite;\n animation: blink 1.06s steps(1) infinite;\n background-color: #7e7;\n }\n\n /* Can style cursor different in overwrite (non-insert) mode */\n .CodeMirror-overwrite .CodeMirror-cursor {\n }\n\n .cm-tab {\n display: inline-block;\n text-decoration: inherit;\n }\n\n .CodeMirror-rulers {\n position: absolute;\n left: 0;\n right: 0;\n top: -50px;\n bottom: 0;\n overflow: hidden;\n }\n .CodeMirror-ruler {\n border-left: 1px solid #ccc;\n top: 0;\n bottom: 0;\n position: absolute;\n }\n\n /* DEFAULT THEME */\n\n .cm-header,\n .cm-strong {\n font-weight: bold;\n }\n .cm-em {\n font-style: italic;\n }\n .cm-link {\n text-decoration: underline;\n }\n .cm-strikethrough {\n text-decoration: line-through;\n }\n\n .CodeMirror-composing {\n border-bottom: 2px solid;\n }\n\n /* Default styles for common addons */\n\n div.CodeMirror span.CodeMirror-matchingbracket {\n color: #0b0;\n }\n div.CodeMirror span.CodeMirror-nonmatchingbracket {\n color: #a22;\n }\n .CodeMirror-matchingtag {\n background: rgba(255, 150, 0, 0.3);\n }\n .CodeMirror-activeline-background {\n background: #e8f2ff;\n }\n\n /* STOP */\n\n /* The rest of this file contains styles related to the mechanics of\n the editor. You probably shouldn't touch them. */\n\n .CodeMirror {\n position: relative;\n overflow: hidden;\n background: ${({ theme }) => `${theme.colors.neutral0}`};\n }\n\n .CodeMirror-scroll {\n overflow: scroll !important; /* Things will break if this is overridden */\n /* 50px is the magic margin used to hide the element's real scrollbars */\n /* See overflow: hidden in .CodeMirror */\n margin-bottom: -50px;\n margin-right: -50px;\n padding-bottom: 50px;\n height: 100%;\n outline: none; /* Prevent dragging from highlighting the element */\n position: relative;\n }\n .CodeMirror-sizer {\n position: relative;\n border-right: 50px solid transparent;\n }\n\n /* The fake, visible scrollbars. Used to force redraw during scrolling\n before actual scrolling happens, thus preventing shaking and\n flickering artifacts. */\n .CodeMirror-vscrollbar,\n .CodeMirror-hscrollbar,\n .CodeMirror-scrollbar-filler,\n .CodeMirror-gutter-filler {\n position: absolute;\n z-index: 1;\n display: none;\n outline: none;\n }\n\n .CodeMirror-vscrollbar {\n right: 0;\n top: 0;\n overflow-x: hidden;\n overflow-y: scroll;\n }\n .CodeMirror-hscrollbar {\n bottom: 0;\n left: 0;\n overflow-y: hidden;\n overflow-x: scroll;\n }\n .CodeMirror-scrollbar-filler {\n right: 0;\n bottom: 0;\n }\n\n .CodeMirror-lines {\n cursor: text;\n min-height: 1px; /* prevents collapsing before first draw */\n }\n /* Reset some styles that the rest of the page might have set */\n .CodeMirror pre.CodeMirror-line,\n .CodeMirror pre.CodeMirror-line-like {\n -moz-border-radius: 0;\n -webkit-border-radius: 0;\n border-radius: 0;\n border-width: 0;\n background: transparent;\n font-family: inherit;\n font-size: inherit;\n margin: 0;\n white-space: pre;\n word-wrap: normal;\n line-height: 1.5;\n color: inherit;\n /* z-index: 2; */\n position: relative;\n overflow: visible;\n -webkit-tap-highlight-color: transparent;\n -webkit-font-variant-ligatures: contextual;\n font-variant-ligatures: contextual;\n }\n\n .CodeMirror pre.CodeMirror-line-like {\n z-index: 2;\n }\n\n .CodeMirror-wrap pre.CodeMirror-line,\n .CodeMirror-wrap pre.CodeMirror-line-like {\n word-wrap: break-word;\n white-space: pre-wrap;\n word-break: break-word;\n }\n\n .CodeMirror-linebackground {\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n z-index: 0;\n }\n\n .CodeMirror-linewidget {\n position: relative;\n /* z-index: 2; */\n padding: 0.1px; /* Force widget margins to stay inside of the container */\n }\n\n .CodeMirror-widget {\n }\n\n .CodeMirror-rtl pre {\n direction: rtl;\n }\n\n .CodeMirror-code {\n outline: none;\n }\n\n /* Force content-box sizing for the elements where we expect it */\n .CodeMirror-scroll,\n .CodeMirror-sizer,\n .CodeMirror-gutter,\n .CodeMirror-gutters,\n .CodeMirror-linenumber {\n -moz-box-sizing: content-box;\n box-sizing: content-box;\n }\n\n .CodeMirror-measure {\n position: absolute;\n width: 100%;\n height: 0;\n overflow: hidden;\n visibility: hidden;\n }\n\n .CodeMirror-cursor {\n position: absolute;\n pointer-events: none;\n border-color: ${({ theme }) => `${theme.colors.neutral800}`};\n }\n .CodeMirror-measure pre {\n position: static;\n }\n\n div.CodeMirror-cursors {\n visibility: hidden;\n position: relative;\n + div {\n z-index: 0 !important;\n }\n }\n\n div.CodeMirror-dragcursors {\n visibility: visible;\n }\n\n .CodeMirror-focused div.CodeMirror-cursors {\n visibility: visible;\n }\n\n .CodeMirror-selected {\n background: ${({ theme }) => theme.colors.neutral200};\n /* z-index: -10; */\n }\n .CodeMirror-crosshair {\n cursor: crosshair;\n }\n\n /* Used to force a border model for a node */\n .cm-force-border {\n padding-right: 0.1px;\n }\n\n /* See issue #2901 */\n .cm-tab-wrap-hack:after {\n content: '';\n }\n\n /* Help users use markselection to safely style text background */\n span.CodeMirror-selectedtext {\n background: none;\n }\n\n span {\n color: ${({ theme }) => theme.colors.neutral800} !important;\n }\n`;\n\nexport { Editor };\nexport type { EditorProps, EditorApi };\n"],"names":["Editor","React","forwardRef","disabled","editorRef","error","isPreviewMode","isExpandMode","name","onChange","placeholder","textareaRef","value","forwardedRef","onChangeRef","useRef","useEffect","current","toTextArea","CodeMirror","fromTextArea","lineWrapping","extraKeys","Enter","Tab","readOnly","smartIndent","spellcheck","inputStyle","commands","newlineAndIndentContinueMarkdownList","on","doc","getValue","hasFocus","setValue","setOption","useImperativeHandle","focus","getInputField","scrollIntoView","args","_jsxs","EditorAndPreviewWrapper","_jsx","EditorStylesContainer","$isExpandMode","$disabled","textarea","ref","PreviewWysiwyg","data","styled","div","theme","colors","neutral600","neutral800","spaces","neutral0","neutral200"],"mappings":";;;;;;;;AAwBMA,MAAAA,MAAAA,iBAASC,KAAMC,CAAAA,UAAU,CAC7B,CACE,EACEC,QAAQ,EACRC,SAAS,EACTC,KAAK,EACLC,aAAa,EACbC,YAAY,EACZC,IAAI,EACJC,QAAQ,EACRC,WAAW,EACXC,WAAW,EACXC,KAAK,EACN,EACDC,YAAAA,GAAAA;IAEA,MAAMC,WAAAA,GAAcb,KAAMc,CAAAA,MAAM,CAACN,QAAAA,CAAAA;AAEjCR,IAAAA,KAAAA,CAAMe,SAAS,CAAC,IAAA;QACd,IAAIZ,SAAAA,CAAUa,OAAO,EAAE;;;YAGrBb,SAAUa,CAAAA,OAAO,CAACC,UAAU,EAAA;AAC9B;AACAd,QAAAA,SAAAA,CAAUa,OAAO,GAAGE,UAAAA,CAAWC,YAAY,CAACT,WAAAA,CAAYM,OAAO,EAAG;YAChEI,YAAc,EAAA,IAAA;YACdC,SAAW,EAAA;gBACTC,KAAO,EAAA,sCAAA;gBACPC,GAAK,EAAA,KAAA;gBACL,WAAa,EAAA;AACf,aAAA;YACAC,QAAU,EAAA,KAAA;YACVC,WAAa,E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,"file":"Editor.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/Wysiwyg/Editor.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport CodeMirror, { EditorFromTextArea } from 'codemirror5';\nimport { styled } from 'styled-components';\n\nimport { PreviewWysiwyg } from './PreviewWysiwyg';\nimport { newlineAndIndentContinueMarkdownList } from './utils/continueList';\n\nimport type { FieldValue, InputProps } from '@strapi/admin/strapi-admin';\n\nimport 'codemirror5/addon/display/placeholder';\n\ninterface EditorApi {\n focus: () => void;\n scrollIntoView: (args?: Parameters<HTMLElement['scrollIntoView']>[0]) => void;\n}\n\ninterface EditorProps extends Omit<FieldValue, 'initialValue'>, Omit<InputProps, 'type' | 'label'> {\n editorRef: React.MutableRefObject<EditorFromTextArea>;\n isPreviewMode?: boolean;\n isExpandMode?: boolean;\n textareaRef: React.RefObject<HTMLTextAreaElement>;\n}\n\nconst Editor = React.forwardRef<EditorApi, EditorProps>(\n (\n {\n disabled,\n editorRef,\n error,\n isPreviewMode,\n isExpandMode,\n name,\n onChange,\n placeholder,\n textareaRef,\n value,\n },\n forwardedRef\n ) => {\n const onChangeRef = React.useRef(onChange);\n\n React.useEffect(() => {\n if (editorRef.current) {\n // Ensure the editor and its wrapper are cleaned up whenever this view is re-rendered\n // e.g. in case of re-ordering wysiwyg components in a DynamicZone\n editorRef.current.toTextArea();\n }\n editorRef.current = CodeMirror.fromTextArea(textareaRef.current!, {\n lineWrapping: true,\n extraKeys: {\n Enter: 'newlineAndIndentContinueMarkdownList',\n Tab: false,\n 'Shift-Tab': false,\n },\n readOnly: false,\n smartIndent: false,\n placeholder,\n spellcheck: true,\n inputStyle: 'contenteditable',\n });\n\n // @ts-expect-error – doesn't think command exists?\n CodeMirror.commands.newlineAndIndentContinueMarkdownList =\n newlineAndIndentContinueMarkdownList;\n editorRef.current.on('change', (doc) => {\n onChangeRef.current(name, doc.getValue());\n });\n }, [editorRef, textareaRef, name, placeholder]);\n\n React.useEffect(() => {\n if (value && !editorRef.current.hasFocus()) {\n editorRef.current.setValue(value);\n }\n }, [editorRef, value]);\n\n React.useEffect(() => {\n if (isPreviewMode || disabled) {\n editorRef.current.setOption('readOnly', 'nocursor');\n } else {\n editorRef.current.setOption('readOnly', false);\n }\n }, [disabled, isPreviewMode, editorRef]);\n\n React.useEffect(() => {\n if (error) {\n editorRef.current.setOption('screenReaderLabel', error);\n } else {\n // to replace with translation\n editorRef.current.setOption('screenReaderLabel', 'Editor');\n }\n }, [editorRef, error]);\n\n React.useImperativeHandle(\n forwardedRef,\n () => ({\n focus() {\n editorRef.current.getInputField().focus();\n },\n scrollIntoView(args?: Parameters<HTMLElement['scrollIntoView']>[0]) {\n editorRef.current.getInputField().scrollIntoView(args);\n },\n }),\n [editorRef]\n );\n\n return (\n <EditorAndPreviewWrapper>\n <EditorStylesContainer $isExpandMode={isExpandMode} $disabled={disabled || isPreviewMode}>\n <textarea ref={textareaRef} />\n </EditorStylesContainer>\n {isPreviewMode && <PreviewWysiwyg data={value} />}\n </EditorAndPreviewWrapper>\n );\n }\n);\n\nconst EditorAndPreviewWrapper = styled.div`\n position: relative;\n height: calc(100% - 48px);\n`;\n\nconst EditorStylesContainer = styled.div<{ $disabled?: boolean; $isExpandMode?: boolean }>`\n cursor: ${({ $disabled }) => ($disabled ? 'not-allowed !important' : 'auto')};\n height: 100%;\n /* BASICS */\n .CodeMirror-placeholder {\n color: ${({ theme }) => theme.colors.neutral600} !important;\n }\n\n .CodeMirror {\n /* Set height, width, borders, and global font properties here */\n font-size: 1.6rem;\n height: ${({ $isExpandMode }) =>\n $isExpandMode\n ? '100%'\n : '410px'}; // 512px(total height) - 48px (header) - 52px(footer) - 2px border\n color: ${({ theme }) => theme.colors.neutral800};\n direction: ltr;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,\n 'Open Sans', 'Helvetica Neue', sans-serif;\n\n ${({ theme }) => theme.breakpoints.medium} {\n font-size: 1.4rem;\n }\n }\n\n /* PADDING */\n\n .CodeMirror-lines {\n padding: ${({ theme }) => `${theme.spaces[3]} ${theme.spaces[4]}`};\n /* Vertical padding around content */\n }\n\n .CodeMirror-scrollbar-filler,\n .CodeMirror-gutter-filler {\n /* The little square between H and V scrollbars */\n background-color: ${({ theme }) => `${theme.colors.neutral0}`};\n }\n\n /* GUTTER */\n\n .CodeMirror-gutters {\n border-right: 1px solid #ddd;\n background-color: #f7f7f7;\n white-space: nowrap;\n }\n .CodeMirror-linenumbers {\n }\n .CodeMirror-linenumber {\n padding: 0 3px 0 5px;\n min-width: 20px;\n text-align: right;\n color: #999;\n white-space: nowrap;\n }\n\n .CodeMirror-guttermarker {\n color: black;\n }\n .CodeMirror-guttermarker-subtle {\n color: #999;\n }\n\n /* CURSOR */\n\n .CodeMirror-cursor {\n border-left: 1px solid black;\n border-right: none;\n width: 0;\n }\n /* Shown when moving in bi-directional text */\n .CodeMirror div.CodeMirror-secondarycursor {\n border-left: 1px solid silver;\n }\n .cm-fat-cursor .CodeMirror-cursor {\n width: auto;\n border: 0 !important;\n background: #7e7;\n }\n .cm-fat-cursor div.CodeMirror-cursors {\n /* z-index: 1; */\n }\n\n .cm-fat-cursor-mark {\n background-color: rgba(20, 255, 20, 0.5);\n -webkit-animation: blink 1.06s steps(1) infinite;\n -moz-animation: blink 1.06s steps(1) infinite;\n animation: blink 1.06s steps(1) infinite;\n }\n .cm-animate-fat-cursor {\n width: auto;\n border: 0;\n -webkit-animation: blink 1.06s steps(1) infinite;\n -moz-animation: blink 1.06s steps(1) infinite;\n animation: blink 1.06s steps(1) infinite;\n background-color: #7e7;\n }\n\n /* Can style cursor different in overwrite (non-insert) mode */\n .CodeMirror-overwrite .CodeMirror-cursor {\n }\n\n .cm-tab {\n display: inline-block;\n text-decoration: inherit;\n }\n\n .CodeMirror-rulers {\n position: absolute;\n left: 0;\n right: 0;\n top: -50px;\n bottom: 0;\n overflow: hidden;\n }\n .CodeMirror-ruler {\n border-left: 1px solid #ccc;\n top: 0;\n bottom: 0;\n position: absolute;\n }\n\n /* DEFAULT THEME */\n\n .cm-header,\n .cm-strong {\n font-weight: bold;\n }\n .cm-em {\n font-style: italic;\n }\n .cm-link {\n text-decoration: underline;\n }\n .cm-strikethrough {\n text-decoration: line-through;\n }\n\n .CodeMirror-composing {\n border-bottom: 2px solid;\n }\n\n /* Default styles for common addons */\n\n div.CodeMirror span.CodeMirror-matchingbracket {\n color: #0b0;\n }\n div.CodeMirror span.CodeMirror-nonmatchingbracket {\n color: #a22;\n }\n .CodeMirror-matchingtag {\n background: rgba(255, 150, 0, 0.3);\n }\n .CodeMirror-activeline-background {\n background: #e8f2ff;\n }\n\n /* STOP */\n\n /* The rest of this file contains styles related to the mechanics of\n the editor. You probably shouldn't touch them. */\n\n .CodeMirror {\n position: relative;\n overflow: hidden;\n background: ${({ theme }) => `${theme.colors.neutral0}`};\n }\n\n .CodeMirror-scroll {\n overflow: scroll !important; /* Things will break if this is overridden */\n /* 50px is the magic margin used to hide the element's real scrollbars */\n /* See overflow: hidden in .CodeMirror */\n margin-bottom: -50px;\n margin-right: -50px;\n padding-bottom: 50px;\n height: 100%;\n outline: none; /* Prevent dragging from highlighting the element */\n position: relative;\n }\n .CodeMirror-sizer {\n position: relative;\n border-right: 50px solid transparent;\n }\n\n /* The fake, visible scrollbars. Used to force redraw during scrolling\n before actual scrolling happens, thus preventing shaking and\n flickering artifacts. */\n .CodeMirror-vscrollbar,\n .CodeMirror-hscrollbar,\n .CodeMirror-scrollbar-filler,\n .CodeMirror-gutter-filler {\n position: absolute;\n z-index: 1;\n display: none;\n outline: none;\n }\n\n .CodeMirror-vscrollbar {\n right: 0;\n top: 0;\n overflow-x: hidden;\n overflow-y: scroll;\n }\n .CodeMirror-hscrollbar {\n bottom: 0;\n left: 0;\n overflow-y: hidden;\n overflow-x: scroll;\n }\n .CodeMirror-scrollbar-filler {\n right: 0;\n bottom: 0;\n }\n\n .CodeMirror-lines {\n cursor: text;\n min-height: 1px; /* prevents collapsing before first draw */\n }\n /* Reset some styles that the rest of the page might have set */\n .CodeMirror pre.CodeMirror-line,\n .CodeMirror pre.CodeMirror-line-like {\n -moz-border-radius: 0;\n -webkit-border-radius: 0;\n border-radius: 0;\n border-width: 0;\n background: transparent;\n font-family: inherit;\n font-size: inherit;\n margin: 0;\n white-space: pre;\n word-wrap: normal;\n line-height: 1.5;\n color: inherit;\n /* z-index: 2; */\n position: relative;\n overflow: visible;\n -webkit-tap-highlight-color: transparent;\n -webkit-font-variant-ligatures: contextual;\n font-variant-ligatures: contextual;\n }\n\n .CodeMirror pre.CodeMirror-line-like {\n z-index: 2;\n }\n\n .CodeMirror-wrap pre.CodeMirror-line,\n .CodeMirror-wrap pre.CodeMirror-line-like {\n word-wrap: break-word;\n white-space: pre-wrap;\n word-break: break-word;\n }\n\n .CodeMirror-linebackground {\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n z-index: 0;\n }\n\n .CodeMirror-linewidget {\n position: relative;\n /* z-index: 2; */\n padding: 0.1px; /* Force widget margins to stay inside of the container */\n }\n\n .CodeMirror-widget {\n }\n\n .CodeMirror-rtl pre {\n direction: rtl;\n }\n\n .CodeMirror-code {\n outline: none;\n }\n\n /* Force content-box sizing for the elements where we expect it */\n .CodeMirror-scroll,\n .CodeMirror-sizer,\n .CodeMirror-gutter,\n .CodeMirror-gutters,\n .CodeMirror-linenumber {\n -moz-box-sizing: content-box;\n box-sizing: content-box;\n }\n\n .CodeMirror-measure {\n position: absolute;\n width: 100%;\n height: 0;\n overflow: hidden;\n visibility: hidden;\n }\n\n .CodeMirror-cursor {\n position: absolute;\n pointer-events: none;\n border-color: ${({ theme }) => `${theme.colors.neutral800}`};\n }\n .CodeMirror-measure pre {\n position: static;\n }\n\n div.CodeMirror-cursors {\n visibility: hidden;\n position: relative;\n + div {\n z-index: 0 !important;\n }\n }\n\n div.CodeMirror-dragcursors {\n visibility: visible;\n }\n\n .CodeMirror-focused div.CodeMirror-cursors {\n visibility: visible;\n }\n\n .CodeMirror-selected {\n background: ${({ theme }) => theme.colors.neutral200};\n /* z-index: -10; */\n }\n .CodeMirror-crosshair {\n cursor: crosshair;\n }\n\n /* Used to force a border model for a node */\n .cm-force-border {\n padding-right: 0.1px;\n }\n\n /* See issue #2901 */\n .cm-tab-wrap-hack:after {\n content: '';\n }\n\n /* Help users use markselection to safely style text background */\n span.CodeMirror-selectedtext {\n background: none;\n }\n\n span {\n color: ${({ theme }) => theme.colors.neutral800} !important;\n }\n`;\n\nexport { Editor };\nexport type { EditorProps, EditorApi };\n"],"names":["Editor","React","forwardRef","disabled","editorRef","error","isPreviewMode","isExpandMode","name","onChange","placeholder","textareaRef","value","forwardedRef","onChangeRef","useRef","useEffect","current","toTextArea","CodeMirror","fromTextArea","lineWrapping","extraKeys","Enter","Tab","readOnly","smartIndent","spellcheck","inputStyle","commands","newlineAndIndentContinueMarkdownList","on","doc","getValue","hasFocus","setValue","setOption","useImperativeHandle","focus","getInputField","scrollIntoView","args","_jsxs","EditorAndPreviewWrapper","_jsx","EditorStylesContainer","$isExpandMode","$disabled","textarea","ref","PreviewWysiwyg","data","styled","div","theme","colors","neutral600","neutral800","breakpoints","medium","spaces","neutral0","neutral200"],"mappings":";;;;;;;;AAwBMA,MAAAA,MAAAA,iBAASC,KAAMC,CAAAA,UAAU,CAC7B,CACE,EACEC,QAAQ,EACRC,SAAS,EACTC,KAAK,EACLC,aAAa,EACbC,YAAY,EACZC,IAAI,EACJC,QAAQ,EACRC,WAAW,EACXC,WAAW,EACXC,KAAK,EACN,EACDC,YAAAA,GAAAA;IAEA,MAAMC,WAAAA,GAAcb,KAAMc,CAAAA,MAAM,CAACN,QAAAA,CAAAA;AAEjCR,IAAAA,KAAAA,CAAMe,SAAS,CAAC,IAAA;QACd,IAAIZ,SAAAA,CAAUa,OAAO,EAAE;;;YAGrBb,SAAUa,CAAAA,OAAO,CAACC,UAAU,EAAA;AAC9B;AACAd,QAAAA,SAAAA,CAAUa,OAAO,GAAGE,UAAA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,CAACE,UAAU,CAAA,CAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;gBAuBhD,EAAE,CAAC,EAAEH,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAACO,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;WAuB9C,EAAE,CAAC,EAAER,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAACE,UAAU,CAAC;;AAEpD,CAAC;;;;"}
|
|
@@ -11,6 +11,7 @@ var useDocumentLayout = require('../../../hooks/useDocumentLayout.js');
|
|
|
11
11
|
var useLazyComponents = require('../../../hooks/useLazyComponents.js');
|
|
12
12
|
var InputPopover = require('../../../preview/components/InputPopover.js');
|
|
13
13
|
var usePreviewInputManager = require('../../../preview/hooks/usePreviewInputManager.js');
|
|
14
|
+
var data = require('../utils/data.js');
|
|
14
15
|
var BlocksInput = require('./FormInputs/BlocksInput/BlocksInput.js');
|
|
15
16
|
var Input = require('./FormInputs/Component/Input.js');
|
|
16
17
|
var Field = require('./FormInputs/DynamicZone/Field.js');
|
|
@@ -146,7 +147,7 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
|
146
147
|
hint: hint,
|
|
147
148
|
layout: components[props.attribute.component].layout,
|
|
148
149
|
disabled: fieldIsDisabled,
|
|
149
|
-
children: (componentInputProps)=>/*#__PURE__*/ jsxRuntime.jsx(
|
|
150
|
+
children: (componentInputProps)=>/*#__PURE__*/ jsxRuntime.jsx(MemoizedInputRenderer, {
|
|
150
151
|
...componentInputProps
|
|
151
152
|
}, `input-${componentInputProps.name}-${localeKey}`)
|
|
152
153
|
}, `input-${props.name}-${localeKey}`);
|
|
@@ -211,7 +212,10 @@ const rulesEngine = strapiAdmin.createRulesEngine();
|
|
|
211
212
|
*/ const ConditionAwareInputRenderer = ({ condition, ...props })=>{
|
|
212
213
|
// Note: this selector causes a re-render every time any form value on the page changes
|
|
213
214
|
const fieldValues = strapiAdmin.useForm('ConditionalInputRenderer', (state)=>state.values);
|
|
214
|
-
|
|
215
|
+
// For nested fields, we evaluate against the parent scope so conditions can read siblings.
|
|
216
|
+
// Top-level fields resolve to the full form values.
|
|
217
|
+
const targetValues = data.getDirectParent(fieldValues, props.name);
|
|
218
|
+
const isVisible = rulesEngine.evaluate(condition, targetValues);
|
|
215
219
|
if (!isVisible) {
|
|
216
220
|
return null;
|
|
217
221
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputRenderer.js","sources":["../../../../../admin/src/pages/EditView/components/InputRenderer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useStrapiApp,\n useForm,\n InputRenderer as FormInputRenderer,\n useField,\n createRulesEngine,\n type JsonLogicCondition,\n} from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\n\nimport { SINGLE_TYPES } from '../../../constants/collections';\nimport { useDocumentRBAC } from '../../../features/DocumentRBAC';\nimport { type UseDocument } from '../../../hooks/useDocument';\nimport { useDocumentContext } from '../../../hooks/useDocumentContext';\nimport { useDocumentLayout } from '../../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../../hooks/useLazyComponents';\nimport { useHasInputPopoverParent } from '../../../preview/components/InputPopover';\nimport { usePreviewInputManager } from '../../../preview/hooks/usePreviewInputManager';\n\nimport { BlocksInput } from './FormInputs/BlocksInput/BlocksInput';\nimport { ComponentInput } from './FormInputs/Component/Input';\nimport { DynamicZone, useDynamicZone } from './FormInputs/DynamicZone/Field';\nimport { NotAllowedInput } from './FormInputs/NotAllowed';\nimport { RelationsInput } from './FormInputs/Relations/Relations';\nimport { UIDInput } from './FormInputs/UID';\nimport { Wysiwyg } from './FormInputs/Wysiwyg/Field';\n\nimport type { EditFieldLayout } from '../../../hooks/useDocumentLayout';\nimport type { Schema } from '@strapi/types';\nimport type { DistributiveOmit } from 'react-redux';\n\ntype InputRendererProps = DistributiveOmit<EditFieldLayout, 'size'> & {\n document: ReturnType<UseDocument>;\n};\n\n/**\n * @internal\n *\n * @description An abstraction around the regular form input renderer designed\n * specifically to be used in the EditView of the content-manager this understands\n * the complete EditFieldLayout and will handle RBAC conditions and rendering CM specific\n * components such as Blocks / Relations.\n */\nconst BaseInputRenderer = ({\n visible,\n hint: providedHint,\n document,\n ...inputProps\n}: InputRendererProps) => {\n const localeKey = document?.document?.locale || 'default';\n const { currentDocumentMeta } = useDocumentContext('DynamicComponent');\n const {\n edit: { components },\n } = useDocumentLayout(currentDocumentMeta.model);\n\n const collectionType =\n document.schema?.kind === 'collectionType' ? 'collection-types' : 'single-types';\n\n const isInDynamicZone = useDynamicZone('isInDynamicZone', (state) => state.isInDynamicZone);\n const isInPreviewPopover = useHasInputPopoverParent();\n const shouldIgnorePermissions = isInDynamicZone || isInPreviewPopover;\n\n const isFormDisabled = useForm('InputRenderer', (state) => state.disabled);\n const canCreateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canCreateFields);\n const canReadFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canReadFields);\n const canUpdateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUpdateFields);\n const canUserAction = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUserAction);\n\n let idToCheck = document.document?.documentId;\n if (collectionType === SINGLE_TYPES) {\n idToCheck = document?.document?.documentId;\n }\n\n const editableFields = idToCheck ? canUpdateFields : canCreateFields;\n const readableFields = idToCheck ? canReadFields : canCreateFields;\n\n // Everything preview related\n const previewProps = usePreviewInputManager(inputProps.name, inputProps.attribute);\n const props = { ...inputProps, ...previewProps };\n\n /**\n * Component fields are always readable and editable,\n * however the fields within them may not be.\n */\n const canUserReadField = canUserAction(props.name, readableFields, props.type);\n const canUserEditField = canUserAction(props.name, editableFields, props.type);\n\n const fields = useStrapiApp('InputRenderer', (app) => app.fields);\n const { lazyComponentStore } = useLazyComponents(\n attributeHasCustomFieldProperty(props.attribute) ? [props.attribute.customField] : undefined\n );\n\n const hint = useFieldHint(providedHint, props.attribute);\n\n // We pass field in case of Custom Fields to keep backward compatibility\n const field = useField(props.name);\n\n if (!visible) {\n return null;\n }\n\n /**\n * If the user can't read the field then we don't want to ever render it.\n */\n if (!canUserReadField && !shouldIgnorePermissions) {\n return <NotAllowedInput hint={hint} {...props} />;\n }\n\n const fieldIsDisabled =\n (!canUserEditField && !shouldIgnorePermissions) || props.disabled || isFormDisabled;\n\n /**\n * Because a custom field has a unique prop but the type could be confused with either\n * the useField hook or the type of the field we need to handle it separately and first.\n */\n if (attributeHasCustomFieldProperty(props.attribute)) {\n const CustomInput = lazyComponentStore[props.attribute.customField];\n\n if (CustomInput) {\n return (\n <CustomInput\n {...props}\n {...field}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n return (\n <FormInputRenderer\n key={`input-${props.name}-${localeKey}`}\n {...props}\n {...previewProps}\n hint={hint}\n // @ts-expect-error – this workaround lets us display that the custom field is missing.\n type={props.attribute.customField}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * This is where we handle ONLY the fields from the `useLibrary` hook.\n */\n const addedInputTypes = Object.keys(fields);\n if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {\n const CustomInput = fields[props.type];\n return (\n <CustomInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * These include the content-manager specific fields, failing that we fall back\n * to the more generic form input renderer.\n */\n switch (props.type) {\n case 'blocks':\n return (\n <BlocksInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n />\n );\n case 'component':\n return (\n <ComponentInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n layout={components[props.attribute.component].layout}\n disabled={fieldIsDisabled}\n >\n {(componentInputProps) => (\n <BaseInputRenderer\n key={`input-${componentInputProps.name}-${localeKey}`}\n {...componentInputProps}\n />\n )}\n </ComponentInput>\n );\n case 'dynamiczone':\n return (\n <DynamicZone\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n case 'relation':\n return (\n <RelationsInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n case 'richtext':\n return (\n <Wysiwyg\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n />\n );\n case 'uid':\n // These props are not needed for the generic form input renderer.\n const { unique: _uniqueUID, ...restUIDProps } = props;\n return (\n <UIDInput\n key={`input-${props.name}-${localeKey}`}\n {...restUIDProps}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n />\n );\n /**\n * Enumerations are a special case because they require options.\n */\n case 'enumeration':\n return (\n <FormInputRenderer\n key={`input-${props.name}-${localeKey}`}\n {...props}\n {...previewProps}\n hint={hint}\n options={props.attribute.enum.map((value) => ({ value }))}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n default:\n // These props are not needed for the generic form input renderer.\n const { unique: _unique, mainField: _mainField, ...restProps } = props;\n return (\n <FormInputRenderer\n key={`input-${props.name}-${localeKey}`}\n {...restProps}\n {...previewProps}\n hint={hint}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n }\n};\n\nconst rulesEngine = createRulesEngine();\n\n/**\n * A wrapper around BaseInputRenderer that conditionally renders it depending on the attribute's condition.\n */\nconst ConditionAwareInputRenderer = ({\n condition,\n ...props\n}: InputRendererProps & { condition: JsonLogicCondition }) => {\n // Note: this selector causes a re-render every time any form value on the page changes\n const fieldValues = useForm('ConditionalInputRenderer', (state) => state.values);\n const isVisible = rulesEngine.evaluate(condition, fieldValues);\n\n if (!isVisible) {\n return null;\n }\n\n return <BaseInputRenderer {...props} />;\n};\n\nconst attributeHasCustomFieldProperty = (\n attribute: Schema.Attribute.AnyAttribute\n): attribute is Schema.Attribute.AnyAttribute & Schema.Attribute.CustomField<string> =>\n 'customField' in attribute && typeof attribute.customField === 'string';\n\nconst useFieldHint = (\n hint: React.ReactNode = undefined,\n attribute: Schema.Attribute.AnyAttribute\n) => {\n const { formatMessage } = useIntl();\n\n const { maximum, minimum } = getMinMax(attribute);\n\n if (!maximum && !minimum) {\n return hint;\n }\n\n const units = ['string', 'uid', 'richtext', 'email', 'password', 'text'].includes(attribute.type)\n ? formatMessage(\n {\n id: 'content-manager.form.Input.hint.character.unit',\n defaultMessage: '{maxValue, plural, one { character} other { characters}}',\n },\n {\n maxValue: Math.max(minimum || 0, maximum || 0),\n }\n )\n : null;\n\n const hasMinAndMax = typeof minimum === 'number' && typeof maximum === 'number';\n\n return formatMessage(\n {\n id: 'content-manager.form.Input.hint.text',\n defaultMessage:\n '{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}',\n },\n {\n min: minimum,\n max: maximum,\n description: hint,\n unit: units,\n divider: hasMinAndMax\n ? formatMessage({\n id: 'content-manager.form.Input.hint.minMaxDivider',\n defaultMessage: ' / ',\n })\n : null,\n br: <br />,\n }\n );\n};\n\nconst getMinMax = (attribute: Schema.Attribute.AnyAttribute) => {\n if ('min' in attribute || 'max' in attribute) {\n return {\n maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : undefined,\n minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : undefined,\n };\n } else if ('maxLength' in attribute || 'minLength' in attribute) {\n return { maximum: attribute.maxLength, minimum: attribute.minLength };\n } else {\n return { maximum: undefined, minimum: undefined };\n }\n};\n\n/**\n * Conditionally routes the exported InputRender component towards ConditionalInputRenderer\n * (when there's a JSON logic condition on the attribute, or BaseInputRenderer otherwise.\n * We do this because rendering a conditional field requires access to the values of\n * other form fields, which causes many re-renders and performance issues on complex content\n * types. By splitting the component into two, we isolate the performance issue to\n * conditional fields only, not all edit view fields.\n */\nconst MemoizedInputRenderer = React.memo((props: InputRendererProps) => {\n const condition = props.attribute.conditions?.visible;\n if (condition) {\n return <ConditionAwareInputRenderer {...props} condition={condition} />;\n }\n\n return <BaseInputRenderer {...props} />;\n});\n\nexport type { InputRendererProps };\nexport { MemoizedInputRenderer as InputRenderer, useFieldHint };\n"],"names":["BaseInputRenderer","visible","hint","providedHint","document","inputProps","localeKey","locale","currentDocumentMeta","useDocumentContext","edit","components","useDocumentLayout","model","collectionType","schema","kind","isInDynamicZone","useDynamicZone","state","isInPreviewPopover","useHasInputPopoverParent","shouldIgnorePermissions","isFormDisabled","useForm","disabled","canCreateFields","useDocumentRBAC","rbac","canReadFields","canUpdateFields","canUserAction","idToCheck","documentId","SINGLE_TYPES","editableFields","readableFields","previewProps","usePreviewInputManager","name","attribute","props","canUserReadField","type","canUserEditField","fields","useStrapiApp","app","lazyComponentStore","useLazyComponents","attributeHasCustomFieldProperty","customField","undefined","useFieldHint","field","useField","_jsx","NotAllowedInput","fieldIsDisabled","CustomInput","FormInputRenderer","addedInputTypes","Object","keys","includes","BlocksInput","ComponentInput","layout","component","componentInputProps","DynamicZone","RelationsInput","Wysiwyg","unique","_uniqueUID","restUIDProps","UIDInput","options","enum","map","value","_unique","mainField","_mainField","restProps","rulesEngine","createRulesEngine","ConditionAwareInputRenderer","condition","fieldValues","values","isVisible","evaluate","formatMessage","useIntl","maximum","minimum","getMinMax","units","id","defaultMessage","maxValue","Math","max","hasMinAndMax","min","description","unit","divider","br","Number","isNaN","maxLength","minLength","MemoizedInputRenderer","React","memo","conditions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA;;;;;;;AAOC,IACD,MAAMA,iBAAAA,GAAoB,CAAC,EACzBC,OAAO,EACPC,IAAMC,EAAAA,YAAY,EAClBC,QAAQ,EACR,GAAGC,UACgB,EAAA,GAA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e,MAAOC,CAAAA,KAAK,CAACD,MAAAA,CAAOtE,SAAU+D,CAAAA,GAAG,CAAKO,CAAAA,GAAAA,MAAAA,CAAOtE,SAAU+D,CAAAA,GAAG,CAAInD,GAAAA,SAAAA;YACxE4C,OAAS,EAAA,CAACc,MAAOC,CAAAA,KAAK,CAACD,MAAAA,CAAOtE,SAAUiE,CAAAA,GAAG,CAAKK,CAAAA,GAAAA,MAAAA,CAAOtE,SAAUiE,CAAAA,GAAG,CAAIrD,GAAAA;AAC1E,SAAA;AACF,KAAA,MAAO,IAAI,WAAA,IAAeZ,SAAa,IAAA,WAAA,IAAeA,SAAW,EAAA;QAC/D,OAAO;AAAEuD,YAAAA,OAAAA,EAASvD,UAAUwE,SAAS;AAAEhB,YAAAA,OAAAA,EAASxD,UAAUyE;AAAU,SAAA;KAC/D,MAAA;QACL,OAAO;YAAElB,OAAS3C,EAAAA,SAAAA;YAAW4C,OAAS5C,EAAAA;AAAU,SAAA;AAClD;AACF,CAAA;AAEA;;;;;;;AAOC,IACK8D,MAAAA,qBAAAA,iBAAwBC,gBAAMC,CAAAA,IAAI,CAAC,CAAC3E,KAAAA,GAAAA;AACxC,IAAA,MAAM+C,SAAY/C,GAAAA,KAAAA,CAAMD,SAAS,CAAC6E,UAAU,EAAEpH,OAAAA;AAC9C,IAAA,IAAIuF,SAAW,EAAA;AACb,QAAA,qBAAOhC,cAAC+B,CAAAA,2BAAAA,EAAAA;AAA6B,YAAA,GAAG9C,KAAK;YAAE+C,SAAWA,EAAAA;;AAC5D;AAEA,IAAA,qBAAOhC,cAACxD,CAAAA,iBAAAA,EAAAA;AAAmB,QAAA,GAAGyC;;AAChC,CAAA;;;;;"}
|
|
1
|
+
{"version":3,"file":"InputRenderer.js","sources":["../../../../../admin/src/pages/EditView/components/InputRenderer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useStrapiApp,\n useForm,\n InputRenderer as FormInputRenderer,\n useField,\n createRulesEngine,\n type JsonLogicCondition,\n} from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\n\nimport { SINGLE_TYPES } from '../../../constants/collections';\nimport { useDocumentRBAC } from '../../../features/DocumentRBAC';\nimport { type UseDocument } from '../../../hooks/useDocument';\nimport { useDocumentContext } from '../../../hooks/useDocumentContext';\nimport { useDocumentLayout } from '../../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../../hooks/useLazyComponents';\nimport { useHasInputPopoverParent } from '../../../preview/components/InputPopover';\nimport { usePreviewInputManager } from '../../../preview/hooks/usePreviewInputManager';\nimport { getDirectParent } from '../utils/data';\n\nimport { BlocksInput } from './FormInputs/BlocksInput/BlocksInput';\nimport { ComponentInput } from './FormInputs/Component/Input';\nimport { DynamicZone, useDynamicZone } from './FormInputs/DynamicZone/Field';\nimport { NotAllowedInput } from './FormInputs/NotAllowed';\nimport { RelationsInput } from './FormInputs/Relations/Relations';\nimport { UIDInput } from './FormInputs/UID';\nimport { Wysiwyg } from './FormInputs/Wysiwyg/Field';\n\nimport type { EditFieldLayout } from '../../../hooks/useDocumentLayout';\nimport type { Schema } from '@strapi/types';\nimport type { DistributiveOmit } from 'react-redux';\n\ntype InputRendererProps = DistributiveOmit<EditFieldLayout, 'size'> & {\n document: ReturnType<UseDocument>;\n};\n\n/**\n * @internal\n *\n * @description An abstraction around the regular form input renderer designed\n * specifically to be used in the EditView of the content-manager this understands\n * the complete EditFieldLayout and will handle RBAC conditions and rendering CM specific\n * components such as Blocks / Relations.\n */\nconst BaseInputRenderer = ({\n visible,\n hint: providedHint,\n document,\n ...inputProps\n}: InputRendererProps) => {\n const localeKey = document?.document?.locale || 'default';\n const { currentDocumentMeta } = useDocumentContext('DynamicComponent');\n const {\n edit: { components },\n } = useDocumentLayout(currentDocumentMeta.model);\n\n const collectionType =\n document.schema?.kind === 'collectionType' ? 'collection-types' : 'single-types';\n\n const isInDynamicZone = useDynamicZone('isInDynamicZone', (state) => state.isInDynamicZone);\n const isInPreviewPopover = useHasInputPopoverParent();\n const shouldIgnorePermissions = isInDynamicZone || isInPreviewPopover;\n\n const isFormDisabled = useForm('InputRenderer', (state) => state.disabled);\n const canCreateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canCreateFields);\n const canReadFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canReadFields);\n const canUpdateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUpdateFields);\n const canUserAction = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUserAction);\n\n let idToCheck = document.document?.documentId;\n if (collectionType === SINGLE_TYPES) {\n idToCheck = document?.document?.documentId;\n }\n\n const editableFields = idToCheck ? canUpdateFields : canCreateFields;\n const readableFields = idToCheck ? canReadFields : canCreateFields;\n\n // Everything preview related\n const previewProps = usePreviewInputManager(inputProps.name, inputProps.attribute);\n const props = { ...inputProps, ...previewProps };\n\n /**\n * Component fields are always readable and editable,\n * however the fields within them may not be.\n */\n const canUserReadField = canUserAction(props.name, readableFields, props.type);\n const canUserEditField = canUserAction(props.name, editableFields, props.type);\n\n const fields = useStrapiApp('InputRenderer', (app) => app.fields);\n const { lazyComponentStore } = useLazyComponents(\n attributeHasCustomFieldProperty(props.attribute) ? [props.attribute.customField] : undefined\n );\n\n const hint = useFieldHint(providedHint, props.attribute);\n\n // We pass field in case of Custom Fields to keep backward compatibility\n const field = useField(props.name);\n\n if (!visible) {\n return null;\n }\n\n /**\n * If the user can't read the field then we don't want to ever render it.\n */\n if (!canUserReadField && !shouldIgnorePermissions) {\n return <NotAllowedInput hint={hint} {...props} />;\n }\n\n const fieldIsDisabled =\n (!canUserEditField && !shouldIgnorePermissions) || props.disabled || isFormDisabled;\n\n /**\n * Because a custom field has a unique prop but the type could be confused with either\n * the useField hook or the type of the field we need to handle it separately and first.\n */\n if (attributeHasCustomFieldProperty(props.attribute)) {\n const CustomInput = lazyComponentStore[props.attribute.customField];\n\n if (CustomInput) {\n return (\n <CustomInput\n {...props}\n {...field}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n return (\n <FormInputRenderer\n key={`input-${props.name}-${localeKey}`}\n {...props}\n {...previewProps}\n hint={hint}\n // @ts-expect-error – this workaround lets us display that the custom field is missing.\n type={props.attribute.customField}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * This is where we handle ONLY the fields from the `useLibrary` hook.\n */\n const addedInputTypes = Object.keys(fields);\n if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {\n const CustomInput = fields[props.type];\n return (\n <CustomInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * These include the content-manager specific fields, failing that we fall back\n * to the more generic form input renderer.\n */\n switch (props.type) {\n case 'blocks':\n return (\n <BlocksInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n />\n );\n case 'component':\n return (\n <ComponentInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n layout={components[props.attribute.component].layout}\n disabled={fieldIsDisabled}\n >\n {(componentInputProps) => (\n <MemoizedInputRenderer\n key={`input-${componentInputProps.name}-${localeKey}`}\n {...componentInputProps}\n />\n )}\n </ComponentInput>\n );\n case 'dynamiczone':\n return (\n <DynamicZone\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n case 'relation':\n return (\n <RelationsInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n case 'richtext':\n return (\n <Wysiwyg\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n />\n );\n case 'uid':\n // These props are not needed for the generic form input renderer.\n const { unique: _uniqueUID, ...restUIDProps } = props;\n return (\n <UIDInput\n key={`input-${props.name}-${localeKey}`}\n {...restUIDProps}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n />\n );\n /**\n * Enumerations are a special case because they require options.\n */\n case 'enumeration':\n return (\n <FormInputRenderer\n key={`input-${props.name}-${localeKey}`}\n {...props}\n {...previewProps}\n hint={hint}\n options={props.attribute.enum.map((value) => ({ value }))}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n default:\n // These props are not needed for the generic form input renderer.\n const { unique: _unique, mainField: _mainField, ...restProps } = props;\n return (\n <FormInputRenderer\n key={`input-${props.name}-${localeKey}`}\n {...restProps}\n {...previewProps}\n hint={hint}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n }\n};\n\nconst rulesEngine = createRulesEngine();\n\n/**\n * A wrapper around BaseInputRenderer that conditionally renders it depending on the attribute's condition.\n */\nconst ConditionAwareInputRenderer = ({\n condition,\n ...props\n}: InputRendererProps & { condition: JsonLogicCondition }) => {\n // Note: this selector causes a re-render every time any form value on the page changes\n const fieldValues = useForm('ConditionalInputRenderer', (state) => state.values);\n // For nested fields, we evaluate against the parent scope so conditions can read siblings.\n // Top-level fields resolve to the full form values.\n const targetValues = getDirectParent(fieldValues, props.name);\n\n const isVisible = rulesEngine.evaluate(condition, targetValues);\n\n if (!isVisible) {\n return null;\n }\n\n return <BaseInputRenderer {...props} />;\n};\n\nconst attributeHasCustomFieldProperty = (\n attribute: Schema.Attribute.AnyAttribute\n): attribute is Schema.Attribute.AnyAttribute & Schema.Attribute.CustomField<string> =>\n 'customField' in attribute && typeof attribute.customField === 'string';\n\nconst useFieldHint = (\n hint: React.ReactNode = undefined,\n attribute: Schema.Attribute.AnyAttribute\n) => {\n const { formatMessage } = useIntl();\n\n const { maximum, minimum } = getMinMax(attribute);\n\n if (!maximum && !minimum) {\n return hint;\n }\n\n const units = ['string', 'uid', 'richtext', 'email', 'password', 'text'].includes(attribute.type)\n ? formatMessage(\n {\n id: 'content-manager.form.Input.hint.character.unit',\n defaultMessage: '{maxValue, plural, one { character} other { characters}}',\n },\n {\n maxValue: Math.max(minimum || 0, maximum || 0),\n }\n )\n : null;\n\n const hasMinAndMax = typeof minimum === 'number' && typeof maximum === 'number';\n\n return formatMessage(\n {\n id: 'content-manager.form.Input.hint.text',\n defaultMessage:\n '{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}',\n },\n {\n min: minimum,\n max: maximum,\n description: hint,\n unit: units,\n divider: hasMinAndMax\n ? formatMessage({\n id: 'content-manager.form.Input.hint.minMaxDivider',\n defaultMessage: ' / ',\n })\n : null,\n br: <br />,\n }\n );\n};\n\nconst getMinMax = (attribute: Schema.Attribute.AnyAttribute) => {\n if ('min' in attribute || 'max' in attribute) {\n return {\n maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : undefined,\n minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : undefined,\n };\n } else if ('maxLength' in attribute || 'minLength' in attribute) {\n return { maximum: attribute.maxLength, minimum: attribute.minLength };\n } else {\n return { maximum: undefined, minimum: undefined };\n }\n};\n\n/**\n * Conditionally routes the exported InputRender component towards ConditionalInputRenderer\n * (when there's a JSON logic condition on the attribute, or BaseInputRenderer otherwise.\n * We do this because rendering a conditional field requires access to the values of\n * other form fields, which causes many re-renders and performance issues on complex content\n * types. By splitting the component into two, we isolate the performance issue to\n * conditional fields only, not all edit view fields.\n */\nconst MemoizedInputRenderer = React.memo((props: InputRendererProps) => {\n const condition = props.attribute.conditions?.visible;\n if (condition) {\n return <ConditionAwareInputRenderer {...props} condition={condition} />;\n }\n\n return <BaseInputRenderer {...props} />;\n});\n\nexport type { InputRendererProps };\nexport { MemoizedInputRenderer as InputRenderer, useFieldHint };\n"],"names":["BaseInputRenderer","visible","hint","providedHint","document","inputProps","localeKey","locale","currentDocumentMeta","useDocumentContext","edit","components","useDocumentLayout","model","collectionType","schema","kind","isInDynamicZone","useDynamicZone","state","isInPreviewPopover","useHasInputPopoverParent","shouldIgnorePermissions","isFormDisabled","useForm","disabled","canCreateFields","useDocumentRBAC","rbac","canReadFields","canUpdateFields","canUserAction","idToCheck","documentId","SINGLE_TYPES","editableFields","readableFields","previewProps","usePreviewInputManager","name","attribute","props","canUserReadField","type","canUserEditField","fields","useStrapiApp","app","lazyComponentStore","useLazyComponents","attributeHasCustomFieldProperty","customField","undefined","useFieldHint","field","useField","_jsx","NotAllowedInput","fieldIsDisabled","CustomInput","FormInputRenderer","addedInputTypes","Object","keys","includes","BlocksInput","ComponentInput","layout","component","componentInputProps","MemoizedInputRenderer","DynamicZone","RelationsInput","Wysiwyg","unique","_uniqueUID","restUIDProps","UIDInput","options","enum","map","value","_unique","mainField","_mainField","restProps","rulesEngine","createRulesEngine","ConditionAwareInputRenderer","condition","fieldValues","values","targetValues","getDirectParent","isVisible","evaluate","formatMessage","useIntl","maximum","minimum","getMinMax","units","id","defaultMessage","maxValue","Math","max","hasMinAndMax","min","description","unit","divider","br","Number","isNaN","maxLength","minLength","React","memo","conditions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA;;;;;;;AAOC,IACD,MAAMA,iBAAAA,GAAoB,CAAC,EACzBC,OAAO,EACPC,IAAMC,EAAAA,YAAY,EAClBC,QAAQ,EACR,GAAGC,UACgB,EAAA,GAAA;IACnB,MAAMC,SAAAA,GAAYF,QAAUA,EAAAA,QAAAA,EAAUG,MAAU,IAAA,SAAA;AAChD,IAAA,MAAM,EAAEC,mBAAmB,EAAE,GAAGC,qCAAmB,CAAA,kBAAA,CAAA;IACnD,MAAM,EACJC,MAAM,EAAEC,UAAU,EAAE,EACrB,GAAGC,mCAAkBJ,CAAAA,mBAAAA,CAAoBK,KAAK,CAAA;AAE/C,IAAA,MAAMC,iBACJV,QAASW,CAAAA,MAAM,EAAEC,IAAAA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oE,CAAAA,GAAG,CAAKK,CAAAA,GAAAA,MAAAA,CAAOzE,SAAUoE,CAAAA,GAAG,CAAIxD,GAAAA;AAC1E,SAAA;AACF,KAAA,MAAO,IAAI,WAAA,IAAeZ,SAAa,IAAA,WAAA,IAAeA,SAAW,EAAA;QAC/D,OAAO;AAAE0D,YAAAA,OAAAA,EAAS1D,UAAU2E,SAAS;AAAEhB,YAAAA,OAAAA,EAAS3D,UAAU4E;AAAU,SAAA;KAC/D,MAAA;QACL,OAAO;YAAElB,OAAS9C,EAAAA,SAAAA;YAAW+C,OAAS/C,EAAAA;AAAU,SAAA;AAClD;AACF,CAAA;AAEA;;;;;;;AAOC,IACKkB,MAAAA,qBAAAA,iBAAwB+C,gBAAMC,CAAAA,IAAI,CAAC,CAAC7E,KAAAA,GAAAA;AACxC,IAAA,MAAMgD,SAAYhD,GAAAA,KAAAA,CAAMD,SAAS,CAAC+E,UAAU,EAAEtH,OAAAA;AAC9C,IAAA,IAAIwF,SAAW,EAAA;AACb,QAAA,qBAAOjC,cAACgC,CAAAA,2BAAAA,EAAAA;AAA6B,YAAA,GAAG/C,KAAK;YAAEgD,SAAWA,EAAAA;;AAC5D;AAEA,IAAA,qBAAOjC,cAACxD,CAAAA,iBAAAA,EAAAA;AAAmB,QAAA,GAAGyC;;AAChC,CAAA;;;;;"}
|
|
@@ -9,6 +9,7 @@ import { useDocumentLayout } from '../../../hooks/useDocumentLayout.mjs';
|
|
|
9
9
|
import { useLazyComponents } from '../../../hooks/useLazyComponents.mjs';
|
|
10
10
|
import { useHasInputPopoverParent } from '../../../preview/components/InputPopover.mjs';
|
|
11
11
|
import { usePreviewInputManager } from '../../../preview/hooks/usePreviewInputManager.mjs';
|
|
12
|
+
import { getDirectParent } from '../utils/data.mjs';
|
|
12
13
|
import { BlocksInput as MemoizedBlocksInput } from './FormInputs/BlocksInput/BlocksInput.mjs';
|
|
13
14
|
import { ComponentInput as MemoizedComponentInput } from './FormInputs/Component/Input.mjs';
|
|
14
15
|
import { useDynamicZone, DynamicZone } from './FormInputs/DynamicZone/Field.mjs';
|
|
@@ -125,7 +126,7 @@ import { Wysiwyg as MemoizedWysiwyg } from './FormInputs/Wysiwyg/Field.mjs';
|
|
|
125
126
|
hint: hint,
|
|
126
127
|
layout: components[props.attribute.component].layout,
|
|
127
128
|
disabled: fieldIsDisabled,
|
|
128
|
-
children: (componentInputProps)=>/*#__PURE__*/ jsx(
|
|
129
|
+
children: (componentInputProps)=>/*#__PURE__*/ jsx(MemoizedInputRenderer, {
|
|
129
130
|
...componentInputProps
|
|
130
131
|
}, `input-${componentInputProps.name}-${localeKey}`)
|
|
131
132
|
}, `input-${props.name}-${localeKey}`);
|
|
@@ -190,7 +191,10 @@ const rulesEngine = createRulesEngine();
|
|
|
190
191
|
*/ const ConditionAwareInputRenderer = ({ condition, ...props })=>{
|
|
191
192
|
// Note: this selector causes a re-render every time any form value on the page changes
|
|
192
193
|
const fieldValues = useForm('ConditionalInputRenderer', (state)=>state.values);
|
|
193
|
-
|
|
194
|
+
// For nested fields, we evaluate against the parent scope so conditions can read siblings.
|
|
195
|
+
// Top-level fields resolve to the full form values.
|
|
196
|
+
const targetValues = getDirectParent(fieldValues, props.name);
|
|
197
|
+
const isVisible = rulesEngine.evaluate(condition, targetValues);
|
|
194
198
|
if (!isVisible) {
|
|
195
199
|
return null;
|
|
196
200
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputRenderer.mjs","sources":["../../../../../admin/src/pages/EditView/components/InputRenderer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useStrapiApp,\n useForm,\n InputRenderer as FormInputRenderer,\n useField,\n createRulesEngine,\n type JsonLogicCondition,\n} from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\n\nimport { SINGLE_TYPES } from '../../../constants/collections';\nimport { useDocumentRBAC } from '../../../features/DocumentRBAC';\nimport { type UseDocument } from '../../../hooks/useDocument';\nimport { useDocumentContext } from '../../../hooks/useDocumentContext';\nimport { useDocumentLayout } from '../../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../../hooks/useLazyComponents';\nimport { useHasInputPopoverParent } from '../../../preview/components/InputPopover';\nimport { usePreviewInputManager } from '../../../preview/hooks/usePreviewInputManager';\n\nimport { BlocksInput } from './FormInputs/BlocksInput/BlocksInput';\nimport { ComponentInput } from './FormInputs/Component/Input';\nimport { DynamicZone, useDynamicZone } from './FormInputs/DynamicZone/Field';\nimport { NotAllowedInput } from './FormInputs/NotAllowed';\nimport { RelationsInput } from './FormInputs/Relations/Relations';\nimport { UIDInput } from './FormInputs/UID';\nimport { Wysiwyg } from './FormInputs/Wysiwyg/Field';\n\nimport type { EditFieldLayout } from '../../../hooks/useDocumentLayout';\nimport type { Schema } from '@strapi/types';\nimport type { DistributiveOmit } from 'react-redux';\n\ntype InputRendererProps = DistributiveOmit<EditFieldLayout, 'size'> & {\n document: ReturnType<UseDocument>;\n};\n\n/**\n * @internal\n *\n * @description An abstraction around the regular form input renderer designed\n * specifically to be used in the EditView of the content-manager this understands\n * the complete EditFieldLayout and will handle RBAC conditions and rendering CM specific\n * components such as Blocks / Relations.\n */\nconst BaseInputRenderer = ({\n visible,\n hint: providedHint,\n document,\n ...inputProps\n}: InputRendererProps) => {\n const localeKey = document?.document?.locale || 'default';\n const { currentDocumentMeta } = useDocumentContext('DynamicComponent');\n const {\n edit: { components },\n } = useDocumentLayout(currentDocumentMeta.model);\n\n const collectionType =\n document.schema?.kind === 'collectionType' ? 'collection-types' : 'single-types';\n\n const isInDynamicZone = useDynamicZone('isInDynamicZone', (state) => state.isInDynamicZone);\n const isInPreviewPopover = useHasInputPopoverParent();\n const shouldIgnorePermissions = isInDynamicZone || isInPreviewPopover;\n\n const isFormDisabled = useForm('InputRenderer', (state) => state.disabled);\n const canCreateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canCreateFields);\n const canReadFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canReadFields);\n const canUpdateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUpdateFields);\n const canUserAction = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUserAction);\n\n let idToCheck = document.document?.documentId;\n if (collectionType === SINGLE_TYPES) {\n idToCheck = document?.document?.documentId;\n }\n\n const editableFields = idToCheck ? canUpdateFields : canCreateFields;\n const readableFields = idToCheck ? canReadFields : canCreateFields;\n\n // Everything preview related\n const previewProps = usePreviewInputManager(inputProps.name, inputProps.attribute);\n const props = { ...inputProps, ...previewProps };\n\n /**\n * Component fields are always readable and editable,\n * however the fields within them may not be.\n */\n const canUserReadField = canUserAction(props.name, readableFields, props.type);\n const canUserEditField = canUserAction(props.name, editableFields, props.type);\n\n const fields = useStrapiApp('InputRenderer', (app) => app.fields);\n const { lazyComponentStore } = useLazyComponents(\n attributeHasCustomFieldProperty(props.attribute) ? [props.attribute.customField] : undefined\n );\n\n const hint = useFieldHint(providedHint, props.attribute);\n\n // We pass field in case of Custom Fields to keep backward compatibility\n const field = useField(props.name);\n\n if (!visible) {\n return null;\n }\n\n /**\n * If the user can't read the field then we don't want to ever render it.\n */\n if (!canUserReadField && !shouldIgnorePermissions) {\n return <NotAllowedInput hint={hint} {...props} />;\n }\n\n const fieldIsDisabled =\n (!canUserEditField && !shouldIgnorePermissions) || props.disabled || isFormDisabled;\n\n /**\n * Because a custom field has a unique prop but the type could be confused with either\n * the useField hook or the type of the field we need to handle it separately and first.\n */\n if (attributeHasCustomFieldProperty(props.attribute)) {\n const CustomInput = lazyComponentStore[props.attribute.customField];\n\n if (CustomInput) {\n return (\n <CustomInput\n {...props}\n {...field}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n return (\n <FormInputRenderer\n key={`input-${props.name}-${localeKey}`}\n {...props}\n {...previewProps}\n hint={hint}\n // @ts-expect-error – this workaround lets us display that the custom field is missing.\n type={props.attribute.customField}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * This is where we handle ONLY the fields from the `useLibrary` hook.\n */\n const addedInputTypes = Object.keys(fields);\n if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {\n const CustomInput = fields[props.type];\n return (\n <CustomInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * These include the content-manager specific fields, failing that we fall back\n * to the more generic form input renderer.\n */\n switch (props.type) {\n case 'blocks':\n return (\n <BlocksInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n />\n );\n case 'component':\n return (\n <ComponentInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n layout={components[props.attribute.component].layout}\n disabled={fieldIsDisabled}\n >\n {(componentInputProps) => (\n <BaseInputRenderer\n key={`input-${componentInputProps.name}-${localeKey}`}\n {...componentInputProps}\n />\n )}\n </ComponentInput>\n );\n case 'dynamiczone':\n return (\n <DynamicZone\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n case 'relation':\n return (\n <RelationsInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n case 'richtext':\n return (\n <Wysiwyg\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n />\n );\n case 'uid':\n // These props are not needed for the generic form input renderer.\n const { unique: _uniqueUID, ...restUIDProps } = props;\n return (\n <UIDInput\n key={`input-${props.name}-${localeKey}`}\n {...restUIDProps}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n />\n );\n /**\n * Enumerations are a special case because they require options.\n */\n case 'enumeration':\n return (\n <FormInputRenderer\n key={`input-${props.name}-${localeKey}`}\n {...props}\n {...previewProps}\n hint={hint}\n options={props.attribute.enum.map((value) => ({ value }))}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n default:\n // These props are not needed for the generic form input renderer.\n const { unique: _unique, mainField: _mainField, ...restProps } = props;\n return (\n <FormInputRenderer\n key={`input-${props.name}-${localeKey}`}\n {...restProps}\n {...previewProps}\n hint={hint}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n }\n};\n\nconst rulesEngine = createRulesEngine();\n\n/**\n * A wrapper around BaseInputRenderer that conditionally renders it depending on the attribute's condition.\n */\nconst ConditionAwareInputRenderer = ({\n condition,\n ...props\n}: InputRendererProps & { condition: JsonLogicCondition }) => {\n // Note: this selector causes a re-render every time any form value on the page changes\n const fieldValues = useForm('ConditionalInputRenderer', (state) => state.values);\n const isVisible = rulesEngine.evaluate(condition, fieldValues);\n\n if (!isVisible) {\n return null;\n }\n\n return <BaseInputRenderer {...props} />;\n};\n\nconst attributeHasCustomFieldProperty = (\n attribute: Schema.Attribute.AnyAttribute\n): attribute is Schema.Attribute.AnyAttribute & Schema.Attribute.CustomField<string> =>\n 'customField' in attribute && typeof attribute.customField === 'string';\n\nconst useFieldHint = (\n hint: React.ReactNode = undefined,\n attribute: Schema.Attribute.AnyAttribute\n) => {\n const { formatMessage } = useIntl();\n\n const { maximum, minimum } = getMinMax(attribute);\n\n if (!maximum && !minimum) {\n return hint;\n }\n\n const units = ['string', 'uid', 'richtext', 'email', 'password', 'text'].includes(attribute.type)\n ? formatMessage(\n {\n id: 'content-manager.form.Input.hint.character.unit',\n defaultMessage: '{maxValue, plural, one { character} other { characters}}',\n },\n {\n maxValue: Math.max(minimum || 0, maximum || 0),\n }\n )\n : null;\n\n const hasMinAndMax = typeof minimum === 'number' && typeof maximum === 'number';\n\n return formatMessage(\n {\n id: 'content-manager.form.Input.hint.text',\n defaultMessage:\n '{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}',\n },\n {\n min: minimum,\n max: maximum,\n description: hint,\n unit: units,\n divider: hasMinAndMax\n ? formatMessage({\n id: 'content-manager.form.Input.hint.minMaxDivider',\n defaultMessage: ' / ',\n })\n : null,\n br: <br />,\n }\n );\n};\n\nconst getMinMax = (attribute: Schema.Attribute.AnyAttribute) => {\n if ('min' in attribute || 'max' in attribute) {\n return {\n maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : undefined,\n minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : undefined,\n };\n } else if ('maxLength' in attribute || 'minLength' in attribute) {\n return { maximum: attribute.maxLength, minimum: attribute.minLength };\n } else {\n return { maximum: undefined, minimum: undefined };\n }\n};\n\n/**\n * Conditionally routes the exported InputRender component towards ConditionalInputRenderer\n * (when there's a JSON logic condition on the attribute, or BaseInputRenderer otherwise.\n * We do this because rendering a conditional field requires access to the values of\n * other form fields, which causes many re-renders and performance issues on complex content\n * types. By splitting the component into two, we isolate the performance issue to\n * conditional fields only, not all edit view fields.\n */\nconst MemoizedInputRenderer = React.memo((props: InputRendererProps) => {\n const condition = props.attribute.conditions?.visible;\n if (condition) {\n return <ConditionAwareInputRenderer {...props} condition={condition} />;\n }\n\n return <BaseInputRenderer {...props} />;\n});\n\nexport type { InputRendererProps };\nexport { MemoizedInputRenderer as InputRenderer, useFieldHint };\n"],"names":["BaseInputRenderer","visible","hint","providedHint","document","inputProps","localeKey","locale","currentDocumentMeta","useDocumentContext","edit","components","useDocumentLayout","model","collectionType","schema","kind","isInDynamicZone","useDynamicZone","state","isInPreviewPopover","useHasInputPopoverParent","shouldIgnorePermissions","isFormDisabled","useForm","disabled","canCreateFields","useDocumentRBAC","rbac","canReadFields","canUpdateFields","canUserAction","idToCheck","documentId","SINGLE_TYPES","editableFields","readableFields","previewProps","usePreviewInputManager","name","attribute","props","canUserReadField","type","canUserEditField","fields","useStrapiApp","app","lazyComponentStore","useLazyComponents","attributeHasCustomFieldProperty","customField","undefined","useFieldHint","field","useField","_jsx","NotAllowedInput","fieldIsDisabled","CustomInput","FormInputRenderer","addedInputTypes","Object","keys","includes","BlocksInput","ComponentInput","layout","component","componentInputProps","DynamicZone","RelationsInput","Wysiwyg","unique","_uniqueUID","restUIDProps","UIDInput","options","enum","map","value","_unique","mainField","_mainField","restProps","rulesEngine","createRulesEngine","ConditionAwareInputRenderer","condition","fieldValues","values","isVisible","evaluate","formatMessage","useIntl","maximum","minimum","getMinMax","units","id","defaultMessage","maxValue","Math","max","hasMinAndMax","min","description","unit","divider","br","Number","isNaN","maxLength","minLength","MemoizedInputRenderer","React","memo","conditions"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA;;;;;;;AAOC,IACD,MAAMA,iBAAAA,GAAoB,CAAC,EACzBC,OAAO,EACPC,IAAMC,EAAAA,YAAY,EAClBC,QAAQ,EACR,GAAGC,UACgB,EAAA,GAAA;IACnB,MAAMC,SAAAA,GAAYF,QAAUA,EAAAA,QAAAA,EAAUG,MAAU,IAAA,SAAA;AAChD,IAAA,MAAM,EAAEC,mBAAmB,EAAE,GAAGC,kBAAmB,CAAA,kBAAA,CAAA;IACnD,MAAM,EACJC,MAAM,EAAEC,UAAU,EAAE,EACrB,GAAGC,iBAAkBJ,CAAAA,mBAAAA,CAAoBK,KAAK,CAAA;AAE/C,IAAA,MAAMC,iBACJV,QAASW,CAAAA,MAAM,EAAEC,IAAAA,KAAS,mBAAmB,kBAAqB,GAAA,cAAA;AAEpE,IAAA,MAAMC,kBAAkBC,cAAe,CAAA,iBAAA,EAAmB,CAACC,KAAAA,GAAUA,MAAMF,eAAe,CAAA;AAC1F,IAAA,MAAMG,kBAAqBC,GAAAA,wBAAAA,EAAAA;AAC3B,IAAA,MAAMC,0BAA0BL,eAAmBG,IAAAA,kBAAAA;AAEnD,IAAA,MAAMG,iBAAiBC,OAAQ,CAAA,eAAA,EAAiB,CAACL,KAAAA,GAAUA,MAAMM,QAAQ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BC,KAAMC,CAAAA,IAAI,CAAC,CAAC3E,KAAAA,GAAAA;AACxC,IAAA,MAAM+C,SAAY/C,GAAAA,KAAAA,CAAMD,SAAS,CAAC6E,UAAU,EAAEpH,OAAAA;AAC9C,IAAA,IAAIuF,SAAW,EAAA;AACb,QAAA,qBAAOhC,GAAC+B,CAAAA,2BAAAA,EAAAA;AAA6B,YAAA,GAAG9C,KAAK;YAAE+C,SAAWA,EAAAA;;AAC5D;AAEA,IAAA,qBAAOhC,GAACxD,CAAAA,iBAAAA,EAAAA;AAAmB,QAAA,GAAGyC;;AAChC,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"InputRenderer.mjs","sources":["../../../../../admin/src/pages/EditView/components/InputRenderer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useStrapiApp,\n useForm,\n InputRenderer as FormInputRenderer,\n useField,\n createRulesEngine,\n type JsonLogicCondition,\n} from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\n\nimport { SINGLE_TYPES } from '../../../constants/collections';\nimport { useDocumentRBAC } from '../../../features/DocumentRBAC';\nimport { type UseDocument } from '../../../hooks/useDocument';\nimport { useDocumentContext } from '../../../hooks/useDocumentContext';\nimport { useDocumentLayout } from '../../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../../hooks/useLazyComponents';\nimport { useHasInputPopoverParent } from '../../../preview/components/InputPopover';\nimport { usePreviewInputManager } from '../../../preview/hooks/usePreviewInputManager';\nimport { getDirectParent } from '../utils/data';\n\nimport { BlocksInput } from './FormInputs/BlocksInput/BlocksInput';\nimport { ComponentInput } from './FormInputs/Component/Input';\nimport { DynamicZone, useDynamicZone } from './FormInputs/DynamicZone/Field';\nimport { NotAllowedInput } from './FormInputs/NotAllowed';\nimport { RelationsInput } from './FormInputs/Relations/Relations';\nimport { UIDInput } from './FormInputs/UID';\nimport { Wysiwyg } from './FormInputs/Wysiwyg/Field';\n\nimport type { EditFieldLayout } from '../../../hooks/useDocumentLayout';\nimport type { Schema } from '@strapi/types';\nimport type { DistributiveOmit } from 'react-redux';\n\ntype InputRendererProps = DistributiveOmit<EditFieldLayout, 'size'> & {\n document: ReturnType<UseDocument>;\n};\n\n/**\n * @internal\n *\n * @description An abstraction around the regular form input renderer designed\n * specifically to be used in the EditView of the content-manager this understands\n * the complete EditFieldLayout and will handle RBAC conditions and rendering CM specific\n * components such as Blocks / Relations.\n */\nconst BaseInputRenderer = ({\n visible,\n hint: providedHint,\n document,\n ...inputProps\n}: InputRendererProps) => {\n const localeKey = document?.document?.locale || 'default';\n const { currentDocumentMeta } = useDocumentContext('DynamicComponent');\n const {\n edit: { components },\n } = useDocumentLayout(currentDocumentMeta.model);\n\n const collectionType =\n document.schema?.kind === 'collectionType' ? 'collection-types' : 'single-types';\n\n const isInDynamicZone = useDynamicZone('isInDynamicZone', (state) => state.isInDynamicZone);\n const isInPreviewPopover = useHasInputPopoverParent();\n const shouldIgnorePermissions = isInDynamicZone || isInPreviewPopover;\n\n const isFormDisabled = useForm('InputRenderer', (state) => state.disabled);\n const canCreateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canCreateFields);\n const canReadFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canReadFields);\n const canUpdateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUpdateFields);\n const canUserAction = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUserAction);\n\n let idToCheck = document.document?.documentId;\n if (collectionType === SINGLE_TYPES) {\n idToCheck = document?.document?.documentId;\n }\n\n const editableFields = idToCheck ? canUpdateFields : canCreateFields;\n const readableFields = idToCheck ? canReadFields : canCreateFields;\n\n // Everything preview related\n const previewProps = usePreviewInputManager(inputProps.name, inputProps.attribute);\n const props = { ...inputProps, ...previewProps };\n\n /**\n * Component fields are always readable and editable,\n * however the fields within them may not be.\n */\n const canUserReadField = canUserAction(props.name, readableFields, props.type);\n const canUserEditField = canUserAction(props.name, editableFields, props.type);\n\n const fields = useStrapiApp('InputRenderer', (app) => app.fields);\n const { lazyComponentStore } = useLazyComponents(\n attributeHasCustomFieldProperty(props.attribute) ? [props.attribute.customField] : undefined\n );\n\n const hint = useFieldHint(providedHint, props.attribute);\n\n // We pass field in case of Custom Fields to keep backward compatibility\n const field = useField(props.name);\n\n if (!visible) {\n return null;\n }\n\n /**\n * If the user can't read the field then we don't want to ever render it.\n */\n if (!canUserReadField && !shouldIgnorePermissions) {\n return <NotAllowedInput hint={hint} {...props} />;\n }\n\n const fieldIsDisabled =\n (!canUserEditField && !shouldIgnorePermissions) || props.disabled || isFormDisabled;\n\n /**\n * Because a custom field has a unique prop but the type could be confused with either\n * the useField hook or the type of the field we need to handle it separately and first.\n */\n if (attributeHasCustomFieldProperty(props.attribute)) {\n const CustomInput = lazyComponentStore[props.attribute.customField];\n\n if (CustomInput) {\n return (\n <CustomInput\n {...props}\n {...field}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n return (\n <FormInputRenderer\n key={`input-${props.name}-${localeKey}`}\n {...props}\n {...previewProps}\n hint={hint}\n // @ts-expect-error – this workaround lets us display that the custom field is missing.\n type={props.attribute.customField}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * This is where we handle ONLY the fields from the `useLibrary` hook.\n */\n const addedInputTypes = Object.keys(fields);\n if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {\n const CustomInput = fields[props.type];\n return (\n <CustomInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * These include the content-manager specific fields, failing that we fall back\n * to the more generic form input renderer.\n */\n switch (props.type) {\n case 'blocks':\n return (\n <BlocksInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n />\n );\n case 'component':\n return (\n <ComponentInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n layout={components[props.attribute.component].layout}\n disabled={fieldIsDisabled}\n >\n {(componentInputProps) => (\n <MemoizedInputRenderer\n key={`input-${componentInputProps.name}-${localeKey}`}\n {...componentInputProps}\n />\n )}\n </ComponentInput>\n );\n case 'dynamiczone':\n return (\n <DynamicZone\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n case 'relation':\n return (\n <RelationsInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n case 'richtext':\n return (\n <Wysiwyg\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n />\n );\n case 'uid':\n // These props are not needed for the generic form input renderer.\n const { unique: _uniqueUID, ...restUIDProps } = props;\n return (\n <UIDInput\n key={`input-${props.name}-${localeKey}`}\n {...restUIDProps}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n />\n );\n /**\n * Enumerations are a special case because they require options.\n */\n case 'enumeration':\n return (\n <FormInputRenderer\n key={`input-${props.name}-${localeKey}`}\n {...props}\n {...previewProps}\n hint={hint}\n options={props.attribute.enum.map((value) => ({ value }))}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n default:\n // These props are not needed for the generic form input renderer.\n const { unique: _unique, mainField: _mainField, ...restProps } = props;\n return (\n <FormInputRenderer\n key={`input-${props.name}-${localeKey}`}\n {...restProps}\n {...previewProps}\n hint={hint}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n }\n};\n\nconst rulesEngine = createRulesEngine();\n\n/**\n * A wrapper around BaseInputRenderer that conditionally renders it depending on the attribute's condition.\n */\nconst ConditionAwareInputRenderer = ({\n condition,\n ...props\n}: InputRendererProps & { condition: JsonLogicCondition }) => {\n // Note: this selector causes a re-render every time any form value on the page changes\n const fieldValues = useForm('ConditionalInputRenderer', (state) => state.values);\n // For nested fields, we evaluate against the parent scope so conditions can read siblings.\n // Top-level fields resolve to the full form values.\n const targetValues = getDirectParent(fieldValues, props.name);\n\n const isVisible = rulesEngine.evaluate(condition, targetValues);\n\n if (!isVisible) {\n return null;\n }\n\n return <BaseInputRenderer {...props} />;\n};\n\nconst attributeHasCustomFieldProperty = (\n attribute: Schema.Attribute.AnyAttribute\n): attribute is Schema.Attribute.AnyAttribute & Schema.Attribute.CustomField<string> =>\n 'customField' in attribute && typeof attribute.customField === 'string';\n\nconst useFieldHint = (\n hint: React.ReactNode = undefined,\n attribute: Schema.Attribute.AnyAttribute\n) => {\n const { formatMessage } = useIntl();\n\n const { maximum, minimum } = getMinMax(attribute);\n\n if (!maximum && !minimum) {\n return hint;\n }\n\n const units = ['string', 'uid', 'richtext', 'email', 'password', 'text'].includes(attribute.type)\n ? formatMessage(\n {\n id: 'content-manager.form.Input.hint.character.unit',\n defaultMessage: '{maxValue, plural, one { character} other { characters}}',\n },\n {\n maxValue: Math.max(minimum || 0, maximum || 0),\n }\n )\n : null;\n\n const hasMinAndMax = typeof minimum === 'number' && typeof maximum === 'number';\n\n return formatMessage(\n {\n id: 'content-manager.form.Input.hint.text',\n defaultMessage:\n '{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}',\n },\n {\n min: minimum,\n max: maximum,\n description: hint,\n unit: units,\n divider: hasMinAndMax\n ? formatMessage({\n id: 'content-manager.form.Input.hint.minMaxDivider',\n defaultMessage: ' / ',\n })\n : null,\n br: <br />,\n }\n );\n};\n\nconst getMinMax = (attribute: Schema.Attribute.AnyAttribute) => {\n if ('min' in attribute || 'max' in attribute) {\n return {\n maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : undefined,\n minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : undefined,\n };\n } else if ('maxLength' in attribute || 'minLength' in attribute) {\n return { maximum: attribute.maxLength, minimum: attribute.minLength };\n } else {\n return { maximum: undefined, minimum: undefined };\n }\n};\n\n/**\n * Conditionally routes the exported InputRender component towards ConditionalInputRenderer\n * (when there's a JSON logic condition on the attribute, or BaseInputRenderer otherwise.\n * We do this because rendering a conditional field requires access to the values of\n * other form fields, which causes many re-renders and performance issues on complex content\n * types. By splitting the component into two, we isolate the performance issue to\n * conditional fields only, not all edit view fields.\n */\nconst MemoizedInputRenderer = React.memo((props: InputRendererProps) => {\n const condition = props.attribute.conditions?.visible;\n if (condition) {\n return <ConditionAwareInputRenderer {...props} condition={condition} />;\n }\n\n return <BaseInputRenderer {...props} />;\n});\n\nexport type { InputRendererProps };\nexport { MemoizedInputRenderer as InputRenderer, useFieldHint };\n"],"names":["BaseInputRenderer","visible","hint","providedHint","document","inputProps","localeKey","locale","currentDocumentMeta","useDocumentContext","edit","components","useDocumentLayout","model","collectionType","schema","kind","isInDynamicZone","useDynamicZone","state","isInPreviewPopover","useHasInputPopoverParent","shouldIgnorePermissions","isFormDisabled","useForm","disabled","canCreateFields","useDocumentRBAC","rbac","canReadFields","canUpdateFields","canUserAction","idToCheck","documentId","SINGLE_TYPES","editableFields","readableFields","previewProps","usePreviewInputManager","name","attribute","props","canUserReadField","type","canUserEditField","fields","useStrapiApp","app","lazyComponentStore","useLazyComponents","attributeHasCustomFieldProperty","customField","undefined","useFieldHint","field","useField","_jsx","NotAllowedInput","fieldIsDisabled","CustomInput","FormInputRenderer","addedInputTypes","Object","keys","includes","BlocksInput","ComponentInput","layout","component","componentInputProps","MemoizedInputRenderer","DynamicZone","RelationsInput","Wysiwyg","unique","_uniqueUID","restUIDProps","UIDInput","options","enum","map","value","_unique","mainField","_mainField","restProps","rulesEngine","createRulesEngine","ConditionAwareInputRenderer","condition","fieldValues","values","targetValues","getDirectParent","isVisible","evaluate","formatMessage","useIntl","maximum","minimum","getMinMax","units","id","defaultMessage","maxValue","Math","max","hasMinAndMax","min","description","unit","divider","br","Number","isNaN","maxLength","minLength","React","memo","conditions"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsCA;;;;;;;AAOC,IACD,MAAMA,iBAAAA,GAAoB,CAAC,EACzBC,OAAO,EACPC,IAAMC,EAAAA,YAAY,EAClBC,QAAQ,EACR,GAAGC,UACgB,EAAA,GAAA;IACnB,MAAMC,SAAAA,GAAYF,QAAUA,EAAAA,QAAAA,EAAUG,MAAU,IAAA,SAAA;AAChD,IAAA,MAAM,EAAEC,mBAAmB,EAAE,GAAGC,kBAAmB,CAAA,kBAAA,CAAA;IACnD,MAAM,EACJC,MAAM,EAAEC,UAAU,EAAE,EACrB,GAAGC,iBAAkBJ,CAAAA,mBAAAA,CAAoBK,KAAK,CAAA;AAE/C,IAAA,MAAMC,iBACJV,QAASW,CAAAA,MAAM,EAAEC,IAAAA,KAAS,mBAAmB,kBAAqB,GAAA,cAAA;AAEpE,IAAA,MAAMC,kBAAkBC,cAAe,CAAA,iBAAA,EAAmB,CAACC,KAAAA,GAAUA,MAAMF,eAAe,CAAA;AAC1F,IAAA,MAAMG,kBAAqBC,GAAAA,wBAAAA,EAAAA;AAC3B,IAAA,MAAMC,0BAA0BL,eAAmBG,IAAAA,kBAAAA;AAEnD,IAAA,MAAMG,iBAAiBC,OAAQ,CAAA,eAAA,EAAiB,CAACL,KAAAA,GAAUA,MAAMM,QAAQ,CAAA;AACzE,IAAA,MAAMC,kBAAkBC,eAAgB,CAAA,eAAA,EAAiB,CAACC,IAAAA,GAASA,KAAKF,eAAe,CAAA;AACvF,IAAA,MAAMG,gBAAgBF,eAAgB,CAAA,eAAA,EAAiB,CAACC,IAAAA,GAASA,KAAKC,aAAa,CAAA;AACnF,IAAA,MAAMC,kBAAkBH,eAAgB,CAAA,eAAA,EAAiB,CAACC,IAAAA,GAASA,KAAKE,eAAe,CAAA;AACvF,IAAA,MAAMC,gBAAgBJ,eAAgB,CAAA,eAAA,EAAiB,CAACC,IAAAA,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AAWA,EAAAA;;AAC5D;AAEA,IAAA,qBAAOjC,GAACxD,CAAAA,iBAAAA,EAAAA;AAAmB,QAAA,GAAGyC;;AAChC,CAAA;;;;"}
|
|
@@ -9,6 +9,27 @@ const BLOCK_LIST_ATTRIBUTE_KEYS = [
|
|
|
9
9
|
'__component',
|
|
10
10
|
'__temp_key__'
|
|
11
11
|
];
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
* @description Returns the direct parent object for a dot-separated path.
|
|
15
|
+
*/ const getDirectParent = (data, path)=>{
|
|
16
|
+
if (!path) return undefined;
|
|
17
|
+
const isNumericIndex = (value)=>/^\d+$/.test(value);
|
|
18
|
+
const segments = path.split('.');
|
|
19
|
+
const parentPath = segments.slice(0, -1);
|
|
20
|
+
let current = data;
|
|
21
|
+
for (const segment of parentPath){
|
|
22
|
+
if (current == null) return undefined;
|
|
23
|
+
if (isNumericIndex(segment)) {
|
|
24
|
+
if (!Array.isArray(current)) return undefined;
|
|
25
|
+
current = current[Number(segment)];
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (typeof current !== 'object') return undefined;
|
|
29
|
+
current = current[segment];
|
|
30
|
+
}
|
|
31
|
+
return current;
|
|
32
|
+
};
|
|
12
33
|
/**
|
|
13
34
|
* @internal This function is used to traverse the data and transform the values.
|
|
14
35
|
* Given a predicate function, it will transform the value (using the given transform function)
|
|
@@ -329,6 +350,7 @@ const BLOCK_LIST_ATTRIBUTE_KEYS = [
|
|
|
329
350
|
};
|
|
330
351
|
};
|
|
331
352
|
|
|
353
|
+
exports.getDirectParent = getDirectParent;
|
|
332
354
|
exports.handleInvisibleAttributes = handleInvisibleAttributes;
|
|
333
355
|
exports.prepareRelations = prepareRelations;
|
|
334
356
|
exports.prepareTempKeys = prepareTempKeys;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.js","sources":["../../../../../admin/src/pages/EditView/utils/data.ts"],"sourcesContent":["import { createRulesEngine } from '@strapi/admin/strapi-admin';\nimport { generateNKeysBetween } from 'fractional-indexing';\nimport pipe from 'lodash/fp/pipe';\n\nimport { DOCUMENT_META_FIELDS } from '../../../constants/attributes';\n\nimport type { ComponentsDictionary, Document } from '../../../hooks/useDocument';\nimport type { Schema, UID } from '@strapi/types';\n\n/* -------------------------------------------------------------------------------------------------\n * traverseData\n * -----------------------------------------------------------------------------------------------*/\n\n// Make only attributes required since it's the only one Content History has\ntype PartialSchema = Partial<Schema.Schema> & Pick<Schema.Schema, 'attributes'>;\n\ntype Predicate = <TAttribute extends Schema.Attribute.AnyAttribute>(\n attribute: TAttribute,\n value: Schema.Attribute.Value<TAttribute>\n) => boolean;\ntype Transform = <TAttribute extends Schema.Attribute.AnyAttribute>(\n value: any,\n attribute: TAttribute\n) => any;\ntype AnyData = Omit<Document, 'id'>;\n\nconst BLOCK_LIST_ATTRIBUTE_KEYS = ['__component', '__temp_key__'];\n\n/**\n * @internal This function is used to traverse the data and transform the values.\n * Given a predicate function, it will transform the value (using the given transform function)\n * if the predicate returns true. If it finds that the attribute is a component or dynamiczone,\n * it will recursively traverse those data structures as well.\n *\n * It is possible to break the ContentManager by using this function incorrectly, for example,\n * if you transform a number into a string but the attribute type is a number, the ContentManager\n * will not be able to save the data and the Form will likely crash because the component it's\n * passing the data too won't succesfully be able to handle the value.\n */\nconst traverseData =\n (predicate: Predicate, transform: Transform) =>\n (schema: PartialSchema, components: ComponentsDictionary = {}) =>\n (data: AnyData = {}) => {\n const traverse = (datum: AnyData, attributes: Schema.Schema['attributes']) => {\n return Object.entries(datum).reduce<AnyData>((acc, [key, value]) => {\n const attribute = attributes[key];\n\n /**\n * If the attribute is a block list attribute, we don't want to transform it.\n * We also don't want to transform null or undefined values.\n */\n if (BLOCK_LIST_ATTRIBUTE_KEYS.includes(key) || value === null || value === undefined) {\n acc[key] = value;\n return acc;\n }\n\n if (attribute.type === 'component') {\n if (attribute.repeatable) {\n const componentValue = (\n predicate(attribute, value) ? transform(value, attribute) : value\n ) as Schema.Attribute.Value<Schema.Attribute.Component<UID.Component, true>>;\n acc[key] = componentValue.map((componentData) =>\n traverse(componentData, components[attribute.component]?.attributes ?? {})\n );\n } else {\n const componentValue = (\n predicate(attribute, value) ? transform(value, attribute) : value\n ) as Schema.Attribute.Value<Schema.Attribute.Component<UID.Component, false>>;\n\n acc[key] = traverse(componentValue, components[attribute.component]?.attributes ?? {});\n }\n } else if (attribute.type === 'dynamiczone') {\n const dynamicZoneValue = (\n predicate(attribute, value) ? transform(value, attribute) : value\n ) as Schema.Attribute.Value<Schema.Attribute.DynamicZone>;\n\n acc[key] = dynamicZoneValue.map((componentData) =>\n traverse(componentData, components[componentData.__component]?.attributes ?? {})\n );\n } else if (predicate(attribute, value)) {\n acc[key] = transform(value, attribute);\n } else {\n acc[key] = value;\n }\n\n return acc;\n }, {});\n };\n\n return traverse(data, schema.attributes);\n };\n\n/* -------------------------------------------------------------------------------------------------\n * removeProhibitedFields\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal Removes all the fields that are not allowed.\n */\nconst removeProhibitedFields = (prohibitedFields: Schema.Attribute.Kind[]) =>\n traverseData(\n (attribute) => prohibitedFields.includes(attribute.type),\n () => ''\n );\n\n/* -------------------------------------------------------------------------------------------------\n * prepareRelations\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Sets all relation values to an empty array.\n */\nconst prepareRelations = traverseData(\n (attribute) => attribute.type === 'relation',\n () => ({\n connect: [],\n disconnect: [],\n })\n);\n\n/* -------------------------------------------------------------------------------------------------\n * prepareTempKeys\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Adds a `__temp_key__` to each component and dynamiczone item. This gives us\n * a stable identifier regardless of its ids etc. that we can then use for drag and drop.\n */\nconst prepareTempKeys = traverseData(\n (attribute) =>\n (attribute.type === 'component' && attribute.repeatable) || attribute.type === 'dynamiczone',\n (data) => {\n if (Array.isArray(data) && data.length > 0) {\n const keys = generateNKeysBetween(undefined, undefined, data.length);\n\n return data.map((datum, index) => ({\n ...datum,\n __temp_key__: keys[index],\n }));\n }\n\n return data;\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * removeFieldsThatDontExistOnSchema\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Fields that don't exist in the schema like createdAt etc. are only on the first level (not nested),\n * as such we don't need to traverse the components to remove them.\n */\nconst removeFieldsThatDontExistOnSchema = (schema: PartialSchema) => (data: AnyData) => {\n const schemaKeys = Object.keys(schema.attributes);\n const dataKeys = Object.keys(data);\n\n const keysToRemove = dataKeys.filter((key) => !schemaKeys.includes(key));\n\n const revisedData = [...keysToRemove, ...DOCUMENT_META_FIELDS].reduce((acc, key) => {\n delete acc[key];\n\n return acc;\n }, structuredClone(data));\n\n return revisedData;\n};\n\n/**\n * @internal\n * @description We need to remove null fields from the data-structure because it will pass it\n * to the specific inputs breaking them as most would prefer empty strings or `undefined` if\n * they're controlled / uncontrolled. However, Boolean fields should preserve null values.\n */\nconst removeNullValues = (schema: PartialSchema, components: ComponentsDictionary = {}) =>\n traverseData(\n (attribute, value) => value === null && attribute.type !== 'boolean',\n () => undefined\n )(schema, components);\n\n/* -------------------------------------------------------------------------------------------------\n * transformDocuments\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Takes a document data structure (this could be from the API or a default form structure)\n * and applies consistent data transformations to it. This is also used when we add new components to the\n * form to ensure the data is correctly prepared from their default state e.g. relations are set to an empty array.\n */\nconst transformDocument =\n (schema: PartialSchema, components: ComponentsDictionary = {}) =>\n (document: AnyData) => {\n const transformations = pipe(\n removeFieldsThatDontExistOnSchema(schema),\n removeProhibitedFields(['password'])(schema, components),\n removeNullValues(schema, components),\n prepareRelations(schema, components),\n prepareTempKeys(schema, components)\n );\n\n return transformations(document);\n };\n\ntype HandleOptions = {\n schema?: Schema.ContentType | Schema.Component;\n initialValues?: AnyData;\n components?: Record<string, Schema.Component>;\n};\n\ntype RemovedFieldPath = string;\n\n/**\n * @internal\n * @description Finds the initial value for a component or dynamic zone item (based on its __temp_key__ and not its index).\n * @param initialValue - The initial values object.\n * @param item - The item to find the initial value for.\n * @returns The initial value for the item.\n */\nconst getItemInitialValue = (initialValue: AnyData, item: AnyData) => {\n if (initialValue && Array.isArray(initialValue)) {\n const matchingInitialItem = initialValue.find(\n (initialItem) => initialItem.__temp_key__ === item.__temp_key__\n );\n if (matchingInitialItem) {\n return matchingInitialItem;\n }\n }\n return {};\n};\n\n/**\n * @internal\n * @description Collects paths of attributes that should be removed based on visibility conditions.\n * This function only evaluates conditions.visible (JSON Logic), not the visible boolean property.\n *\n * @param data - The data object to evaluate\n * @param schema - The content type schema\n * @param components - Dictionary of component schemas\n * @param path - Current path in the data structure (for nested components/dynamiczones)\n * @returns Array of field paths that should be removed\n */\nconst collectInvisibleAttributes = (\n data: AnyData,\n schema: Schema.ContentType | Schema.Component | undefined,\n components: Record<string, Schema.Component>,\n path: string[] = []\n): RemovedFieldPath[] => {\n if (!schema?.attributes) return [];\n\n const rulesEngine = createRulesEngine();\n const removedPaths: RemovedFieldPath[] = [];\n const evaluatedData: AnyData = {};\n\n for (const [attrName, attrDef] of Object.entries(schema.attributes)) {\n const fullPath = [...path, attrName].join('.');\n\n // Skip fields with visible: false - they're managed by backend\n if ('visible' in attrDef && attrDef.visible === false) {\n continue;\n }\n\n const condition = attrDef?.conditions?.visible;\n const isVisible = condition\n ? rulesEngine.evaluate(condition, { ...data, ...evaluatedData })\n : true;\n\n if (!isVisible) {\n removedPaths.push(fullPath);\n continue;\n }\n\n // Track this field for future condition evaluations\n if (attrName in data) {\n evaluatedData[attrName] = data[attrName];\n }\n\n // Recursively process components\n if (attrDef.type === 'component') {\n const compSchema = components[attrDef.component];\n const value = data[attrName];\n\n if (attrDef.repeatable && Array.isArray(value)) {\n value.forEach((item) => {\n const nestedPaths = collectInvisibleAttributes(item, compSchema, components, [\n ...path,\n `${attrName}[${item.__temp_key__}]`,\n ]);\n removedPaths.push(...nestedPaths);\n });\n } else if (value && typeof value === 'object') {\n const nestedPaths = collectInvisibleAttributes(value, compSchema, components, [\n ...path,\n attrName,\n ]);\n removedPaths.push(...nestedPaths);\n }\n }\n\n // Recursively process dynamic zones\n if (attrDef.type === 'dynamiczone' && Array.isArray(data[attrName])) {\n data[attrName].forEach((dzItem: AnyData) => {\n const compUID = dzItem?.__component;\n const compSchema = components[compUID];\n const nestedPaths = collectInvisibleAttributes(dzItem, compSchema, components, [\n ...path,\n `${attrName}[${dzItem.__temp_key__}]`,\n ]);\n removedPaths.push(...nestedPaths);\n });\n }\n }\n\n return removedPaths;\n};\n\n/**\n * @internal\n * @description Removes attributes from data based on the list of paths to remove.\n * Preserves fields with visible: false from data or initialValues.\n *\n * @param data - The data object to filter\n * @param initialValues - Initial values to fall back to\n * @param schema - The content type schema\n * @param components - Dictionary of component schemas\n * @param removedPaths - Array of field paths to remove\n * @param currentPath - Current path in the data structure\n * @returns Filtered data object\n */\nconst filterDataByRemovedPaths = (\n data: AnyData,\n initialValues: AnyData,\n schema: Schema.ContentType | Schema.Component | undefined,\n components: Record<string, Schema.Component>,\n removedPaths: RemovedFieldPath[],\n currentPath: string[] = []\n): AnyData => {\n if (!schema?.attributes) return data;\n\n const result: AnyData = {};\n\n for (const [attrName, attrDef] of Object.entries(schema.attributes)) {\n const fullPath = [...currentPath, attrName].join('.');\n\n // Check if this field should be removed\n if (removedPaths.includes(fullPath)) {\n continue;\n }\n\n // Handle fields with visible: false - preserve from data or initialValues\n if ('visible' in attrDef && attrDef.visible === false) {\n const userProvided = Object.hasOwn(data, attrName);\n if (userProvided) {\n result[attrName] = data[attrName];\n } else if (attrName in initialValues) {\n result[attrName] = initialValues[attrName];\n }\n continue;\n }\n\n const userProvided = Object.hasOwn(data, attrName);\n const currentValue = userProvided ? data[attrName] : undefined;\n const initialValue = initialValues?.[attrName];\n\n // Handle components\n if (attrDef.type === 'component') {\n const compSchema = components[attrDef.component];\n const value = currentValue === undefined ? initialValue : currentValue;\n\n if (!value) {\n result[attrName] = attrDef.repeatable ? [] : null;\n continue;\n }\n\n if (attrDef.repeatable && Array.isArray(value)) {\n result[attrName] = value.map((item) => {\n const componentInitialValue = getItemInitialValue(initialValue, item);\n return filterDataByRemovedPaths(\n item,\n componentInitialValue,\n compSchema,\n components,\n removedPaths,\n [...currentPath, `${attrName}[${item.__temp_key__}]`]\n );\n });\n } else {\n result[attrName] = filterDataByRemovedPaths(\n value,\n initialValue ?? {},\n compSchema,\n components,\n removedPaths,\n [...currentPath, attrName]\n );\n }\n\n continue;\n }\n\n // Handle dynamic zones\n if (attrDef.type === 'dynamiczone') {\n if (!Array.isArray(currentValue)) {\n result[attrName] = [];\n continue;\n }\n\n result[attrName] = currentValue.map((dzItem) => {\n const compUID = dzItem?.__component;\n const compSchema = components[compUID];\n const componentInitialValue = getItemInitialValue(initialValue, dzItem);\n\n const cleaned = filterDataByRemovedPaths(\n dzItem,\n componentInitialValue,\n compSchema,\n components,\n removedPaths,\n [...currentPath, `${attrName}[${dzItem.__temp_key__}]`]\n );\n\n // For newly created components, ensure id is undefined (in case of reordering)\n const processedItem =\n dzItem.id === undefined || dzItem.id === null\n ? { __component: compUID, ...cleaned, id: undefined }\n : { __component: compUID, ...cleaned };\n\n return processedItem;\n });\n\n continue;\n }\n\n // Regular fields - preserve from data or initialValues\n if (currentValue !== undefined) {\n result[attrName] = currentValue;\n } else if (initialValue !== undefined) {\n result[attrName] = initialValue;\n }\n }\n\n // Pass through any fields from data that aren't in the schema\n for (const [key, value] of Object.entries(data)) {\n if (!(key in result) && !(key in (schema?.attributes || {}))) {\n result[key] = value;\n }\n }\n\n return result;\n};\n\n/**\n * Removes values from the data object if their corresponding attribute has a\n * visibility condition that evaluates to false.\n *\n * @param data - The data object to filter based on visibility\n * @param options - Schema, initialValues, and components\n * @returns Object with filtered data and list of removed attribute paths\n */\nconst handleInvisibleAttributes = (\n data: AnyData,\n { schema, initialValues = {}, components = {} }: HandleOptions\n): {\n data: AnyData;\n removedAttributes: RemovedFieldPath[];\n} => {\n if (!schema?.attributes) return { data, removedAttributes: [] };\n\n const removedAttributes = collectInvisibleAttributes(data, schema, components);\n\n const filteredData = filterDataByRemovedPaths(\n data,\n initialValues,\n schema,\n components,\n removedAttributes\n );\n\n return {\n data: filteredData,\n removedAttributes,\n };\n};\n\nexport {\n removeProhibitedFields,\n prepareRelations,\n prepareTempKeys,\n removeFieldsThatDontExistOnSchema,\n transformDocument,\n handleInvisibleAttributes,\n};\nexport type { AnyData };\n"],"names":["BLOCK_LIST_ATTRIBUTE_KEYS","traverseData","predicate","transform","schema","components","data","traverse","datum","attributes","Object","entries","reduce","acc","key","value","attribute","includes","undefined","type","repeatable","componentValue","map","componentData","component","dynamicZoneValue","__component","removeProhibitedFields","prohibitedFields","prepareRelations","connect","disconnect","prepareTempKeys","Array","isArray","length","keys","generateNKeysBetween","index","__temp_key__","removeFieldsThatDontExistOnSchema","schemaKeys","dataKeys","keysToRemove","filter","revisedData","DOCUMENT_META_FIELDS","structuredClone","removeNullValues","transformDocument","document","transformations","pipe","getItemInitialValue","initialValue","item","matchingInitialItem","find","initialItem","collectInvisibleAttributes","path","rulesEngine","createRulesEngine","removedPaths","evaluatedData","attrName","attrDef","fullPath","join","visible","condition","conditions","isVisible","evaluate","push","compSchema","forEach","nestedPaths","dzItem","compUID","filterDataByRemovedPaths","initialValues","currentPath","result","userProvided","hasOwn","currentValue","componentInitialValue","cleaned","processedItem","id","handleInvisibleAttributes","removedAttributes","filteredData"],"mappings":";;;;;;;AA0BA,MAAMA,yBAA4B,GAAA;AAAC,IAAA,aAAA;AAAe,IAAA;AAAe,CAAA;AAEjE;;;;;;;;;;AAUC,IACD,MAAMC,YAAAA,GACJ,CAACC,SAAAA,EAAsBC,YACvB,CAACC,MAAAA,EAAuBC,UAAmC,GAAA,EAAE,GAC7D,CAACC,IAAAA,GAAgB,EAAE,GAAA;YACjB,MAAMC,QAAAA,GAAW,CAACC,KAAgBC,EAAAA,UAAAA,GAAAA;gBAChC,OAAOC,MAA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AE6E,aAAgB,GAAA,EAAE,EAAE5E,UAAa,GAAA,EAAE,EAAiB,GAAA;IAK9D,IAAI,CAACD,MAAQK,EAAAA,UAAAA,EAAY,OAAO;AAAEH,QAAAA,IAAAA;AAAMsF,QAAAA,iBAAAA,EAAmB;AAAG,KAAA;IAE9D,MAAMA,iBAAAA,GAAoBjC,0BAA2BrD,CAAAA,IAAAA,EAAMF,MAAQC,EAAAA,UAAAA,CAAAA;AAEnE,IAAA,MAAMwF,YAAeb,GAAAA,wBAAAA,CACnB1E,IACA2E,EAAAA,aAAAA,EACA7E,QACAC,UACAuF,EAAAA,iBAAAA,CAAAA;IAGF,OAAO;QACLtF,IAAMuF,EAAAA,YAAAA;AACND,QAAAA;AACF,KAAA;AACF;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"data.js","sources":["../../../../../admin/src/pages/EditView/utils/data.ts"],"sourcesContent":["import { createRulesEngine } from '@strapi/admin/strapi-admin';\nimport { generateNKeysBetween } from 'fractional-indexing';\nimport pipe from 'lodash/fp/pipe';\n\nimport { DOCUMENT_META_FIELDS } from '../../../constants/attributes';\n\nimport type { ComponentsDictionary, Document } from '../../../hooks/useDocument';\nimport type { Schema, UID } from '@strapi/types';\n\n/* -------------------------------------------------------------------------------------------------\n * traverseData\n * -----------------------------------------------------------------------------------------------*/\n\n// Make only attributes required since it's the only one Content History has\ntype PartialSchema = Partial<Schema.Schema> & Pick<Schema.Schema, 'attributes'>;\n\ntype Predicate = <TAttribute extends Schema.Attribute.AnyAttribute>(\n attribute: TAttribute,\n value: Schema.Attribute.Value<TAttribute>\n) => boolean;\ntype Transform = <TAttribute extends Schema.Attribute.AnyAttribute>(\n value: any,\n attribute: TAttribute\n) => any;\ntype AnyData = Omit<Document, 'id'>;\n\nconst BLOCK_LIST_ATTRIBUTE_KEYS = ['__component', '__temp_key__'];\n\n/**\n * @internal\n * @description Returns the direct parent object for a dot-separated path.\n */\nconst getDirectParent = (data: unknown, path: string): unknown => {\n if (!path) return undefined;\n const isNumericIndex = (value: string) => /^\\d+$/.test(value);\n const segments = path.split('.');\n const parentPath = segments.slice(0, -1);\n let current: unknown = data;\n\n for (const segment of parentPath) {\n if (current == null) return undefined;\n\n if (isNumericIndex(segment)) {\n if (!Array.isArray(current)) return undefined;\n current = current[Number(segment)];\n continue;\n }\n\n if (typeof current !== 'object') return undefined;\n current = (current as Record<string, unknown>)[segment];\n }\n\n return current;\n};\n\n/**\n * @internal This function is used to traverse the data and transform the values.\n * Given a predicate function, it will transform the value (using the given transform function)\n * if the predicate returns true. If it finds that the attribute is a component or dynamiczone,\n * it will recursively traverse those data structures as well.\n *\n * It is possible to break the ContentManager by using this function incorrectly, for example,\n * if you transform a number into a string but the attribute type is a number, the ContentManager\n * will not be able to save the data and the Form will likely crash because the component it's\n * passing the data too won't succesfully be able to handle the value.\n */\nconst traverseData =\n (predicate: Predicate, transform: Transform) =>\n (schema: PartialSchema, components: ComponentsDictionary = {}) =>\n (data: AnyData = {}) => {\n const traverse = (datum: AnyData, attributes: Schema.Schema['attributes']) => {\n return Object.entries(datum).reduce<AnyData>((acc, [key, value]) => {\n const attribute = attributes[key];\n\n /**\n * If the attribute is a block list attribute, we don't want to transform it.\n * We also don't want to transform null or undefined values.\n */\n if (BLOCK_LIST_ATTRIBUTE_KEYS.includes(key) || value === null || value === undefined) {\n acc[key] = value;\n return acc;\n }\n\n if (attribute.type === 'component') {\n if (attribute.repeatable) {\n const componentValue = (\n predicate(attribute, value) ? transform(value, attribute) : value\n ) as Schema.Attribute.Value<Schema.Attribute.Component<UID.Component, true>>;\n acc[key] = componentValue.map((componentData) =>\n traverse(componentData, components[attribute.component]?.attributes ?? {})\n );\n } else {\n const componentValue = (\n predicate(attribute, value) ? transform(value, attribute) : value\n ) as Schema.Attribute.Value<Schema.Attribute.Component<UID.Component, false>>;\n\n acc[key] = traverse(componentValue, components[attribute.component]?.attributes ?? {});\n }\n } else if (attribute.type === 'dynamiczone') {\n const dynamicZoneValue = (\n predicate(attribute, value) ? transform(value, attribute) : value\n ) as Schema.Attribute.Value<Schema.Attribute.DynamicZone>;\n\n acc[key] = dynamicZoneValue.map((componentData) =>\n traverse(componentData, components[componentData.__component]?.attributes ?? {})\n );\n } else if (predicate(attribute, value)) {\n acc[key] = transform(value, attribute);\n } else {\n acc[key] = value;\n }\n\n return acc;\n }, {});\n };\n\n return traverse(data, schema.attributes);\n };\n\n/* -------------------------------------------------------------------------------------------------\n * removeProhibitedFields\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal Removes all the fields that are not allowed.\n */\nconst removeProhibitedFields = (prohibitedFields: Schema.Attribute.Kind[]) =>\n traverseData(\n (attribute) => prohibitedFields.includes(attribute.type),\n () => ''\n );\n\n/* -------------------------------------------------------------------------------------------------\n * prepareRelations\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Sets all relation values to an empty array.\n */\nconst prepareRelations = traverseData(\n (attribute) => attribute.type === 'relation',\n () => ({\n connect: [],\n disconnect: [],\n })\n);\n\n/* -------------------------------------------------------------------------------------------------\n * prepareTempKeys\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Adds a `__temp_key__` to each component and dynamiczone item. This gives us\n * a stable identifier regardless of its ids etc. that we can then use for drag and drop.\n */\nconst prepareTempKeys = traverseData(\n (attribute) =>\n (attribute.type === 'component' && attribute.repeatable) || attribute.type === 'dynamiczone',\n (data) => {\n if (Array.isArray(data) && data.length > 0) {\n const keys = generateNKeysBetween(undefined, undefined, data.length);\n\n return data.map((datum, index) => ({\n ...datum,\n __temp_key__: keys[index],\n }));\n }\n\n return data;\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * removeFieldsThatDontExistOnSchema\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Fields that don't exist in the schema like createdAt etc. are only on the first level (not nested),\n * as such we don't need to traverse the components to remove them.\n */\nconst removeFieldsThatDontExistOnSchema = (schema: PartialSchema) => (data: AnyData) => {\n const schemaKeys = Object.keys(schema.attributes);\n const dataKeys = Object.keys(data);\n\n const keysToRemove = dataKeys.filter((key) => !schemaKeys.includes(key));\n\n const revisedData = [...keysToRemove, ...DOCUMENT_META_FIELDS].reduce((acc, key) => {\n delete acc[key];\n\n return acc;\n }, structuredClone(data));\n\n return revisedData;\n};\n\n/**\n * @internal\n * @description We need to remove null fields from the data-structure because it will pass it\n * to the specific inputs breaking them as most would prefer empty strings or `undefined` if\n * they're controlled / uncontrolled. However, Boolean fields should preserve null values.\n */\nconst removeNullValues = (schema: PartialSchema, components: ComponentsDictionary = {}) =>\n traverseData(\n (attribute, value) => value === null && attribute.type !== 'boolean',\n () => undefined\n )(schema, components);\n\n/* -------------------------------------------------------------------------------------------------\n * transformDocuments\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal\n * @description Takes a document data structure (this could be from the API or a default form structure)\n * and applies consistent data transformations to it. This is also used when we add new components to the\n * form to ensure the data is correctly prepared from their default state e.g. relations are set to an empty array.\n */\nconst transformDocument =\n (schema: PartialSchema, components: ComponentsDictionary = {}) =>\n (document: AnyData) => {\n const transformations = pipe(\n removeFieldsThatDontExistOnSchema(schema),\n removeProhibitedFields(['password'])(schema, components),\n removeNullValues(schema, components),\n prepareRelations(schema, components),\n prepareTempKeys(schema, components)\n );\n\n return transformations(document);\n };\n\ntype HandleOptions = {\n schema?: Schema.ContentType | Schema.Component;\n initialValues?: AnyData;\n components?: Record<string, Schema.Component>;\n};\n\ntype RemovedFieldPath = string;\n\n/**\n * @internal\n * @description Finds the initial value for a component or dynamic zone item (based on its __temp_key__ and not its index).\n * @param initialValue - The initial values object.\n * @param item - The item to find the initial value for.\n * @returns The initial value for the item.\n */\nconst getItemInitialValue = (initialValue: AnyData, item: AnyData) => {\n if (initialValue && Array.isArray(initialValue)) {\n const matchingInitialItem = initialValue.find(\n (initialItem) => initialItem.__temp_key__ === item.__temp_key__\n );\n if (matchingInitialItem) {\n return matchingInitialItem;\n }\n }\n return {};\n};\n\n/**\n * @internal\n * @description Collects paths of attributes that should be removed based on visibility conditions.\n * This function only evaluates conditions.visible (JSON Logic), not the visible boolean property.\n *\n * @param data - The data object to evaluate\n * @param schema - The content type schema\n * @param components - Dictionary of component schemas\n * @param path - Current path in the data structure (for nested components/dynamiczones)\n * @returns Array of field paths that should be removed\n */\nconst collectInvisibleAttributes = (\n data: AnyData,\n schema: Schema.ContentType | Schema.Component | undefined,\n components: Record<string, Schema.Component>,\n path: string[] = []\n): RemovedFieldPath[] => {\n if (!schema?.attributes) return [];\n\n const rulesEngine = createRulesEngine();\n const removedPaths: RemovedFieldPath[] = [];\n const evaluatedData: AnyData = {};\n\n for (const [attrName, attrDef] of Object.entries(schema.attributes)) {\n const fullPath = [...path, attrName].join('.');\n\n // Skip fields with visible: false - they're managed by backend\n if ('visible' in attrDef && attrDef.visible === false) {\n continue;\n }\n\n const condition = attrDef?.conditions?.visible;\n const isVisible = condition\n ? rulesEngine.evaluate(condition, { ...data, ...evaluatedData })\n : true;\n\n if (!isVisible) {\n removedPaths.push(fullPath);\n continue;\n }\n\n // Track this field for future condition evaluations\n if (attrName in data) {\n evaluatedData[attrName] = data[attrName];\n }\n\n // Recursively process components\n if (attrDef.type === 'component') {\n const compSchema = components[attrDef.component];\n const value = data[attrName];\n\n if (attrDef.repeatable && Array.isArray(value)) {\n value.forEach((item) => {\n const nestedPaths = collectInvisibleAttributes(item, compSchema, components, [\n ...path,\n `${attrName}[${item.__temp_key__}]`,\n ]);\n removedPaths.push(...nestedPaths);\n });\n } else if (value && typeof value === 'object') {\n const nestedPaths = collectInvisibleAttributes(value, compSchema, components, [\n ...path,\n attrName,\n ]);\n removedPaths.push(...nestedPaths);\n }\n }\n\n // Recursively process dynamic zones\n if (attrDef.type === 'dynamiczone' && Array.isArray(data[attrName])) {\n data[attrName].forEach((dzItem: AnyData) => {\n const compUID = dzItem?.__component;\n const compSchema = components[compUID];\n const nestedPaths = collectInvisibleAttributes(dzItem, compSchema, components, [\n ...path,\n `${attrName}[${dzItem.__temp_key__}]`,\n ]);\n removedPaths.push(...nestedPaths);\n });\n }\n }\n\n return removedPaths;\n};\n\n/**\n * @internal\n * @description Removes attributes from data based on the list of paths to remove.\n * Preserves fields with visible: false from data or initialValues.\n *\n * @param data - The data object to filter\n * @param initialValues - Initial values to fall back to\n * @param schema - The content type schema\n * @param components - Dictionary of component schemas\n * @param removedPaths - Array of field paths to remove\n * @param currentPath - Current path in the data structure\n * @returns Filtered data object\n */\nconst filterDataByRemovedPaths = (\n data: AnyData,\n initialValues: AnyData,\n schema: Schema.ContentType | Schema.Component | undefined,\n components: Record<string, Schema.Component>,\n removedPaths: RemovedFieldPath[],\n currentPath: string[] = []\n): AnyData => {\n if (!schema?.attributes) return data;\n\n const result: AnyData = {};\n\n for (const [attrName, attrDef] of Object.entries(schema.attributes)) {\n const fullPath = [...currentPath, attrName].join('.');\n\n // Check if this field should be removed\n if (removedPaths.includes(fullPath)) {\n continue;\n }\n\n // Handle fields with visible: false - preserve from data or initialValues\n if ('visible' in attrDef && attrDef.visible === false) {\n const userProvided = Object.hasOwn(data, attrName);\n if (userProvided) {\n result[attrName] = data[attrName];\n } else if (attrName in initialValues) {\n result[attrName] = initialValues[attrName];\n }\n continue;\n }\n\n const userProvided = Object.hasOwn(data, attrName);\n const currentValue = userProvided ? data[attrName] : undefined;\n const initialValue = initialValues?.[attrName];\n\n // Handle components\n if (attrDef.type === 'component') {\n const compSchema = components[attrDef.component];\n const value = currentValue === undefined ? initialValue : currentValue;\n\n if (!value) {\n result[attrName] = attrDef.repeatable ? [] : null;\n continue;\n }\n\n if (attrDef.repeatable && Array.isArray(value)) {\n result[attrName] = value.map((item) => {\n const componentInitialValue = getItemInitialValue(initialValue, item);\n return filterDataByRemovedPaths(\n item,\n componentInitialValue,\n compSchema,\n components,\n removedPaths,\n [...currentPath, `${attrName}[${item.__temp_key__}]`]\n );\n });\n } else {\n result[attrName] = filterDataByRemovedPaths(\n value,\n initialValue ?? {},\n compSchema,\n components,\n removedPaths,\n [...currentPath, attrName]\n );\n }\n\n continue;\n }\n\n // Handle dynamic zones\n if (attrDef.type === 'dynamiczone') {\n if (!Array.isArray(currentValue)) {\n result[attrName] = [];\n continue;\n }\n\n result[attrName] = currentValue.map((dzItem) => {\n const compUID = dzItem?.__component;\n const compSchema = components[compUID];\n const componentInitialValue = getItemInitialValue(initialValue, dzItem);\n\n const cleaned = filterDataByRemovedPaths(\n dzItem,\n componentInitialValue,\n compSchema,\n components,\n removedPaths,\n [...currentPath, `${attrName}[${dzItem.__temp_key__}]`]\n );\n\n // For newly created components, ensure id is undefined (in case of reordering)\n const processedItem =\n dzItem.id === undefined || dzItem.id === null\n ? { __component: compUID, ...cleaned, id: undefined }\n : { __component: compUID, ...cleaned };\n\n return processedItem;\n });\n\n continue;\n }\n\n // Regular fields - preserve from data or initialValues\n if (currentValue !== undefined) {\n result[attrName] = currentValue;\n } else if (initialValue !== undefined) {\n result[attrName] = initialValue;\n }\n }\n\n // Pass through any fields from data that aren't in the schema\n for (const [key, value] of Object.entries(data)) {\n if (!(key in result) && !(key in (schema?.attributes || {}))) {\n result[key] = value;\n }\n }\n\n return result;\n};\n\n/**\n * Removes values from the data object if their corresponding attribute has a\n * visibility condition that evaluates to false.\n *\n * @param data - The data object to filter based on visibility\n * @param options - Schema, initialValues, and components\n * @returns Object with filtered data and list of removed attribute paths\n */\nconst handleInvisibleAttributes = (\n data: AnyData,\n { schema, initialValues = {}, components = {} }: HandleOptions\n): {\n data: AnyData;\n removedAttributes: RemovedFieldPath[];\n} => {\n if (!schema?.attributes) return { data, removedAttributes: [] };\n\n const removedAttributes = collectInvisibleAttributes(data, schema, components);\n\n const filteredData = filterDataByRemovedPaths(\n data,\n initialValues,\n schema,\n components,\n removedAttributes\n );\n\n return {\n data: filteredData,\n removedAttributes,\n };\n};\n\nexport {\n removeProhibitedFields,\n prepareRelations,\n prepareTempKeys,\n removeFieldsThatDontExistOnSchema,\n transformDocument,\n handleInvisibleAttributes,\n getDirectParent,\n};\nexport type { AnyData };\n"],"names":["BLOCK_LIST_ATTRIBUTE_KEYS","getDirectParent","data","path","undefined","isNumericIndex","value","test","segments","split","parentPath","slice","current","segment","Array","isArray","Number","traverseData","predicate","transform","schema","components","traverse","datum","attributes","Object","entries","reduce","acc","key","attribute","includes","type","repeatable","componentValue","map","componentData","component","dynamicZoneValue","__component","removeProhibitedFields","prohibitedFields","prepareRelations","connect","disconnect","prepareTempKeys","length","keys","generateNKeysBetween","index","__temp_key__","removeFieldsThatDontExistOnSchema","schemaKeys","dataKeys","keysToRemove","filter","revisedData","DOCUMENT_META_FIELDS","structuredClone","removeNullValues","transformDocument","document","transformations","pipe","getItemInitialValue","initialValue","item","matchingInitialItem","find","initialItem","collectInvisibleAttributes","rulesEngine","createRulesEngine","removedPaths","evaluatedData","attrName","attrDef","fullPath","join","visible","condition","conditions","isVisible","evaluate","push","compSchema","forEach","nestedPaths","dzItem","compUID","filterDataByRemovedPaths","initialValues","currentPath","result","userProvided","hasOwn","currentValue","componentInitialValue","cleaned","processedItem","id","handleInvisibleAttributes","removedAttributes","filteredData"],"mappings":";;;;;;;AA0BA,MAAMA,yBAA4B,GAAA;AAAC,IAAA,aAAA;AAAe,IAAA;AAAe,CAAA;AAEjE;;;IAIA,MAAMC,eAAkB,GAAA,CAACC,IAAeC,EAAAA,IAAAA,GAAAA;IACtC,IAAI,CAACA,MAAM,OAAOC,SAAAA;AAClB,IAAA,MAAMC,cAAiB,GAAA,CAACC,KAAkB,GAAA,OAAA,CAAQC,IAAI,CAACD,KAAAA,CAAAA;IACvD,MAAME,QAAAA,GAAWL,IAAKM,CAAAA,KAAK,CAAC,GAAA,CAAA;AAC5B,IAAA,MAAMC,UAAaF,GAAAA,QAAAA,CAASG,KAAK,CAAC,GAAG,CAAC,CAAA,CAAA;AACtC,IAAA,IAAIC,OAAmBV,GAAAA,IAAAA;IAEvB,KAAK,MAAMW,WAAWH,UAAY,CAAA;QAChC,IAAIE,OAAAA,IAAW,MAAM,OAAOR,SAAAA;AAE5B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