@strapi/content-manager 0.0.0-experimental.f49f46a1c17445a39e8af3f63124bcccf73842e6 → 0.0.0-experimental.f6f58027a6338ed795382f2d1c8882158b242361
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/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -1
- package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-D3ZWDAHG.mjs → ComponentConfigurationPage-D4H-v0et.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-D3ZWDAHG.mjs.map → ComponentConfigurationPage-D4H-v0et.mjs.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-ClKl_TA2.js → ComponentConfigurationPage-DdkVGfXC.js} +4 -5
- package/dist/_chunks/{ComponentConfigurationPage-ClKl_TA2.js.map → ComponentConfigurationPage-DdkVGfXC.js.map} +1 -1
- package/dist/_chunks/{ComponentIcon-BXdiCGQp.js → ComponentIcon-CRbtQEUV.js} +2 -3
- package/dist/_chunks/{ComponentIcon-BXdiCGQp.js.map → ComponentIcon-CRbtQEUV.js.map} +1 -1
- package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -1
- package/dist/_chunks/{EditConfigurationPage-BYCBSJxP.mjs → EditConfigurationPage-D1nvB7Br.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-BYCBSJxP.mjs.map → EditConfigurationPage-D1nvB7Br.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-OWez0Kxp.js → EditConfigurationPage-LYEvR4fW.js} +4 -5
- package/dist/_chunks/{EditConfigurationPage-OWez0Kxp.js.map → EditConfigurationPage-LYEvR4fW.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-5pdbvsO_.mjs → EditViewPage-Bcnff6Vd.mjs} +11 -74
- package/dist/_chunks/EditViewPage-Bcnff6Vd.mjs.map +1 -0
- package/dist/_chunks/{EditViewPage-BEs5iGDi.js → EditViewPage-DqelJ9UK.js} +14 -78
- package/dist/_chunks/EditViewPage-DqelJ9UK.js.map +1 -0
- package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -1
- package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -1
- package/dist/_chunks/{Form-CoRxWJOz.js → Form-CnHfBeiB.js} +5 -6
- package/dist/_chunks/{Form-CoRxWJOz.js.map → Form-CnHfBeiB.js.map} +1 -1
- package/dist/_chunks/{Form-CGwM_-5c.mjs → Form-CzPCJi3B.mjs} +3 -3
- package/dist/_chunks/{Form-CGwM_-5c.mjs.map → Form-CzPCJi3B.mjs.map} +1 -1
- package/dist/_chunks/{History-DEvr3Q_V.mjs → History-CcmSn3Mj.mjs} +33 -9
- package/dist/_chunks/History-CcmSn3Mj.mjs.map +1 -0
- package/dist/_chunks/{History-BcUTQrfG.js → History-zArjENzj.js} +45 -22
- package/dist/_chunks/History-zArjENzj.js.map +1 -0
- package/dist/_chunks/{Field-DNHm4wHx.js → Input-CDHKQd7o.js} +1321 -1317
- package/dist/_chunks/Input-CDHKQd7o.js.map +1 -0
- package/dist/_chunks/{Field-DcKuFHYK.mjs → Input-aV8SSoTa.mjs} +1235 -1231
- package/dist/_chunks/Input-aV8SSoTa.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-BM4zZZcM.mjs → ListConfigurationPage-BPvzENJJ.mjs} +3 -3
- package/dist/_chunks/{ListConfigurationPage-BM4zZZcM.mjs.map → ListConfigurationPage-BPvzENJJ.mjs.map} +1 -1
- package/dist/_chunks/{ListConfigurationPage-BE_Ho7tV.js → ListConfigurationPage-ByZAO_9H.js} +4 -5
- package/dist/_chunks/{ListConfigurationPage-BE_Ho7tV.js.map → ListConfigurationPage-ByZAO_9H.js.map} +1 -1
- package/dist/_chunks/{ListViewPage-BkT8Eao0.js → ListViewPage-BVKBeQAA.js} +61 -58
- package/dist/_chunks/ListViewPage-BVKBeQAA.js.map +1 -0
- package/dist/_chunks/{ListViewPage-BK2mkrql.mjs → ListViewPage-HljQVnFH.mjs} +55 -51
- package/dist/_chunks/ListViewPage-HljQVnFH.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-C8mtyc4H.js → NoContentTypePage-BV5zfDxr.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-C8mtyc4H.js.map → NoContentTypePage-BV5zfDxr.js.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-BvcAutu9.mjs → NoContentTypePage-BfHaSM-K.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-BvcAutu9.mjs.map → NoContentTypePage-BfHaSM-K.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-BmbRz7PR.mjs → NoPermissionsPage-D6ze2nQL.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-BmbRz7PR.mjs.map → NoPermissionsPage-D6ze2nQL.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-B5Y9Y78B.js → NoPermissionsPage-vdNpc6jb.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-B5Y9Y78B.js.map → NoPermissionsPage-vdNpc6jb.js.map} +1 -1
- package/dist/_chunks/{Preview-BF8ZDYqS.js → Preview-DEHdENT1.js} +35 -16
- package/dist/_chunks/Preview-DEHdENT1.js.map +1 -0
- package/dist/_chunks/{Preview-DcexhKJE.mjs → Preview-vfWOtPG5.mjs} +36 -16
- package/dist/_chunks/Preview-vfWOtPG5.mjs.map +1 -0
- package/dist/_chunks/{Relations-BjIzc4EK.mjs → Relations-B7_hbF0w.mjs} +9 -10
- package/dist/_chunks/Relations-B7_hbF0w.mjs.map +1 -0
- package/dist/_chunks/{Relations-BKnoK1R0.js → Relations-DcoOBejP.js} +10 -12
- package/dist/_chunks/Relations-DcoOBejP.js.map +1 -0
- package/dist/_chunks/{en-DTWPCdTS.js → en-BR48D_RH.js} +11 -3
- package/dist/_chunks/{en-DTWPCdTS.js.map → en-BR48D_RH.js.map} +1 -1
- package/dist/_chunks/{en-CfIXaZf9.mjs → en-D65uIF6Y.mjs} +11 -3
- package/dist/_chunks/{en-CfIXaZf9.mjs.map → en-D65uIF6Y.mjs.map} +1 -1
- package/dist/_chunks/{fr-B2Kyv8Z9.js → fr-C43IbhA_.js} +4 -1
- package/dist/_chunks/{fr-B2Kyv8Z9.js.map → fr-C43IbhA_.js.map} +1 -1
- package/dist/_chunks/{fr--pg5jUbt.mjs → fr-DBseuRuB.mjs} +4 -1
- package/dist/_chunks/{fr--pg5jUbt.mjs.map → fr-DBseuRuB.mjs.map} +1 -1
- package/dist/_chunks/hooks-BAaaKPS_.js.map +1 -1
- package/dist/_chunks/{index-DOzAG2cq.js → index-CxLSGwnk.js} +482 -188
- package/dist/_chunks/index-CxLSGwnk.js.map +1 -0
- package/dist/_chunks/{index-BW-rXkjn.mjs → index-EH8ZtHd5.mjs} +500 -205
- package/dist/_chunks/index-EH8ZtHd5.mjs.map +1 -0
- package/dist/_chunks/{layout-DFVbgjp2.mjs → layout-CxDMdJ13.mjs} +4 -4
- package/dist/_chunks/{layout-DFVbgjp2.mjs.map → layout-CxDMdJ13.mjs.map} +1 -1
- package/dist/_chunks/{layout-RC3W2obV.js → layout-DSeUTfMv.js} +5 -6
- package/dist/_chunks/{layout-RC3W2obV.js.map → layout-DSeUTfMv.js.map} +1 -1
- package/dist/_chunks/objects-BcXOv6_9.js.map +1 -1
- package/dist/_chunks/objects-D6yBsdmx.mjs.map +1 -1
- package/dist/_chunks/{relations-Dogh8HWI.mjs → relations-B8_Uu38Q.mjs} +17 -3
- package/dist/_chunks/relations-B8_Uu38Q.mjs.map +1 -0
- package/dist/_chunks/{relations-zam7-5H7.js → relations-S5nNKdN3.js} +16 -2
- package/dist/_chunks/relations-S5nNKdN3.js.map +1 -0
- package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js → useDragAndDrop-BMtgCYzL.js} +5 -9
- package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js.map → useDragAndDrop-BMtgCYzL.js.map} +1 -1
- package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs → useDragAndDrop-DJ6jqvZN.mjs} +4 -7
- package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs.map → useDragAndDrop-DJ6jqvZN.mjs.map} +1 -1
- package/dist/_chunks/{useDebounce-CtcjDB3L.js → usePrev-B9w_-eYc.js} +1 -14
- package/dist/_chunks/usePrev-B9w_-eYc.js.map +1 -0
- package/dist/_chunks/usePrev-DH6iah0A.mjs +16 -0
- package/dist/_chunks/usePrev-DH6iah0A.mjs.map +1 -0
- package/dist/admin/index.js +2 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +6 -5
- package/dist/admin/src/content-manager.d.ts +3 -2
- package/dist/admin/src/exports.d.ts +1 -0
- package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
- package/dist/admin/src/hooks/useDocument.d.ts +19 -2
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +7 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/utils/prismLanguages.d.ts +49 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +1 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +4 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +4 -1
- package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +27 -0
- package/dist/admin/src/pages/EditView/utils/data.d.ts +1 -0
- package/dist/admin/src/preview/pages/Preview.d.ts +1 -1
- package/dist/admin/src/preview/services/preview.d.ts +1 -1
- package/dist/admin/src/services/api.d.ts +1 -1
- package/dist/admin/src/services/components.d.ts +2 -2
- package/dist/admin/src/services/contentTypes.d.ts +3 -3
- package/dist/admin/src/services/documents.d.ts +16 -19
- package/dist/admin/src/services/init.d.ts +1 -1
- package/dist/admin/src/services/relations.d.ts +2 -2
- package/dist/admin/src/services/uid.d.ts +3 -3
- package/dist/server/index.js +230 -187
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +231 -187
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/controllers/utils/metadata.d.ts +1 -0
- package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
- package/dist/server/src/history/controllers/history-version.d.ts +1 -1
- package/dist/server/src/history/controllers/history-version.d.ts.map +1 -1
- package/dist/server/src/history/services/history.d.ts +3 -3
- package/dist/server/src/history/services/history.d.ts.map +1 -1
- package/dist/server/src/history/services/utils.d.ts +6 -10
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +3 -2
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -1
- package/dist/server/src/preview/index.d.ts.map +1 -1
- package/dist/server/src/preview/services/index.d.ts +1 -0
- package/dist/server/src/preview/services/index.d.ts.map +1 -1
- package/dist/server/src/preview/services/preview-config.d.ts +2 -0
- package/dist/server/src/preview/services/preview-config.d.ts.map +1 -1
- package/dist/server/src/preview/utils.d.ts +1 -0
- package/dist/server/src/preview/utils.d.ts.map +1 -1
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/services/document-metadata.d.ts +4 -2
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +3 -2
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
- package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
- package/dist/server/src/services/utils/populate.d.ts +2 -2
- package/dist/server/src/services/utils/populate.d.ts.map +1 -1
- package/package.json +11 -10
- package/dist/_chunks/EditViewPage-5pdbvsO_.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-BEs5iGDi.js.map +0 -1
- package/dist/_chunks/Field-DNHm4wHx.js.map +0 -1
- package/dist/_chunks/Field-DcKuFHYK.mjs.map +0 -1
- package/dist/_chunks/History-BcUTQrfG.js.map +0 -1
- package/dist/_chunks/History-DEvr3Q_V.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-BK2mkrql.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-BkT8Eao0.js.map +0 -1
- package/dist/_chunks/Preview-BF8ZDYqS.js.map +0 -1
- package/dist/_chunks/Preview-DcexhKJE.mjs.map +0 -1
- package/dist/_chunks/Relations-BKnoK1R0.js.map +0 -1
- package/dist/_chunks/Relations-BjIzc4EK.mjs.map +0 -1
- package/dist/_chunks/index-BW-rXkjn.mjs.map +0 -1
- package/dist/_chunks/index-DOzAG2cq.js.map +0 -1
- package/dist/_chunks/relations-Dogh8HWI.mjs.map +0 -1
- package/dist/_chunks/relations-zam7-5H7.js.map +0 -1
- package/dist/_chunks/useDebounce-CtcjDB3L.js.map +0 -1
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs +0 -29
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +0 -1
- package/dist/admin/src/preview/constants.d.ts +0 -1
- package/dist/server/src/preview/constants.d.ts +0 -2
- package/dist/server/src/preview/constants.d.ts.map +0 -1
@@ -1,25 +1,76 @@
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
2
2
|
import * as React from "react";
|
3
3
|
import { useState, useEffect, useCallback, memo } from "react";
|
4
|
-
import { useStrapiApp, createContext, useField,
|
5
|
-
import { Box, SingleSelect, SingleSelectOption, Typography, Flex, BaseLink, Button, Popover, Field, Tooltip, IconButton, useComposedRefs, Portal, FocusTrap, Divider, VisuallyHidden, Grid as Grid$1,
|
6
|
-
import
|
4
|
+
import { useStrapiApp, createContext, useField, useForm, useNotification, useAPIErrorHandler, useQueryParams, useFocusInputField, InputRenderer as InputRenderer$1 } from "@strapi/admin/strapi-admin";
|
5
|
+
import { Box, SingleSelect, SingleSelectOption, Typography, Flex, BaseLink, Button, Popover, Field, Tooltip, IconButton, useComposedRefs, Portal, FocusTrap, Divider, VisuallyHidden, Accordion, Menu, MenuItem, Grid as Grid$1, TextInput, IconButtonGroup, TextButton } from "@strapi/design-system";
|
6
|
+
import { CodeBlock as CodeBlock$1, HeadingOne, HeadingTwo, HeadingThree, HeadingFour, HeadingFive, HeadingSix, Image as Image$1, NumberList, BulletList, Paragraph, Quotes, Link as Link$1, Drag, Collapse, Bold, Italic, Underline, StrikeThrough, Code, Expand, PlusCircle, Trash, More, EyeStriked, CheckCircle, WarningCircle, Loader, ArrowClockwise, Plus } from "@strapi/icons";
|
7
7
|
import { useIntl } from "react-intl";
|
8
|
-
import {
|
9
|
-
import { generateNKeysBetween } from "fractional-indexing";
|
10
|
-
import { u as useComponent, C as ComponentProvider, M as MemoizedRelationsField } from "./Relations-BjIzc4EK.mjs";
|
11
|
-
import { Code, HeadingOne, HeadingTwo, HeadingThree, HeadingFour, HeadingFive, HeadingSix, Image as Image$1, NumberList, BulletList, Paragraph, Quotes, Link as Link$1, Drag, Collapse, Bold, Italic, Underline, StrikeThrough, Expand, PlusCircle, Plus, Trash, EyeStriked, CheckCircle, WarningCircle, Loader, ArrowClockwise, More } from "@strapi/icons";
|
8
|
+
import { g as getTranslation, m as useDocLayout, c as useDoc, n as createDefaultForm, t as transformDocument, e as contentManagerApi, o as CLONE_PATH, d as buildValidParams, f as useDocumentRBAC, S as SINGLE_TYPES } from "./index-EH8ZtHd5.mjs";
|
12
9
|
import { styled, css, keyframes } from "styled-components";
|
13
|
-
import { C as ComponentIcon, a as COMPONENT_ICONS } from "./ComponentIcon-u4bIXTFY.mjs";
|
14
|
-
import { getEmptyImage } from "react-dnd-html5-backend";
|
15
|
-
import { a as DIRECTIONS, u as useDragAndDrop, I as ItemTypes } from "./useDragAndDrop-DdHgKsqq.mjs";
|
16
|
-
import { g as getIn } from "./objects-D6yBsdmx.mjs";
|
17
10
|
import { Editor as Editor$1, Transforms, Node, Element, Range, Path, Point, createEditor } from "slate";
|
18
11
|
import { withHistory } from "slate-history";
|
19
12
|
import { useFocused, useSelected, ReactEditor, Editable, useSlate, Slate, withReact } from "slate-react";
|
20
|
-
import
|
13
|
+
import * as Prism from "prismjs";
|
14
|
+
import "prismjs/themes/prism-solarizedlight.css";
|
15
|
+
import "prismjs/components/prism-asmatmel";
|
16
|
+
import "prismjs/components/prism-bash";
|
17
|
+
import "prismjs/components/prism-basic";
|
18
|
+
import "prismjs/components/prism-c";
|
19
|
+
import "prismjs/components/prism-clojure";
|
20
|
+
import "prismjs/components/prism-cobol";
|
21
|
+
import "prismjs/components/prism-cpp";
|
22
|
+
import "prismjs/components/prism-csharp";
|
23
|
+
import "prismjs/components/prism-dart";
|
24
|
+
import "prismjs/components/prism-docker";
|
25
|
+
import "prismjs/components/prism-elixir";
|
26
|
+
import "prismjs/components/prism-erlang";
|
27
|
+
import "prismjs/components/prism-fortran";
|
28
|
+
import "prismjs/components/prism-fsharp";
|
29
|
+
import "prismjs/components/prism-go";
|
30
|
+
import "prismjs/components/prism-graphql";
|
31
|
+
import "prismjs/components/prism-groovy";
|
32
|
+
import "prismjs/components/prism-haskell";
|
33
|
+
import "prismjs/components/prism-haxe";
|
34
|
+
import "prismjs/components/prism-ini";
|
35
|
+
import "prismjs/components/prism-java";
|
36
|
+
import "prismjs/components/prism-javascript";
|
37
|
+
import "prismjs/components/prism-jsx";
|
38
|
+
import "prismjs/components/prism-json";
|
39
|
+
import "prismjs/components/prism-julia";
|
40
|
+
import "prismjs/components/prism-kotlin";
|
41
|
+
import "prismjs/components/prism-latex";
|
42
|
+
import "prismjs/components/prism-lua";
|
43
|
+
import "prismjs/components/prism-markdown";
|
44
|
+
import "prismjs/components/prism-matlab";
|
45
|
+
import "prismjs/components/prism-makefile";
|
46
|
+
import "prismjs/components/prism-objectivec";
|
47
|
+
import "prismjs/components/prism-perl";
|
48
|
+
import "prismjs/components/prism-php";
|
49
|
+
import "prismjs/components/prism-powershell";
|
50
|
+
import "prismjs/components/prism-python";
|
51
|
+
import "prismjs/components/prism-r";
|
52
|
+
import "prismjs/components/prism-ruby";
|
53
|
+
import "prismjs/components/prism-rust";
|
54
|
+
import "prismjs/components/prism-sas";
|
55
|
+
import "prismjs/components/prism-scala";
|
56
|
+
import "prismjs/components/prism-scheme";
|
57
|
+
import "prismjs/components/prism-sql";
|
58
|
+
import "prismjs/components/prism-stata";
|
59
|
+
import "prismjs/components/prism-swift";
|
60
|
+
import "prismjs/components/prism-typescript";
|
61
|
+
import "prismjs/components/prism-tsx";
|
62
|
+
import "prismjs/components/prism-vbnet";
|
63
|
+
import "prismjs/components/prism-yaml";
|
64
|
+
import { p as prefixFileUrlWithBackendUrl, u as usePrev } from "./usePrev-DH6iah0A.mjs";
|
65
|
+
import { a as DIRECTIONS, u as useDragAndDrop, I as ItemTypes } from "./useDragAndDrop-DJ6jqvZN.mjs";
|
21
66
|
import * as Toolbar from "@radix-ui/react-toolbar";
|
22
|
-
import {
|
67
|
+
import { getEmptyImage } from "react-dnd-html5-backend";
|
68
|
+
import { useMatch, useLocation } from "react-router-dom";
|
69
|
+
import { g as getIn } from "./objects-D6yBsdmx.mjs";
|
70
|
+
import { u as useComponent, C as ComponentProvider, M as MemoizedRelationsField } from "./Relations-B7_hbF0w.mjs";
|
71
|
+
import pipe$1 from "lodash/fp/pipe";
|
72
|
+
import { C as ComponentIcon, a as COMPONENT_ICONS } from "./ComponentIcon-u4bIXTFY.mjs";
|
73
|
+
import { a as useDebounce } from "./relations-B8_Uu38Q.mjs";
|
23
74
|
import CodeMirror from "codemirror5";
|
24
75
|
import sanitizeHtml from "sanitize-html";
|
25
76
|
import { getLanguage, highlight, highlightAuto } from "highlight.js";
|
@@ -35,93 +86,6 @@ import sub from "markdown-it-sub";
|
|
35
86
|
import sup from "markdown-it-sup";
|
36
87
|
import "highlight.js/styles/solarized-dark.css";
|
37
88
|
import "codemirror5/addon/display/placeholder";
|
38
|
-
const BLOCK_LIST_ATTRIBUTE_KEYS = ["__component", "__temp_key__"];
|
39
|
-
const traverseData = (predicate, transform) => (schema, components = {}) => (data = {}) => {
|
40
|
-
const traverse = (datum, attributes) => {
|
41
|
-
return Object.entries(datum).reduce((acc, [key, value]) => {
|
42
|
-
const attribute = attributes[key];
|
43
|
-
if (BLOCK_LIST_ATTRIBUTE_KEYS.includes(key) || value === null || value === void 0) {
|
44
|
-
acc[key] = value;
|
45
|
-
return acc;
|
46
|
-
}
|
47
|
-
if (attribute.type === "component") {
|
48
|
-
if (attribute.repeatable) {
|
49
|
-
const componentValue = predicate(attribute, value) ? transform(value, attribute) : value;
|
50
|
-
acc[key] = componentValue.map(
|
51
|
-
(componentData) => traverse(componentData, components[attribute.component]?.attributes ?? {})
|
52
|
-
);
|
53
|
-
} else {
|
54
|
-
const componentValue = predicate(attribute, value) ? transform(value, attribute) : value;
|
55
|
-
acc[key] = traverse(componentValue, components[attribute.component]?.attributes ?? {});
|
56
|
-
}
|
57
|
-
} else if (attribute.type === "dynamiczone") {
|
58
|
-
const dynamicZoneValue = predicate(attribute, value) ? transform(value, attribute) : value;
|
59
|
-
acc[key] = dynamicZoneValue.map(
|
60
|
-
(componentData) => traverse(componentData, components[componentData.__component]?.attributes ?? {})
|
61
|
-
);
|
62
|
-
} else if (predicate(attribute, value)) {
|
63
|
-
acc[key] = transform(value, attribute);
|
64
|
-
} else {
|
65
|
-
acc[key] = value;
|
66
|
-
}
|
67
|
-
return acc;
|
68
|
-
}, {});
|
69
|
-
};
|
70
|
-
return traverse(data, schema.attributes);
|
71
|
-
};
|
72
|
-
const removeProhibitedFields = (prohibitedFields) => traverseData(
|
73
|
-
(attribute) => prohibitedFields.includes(attribute.type),
|
74
|
-
() => ""
|
75
|
-
);
|
76
|
-
const prepareRelations = traverseData(
|
77
|
-
(attribute) => attribute.type === "relation",
|
78
|
-
() => ({
|
79
|
-
connect: [],
|
80
|
-
disconnect: []
|
81
|
-
})
|
82
|
-
);
|
83
|
-
const prepareTempKeys = traverseData(
|
84
|
-
(attribute) => attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone",
|
85
|
-
(data) => {
|
86
|
-
if (Array.isArray(data) && data.length > 0) {
|
87
|
-
const keys = generateNKeysBetween(void 0, void 0, data.length);
|
88
|
-
return data.map((datum, index) => ({
|
89
|
-
...datum,
|
90
|
-
__temp_key__: keys[index]
|
91
|
-
}));
|
92
|
-
}
|
93
|
-
return data;
|
94
|
-
}
|
95
|
-
);
|
96
|
-
const removeFieldsThatDontExistOnSchema = (schema) => (data) => {
|
97
|
-
const schemaKeys = Object.keys(schema.attributes);
|
98
|
-
const dataKeys = Object.keys(data);
|
99
|
-
const keysToRemove = dataKeys.filter((key) => !schemaKeys.includes(key));
|
100
|
-
const revisedData = [...keysToRemove, ...DOCUMENT_META_FIELDS].reduce((acc, key) => {
|
101
|
-
delete acc[key];
|
102
|
-
return acc;
|
103
|
-
}, structuredClone(data));
|
104
|
-
return revisedData;
|
105
|
-
};
|
106
|
-
const removeNullValues = (data) => {
|
107
|
-
return Object.entries(data).reduce((acc, [key, value]) => {
|
108
|
-
if (value === null) {
|
109
|
-
return acc;
|
110
|
-
}
|
111
|
-
acc[key] = value;
|
112
|
-
return acc;
|
113
|
-
}, {});
|
114
|
-
};
|
115
|
-
const transformDocument = (schema, components = {}) => (document2) => {
|
116
|
-
const transformations = pipe$1(
|
117
|
-
removeFieldsThatDontExistOnSchema(schema),
|
118
|
-
removeProhibitedFields(["password"])(schema, components),
|
119
|
-
removeNullValues,
|
120
|
-
prepareRelations(schema, components),
|
121
|
-
prepareTempKeys(schema, components)
|
122
|
-
);
|
123
|
-
return transformations(document2);
|
124
|
-
};
|
125
89
|
const componentStore = /* @__PURE__ */ new Map();
|
126
90
|
const useLazyComponents = (componentUids = []) => {
|
127
91
|
const [lazyComponentStore, setLazyComponentStore] = useState(Object.fromEntries(componentStore));
|
@@ -163,7 +127,8 @@ const useLazyComponents = (componentUids = []) => {
|
|
163
127
|
const codeLanguages = [
|
164
128
|
{
|
165
129
|
value: "asm",
|
166
|
-
label: "Assembly"
|
130
|
+
label: "Assembly",
|
131
|
+
decorate: "asmatmel"
|
167
132
|
},
|
168
133
|
{
|
169
134
|
value: "bash",
|
@@ -199,7 +164,8 @@ const codeLanguages = [
|
|
199
164
|
},
|
200
165
|
{
|
201
166
|
value: "dockerfile",
|
202
|
-
label: "Dockerfile"
|
167
|
+
label: "Dockerfile",
|
168
|
+
decorate: "docker"
|
203
169
|
},
|
204
170
|
{
|
205
171
|
value: "elixir",
|
@@ -355,7 +321,8 @@ const codeLanguages = [
|
|
355
321
|
},
|
356
322
|
{
|
357
323
|
value: "typescript",
|
358
|
-
label: "TypeScript"
|
324
|
+
label: "TypeScript",
|
325
|
+
decorate: "ts"
|
359
326
|
},
|
360
327
|
{
|
361
328
|
value: "tsx",
|
@@ -371,7 +338,8 @@ const codeLanguages = [
|
|
371
338
|
},
|
372
339
|
{
|
373
340
|
value: "yaml",
|
374
|
-
label: "YAML"
|
341
|
+
label: "YAML",
|
342
|
+
decorate: "yml"
|
375
343
|
}
|
376
344
|
];
|
377
345
|
const baseHandleConvert = (editor, attributesToSet) => {
|
@@ -437,6 +405,29 @@ const pressEnterTwiceToExit = (editor) => {
|
|
437
405
|
});
|
438
406
|
}
|
439
407
|
};
|
408
|
+
const decorateCode = ([node, path]) => {
|
409
|
+
const ranges = [];
|
410
|
+
if (!Element.isElement(node) || node.type !== "code") return ranges;
|
411
|
+
const text = Node.string(node);
|
412
|
+
const language = codeLanguages.find((lang) => lang.value === node.language);
|
413
|
+
const decorateKey = language?.decorate ?? language?.value;
|
414
|
+
const selectedLanguage = Prism.languages[decorateKey || "plaintext"];
|
415
|
+
const tokens = Prism.tokenize(text, selectedLanguage);
|
416
|
+
let start = 0;
|
417
|
+
for (const token of tokens) {
|
418
|
+
const length = token.length;
|
419
|
+
const end = start + length;
|
420
|
+
if (typeof token !== "string") {
|
421
|
+
ranges.push({
|
422
|
+
anchor: { path, offset: start },
|
423
|
+
focus: { path, offset: end },
|
424
|
+
className: `token ${token.type}`
|
425
|
+
});
|
426
|
+
}
|
427
|
+
start = end;
|
428
|
+
}
|
429
|
+
return ranges;
|
430
|
+
};
|
440
431
|
const CodeBlock = styled.pre`
|
441
432
|
border-radius: ${({ theme }) => theme.borderRadius};
|
442
433
|
background-color: ${({ theme }) => theme.colors.neutral100};
|
@@ -508,7 +499,7 @@ const CodeEditor = (props) => {
|
|
508
499
|
const codeBlocks = {
|
509
500
|
code: {
|
510
501
|
renderElement: (props) => /* @__PURE__ */ jsx(CodeEditor, { ...props }),
|
511
|
-
icon:
|
502
|
+
icon: CodeBlock$1,
|
512
503
|
label: {
|
513
504
|
id: "components.Blocks.blocks.code",
|
514
505
|
defaultMessage: "Code block"
|
@@ -521,8 +512,7 @@ const codeBlocks = {
|
|
521
512
|
handleEnterKey(editor) {
|
522
513
|
pressEnterTwiceToExit(editor);
|
523
514
|
},
|
524
|
-
snippets: ["```"]
|
525
|
-
dragHandleTopMargin: "10px"
|
515
|
+
snippets: ["```"]
|
526
516
|
}
|
527
517
|
};
|
528
518
|
const H1 = styled(Typography).attrs({ tag: "h1" })`
|
@@ -697,8 +687,7 @@ const ImageDialog = () => {
|
|
697
687
|
const [isOpen, setIsOpen] = React.useState(true);
|
698
688
|
const { editor } = useBlocksEditorContext("ImageDialog");
|
699
689
|
const components = useStrapiApp("ImageDialog", (state) => state.components);
|
700
|
-
if (!components || !isOpen)
|
701
|
-
return null;
|
690
|
+
if (!components || !isOpen) return null;
|
702
691
|
const MediaLibraryDialog = components["media-library"];
|
703
692
|
const insertImages = (images) => {
|
704
693
|
Transforms.unwrapNodes(editor, {
|
@@ -707,14 +696,12 @@ const ImageDialog = () => {
|
|
707
696
|
});
|
708
697
|
const nodeEntryBeingReplaced = Editor$1.above(editor, {
|
709
698
|
match(node) {
|
710
|
-
if (Editor$1.isEditor(node))
|
711
|
-
return false;
|
699
|
+
if (Editor$1.isEditor(node)) return false;
|
712
700
|
const isInlineNode = ["text", "link"].includes(node.type);
|
713
701
|
return !isInlineNode;
|
714
702
|
}
|
715
703
|
});
|
716
|
-
if (!nodeEntryBeingReplaced)
|
717
|
-
return;
|
704
|
+
if (!nodeEntryBeingReplaced) return;
|
718
705
|
const [, pathToInsert] = nodeEntryBeingReplaced;
|
719
706
|
Transforms.removeNodes(editor);
|
720
707
|
const nodesToInsert = images.map((image) => {
|
@@ -892,8 +879,7 @@ const LinkContent = React.forwardRef(
|
|
892
879
|
ReactEditor.focus(editor);
|
893
880
|
};
|
894
881
|
React.useEffect(() => {
|
895
|
-
if (popoverOpen)
|
896
|
-
linkInputRef.current?.focus();
|
882
|
+
if (popoverOpen) linkInputRef.current?.focus();
|
897
883
|
}, [popoverOpen]);
|
898
884
|
const inputNotDirty = !linkText || !linkUrl || link.url && link.url === linkUrl && elementText && elementText === linkText;
|
899
885
|
return /* @__PURE__ */ jsxs(Popover.Root, { open: popoverOpen, children: [
|
@@ -963,11 +949,11 @@ const LinkContent = React.forwardRef(
|
|
963
949
|
),
|
964
950
|
/* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
965
951
|
/* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick: handleClose, children: formatMessage({
|
966
|
-
id: "
|
952
|
+
id: "global.cancel",
|
967
953
|
defaultMessage: "Cancel"
|
968
954
|
}) }),
|
969
955
|
/* @__PURE__ */ jsx(Button, { disabled: Boolean(inputNotDirty) || isSaveDisabled, onClick: handleSave, children: formatMessage({
|
970
|
-
id: "
|
956
|
+
id: "global.save",
|
971
957
|
defaultMessage: "Save"
|
972
958
|
}) })
|
973
959
|
] })
|
@@ -1048,8 +1034,7 @@ const isText$1 = (node) => {
|
|
1048
1034
|
return Node.isNode(node) && !Editor$1.isEditor(node) && node.type === "text";
|
1049
1035
|
};
|
1050
1036
|
const handleBackspaceKeyOnList = (editor, event) => {
|
1051
|
-
if (!editor.selection)
|
1052
|
-
return;
|
1037
|
+
if (!editor.selection) return;
|
1053
1038
|
const [currentListItem, currentListItemPath] = Editor$1.parent(editor, editor.selection.anchor);
|
1054
1039
|
const [currentList, currentListPath] = Editor$1.parent(editor, currentListItemPath);
|
1055
1040
|
const isListEmpty = currentList.children.length === 1 && isText$1(currentListItem.children[0]) && currentListItem.children[0].text === "";
|
@@ -1158,8 +1143,7 @@ const handleEnterKeyOnList = (editor) => {
|
|
1158
1143
|
};
|
1159
1144
|
const handleConvertToList = (editor, format) => {
|
1160
1145
|
const convertedPath = baseHandleConvert(editor, { type: "list-item" });
|
1161
|
-
if (!convertedPath)
|
1162
|
-
return;
|
1146
|
+
if (!convertedPath) return;
|
1163
1147
|
Transforms.wrapNodes(editor, { type: "list", format, children: [] }, { at: convertedPath });
|
1164
1148
|
};
|
1165
1149
|
const handleTabOnList = (editor) => {
|
@@ -1171,8 +1155,7 @@ const handleTabOnList = (editor) => {
|
|
1171
1155
|
}
|
1172
1156
|
const [currentListItem, currentListItemPath] = currentListItemEntry;
|
1173
1157
|
const [currentList] = Editor$1.parent(editor, currentListItemPath);
|
1174
|
-
if (currentListItem === currentList.children[0])
|
1175
|
-
return;
|
1158
|
+
if (currentListItem === currentList.children[0]) return;
|
1176
1159
|
const currentListItemIndex = currentList.children.findIndex((item) => item === currentListItem);
|
1177
1160
|
const previousNode = currentList.children[currentListItemIndex - 1];
|
1178
1161
|
if (previousNode.type === "list") {
|
@@ -1308,13 +1291,13 @@ const quoteBlocks = {
|
|
1308
1291
|
handleEnterKey(editor) {
|
1309
1292
|
pressEnterTwiceToExit(editor);
|
1310
1293
|
},
|
1311
|
-
snippets: [">"]
|
1312
|
-
dragHandleTopMargin: "6px"
|
1294
|
+
snippets: [">"]
|
1313
1295
|
}
|
1314
1296
|
};
|
1315
1297
|
const ToolbarWrapper = styled(Flex)`
|
1316
1298
|
&[aria-disabled='true'] {
|
1317
1299
|
cursor: not-allowed;
|
1300
|
+
background: ${({ theme }) => theme.colors.neutral150};
|
1318
1301
|
}
|
1319
1302
|
`;
|
1320
1303
|
const Separator = styled(Toolbar.Separator)`
|
@@ -1325,7 +1308,7 @@ const Separator = styled(Toolbar.Separator)`
|
|
1325
1308
|
const FlexButton = styled(Flex)`
|
1326
1309
|
// Inherit the not-allowed cursor from ToolbarWrapper when disabled
|
1327
1310
|
&[aria-disabled] {
|
1328
|
-
cursor:
|
1311
|
+
cursor: not-allowed;
|
1329
1312
|
}
|
1330
1313
|
|
1331
1314
|
&[aria-disabled='false'] {
|
@@ -1539,8 +1522,7 @@ const isListNode = (node) => {
|
|
1539
1522
|
const ListButton = ({ block, format }) => {
|
1540
1523
|
const { editor, disabled, blocks } = useBlocksEditorContext("ListButton");
|
1541
1524
|
const isListActive = () => {
|
1542
|
-
if (!editor.selection)
|
1543
|
-
return false;
|
1525
|
+
if (!editor.selection) return false;
|
1544
1526
|
const currentListEntry = Editor$1.above(editor, {
|
1545
1527
|
match: (node) => !Editor$1.isEditor(node) && node.type === "list",
|
1546
1528
|
at: editor.selection.anchor
|
@@ -1614,8 +1596,7 @@ const LinkButton = ({ disabled }) => {
|
|
1614
1596
|
const { editor } = useBlocksEditorContext("LinkButton");
|
1615
1597
|
const isLinkActive = () => {
|
1616
1598
|
const { selection } = editor;
|
1617
|
-
if (!selection)
|
1618
|
-
return false;
|
1599
|
+
if (!selection) return false;
|
1619
1600
|
const [match] = Array.from(
|
1620
1601
|
Editor$1.nodes(editor, {
|
1621
1602
|
at: Editor$1.unhangRange(editor, selection),
|
@@ -1679,7 +1660,7 @@ const BlocksToolbar = () => {
|
|
1679
1660
|
return false;
|
1680
1661
|
};
|
1681
1662
|
const isButtonDisabled = checkButtonDisabled();
|
1682
|
-
return /* @__PURE__ */ jsx(Toolbar.Root, { "aria-disabled": disabled, asChild: true, children: /* @__PURE__ */ jsxs(ToolbarWrapper, { gap: 2, padding: 2, children: [
|
1663
|
+
return /* @__PURE__ */ jsx(Toolbar.Root, { "aria-disabled": disabled, asChild: true, children: /* @__PURE__ */ jsxs(ToolbarWrapper, { gap: 2, padding: 2, width: "100%", children: [
|
1683
1664
|
/* @__PURE__ */ jsx(BlocksDropdown, {}),
|
1684
1665
|
/* @__PURE__ */ jsx(Separator, {}),
|
1685
1666
|
/* @__PURE__ */ jsx(Toolbar.ToggleGroup, { type: "multiple", asChild: true, children: /* @__PURE__ */ jsxs(Flex, { gap: 1, children: [
|
@@ -1753,30 +1734,32 @@ const DragIconButton = styled(IconButton)`
|
|
1753
1734
|
display: flex;
|
1754
1735
|
align-items: center;
|
1755
1736
|
justify-content: center;
|
1737
|
+
border: none;
|
1756
1738
|
border-radius: ${({ theme }) => theme.borderRadius};
|
1757
|
-
|
1758
|
-
|
1739
|
+
padding-left: ${({ theme }) => theme.spaces[0]};
|
1740
|
+
padding-right: ${({ theme }) => theme.spaces[0]};
|
1741
|
+
padding-top: ${({ theme }) => theme.spaces[1]};
|
1742
|
+
padding-bottom: ${({ theme }) => theme.spaces[1]};
|
1759
1743
|
visibility: hidden;
|
1760
1744
|
cursor: grab;
|
1761
1745
|
opacity: inherit;
|
1762
1746
|
margin-top: ${(props) => props.$dragHandleTopMargin ?? 0};
|
1763
1747
|
|
1764
1748
|
&:hover {
|
1765
|
-
background: ${({ theme }) => theme.colors.
|
1749
|
+
background: ${({ theme }) => theme.colors.neutral100};
|
1766
1750
|
}
|
1767
1751
|
&:active {
|
1768
1752
|
cursor: grabbing;
|
1753
|
+
background: ${({ theme }) => theme.colors.neutral150};
|
1769
1754
|
}
|
1770
1755
|
&[aria-disabled='true'] {
|
1771
|
-
|
1772
|
-
background: transparent;
|
1756
|
+
visibility: hidden;
|
1773
1757
|
}
|
1774
1758
|
svg {
|
1775
|
-
height: auto;
|
1776
1759
|
min-width: ${({ theme }) => theme.spaces[3]};
|
1777
1760
|
|
1778
1761
|
path {
|
1779
|
-
fill: ${({ theme }) => theme.colors.
|
1762
|
+
fill: ${({ theme }) => theme.colors.neutral500};
|
1780
1763
|
}
|
1781
1764
|
}
|
1782
1765
|
`;
|
@@ -1821,8 +1804,7 @@ const DragAndDropElement = ({
|
|
1821
1804
|
displayedValue: children
|
1822
1805
|
},
|
1823
1806
|
onDropItem(currentIndex, newIndex) {
|
1824
|
-
if (newIndex)
|
1825
|
-
handleMoveBlock(newIndex, currentIndex);
|
1807
|
+
if (newIndex) handleMoveBlock(newIndex, currentIndex);
|
1826
1808
|
}
|
1827
1809
|
});
|
1828
1810
|
const composedBoxRefs = useComposedRefs(blockRef, dropRef);
|
@@ -1928,7 +1910,7 @@ const baseRenderLeaf = (props, modifiers2) => {
|
|
1928
1910
|
}
|
1929
1911
|
return currentChildren;
|
1930
1912
|
}, props.children);
|
1931
|
-
return /* @__PURE__ */ jsx("span", { ...props.attributes, children: wrappedChildren });
|
1913
|
+
return /* @__PURE__ */ jsx("span", { ...props.attributes, className: props.leaf.className, children: wrappedChildren });
|
1932
1914
|
};
|
1933
1915
|
const baseRenderElement = ({
|
1934
1916
|
props,
|
@@ -1966,8 +1948,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
|
|
1966
1948
|
[modifiers2]
|
1967
1949
|
);
|
1968
1950
|
const handleMoveBlocks = (editor2, event) => {
|
1969
|
-
if (!editor2.selection)
|
1970
|
-
return;
|
1951
|
+
if (!editor2.selection) return;
|
1971
1952
|
const start = Range.start(editor2.selection);
|
1972
1953
|
const currentIndex = [start.path[0]];
|
1973
1954
|
let newIndexPosition = 0;
|
@@ -2104,8 +2085,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
|
|
2104
2085
|
}
|
2105
2086
|
};
|
2106
2087
|
const handleScrollSelectionIntoView = () => {
|
2107
|
-
if (!editor.selection)
|
2108
|
-
return;
|
2088
|
+
if (!editor.selection) return;
|
2109
2089
|
const domRange = ReactEditor.toDOMRange(editor, editor.selection);
|
2110
2090
|
const domRect = domRange.getBoundingClientRect();
|
2111
2091
|
const blocksInput = blocksRef.current;
|
@@ -2132,7 +2112,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
|
|
2132
2112
|
background: "neutral0",
|
2133
2113
|
color: "neutral800",
|
2134
2114
|
lineHeight: 6,
|
2135
|
-
paddingRight:
|
2115
|
+
paddingRight: 7,
|
2136
2116
|
paddingTop: 6,
|
2137
2117
|
paddingBottom: 3,
|
2138
2118
|
children: [
|
@@ -2143,6 +2123,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
|
|
2143
2123
|
readOnly: disabled,
|
2144
2124
|
placeholder,
|
2145
2125
|
isExpandedMode,
|
2126
|
+
decorate: decorateCode,
|
2146
2127
|
renderElement,
|
2147
2128
|
renderLeaf,
|
2148
2129
|
onKeyDown: handleKeyDown,
|
@@ -2299,8 +2280,7 @@ const InlineCode = styled.code`
|
|
2299
2280
|
`;
|
2300
2281
|
const baseCheckIsActive = (editor, name2) => {
|
2301
2282
|
const marks = Editor$1.marks(editor);
|
2302
|
-
if (!marks)
|
2303
|
-
return false;
|
2283
|
+
if (!marks) return false;
|
2304
2284
|
return Boolean(marks[name2]);
|
2305
2285
|
};
|
2306
2286
|
const baseHandleToggle = (editor, name2) => {
|
@@ -2466,6 +2446,7 @@ const ExpandIconButton = styled(IconButton)`
|
|
2466
2446
|
position: absolute;
|
2467
2447
|
bottom: 1.2rem;
|
2468
2448
|
right: 1.2rem;
|
2449
|
+
box-shadow: ${({ theme }) => theme.shadows.filterShadow};
|
2469
2450
|
`;
|
2470
2451
|
function useResetKey(value) {
|
2471
2452
|
const slateUpdatesCount = React.useRef(0);
|
@@ -2597,26 +2578,6 @@ const BlocksInput = React.forwardRef(
|
|
2597
2578
|
}
|
2598
2579
|
);
|
2599
2580
|
const MemoizedBlocksInput = React.memo(BlocksInput);
|
2600
|
-
const createDefaultForm = (contentType, components = {}) => {
|
2601
|
-
const traverseSchema = (attributes) => {
|
2602
|
-
return Object.entries(attributes).reduce((acc, [key, attribute]) => {
|
2603
|
-
if ("default" in attribute) {
|
2604
|
-
acc[key] = attribute.default;
|
2605
|
-
} else if (attribute.type === "component" && attribute.required) {
|
2606
|
-
const defaultComponentForm = traverseSchema(components[attribute.component].attributes);
|
2607
|
-
if (attribute.repeatable) {
|
2608
|
-
acc[key] = attribute.min ? [...Array(attribute.min).fill(defaultComponentForm)] : [];
|
2609
|
-
} else {
|
2610
|
-
acc[key] = defaultComponentForm;
|
2611
|
-
}
|
2612
|
-
} else if (attribute.type === "dynamiczone" && attribute.required) {
|
2613
|
-
acc[key] = [];
|
2614
|
-
}
|
2615
|
-
return acc;
|
2616
|
-
}, {});
|
2617
|
-
};
|
2618
|
-
return traverseSchema(contentType.attributes);
|
2619
|
-
};
|
2620
2581
|
const Initializer = ({ disabled, name: name2, onClick }) => {
|
2621
2582
|
const { formatMessage } = useIntl();
|
2622
2583
|
const field = useField(name2);
|
@@ -2651,126 +2612,451 @@ const Initializer = ({ disabled, name: name2, onClick }) => {
|
|
2651
2612
|
}
|
2652
2613
|
) });
|
2653
2614
|
};
|
2654
|
-
const
|
2655
|
-
|
2656
|
-
|
2615
|
+
const AddComponentButton = ({
|
2616
|
+
hasError,
|
2617
|
+
isDisabled,
|
2618
|
+
isOpen,
|
2657
2619
|
children,
|
2658
|
-
|
2620
|
+
onClick
|
2621
|
+
}) => {
|
2622
|
+
return /* @__PURE__ */ jsx(
|
2623
|
+
StyledButton,
|
2624
|
+
{
|
2625
|
+
type: "button",
|
2626
|
+
onClick,
|
2627
|
+
disabled: isDisabled,
|
2628
|
+
background: "neutral0",
|
2629
|
+
style: { cursor: isDisabled ? "not-allowed" : "pointer" },
|
2630
|
+
variant: "tertiary",
|
2631
|
+
children: /* @__PURE__ */ jsxs(Flex, { tag: "span", gap: 2, children: [
|
2632
|
+
/* @__PURE__ */ jsx(StyledAddIcon, { "aria-hidden": true, $isOpen: isOpen, $hasError: hasError && !isOpen }),
|
2633
|
+
/* @__PURE__ */ jsx(
|
2634
|
+
Typography,
|
2635
|
+
{
|
2636
|
+
variant: "pi",
|
2637
|
+
fontWeight: "bold",
|
2638
|
+
textColor: hasError && !isOpen ? "danger600" : "neutral600",
|
2639
|
+
children
|
2640
|
+
}
|
2641
|
+
)
|
2642
|
+
] })
|
2643
|
+
}
|
2644
|
+
);
|
2645
|
+
};
|
2646
|
+
const StyledAddIcon = styled(PlusCircle)`
|
2647
|
+
height: ${({ theme }) => theme.spaces[6]};
|
2648
|
+
width: ${({ theme }) => theme.spaces[6]};
|
2649
|
+
transform: ${({ $isOpen }) => $isOpen ? "rotate(45deg)" : "rotate(0deg)"};
|
2650
|
+
|
2651
|
+
> circle {
|
2652
|
+
fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger200 : theme.colors.neutral150};
|
2653
|
+
}
|
2654
|
+
> path {
|
2655
|
+
fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral500};
|
2656
|
+
}
|
2657
|
+
`;
|
2658
|
+
const StyledButton = styled(Button)`
|
2659
|
+
padding-left: ${({ theme }) => theme.spaces[3]};
|
2660
|
+
border-radius: 26px;
|
2661
|
+
box-shadow: ${({ theme }) => theme.shadows.filterShadow};
|
2662
|
+
height: 5rem;
|
2663
|
+
`;
|
2664
|
+
const ComponentCategory = ({
|
2665
|
+
category,
|
2666
|
+
components = [],
|
2667
|
+
variant = "primary",
|
2668
|
+
onAddComponent
|
2659
2669
|
}) => {
|
2660
2670
|
const { formatMessage } = useIntl();
|
2661
|
-
|
2662
|
-
|
2663
|
-
|
2664
|
-
|
2671
|
+
return /* @__PURE__ */ jsxs(Accordion.Item, { value: category, children: [
|
2672
|
+
/* @__PURE__ */ jsx(Accordion.Header, { variant, children: /* @__PURE__ */ jsx(Accordion.Trigger, { children: formatMessage({ id: category, defaultMessage: category }) }) }),
|
2673
|
+
/* @__PURE__ */ jsx(ResponsiveAccordionContent, { children: /* @__PURE__ */ jsx(Grid, { paddingTop: 4, paddingBottom: 4, paddingLeft: 3, paddingRight: 3, children: components.map(({ uid, displayName, icon }) => /* @__PURE__ */ jsx(
|
2674
|
+
ComponentBox,
|
2675
|
+
{
|
2676
|
+
tag: "button",
|
2677
|
+
type: "button",
|
2678
|
+
background: "neutral100",
|
2679
|
+
justifyContent: "center",
|
2680
|
+
onClick: onAddComponent(uid),
|
2681
|
+
hasRadius: true,
|
2682
|
+
height: "8.4rem",
|
2683
|
+
shrink: 0,
|
2684
|
+
borderColor: "neutral200",
|
2685
|
+
children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "center", justifyContent: "center", children: [
|
2686
|
+
/* @__PURE__ */ jsx(ComponentIcon, { color: "currentColor", background: "primary200", icon }),
|
2687
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", children: displayName })
|
2688
|
+
] })
|
2689
|
+
},
|
2690
|
+
uid
|
2691
|
+
)) }) })
|
2692
|
+
] });
|
2693
|
+
};
|
2694
|
+
const ResponsiveAccordionContent = styled(Accordion.Content)`
|
2695
|
+
container-type: inline-size;
|
2696
|
+
`;
|
2697
|
+
const Grid = styled(Box)`
|
2698
|
+
display: grid;
|
2699
|
+
grid-template-columns: repeat(auto-fill, 100%);
|
2700
|
+
grid-gap: ${({ theme }) => theme.spaces[1]};
|
2701
|
+
|
2702
|
+
@container (min-width: ${() => RESPONSIVE_CONTAINER_BREAKPOINTS.sm}) {
|
2703
|
+
grid-template-columns: repeat(auto-fill, 14rem);
|
2704
|
+
}
|
2705
|
+
`;
|
2706
|
+
const ComponentBox = styled(Flex)`
|
2707
|
+
color: ${({ theme }) => theme.colors.neutral600};
|
2708
|
+
cursor: pointer;
|
2709
|
+
|
2710
|
+
@media (prefers-reduced-motion: no-preference) {
|
2711
|
+
transition: color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
|
2712
|
+
}
|
2713
|
+
|
2714
|
+
&:focus,
|
2715
|
+
&:hover {
|
2716
|
+
border: 1px solid ${({ theme }) => theme.colors.primary200};
|
2717
|
+
background: ${({ theme }) => theme.colors.primary100};
|
2718
|
+
color: ${({ theme }) => theme.colors.primary600};
|
2719
|
+
}
|
2720
|
+
`;
|
2721
|
+
const ComponentPicker = ({
|
2722
|
+
dynamicComponentsByCategory = {},
|
2723
|
+
isOpen,
|
2724
|
+
onClickAddComponent
|
2725
|
+
}) => {
|
2726
|
+
const { formatMessage } = useIntl();
|
2727
|
+
const handleAddComponentToDz = (componentUid) => () => {
|
2728
|
+
onClickAddComponent(componentUid);
|
2729
|
+
};
|
2730
|
+
if (!isOpen) {
|
2731
|
+
return null;
|
2732
|
+
}
|
2733
|
+
return /* @__PURE__ */ jsxs(
|
2665
2734
|
Box,
|
2666
2735
|
{
|
2667
|
-
background: "neutral100",
|
2668
|
-
paddingLeft: 6,
|
2669
|
-
paddingRight: 6,
|
2670
2736
|
paddingTop: 6,
|
2671
2737
|
paddingBottom: 6,
|
2672
|
-
|
2673
|
-
|
2674
|
-
|
2675
|
-
|
2676
|
-
|
2677
|
-
|
2678
|
-
|
2679
|
-
|
2680
|
-
|
2681
|
-
|
2682
|
-
|
2683
|
-
|
2684
|
-
|
2685
|
-
|
2686
|
-
|
2687
|
-
|
2688
|
-
|
2689
|
-
|
2690
|
-
|
2691
|
-
|
2692
|
-
|
2693
|
-
|
2694
|
-
}) })
|
2738
|
+
paddingLeft: 5,
|
2739
|
+
paddingRight: 5,
|
2740
|
+
background: "neutral0",
|
2741
|
+
shadow: "tableShadow",
|
2742
|
+
borderColor: "neutral150",
|
2743
|
+
hasRadius: true,
|
2744
|
+
children: [
|
2745
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", textColor: "neutral600", children: formatMessage({
|
2746
|
+
id: getTranslation("components.DynamicZone.ComponentPicker-label"),
|
2747
|
+
defaultMessage: "Pick one component"
|
2748
|
+
}) }) }),
|
2749
|
+
/* @__PURE__ */ jsx(Box, { paddingTop: 2, children: /* @__PURE__ */ jsx(Accordion.Root, { defaultValue: Object.keys(dynamicComponentsByCategory)[0], children: Object.entries(dynamicComponentsByCategory).map(([category, components], index) => /* @__PURE__ */ jsx(
|
2750
|
+
ComponentCategory,
|
2751
|
+
{
|
2752
|
+
category,
|
2753
|
+
components,
|
2754
|
+
onAddComponent: handleAddComponentToDz,
|
2755
|
+
variant: index % 2 === 1 ? "primary" : "secondary"
|
2756
|
+
},
|
2757
|
+
category
|
2758
|
+
)) }) })
|
2759
|
+
]
|
2695
2760
|
}
|
2696
|
-
)
|
2761
|
+
);
|
2697
2762
|
};
|
2698
|
-
const
|
2699
|
-
|
2763
|
+
const DynamicComponent = ({
|
2764
|
+
componentUid,
|
2700
2765
|
disabled,
|
2766
|
+
index,
|
2701
2767
|
name: name2,
|
2702
|
-
|
2703
|
-
|
2704
|
-
|
2768
|
+
onRemoveComponentClick,
|
2769
|
+
onMoveComponent,
|
2770
|
+
onGrabItem,
|
2771
|
+
onDropItem,
|
2772
|
+
onCancel,
|
2773
|
+
dynamicComponentsByCategory = {},
|
2774
|
+
onAddComponent,
|
2775
|
+
children
|
2705
2776
|
}) => {
|
2706
|
-
const { toggleNotification } = useNotification();
|
2707
2777
|
const { formatMessage } = useIntl();
|
2708
|
-
const
|
2709
|
-
const search = React.useMemo(() => new URLSearchParams(searchString), [searchString]);
|
2710
|
-
const { components } = useDoc();
|
2778
|
+
const formValues = useForm("DynamicComponent", (state) => state.values);
|
2711
2779
|
const {
|
2712
|
-
|
2713
|
-
|
2714
|
-
|
2715
|
-
|
2716
|
-
|
2717
|
-
|
2718
|
-
|
2719
|
-
|
2780
|
+
edit: { components }
|
2781
|
+
} = useDocLayout();
|
2782
|
+
const title = React.useMemo(() => {
|
2783
|
+
const { mainField } = components[componentUid]?.settings ?? { mainField: "id" };
|
2784
|
+
const mainFieldValue = getIn(formValues, `${name2}.${index}.${mainField}`);
|
2785
|
+
const displayedValue = mainField === "id" || !mainFieldValue ? "" : String(mainFieldValue).trim();
|
2786
|
+
const mainValue = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;
|
2787
|
+
return mainValue;
|
2788
|
+
}, [componentUid, components, formValues, name2, index]);
|
2789
|
+
const { icon, displayName } = React.useMemo(() => {
|
2790
|
+
const [category] = componentUid.split(".");
|
2791
|
+
const { icon: icon2, displayName: displayName2 } = (dynamicComponentsByCategory[category] ?? []).find(
|
2792
|
+
(component) => component.uid === componentUid
|
2793
|
+
) ?? { icon: null, displayName: null };
|
2794
|
+
return { icon: icon2, displayName: displayName2 };
|
2795
|
+
}, [componentUid, dynamicComponentsByCategory]);
|
2796
|
+
const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop(!disabled, {
|
2797
|
+
type: `${ItemTypes.DYNAMIC_ZONE}_${name2}`,
|
2798
|
+
index,
|
2799
|
+
item: {
|
2800
|
+
index,
|
2801
|
+
displayedValue: `${displayName} ${title}`,
|
2802
|
+
icon
|
2803
|
+
},
|
2804
|
+
onMoveItem: onMoveComponent,
|
2805
|
+
onDropItem,
|
2806
|
+
onGrabItem,
|
2807
|
+
onCancel
|
2808
|
+
});
|
2809
|
+
React.useEffect(() => {
|
2810
|
+
dragPreviewRef(getEmptyImage(), { captureDraggingState: false });
|
2811
|
+
}, [dragPreviewRef, index]);
|
2812
|
+
const accordionValue = React.useId();
|
2813
|
+
const { value = [], rawError } = useField(`${name2}.${index}`);
|
2720
2814
|
const [collapseToOpen, setCollapseToOpen] = React.useState("");
|
2721
|
-
const [liveText, setLiveText] = React.useState("");
|
2722
2815
|
React.useEffect(() => {
|
2723
|
-
|
2724
|
-
|
2725
|
-
if (hasNestedErrors && hasNestedValue) {
|
2726
|
-
const errorOpenItems = rawError.map((_, idx) => {
|
2727
|
-
return value[idx] ? value[idx].__temp_key__ : null;
|
2728
|
-
}).filter((value2) => !!value2);
|
2729
|
-
if (errorOpenItems && errorOpenItems.length > 0) {
|
2730
|
-
setCollapseToOpen((collapseToOpen2) => {
|
2731
|
-
if (!errorOpenItems.includes(collapseToOpen2)) {
|
2732
|
-
return errorOpenItems[0];
|
2733
|
-
}
|
2734
|
-
return collapseToOpen2;
|
2735
|
-
});
|
2736
|
-
}
|
2816
|
+
if (rawError && value) {
|
2817
|
+
setCollapseToOpen(accordionValue);
|
2737
2818
|
}
|
2738
|
-
}, [rawError, value]);
|
2739
|
-
const
|
2740
|
-
|
2741
|
-
|
2742
|
-
|
2743
|
-
|
2819
|
+
}, [rawError, value, accordionValue]);
|
2820
|
+
const composedBoxRefs = useComposedRefs(boxRef, dropRef);
|
2821
|
+
const accordionActions = disabled ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
|
2822
|
+
/* @__PURE__ */ jsx(
|
2823
|
+
IconButton,
|
2824
|
+
{
|
2825
|
+
variant: "ghost",
|
2826
|
+
label: formatMessage(
|
2827
|
+
{
|
2828
|
+
id: getTranslation("components.DynamicZone.delete-label"),
|
2829
|
+
defaultMessage: "Delete {name}"
|
2830
|
+
},
|
2831
|
+
{ name: title }
|
2832
|
+
),
|
2833
|
+
onClick: onRemoveComponentClick,
|
2834
|
+
children: /* @__PURE__ */ jsx(Trash, {})
|
2744
2835
|
}
|
2745
|
-
|
2746
|
-
|
2747
|
-
|
2748
|
-
|
2836
|
+
),
|
2837
|
+
/* @__PURE__ */ jsx(
|
2838
|
+
IconButton,
|
2839
|
+
{
|
2840
|
+
variant: "ghost",
|
2841
|
+
onClick: (e) => e.stopPropagation(),
|
2842
|
+
"data-handler-id": handlerId,
|
2843
|
+
ref: dragRef,
|
2844
|
+
label: formatMessage({
|
2845
|
+
id: getTranslation("components.DragHandle-label"),
|
2846
|
+
defaultMessage: "Drag"
|
2847
|
+
}),
|
2848
|
+
onKeyDown: handleKeyDown,
|
2849
|
+
children: /* @__PURE__ */ jsx(Drag, {})
|
2749
2850
|
}
|
2851
|
+
),
|
2852
|
+
/* @__PURE__ */ jsxs(Menu.Root, { children: [
|
2853
|
+
/* @__PURE__ */ jsx(Menu.Trigger, { size: "S", endIcon: null, paddingLeft: 0, paddingRight: 0, children: /* @__PURE__ */ jsx(
|
2854
|
+
IconButton,
|
2855
|
+
{
|
2856
|
+
variant: "ghost",
|
2857
|
+
label: formatMessage({
|
2858
|
+
id: getTranslation("components.DynamicZone.more-actions"),
|
2859
|
+
defaultMessage: "More actions"
|
2860
|
+
}),
|
2861
|
+
tag: "span",
|
2862
|
+
children: /* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false })
|
2863
|
+
}
|
2864
|
+
) }),
|
2865
|
+
/* @__PURE__ */ jsxs(Menu.Content, { children: [
|
2866
|
+
/* @__PURE__ */ jsxs(Menu.SubRoot, { children: [
|
2867
|
+
/* @__PURE__ */ jsx(Menu.SubTrigger, { children: formatMessage({
|
2868
|
+
id: getTranslation("components.DynamicZone.add-item-above"),
|
2869
|
+
defaultMessage: "Add component above"
|
2870
|
+
}) }),
|
2871
|
+
/* @__PURE__ */ jsx(Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
2872
|
+
/* @__PURE__ */ jsx(Menu.Label, { children: category }),
|
2873
|
+
components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsx(MenuItem, { onSelect: () => onAddComponent(uid, index), children: displayName2 }, componentUid))
|
2874
|
+
] }, category)) })
|
2875
|
+
] }),
|
2876
|
+
/* @__PURE__ */ jsxs(Menu.SubRoot, { children: [
|
2877
|
+
/* @__PURE__ */ jsx(Menu.SubTrigger, { children: formatMessage({
|
2878
|
+
id: getTranslation("components.DynamicZone.add-item-below"),
|
2879
|
+
defaultMessage: "Add component below"
|
2880
|
+
}) }),
|
2881
|
+
/* @__PURE__ */ jsx(Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
2882
|
+
/* @__PURE__ */ jsx(Menu.Label, { children: category }),
|
2883
|
+
components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsx(MenuItem, { onSelect: () => onAddComponent(uid, index + 1), children: displayName2 }, componentUid))
|
2884
|
+
] }, category)) })
|
2885
|
+
] })
|
2886
|
+
] })
|
2887
|
+
] })
|
2888
|
+
] });
|
2889
|
+
const accordionTitle = title ? `${displayName} ${title}` : displayName;
|
2890
|
+
return /* @__PURE__ */ jsxs(ComponentContainer, { tag: "li", width: "100%", children: [
|
2891
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Rectangle, { background: "neutral200" }) }),
|
2892
|
+
/* @__PURE__ */ jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsx(Preview$1, {}) : /* @__PURE__ */ jsx(Accordion.Root, { value: collapseToOpen, onValueChange: setCollapseToOpen, children: /* @__PURE__ */ jsxs(Accordion.Item, { value: accordionValue, children: [
|
2893
|
+
/* @__PURE__ */ jsxs(Accordion.Header, { children: [
|
2894
|
+
/* @__PURE__ */ jsx(
|
2895
|
+
Accordion.Trigger,
|
2896
|
+
{
|
2897
|
+
icon: icon && COMPONENT_ICONS[icon] ? COMPONENT_ICONS[icon] : COMPONENT_ICONS.dashboard,
|
2898
|
+
children: accordionTitle
|
2899
|
+
}
|
2900
|
+
),
|
2901
|
+
/* @__PURE__ */ jsx(Accordion.Actions, { children: accordionActions })
|
2902
|
+
] }),
|
2903
|
+
/* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(AccordionContentRadius, { background: "neutral0", children: /* @__PURE__ */ jsx(Box, { paddingLeft: 6, paddingRight: 6, paddingTop: 6, paddingBottom: 6, children: /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: components[componentUid]?.layout?.map((row, rowInd) => /* @__PURE__ */ jsx(
|
2904
|
+
Grid$1.Item,
|
2905
|
+
{
|
2906
|
+
col: 12,
|
2907
|
+
s: 12,
|
2908
|
+
xs: 12,
|
2909
|
+
direction: "column",
|
2910
|
+
alignItems: "stretch",
|
2911
|
+
children: /* @__PURE__ */ jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
|
2912
|
+
const fieldName = `${name2}.${index}.${field.name}`;
|
2913
|
+
const fieldWithTranslatedLabel = {
|
2914
|
+
...field,
|
2915
|
+
label: formatMessage({
|
2916
|
+
id: `content-manager.components.${componentUid}.${field.name}`,
|
2917
|
+
defaultMessage: field.label
|
2918
|
+
})
|
2919
|
+
};
|
2920
|
+
return /* @__PURE__ */ jsx(
|
2921
|
+
ResponsiveGridItem,
|
2922
|
+
{
|
2923
|
+
col: size,
|
2924
|
+
s: 12,
|
2925
|
+
xs: 12,
|
2926
|
+
direction: "column",
|
2927
|
+
alignItems: "stretch",
|
2928
|
+
children: children ? children({ ...fieldWithTranslatedLabel, name: fieldName }) : /* @__PURE__ */ jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel, name: fieldName })
|
2929
|
+
},
|
2930
|
+
fieldName
|
2931
|
+
);
|
2932
|
+
}) })
|
2933
|
+
},
|
2934
|
+
rowInd
|
2935
|
+
)) }) }) }) })
|
2936
|
+
] }) }) })
|
2937
|
+
] });
|
2938
|
+
};
|
2939
|
+
const StyledBox = styled(Box)`
|
2940
|
+
> div:first-child {
|
2941
|
+
box-shadow: ${({ theme }) => theme.shadows.tableShadow};
|
2942
|
+
}
|
2943
|
+
`;
|
2944
|
+
const AccordionContentRadius = styled(Box)`
|
2945
|
+
border-radius: 0 0 ${({ theme }) => theme.spaces[1]} ${({ theme }) => theme.spaces[1]};
|
2946
|
+
`;
|
2947
|
+
const Rectangle = styled(Box)`
|
2948
|
+
width: ${({ theme }) => theme.spaces[2]};
|
2949
|
+
height: ${({ theme }) => theme.spaces[4]};
|
2950
|
+
`;
|
2951
|
+
const Preview$1 = styled.span`
|
2952
|
+
display: block;
|
2953
|
+
background-color: ${({ theme }) => theme.colors.primary100};
|
2954
|
+
outline: 1px dashed ${({ theme }) => theme.colors.primary500};
|
2955
|
+
outline-offset: -1px;
|
2956
|
+
padding: ${({ theme }) => theme.spaces[6]};
|
2957
|
+
`;
|
2958
|
+
const ComponentContainer = styled(Box)`
|
2959
|
+
list-style: none;
|
2960
|
+
padding: 0;
|
2961
|
+
margin: 0;
|
2962
|
+
`;
|
2963
|
+
const DynamicZoneLabel = ({
|
2964
|
+
hint,
|
2965
|
+
label,
|
2966
|
+
labelAction,
|
2967
|
+
name: name2,
|
2968
|
+
numberOfComponents = 0,
|
2969
|
+
required
|
2970
|
+
}) => {
|
2971
|
+
return /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(
|
2972
|
+
Box,
|
2973
|
+
{
|
2974
|
+
paddingTop: 3,
|
2975
|
+
paddingBottom: 3,
|
2976
|
+
paddingRight: 4,
|
2977
|
+
paddingLeft: 4,
|
2978
|
+
borderRadius: "26px",
|
2979
|
+
background: "neutral0",
|
2980
|
+
shadow: "filterShadow",
|
2981
|
+
color: "neutral500",
|
2982
|
+
children: /* @__PURE__ */ jsxs(Flex, { direction: "column", justifyContent: "center", children: [
|
2983
|
+
/* @__PURE__ */ jsxs(Flex, { maxWidth: "35.6rem", children: [
|
2984
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", ellipsis: true, children: [
|
2985
|
+
label || name2,
|
2986
|
+
" "
|
2987
|
+
] }),
|
2988
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", children: [
|
2989
|
+
"(",
|
2990
|
+
numberOfComponents,
|
2991
|
+
")"
|
2992
|
+
] }),
|
2993
|
+
required && /* @__PURE__ */ jsx(Typography, { textColor: "danger600", children: "*" }),
|
2994
|
+
labelAction && /* @__PURE__ */ jsx(Box, { paddingLeft: 1, children: labelAction })
|
2995
|
+
] }),
|
2996
|
+
hint && /* @__PURE__ */ jsx(Box, { paddingTop: 1, maxWidth: "35.6rem", children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", ellipsis: true, children: hint }) })
|
2997
|
+
] })
|
2750
2998
|
}
|
2751
|
-
|
2752
|
-
|
2753
|
-
|
2754
|
-
|
2755
|
-
|
2756
|
-
|
2757
|
-
|
2758
|
-
|
2759
|
-
|
2760
|
-
|
2761
|
-
|
2762
|
-
|
2763
|
-
|
2764
|
-
|
2765
|
-
|
2766
|
-
|
2767
|
-
|
2768
|
-
|
2769
|
-
|
2770
|
-
|
2771
|
-
|
2772
|
-
|
2773
|
-
|
2999
|
+
) });
|
3000
|
+
};
|
3001
|
+
const [DynamicZoneProvider, useDynamicZone] = createContext(
|
3002
|
+
"DynamicZone",
|
3003
|
+
{
|
3004
|
+
isInDynamicZone: false
|
3005
|
+
}
|
3006
|
+
);
|
3007
|
+
const DynamicZone = ({
|
3008
|
+
attribute,
|
3009
|
+
disabled: disabledProp,
|
3010
|
+
hint,
|
3011
|
+
label,
|
3012
|
+
labelAction,
|
3013
|
+
name: name2,
|
3014
|
+
required = false,
|
3015
|
+
children
|
3016
|
+
}) => {
|
3017
|
+
const { max = Infinity, min = -Infinity } = attribute ?? {};
|
3018
|
+
const [addComponentIsOpen, setAddComponentIsOpen] = React.useState(false);
|
3019
|
+
const [liveText, setLiveText] = React.useState("");
|
3020
|
+
const { components, isLoading } = useDoc();
|
3021
|
+
const disabled = disabledProp || isLoading;
|
3022
|
+
const { addFieldRow, removeFieldRow, moveFieldRow } = useForm(
|
3023
|
+
"DynamicZone",
|
3024
|
+
({ addFieldRow: addFieldRow2, removeFieldRow: removeFieldRow2, moveFieldRow: moveFieldRow2 }) => ({
|
3025
|
+
addFieldRow: addFieldRow2,
|
3026
|
+
removeFieldRow: removeFieldRow2,
|
3027
|
+
moveFieldRow: moveFieldRow2
|
3028
|
+
})
|
3029
|
+
);
|
3030
|
+
const { value = [], error } = useField(name2);
|
3031
|
+
const dynamicComponentsByCategory = React.useMemo(() => {
|
3032
|
+
return attribute.components.reduce((acc, componentUid) => {
|
3033
|
+
const { category, info } = components[componentUid] ?? { info: {} };
|
3034
|
+
const component = { uid: componentUid, displayName: info.displayName, icon: info.icon };
|
3035
|
+
if (!acc[category]) {
|
3036
|
+
acc[category] = [];
|
3037
|
+
}
|
3038
|
+
acc[category] = [...acc[category], component];
|
3039
|
+
return acc;
|
3040
|
+
}, {});
|
3041
|
+
}, [attribute.components, components]);
|
3042
|
+
const { formatMessage } = useIntl();
|
3043
|
+
const { toggleNotification } = useNotification();
|
3044
|
+
const dynamicDisplayedComponentsLength = value.length;
|
3045
|
+
const handleAddComponent = (uid, position) => {
|
3046
|
+
setAddComponentIsOpen(false);
|
3047
|
+
const schema = components[uid];
|
3048
|
+
const form = createDefaultForm(schema, components);
|
3049
|
+
const transformations = pipe$1(transformDocument(schema, components), (data2) => ({
|
3050
|
+
...data2,
|
3051
|
+
__component: uid
|
3052
|
+
}));
|
3053
|
+
const data = transformations(form);
|
3054
|
+
addFieldRow(name2, data, position);
|
3055
|
+
};
|
3056
|
+
const handleClickOpenPicker = () => {
|
3057
|
+
if (dynamicDisplayedComponentsLength < max) {
|
3058
|
+
setAddComponentIsOpen((prev) => !prev);
|
3059
|
+
} else {
|
2774
3060
|
toggleNotification({
|
2775
3061
|
type: "info",
|
2776
3062
|
message: formatMessage({
|
@@ -2779,7 +3065,7 @@ const RepeatableComponent = ({
|
|
2779
3065
|
});
|
2780
3066
|
}
|
2781
3067
|
};
|
2782
|
-
const
|
3068
|
+
const handleMoveComponent = (newIndex, currentIndex) => {
|
2783
3069
|
setLiveText(
|
2784
3070
|
formatMessage(
|
2785
3071
|
{
|
@@ -2794,9 +3080,6 @@ const RepeatableComponent = ({
|
|
2794
3080
|
);
|
2795
3081
|
moveFieldRow(name2, currentIndex, newIndex);
|
2796
3082
|
};
|
2797
|
-
const handleValueChange = (key) => {
|
2798
|
-
setCollapseToOpen(key);
|
2799
|
-
};
|
2800
3083
|
const getItemPos = (index) => `${index + 1} of ${value.length}`;
|
2801
3084
|
const handleCancel = (index) => {
|
2802
3085
|
setLiveText(
|
@@ -2830,445 +3113,118 @@ const RepeatableComponent = ({
|
|
2830
3113
|
formatMessage(
|
2831
3114
|
{
|
2832
3115
|
id: getTranslation("dnd.drop-item"),
|
2833
|
-
defaultMessage: `{item}, dropped. Final position in list: {position}.`
|
2834
|
-
},
|
2835
|
-
{
|
2836
|
-
item: `${name2}.${index}`,
|
2837
|
-
position: getItemPos(index)
|
2838
|
-
}
|
2839
|
-
)
|
2840
|
-
);
|
2841
|
-
};
|
2842
|
-
const ariaDescriptionId = React.useId();
|
2843
|
-
const level = useComponent("RepeatableComponent", (state) => state.level);
|
2844
|
-
if (value.length === 0) {
|
2845
|
-
return /* @__PURE__ */ jsx(Initializer, { disabled, name: name2, onClick: handleClick });
|
2846
|
-
}
|
2847
|
-
return /* @__PURE__ */ jsxs(Box, { hasRadius: true, children: [
|
2848
|
-
/* @__PURE__ */ jsx(VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
|
2849
|
-
id: getTranslation("dnd.instructions"),
|
2850
|
-
defaultMessage: `Press spacebar to grab and re-order`
|
2851
|
-
}) }),
|
2852
|
-
/* @__PURE__ */ jsx(VisuallyHidden, { "aria-live": "assertive", children: liveText }),
|
2853
|
-
/* @__PURE__ */ jsxs(
|
2854
|
-
AccordionRoot,
|
2855
|
-
{
|
2856
|
-
$error: error,
|
2857
|
-
value: collapseToOpen,
|
2858
|
-
onValueChange: handleValueChange,
|
2859
|
-
"aria-describedby": ariaDescriptionId,
|
2860
|
-
children: [
|
2861
|
-
value.map(({ __temp_key__: key, id }, index) => {
|
2862
|
-
const nameWithIndex = `${name2}.${index}`;
|
2863
|
-
return /* @__PURE__ */ jsx(
|
2864
|
-
ComponentProvider,
|
2865
|
-
{
|
2866
|
-
id,
|
2867
|
-
uid: attribute.component,
|
2868
|
-
level: level + 1,
|
2869
|
-
type: "repeatable",
|
2870
|
-
children: /* @__PURE__ */ jsx(
|
2871
|
-
Component,
|
2872
|
-
{
|
2873
|
-
disabled,
|
2874
|
-
name: nameWithIndex,
|
2875
|
-
attribute,
|
2876
|
-
index,
|
2877
|
-
mainField,
|
2878
|
-
onMoveItem: handleMoveComponentField,
|
2879
|
-
onDeleteComponent: () => {
|
2880
|
-
removeFieldRow(name2, index);
|
2881
|
-
toggleCollapses();
|
2882
|
-
},
|
2883
|
-
toggleCollapses,
|
2884
|
-
onCancel: handleCancel,
|
2885
|
-
onDropItem: handleDropItem,
|
2886
|
-
onGrabItem: handleGrabItem,
|
2887
|
-
__temp_key__: key,
|
2888
|
-
children: layout.map((row, index2) => {
|
2889
|
-
return /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: row.map(({ size, ...field }) => {
|
2890
|
-
const completeFieldName = `${nameWithIndex}.${field.name}`;
|
2891
|
-
const translatedLabel = formatMessage({
|
2892
|
-
id: `content-manager.components.${attribute.component}.${field.name}`,
|
2893
|
-
defaultMessage: field.label
|
2894
|
-
});
|
2895
|
-
return /* @__PURE__ */ jsx(
|
2896
|
-
Grid$1.Item,
|
2897
|
-
{
|
2898
|
-
col: size,
|
2899
|
-
s: 12,
|
2900
|
-
xs: 12,
|
2901
|
-
direction: "column",
|
2902
|
-
alignItems: "stretch",
|
2903
|
-
children: children({
|
2904
|
-
...field,
|
2905
|
-
label: translatedLabel,
|
2906
|
-
name: completeFieldName
|
2907
|
-
})
|
2908
|
-
},
|
2909
|
-
completeFieldName
|
2910
|
-
);
|
2911
|
-
}) }, index2);
|
2912
|
-
})
|
2913
|
-
}
|
2914
|
-
)
|
2915
|
-
},
|
2916
|
-
key
|
2917
|
-
);
|
2918
|
-
}),
|
2919
|
-
/* @__PURE__ */ jsx(TextButtonCustom, { disabled, onClick: handleClick, startIcon: /* @__PURE__ */ jsx(Plus, {}), children: formatMessage({
|
2920
|
-
id: getTranslation("containers.EditView.add.new-entry"),
|
2921
|
-
defaultMessage: "Add an entry"
|
2922
|
-
}) })
|
2923
|
-
]
|
2924
|
-
}
|
2925
|
-
)
|
2926
|
-
] });
|
2927
|
-
};
|
2928
|
-
const AccordionRoot = styled(Accordion.Root)`
|
2929
|
-
border: 1px solid
|
2930
|
-
${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
|
2931
|
-
`;
|
2932
|
-
const TextButtonCustom = styled(TextButton)`
|
2933
|
-
width: 100%;
|
2934
|
-
display: flex;
|
2935
|
-
justify-content: center;
|
2936
|
-
border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
|
2937
|
-
padding-inline: ${(props) => props.theme.spaces[6]};
|
2938
|
-
padding-block: ${(props) => props.theme.spaces[3]};
|
2939
|
-
|
2940
|
-
&:not([disabled]) {
|
2941
|
-
cursor: pointer;
|
2942
|
-
|
2943
|
-
&:hover {
|
2944
|
-
background-color: ${(props) => props.theme.colors.primary100};
|
2945
|
-
}
|
2946
|
-
}
|
2947
|
-
|
2948
|
-
span {
|
2949
|
-
font-weight: 600;
|
2950
|
-
font-size: 1.4rem;
|
2951
|
-
line-height: 2.4rem;
|
2952
|
-
}
|
2953
|
-
|
2954
|
-
@media (prefers-reduced-motion: no-preference) {
|
2955
|
-
transition: background-color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
|
2956
|
-
}
|
2957
|
-
`;
|
2958
|
-
const Component = ({
|
2959
|
-
disabled,
|
2960
|
-
index,
|
2961
|
-
name: name2,
|
2962
|
-
mainField = {
|
2963
|
-
name: "id",
|
2964
|
-
type: "integer"
|
2965
|
-
},
|
2966
|
-
children,
|
2967
|
-
onDeleteComponent,
|
2968
|
-
toggleCollapses,
|
2969
|
-
__temp_key__,
|
2970
|
-
...dragProps
|
2971
|
-
}) => {
|
2972
|
-
const { formatMessage } = useIntl();
|
2973
|
-
const displayValue = useForm("RepeatableComponent", (state) => {
|
2974
|
-
return getIn(state.values, [...name2.split("."), mainField.name]);
|
2975
|
-
});
|
2976
|
-
const accordionRef = React.useRef(null);
|
2977
|
-
const componentKey = name2.split(".").slice(0, -1).join(".");
|
2978
|
-
const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop(!disabled, {
|
2979
|
-
type: `${ItemTypes.COMPONENT}_${componentKey}`,
|
2980
|
-
index,
|
2981
|
-
item: {
|
2982
|
-
index,
|
2983
|
-
displayedValue: displayValue
|
2984
|
-
},
|
2985
|
-
onStart() {
|
2986
|
-
toggleCollapses();
|
2987
|
-
},
|
2988
|
-
...dragProps
|
2989
|
-
});
|
2990
|
-
React.useEffect(() => {
|
2991
|
-
dragPreviewRef(getEmptyImage(), { captureDraggingState: false });
|
2992
|
-
}, [dragPreviewRef, index]);
|
2993
|
-
const composedAccordionRefs = useComposedRefs(accordionRef, dragRef);
|
2994
|
-
const composedBoxRefs = useComposedRefs(
|
2995
|
-
boxRef,
|
2996
|
-
dropRef
|
2997
|
-
);
|
2998
|
-
return /* @__PURE__ */ jsx(Fragment, { children: isDragging ? /* @__PURE__ */ jsx(Preview$1, {}) : /* @__PURE__ */ jsxs(Accordion.Item, { ref: composedBoxRefs, value: __temp_key__, children: [
|
2999
|
-
/* @__PURE__ */ jsxs(Accordion.Header, { children: [
|
3000
|
-
/* @__PURE__ */ jsx(Accordion.Trigger, { children: displayValue }),
|
3001
|
-
/* @__PURE__ */ jsxs(Accordion.Actions, { children: [
|
3002
|
-
/* @__PURE__ */ jsx(
|
3003
|
-
IconButton,
|
3004
|
-
{
|
3005
|
-
variant: "ghost",
|
3006
|
-
onClick: onDeleteComponent,
|
3007
|
-
label: formatMessage({
|
3008
|
-
id: getTranslation("containers.Edit.delete"),
|
3009
|
-
defaultMessage: "Delete"
|
3010
|
-
}),
|
3011
|
-
children: /* @__PURE__ */ jsx(Trash, {})
|
3012
|
-
}
|
3013
|
-
),
|
3014
|
-
/* @__PURE__ */ jsx(
|
3015
|
-
IconButton,
|
3016
|
-
{
|
3017
|
-
ref: composedAccordionRefs,
|
3018
|
-
variant: "ghost",
|
3019
|
-
onClick: (e) => e.stopPropagation(),
|
3020
|
-
"data-handler-id": handlerId,
|
3021
|
-
label: formatMessage({
|
3022
|
-
id: getTranslation("components.DragHandle-label"),
|
3023
|
-
defaultMessage: "Drag"
|
3024
|
-
}),
|
3025
|
-
onKeyDown: handleKeyDown,
|
3026
|
-
children: /* @__PURE__ */ jsx(Drag, {})
|
3027
|
-
}
|
3028
|
-
)
|
3029
|
-
] })
|
3030
|
-
] }),
|
3031
|
-
/* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(
|
3032
|
-
Flex,
|
3033
|
-
{
|
3034
|
-
direction: "column",
|
3035
|
-
alignItems: "stretch",
|
3036
|
-
background: "neutral100",
|
3037
|
-
padding: 6,
|
3038
|
-
gap: 6,
|
3039
|
-
children
|
3040
|
-
}
|
3041
|
-
) })
|
3042
|
-
] }) });
|
3043
|
-
};
|
3044
|
-
const Preview$1 = () => {
|
3045
|
-
return /* @__PURE__ */ jsx(StyledSpan, { tag: "span", padding: 6, background: "primary100" });
|
3046
|
-
};
|
3047
|
-
const StyledSpan = styled(Box)`
|
3048
|
-
display: block;
|
3049
|
-
outline: 1px dashed ${({ theme }) => theme.colors.primary500};
|
3050
|
-
outline-offset: -1px;
|
3051
|
-
`;
|
3052
|
-
const ComponentInput = ({
|
3053
|
-
label,
|
3054
|
-
required,
|
3055
|
-
name: name2,
|
3056
|
-
attribute,
|
3057
|
-
disabled,
|
3058
|
-
labelAction,
|
3059
|
-
...props
|
3060
|
-
}) => {
|
3061
|
-
const { formatMessage } = useIntl();
|
3062
|
-
const field = useField(name2);
|
3063
|
-
const showResetComponent = !attribute.repeatable && field.value && !disabled;
|
3064
|
-
const { components } = useDoc();
|
3065
|
-
const handleInitialisationClick = () => {
|
3066
|
-
const schema = components[attribute.component];
|
3067
|
-
const form = createDefaultForm(schema, components);
|
3068
|
-
const data = transformDocument(schema, components)(form);
|
3069
|
-
field.onChange(name2, data);
|
3070
|
-
};
|
3071
|
-
return /* @__PURE__ */ jsxs(Field.Root, { error: field.error, required, children: [
|
3072
|
-
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", children: [
|
3073
|
-
/* @__PURE__ */ jsxs(Field.Label, { action: labelAction, children: [
|
3074
|
-
label,
|
3075
|
-
attribute.repeatable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
3076
|
-
" (",
|
3077
|
-
Array.isArray(field.value) ? field.value.length : 0,
|
3078
|
-
")"
|
3079
|
-
] })
|
3080
|
-
] }),
|
3081
|
-
showResetComponent && /* @__PURE__ */ jsx(
|
3082
|
-
IconButton,
|
3116
|
+
defaultMessage: `{item}, dropped. Final position in list: {position}.`
|
3117
|
+
},
|
3083
3118
|
{
|
3084
|
-
|
3085
|
-
|
3086
|
-
defaultMessage: "Reset Entry"
|
3087
|
-
}),
|
3088
|
-
variant: "ghost",
|
3089
|
-
onClick: () => {
|
3090
|
-
field.onChange(name2, null);
|
3091
|
-
},
|
3092
|
-
children: /* @__PURE__ */ jsx(Trash, {})
|
3119
|
+
item: `${name2}.${index}`,
|
3120
|
+
position: getItemPos(index)
|
3093
3121
|
}
|
3094
3122
|
)
|
3095
|
-
|
3096
|
-
|
3097
|
-
|
3098
|
-
|
3099
|
-
|
3100
|
-
|
3101
|
-
|
3102
|
-
|
3103
|
-
|
3104
|
-
hasError,
|
3105
|
-
isDisabled,
|
3106
|
-
isOpen,
|
3107
|
-
children,
|
3108
|
-
onClick
|
3109
|
-
}) => {
|
3110
|
-
return /* @__PURE__ */ jsx(
|
3111
|
-
StyledButton,
|
3112
|
-
{
|
3113
|
-
type: "button",
|
3114
|
-
onClick,
|
3115
|
-
disabled: isDisabled,
|
3116
|
-
background: "neutral0",
|
3117
|
-
style: { cursor: isDisabled ? "not-allowed" : "pointer" },
|
3118
|
-
variant: "tertiary",
|
3119
|
-
children: /* @__PURE__ */ jsxs(Flex, { tag: "span", gap: 2, children: [
|
3120
|
-
/* @__PURE__ */ jsx(StyledAddIcon, { "aria-hidden": true, $isOpen: isOpen, $hasError: hasError && !isOpen }),
|
3121
|
-
/* @__PURE__ */ jsx(
|
3122
|
-
AddComponentTitle,
|
3123
|
-
{
|
3124
|
-
variant: "pi",
|
3125
|
-
fontWeight: "bold",
|
3126
|
-
textColor: hasError && !isOpen ? "danger600" : "neutral500",
|
3127
|
-
children
|
3128
|
-
}
|
3129
|
-
)
|
3130
|
-
] })
|
3131
|
-
}
|
3132
|
-
);
|
3133
|
-
};
|
3134
|
-
const StyledAddIcon = styled(PlusCircle)`
|
3135
|
-
height: ${({ theme }) => theme.spaces[6]};
|
3136
|
-
width: ${({ theme }) => theme.spaces[6]};
|
3137
|
-
transform: ${({ $isOpen }) => $isOpen ? "rotate(45deg)" : "rotate(0deg)"};
|
3138
|
-
|
3139
|
-
> circle {
|
3140
|
-
fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger200 : theme.colors.neutral150};
|
3141
|
-
}
|
3142
|
-
> path {
|
3143
|
-
fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral600};
|
3144
|
-
}
|
3145
|
-
`;
|
3146
|
-
const AddComponentTitle = styled(Typography)``;
|
3147
|
-
const StyledButton = styled(Button)`
|
3148
|
-
border-radius: 26px;
|
3149
|
-
border-color: ${({ theme }) => theme.colors.neutral150};
|
3150
|
-
box-shadow: ${({ theme }) => theme.shadows.filterShadow};
|
3151
|
-
height: 5rem;
|
3152
|
-
|
3153
|
-
&:hover {
|
3154
|
-
${AddComponentTitle} {
|
3155
|
-
color: ${({ theme }) => theme.colors.primary600};
|
3156
|
-
}
|
3157
|
-
|
3158
|
-
${StyledAddIcon} {
|
3159
|
-
> circle {
|
3160
|
-
fill: ${({ theme }) => theme.colors.primary600};
|
3161
|
-
}
|
3162
|
-
> path {
|
3163
|
-
fill: ${({ theme }) => theme.colors.primary600};
|
3164
|
-
}
|
3123
|
+
);
|
3124
|
+
};
|
3125
|
+
const handleRemoveComponent = (name22, currentIndex) => () => {
|
3126
|
+
removeFieldRow(name22, currentIndex);
|
3127
|
+
};
|
3128
|
+
const hasError = error !== void 0;
|
3129
|
+
const renderButtonLabel = () => {
|
3130
|
+
if (addComponentIsOpen) {
|
3131
|
+
return formatMessage({ id: "app.utils.close-label", defaultMessage: "Close" });
|
3165
3132
|
}
|
3166
|
-
|
3167
|
-
|
3168
|
-
|
3169
|
-
|
3133
|
+
if (hasError && dynamicDisplayedComponentsLength > max) {
|
3134
|
+
return formatMessage(
|
3135
|
+
{
|
3136
|
+
id: getTranslation(`components.DynamicZone.extra-components`),
|
3137
|
+
defaultMessage: "There {number, plural, =0 {are # extra components} one {is # extra component} other {are # extra components}}"
|
3138
|
+
},
|
3139
|
+
{
|
3140
|
+
number: dynamicDisplayedComponentsLength - max
|
3141
|
+
}
|
3142
|
+
);
|
3170
3143
|
}
|
3171
|
-
|
3172
|
-
|
3173
|
-
|
3174
|
-
|
3175
|
-
|
3176
|
-
|
3177
|
-
|
3144
|
+
if (hasError && dynamicDisplayedComponentsLength < min) {
|
3145
|
+
return formatMessage(
|
3146
|
+
{
|
3147
|
+
id: getTranslation(`components.DynamicZone.missing-components`),
|
3148
|
+
defaultMessage: "There {number, plural, =0 {are # missing components} one {is # missing component} other {are # missing components}}"
|
3149
|
+
},
|
3150
|
+
{ number: min - dynamicDisplayedComponentsLength }
|
3151
|
+
);
|
3178
3152
|
}
|
3179
|
-
|
3180
|
-
`;
|
3181
|
-
const ComponentCategory = ({
|
3182
|
-
category,
|
3183
|
-
components = [],
|
3184
|
-
variant = "primary",
|
3185
|
-
onAddComponent
|
3186
|
-
}) => {
|
3187
|
-
const { formatMessage } = useIntl();
|
3188
|
-
return /* @__PURE__ */ jsxs(Accordion.Item, { value: category, children: [
|
3189
|
-
/* @__PURE__ */ jsx(Accordion.Header, { variant, children: /* @__PURE__ */ jsx(Accordion.Trigger, { children: formatMessage({ id: category, defaultMessage: category }) }) }),
|
3190
|
-
/* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(Grid, { paddingTop: 4, paddingBottom: 4, paddingLeft: 3, paddingRight: 3, children: components.map(({ uid, displayName, icon }) => /* @__PURE__ */ jsx(
|
3191
|
-
ComponentBox,
|
3153
|
+
return formatMessage(
|
3192
3154
|
{
|
3193
|
-
|
3194
|
-
|
3195
|
-
background: "neutral100",
|
3196
|
-
justifyContent: "center",
|
3197
|
-
onClick: onAddComponent(uid),
|
3198
|
-
hasRadius: true,
|
3199
|
-
height: "8.4rem",
|
3200
|
-
shrink: 0,
|
3201
|
-
borderColor: "neutral200",
|
3202
|
-
children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "center", justifyContent: "center", children: [
|
3203
|
-
/* @__PURE__ */ jsx(ComponentIcon, { color: "currentColor", background: "primary200", icon }),
|
3204
|
-
/* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", children: displayName })
|
3205
|
-
] })
|
3155
|
+
id: getTranslation("components.DynamicZone.add-component"),
|
3156
|
+
defaultMessage: "Add a component to {componentName}"
|
3206
3157
|
},
|
3207
|
-
|
3208
|
-
)
|
3209
|
-
] });
|
3210
|
-
};
|
3211
|
-
const Grid = styled(Box)`
|
3212
|
-
display: grid;
|
3213
|
-
grid-template-columns: repeat(auto-fit, 14rem);
|
3214
|
-
grid-gap: ${({ theme }) => theme.spaces[1]};
|
3215
|
-
`;
|
3216
|
-
const ComponentBox = styled(Flex)`
|
3217
|
-
color: ${({ theme }) => theme.colors.neutral600};
|
3218
|
-
cursor: pointer;
|
3219
|
-
|
3220
|
-
@media (prefers-reduced-motion: no-preference) {
|
3221
|
-
transition: color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
|
3222
|
-
}
|
3223
|
-
|
3224
|
-
&:focus,
|
3225
|
-
&:hover {
|
3226
|
-
border: 1px solid ${({ theme }) => theme.colors.primary200};
|
3227
|
-
background: ${({ theme }) => theme.colors.primary100};
|
3228
|
-
color: ${({ theme }) => theme.colors.primary600};
|
3229
|
-
}
|
3230
|
-
`;
|
3231
|
-
const ComponentPicker = ({
|
3232
|
-
dynamicComponentsByCategory = {},
|
3233
|
-
isOpen,
|
3234
|
-
onClickAddComponent
|
3235
|
-
}) => {
|
3236
|
-
const { formatMessage } = useIntl();
|
3237
|
-
const handleAddComponentToDz = (componentUid) => () => {
|
3238
|
-
onClickAddComponent(componentUid);
|
3158
|
+
{ componentName: label || name2 }
|
3159
|
+
);
|
3239
3160
|
};
|
3240
|
-
|
3241
|
-
|
3242
|
-
|
3243
|
-
|
3244
|
-
|
3245
|
-
|
3246
|
-
|
3247
|
-
|
3248
|
-
|
3249
|
-
|
3250
|
-
|
3251
|
-
|
3252
|
-
|
3253
|
-
|
3254
|
-
|
3255
|
-
|
3256
|
-
|
3257
|
-
|
3258
|
-
|
3259
|
-
|
3260
|
-
|
3261
|
-
|
3262
|
-
|
3263
|
-
|
3264
|
-
|
3265
|
-
|
3266
|
-
|
3267
|
-
|
3268
|
-
|
3269
|
-
|
3270
|
-
|
3271
|
-
|
3161
|
+
const level = useComponent("DynamicZone", (state) => state.level);
|
3162
|
+
const ariaDescriptionId = React.useId();
|
3163
|
+
return /* @__PURE__ */ jsx(DynamicZoneProvider, { isInDynamicZone: true, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
3164
|
+
dynamicDisplayedComponentsLength > 0 && /* @__PURE__ */ jsxs(Box, { children: [
|
3165
|
+
/* @__PURE__ */ jsx(
|
3166
|
+
DynamicZoneLabel,
|
3167
|
+
{
|
3168
|
+
hint,
|
3169
|
+
label,
|
3170
|
+
labelAction,
|
3171
|
+
name: name2,
|
3172
|
+
numberOfComponents: dynamicDisplayedComponentsLength,
|
3173
|
+
required
|
3174
|
+
}
|
3175
|
+
),
|
3176
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
|
3177
|
+
id: getTranslation("dnd.instructions"),
|
3178
|
+
defaultMessage: `Press spacebar to grab and re-order`
|
3179
|
+
}) }),
|
3180
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { "aria-live": "assertive", children: liveText }),
|
3181
|
+
/* @__PURE__ */ jsx("ol", { "aria-describedby": ariaDescriptionId, children: value.map((field, index) => /* @__PURE__ */ jsx(
|
3182
|
+
ComponentProvider,
|
3183
|
+
{
|
3184
|
+
level: level + 1,
|
3185
|
+
uid: field.__component,
|
3186
|
+
id: field.id,
|
3187
|
+
type: "dynamiczone",
|
3188
|
+
children: /* @__PURE__ */ jsx(
|
3189
|
+
DynamicComponent,
|
3190
|
+
{
|
3191
|
+
disabled,
|
3192
|
+
name: name2,
|
3193
|
+
index,
|
3194
|
+
componentUid: field.__component,
|
3195
|
+
onMoveComponent: handleMoveComponent,
|
3196
|
+
onRemoveComponentClick: handleRemoveComponent(name2, index),
|
3197
|
+
onCancel: handleCancel,
|
3198
|
+
onDropItem: handleDropItem,
|
3199
|
+
onGrabItem: handleGrabItem,
|
3200
|
+
onAddComponent: handleAddComponent,
|
3201
|
+
dynamicComponentsByCategory,
|
3202
|
+
children
|
3203
|
+
}
|
3204
|
+
)
|
3205
|
+
},
|
3206
|
+
field.__temp_key__
|
3207
|
+
)) })
|
3208
|
+
] }),
|
3209
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(
|
3210
|
+
AddComponentButton,
|
3211
|
+
{
|
3212
|
+
hasError,
|
3213
|
+
isDisabled: disabled,
|
3214
|
+
isOpen: addComponentIsOpen,
|
3215
|
+
onClick: handleClickOpenPicker,
|
3216
|
+
children: renderButtonLabel()
|
3217
|
+
}
|
3218
|
+
) }),
|
3219
|
+
/* @__PURE__ */ jsx(
|
3220
|
+
ComponentPicker,
|
3221
|
+
{
|
3222
|
+
dynamicComponentsByCategory,
|
3223
|
+
isOpen: addComponentIsOpen,
|
3224
|
+
onClickAddComponent: handleAddComponent
|
3225
|
+
}
|
3226
|
+
)
|
3227
|
+
] }) });
|
3272
3228
|
};
|
3273
3229
|
const NotAllowedInput = ({ hint, label, required, name: name2 }) => {
|
3274
3230
|
const { formatMessage } = useIntl();
|
@@ -3748,8 +3704,7 @@ const Wrapper = styled.div`
|
|
3748
3704
|
`;
|
3749
3705
|
var listRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/, emptyListRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/, unorderedListRE = /[*+-]\s/;
|
3750
3706
|
function newlineAndIndentContinueMarkdownList(cm) {
|
3751
|
-
if (cm.getOption("disableInput"))
|
3752
|
-
return CodeMirror.Pass;
|
3707
|
+
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
3753
3708
|
var ranges = cm.listSelections(), replacements = [];
|
3754
3709
|
for (var i = 0; i < ranges.length; i++) {
|
3755
3710
|
var pos = ranges[i].head;
|
@@ -3783,8 +3738,7 @@ function newlineAndIndentContinueMarkdownList(cm) {
|
|
3783
3738
|
var numbered = !(unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0);
|
3784
3739
|
var bullet = numbered ? parseInt(match[3], 10) + 1 + match[4] : match[2].replace("x", " ");
|
3785
3740
|
replacements[i] = "\n" + indent + bullet + after;
|
3786
|
-
if (numbered)
|
3787
|
-
incrementRemainingMarkdownListNumbers(cm, pos);
|
3741
|
+
if (numbered) incrementRemainingMarkdownListNumbers(cm, pos);
|
3788
3742
|
}
|
3789
3743
|
}
|
3790
3744
|
cm.replaceSelections(replacements);
|
@@ -3802,10 +3756,8 @@ function incrementRemainingMarkdownListNumbers(cm, pos) {
|
|
3802
3756
|
var newNumber = parseInt(startItem[3], 10) + lookAhead - skipCount;
|
3803
3757
|
var nextNumber = parseInt(nextItem[3], 10), itemNumber = nextNumber;
|
3804
3758
|
if (startIndent === nextIndent && !isNaN(nextNumber)) {
|
3805
|
-
if (newNumber === nextNumber)
|
3806
|
-
|
3807
|
-
if (newNumber > nextNumber)
|
3808
|
-
itemNumber = newNumber + 1;
|
3759
|
+
if (newNumber === nextNumber) itemNumber = nextNumber + 1;
|
3760
|
+
if (newNumber > nextNumber) itemNumber = newNumber + 1;
|
3809
3761
|
cm.replaceRange(
|
3810
3762
|
nextLine.replace(listRE, nextIndent + itemNumber + nextItem[4] + nextItem[5]),
|
3811
3763
|
{
|
@@ -3818,10 +3770,8 @@ function incrementRemainingMarkdownListNumbers(cm, pos) {
|
|
3818
3770
|
}
|
3819
3771
|
);
|
3820
3772
|
} else {
|
3821
|
-
if (startIndent.length > nextIndent.length)
|
3822
|
-
|
3823
|
-
if (startIndent.length < nextIndent.length && lookAhead === 1)
|
3824
|
-
return;
|
3773
|
+
if (startIndent.length > nextIndent.length) return;
|
3774
|
+
if (startIndent.length < nextIndent.length && lookAhead === 1) return;
|
3825
3775
|
skipCount += 1;
|
3826
3776
|
}
|
3827
3777
|
}
|
@@ -5016,567 +4966,621 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
|
|
5016
4966
|
return /* @__PURE__ */ jsx(
|
5017
4967
|
MemoizedComponentInput,
|
5018
4968
|
{
|
5019
|
-
...props,
|
5020
|
-
hint,
|
5021
|
-
layout: components[props.attribute.component].layout,
|
5022
|
-
disabled: fieldIsDisabled,
|
5023
|
-
children: (inputProps) => /* @__PURE__ */ jsx(InputRenderer, { ...inputProps })
|
4969
|
+
...props,
|
4970
|
+
hint,
|
4971
|
+
layout: components[props.attribute.component].layout,
|
4972
|
+
disabled: fieldIsDisabled,
|
4973
|
+
children: (inputProps) => /* @__PURE__ */ jsx(InputRenderer, { ...inputProps })
|
4974
|
+
}
|
4975
|
+
);
|
4976
|
+
case "dynamiczone":
|
4977
|
+
return /* @__PURE__ */ jsx(DynamicZone, { ...props, hint, disabled: fieldIsDisabled });
|
4978
|
+
case "relation":
|
4979
|
+
return /* @__PURE__ */ jsx(MemoizedRelationsField, { ...props, hint, disabled: fieldIsDisabled });
|
4980
|
+
case "richtext":
|
4981
|
+
return /* @__PURE__ */ jsx(MemoizedWysiwyg, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
|
4982
|
+
case "uid":
|
4983
|
+
return /* @__PURE__ */ jsx(MemoizedUIDInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
|
4984
|
+
case "enumeration":
|
4985
|
+
return /* @__PURE__ */ jsx(
|
4986
|
+
InputRenderer$1,
|
4987
|
+
{
|
4988
|
+
...props,
|
4989
|
+
hint,
|
4990
|
+
options: props.attribute.enum.map((value) => ({ value })),
|
4991
|
+
type: props.customField ? "custom-field" : props.type,
|
4992
|
+
disabled: fieldIsDisabled
|
4993
|
+
}
|
4994
|
+
);
|
4995
|
+
default:
|
4996
|
+
const { unique: _unique, mainField: _mainField, ...restProps } = props;
|
4997
|
+
return /* @__PURE__ */ jsx(
|
4998
|
+
InputRenderer$1,
|
4999
|
+
{
|
5000
|
+
...restProps,
|
5001
|
+
hint,
|
5002
|
+
type: props.customField ? "custom-field" : props.type,
|
5003
|
+
disabled: fieldIsDisabled
|
5004
|
+
}
|
5005
|
+
);
|
5006
|
+
}
|
5007
|
+
};
|
5008
|
+
const attributeHasCustomFieldProperty = (attribute) => "customField" in attribute && typeof attribute.customField === "string";
|
5009
|
+
const useFieldHint = (hint = void 0, attribute) => {
|
5010
|
+
const { formatMessage } = useIntl();
|
5011
|
+
const { maximum, minimum } = getMinMax(attribute);
|
5012
|
+
if (!maximum && !minimum) {
|
5013
|
+
return hint;
|
5014
|
+
}
|
5015
|
+
const units = !["biginteger", "integer", "number", "dynamiczone", "component"].includes(
|
5016
|
+
attribute.type
|
5017
|
+
) ? formatMessage(
|
5018
|
+
{
|
5019
|
+
id: "content-manager.form.Input.hint.character.unit",
|
5020
|
+
defaultMessage: "{maxValue, plural, one { character} other { characters}}"
|
5021
|
+
},
|
5022
|
+
{
|
5023
|
+
maxValue: Math.max(minimum || 0, maximum || 0)
|
5024
|
+
}
|
5025
|
+
) : null;
|
5026
|
+
const hasMinAndMax = typeof minimum === "number" && typeof maximum === "number";
|
5027
|
+
return formatMessage(
|
5028
|
+
{
|
5029
|
+
id: "content-manager.form.Input.hint.text",
|
5030
|
+
defaultMessage: "{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}"
|
5031
|
+
},
|
5032
|
+
{
|
5033
|
+
min: minimum,
|
5034
|
+
max: maximum,
|
5035
|
+
description: hint,
|
5036
|
+
unit: units,
|
5037
|
+
divider: hasMinAndMax ? formatMessage({
|
5038
|
+
id: "content-manager.form.Input.hint.minMaxDivider",
|
5039
|
+
defaultMessage: " / "
|
5040
|
+
}) : null,
|
5041
|
+
br: /* @__PURE__ */ jsx("br", {})
|
5042
|
+
}
|
5043
|
+
);
|
5044
|
+
};
|
5045
|
+
const getMinMax = (attribute) => {
|
5046
|
+
if ("min" in attribute || "max" in attribute) {
|
5047
|
+
return {
|
5048
|
+
maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : void 0,
|
5049
|
+
minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : void 0
|
5050
|
+
};
|
5051
|
+
} else if ("maxLength" in attribute || "minLength" in attribute) {
|
5052
|
+
return { maximum: attribute.maxLength, minimum: attribute.minLength };
|
5053
|
+
} else {
|
5054
|
+
return { maximum: void 0, minimum: void 0 };
|
5055
|
+
}
|
5056
|
+
};
|
5057
|
+
const MemoizedInputRenderer = memo(InputRenderer);
|
5058
|
+
const RESPONSIVE_CONTAINER_BREAKPOINTS = {
|
5059
|
+
sm: "27.5rem"
|
5060
|
+
// 440px
|
5061
|
+
};
|
5062
|
+
const ResponsiveGridRoot = styled(Grid$1.Root)`
|
5063
|
+
container-type: inline-size;
|
5064
|
+
`;
|
5065
|
+
const ResponsiveGridItem = styled(Grid$1.Item)`
|
5066
|
+
grid-column: span 12;
|
5067
|
+
|
5068
|
+
@container (min-width: ${RESPONSIVE_CONTAINER_BREAKPOINTS.sm}) {
|
5069
|
+
${({ col }) => col && `grid-column: span ${col};`}
|
5070
|
+
}
|
5071
|
+
`;
|
5072
|
+
const FormLayout = ({ layout }) => {
|
5073
|
+
const { formatMessage } = useIntl();
|
5074
|
+
const { model } = useDoc();
|
5075
|
+
return /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((panel, index) => {
|
5076
|
+
if (panel.some((row) => row.some((field) => field.type === "dynamiczone"))) {
|
5077
|
+
const [row] = panel;
|
5078
|
+
const [field] = row;
|
5079
|
+
const fieldWithTranslatedLabel = {
|
5080
|
+
...field,
|
5081
|
+
label: formatMessage({
|
5082
|
+
id: `content-manager.content-types.${model}.${field.name}`,
|
5083
|
+
defaultMessage: field.label
|
5084
|
+
})
|
5085
|
+
};
|
5086
|
+
return /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: /* @__PURE__ */ jsx(Grid$1.Item, { col: 12, s: 12, xs: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel }) }) }, field.name);
|
5087
|
+
}
|
5088
|
+
return /* @__PURE__ */ jsx(
|
5089
|
+
Box,
|
5090
|
+
{
|
5091
|
+
hasRadius: true,
|
5092
|
+
background: "neutral0",
|
5093
|
+
shadow: "tableShadow",
|
5094
|
+
paddingLeft: 6,
|
5095
|
+
paddingRight: 6,
|
5096
|
+
paddingTop: 6,
|
5097
|
+
paddingBottom: 6,
|
5098
|
+
borderColor: "neutral150",
|
5099
|
+
children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: panel.map((row, gridRowIndex) => /* @__PURE__ */ jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
|
5100
|
+
const fieldWithTranslatedLabel = {
|
5101
|
+
...field,
|
5102
|
+
label: formatMessage({
|
5103
|
+
id: `content-manager.content-types.${model}.${field.name}`,
|
5104
|
+
defaultMessage: field.label
|
5105
|
+
})
|
5106
|
+
};
|
5107
|
+
return /* @__PURE__ */ jsx(
|
5108
|
+
ResponsiveGridItem,
|
5109
|
+
{
|
5110
|
+
col: size,
|
5111
|
+
s: 12,
|
5112
|
+
xs: 12,
|
5113
|
+
direction: "column",
|
5114
|
+
alignItems: "stretch",
|
5115
|
+
children: /* @__PURE__ */ jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel })
|
5116
|
+
},
|
5117
|
+
field.name
|
5118
|
+
);
|
5119
|
+
}) }, gridRowIndex)) })
|
5120
|
+
},
|
5121
|
+
index
|
5122
|
+
);
|
5123
|
+
}) });
|
5124
|
+
};
|
5125
|
+
const NonRepeatableComponent = ({
|
5126
|
+
attribute,
|
5127
|
+
name: name2,
|
5128
|
+
children,
|
5129
|
+
layout
|
5130
|
+
}) => {
|
5131
|
+
const { formatMessage } = useIntl();
|
5132
|
+
const { value } = useField(name2);
|
5133
|
+
const level = useComponent("NonRepeatableComponent", (state) => state.level);
|
5134
|
+
const isNested = level > 0;
|
5135
|
+
return /* @__PURE__ */ jsx(ComponentProvider, { id: value?.id, uid: attribute.component, level: level + 1, type: "component", children: /* @__PURE__ */ jsx(
|
5136
|
+
Box,
|
5137
|
+
{
|
5138
|
+
background: "neutral100",
|
5139
|
+
paddingLeft: 6,
|
5140
|
+
paddingRight: 6,
|
5141
|
+
paddingTop: 6,
|
5142
|
+
paddingBottom: 6,
|
5143
|
+
hasRadius: isNested,
|
5144
|
+
borderColor: isNested ? "neutral200" : void 0,
|
5145
|
+
children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((row, index) => {
|
5146
|
+
return /* @__PURE__ */ jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
|
5147
|
+
const completeFieldName = `${name2}.${field.name}`;
|
5148
|
+
const translatedLabel = formatMessage({
|
5149
|
+
id: `content-manager.components.${attribute.component}.${field.name}`,
|
5150
|
+
defaultMessage: field.label
|
5151
|
+
});
|
5152
|
+
return /* @__PURE__ */ jsx(
|
5153
|
+
ResponsiveGridItem,
|
5154
|
+
{
|
5155
|
+
col: size,
|
5156
|
+
s: 12,
|
5157
|
+
xs: 12,
|
5158
|
+
direction: "column",
|
5159
|
+
alignItems: "stretch",
|
5160
|
+
children: children({ ...field, label: translatedLabel, name: completeFieldName })
|
5161
|
+
},
|
5162
|
+
completeFieldName
|
5163
|
+
);
|
5164
|
+
}) }, index);
|
5165
|
+
}) })
|
5166
|
+
}
|
5167
|
+
) });
|
5168
|
+
};
|
5169
|
+
const RepeatableComponent = ({
|
5170
|
+
attribute,
|
5171
|
+
disabled,
|
5172
|
+
name: name2,
|
5173
|
+
mainField,
|
5174
|
+
children,
|
5175
|
+
layout
|
5176
|
+
}) => {
|
5177
|
+
const { toggleNotification } = useNotification();
|
5178
|
+
const { formatMessage } = useIntl();
|
5179
|
+
const { search: searchString } = useLocation();
|
5180
|
+
const search = React.useMemo(() => new URLSearchParams(searchString), [searchString]);
|
5181
|
+
const { components } = useDoc();
|
5182
|
+
const {
|
5183
|
+
value = [],
|
5184
|
+
error,
|
5185
|
+
rawError
|
5186
|
+
} = useField(name2);
|
5187
|
+
const addFieldRow = useForm("RepeatableComponent", (state) => state.addFieldRow);
|
5188
|
+
const moveFieldRow = useForm("RepeatableComponent", (state) => state.moveFieldRow);
|
5189
|
+
const removeFieldRow = useForm("RepeatableComponent", (state) => state.removeFieldRow);
|
5190
|
+
const { max = Infinity } = attribute;
|
5191
|
+
const [collapseToOpen, setCollapseToOpen] = React.useState("");
|
5192
|
+
const [liveText, setLiveText] = React.useState("");
|
5193
|
+
React.useEffect(() => {
|
5194
|
+
const hasNestedErrors = rawError && Array.isArray(rawError) && rawError.length > 0;
|
5195
|
+
const hasNestedValue = value && Array.isArray(value) && value.length > 0;
|
5196
|
+
if (hasNestedErrors && hasNestedValue) {
|
5197
|
+
const errorOpenItems = rawError.map((_, idx) => {
|
5198
|
+
return value[idx] ? value[idx].__temp_key__ : null;
|
5199
|
+
}).filter((value2) => !!value2);
|
5200
|
+
if (errorOpenItems && errorOpenItems.length > 0) {
|
5201
|
+
setCollapseToOpen((collapseToOpen2) => {
|
5202
|
+
if (!errorOpenItems.includes(collapseToOpen2)) {
|
5203
|
+
return errorOpenItems[0];
|
5204
|
+
}
|
5205
|
+
return collapseToOpen2;
|
5206
|
+
});
|
5207
|
+
}
|
5208
|
+
}
|
5209
|
+
}, [rawError, value]);
|
5210
|
+
const componentTmpKeyWithFocussedField = React.useMemo(() => {
|
5211
|
+
if (search.has("field")) {
|
5212
|
+
const fieldParam = search.get("field");
|
5213
|
+
if (!fieldParam) {
|
5214
|
+
return void 0;
|
5215
|
+
}
|
5216
|
+
const [, path] = fieldParam.split(`${name2}.`);
|
5217
|
+
if (getIn(value, path, void 0) !== void 0) {
|
5218
|
+
const [subpath] = path.split(".");
|
5219
|
+
return getIn(value, subpath, void 0)?.__temp_key__;
|
5220
|
+
}
|
5221
|
+
}
|
5222
|
+
return void 0;
|
5223
|
+
}, [search, name2, value]);
|
5224
|
+
const prevValue = usePrev(value);
|
5225
|
+
React.useEffect(() => {
|
5226
|
+
if (prevValue && prevValue.length < value.length) {
|
5227
|
+
setCollapseToOpen(value[value.length - 1].__temp_key__);
|
5228
|
+
}
|
5229
|
+
}, [value, prevValue]);
|
5230
|
+
React.useEffect(() => {
|
5231
|
+
if (typeof componentTmpKeyWithFocussedField === "string") {
|
5232
|
+
setCollapseToOpen(componentTmpKeyWithFocussedField);
|
5233
|
+
}
|
5234
|
+
}, [componentTmpKeyWithFocussedField]);
|
5235
|
+
const toggleCollapses = () => {
|
5236
|
+
setCollapseToOpen("");
|
5237
|
+
};
|
5238
|
+
const handleClick = () => {
|
5239
|
+
if (value.length < max) {
|
5240
|
+
const schema = components[attribute.component];
|
5241
|
+
const form = createDefaultForm(schema, components);
|
5242
|
+
const data = transformDocument(schema, components)(form);
|
5243
|
+
addFieldRow(name2, data);
|
5244
|
+
} else if (value.length >= max) {
|
5245
|
+
toggleNotification({
|
5246
|
+
type: "info",
|
5247
|
+
message: formatMessage({
|
5248
|
+
id: getTranslation("components.notification.info.maximum-requirement")
|
5249
|
+
})
|
5250
|
+
});
|
5251
|
+
}
|
5252
|
+
};
|
5253
|
+
const handleMoveComponentField = (newIndex, currentIndex) => {
|
5254
|
+
setLiveText(
|
5255
|
+
formatMessage(
|
5256
|
+
{
|
5257
|
+
id: getTranslation("dnd.reorder"),
|
5258
|
+
defaultMessage: "{item}, moved. New position in list: {position}."
|
5259
|
+
},
|
5260
|
+
{
|
5261
|
+
item: `${name2}.${currentIndex}`,
|
5262
|
+
position: getItemPos(newIndex)
|
5024
5263
|
}
|
5025
|
-
)
|
5026
|
-
|
5027
|
-
|
5028
|
-
|
5029
|
-
|
5030
|
-
|
5031
|
-
|
5032
|
-
|
5033
|
-
|
5034
|
-
|
5035
|
-
|
5036
|
-
InputRenderer$1,
|
5264
|
+
)
|
5265
|
+
);
|
5266
|
+
moveFieldRow(name2, currentIndex, newIndex);
|
5267
|
+
};
|
5268
|
+
const handleValueChange = (key) => {
|
5269
|
+
setCollapseToOpen(key);
|
5270
|
+
};
|
5271
|
+
const getItemPos = (index) => `${index + 1} of ${value.length}`;
|
5272
|
+
const handleCancel = (index) => {
|
5273
|
+
setLiveText(
|
5274
|
+
formatMessage(
|
5037
5275
|
{
|
5038
|
-
|
5039
|
-
|
5040
|
-
|
5041
|
-
|
5042
|
-
|
5276
|
+
id: getTranslation("dnd.cancel-item"),
|
5277
|
+
defaultMessage: "{item}, dropped. Re-order cancelled."
|
5278
|
+
},
|
5279
|
+
{
|
5280
|
+
item: `${name2}.${index}`
|
5043
5281
|
}
|
5044
|
-
)
|
5045
|
-
|
5046
|
-
|
5047
|
-
|
5048
|
-
|
5282
|
+
)
|
5283
|
+
);
|
5284
|
+
};
|
5285
|
+
const handleGrabItem = (index) => {
|
5286
|
+
setLiveText(
|
5287
|
+
formatMessage(
|
5049
5288
|
{
|
5050
|
-
|
5051
|
-
|
5052
|
-
|
5053
|
-
|
5289
|
+
id: getTranslation("dnd.grab-item"),
|
5290
|
+
defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
|
5291
|
+
},
|
5292
|
+
{
|
5293
|
+
item: `${name2}.${index}`,
|
5294
|
+
position: getItemPos(index)
|
5054
5295
|
}
|
5055
|
-
)
|
5296
|
+
)
|
5297
|
+
);
|
5298
|
+
};
|
5299
|
+
const handleDropItem = (index) => {
|
5300
|
+
setLiveText(
|
5301
|
+
formatMessage(
|
5302
|
+
{
|
5303
|
+
id: getTranslation("dnd.drop-item"),
|
5304
|
+
defaultMessage: `{item}, dropped. Final position in list: {position}.`
|
5305
|
+
},
|
5306
|
+
{
|
5307
|
+
item: `${name2}.${index}`,
|
5308
|
+
position: getItemPos(index)
|
5309
|
+
}
|
5310
|
+
)
|
5311
|
+
);
|
5312
|
+
};
|
5313
|
+
const ariaDescriptionId = React.useId();
|
5314
|
+
const level = useComponent("RepeatableComponent", (state) => state.level);
|
5315
|
+
if (value.length === 0) {
|
5316
|
+
return /* @__PURE__ */ jsx(Initializer, { disabled, name: name2, onClick: handleClick });
|
5056
5317
|
}
|
5318
|
+
return /* @__PURE__ */ jsxs(Box, { hasRadius: true, children: [
|
5319
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
|
5320
|
+
id: getTranslation("dnd.instructions"),
|
5321
|
+
defaultMessage: `Press spacebar to grab and re-order`
|
5322
|
+
}) }),
|
5323
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { "aria-live": "assertive", children: liveText }),
|
5324
|
+
/* @__PURE__ */ jsxs(
|
5325
|
+
AccordionRoot,
|
5326
|
+
{
|
5327
|
+
$error: error,
|
5328
|
+
value: collapseToOpen,
|
5329
|
+
onValueChange: handleValueChange,
|
5330
|
+
"aria-describedby": ariaDescriptionId,
|
5331
|
+
children: [
|
5332
|
+
value.map(({ __temp_key__: key, id }, index) => {
|
5333
|
+
const nameWithIndex = `${name2}.${index}`;
|
5334
|
+
return /* @__PURE__ */ jsx(
|
5335
|
+
ComponentProvider,
|
5336
|
+
{
|
5337
|
+
id,
|
5338
|
+
uid: attribute.component,
|
5339
|
+
level: level + 1,
|
5340
|
+
type: "repeatable",
|
5341
|
+
children: /* @__PURE__ */ jsx(
|
5342
|
+
Component,
|
5343
|
+
{
|
5344
|
+
disabled,
|
5345
|
+
name: nameWithIndex,
|
5346
|
+
attribute,
|
5347
|
+
index,
|
5348
|
+
mainField,
|
5349
|
+
onMoveItem: handleMoveComponentField,
|
5350
|
+
onDeleteComponent: () => {
|
5351
|
+
removeFieldRow(name2, index);
|
5352
|
+
toggleCollapses();
|
5353
|
+
},
|
5354
|
+
toggleCollapses,
|
5355
|
+
onCancel: handleCancel,
|
5356
|
+
onDropItem: handleDropItem,
|
5357
|
+
onGrabItem: handleGrabItem,
|
5358
|
+
__temp_key__: key,
|
5359
|
+
children: layout.map((row, index2) => {
|
5360
|
+
return /* @__PURE__ */ jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
|
5361
|
+
const completeFieldName = `${nameWithIndex}.${field.name}`;
|
5362
|
+
const translatedLabel = formatMessage({
|
5363
|
+
id: `content-manager.components.${attribute.component}.${field.name}`,
|
5364
|
+
defaultMessage: field.label
|
5365
|
+
});
|
5366
|
+
return /* @__PURE__ */ jsx(
|
5367
|
+
ResponsiveGridItem,
|
5368
|
+
{
|
5369
|
+
col: size,
|
5370
|
+
s: 12,
|
5371
|
+
xs: 12,
|
5372
|
+
direction: "column",
|
5373
|
+
alignItems: "stretch",
|
5374
|
+
children: children({
|
5375
|
+
...field,
|
5376
|
+
label: translatedLabel,
|
5377
|
+
name: completeFieldName
|
5378
|
+
})
|
5379
|
+
},
|
5380
|
+
completeFieldName
|
5381
|
+
);
|
5382
|
+
}) }, index2);
|
5383
|
+
})
|
5384
|
+
}
|
5385
|
+
)
|
5386
|
+
},
|
5387
|
+
key
|
5388
|
+
);
|
5389
|
+
}),
|
5390
|
+
/* @__PURE__ */ jsx(TextButtonCustom, { disabled, onClick: handleClick, startIcon: /* @__PURE__ */ jsx(Plus, {}), children: formatMessage({
|
5391
|
+
id: getTranslation("containers.EditView.add.new-entry"),
|
5392
|
+
defaultMessage: "Add an entry"
|
5393
|
+
}) })
|
5394
|
+
]
|
5395
|
+
}
|
5396
|
+
)
|
5397
|
+
] });
|
5057
5398
|
};
|
5058
|
-
const
|
5059
|
-
|
5060
|
-
|
5061
|
-
|
5062
|
-
|
5063
|
-
|
5064
|
-
|
5065
|
-
|
5066
|
-
|
5067
|
-
)
|
5068
|
-
|
5069
|
-
|
5070
|
-
|
5071
|
-
|
5072
|
-
|
5073
|
-
|
5074
|
-
|
5075
|
-
) : null;
|
5076
|
-
const hasMinAndMax = typeof minimum === "number" && typeof maximum === "number";
|
5077
|
-
return formatMessage(
|
5078
|
-
{
|
5079
|
-
id: "content-manager.form.Input.hint.text",
|
5080
|
-
defaultMessage: "{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}"
|
5081
|
-
},
|
5082
|
-
{
|
5083
|
-
min: minimum,
|
5084
|
-
max: maximum,
|
5085
|
-
description: hint,
|
5086
|
-
unit: units,
|
5087
|
-
divider: hasMinAndMax ? formatMessage({
|
5088
|
-
id: "content-manager.form.Input.hint.minMaxDivider",
|
5089
|
-
defaultMessage: " / "
|
5090
|
-
}) : null,
|
5091
|
-
br: /* @__PURE__ */ jsx("br", {})
|
5399
|
+
const AccordionRoot = styled(Accordion.Root)`
|
5400
|
+
border: 1px solid
|
5401
|
+
${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
|
5402
|
+
`;
|
5403
|
+
const TextButtonCustom = styled(TextButton)`
|
5404
|
+
width: 100%;
|
5405
|
+
display: flex;
|
5406
|
+
justify-content: center;
|
5407
|
+
border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
|
5408
|
+
padding-inline: ${(props) => props.theme.spaces[6]};
|
5409
|
+
padding-block: ${(props) => props.theme.spaces[3]};
|
5410
|
+
|
5411
|
+
&:not([disabled]) {
|
5412
|
+
cursor: pointer;
|
5413
|
+
|
5414
|
+
&:hover {
|
5415
|
+
background-color: ${(props) => props.theme.colors.primary100};
|
5092
5416
|
}
|
5093
|
-
);
|
5094
|
-
};
|
5095
|
-
const getMinMax = (attribute) => {
|
5096
|
-
if ("min" in attribute || "max" in attribute) {
|
5097
|
-
return {
|
5098
|
-
maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : void 0,
|
5099
|
-
minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : void 0
|
5100
|
-
};
|
5101
|
-
} else if ("maxLength" in attribute || "minLength" in attribute) {
|
5102
|
-
return { maximum: attribute.maxLength, minimum: attribute.minLength };
|
5103
|
-
} else {
|
5104
|
-
return { maximum: void 0, minimum: void 0 };
|
5105
5417
|
}
|
5106
|
-
|
5107
|
-
|
5108
|
-
|
5109
|
-
|
5418
|
+
|
5419
|
+
span {
|
5420
|
+
font-weight: 600;
|
5421
|
+
font-size: 1.4rem;
|
5422
|
+
line-height: 2.4rem;
|
5423
|
+
}
|
5424
|
+
|
5425
|
+
@media (prefers-reduced-motion: no-preference) {
|
5426
|
+
transition: background-color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
|
5427
|
+
}
|
5428
|
+
`;
|
5429
|
+
const Component = ({
|
5110
5430
|
disabled,
|
5111
5431
|
index,
|
5112
5432
|
name: name2,
|
5113
|
-
|
5114
|
-
|
5115
|
-
|
5116
|
-
|
5117
|
-
|
5118
|
-
|
5119
|
-
|
5433
|
+
mainField = {
|
5434
|
+
name: "id",
|
5435
|
+
type: "integer"
|
5436
|
+
},
|
5437
|
+
children,
|
5438
|
+
onDeleteComponent,
|
5439
|
+
toggleCollapses,
|
5440
|
+
__temp_key__,
|
5441
|
+
...dragProps
|
5120
5442
|
}) => {
|
5121
5443
|
const { formatMessage } = useIntl();
|
5122
|
-
const
|
5123
|
-
|
5124
|
-
|
5125
|
-
|
5126
|
-
const
|
5127
|
-
const { mainField } = components[componentUid]?.settings ?? { mainField: "id" };
|
5128
|
-
const mainFieldValue = getIn(formValues, `${name2}.${index}.${mainField}`);
|
5129
|
-
const displayedValue = mainField === "id" || !mainFieldValue ? "" : String(mainFieldValue).trim();
|
5130
|
-
const mainValue = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;
|
5131
|
-
return mainValue;
|
5132
|
-
}, [componentUid, components, formValues, name2, index]);
|
5133
|
-
const { icon, displayName } = React.useMemo(() => {
|
5134
|
-
const [category] = componentUid.split(".");
|
5135
|
-
const { icon: icon2, displayName: displayName2 } = (dynamicComponentsByCategory[category] ?? []).find(
|
5136
|
-
(component) => component.uid === componentUid
|
5137
|
-
) ?? { icon: null, displayName: null };
|
5138
|
-
return { icon: icon2, displayName: displayName2 };
|
5139
|
-
}, [componentUid, dynamicComponentsByCategory]);
|
5444
|
+
const displayValue = useForm("RepeatableComponent", (state) => {
|
5445
|
+
return getIn(state.values, [...name2.split("."), mainField.name]);
|
5446
|
+
});
|
5447
|
+
const accordionRef = React.useRef(null);
|
5448
|
+
const componentKey = name2.split(".").slice(0, -1).join(".");
|
5140
5449
|
const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop(!disabled, {
|
5141
|
-
type: `${ItemTypes.
|
5450
|
+
type: `${ItemTypes.COMPONENT}_${componentKey}`,
|
5142
5451
|
index,
|
5143
5452
|
item: {
|
5144
5453
|
index,
|
5145
|
-
displayedValue:
|
5146
|
-
icon
|
5454
|
+
displayedValue: displayValue
|
5147
5455
|
},
|
5148
|
-
|
5149
|
-
|
5150
|
-
|
5151
|
-
|
5456
|
+
onStart() {
|
5457
|
+
toggleCollapses();
|
5458
|
+
},
|
5459
|
+
...dragProps
|
5152
5460
|
});
|
5153
5461
|
React.useEffect(() => {
|
5154
5462
|
dragPreviewRef(getEmptyImage(), { captureDraggingState: false });
|
5155
5463
|
}, [dragPreviewRef, index]);
|
5156
|
-
const
|
5157
|
-
const
|
5158
|
-
|
5159
|
-
|
5160
|
-
|
5161
|
-
|
5162
|
-
|
5163
|
-
|
5164
|
-
|
5165
|
-
|
5166
|
-
|
5167
|
-
IconButton,
|
5168
|
-
{
|
5169
|
-
variant: "ghost",
|
5170
|
-
label: formatMessage(
|
5464
|
+
const composedAccordionRefs = useComposedRefs(accordionRef, dragRef);
|
5465
|
+
const composedBoxRefs = useComposedRefs(
|
5466
|
+
boxRef,
|
5467
|
+
dropRef
|
5468
|
+
);
|
5469
|
+
return /* @__PURE__ */ jsx(Fragment, { children: isDragging ? /* @__PURE__ */ jsx(Preview, {}) : /* @__PURE__ */ jsxs(Accordion.Item, { ref: composedBoxRefs, value: __temp_key__, children: [
|
5470
|
+
/* @__PURE__ */ jsxs(Accordion.Header, { children: [
|
5471
|
+
/* @__PURE__ */ jsx(Accordion.Trigger, { children: displayValue }),
|
5472
|
+
/* @__PURE__ */ jsxs(Accordion.Actions, { children: [
|
5473
|
+
/* @__PURE__ */ jsx(
|
5474
|
+
IconButton,
|
5171
5475
|
{
|
5172
|
-
|
5173
|
-
|
5174
|
-
|
5175
|
-
|
5476
|
+
variant: "ghost",
|
5477
|
+
onClick: onDeleteComponent,
|
5478
|
+
label: formatMessage({
|
5479
|
+
id: getTranslation("containers.Edit.delete"),
|
5480
|
+
defaultMessage: "Delete"
|
5481
|
+
}),
|
5482
|
+
children: /* @__PURE__ */ jsx(Trash, {})
|
5483
|
+
}
|
5176
5484
|
),
|
5177
|
-
onClick: onRemoveComponentClick,
|
5178
|
-
children: /* @__PURE__ */ jsx(Trash, {})
|
5179
|
-
}
|
5180
|
-
),
|
5181
|
-
/* @__PURE__ */ jsx(
|
5182
|
-
IconButton,
|
5183
|
-
{
|
5184
|
-
variant: "ghost",
|
5185
|
-
onClick: (e) => e.stopPropagation(),
|
5186
|
-
"data-handler-id": handlerId,
|
5187
|
-
ref: dragRef,
|
5188
|
-
label: formatMessage({
|
5189
|
-
id: getTranslation("components.DragHandle-label"),
|
5190
|
-
defaultMessage: "Drag"
|
5191
|
-
}),
|
5192
|
-
onKeyDown: handleKeyDown,
|
5193
|
-
children: /* @__PURE__ */ jsx(Drag, {})
|
5194
|
-
}
|
5195
|
-
),
|
5196
|
-
/* @__PURE__ */ jsxs(Menu.Root, { children: [
|
5197
|
-
/* @__PURE__ */ jsxs(Menu.Trigger, { size: "S", endIcon: null, paddingLeft: 2, paddingRight: 2, children: [
|
5198
|
-
/* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false }),
|
5199
|
-
/* @__PURE__ */ jsx(VisuallyHidden, { tag: "span", children: formatMessage({
|
5200
|
-
id: getTranslation("components.DynamicZone.more-actions"),
|
5201
|
-
defaultMessage: "More actions"
|
5202
|
-
}) })
|
5203
|
-
] }),
|
5204
|
-
/* @__PURE__ */ jsxs(Menu.Content, { children: [
|
5205
|
-
/* @__PURE__ */ jsxs(Menu.SubRoot, { children: [
|
5206
|
-
/* @__PURE__ */ jsx(Menu.SubTrigger, { children: formatMessage({
|
5207
|
-
id: getTranslation("components.DynamicZone.add-item-above"),
|
5208
|
-
defaultMessage: "Add component above"
|
5209
|
-
}) }),
|
5210
|
-
/* @__PURE__ */ jsx(Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
5211
|
-
/* @__PURE__ */ jsx(Menu.Label, { children: category }),
|
5212
|
-
components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsx(MenuItem, { onSelect: () => onAddComponent(uid, index), children: displayName2 }, componentUid))
|
5213
|
-
] }, category)) })
|
5214
|
-
] }),
|
5215
|
-
/* @__PURE__ */ jsxs(Menu.SubRoot, { children: [
|
5216
|
-
/* @__PURE__ */ jsx(Menu.SubTrigger, { children: formatMessage({
|
5217
|
-
id: getTranslation("components.DynamicZone.add-item-below"),
|
5218
|
-
defaultMessage: "Add component below"
|
5219
|
-
}) }),
|
5220
|
-
/* @__PURE__ */ jsx(Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
5221
|
-
/* @__PURE__ */ jsx(Menu.Label, { children: category }),
|
5222
|
-
components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsx(MenuItem, { onSelect: () => onAddComponent(uid, index + 1), children: displayName2 }, componentUid))
|
5223
|
-
] }, category)) })
|
5224
|
-
] })
|
5225
|
-
] })
|
5226
|
-
] })
|
5227
|
-
] });
|
5228
|
-
const accordionTitle = title ? `${displayName} ${title}` : displayName;
|
5229
|
-
return /* @__PURE__ */ jsxs(ComponentContainer, { tag: "li", width: "100%", children: [
|
5230
|
-
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Rectangle, { background: "neutral200" }) }),
|
5231
|
-
/* @__PURE__ */ jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsx(Preview, {}) : /* @__PURE__ */ jsx(Accordion.Root, { value: collapseToOpen, onValueChange: setCollapseToOpen, children: /* @__PURE__ */ jsxs(Accordion.Item, { value: accordionValue, children: [
|
5232
|
-
/* @__PURE__ */ jsxs(Accordion.Header, { children: [
|
5233
5485
|
/* @__PURE__ */ jsx(
|
5234
|
-
|
5486
|
+
IconButton,
|
5235
5487
|
{
|
5236
|
-
|
5237
|
-
|
5488
|
+
ref: composedAccordionRefs,
|
5489
|
+
variant: "ghost",
|
5490
|
+
onClick: (e) => e.stopPropagation(),
|
5491
|
+
"data-handler-id": handlerId,
|
5492
|
+
label: formatMessage({
|
5493
|
+
id: getTranslation("components.DragHandle-label"),
|
5494
|
+
defaultMessage: "Drag"
|
5495
|
+
}),
|
5496
|
+
onKeyDown: handleKeyDown,
|
5497
|
+
children: /* @__PURE__ */ jsx(Drag, {})
|
5238
5498
|
}
|
5239
|
-
)
|
5240
|
-
/* @__PURE__ */ jsx(Accordion.Actions, { children: accordionActions })
|
5241
|
-
] }),
|
5242
|
-
/* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(AccordionContentRadius, { background: "neutral0", children: /* @__PURE__ */ jsx(Box, { paddingLeft: 6, paddingRight: 6, paddingTop: 6, paddingBottom: 6, children: /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: components[componentUid]?.layout?.map((row, rowInd) => /* @__PURE__ */ jsx(
|
5243
|
-
Grid$1.Item,
|
5244
|
-
{
|
5245
|
-
col: 12,
|
5246
|
-
s: 12,
|
5247
|
-
xs: 12,
|
5248
|
-
direction: "column",
|
5249
|
-
alignItems: "stretch",
|
5250
|
-
children: /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: row.map(({ size, ...field }) => {
|
5251
|
-
const fieldName = `${name2}.${index}.${field.name}`;
|
5252
|
-
const fieldWithTranslatedLabel = {
|
5253
|
-
...field,
|
5254
|
-
label: formatMessage({
|
5255
|
-
id: `content-manager.components.${componentUid}.${field.name}`,
|
5256
|
-
defaultMessage: field.label
|
5257
|
-
})
|
5258
|
-
};
|
5259
|
-
return /* @__PURE__ */ jsx(
|
5260
|
-
Grid$1.Item,
|
5261
|
-
{
|
5262
|
-
col: size,
|
5263
|
-
s: 12,
|
5264
|
-
xs: 12,
|
5265
|
-
direction: "column",
|
5266
|
-
alignItems: "stretch",
|
5267
|
-
children: /* @__PURE__ */ jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel, name: fieldName })
|
5268
|
-
},
|
5269
|
-
fieldName
|
5270
|
-
);
|
5271
|
-
}) })
|
5272
|
-
},
|
5273
|
-
rowInd
|
5274
|
-
)) }) }) }) })
|
5275
|
-
] }) }) })
|
5276
|
-
] });
|
5277
|
-
};
|
5278
|
-
const StyledBox = styled(Box)`
|
5279
|
-
> div:first-child {
|
5280
|
-
box-shadow: ${({ theme }) => theme.shadows.tableShadow};
|
5281
|
-
}
|
5282
|
-
`;
|
5283
|
-
const AccordionContentRadius = styled(Box)`
|
5284
|
-
border-radius: 0 0 ${({ theme }) => theme.spaces[1]} ${({ theme }) => theme.spaces[1]};
|
5285
|
-
`;
|
5286
|
-
const Rectangle = styled(Box)`
|
5287
|
-
width: ${({ theme }) => theme.spaces[2]};
|
5288
|
-
height: ${({ theme }) => theme.spaces[4]};
|
5289
|
-
`;
|
5290
|
-
const Preview = styled.span`
|
5291
|
-
display: block;
|
5292
|
-
background-color: ${({ theme }) => theme.colors.primary100};
|
5293
|
-
outline: 1px dashed ${({ theme }) => theme.colors.primary500};
|
5294
|
-
outline-offset: -1px;
|
5295
|
-
padding: ${({ theme }) => theme.spaces[6]};
|
5296
|
-
`;
|
5297
|
-
const ComponentContainer = styled(Box)`
|
5298
|
-
list-style: none;
|
5299
|
-
padding: 0;
|
5300
|
-
margin: 0;
|
5301
|
-
`;
|
5302
|
-
const DynamicZoneLabel = ({
|
5303
|
-
hint,
|
5304
|
-
label,
|
5305
|
-
labelAction,
|
5306
|
-
name: name2,
|
5307
|
-
numberOfComponents = 0,
|
5308
|
-
required
|
5309
|
-
}) => {
|
5310
|
-
return /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(
|
5311
|
-
Box,
|
5312
|
-
{
|
5313
|
-
paddingTop: 3,
|
5314
|
-
paddingBottom: 3,
|
5315
|
-
paddingRight: 4,
|
5316
|
-
paddingLeft: 4,
|
5317
|
-
borderRadius: "26px",
|
5318
|
-
background: "neutral0",
|
5319
|
-
shadow: "filterShadow",
|
5320
|
-
color: "neutral500",
|
5321
|
-
children: /* @__PURE__ */ jsxs(Flex, { direction: "column", justifyContent: "center", children: [
|
5322
|
-
/* @__PURE__ */ jsxs(Flex, { maxWidth: "35.6rem", children: [
|
5323
|
-
/* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", ellipsis: true, children: [
|
5324
|
-
label || name2,
|
5325
|
-
" "
|
5326
|
-
] }),
|
5327
|
-
/* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", children: [
|
5328
|
-
"(",
|
5329
|
-
numberOfComponents,
|
5330
|
-
")"
|
5331
|
-
] }),
|
5332
|
-
required && /* @__PURE__ */ jsx(Typography, { textColor: "danger600", children: "*" }),
|
5333
|
-
labelAction && /* @__PURE__ */ jsx(Box, { paddingLeft: 1, children: labelAction })
|
5334
|
-
] }),
|
5335
|
-
hint && /* @__PURE__ */ jsx(Box, { paddingTop: 1, maxWidth: "35.6rem", children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", ellipsis: true, children: hint }) })
|
5499
|
+
)
|
5336
5500
|
] })
|
5337
|
-
}
|
5338
|
-
|
5339
|
-
|
5340
|
-
|
5341
|
-
|
5342
|
-
|
5343
|
-
|
5344
|
-
|
5345
|
-
|
5346
|
-
|
5347
|
-
|
5348
|
-
|
5349
|
-
|
5501
|
+
] }),
|
5502
|
+
/* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(
|
5503
|
+
Flex,
|
5504
|
+
{
|
5505
|
+
direction: "column",
|
5506
|
+
alignItems: "stretch",
|
5507
|
+
background: "neutral100",
|
5508
|
+
padding: 6,
|
5509
|
+
gap: 6,
|
5510
|
+
children
|
5511
|
+
}
|
5512
|
+
) })
|
5513
|
+
] }) });
|
5514
|
+
};
|
5515
|
+
const Preview = () => {
|
5516
|
+
return /* @__PURE__ */ jsx(StyledSpan, { tag: "span", padding: 6, background: "primary100" });
|
5517
|
+
};
|
5518
|
+
const StyledSpan = styled(Box)`
|
5519
|
+
display: block;
|
5520
|
+
outline: 1px dashed ${({ theme }) => theme.colors.primary500};
|
5521
|
+
outline-offset: -1px;
|
5522
|
+
`;
|
5523
|
+
const ComponentInput = ({
|
5350
5524
|
label,
|
5351
|
-
|
5525
|
+
required,
|
5352
5526
|
name: name2,
|
5353
|
-
|
5527
|
+
attribute,
|
5528
|
+
disabled,
|
5529
|
+
labelAction,
|
5530
|
+
...props
|
5354
5531
|
}) => {
|
5355
|
-
const { max = Infinity, min = -Infinity } = attribute ?? {};
|
5356
|
-
const [addComponentIsOpen, setAddComponentIsOpen] = React.useState(false);
|
5357
|
-
const [liveText, setLiveText] = React.useState("");
|
5358
|
-
const { components, isLoading } = useDoc();
|
5359
|
-
const disabled = disabledProp || isLoading;
|
5360
|
-
const { addFieldRow, removeFieldRow, moveFieldRow } = useForm(
|
5361
|
-
"DynamicZone",
|
5362
|
-
({ addFieldRow: addFieldRow2, removeFieldRow: removeFieldRow2, moveFieldRow: moveFieldRow2 }) => ({
|
5363
|
-
addFieldRow: addFieldRow2,
|
5364
|
-
removeFieldRow: removeFieldRow2,
|
5365
|
-
moveFieldRow: moveFieldRow2
|
5366
|
-
})
|
5367
|
-
);
|
5368
|
-
const { value = [], error } = useField(name2);
|
5369
|
-
const dynamicComponentsByCategory = React.useMemo(() => {
|
5370
|
-
return attribute.components.reduce((acc, componentUid) => {
|
5371
|
-
const { category, info } = components[componentUid] ?? { info: {} };
|
5372
|
-
const component = { uid: componentUid, displayName: info.displayName, icon: info.icon };
|
5373
|
-
if (!acc[category]) {
|
5374
|
-
acc[category] = [];
|
5375
|
-
}
|
5376
|
-
acc[category] = [...acc[category], component];
|
5377
|
-
return acc;
|
5378
|
-
}, {});
|
5379
|
-
}, [attribute.components, components]);
|
5380
5532
|
const { formatMessage } = useIntl();
|
5381
|
-
const
|
5382
|
-
const
|
5383
|
-
const
|
5384
|
-
|
5385
|
-
const schema = components[
|
5533
|
+
const field = useField(name2);
|
5534
|
+
const showResetComponent = !attribute.repeatable && field.value && !disabled;
|
5535
|
+
const { components } = useDoc();
|
5536
|
+
const handleInitialisationClick = () => {
|
5537
|
+
const schema = components[attribute.component];
|
5386
5538
|
const form = createDefaultForm(schema, components);
|
5387
|
-
const
|
5388
|
-
|
5389
|
-
__component: uid
|
5390
|
-
}));
|
5391
|
-
const data = transformations(form);
|
5392
|
-
addFieldRow(name2, data, position);
|
5393
|
-
};
|
5394
|
-
const handleClickOpenPicker = () => {
|
5395
|
-
if (dynamicDisplayedComponentsLength < max) {
|
5396
|
-
setAddComponentIsOpen((prev) => !prev);
|
5397
|
-
} else {
|
5398
|
-
toggleNotification({
|
5399
|
-
type: "info",
|
5400
|
-
message: formatMessage({
|
5401
|
-
id: getTranslation("components.notification.info.maximum-requirement")
|
5402
|
-
})
|
5403
|
-
});
|
5404
|
-
}
|
5405
|
-
};
|
5406
|
-
const handleMoveComponent = (newIndex, currentIndex) => {
|
5407
|
-
setLiveText(
|
5408
|
-
formatMessage(
|
5409
|
-
{
|
5410
|
-
id: getTranslation("dnd.reorder"),
|
5411
|
-
defaultMessage: "{item}, moved. New position in list: {position}."
|
5412
|
-
},
|
5413
|
-
{
|
5414
|
-
item: `${name2}.${currentIndex}`,
|
5415
|
-
position: getItemPos(newIndex)
|
5416
|
-
}
|
5417
|
-
)
|
5418
|
-
);
|
5419
|
-
moveFieldRow(name2, currentIndex, newIndex);
|
5420
|
-
};
|
5421
|
-
const getItemPos = (index) => `${index + 1} of ${value.length}`;
|
5422
|
-
const handleCancel = (index) => {
|
5423
|
-
setLiveText(
|
5424
|
-
formatMessage(
|
5425
|
-
{
|
5426
|
-
id: getTranslation("dnd.cancel-item"),
|
5427
|
-
defaultMessage: "{item}, dropped. Re-order cancelled."
|
5428
|
-
},
|
5429
|
-
{
|
5430
|
-
item: `${name2}.${index}`
|
5431
|
-
}
|
5432
|
-
)
|
5433
|
-
);
|
5434
|
-
};
|
5435
|
-
const handleGrabItem = (index) => {
|
5436
|
-
setLiveText(
|
5437
|
-
formatMessage(
|
5438
|
-
{
|
5439
|
-
id: getTranslation("dnd.grab-item"),
|
5440
|
-
defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
|
5441
|
-
},
|
5442
|
-
{
|
5443
|
-
item: `${name2}.${index}`,
|
5444
|
-
position: getItemPos(index)
|
5445
|
-
}
|
5446
|
-
)
|
5447
|
-
);
|
5539
|
+
const data = transformDocument(schema, components)(form);
|
5540
|
+
field.onChange(name2, data);
|
5448
5541
|
};
|
5449
|
-
|
5450
|
-
|
5451
|
-
|
5452
|
-
|
5453
|
-
|
5454
|
-
|
5455
|
-
|
5542
|
+
return /* @__PURE__ */ jsxs(Field.Root, { error: field.error, required, children: [
|
5543
|
+
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", children: [
|
5544
|
+
/* @__PURE__ */ jsxs(Field.Label, { action: labelAction, children: [
|
5545
|
+
label,
|
5546
|
+
attribute.repeatable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
5547
|
+
" (",
|
5548
|
+
Array.isArray(field.value) ? field.value.length : 0,
|
5549
|
+
")"
|
5550
|
+
] })
|
5551
|
+
] }),
|
5552
|
+
showResetComponent && /* @__PURE__ */ jsx(
|
5553
|
+
IconButton,
|
5456
5554
|
{
|
5457
|
-
|
5458
|
-
|
5555
|
+
label: formatMessage({
|
5556
|
+
id: getTranslation("components.reset-entry"),
|
5557
|
+
defaultMessage: "Reset Entry"
|
5558
|
+
}),
|
5559
|
+
variant: "ghost",
|
5560
|
+
onClick: () => {
|
5561
|
+
field.onChange(name2, null);
|
5562
|
+
},
|
5563
|
+
children: /* @__PURE__ */ jsx(Trash, {})
|
5459
5564
|
}
|
5460
5565
|
)
|
5461
|
-
);
|
5462
|
-
};
|
5463
|
-
const handleRemoveComponent = (name22, currentIndex) => () => {
|
5464
|
-
removeFieldRow(name22, currentIndex);
|
5465
|
-
};
|
5466
|
-
const hasError = error !== void 0;
|
5467
|
-
const renderButtonLabel = () => {
|
5468
|
-
if (addComponentIsOpen) {
|
5469
|
-
return formatMessage({ id: "app.utils.close-label", defaultMessage: "Close" });
|
5470
|
-
}
|
5471
|
-
if (hasError && dynamicDisplayedComponentsLength > max) {
|
5472
|
-
return formatMessage(
|
5473
|
-
{
|
5474
|
-
id: getTranslation(`components.DynamicZone.extra-components`),
|
5475
|
-
defaultMessage: "There {number, plural, =0 {are # extra components} one {is # extra component} other {are # extra components}}"
|
5476
|
-
},
|
5477
|
-
{
|
5478
|
-
number: dynamicDisplayedComponentsLength - max
|
5479
|
-
}
|
5480
|
-
);
|
5481
|
-
}
|
5482
|
-
if (hasError && dynamicDisplayedComponentsLength < min) {
|
5483
|
-
return formatMessage(
|
5484
|
-
{
|
5485
|
-
id: getTranslation(`components.DynamicZone.missing-components`),
|
5486
|
-
defaultMessage: "There {number, plural, =0 {are # missing components} one {is # missing component} other {are # missing components}}"
|
5487
|
-
},
|
5488
|
-
{ number: min - dynamicDisplayedComponentsLength }
|
5489
|
-
);
|
5490
|
-
}
|
5491
|
-
return formatMessage(
|
5492
|
-
{
|
5493
|
-
id: getTranslation("components.DynamicZone.add-component"),
|
5494
|
-
defaultMessage: "Add a component to {componentName}"
|
5495
|
-
},
|
5496
|
-
{ componentName: label || name2 }
|
5497
|
-
);
|
5498
|
-
};
|
5499
|
-
const level = useComponent("DynamicZone", (state) => state.level);
|
5500
|
-
const ariaDescriptionId = React.useId();
|
5501
|
-
return /* @__PURE__ */ jsx(DynamicZoneProvider, { isInDynamicZone: true, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
5502
|
-
dynamicDisplayedComponentsLength > 0 && /* @__PURE__ */ jsxs(Box, { children: [
|
5503
|
-
/* @__PURE__ */ jsx(
|
5504
|
-
DynamicZoneLabel,
|
5505
|
-
{
|
5506
|
-
hint,
|
5507
|
-
label,
|
5508
|
-
labelAction,
|
5509
|
-
name: name2,
|
5510
|
-
numberOfComponents: dynamicDisplayedComponentsLength,
|
5511
|
-
required
|
5512
|
-
}
|
5513
|
-
),
|
5514
|
-
/* @__PURE__ */ jsx(VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
|
5515
|
-
id: getTranslation("dnd.instructions"),
|
5516
|
-
defaultMessage: `Press spacebar to grab and re-order`
|
5517
|
-
}) }),
|
5518
|
-
/* @__PURE__ */ jsx(VisuallyHidden, { "aria-live": "assertive", children: liveText }),
|
5519
|
-
/* @__PURE__ */ jsx("ol", { "aria-describedby": ariaDescriptionId, children: value.map((field, index) => /* @__PURE__ */ jsx(
|
5520
|
-
ComponentProvider,
|
5521
|
-
{
|
5522
|
-
level: level + 1,
|
5523
|
-
uid: field.__component,
|
5524
|
-
id: field.id,
|
5525
|
-
type: "dynamiczone",
|
5526
|
-
children: /* @__PURE__ */ jsx(
|
5527
|
-
DynamicComponent,
|
5528
|
-
{
|
5529
|
-
disabled,
|
5530
|
-
name: name2,
|
5531
|
-
index,
|
5532
|
-
componentUid: field.__component,
|
5533
|
-
onMoveComponent: handleMoveComponent,
|
5534
|
-
onRemoveComponentClick: handleRemoveComponent(name2, index),
|
5535
|
-
onCancel: handleCancel,
|
5536
|
-
onDropItem: handleDropItem,
|
5537
|
-
onGrabItem: handleGrabItem,
|
5538
|
-
onAddComponent: handleAddComponent,
|
5539
|
-
dynamicComponentsByCategory
|
5540
|
-
}
|
5541
|
-
)
|
5542
|
-
},
|
5543
|
-
field.__temp_key__
|
5544
|
-
)) })
|
5545
5566
|
] }),
|
5546
|
-
/* @__PURE__ */ jsx(
|
5547
|
-
|
5548
|
-
|
5549
|
-
|
5550
|
-
|
5551
|
-
isOpen: addComponentIsOpen,
|
5552
|
-
onClick: handleClickOpenPicker,
|
5553
|
-
children: renderButtonLabel()
|
5554
|
-
}
|
5555
|
-
) }),
|
5556
|
-
/* @__PURE__ */ jsx(
|
5557
|
-
ComponentPicker,
|
5558
|
-
{
|
5559
|
-
dynamicComponentsByCategory,
|
5560
|
-
isOpen: addComponentIsOpen,
|
5561
|
-
onClickAddComponent: handleAddComponent
|
5562
|
-
}
|
5563
|
-
)
|
5564
|
-
] }) });
|
5567
|
+
!attribute.repeatable && !field.value && /* @__PURE__ */ jsx(Initializer, { disabled, name: name2, onClick: handleInitialisationClick }),
|
5568
|
+
!attribute.repeatable && field.value ? /* @__PURE__ */ jsx(NonRepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }) : null,
|
5569
|
+
attribute.repeatable && /* @__PURE__ */ jsx(RepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }),
|
5570
|
+
/* @__PURE__ */ jsx(Field.Error, {})
|
5571
|
+
] });
|
5565
5572
|
};
|
5573
|
+
const MemoizedComponentInput = React.memo(ComponentInput);
|
5566
5574
|
export {
|
5567
5575
|
DynamicZone as D,
|
5568
|
-
|
5576
|
+
FormLayout as F,
|
5577
|
+
MemoizedUIDInput as M,
|
5569
5578
|
NotAllowedInput as N,
|
5570
5579
|
useDynamicZone as a,
|
5571
5580
|
useFieldHint as b,
|
5572
|
-
|
5573
|
-
|
5574
|
-
|
5575
|
-
MemoizedComponentInput as f,
|
5576
|
-
MemoizedBlocksInput as g,
|
5577
|
-
prepareTempKeys as p,
|
5578
|
-
removeFieldsThatDontExistOnSchema as r,
|
5579
|
-
transformDocument as t,
|
5581
|
+
MemoizedWysiwyg as c,
|
5582
|
+
MemoizedComponentInput as d,
|
5583
|
+
MemoizedBlocksInput as e,
|
5580
5584
|
useLazyComponents as u
|
5581
5585
|
};
|
5582
|
-
//# sourceMappingURL=
|
5586
|
+
//# sourceMappingURL=Input-aV8SSoTa.mjs.map
|