@strapi/content-manager 0.0.0-experimental.e60ec1829240dae21c1e1d29076681c322288813 → 0.0.0-experimental.eba25ec571b091c6bde1104eb6c753debdf15462
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/LICENSE +18 -3
- package/dist/_chunks/{CardDragPreview-DSVYodBX.js → CardDragPreview-C0QyJgRA.js} +10 -14
- package/dist/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -0
- package/dist/_chunks/{CardDragPreview-ikSG4M46.mjs → CardDragPreview-DOxamsuj.mjs} +7 -9
- package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -0
- package/dist/_chunks/{ComponentConfigurationPage-BPvzFjM7.mjs → ComponentConfigurationPage-BaJMOQyq.mjs} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-BPvzFjM7.mjs.map → ComponentConfigurationPage-BaJMOQyq.mjs.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-DjWJdz6Y.js → ComponentConfigurationPage-N-CTtgQa.js} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-DjWJdz6Y.js.map → ComponentConfigurationPage-N-CTtgQa.js.map} +1 -1
- package/dist/_chunks/{ComponentIcon-BBQsYCVn.js → ComponentIcon-BXdiCGQp.js} +8 -2
- package/dist/_chunks/ComponentIcon-BXdiCGQp.js.map +1 -0
- package/dist/_chunks/{ComponentIcon-BOFnK76n.mjs → ComponentIcon-u4bIXTFY.mjs} +9 -3
- package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -0
- package/dist/_chunks/{EditConfigurationPage-Dmv83RlS.js → EditConfigurationPage-BHkjAbxH.js} +4 -4
- package/dist/_chunks/{EditConfigurationPage-Dmv83RlS.js.map → EditConfigurationPage-BHkjAbxH.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-DacbqQ_f.mjs → EditConfigurationPage-CKK-5LfX.mjs} +4 -4
- package/dist/_chunks/{EditConfigurationPage-DacbqQ_f.mjs.map → EditConfigurationPage-CKK-5LfX.mjs.map} +1 -1
- package/dist/_chunks/EditViewPage-B11aeMcf.mjs +254 -0
- package/dist/_chunks/EditViewPage-B11aeMcf.mjs.map +1 -0
- package/dist/_chunks/{EditViewPage-DvNpQkam.js → EditViewPage-QPUftxUd.js} +101 -52
- package/dist/_chunks/EditViewPage-QPUftxUd.js.map +1 -0
- package/dist/_chunks/{Field-6gvGdPBV.mjs → Field-Bj_RgtGo.mjs} +1077 -814
- package/dist/_chunks/Field-Bj_RgtGo.mjs.map +1 -0
- package/dist/_chunks/{Field-DmVKIAOo.js → Field-DUK83cfh.js} +1121 -859
- package/dist/_chunks/Field-DUK83cfh.js.map +1 -0
- package/dist/_chunks/{Form-CPZC9vWa.js → Form-DHmBRlHd.js} +66 -46
- package/dist/_chunks/Form-DHmBRlHd.js.map +1 -0
- package/dist/_chunks/{Form-DW6K1IH-.mjs → Form-DLMSoXV7.mjs} +66 -45
- package/dist/_chunks/Form-DLMSoXV7.mjs.map +1 -0
- package/dist/_chunks/{History-Dmr9fmUA.mjs → History-CfCSNlG9.mjs} +181 -144
- package/dist/_chunks/History-CfCSNlG9.mjs.map +1 -0
- package/dist/_chunks/{History-DeAPlvtv.js → History-Di3zm4HT.js} +181 -145
- package/dist/_chunks/History-Di3zm4HT.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DhwvYcNv.mjs → ListConfigurationPage-0mtv_iqk.mjs} +67 -56
- package/dist/_chunks/ListConfigurationPage-0mtv_iqk.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DPCwW5Vr.js → ListConfigurationPage-Cq361KIt.js} +70 -60
- package/dist/_chunks/ListConfigurationPage-Cq361KIt.js.map +1 -0
- package/dist/_chunks/{ListViewPage-BtAwuYLE.mjs → ListViewPage-BxLVROX8.mjs} +175 -159
- package/dist/_chunks/ListViewPage-BxLVROX8.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-5ySZ-VUs.js → ListViewPage-DFDcG8gM.js} +178 -162
- package/dist/_chunks/ListViewPage-DFDcG8gM.js.map +1 -0
- package/dist/_chunks/{NoContentTypePage-DSPxnxxp.mjs → NoContentTypePage-BRfDd67_.mjs} +3 -3
- package/dist/_chunks/NoContentTypePage-BRfDd67_.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-DOC_yWOf.js → NoContentTypePage-BSyvnDZZ.js} +3 -3
- package/dist/_chunks/NoContentTypePage-BSyvnDZZ.js.map +1 -0
- package/dist/_chunks/{NoPermissionsPage-UWDC-1Tw.mjs → NoPermissionsPage-CV9V8KWa.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-UWDC-1Tw.mjs.map → NoPermissionsPage-CV9V8KWa.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-Dwu8rRJu.js → NoPermissionsPage-DyLphsn_.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-Dwu8rRJu.js.map → NoPermissionsPage-DyLphsn_.js.map} +1 -1
- package/dist/_chunks/Preview-C_B1nx3g.mjs +272 -0
- package/dist/_chunks/Preview-C_B1nx3g.mjs.map +1 -0
- package/dist/_chunks/Preview-D_3aO6Ly.js +291 -0
- package/dist/_chunks/Preview-D_3aO6Ly.js.map +1 -0
- package/dist/_chunks/{Relations-J8cscLlR.mjs → Relations-C6pwmDXh.mjs} +135 -89
- package/dist/_chunks/Relations-C6pwmDXh.mjs.map +1 -0
- package/dist/_chunks/{Relations-CgWtgnPe.js → Relations-Cne2AlrL.js} +138 -93
- package/dist/_chunks/Relations-Cne2AlrL.js.map +1 -0
- package/dist/_chunks/{en-MBPul9Su.mjs → en-DhFUjrNW.mjs} +37 -18
- package/dist/_chunks/{en-MBPul9Su.mjs.map → en-DhFUjrNW.mjs.map} +1 -1
- package/dist/_chunks/{en-C-V1_90f.js → en-Ic0kXjxB.js} +37 -18
- package/dist/_chunks/{en-C-V1_90f.js.map → en-Ic0kXjxB.js.map} +1 -1
- package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
- package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
- package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
- package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
- package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
- package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
- package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
- package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
- package/dist/_chunks/{index-CwRRo1V9.mjs → index-BpxR3En4.mjs} +1835 -824
- package/dist/_chunks/index-BpxR3En4.mjs.map +1 -0
- package/dist/_chunks/{index-C6AH2hEl.js → index-T-aWjbj2.js} +1788 -777
- package/dist/_chunks/index-T-aWjbj2.js.map +1 -0
- package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
- package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
- package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
- package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
- package/dist/_chunks/{layout-B_SXLhqf.js → layout-BEuNwv-F.js} +45 -29
- package/dist/_chunks/layout-BEuNwv-F.js.map +1 -0
- package/dist/_chunks/{layout-jIDzX0Fp.mjs → layout-DhMZ_lDx.mjs} +45 -27
- package/dist/_chunks/layout-DhMZ_lDx.mjs.map +1 -0
- package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
- package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
- package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
- package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
- package/dist/_chunks/{relations-CuvIgCqI.mjs → relations-BdnxoX6f.mjs} +6 -7
- package/dist/_chunks/relations-BdnxoX6f.mjs.map +1 -0
- package/dist/_chunks/{relations-iBMa_OFG.js → relations-kLcuobLk.js} +6 -7
- package/dist/_chunks/relations-kLcuobLk.js.map +1 -0
- package/dist/_chunks/useDebounce-CtcjDB3L.js +28 -0
- package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -0
- package/dist/_chunks/useDragAndDrop-DdHgKsqq.mjs.map +1 -1
- package/dist/_chunks/useDragAndDrop-J0TUUbR6.js.map +1 -1
- package/dist/admin/index.js +3 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +9 -7
- package/dist/admin/src/components/ComponentIcon.d.ts +6 -3
- package/dist/admin/src/content-manager.d.ts +3 -3
- package/dist/admin/src/exports.d.ts +2 -1
- package/dist/admin/src/history/components/VersionInputRenderer.d.ts +1 -1
- package/dist/admin/src/history/index.d.ts +3 -0
- package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
- package/dist/admin/src/hooks/useDocument.d.ts +37 -9
- package/dist/admin/src/hooks/useDocumentActions.d.ts +24 -3
- package/dist/admin/src/hooks/useDocumentLayout.d.ts +2 -2
- package/dist/admin/src/hooks/useDragAndDrop.d.ts +4 -4
- package/dist/admin/src/hooks/useKeyboardDragAndDrop.d.ts +1 -1
- package/dist/admin/src/index.d.ts +1 -0
- package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
- package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +11 -4
- package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.d.ts +3 -3
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +4 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/Component/Input.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.d.ts +3 -5
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +30 -18
- package/dist/admin/src/pages/EditView/components/FormInputs/UID.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +3 -49
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/Field.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +16 -53
- package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
- package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +2 -10
- package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +3 -30
- package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +2 -2
- package/dist/admin/src/pages/ListView/components/BulkActions/PublishAction.d.ts +9 -26
- package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
- package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
- package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
- package/dist/admin/src/preview/constants.d.ts +1 -0
- package/dist/admin/src/preview/index.d.ts +4 -0
- package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
- package/dist/admin/src/preview/routes.d.ts +3 -0
- package/dist/admin/src/preview/services/preview.d.ts +3 -0
- package/dist/admin/src/router.d.ts +1 -1
- package/dist/admin/src/services/api.d.ts +2 -3
- package/dist/admin/src/services/components.d.ts +2 -2
- package/dist/admin/src/services/contentTypes.d.ts +5 -5
- package/dist/admin/src/services/documents.d.ts +31 -20
- package/dist/admin/src/services/init.d.ts +2 -2
- package/dist/admin/src/services/relations.d.ts +3 -3
- package/dist/admin/src/services/uid.d.ts +3 -3
- package/dist/admin/src/utils/api.d.ts +4 -18
- package/dist/admin/src/utils/validation.d.ts +5 -7
- package/dist/server/index.js +852 -436
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +859 -443
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
- package/dist/server/src/controllers/index.d.ts.map +1 -1
- package/dist/server/src/controllers/relations.d.ts.map +1 -1
- package/dist/server/src/controllers/single-types.d.ts.map +1 -1
- package/dist/server/src/controllers/uid.d.ts.map +1 -1
- package/dist/server/src/controllers/utils/metadata.d.ts +22 -0
- package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -0
- package/dist/server/src/controllers/validation/dimensions.d.ts +11 -0
- package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -0
- package/dist/server/src/controllers/validation/index.d.ts +1 -1
- package/dist/server/src/history/services/history.d.ts.map +1 -1
- package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
- package/dist/server/src/history/services/utils.d.ts +4 -4
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +21 -42
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
- package/dist/server/src/preview/constants.d.ts +2 -0
- package/dist/server/src/preview/constants.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/index.d.ts +2 -0
- package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/preview.d.ts +13 -0
- package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
- package/dist/server/src/preview/index.d.ts +4 -0
- package/dist/server/src/preview/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/index.d.ts +8 -0
- package/dist/server/src/preview/routes/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/preview.d.ts +4 -0
- package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
- package/dist/server/src/preview/services/index.d.ts +16 -0
- package/dist/server/src/preview/services/index.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview-config.d.ts +32 -0
- package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview.d.ts +12 -0
- package/dist/server/src/preview/services/preview.d.ts.map +1 -0
- package/dist/server/src/preview/utils.d.ts +19 -0
- package/dist/server/src/preview/utils.d.ts.map +1 -0
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/routes/index.d.ts.map +1 -1
- package/dist/server/src/services/document-manager.d.ts +13 -12
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/dist/server/src/services/document-metadata.d.ts +14 -35
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +21 -42
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/permission-checker.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 +8 -1
- package/dist/server/src/services/utils/populate.d.ts.map +1 -1
- package/dist/server/src/utils/index.d.ts +2 -0
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/shared/contracts/collection-types.d.ts +17 -7
- package/dist/shared/contracts/collection-types.d.ts.map +1 -1
- package/dist/shared/contracts/index.d.ts +1 -0
- package/dist/shared/contracts/index.d.ts.map +1 -1
- package/dist/shared/contracts/preview.d.ts +27 -0
- package/dist/shared/contracts/preview.d.ts.map +1 -0
- package/dist/shared/contracts/relations.d.ts +2 -2
- package/dist/shared/contracts/relations.d.ts.map +1 -1
- package/dist/shared/index.js +4 -0
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +4 -0
- package/dist/shared/index.mjs.map +1 -1
- package/package.json +19 -20
- package/dist/_chunks/CardDragPreview-DSVYodBX.js.map +0 -1
- package/dist/_chunks/CardDragPreview-ikSG4M46.mjs.map +0 -1
- package/dist/_chunks/ComponentIcon-BBQsYCVn.js.map +0 -1
- package/dist/_chunks/ComponentIcon-BOFnK76n.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-DDS6H9HO.mjs +0 -203
- package/dist/_chunks/EditViewPage-DDS6H9HO.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-DvNpQkam.js.map +0 -1
- package/dist/_chunks/Field-6gvGdPBV.mjs.map +0 -1
- package/dist/_chunks/Field-DmVKIAOo.js.map +0 -1
- package/dist/_chunks/Form-CPZC9vWa.js.map +0 -1
- package/dist/_chunks/Form-DW6K1IH-.mjs.map +0 -1
- package/dist/_chunks/History-DeAPlvtv.js.map +0 -1
- package/dist/_chunks/History-Dmr9fmUA.mjs.map +0 -1
- package/dist/_chunks/ListConfigurationPage-DPCwW5Vr.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-DhwvYcNv.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-5ySZ-VUs.js.map +0 -1
- package/dist/_chunks/ListViewPage-BtAwuYLE.mjs.map +0 -1
- package/dist/_chunks/NoContentTypePage-DOC_yWOf.js.map +0 -1
- package/dist/_chunks/NoContentTypePage-DSPxnxxp.mjs.map +0 -1
- package/dist/_chunks/Relations-CgWtgnPe.js.map +0 -1
- package/dist/_chunks/Relations-J8cscLlR.mjs.map +0 -1
- package/dist/_chunks/index-C6AH2hEl.js.map +0 -1
- package/dist/_chunks/index-CwRRo1V9.mjs.map +0 -1
- package/dist/_chunks/layout-B_SXLhqf.js.map +0 -1
- package/dist/_chunks/layout-jIDzX0Fp.mjs.map +0 -1
- package/dist/_chunks/relations-CuvIgCqI.mjs.map +0 -1
- package/dist/_chunks/relations-iBMa_OFG.js.map +0 -1
- package/dist/_chunks/urls-CbOsUOoW.mjs +0 -7
- package/dist/_chunks/urls-CbOsUOoW.mjs.map +0 -1
- package/dist/_chunks/urls-DzZya_gm.js +0 -6
- package/dist/_chunks/urls-DzZya_gm.js.map +0 -1
- package/dist/server/src/controllers/utils/dimensions.d.ts +0 -5
- package/dist/server/src/controllers/utils/dimensions.d.ts.map +0 -1
- package/strapi-server.js +0 -3
@@ -1,25 +1,25 @@
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
2
2
|
import * as React from "react";
|
3
|
-
import { useState, useEffect, useCallback } from "react";
|
3
|
+
import { useState, useEffect, useCallback, memo } from "react";
|
4
4
|
import { useStrapiApp, createContext, useField, useNotification, useForm, useAPIErrorHandler, useQueryParams, useFocusInputField, InputRenderer as InputRenderer$1 } from "@strapi/admin/strapi-admin";
|
5
|
-
import { Typography, Flex,
|
5
|
+
import { Box, SingleSelect, SingleSelectOption, Typography, Flex, BaseLink, Button, Popover, Field, Tooltip, IconButton, useComposedRefs, Portal, FocusTrap, Divider, VisuallyHidden, Grid as Grid$1, Accordion, TextButton, TextInput, IconButtonGroup, Menu, MenuItem } from "@strapi/design-system";
|
6
6
|
import pipe$1 from "lodash/fp/pipe";
|
7
7
|
import { useIntl } from "react-intl";
|
8
|
-
import {
|
8
|
+
import { m as DOCUMENT_META_FIELDS, g as getTranslation, c as useDoc, e as contentManagerApi, n as CLONE_PATH, d as buildValidParams, f as useDocumentRBAC, S as SINGLE_TYPES, o as useDocLayout } from "./index-BpxR3En4.mjs";
|
9
9
|
import { generateNKeysBetween } from "fractional-indexing";
|
10
|
-
import { u as useComponent, C as ComponentProvider,
|
11
|
-
import {
|
12
|
-
import styled,
|
13
|
-
import { C as ComponentIcon } from "./ComponentIcon-
|
10
|
+
import { u as useComponent, C as ComponentProvider, M as MemoizedRelationsField } from "./Relations-C6pwmDXh.mjs";
|
11
|
+
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, Plus, Trash, EyeStriked, CheckCircle, WarningCircle, Loader, ArrowClockwise, More } from "@strapi/icons";
|
12
|
+
import { styled, css, keyframes } from "styled-components";
|
13
|
+
import { C as ComponentIcon, a as COMPONENT_ICONS } from "./ComponentIcon-u4bIXTFY.mjs";
|
14
14
|
import { getEmptyImage } from "react-dnd-html5-backend";
|
15
15
|
import { a as DIRECTIONS, u as useDragAndDrop, I as ItemTypes } from "./useDragAndDrop-DdHgKsqq.mjs";
|
16
|
-
import { g as getIn } from "./objects-
|
16
|
+
import { g as getIn } from "./objects-D6yBsdmx.mjs";
|
17
17
|
import { Editor as Editor$1, Transforms, Node, Element, Range, Path, Point, createEditor } from "slate";
|
18
18
|
import { withHistory } from "slate-history";
|
19
19
|
import { useFocused, useSelected, ReactEditor, Editable, useSlate, Slate, withReact } from "slate-react";
|
20
|
-
import { p as prefixFileUrlWithBackendUrl } from "./
|
20
|
+
import { p as prefixFileUrlWithBackendUrl, u as usePrev, a as useDebounce } from "./useDebounce-DmuSJIF3.mjs";
|
21
21
|
import * as Toolbar from "@radix-ui/react-toolbar";
|
22
|
-
import { useLocation } from "react-router-dom";
|
22
|
+
import { useLocation, useMatch } from "react-router-dom";
|
23
23
|
import CodeMirror from "codemirror5";
|
24
24
|
import sanitizeHtml from "sanitize-html";
|
25
25
|
import { getLanguage, highlight, highlightAuto } from "highlight.js";
|
@@ -160,6 +160,220 @@ const useLazyComponents = (componentUids = []) => {
|
|
160
160
|
}, []);
|
161
161
|
return { isLazyLoading: loading, lazyComponentStore, cleanup };
|
162
162
|
};
|
163
|
+
const codeLanguages = [
|
164
|
+
{
|
165
|
+
value: "asm",
|
166
|
+
label: "Assembly"
|
167
|
+
},
|
168
|
+
{
|
169
|
+
value: "bash",
|
170
|
+
label: "Bash"
|
171
|
+
},
|
172
|
+
{
|
173
|
+
value: "c",
|
174
|
+
label: "C"
|
175
|
+
},
|
176
|
+
{
|
177
|
+
value: "clojure",
|
178
|
+
label: "Clojure"
|
179
|
+
},
|
180
|
+
{
|
181
|
+
value: "cobol",
|
182
|
+
label: "COBOL"
|
183
|
+
},
|
184
|
+
{
|
185
|
+
value: "cpp",
|
186
|
+
label: "C++"
|
187
|
+
},
|
188
|
+
{
|
189
|
+
value: "csharp",
|
190
|
+
label: "C#"
|
191
|
+
},
|
192
|
+
{
|
193
|
+
value: "css",
|
194
|
+
label: "CSS"
|
195
|
+
},
|
196
|
+
{
|
197
|
+
value: "dart",
|
198
|
+
label: "Dart"
|
199
|
+
},
|
200
|
+
{
|
201
|
+
value: "dockerfile",
|
202
|
+
label: "Dockerfile"
|
203
|
+
},
|
204
|
+
{
|
205
|
+
value: "elixir",
|
206
|
+
label: "Elixir"
|
207
|
+
},
|
208
|
+
{
|
209
|
+
value: "erlang",
|
210
|
+
label: "Erlang"
|
211
|
+
},
|
212
|
+
{
|
213
|
+
value: "fortran",
|
214
|
+
label: "Fortran"
|
215
|
+
},
|
216
|
+
{
|
217
|
+
value: "fsharp",
|
218
|
+
label: "F#"
|
219
|
+
},
|
220
|
+
{
|
221
|
+
value: "go",
|
222
|
+
label: "Go"
|
223
|
+
},
|
224
|
+
{
|
225
|
+
value: "graphql",
|
226
|
+
label: "GraphQL"
|
227
|
+
},
|
228
|
+
{
|
229
|
+
value: "groovy",
|
230
|
+
label: "Groovy"
|
231
|
+
},
|
232
|
+
{
|
233
|
+
value: "haskell",
|
234
|
+
label: "Haskell"
|
235
|
+
},
|
236
|
+
{
|
237
|
+
value: "haxe",
|
238
|
+
label: "Haxe"
|
239
|
+
},
|
240
|
+
{
|
241
|
+
value: "html",
|
242
|
+
label: "HTML"
|
243
|
+
},
|
244
|
+
{
|
245
|
+
value: "ini",
|
246
|
+
label: "INI"
|
247
|
+
},
|
248
|
+
{
|
249
|
+
value: "java",
|
250
|
+
label: "Java"
|
251
|
+
},
|
252
|
+
{
|
253
|
+
value: "javascript",
|
254
|
+
label: "JavaScript"
|
255
|
+
},
|
256
|
+
{
|
257
|
+
value: "jsx",
|
258
|
+
label: "JavaScript (React)"
|
259
|
+
},
|
260
|
+
{
|
261
|
+
value: "json",
|
262
|
+
label: "JSON"
|
263
|
+
},
|
264
|
+
{
|
265
|
+
value: "julia",
|
266
|
+
label: "Julia"
|
267
|
+
},
|
268
|
+
{
|
269
|
+
value: "kotlin",
|
270
|
+
label: "Kotlin"
|
271
|
+
},
|
272
|
+
{
|
273
|
+
value: "latex",
|
274
|
+
label: "LaTeX"
|
275
|
+
},
|
276
|
+
{
|
277
|
+
value: "lua",
|
278
|
+
label: "Lua"
|
279
|
+
},
|
280
|
+
{
|
281
|
+
value: "markdown",
|
282
|
+
label: "Markdown"
|
283
|
+
},
|
284
|
+
{
|
285
|
+
value: "matlab",
|
286
|
+
label: "MATLAB"
|
287
|
+
},
|
288
|
+
{
|
289
|
+
value: "makefile",
|
290
|
+
label: "Makefile"
|
291
|
+
},
|
292
|
+
{
|
293
|
+
value: "objectivec",
|
294
|
+
label: "Objective-C"
|
295
|
+
},
|
296
|
+
{
|
297
|
+
value: "perl",
|
298
|
+
label: "Perl"
|
299
|
+
},
|
300
|
+
{
|
301
|
+
value: "php",
|
302
|
+
label: "PHP"
|
303
|
+
},
|
304
|
+
{
|
305
|
+
value: "plaintext",
|
306
|
+
label: "Plain text"
|
307
|
+
},
|
308
|
+
{
|
309
|
+
value: "powershell",
|
310
|
+
label: "PowerShell"
|
311
|
+
},
|
312
|
+
{
|
313
|
+
value: "python",
|
314
|
+
label: "Python"
|
315
|
+
},
|
316
|
+
{
|
317
|
+
value: "r",
|
318
|
+
label: "R"
|
319
|
+
},
|
320
|
+
{
|
321
|
+
value: "ruby",
|
322
|
+
label: "Ruby"
|
323
|
+
},
|
324
|
+
{
|
325
|
+
value: "rust",
|
326
|
+
label: "Rust"
|
327
|
+
},
|
328
|
+
{
|
329
|
+
value: "sas",
|
330
|
+
label: "SAS"
|
331
|
+
},
|
332
|
+
{
|
333
|
+
value: "scala",
|
334
|
+
label: "Scala"
|
335
|
+
},
|
336
|
+
{
|
337
|
+
value: "scheme",
|
338
|
+
label: "Scheme"
|
339
|
+
},
|
340
|
+
{
|
341
|
+
value: "shell",
|
342
|
+
label: "Shell"
|
343
|
+
},
|
344
|
+
{
|
345
|
+
value: "sql",
|
346
|
+
label: "SQL"
|
347
|
+
},
|
348
|
+
{
|
349
|
+
value: "stata",
|
350
|
+
label: "Stata"
|
351
|
+
},
|
352
|
+
{
|
353
|
+
value: "swift",
|
354
|
+
label: "Swift"
|
355
|
+
},
|
356
|
+
{
|
357
|
+
value: "typescript",
|
358
|
+
label: "TypeScript"
|
359
|
+
},
|
360
|
+
{
|
361
|
+
value: "tsx",
|
362
|
+
label: "TypeScript (React)"
|
363
|
+
},
|
364
|
+
{
|
365
|
+
value: "vbnet",
|
366
|
+
label: "VB.NET"
|
367
|
+
},
|
368
|
+
{
|
369
|
+
value: "xml",
|
370
|
+
label: "XML"
|
371
|
+
},
|
372
|
+
{
|
373
|
+
value: "yaml",
|
374
|
+
label: "YAML"
|
375
|
+
}
|
376
|
+
];
|
163
377
|
const baseHandleConvert = (editor, attributesToSet) => {
|
164
378
|
const [_, lastNodePath] = Editor$1.last(editor, []);
|
165
379
|
Transforms.unwrapNodes(editor, {
|
@@ -223,13 +437,14 @@ const pressEnterTwiceToExit = (editor) => {
|
|
223
437
|
});
|
224
438
|
}
|
225
439
|
};
|
226
|
-
const CodeBlock = styled.pre
|
440
|
+
const CodeBlock = styled.pre`
|
227
441
|
border-radius: ${({ theme }) => theme.borderRadius};
|
228
442
|
background-color: ${({ theme }) => theme.colors.neutral100};
|
229
443
|
max-width: 100%;
|
230
444
|
overflow: auto;
|
231
445
|
padding: ${({ theme }) => `${theme.spaces[3]} ${theme.spaces[4]}`};
|
232
446
|
flex-shrink: 1;
|
447
|
+
|
233
448
|
& > code {
|
234
449
|
font-family: 'SF Mono', SFMono-Regular, ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas,
|
235
450
|
monospace;
|
@@ -238,10 +453,62 @@ const CodeBlock = styled.pre.attrs({ role: "code" })`
|
|
238
453
|
max-width: 100%;
|
239
454
|
}
|
240
455
|
`;
|
456
|
+
const CodeEditor = (props) => {
|
457
|
+
const { editor } = useBlocksEditorContext("ImageDialog");
|
458
|
+
const editorIsFocused = useFocused();
|
459
|
+
const imageIsSelected = useSelected();
|
460
|
+
const { formatMessage } = useIntl();
|
461
|
+
const [isSelectOpen, setIsSelectOpen] = React.useState(false);
|
462
|
+
const shouldDisplayLanguageSelect = editorIsFocused && imageIsSelected || isSelectOpen;
|
463
|
+
return /* @__PURE__ */ jsxs(Box, { position: "relative", width: "100%", children: [
|
464
|
+
/* @__PURE__ */ jsx(CodeBlock, { ...props.attributes, children: /* @__PURE__ */ jsx("code", { children: props.children }) }),
|
465
|
+
shouldDisplayLanguageSelect && /* @__PURE__ */ jsx(
|
466
|
+
Box,
|
467
|
+
{
|
468
|
+
position: "absolute",
|
469
|
+
background: "neutral0",
|
470
|
+
borderColor: "neutral150",
|
471
|
+
borderStyle: "solid",
|
472
|
+
borderWidth: "0.5px",
|
473
|
+
shadow: "tableShadow",
|
474
|
+
top: "100%",
|
475
|
+
marginTop: 1,
|
476
|
+
right: 0,
|
477
|
+
padding: 1,
|
478
|
+
hasRadius: true,
|
479
|
+
children: /* @__PURE__ */ jsx(
|
480
|
+
SingleSelect,
|
481
|
+
{
|
482
|
+
onChange: (open) => {
|
483
|
+
Transforms.setNodes(
|
484
|
+
editor,
|
485
|
+
{ language: open.toString() },
|
486
|
+
{ match: (node) => !Editor$1.isEditor(node) && node.type === "code" }
|
487
|
+
);
|
488
|
+
},
|
489
|
+
value: props.element.type === "code" && props.element.language || "plaintext",
|
490
|
+
onOpenChange: (open) => {
|
491
|
+
setIsSelectOpen(open);
|
492
|
+
if (!open) {
|
493
|
+
ReactEditor.focus(editor);
|
494
|
+
}
|
495
|
+
},
|
496
|
+
onCloseAutoFocus: (e) => e.preventDefault(),
|
497
|
+
"aria-label": formatMessage({
|
498
|
+
id: "components.Blocks.blocks.code.languageLabel",
|
499
|
+
defaultMessage: "Select a language"
|
500
|
+
}),
|
501
|
+
children: codeLanguages.map(({ value, label }) => /* @__PURE__ */ jsx(SingleSelectOption, { value, children: label }, value))
|
502
|
+
}
|
503
|
+
)
|
504
|
+
}
|
505
|
+
)
|
506
|
+
] });
|
507
|
+
};
|
241
508
|
const codeBlocks = {
|
242
509
|
code: {
|
243
|
-
renderElement: (props) => /* @__PURE__ */ jsx(
|
244
|
-
icon:
|
510
|
+
renderElement: (props) => /* @__PURE__ */ jsx(CodeEditor, { ...props }),
|
511
|
+
icon: CodeBlock$1,
|
245
512
|
label: {
|
246
513
|
id: "components.Blocks.blocks.code",
|
247
514
|
defaultMessage: "Code block"
|
@@ -249,7 +516,7 @@ const codeBlocks = {
|
|
249
516
|
matchNode: (node) => node.type === "code",
|
250
517
|
isInBlocksSelector: true,
|
251
518
|
handleConvert(editor) {
|
252
|
-
baseHandleConvert(editor, { type: "code" });
|
519
|
+
baseHandleConvert(editor, { type: "code", language: "plaintext" });
|
253
520
|
},
|
254
521
|
handleEnterKey(editor) {
|
255
522
|
pressEnterTwiceToExit(editor);
|
@@ -258,27 +525,27 @@ const codeBlocks = {
|
|
258
525
|
dragHandleTopMargin: "10px"
|
259
526
|
}
|
260
527
|
};
|
261
|
-
const H1 = styled(Typography).attrs({
|
528
|
+
const H1 = styled(Typography).attrs({ tag: "h1" })`
|
262
529
|
font-size: 4.2rem;
|
263
530
|
line-height: ${({ theme }) => theme.lineHeights[1]};
|
264
531
|
`;
|
265
|
-
const H2 = styled(Typography).attrs({
|
532
|
+
const H2 = styled(Typography).attrs({ tag: "h2" })`
|
266
533
|
font-size: 3.5rem;
|
267
534
|
line-height: ${({ theme }) => theme.lineHeights[1]};
|
268
535
|
`;
|
269
|
-
const H3 = styled(Typography).attrs({
|
536
|
+
const H3 = styled(Typography).attrs({ tag: "h3" })`
|
270
537
|
font-size: 2.9rem;
|
271
538
|
line-height: ${({ theme }) => theme.lineHeights[1]};
|
272
539
|
`;
|
273
|
-
const H4 = styled(Typography).attrs({
|
540
|
+
const H4 = styled(Typography).attrs({ tag: "h4" })`
|
274
541
|
font-size: 2.4rem;
|
275
542
|
line-height: ${({ theme }) => theme.lineHeights[1]};
|
276
543
|
`;
|
277
|
-
const H5 = styled(Typography).attrs({
|
544
|
+
const H5 = styled(Typography).attrs({ tag: "h5" })`
|
278
545
|
font-size: 2rem;
|
279
546
|
line-height: ${({ theme }) => theme.lineHeights[1]};
|
280
547
|
`;
|
281
|
-
const H6 = styled(Typography).attrs({
|
548
|
+
const H6 = styled(Typography).attrs({ tag: "h6" })`
|
282
549
|
font-size: 1.6rem;
|
283
550
|
line-height: ${({ theme }) => theme.lineHeights[1]};
|
284
551
|
`;
|
@@ -367,7 +634,7 @@ const headingBlocks = {
|
|
367
634
|
const ImageWrapper = styled(Flex)`
|
368
635
|
transition-property: box-shadow;
|
369
636
|
transition-duration: 0.2s;
|
370
|
-
${(props) => props
|
637
|
+
${(props) => props.$isFocused && css`
|
371
638
|
box-shadow: ${props.theme.colors.primary600} 0px 0px 0px 3px;
|
372
639
|
`}
|
373
640
|
|
@@ -419,7 +686,7 @@ const Image = ({ attributes, children, element }) => {
|
|
419
686
|
background: "neutral100",
|
420
687
|
contentEditable: false,
|
421
688
|
justifyContent: "center",
|
422
|
-
isFocused: editorIsFocused && imageIsSelected,
|
689
|
+
$isFocused: editorIsFocused && imageIsSelected,
|
423
690
|
hasRadius: true,
|
424
691
|
children: /* @__PURE__ */ jsx("img", { src: url, alt: alternativeText, width, height })
|
425
692
|
}
|
@@ -579,7 +846,7 @@ const StyledBaseLink = styled(BaseLink)`
|
|
579
846
|
text-decoration: none;
|
580
847
|
`;
|
581
848
|
const RemoveButton = styled(Button)`
|
582
|
-
visibility: ${(props) => props
|
849
|
+
visibility: ${(props) => props.$visible ? "visible" : "hidden"};
|
583
850
|
`;
|
584
851
|
const LinkContent = React.forwardRef(
|
585
852
|
({ link, children, attributes }, forwardedRef) => {
|
@@ -589,18 +856,12 @@ const LinkContent = React.forwardRef(
|
|
589
856
|
const [popoverOpen, setPopoverOpen] = React.useState(
|
590
857
|
editor.lastInsertedLinkPath ? Path.equals(path, editor.lastInsertedLinkPath) : false
|
591
858
|
);
|
592
|
-
const linkRef = React.useRef(null);
|
593
859
|
const elementText = link.children.map((child) => child.text).join("");
|
594
860
|
const [linkText, setLinkText] = React.useState(elementText);
|
595
861
|
const [linkUrl, setLinkUrl] = React.useState(link.url);
|
596
862
|
const linkInputRef = React.useRef(null);
|
597
|
-
const
|
863
|
+
const isLastInsertedLink = editor.lastInsertedLinkPath ? !Path.equals(path, editor.lastInsertedLinkPath) : true;
|
598
864
|
const [isSaveDisabled, setIsSaveDisabled] = React.useState(false);
|
599
|
-
const handleOpenEditPopover = (e) => {
|
600
|
-
e.preventDefault();
|
601
|
-
setPopoverOpen(true);
|
602
|
-
setShowRemoveButton(true);
|
603
|
-
};
|
604
865
|
const onLinkChange = (e) => {
|
605
866
|
setIsSaveDisabled(false);
|
606
867
|
setLinkUrl(e.target.value);
|
@@ -621,40 +882,40 @@ const LinkContent = React.forwardRef(
|
|
621
882
|
editLink(editor, { url: linkUrl, text: linkText });
|
622
883
|
setPopoverOpen(false);
|
623
884
|
editor.lastInsertedLinkPath = null;
|
885
|
+
ReactEditor.focus(editor);
|
624
886
|
};
|
625
|
-
const
|
626
|
-
setPopoverOpen(false);
|
887
|
+
const handleClose = () => {
|
627
888
|
if (link.url === "") {
|
628
889
|
removeLink(editor);
|
629
890
|
}
|
891
|
+
setPopoverOpen(false);
|
630
892
|
ReactEditor.focus(editor);
|
631
893
|
};
|
632
|
-
const inputNotDirty = !linkText || !linkUrl || link.url && link.url === linkUrl && elementText && elementText === linkText;
|
633
|
-
const composedRefs = useComposedRefs(linkRef, forwardedRef);
|
634
894
|
React.useEffect(() => {
|
635
895
|
if (popoverOpen)
|
636
896
|
linkInputRef.current?.focus();
|
637
897
|
}, [popoverOpen]);
|
638
|
-
|
639
|
-
|
898
|
+
const inputNotDirty = !linkText || !linkUrl || link.url && link.url === linkUrl && elementText && elementText === linkText;
|
899
|
+
return /* @__PURE__ */ jsxs(Popover.Root, { open: popoverOpen, children: [
|
900
|
+
/* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx(
|
640
901
|
StyledBaseLink,
|
641
902
|
{
|
642
903
|
...attributes,
|
643
|
-
ref:
|
904
|
+
ref: forwardedRef,
|
644
905
|
href: link.url,
|
645
|
-
onClick:
|
906
|
+
onClick: () => setPopoverOpen(true),
|
646
907
|
color: "primary600",
|
647
908
|
children
|
648
909
|
}
|
649
|
-
),
|
650
|
-
|
651
|
-
/* @__PURE__ */ jsx(Field, { width: "368px", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "stretch", children: [
|
652
|
-
/* @__PURE__ */ jsx(
|
910
|
+
) }),
|
911
|
+
/* @__PURE__ */ jsx(Popover.Content, { onPointerDownOutside: handleClose, children: /* @__PURE__ */ jsxs(Flex, { padding: 4, direction: "column", gap: 4, children: [
|
912
|
+
/* @__PURE__ */ jsx(Field.Root, { width: "368px", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "stretch", children: [
|
913
|
+
/* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
|
653
914
|
id: "components.Blocks.popover.text",
|
654
915
|
defaultMessage: "Text"
|
655
916
|
}) }),
|
656
917
|
/* @__PURE__ */ jsx(
|
657
|
-
|
918
|
+
Field.Input,
|
658
919
|
{
|
659
920
|
name: "text",
|
660
921
|
placeholder: formatMessage({
|
@@ -668,13 +929,13 @@ const LinkContent = React.forwardRef(
|
|
668
929
|
}
|
669
930
|
)
|
670
931
|
] }) }),
|
671
|
-
/* @__PURE__ */ jsx(Field, { width: "368px", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "stretch", children: [
|
672
|
-
/* @__PURE__ */ jsx(
|
932
|
+
/* @__PURE__ */ jsx(Field.Root, { width: "368px", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "stretch", children: [
|
933
|
+
/* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
|
673
934
|
id: "components.Blocks.popover.link",
|
674
935
|
defaultMessage: "Link"
|
675
936
|
}) }),
|
676
937
|
/* @__PURE__ */ jsx(
|
677
|
-
|
938
|
+
Field.Input,
|
678
939
|
{
|
679
940
|
ref: linkInputRef,
|
680
941
|
name: "url",
|
@@ -693,7 +954,7 @@ const LinkContent = React.forwardRef(
|
|
693
954
|
{
|
694
955
|
variant: "danger-light",
|
695
956
|
onClick: () => removeLink(editor),
|
696
|
-
visible:
|
957
|
+
$visible: isLastInsertedLink,
|
697
958
|
children: formatMessage({
|
698
959
|
id: "components.Blocks.popover.remove",
|
699
960
|
defaultMessage: "Remove"
|
@@ -701,11 +962,11 @@ const LinkContent = React.forwardRef(
|
|
701
962
|
}
|
702
963
|
),
|
703
964
|
/* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
704
|
-
/* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick:
|
965
|
+
/* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick: handleClose, children: formatMessage({
|
705
966
|
id: "components.Blocks.popover.cancel",
|
706
967
|
defaultMessage: "Cancel"
|
707
968
|
}) }),
|
708
|
-
/* @__PURE__ */ jsx(Button, {
|
969
|
+
/* @__PURE__ */ jsx(Button, { disabled: Boolean(inputNotDirty) || isSaveDisabled, onClick: handleSave, children: formatMessage({
|
709
970
|
id: "components.Blocks.popover.save",
|
710
971
|
defaultMessage: "Save"
|
711
972
|
}) })
|
@@ -748,11 +1009,11 @@ const listStyle = css`
|
|
748
1009
|
}
|
749
1010
|
`;
|
750
1011
|
const Orderedlist = styled.ol`
|
751
|
-
list-style-type: ${(props) => props
|
1012
|
+
list-style-type: ${(props) => props.$listStyleType};
|
752
1013
|
${listStyle}
|
753
1014
|
`;
|
754
1015
|
const Unorderedlist = styled.ul`
|
755
|
-
list-style-type: ${(props) => props
|
1016
|
+
list-style-type: ${(props) => props.$listStyleType};
|
756
1017
|
${listStyle}
|
757
1018
|
`;
|
758
1019
|
const orderedStyles = ["decimal", "lower-alpha", "upper-roman"];
|
@@ -765,9 +1026,9 @@ const List = ({ attributes, children, element }) => {
|
|
765
1026
|
const nextIndex = (element.indentLevel || 0) % listStyles.length;
|
766
1027
|
const listStyleType = listStyles[nextIndex];
|
767
1028
|
if (element.format === "ordered") {
|
768
|
-
return /* @__PURE__ */ jsx(Orderedlist, { listStyleType, ...attributes, children });
|
1029
|
+
return /* @__PURE__ */ jsx(Orderedlist, { $listStyleType: listStyleType, ...attributes, children });
|
769
1030
|
}
|
770
|
-
return /* @__PURE__ */ jsx(Unorderedlist, { listStyleType, ...attributes, children });
|
1031
|
+
return /* @__PURE__ */ jsx(Unorderedlist, { $listStyleType: listStyleType, ...attributes, children });
|
771
1032
|
};
|
772
1033
|
const replaceListWithEmptyBlock = (editor, currentListPath) => {
|
773
1034
|
Transforms.removeNodes(editor, { at: currentListPath });
|
@@ -964,7 +1225,7 @@ const listBlocks = {
|
|
964
1225
|
snippets: ["-", "*", "+"]
|
965
1226
|
},
|
966
1227
|
"list-item": {
|
967
|
-
renderElement: (props) => /* @__PURE__ */ jsx(Typography, {
|
1228
|
+
renderElement: (props) => /* @__PURE__ */ jsx(Typography, { tag: "li", ...props.attributes, children: props.children }),
|
968
1229
|
// No handleConvert, list items are created when converting to the parent list
|
969
1230
|
matchNode: (node) => node.type === "list-item",
|
970
1231
|
isInBlocksSelector: false,
|
@@ -973,7 +1234,7 @@ const listBlocks = {
|
|
973
1234
|
};
|
974
1235
|
const paragraphBlocks = {
|
975
1236
|
paragraph: {
|
976
|
-
renderElement: (props) => /* @__PURE__ */ jsx(Typography, {
|
1237
|
+
renderElement: (props) => /* @__PURE__ */ jsx(Typography, { tag: "p", variant: "omega", ...props.attributes, children: props.children }),
|
977
1238
|
icon: Paragraph,
|
978
1239
|
label: {
|
979
1240
|
id: "components.Blocks.blocks.text",
|
@@ -1139,14 +1400,14 @@ const ToolbarButton = ({
|
|
1139
1400
|
children: /* @__PURE__ */ jsx(
|
1140
1401
|
FlexButton,
|
1141
1402
|
{
|
1142
|
-
|
1403
|
+
tag: "button",
|
1143
1404
|
background: isActive ? "primary100" : "",
|
1144
1405
|
alignItems: "center",
|
1145
1406
|
justifyContent: "center",
|
1146
1407
|
width: 7,
|
1147
1408
|
height: 7,
|
1148
1409
|
hasRadius: true,
|
1149
|
-
children: /* @__PURE__ */ jsx(Icon, {
|
1410
|
+
children: /* @__PURE__ */ jsx(Icon, { fill: disabled ? "neutral300" : enabledColor })
|
1150
1411
|
}
|
1151
1412
|
)
|
1152
1413
|
}
|
@@ -1291,6 +1552,26 @@ const ListButton = ({ block, format }) => {
|
|
1291
1552
|
}
|
1292
1553
|
return false;
|
1293
1554
|
};
|
1555
|
+
const isListDisabled = () => {
|
1556
|
+
if (disabled) {
|
1557
|
+
return true;
|
1558
|
+
}
|
1559
|
+
if (!editor.selection) {
|
1560
|
+
return false;
|
1561
|
+
}
|
1562
|
+
const anchorNodeEntry = Editor$1.above(editor, {
|
1563
|
+
at: editor.selection.anchor,
|
1564
|
+
match: (node) => !Editor$1.isEditor(node) && node.type !== "text"
|
1565
|
+
});
|
1566
|
+
const focusNodeEntry = Editor$1.above(editor, {
|
1567
|
+
at: editor.selection.focus,
|
1568
|
+
match: (node) => !Editor$1.isEditor(node) && node.type !== "text"
|
1569
|
+
});
|
1570
|
+
if (!anchorNodeEntry || !focusNodeEntry) {
|
1571
|
+
return false;
|
1572
|
+
}
|
1573
|
+
return anchorNodeEntry[0] !== focusNodeEntry[0];
|
1574
|
+
};
|
1294
1575
|
const toggleList = (format2) => {
|
1295
1576
|
let currentListEntry;
|
1296
1577
|
if (editor.selection) {
|
@@ -1324,7 +1605,7 @@ const ListButton = ({ block, format }) => {
|
|
1324
1605
|
name: format,
|
1325
1606
|
label: block.label,
|
1326
1607
|
isActive: isListActive(),
|
1327
|
-
disabled,
|
1608
|
+
disabled: isListDisabled(),
|
1328
1609
|
handleClick: () => toggleList(format)
|
1329
1610
|
}
|
1330
1611
|
);
|
@@ -1460,7 +1741,7 @@ const DragItem = styled(Flex)`
|
|
1460
1741
|
|
1461
1742
|
// Set the visibility of drag button
|
1462
1743
|
[role='button'] {
|
1463
|
-
visibility: ${(props) => props
|
1744
|
+
visibility: ${(props) => props.$dragVisibility};
|
1464
1745
|
opacity: inherit;
|
1465
1746
|
}
|
1466
1747
|
&[aria-disabled='true'] {
|
@@ -1468,6 +1749,7 @@ const DragItem = styled(Flex)`
|
|
1468
1749
|
}
|
1469
1750
|
`;
|
1470
1751
|
const DragIconButton = styled(IconButton)`
|
1752
|
+
user-select: none;
|
1471
1753
|
display: flex;
|
1472
1754
|
align-items: center;
|
1473
1755
|
justify-content: center;
|
@@ -1477,7 +1759,7 @@ const DragIconButton = styled(IconButton)`
|
|
1477
1759
|
visibility: hidden;
|
1478
1760
|
cursor: grab;
|
1479
1761
|
opacity: inherit;
|
1480
|
-
margin-top: ${(props) => props
|
1762
|
+
margin-top: ${(props) => props.$dragHandleTopMargin ?? 0};
|
1481
1763
|
|
1482
1764
|
&:hover {
|
1483
1765
|
background: ${({ theme }) => theme.colors.neutral200};
|
@@ -1491,7 +1773,7 @@ const DragIconButton = styled(IconButton)`
|
|
1491
1773
|
}
|
1492
1774
|
svg {
|
1493
1775
|
height: auto;
|
1494
|
-
width: ${({ theme }) => theme.spaces[3]};
|
1776
|
+
min-width: ${({ theme }) => theme.spaces[3]};
|
1495
1777
|
|
1496
1778
|
path {
|
1497
1779
|
fill: ${({ theme }) => theme.colors.neutral700};
|
@@ -1552,7 +1834,7 @@ const DragAndDropElement = ({
|
|
1552
1834
|
React.useEffect(() => {
|
1553
1835
|
setDragVisibility("hidden");
|
1554
1836
|
}, [editor.selection]);
|
1555
|
-
return /* @__PURE__ */ jsxs(Wrapper$1, { ref:
|
1837
|
+
return /* @__PURE__ */ jsxs(Wrapper$1, { ref: composedBoxRefs, isOverDropTarget, children: [
|
1556
1838
|
isOverDropTarget && /* @__PURE__ */ jsx(
|
1557
1839
|
DropPlaceholder,
|
1558
1840
|
{
|
@@ -1590,15 +1872,17 @@ const DragAndDropElement = ({
|
|
1590
1872
|
onSelect: () => setDragVisibility("visible"),
|
1591
1873
|
onMouseLeave: () => setDragVisibility("hidden"),
|
1592
1874
|
"aria-disabled": disabled,
|
1593
|
-
dragVisibility,
|
1875
|
+
$dragVisibility: dragVisibility,
|
1594
1876
|
children: [
|
1595
1877
|
/* @__PURE__ */ jsx(
|
1596
1878
|
DragIconButton,
|
1597
1879
|
{
|
1598
|
-
|
1880
|
+
tag: "div",
|
1881
|
+
contentEditable: false,
|
1599
1882
|
role: "button",
|
1600
1883
|
tabIndex: 0,
|
1601
|
-
|
1884
|
+
withTooltip: false,
|
1885
|
+
label: formatMessage({
|
1602
1886
|
id: getTranslation("components.DragHandle-label"),
|
1603
1887
|
defaultMessage: "Drag"
|
1604
1888
|
}),
|
@@ -1606,8 +1890,8 @@ const DragAndDropElement = ({
|
|
1606
1890
|
"aria-disabled": disabled,
|
1607
1891
|
disabled,
|
1608
1892
|
draggable: true,
|
1609
|
-
dragHandleTopMargin,
|
1610
|
-
children: /* @__PURE__ */ jsx(Drag, { color: "
|
1893
|
+
$dragHandleTopMargin: dragHandleTopMargin,
|
1894
|
+
children: /* @__PURE__ */ jsx(Drag, { color: "primary500" })
|
1611
1895
|
}
|
1612
1896
|
),
|
1613
1897
|
children
|
@@ -1618,17 +1902,18 @@ const DragAndDropElement = ({
|
|
1618
1902
|
};
|
1619
1903
|
const CloneDragItem = ({ children, dragHandleTopMargin }) => {
|
1620
1904
|
const { formatMessage } = useIntl();
|
1621
|
-
return /* @__PURE__ */ jsxs(DragItem, { gap: 2, paddingLeft: 2, alignItems: "start", dragVisibility: "visible", children: [
|
1905
|
+
return /* @__PURE__ */ jsxs(DragItem, { gap: 2, paddingLeft: 2, alignItems: "start", $dragVisibility: "visible", children: [
|
1622
1906
|
/* @__PURE__ */ jsx(
|
1623
1907
|
DragIconButton,
|
1624
1908
|
{
|
1625
|
-
|
1909
|
+
tag: "div",
|
1626
1910
|
role: "button",
|
1627
|
-
|
1911
|
+
withTooltip: false,
|
1912
|
+
label: formatMessage({
|
1628
1913
|
id: getTranslation("components.DragHandle-label"),
|
1629
1914
|
defaultMessage: "Drag"
|
1630
1915
|
}),
|
1631
|
-
dragHandleTopMargin,
|
1916
|
+
$dragHandleTopMargin: dragHandleTopMargin,
|
1632
1917
|
children: /* @__PURE__ */ jsx(Drag, { color: "neutral600" })
|
1633
1918
|
}
|
1634
1919
|
),
|
@@ -1930,7 +2215,7 @@ const EditorLayout$1 = ({
|
|
1930
2215
|
/* @__PURE__ */ jsx(
|
1931
2216
|
CollapseIconButton,
|
1932
2217
|
{
|
1933
|
-
|
2218
|
+
label: formatMessage({
|
1934
2219
|
id: getTranslation("components.Blocks.collapse"),
|
1935
2220
|
defaultMessage: "Collapse"
|
1936
2221
|
}),
|
@@ -1950,8 +2235,8 @@ const EditorLayout$1 = ({
|
|
1950
2235
|
direction: "column",
|
1951
2236
|
alignItems: "flex-start",
|
1952
2237
|
height: "512px",
|
1953
|
-
disabled,
|
1954
|
-
hasError: Boolean(error),
|
2238
|
+
$disabled: disabled,
|
2239
|
+
$hasError: Boolean(error),
|
1955
2240
|
style: { overflow: "hidden" },
|
1956
2241
|
"aria-describedby": ariaDescriptionId,
|
1957
2242
|
position: "relative",
|
@@ -1959,6 +2244,29 @@ const EditorLayout$1 = ({
|
|
1959
2244
|
}
|
1960
2245
|
);
|
1961
2246
|
};
|
2247
|
+
const InputWrapper = styled(Flex)`
|
2248
|
+
border: 1px solid
|
2249
|
+
${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral200};
|
2250
|
+
border-radius: ${({ theme }) => theme.borderRadius};
|
2251
|
+
background: ${({ theme }) => theme.colors.neutral0};
|
2252
|
+
|
2253
|
+
${({ theme, $hasError = false }) => css`
|
2254
|
+
outline: none;
|
2255
|
+
box-shadow: 0;
|
2256
|
+
transition-property: border-color, box-shadow, fill;
|
2257
|
+
transition-duration: 0.2s;
|
2258
|
+
|
2259
|
+
&:focus-within {
|
2260
|
+
border: 1px solid ${$hasError ? theme.colors.danger600 : theme.colors.primary600};
|
2261
|
+
box-shadow: ${$hasError ? theme.colors.danger600 : theme.colors.primary600} 0px 0px 0px 2px;
|
2262
|
+
}
|
2263
|
+
`}
|
2264
|
+
|
2265
|
+
${({ theme, $disabled }) => $disabled ? css`
|
2266
|
+
color: ${theme.colors.neutral600};
|
2267
|
+
background: ${theme.colors.neutral150};
|
2268
|
+
` : void 0}
|
2269
|
+
`;
|
1962
2270
|
const stylesToInherit = css`
|
1963
2271
|
font-size: inherit;
|
1964
2272
|
color: inherit;
|
@@ -1971,10 +2279,14 @@ const ItalicText = styled(Typography)`
|
|
1971
2279
|
font-style: italic;
|
1972
2280
|
${stylesToInherit}
|
1973
2281
|
`;
|
1974
|
-
const UnderlineText = styled(Typography).attrs({
|
2282
|
+
const UnderlineText = styled(Typography).attrs({
|
2283
|
+
textDecoration: "underline"
|
2284
|
+
})`
|
1975
2285
|
${stylesToInherit}
|
1976
2286
|
`;
|
1977
|
-
const StrikeThroughText = styled(Typography).attrs({
|
2287
|
+
const StrikeThroughText = styled(Typography).attrs({
|
2288
|
+
textDecoration: "line-through"
|
2289
|
+
})`
|
1978
2290
|
${stylesToInherit}
|
1979
2291
|
`;
|
1980
2292
|
const InlineCode = styled.code`
|
@@ -2242,7 +2554,7 @@ const BlocksEditor = React.forwardRef(
|
|
2242
2554
|
!isExpandedMode && /* @__PURE__ */ jsx(
|
2243
2555
|
ExpandIconButton,
|
2244
2556
|
{
|
2245
|
-
|
2557
|
+
label: formatMessage({
|
2246
2558
|
id: getTranslation("components.Blocks.expand"),
|
2247
2559
|
defaultMessage: "Expand"
|
2248
2560
|
}),
|
@@ -2265,8 +2577,8 @@ const BlocksInput = React.forwardRef(
|
|
2265
2577
|
({ label, name: name2, required = false, hint, labelAction, ...editorProps }, forwardedRef) => {
|
2266
2578
|
const id = React.useId();
|
2267
2579
|
const field = useField(name2);
|
2268
|
-
return /* @__PURE__ */ jsx(Field, { id, name: name2, hint, error: field.error, required, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
|
2269
|
-
/* @__PURE__ */ jsx(
|
2580
|
+
return /* @__PURE__ */ jsx(Field.Root, { id, name: name2, hint, error: field.error, required, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
|
2581
|
+
/* @__PURE__ */ jsx(Field.Label, { action: labelAction, children: label }),
|
2270
2582
|
/* @__PURE__ */ jsx(
|
2271
2583
|
BlocksEditor,
|
2272
2584
|
{
|
@@ -2279,11 +2591,12 @@ const BlocksInput = React.forwardRef(
|
|
2279
2591
|
...editorProps
|
2280
2592
|
}
|
2281
2593
|
),
|
2282
|
-
/* @__PURE__ */ jsx(
|
2283
|
-
/* @__PURE__ */ jsx(
|
2594
|
+
/* @__PURE__ */ jsx(Field.Hint, {}),
|
2595
|
+
/* @__PURE__ */ jsx(Field.Error, {})
|
2284
2596
|
] }) });
|
2285
2597
|
}
|
2286
2598
|
);
|
2599
|
+
const MemoizedBlocksInput = React.memo(BlocksInput);
|
2287
2600
|
const createDefaultForm = (contentType, components = {}) => {
|
2288
2601
|
const traverseSchema = (attributes) => {
|
2289
2602
|
return Object.entries(attributes).reduce((acc, [key, attribute]) => {
|
@@ -2307,47 +2620,44 @@ const createDefaultForm = (contentType, components = {}) => {
|
|
2307
2620
|
const Initializer = ({ disabled, name: name2, onClick }) => {
|
2308
2621
|
const { formatMessage } = useIntl();
|
2309
2622
|
const field = useField(name2);
|
2310
|
-
return /* @__PURE__ */
|
2311
|
-
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2321
|
-
|
2322
|
-
|
2323
|
-
|
2324
|
-
|
2325
|
-
|
2326
|
-
|
2327
|
-
|
2328
|
-
|
2329
|
-
|
2330
|
-
|
2331
|
-
|
2332
|
-
|
2333
|
-
|
2623
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
2624
|
+
Box,
|
2625
|
+
{
|
2626
|
+
tag: "button",
|
2627
|
+
background: disabled ? "neutral150" : "neutral100",
|
2628
|
+
borderColor: field.error ? "danger600" : "neutral200",
|
2629
|
+
hasRadius: true,
|
2630
|
+
disabled,
|
2631
|
+
onClick,
|
2632
|
+
paddingTop: 9,
|
2633
|
+
paddingBottom: 9,
|
2634
|
+
type: "button",
|
2635
|
+
style: { cursor: disabled ? "not-allowed" : "pointer" },
|
2636
|
+
children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
|
2637
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", color: disabled ? "neutral500" : "primary600", children: /* @__PURE__ */ jsx(PlusCircle, { width: "3.2rem", height: "3.2rem" }) }),
|
2638
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(
|
2639
|
+
Typography,
|
2640
|
+
{
|
2641
|
+
textColor: disabled ? "neutral600" : "primary600",
|
2642
|
+
variant: "pi",
|
2643
|
+
fontWeight: "bold",
|
2644
|
+
children: formatMessage({
|
2645
|
+
id: getTranslation("components.empty-repeatable"),
|
2646
|
+
defaultMessage: "No entry yet. Click to add one."
|
2647
|
+
})
|
2648
|
+
}
|
2649
|
+
) })
|
2650
|
+
] })
|
2651
|
+
}
|
2652
|
+
) });
|
2334
2653
|
};
|
2335
|
-
const CircleIcon = styled(PlusCircle)`
|
2336
|
-
width: 2.4rem;
|
2337
|
-
height: 2.4rem;
|
2338
|
-
> circle {
|
2339
|
-
fill: ${({ theme }) => theme.colors.primary200};
|
2340
|
-
}
|
2341
|
-
> path {
|
2342
|
-
fill: ${({ theme }) => theme.colors.primary600};
|
2343
|
-
}
|
2344
|
-
`;
|
2345
2654
|
const NonRepeatableComponent = ({
|
2346
2655
|
attribute,
|
2347
2656
|
name: name2,
|
2348
2657
|
children,
|
2349
2658
|
layout
|
2350
2659
|
}) => {
|
2660
|
+
const { formatMessage } = useIntl();
|
2351
2661
|
const { value } = useField(name2);
|
2352
2662
|
const level = useComponent("NonRepeatableComponent", (state) => state.level);
|
2353
2663
|
const isNested = level > 0;
|
@@ -2362,9 +2672,24 @@ const NonRepeatableComponent = ({
|
|
2362
2672
|
hasRadius: isNested,
|
2363
2673
|
borderColor: isNested ? "neutral200" : void 0,
|
2364
2674
|
children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((row, index) => {
|
2365
|
-
return /* @__PURE__ */ jsx(Grid$1, { gap: 4, children: row.map(({ size, ...field }) => {
|
2675
|
+
return /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: row.map(({ size, ...field }) => {
|
2366
2676
|
const completeFieldName = `${name2}.${field.name}`;
|
2367
|
-
|
2677
|
+
const translatedLabel = formatMessage({
|
2678
|
+
id: `content-manager.components.${attribute.component}.${field.name}`,
|
2679
|
+
defaultMessage: field.label
|
2680
|
+
});
|
2681
|
+
return /* @__PURE__ */ jsx(
|
2682
|
+
Grid$1.Item,
|
2683
|
+
{
|
2684
|
+
col: size,
|
2685
|
+
s: 12,
|
2686
|
+
xs: 12,
|
2687
|
+
direction: "column",
|
2688
|
+
alignItems: "stretch",
|
2689
|
+
children: children({ ...field, label: translatedLabel, name: completeFieldName })
|
2690
|
+
},
|
2691
|
+
completeFieldName
|
2692
|
+
);
|
2368
2693
|
}) }, index);
|
2369
2694
|
}) })
|
2370
2695
|
}
|
@@ -2383,13 +2708,34 @@ const RepeatableComponent = ({
|
|
2383
2708
|
const { search: searchString } = useLocation();
|
2384
2709
|
const search = React.useMemo(() => new URLSearchParams(searchString), [searchString]);
|
2385
2710
|
const { components } = useDoc();
|
2386
|
-
const {
|
2711
|
+
const {
|
2712
|
+
value = [],
|
2713
|
+
error,
|
2714
|
+
rawError
|
2715
|
+
} = useField(name2);
|
2387
2716
|
const addFieldRow = useForm("RepeatableComponent", (state) => state.addFieldRow);
|
2388
2717
|
const moveFieldRow = useForm("RepeatableComponent", (state) => state.moveFieldRow);
|
2389
2718
|
const removeFieldRow = useForm("RepeatableComponent", (state) => state.removeFieldRow);
|
2390
2719
|
const { max = Infinity } = attribute;
|
2391
|
-
const [collapseToOpen, setCollapseToOpen] = React.useState(
|
2720
|
+
const [collapseToOpen, setCollapseToOpen] = React.useState("");
|
2392
2721
|
const [liveText, setLiveText] = React.useState("");
|
2722
|
+
React.useEffect(() => {
|
2723
|
+
const hasNestedErrors = rawError && Array.isArray(rawError) && rawError.length > 0;
|
2724
|
+
const hasNestedValue = value && Array.isArray(value) && value.length > 0;
|
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
|
+
}
|
2737
|
+
}
|
2738
|
+
}, [rawError, value]);
|
2393
2739
|
const componentTmpKeyWithFocussedField = React.useMemo(() => {
|
2394
2740
|
if (search.has("field")) {
|
2395
2741
|
const fieldParam = search.get("field");
|
@@ -2404,13 +2750,19 @@ const RepeatableComponent = ({
|
|
2404
2750
|
}
|
2405
2751
|
return void 0;
|
2406
2752
|
}, [search, name2, value]);
|
2753
|
+
const prevValue = usePrev(value);
|
2754
|
+
React.useEffect(() => {
|
2755
|
+
if (prevValue && prevValue.length < value.length) {
|
2756
|
+
setCollapseToOpen(value[value.length - 1].__temp_key__);
|
2757
|
+
}
|
2758
|
+
}, [value, prevValue]);
|
2407
2759
|
React.useEffect(() => {
|
2408
|
-
if (typeof componentTmpKeyWithFocussedField === "
|
2760
|
+
if (typeof componentTmpKeyWithFocussedField === "string") {
|
2409
2761
|
setCollapseToOpen(componentTmpKeyWithFocussedField);
|
2410
2762
|
}
|
2411
2763
|
}, [componentTmpKeyWithFocussedField]);
|
2412
2764
|
const toggleCollapses = () => {
|
2413
|
-
setCollapseToOpen(
|
2765
|
+
setCollapseToOpen("");
|
2414
2766
|
};
|
2415
2767
|
const handleClick = () => {
|
2416
2768
|
if (value.length < max) {
|
@@ -2442,12 +2794,8 @@ const RepeatableComponent = ({
|
|
2442
2794
|
);
|
2443
2795
|
moveFieldRow(name2, currentIndex, newIndex);
|
2444
2796
|
};
|
2445
|
-
const
|
2446
|
-
|
2447
|
-
setCollapseToOpen(null);
|
2448
|
-
} else {
|
2449
|
-
setCollapseToOpen(key);
|
2450
|
-
}
|
2797
|
+
const handleValueChange = (key) => {
|
2798
|
+
setCollapseToOpen(key);
|
2451
2799
|
};
|
2452
2800
|
const getItemPos = (index) => `${index + 1} of ${value.length}`;
|
2453
2801
|
const handleCancel = (index) => {
|
@@ -2502,158 +2850,123 @@ const RepeatableComponent = ({
|
|
2502
2850
|
defaultMessage: `Press spacebar to grab and re-order`
|
2503
2851
|
}) }),
|
2504
2852
|
/* @__PURE__ */ jsx(VisuallyHidden, { "aria-live": "assertive", children: liveText }),
|
2505
|
-
/* @__PURE__ */ jsxs(
|
2506
|
-
|
2507
|
-
|
2508
|
-
|
2509
|
-
|
2510
|
-
|
2511
|
-
|
2512
|
-
|
2513
|
-
|
2514
|
-
|
2515
|
-
|
2516
|
-
|
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,
|
2517
2865
|
{
|
2518
|
-
|
2519
|
-
|
2520
|
-
|
2521
|
-
|
2522
|
-
|
2523
|
-
|
2524
|
-
|
2525
|
-
|
2526
|
-
|
2527
|
-
|
2528
|
-
|
2529
|
-
|
2530
|
-
|
2531
|
-
|
2532
|
-
|
2533
|
-
|
2534
|
-
|
2535
|
-
|
2536
|
-
|
2537
|
-
|
2538
|
-
|
2539
|
-
|
2540
|
-
|
2541
|
-
|
2542
|
-
|
2543
|
-
|
2544
|
-
|
2545
|
-
|
2546
|
-
|
2547
|
-
|
2548
|
-
|
2549
|
-
|
2550
|
-
|
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
|
+
)
|
2551
2926
|
] });
|
2552
2927
|
};
|
2928
|
+
const AccordionRoot = styled(Accordion.Root)`
|
2929
|
+
border: 1px solid
|
2930
|
+
${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
|
2931
|
+
`;
|
2553
2932
|
const TextButtonCustom = styled(TextButton)`
|
2554
|
-
height: 100%;
|
2555
2933
|
width: 100%;
|
2556
|
-
border-radius: 0 0 4px 4px;
|
2557
2934
|
display: flex;
|
2558
2935
|
justify-content: center;
|
2559
|
-
|
2560
|
-
|
2561
|
-
|
2562
|
-
}
|
2563
|
-
`;
|
2564
|
-
const AccordionFooter = styled(Box)`
|
2565
|
-
overflow: hidden;
|
2566
|
-
border-bottom: 1px solid ${({ theme }) => theme.colors.neutral200};
|
2567
|
-
border-right: 1px solid ${({ theme }) => theme.colors.neutral200};
|
2568
|
-
border-left: 1px solid ${({ theme }) => theme.colors.neutral200};
|
2569
|
-
border-radius: 0 0 ${({ theme }) => theme.borderRadius} ${({ theme }) => theme.borderRadius};
|
2570
|
-
`;
|
2571
|
-
const AccordionContent = styled(Box)`
|
2572
|
-
border-bottom: none;
|
2573
|
-
|
2574
|
-
/* add the borders and make sure the top is transparent to avoid jumping with the hover effect */
|
2575
|
-
& > div > div {
|
2576
|
-
border: 1px solid ${({ theme }) => theme.colors.neutral200};
|
2577
|
-
border-top-color: transparent;
|
2578
|
-
}
|
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]};
|
2579
2939
|
|
2580
|
-
|
2581
|
-
|
2582
|
-
border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
|
2583
|
-
}
|
2940
|
+
&:not([disabled]) {
|
2941
|
+
cursor: pointer;
|
2584
2942
|
|
2585
|
-
|
2586
|
-
|
2587
|
-
|
2588
|
-
border-radius: unset;
|
2943
|
+
&:hover {
|
2944
|
+
background-color: ${(props) => props.theme.colors.primary100};
|
2945
|
+
}
|
2589
2946
|
}
|
2590
2947
|
|
2591
|
-
|
2592
|
-
|
2593
|
-
|
2594
|
-
|
2948
|
+
span {
|
2949
|
+
font-weight: 600;
|
2950
|
+
font-size: 1.4rem;
|
2951
|
+
line-height: 2.4rem;
|
2595
2952
|
}
|
2596
2953
|
|
2597
|
-
|
2598
|
-
|
2599
|
-
}
|
2600
|
-
`;
|
2601
|
-
const AccordionGroup = ({ children, error }) => {
|
2602
|
-
return /* @__PURE__ */ jsxs(KeyboardNavigable, { attributeName: "data-strapi-accordion-toggle", children: [
|
2603
|
-
children,
|
2604
|
-
error && /* @__PURE__ */ jsx(Box, { paddingTop: 1, children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger600", children: error }) })
|
2605
|
-
] });
|
2606
|
-
};
|
2607
|
-
const CustomIconButton$1 = styled(IconButton)`
|
2608
|
-
background-color: transparent;
|
2609
|
-
|
2610
|
-
svg {
|
2611
|
-
path {
|
2612
|
-
fill: ${({ theme, expanded }) => expanded ? theme.colors.primary600 : theme.colors.neutral600};
|
2613
|
-
}
|
2614
|
-
}
|
2615
|
-
|
2616
|
-
&:hover {
|
2617
|
-
svg {
|
2618
|
-
path {
|
2619
|
-
fill: ${({ theme }) => theme.colors.primary600};
|
2620
|
-
}
|
2621
|
-
}
|
2622
|
-
}
|
2623
|
-
`;
|
2624
|
-
const ActionsFlex$1 = styled(Flex)`
|
2625
|
-
& .drag-handle {
|
2626
|
-
background: unset;
|
2627
|
-
|
2628
|
-
svg {
|
2629
|
-
path {
|
2630
|
-
fill: ${({ theme, expanded }) => expanded ? theme.colors.primary600 : void 0};
|
2631
|
-
}
|
2632
|
-
}
|
2633
|
-
|
2634
|
-
&:hover {
|
2635
|
-
svg {
|
2636
|
-
path {
|
2637
|
-
/* keeps the hover style of the accordion */
|
2638
|
-
fill: ${({ theme }) => theme.colors.primary600};
|
2639
|
-
}
|
2640
|
-
}
|
2641
|
-
}
|
2954
|
+
@media (prefers-reduced-motion: no-preference) {
|
2955
|
+
transition: background-color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
|
2642
2956
|
}
|
2643
2957
|
`;
|
2644
2958
|
const Component = ({
|
2645
2959
|
disabled,
|
2646
2960
|
index,
|
2647
|
-
isOpen,
|
2648
2961
|
name: name2,
|
2649
2962
|
mainField = {
|
2650
2963
|
name: "id",
|
2651
2964
|
type: "integer"
|
2652
2965
|
},
|
2653
2966
|
children,
|
2654
|
-
onClickToggle,
|
2655
2967
|
onDeleteComponent,
|
2656
2968
|
toggleCollapses,
|
2969
|
+
__temp_key__,
|
2657
2970
|
...dragProps
|
2658
2971
|
}) => {
|
2659
2972
|
const { formatMessage } = useIntl();
|
@@ -2678,50 +2991,44 @@ const Component = ({
|
|
2678
2991
|
dragPreviewRef(getEmptyImage(), { captureDraggingState: false });
|
2679
2992
|
}, [dragPreviewRef, index]);
|
2680
2993
|
const composedAccordionRefs = useComposedRefs(accordionRef, dragRef);
|
2681
|
-
const composedBoxRefs = useComposedRefs(
|
2682
|
-
|
2683
|
-
|
2684
|
-
|
2685
|
-
|
2686
|
-
|
2687
|
-
|
2688
|
-
|
2689
|
-
|
2690
|
-
|
2691
|
-
|
2692
|
-
|
2693
|
-
|
2694
|
-
|
2695
|
-
|
2696
|
-
|
2697
|
-
|
2698
|
-
}
|
2699
|
-
|
2700
|
-
|
2701
|
-
|
2702
|
-
|
2703
|
-
|
2704
|
-
|
2705
|
-
|
2706
|
-
|
2707
|
-
|
2708
|
-
|
2709
|
-
|
2710
|
-
"
|
2711
|
-
|
2712
|
-
|
2713
|
-
|
2714
|
-
|
2715
|
-
|
2716
|
-
|
2717
|
-
|
2718
|
-
|
2719
|
-
] }),
|
2720
|
-
title: displayValue,
|
2721
|
-
togglePosition: "left"
|
2722
|
-
}
|
2723
|
-
),
|
2724
|
-
/* @__PURE__ */ jsx(AccordionContent$1, { children: /* @__PURE__ */ jsx(
|
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(
|
2725
3032
|
Flex,
|
2726
3033
|
{
|
2727
3034
|
direction: "column",
|
@@ -2735,7 +3042,7 @@ const Component = ({
|
|
2735
3042
|
] }) });
|
2736
3043
|
};
|
2737
3044
|
const Preview$1 = () => {
|
2738
|
-
return /* @__PURE__ */ jsx(StyledSpan, {
|
3045
|
+
return /* @__PURE__ */ jsx(StyledSpan, { tag: "span", padding: 6, background: "primary100" });
|
2739
3046
|
};
|
2740
3047
|
const StyledSpan = styled(Box)`
|
2741
3048
|
display: block;
|
@@ -2761,29 +3068,15 @@ const ComponentInput = ({
|
|
2761
3068
|
const data = transformDocument(schema, components)(form);
|
2762
3069
|
field.onChange(name2, data);
|
2763
3070
|
};
|
2764
|
-
return /* @__PURE__ */ jsxs(
|
3071
|
+
return /* @__PURE__ */ jsxs(Field.Root, { error: field.error, required, children: [
|
2765
3072
|
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", children: [
|
2766
|
-
/* @__PURE__ */ jsxs(
|
2767
|
-
|
2768
|
-
|
2769
|
-
|
2770
|
-
|
2771
|
-
|
2772
|
-
|
2773
|
-
fontWeight: "bold",
|
2774
|
-
as: "label",
|
2775
|
-
children: [
|
2776
|
-
label,
|
2777
|
-
attribute.repeatable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
2778
|
-
" (",
|
2779
|
-
Array.isArray(field.value) ? field.value.length : 0,
|
2780
|
-
")"
|
2781
|
-
] }),
|
2782
|
-
required && /* @__PURE__ */ jsx(Typography, { textColor: "danger600", children: "*" })
|
2783
|
-
]
|
2784
|
-
}
|
2785
|
-
),
|
2786
|
-
labelAction && /* @__PURE__ */ jsx(Box, { paddingLeft: 1, children: labelAction })
|
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
|
+
] })
|
2787
3080
|
] }),
|
2788
3081
|
showResetComponent && /* @__PURE__ */ jsx(
|
2789
3082
|
IconButton,
|
@@ -2792,21 +3085,21 @@ const ComponentInput = ({
|
|
2792
3085
|
id: getTranslation("components.reset-entry"),
|
2793
3086
|
defaultMessage: "Reset Entry"
|
2794
3087
|
}),
|
2795
|
-
|
2796
|
-
borderWidth: 0,
|
3088
|
+
variant: "ghost",
|
2797
3089
|
onClick: () => {
|
2798
3090
|
field.onChange(name2, null);
|
2799
|
-
}
|
3091
|
+
},
|
3092
|
+
children: /* @__PURE__ */ jsx(Trash, {})
|
2800
3093
|
}
|
2801
3094
|
)
|
2802
3095
|
] }),
|
2803
|
-
/* @__PURE__ */
|
2804
|
-
|
2805
|
-
|
2806
|
-
|
2807
|
-
] })
|
3096
|
+
!attribute.repeatable && !field.value && /* @__PURE__ */ jsx(Initializer, { disabled, name: name2, onClick: handleInitialisationClick }),
|
3097
|
+
!attribute.repeatable && field.value ? /* @__PURE__ */ jsx(NonRepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }) : null,
|
3098
|
+
attribute.repeatable && /* @__PURE__ */ jsx(RepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }),
|
3099
|
+
/* @__PURE__ */ jsx(Field.Error, {})
|
2808
3100
|
] });
|
2809
3101
|
};
|
3102
|
+
const MemoizedComponentInput = React.memo(ComponentInput);
|
2810
3103
|
const AddComponentButton = ({
|
2811
3104
|
hasError,
|
2812
3105
|
isDisabled,
|
@@ -2821,15 +3114,12 @@ const AddComponentButton = ({
|
|
2821
3114
|
onClick,
|
2822
3115
|
disabled: isDisabled,
|
2823
3116
|
background: "neutral0",
|
2824
|
-
paddingTop: 3,
|
2825
|
-
paddingBottom: 3,
|
2826
|
-
paddingLeft: 4,
|
2827
|
-
paddingRight: 4,
|
2828
3117
|
style: { cursor: isDisabled ? "not-allowed" : "pointer" },
|
2829
|
-
|
3118
|
+
variant: "tertiary",
|
3119
|
+
children: /* @__PURE__ */ jsxs(Flex, { tag: "span", gap: 2, children: [
|
2830
3120
|
/* @__PURE__ */ jsx(StyledAddIcon, { "aria-hidden": true, $isOpen: isOpen, $hasError: hasError && !isOpen }),
|
2831
3121
|
/* @__PURE__ */ jsx(
|
2832
|
-
|
3122
|
+
AddComponentTitle,
|
2833
3123
|
{
|
2834
3124
|
variant: "pi",
|
2835
3125
|
fontWeight: "bold",
|
@@ -2853,13 +3143,15 @@ const StyledAddIcon = styled(PlusCircle)`
|
|
2853
3143
|
fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral600};
|
2854
3144
|
}
|
2855
3145
|
`;
|
2856
|
-
const
|
3146
|
+
const AddComponentTitle = styled(Typography)``;
|
3147
|
+
const StyledButton = styled(Button)`
|
2857
3148
|
border-radius: 26px;
|
2858
3149
|
border-color: ${({ theme }) => theme.colors.neutral150};
|
2859
3150
|
box-shadow: ${({ theme }) => theme.shadows.filterShadow};
|
3151
|
+
height: 5rem;
|
2860
3152
|
|
2861
3153
|
&:hover {
|
2862
|
-
${
|
3154
|
+
${AddComponentTitle} {
|
2863
3155
|
color: ${({ theme }) => theme.colors.primary600};
|
2864
3156
|
}
|
2865
3157
|
|
@@ -2868,12 +3160,12 @@ const StyledButton = styled(BaseButton)`
|
|
2868
3160
|
fill: ${({ theme }) => theme.colors.primary600};
|
2869
3161
|
}
|
2870
3162
|
> path {
|
2871
|
-
fill: ${({ theme }) => theme.colors.
|
3163
|
+
fill: ${({ theme }) => theme.colors.primary600};
|
2872
3164
|
}
|
2873
3165
|
}
|
2874
3166
|
}
|
2875
3167
|
&:active {
|
2876
|
-
${
|
3168
|
+
${AddComponentTitle} {
|
2877
3169
|
color: ${({ theme }) => theme.colors.primary600};
|
2878
3170
|
}
|
2879
3171
|
${StyledAddIcon} {
|
@@ -2890,27 +3182,15 @@ const ComponentCategory = ({
|
|
2890
3182
|
category,
|
2891
3183
|
components = [],
|
2892
3184
|
variant = "primary",
|
2893
|
-
|
2894
|
-
onAddComponent,
|
2895
|
-
onToggle
|
3185
|
+
onAddComponent
|
2896
3186
|
}) => {
|
2897
3187
|
const { formatMessage } = useIntl();
|
2898
|
-
|
2899
|
-
|
2900
|
-
|
2901
|
-
return /* @__PURE__ */ jsxs(Accordion, { expanded: isOpen, onToggle: handleToggle, size: "S", children: [
|
2902
|
-
/* @__PURE__ */ jsx(
|
2903
|
-
AccordionToggle,
|
2904
|
-
{
|
2905
|
-
variant,
|
2906
|
-
title: formatMessage({ id: category, defaultMessage: category }),
|
2907
|
-
togglePosition: "left"
|
2908
|
-
}
|
2909
|
-
),
|
2910
|
-
/* @__PURE__ */ jsx(AccordionContent$1, { children: /* @__PURE__ */ jsx(Box, { paddingTop: 4, paddingBottom: 4, paddingLeft: 3, paddingRight: 3, children: /* @__PURE__ */ jsx(Grid, { children: components.map(({ uid, displayName, icon }) => /* @__PURE__ */ jsx(
|
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(
|
2911
3191
|
ComponentBox,
|
2912
3192
|
{
|
2913
|
-
|
3193
|
+
tag: "button",
|
2914
3194
|
type: "button",
|
2915
3195
|
background: "neutral100",
|
2916
3196
|
justifyContent: "center",
|
@@ -2920,34 +3200,32 @@ const ComponentCategory = ({
|
|
2920
3200
|
shrink: 0,
|
2921
3201
|
borderColor: "neutral200",
|
2922
3202
|
children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "center", justifyContent: "center", children: [
|
2923
|
-
/* @__PURE__ */ jsx(ComponentIcon, { icon }),
|
2924
|
-
/* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold",
|
3203
|
+
/* @__PURE__ */ jsx(ComponentIcon, { color: "currentColor", background: "primary200", icon }),
|
3204
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", children: displayName })
|
2925
3205
|
] })
|
2926
3206
|
},
|
2927
3207
|
uid
|
2928
|
-
)) }) })
|
3208
|
+
)) }) })
|
2929
3209
|
] });
|
2930
3210
|
};
|
2931
|
-
const Grid = styled
|
3211
|
+
const Grid = styled(Box)`
|
2932
3212
|
display: grid;
|
2933
3213
|
grid-template-columns: repeat(auto-fit, 14rem);
|
2934
3214
|
grid-gap: ${({ theme }) => theme.spaces[1]};
|
2935
3215
|
`;
|
2936
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
|
+
|
2937
3224
|
&:focus,
|
2938
3225
|
&:hover {
|
2939
3226
|
border: 1px solid ${({ theme }) => theme.colors.primary200};
|
2940
3227
|
background: ${({ theme }) => theme.colors.primary100};
|
2941
|
-
|
2942
|
-
${Typography} {
|
2943
|
-
color: ${({ theme }) => theme.colors.primary600};
|
2944
|
-
}
|
2945
|
-
|
2946
|
-
/* > Flex > ComponentIcon */
|
2947
|
-
> div > div:first-child {
|
2948
|
-
background: ${({ theme }) => theme.colors.primary200};
|
2949
|
-
color: ${({ theme }) => theme.colors.primary600};
|
2950
|
-
}
|
3228
|
+
color: ${({ theme }) => theme.colors.primary600};
|
2951
3229
|
}
|
2952
3230
|
`;
|
2953
3231
|
const ComponentPicker = ({
|
@@ -2956,19 +3234,8 @@ const ComponentPicker = ({
|
|
2956
3234
|
onClickAddComponent
|
2957
3235
|
}) => {
|
2958
3236
|
const { formatMessage } = useIntl();
|
2959
|
-
const [categoryToOpen, setCategoryToOpen] = React.useState("");
|
2960
|
-
React.useEffect(() => {
|
2961
|
-
const categoryKeys = Object.keys(dynamicComponentsByCategory);
|
2962
|
-
if (isOpen && categoryKeys.length > 0) {
|
2963
|
-
setCategoryToOpen(categoryKeys[0]);
|
2964
|
-
}
|
2965
|
-
}, [isOpen, dynamicComponentsByCategory]);
|
2966
3237
|
const handleAddComponentToDz = (componentUid) => () => {
|
2967
3238
|
onClickAddComponent(componentUid);
|
2968
|
-
setCategoryToOpen("");
|
2969
|
-
};
|
2970
|
-
const handleClickToggle = (categoryName) => {
|
2971
|
-
setCategoryToOpen((currentCat) => currentCat === categoryName ? "" : categoryName);
|
2972
3239
|
};
|
2973
3240
|
if (!isOpen) {
|
2974
3241
|
return null;
|
@@ -2989,14 +3256,12 @@ const ComponentPicker = ({
|
|
2989
3256
|
id: getTranslation("components.DynamicZone.ComponentPicker-label"),
|
2990
3257
|
defaultMessage: "Pick one component"
|
2991
3258
|
}) }) }),
|
2992
|
-
/* @__PURE__ */ jsx(Box, { paddingTop: 2, children: /* @__PURE__ */ jsx(
|
3259
|
+
/* @__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(
|
2993
3260
|
ComponentCategory,
|
2994
3261
|
{
|
2995
3262
|
category,
|
2996
3263
|
components,
|
2997
3264
|
onAddComponent: handleAddComponentToDz,
|
2998
|
-
isOpen: category === categoryToOpen,
|
2999
|
-
onToggle: handleClickToggle,
|
3000
3265
|
variant: index % 2 === 1 ? "primary" : "secondary"
|
3001
3266
|
},
|
3002
3267
|
category
|
@@ -3011,39 +3276,21 @@ const NotAllowedInput = ({ hint, label, required, name: name2 }) => {
|
|
3011
3276
|
id: "components.NotAllowedInput.text",
|
3012
3277
|
defaultMessage: "No permissions to see this field"
|
3013
3278
|
});
|
3014
|
-
return /* @__PURE__ */
|
3015
|
-
|
3016
|
-
|
3017
|
-
|
3018
|
-
|
3019
|
-
|
3020
|
-
|
3021
|
-
|
3022
|
-
|
3023
|
-
|
3024
|
-
|
3025
|
-
|
3026
|
-
|
3027
|
-
|
3028
|
-
);
|
3279
|
+
return /* @__PURE__ */ jsxs(Field.Root, { id: name2, hint, name: name2, required, children: [
|
3280
|
+
/* @__PURE__ */ jsx(Field.Label, { children: label }),
|
3281
|
+
/* @__PURE__ */ jsx(
|
3282
|
+
TextInput,
|
3283
|
+
{
|
3284
|
+
disabled: true,
|
3285
|
+
placeholder,
|
3286
|
+
startAction: /* @__PURE__ */ jsx(EyeStriked, { fill: "neutral600" }),
|
3287
|
+
type: "text",
|
3288
|
+
value: ""
|
3289
|
+
}
|
3290
|
+
),
|
3291
|
+
/* @__PURE__ */ jsx(Field.Hint, {})
|
3292
|
+
] });
|
3029
3293
|
};
|
3030
|
-
const StyledIcon = styled(EyeStriked)`
|
3031
|
-
& > path {
|
3032
|
-
fill: ${({ theme }) => theme.colors.neutral600};
|
3033
|
-
}
|
3034
|
-
`;
|
3035
|
-
function useDebounce(value, delay) {
|
3036
|
-
const [debouncedValue, setDebouncedValue] = useState(value);
|
3037
|
-
useEffect(() => {
|
3038
|
-
const handler = setTimeout(() => {
|
3039
|
-
setDebouncedValue(value);
|
3040
|
-
}, delay);
|
3041
|
-
return () => {
|
3042
|
-
clearTimeout(handler);
|
3043
|
-
};
|
3044
|
-
}, [value, delay]);
|
3045
|
-
return debouncedValue;
|
3046
|
-
}
|
3047
3294
|
const uidApi = contentManagerApi.injectEndpoints({
|
3048
3295
|
endpoints: (builder) => ({
|
3049
3296
|
getDefaultUID: builder.query({
|
@@ -3078,194 +3325,206 @@ const uidApi = contentManagerApi.injectEndpoints({
|
|
3078
3325
|
config: {
|
3079
3326
|
params
|
3080
3327
|
}
|
3081
|
-
})
|
3328
|
+
}),
|
3329
|
+
providesTags: (_res, _error, params) => [
|
3330
|
+
{ type: "UidAvailability", id: params.contentTypeUID }
|
3331
|
+
]
|
3082
3332
|
})
|
3083
3333
|
})
|
3084
3334
|
});
|
3085
3335
|
const { useGenerateUIDMutation, useGetDefaultUIDQuery, useGetAvailabilityQuery } = uidApi;
|
3086
3336
|
const UID_REGEX = /^[A-Za-z0-9-_.~]*$/;
|
3087
|
-
const UIDInput = React.forwardRef(
|
3088
|
-
|
3089
|
-
|
3090
|
-
|
3091
|
-
|
3092
|
-
|
3093
|
-
|
3094
|
-
|
3095
|
-
|
3096
|
-
|
3097
|
-
|
3098
|
-
|
3099
|
-
|
3100
|
-
|
3101
|
-
|
3102
|
-
|
3103
|
-
|
3104
|
-
|
3105
|
-
|
3106
|
-
|
3107
|
-
|
3108
|
-
id: id ?? "",
|
3109
|
-
...allFormValues
|
3110
|
-
},
|
3111
|
-
params
|
3112
|
-
},
|
3113
|
-
{
|
3114
|
-
skip: field.value || !props.required
|
3115
|
-
}
|
3116
|
-
);
|
3117
|
-
React.useEffect(() => {
|
3118
|
-
if (apiError) {
|
3119
|
-
toggleNotification({
|
3120
|
-
type: "warning",
|
3121
|
-
message: formatAPIError(apiError)
|
3122
|
-
});
|
3123
|
-
}
|
3124
|
-
}, [apiError, formatAPIError, toggleNotification]);
|
3125
|
-
React.useEffect(() => {
|
3126
|
-
if (defaultGeneratedUID && field.value === void 0) {
|
3127
|
-
field.onChange(props.name, defaultGeneratedUID);
|
3128
|
-
}
|
3129
|
-
}, [defaultGeneratedUID, field, props.name]);
|
3130
|
-
const [generateUID, { isLoading: isGeneratingUID }] = useGenerateUIDMutation();
|
3131
|
-
const handleRegenerateClick = async () => {
|
3132
|
-
try {
|
3133
|
-
const res = await generateUID({
|
3337
|
+
const UIDInput = React.forwardRef(
|
3338
|
+
({ hint, label, labelAction, name: name2, required, ...props }, ref) => {
|
3339
|
+
const { model, id } = useDoc();
|
3340
|
+
const allFormValues = useForm("InputUID", (form) => form.values);
|
3341
|
+
const [availability, setAvailability] = React.useState();
|
3342
|
+
const [showRegenerate, setShowRegenerate] = React.useState(false);
|
3343
|
+
const isCloning = useMatch(CLONE_PATH) !== null;
|
3344
|
+
const field = useField(name2);
|
3345
|
+
const debouncedValue = useDebounce(field.value, 300);
|
3346
|
+
const hasChanged = debouncedValue !== field.initialValue;
|
3347
|
+
const { toggleNotification } = useNotification();
|
3348
|
+
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
3349
|
+
const { formatMessage } = useIntl();
|
3350
|
+
const [{ query }] = useQueryParams();
|
3351
|
+
const params = React.useMemo(() => buildValidParams(query), [query]);
|
3352
|
+
const {
|
3353
|
+
data: defaultGeneratedUID,
|
3354
|
+
isLoading: isGeneratingDefaultUID,
|
3355
|
+
error: apiError
|
3356
|
+
} = useGetDefaultUIDQuery(
|
3357
|
+
{
|
3134
3358
|
contentTypeUID: model,
|
3135
|
-
field:
|
3136
|
-
data: {
|
3359
|
+
field: name2,
|
3360
|
+
data: {
|
3361
|
+
id: id ?? "",
|
3362
|
+
...allFormValues
|
3363
|
+
},
|
3137
3364
|
params
|
3138
|
-
}
|
3139
|
-
|
3140
|
-
field.
|
3141
|
-
}
|
3365
|
+
},
|
3366
|
+
{
|
3367
|
+
skip: field.value || !required
|
3368
|
+
}
|
3369
|
+
);
|
3370
|
+
React.useEffect(() => {
|
3371
|
+
if (apiError) {
|
3142
3372
|
toggleNotification({
|
3143
|
-
type: "
|
3144
|
-
message: formatAPIError(
|
3373
|
+
type: "warning",
|
3374
|
+
message: formatAPIError(apiError)
|
3145
3375
|
});
|
3146
3376
|
}
|
3147
|
-
}
|
3148
|
-
|
3149
|
-
|
3150
|
-
|
3151
|
-
|
3152
|
-
|
3153
|
-
|
3154
|
-
|
3155
|
-
|
3156
|
-
|
3157
|
-
|
3158
|
-
|
3159
|
-
|
3160
|
-
|
3161
|
-
|
3162
|
-
|
3163
|
-
|
3164
|
-
|
3165
|
-
|
3166
|
-
|
3167
|
-
|
3168
|
-
|
3169
|
-
|
3170
|
-
|
3171
|
-
|
3172
|
-
|
3173
|
-
|
3174
|
-
|
3175
|
-
|
3176
|
-
|
3177
|
-
|
3178
|
-
message: formatAPIError(availabilityError)
|
3179
|
-
});
|
3180
|
-
}
|
3181
|
-
}, [availabilityError, formatAPIError, toggleNotification]);
|
3182
|
-
React.useEffect(() => {
|
3183
|
-
setAvailability(availabilityData);
|
3184
|
-
let timer;
|
3185
|
-
if (availabilityData?.isAvailable) {
|
3186
|
-
timer = window.setTimeout(() => {
|
3187
|
-
setAvailability(void 0);
|
3188
|
-
}, 4e3);
|
3189
|
-
}
|
3190
|
-
return () => {
|
3191
|
-
if (timer) {
|
3192
|
-
clearTimeout(timer);
|
3377
|
+
}, [apiError, formatAPIError, toggleNotification]);
|
3378
|
+
React.useEffect(() => {
|
3379
|
+
if (defaultGeneratedUID && field.value === void 0) {
|
3380
|
+
field.onChange(name2, defaultGeneratedUID);
|
3381
|
+
}
|
3382
|
+
}, [defaultGeneratedUID, field, name2]);
|
3383
|
+
const [generateUID, { isLoading: isGeneratingUID }] = useGenerateUIDMutation();
|
3384
|
+
const handleRegenerateClick = async () => {
|
3385
|
+
try {
|
3386
|
+
const res = await generateUID({
|
3387
|
+
contentTypeUID: model,
|
3388
|
+
field: name2,
|
3389
|
+
data: { id: id ?? "", ...allFormValues },
|
3390
|
+
params
|
3391
|
+
});
|
3392
|
+
if ("data" in res) {
|
3393
|
+
field.onChange(name2, res.data);
|
3394
|
+
} else {
|
3395
|
+
toggleNotification({
|
3396
|
+
type: "danger",
|
3397
|
+
message: formatAPIError(res.error)
|
3398
|
+
});
|
3399
|
+
}
|
3400
|
+
} catch (err) {
|
3401
|
+
toggleNotification({
|
3402
|
+
type: "danger",
|
3403
|
+
message: formatMessage({
|
3404
|
+
id: "notification.error",
|
3405
|
+
defaultMessage: "An error occurred."
|
3406
|
+
})
|
3407
|
+
});
|
3193
3408
|
}
|
3194
3409
|
};
|
3195
|
-
|
3196
|
-
|
3197
|
-
|
3198
|
-
|
3199
|
-
|
3200
|
-
// @ts-expect-error – label _could_ be a ReactNode since it's a child, this should be fixed in the DS.
|
3201
|
-
/* @__PURE__ */ jsx(
|
3202
|
-
TextInput,
|
3410
|
+
const {
|
3411
|
+
data: availabilityData,
|
3412
|
+
isLoading: isCheckingAvailability,
|
3413
|
+
error: availabilityError
|
3414
|
+
} = useGetAvailabilityQuery(
|
3203
3415
|
{
|
3204
|
-
|
3205
|
-
|
3206
|
-
|
3207
|
-
|
3208
|
-
|
3209
|
-
|
3210
|
-
|
3211
|
-
|
3212
|
-
|
3213
|
-
|
3214
|
-
|
3215
|
-
|
3216
|
-
|
3217
|
-
|
3218
|
-
|
3219
|
-
|
3220
|
-
|
3221
|
-
|
3222
|
-
|
3223
|
-
|
3224
|
-
|
3225
|
-
|
3226
|
-
|
3227
|
-
|
3228
|
-
|
3229
|
-
|
3230
|
-
|
3231
|
-
|
3232
|
-
|
3233
|
-
|
3234
|
-
|
3235
|
-
|
3236
|
-
|
3237
|
-
|
3238
|
-
|
3239
|
-
|
3240
|
-
|
3241
|
-
|
3242
|
-
|
3243
|
-
|
3244
|
-
|
3245
|
-
|
3246
|
-
|
3247
|
-
|
3416
|
+
contentTypeUID: model,
|
3417
|
+
field: name2,
|
3418
|
+
value: debouncedValue ? debouncedValue.trim() : "",
|
3419
|
+
params
|
3420
|
+
},
|
3421
|
+
{
|
3422
|
+
// Don't check availability if the value is empty or wasn't changed
|
3423
|
+
skip: !Boolean(
|
3424
|
+
(hasChanged || isCloning) && debouncedValue && UID_REGEX.test(debouncedValue.trim())
|
3425
|
+
)
|
3426
|
+
}
|
3427
|
+
);
|
3428
|
+
React.useEffect(() => {
|
3429
|
+
if (availabilityError) {
|
3430
|
+
toggleNotification({
|
3431
|
+
type: "warning",
|
3432
|
+
message: formatAPIError(availabilityError)
|
3433
|
+
});
|
3434
|
+
}
|
3435
|
+
}, [availabilityError, formatAPIError, toggleNotification]);
|
3436
|
+
React.useEffect(() => {
|
3437
|
+
setAvailability(availabilityData);
|
3438
|
+
let timer;
|
3439
|
+
if (availabilityData?.isAvailable) {
|
3440
|
+
timer = window.setTimeout(() => {
|
3441
|
+
setAvailability(void 0);
|
3442
|
+
}, 4e3);
|
3443
|
+
}
|
3444
|
+
return () => {
|
3445
|
+
if (timer) {
|
3446
|
+
clearTimeout(timer);
|
3447
|
+
}
|
3448
|
+
};
|
3449
|
+
}, [availabilityData]);
|
3450
|
+
const isLoading = isGeneratingDefaultUID || isGeneratingUID || isCheckingAvailability;
|
3451
|
+
const fieldRef = useFocusInputField(name2);
|
3452
|
+
const composedRefs = useComposedRefs(ref, fieldRef);
|
3453
|
+
const shouldShowAvailability = (hasChanged || isCloning) && debouncedValue != null && availability && !showRegenerate;
|
3454
|
+
return /* @__PURE__ */ jsxs(Field.Root, { hint, name: name2, error: field.error, required, children: [
|
3455
|
+
/* @__PURE__ */ jsx(Field.Label, { action: labelAction, children: label }),
|
3456
|
+
/* @__PURE__ */ jsx(
|
3457
|
+
TextInput,
|
3458
|
+
{
|
3459
|
+
ref: composedRefs,
|
3460
|
+
disabled: props.disabled,
|
3461
|
+
endAction: /* @__PURE__ */ jsxs(Flex, { position: "relative", gap: 1, children: [
|
3462
|
+
shouldShowAvailability && /* @__PURE__ */ jsxs(
|
3463
|
+
TextValidation,
|
3248
3464
|
{
|
3249
|
-
|
3250
|
-
|
3251
|
-
|
3252
|
-
|
3253
|
-
|
3254
|
-
|
3255
|
-
|
3256
|
-
|
3465
|
+
alignItems: "center",
|
3466
|
+
gap: 1,
|
3467
|
+
justifyContent: "flex-end",
|
3468
|
+
$available: !!availability?.isAvailable,
|
3469
|
+
"data-not-here-outer": true,
|
3470
|
+
position: "absolute",
|
3471
|
+
pointerEvents: "none",
|
3472
|
+
right: 6,
|
3473
|
+
width: "100px",
|
3474
|
+
children: [
|
3475
|
+
availability?.isAvailable ? /* @__PURE__ */ jsx(CheckCircle, {}) : /* @__PURE__ */ jsx(WarningCircle, {}),
|
3476
|
+
/* @__PURE__ */ jsx(
|
3477
|
+
Typography,
|
3478
|
+
{
|
3479
|
+
textColor: availability.isAvailable ? "success600" : "danger600",
|
3480
|
+
variant: "pi",
|
3481
|
+
children: formatMessage(
|
3482
|
+
availability.isAvailable ? {
|
3483
|
+
id: "content-manager.components.uid.available",
|
3484
|
+
defaultMessage: "Available"
|
3485
|
+
} : {
|
3486
|
+
id: "content-manager.components.uid.unavailable",
|
3487
|
+
defaultMessage: "Unavailable"
|
3488
|
+
}
|
3489
|
+
)
|
3490
|
+
}
|
3491
|
+
)
|
3492
|
+
]
|
3257
3493
|
}
|
3258
|
-
)
|
3259
|
-
|
3260
|
-
|
3261
|
-
|
3262
|
-
|
3263
|
-
|
3264
|
-
|
3265
|
-
|
3266
|
-
|
3267
|
-
|
3268
|
-
|
3494
|
+
),
|
3495
|
+
!props.disabled && /* @__PURE__ */ jsxs(Fragment, { children: [
|
3496
|
+
showRegenerate && /* @__PURE__ */ jsx(TextValidation, { alignItems: "center", justifyContent: "flex-end", gap: 1, children: /* @__PURE__ */ jsx(Typography, { textColor: "primary600", variant: "pi", children: formatMessage({
|
3497
|
+
id: "content-manager.components.uid.regenerate",
|
3498
|
+
defaultMessage: "Regenerate"
|
3499
|
+
}) }) }),
|
3500
|
+
/* @__PURE__ */ jsx(
|
3501
|
+
FieldActionWrapper,
|
3502
|
+
{
|
3503
|
+
onClick: handleRegenerateClick,
|
3504
|
+
label: formatMessage({
|
3505
|
+
id: "content-manager.components.uid.regenerate",
|
3506
|
+
defaultMessage: "Regenerate"
|
3507
|
+
}),
|
3508
|
+
onMouseEnter: () => setShowRegenerate(true),
|
3509
|
+
onMouseLeave: () => setShowRegenerate(false),
|
3510
|
+
children: isLoading ? /* @__PURE__ */ jsx(LoadingWrapper, { "data-testid": "loading-wrapper", children: /* @__PURE__ */ jsx(Loader, {}) }) : /* @__PURE__ */ jsx(ArrowClockwise, {})
|
3511
|
+
}
|
3512
|
+
)
|
3513
|
+
] })
|
3514
|
+
] }),
|
3515
|
+
onChange: field.onChange,
|
3516
|
+
value: field.value ?? "",
|
3517
|
+
...props
|
3518
|
+
}
|
3519
|
+
),
|
3520
|
+
/* @__PURE__ */ jsx(Field.Error, {}),
|
3521
|
+
/* @__PURE__ */ jsx(Field.Hint, {})
|
3522
|
+
] });
|
3523
|
+
}
|
3524
|
+
);
|
3525
|
+
const FieldActionWrapper = styled(Field.Action)`
|
3526
|
+
width: 1.6rem;
|
3527
|
+
|
3269
3528
|
svg {
|
3270
3529
|
height: 1.6rem;
|
3271
3530
|
width: 1.6rem;
|
@@ -3286,7 +3545,7 @@ const TextValidation = styled(Flex)`
|
|
3286
3545
|
width: 1.2rem;
|
3287
3546
|
|
3288
3547
|
path {
|
3289
|
-
fill: ${({ theme, available }) => available ? theme.colors.success600 : theme.colors.danger600};
|
3548
|
+
fill: ${({ theme, $available }) => $available ? theme.colors.success600 : theme.colors.danger600};
|
3290
3549
|
}
|
3291
3550
|
}
|
3292
3551
|
`;
|
@@ -3301,6 +3560,7 @@ const rotation = keyframes`
|
|
3301
3560
|
const LoadingWrapper = styled(Flex)`
|
3302
3561
|
animation: ${rotation} 2s infinite linear;
|
3303
3562
|
`;
|
3563
|
+
const MemoizedUIDInput = React.memo(UIDInput);
|
3304
3564
|
const md = new Markdown({
|
3305
3565
|
html: true,
|
3306
3566
|
// Enable HTML tags in source
|
@@ -3635,7 +3895,7 @@ const Editor = React.forwardRef(
|
|
3635
3895
|
[editorRef]
|
3636
3896
|
);
|
3637
3897
|
return /* @__PURE__ */ jsxs(EditorAndPreviewWrapper, { children: [
|
3638
|
-
/* @__PURE__ */ jsx(EditorStylesContainer, { isExpandMode, disabled: disabled || isPreviewMode, children: /* @__PURE__ */ jsx("textarea", { ref: textareaRef }) }),
|
3898
|
+
/* @__PURE__ */ jsx(EditorStylesContainer, { $isExpandMode: isExpandMode, $disabled: disabled || isPreviewMode, children: /* @__PURE__ */ jsx("textarea", { ref: textareaRef }) }),
|
3639
3899
|
isPreviewMode && /* @__PURE__ */ jsx(PreviewWysiwyg, { data: value })
|
3640
3900
|
] });
|
3641
3901
|
}
|
@@ -3645,7 +3905,7 @@ const EditorAndPreviewWrapper = styled.div`
|
|
3645
3905
|
height: calc(100% - 48px);
|
3646
3906
|
`;
|
3647
3907
|
const EditorStylesContainer = styled.div`
|
3648
|
-
cursor: ${({ disabled }) => disabled ? "not-allowed !important" : "auto"};
|
3908
|
+
cursor: ${({ $disabled }) => $disabled ? "not-allowed !important" : "auto"};
|
3649
3909
|
height: 100%;
|
3650
3910
|
/* BASICS */
|
3651
3911
|
.CodeMirror-placeholder {
|
@@ -3655,7 +3915,7 @@ const EditorStylesContainer = styled.div`
|
|
3655
3915
|
.CodeMirror {
|
3656
3916
|
/* Set height, width, borders, and global font properties here */
|
3657
3917
|
font-size: 1.4rem;
|
3658
|
-
height: ${({ isExpandMode }) => isExpandMode ? "100%" : "410px"}; // 512px(total height) - 48px (header) - 52px(footer) - 2px border
|
3918
|
+
height: ${({ $isExpandMode }) => $isExpandMode ? "100%" : "410px"}; // 512px(total height) - 48px (header) - 52px(footer) - 2px border
|
3659
3919
|
color: ${({ theme }) => theme.colors.neutral800};
|
3660
3920
|
direction: ltr;
|
3661
3921
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
|
@@ -4033,7 +4293,7 @@ const EditorLayout = ({
|
|
4033
4293
|
justifyContent: "flex-end",
|
4034
4294
|
shrink: 0,
|
4035
4295
|
width: "100%",
|
4036
|
-
children: /* @__PURE__ */ jsxs(ExpandButton$1, { onClick: onCollapse, children: [
|
4296
|
+
children: /* @__PURE__ */ jsxs(ExpandButton$1, { onClick: onCollapse, variant: "tertiary", size: "M", children: [
|
4037
4297
|
/* @__PURE__ */ jsx(Typography, { children: formatMessage({
|
4038
4298
|
id: "components.Wysiwyg.collapse",
|
4039
4299
|
defaultMessage: "Collapse"
|
@@ -4051,12 +4311,14 @@ const EditorLayout = ({
|
|
4051
4311
|
) }) });
|
4052
4312
|
}
|
4053
4313
|
return /* @__PURE__ */ jsx(
|
4054
|
-
|
4314
|
+
Flex,
|
4055
4315
|
{
|
4056
4316
|
borderColor: error ? "danger600" : "neutral200",
|
4057
4317
|
borderStyle: "solid",
|
4058
4318
|
borderWidth: "1px",
|
4059
4319
|
hasRadius: true,
|
4320
|
+
direction: "column",
|
4321
|
+
alignItems: "stretch",
|
4060
4322
|
children
|
4061
4323
|
}
|
4062
4324
|
);
|
@@ -4067,11 +4329,19 @@ const ExpandWrapper = styled(Flex)`
|
|
4067
4329
|
const BoxWithBorder = styled(Box)`
|
4068
4330
|
border-right: 1px solid ${({ theme }) => theme.colors.neutral200};
|
4069
4331
|
`;
|
4070
|
-
const ExpandButton$1 = styled(
|
4332
|
+
const ExpandButton$1 = styled(Button)`
|
4071
4333
|
background-color: transparent;
|
4072
4334
|
border: none;
|
4073
4335
|
align-items: center;
|
4074
4336
|
|
4337
|
+
& > span {
|
4338
|
+
display: flex;
|
4339
|
+
justify-content: space-between;
|
4340
|
+
align-items: center;
|
4341
|
+
width: 100%;
|
4342
|
+
font-weight: ${({ theme }) => theme.fontWeights.regular};
|
4343
|
+
}
|
4344
|
+
|
4075
4345
|
svg {
|
4076
4346
|
margin-left: ${({ theme }) => `${theme.spaces[2]}`};
|
4077
4347
|
|
@@ -4338,42 +4608,28 @@ const quoteAndCodeHandler = (editor, markdownType) => {
|
|
4338
4608
|
insertWithoutTextToEdit(editor, markdownType, line, contentLength);
|
4339
4609
|
}
|
4340
4610
|
};
|
4341
|
-
const CustomIconButton = styled(IconButton)`
|
4342
|
-
padding: ${({ theme }) => theme.spaces[2]};
|
4343
|
-
/* Trick to prevent the outline from overflowing because of the general outline-offset */
|
4344
|
-
outline-offset: -2px !important;
|
4345
|
-
|
4346
|
-
svg {
|
4347
|
-
width: 1.8rem;
|
4348
|
-
height: 1.8rem;
|
4349
|
-
}
|
4350
|
-
`;
|
4351
|
-
const CustomLinkIconButton = styled(CustomIconButton)`
|
4352
|
-
svg {
|
4353
|
-
width: 0.8rem;
|
4354
|
-
height: 0.8rem;
|
4355
|
-
}
|
4356
|
-
`;
|
4357
4611
|
const MainButtons = styled(IconButtonGroup)`
|
4358
4612
|
margin-left: ${({ theme }) => theme.spaces[4]};
|
4359
4613
|
`;
|
4360
4614
|
const MoreButton = styled(IconButton)`
|
4361
4615
|
margin: ${({ theme }) => `0 ${theme.spaces[2]}`};
|
4362
|
-
padding: ${({ theme }) => theme.spaces[2]};
|
4363
|
-
|
4364
|
-
svg {
|
4365
|
-
width: 1.8rem;
|
4366
|
-
height: 1.8rem;
|
4367
|
-
}
|
4368
4616
|
`;
|
4369
4617
|
const IconButtonGroupMargin = styled(IconButtonGroup)`
|
4370
4618
|
margin-right: ${({ theme }) => `${theme.spaces[2]}`};
|
4371
4619
|
`;
|
4372
|
-
const ExpandButton = styled(
|
4620
|
+
const ExpandButton = styled(Button)`
|
4373
4621
|
background-color: transparent;
|
4374
4622
|
border: none;
|
4375
4623
|
align-items: center;
|
4376
4624
|
|
4625
|
+
& > span {
|
4626
|
+
display: flex;
|
4627
|
+
justify-content: space-between;
|
4628
|
+
align-items: center;
|
4629
|
+
width: 100%;
|
4630
|
+
font-weight: ${({ theme }) => theme.fontWeights.regular};
|
4631
|
+
}
|
4632
|
+
|
4377
4633
|
svg {
|
4378
4634
|
margin-left: ${({ theme }) => `${theme.spaces[2]}`};
|
4379
4635
|
path {
|
@@ -4385,8 +4641,8 @@ const ExpandButton = styled(BaseButton)`
|
|
4385
4641
|
`;
|
4386
4642
|
const WysiwygFooter = ({ onToggleExpand }) => {
|
4387
4643
|
const { formatMessage } = useIntl();
|
4388
|
-
return /* @__PURE__ */ jsx(Box, { padding: 2, background: "neutral100", borderRadius: `0 0 0.4rem 0.4rem`, children: /* @__PURE__ */ jsx(Flex, { justifyContent: "flex-end", alignItems: "flex-end", children: /* @__PURE__ */ jsxs(ExpandButton, { id: "expand", onClick: onToggleExpand, children: [
|
4389
|
-
/* @__PURE__ */ jsx(Typography, { children: formatMessage({
|
4644
|
+
return /* @__PURE__ */ jsx(Box, { padding: 2, background: "neutral100", borderRadius: `0 0 0.4rem 0.4rem`, children: /* @__PURE__ */ jsx(Flex, { justifyContent: "flex-end", alignItems: "flex-end", children: /* @__PURE__ */ jsxs(ExpandButton, { id: "expand", onClick: onToggleExpand, variant: "tertiary", size: "M", children: [
|
4645
|
+
/* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: formatMessage({
|
4390
4646
|
id: "components.WysiwygBottomControls.fullscreen",
|
4391
4647
|
defaultMessage: "Expand"
|
4392
4648
|
}) }),
|
@@ -4408,7 +4664,7 @@ const WysiwygNav = ({
|
|
4408
4664
|
id: "components.Wysiwyg.selectOptions.title",
|
4409
4665
|
defaultMessage: "Add a title"
|
4410
4666
|
});
|
4411
|
-
|
4667
|
+
React.useRef(null);
|
4412
4668
|
const handleTogglePopover = () => {
|
4413
4669
|
setVisiblePopover((prev) => !prev);
|
4414
4670
|
};
|
@@ -4421,21 +4677,30 @@ const WysiwygNav = ({
|
|
4421
4677
|
justifyContent: "space-between",
|
4422
4678
|
borderRadius: `0.4rem 0.4rem 0 0`,
|
4423
4679
|
children: [
|
4424
|
-
/* @__PURE__ */ jsxs(
|
4425
|
-
/* @__PURE__ */
|
4426
|
-
|
4427
|
-
|
4428
|
-
|
4429
|
-
|
4430
|
-
|
4431
|
-
|
4432
|
-
|
4680
|
+
/* @__PURE__ */ jsxs(Flex, { children: [
|
4681
|
+
/* @__PURE__ */ jsx(Field.Root, { children: /* @__PURE__ */ jsxs(
|
4682
|
+
SingleSelect,
|
4683
|
+
{
|
4684
|
+
disabled: true,
|
4685
|
+
placeholder: selectPlaceholder,
|
4686
|
+
"aria-label": selectPlaceholder,
|
4687
|
+
size: "S",
|
4688
|
+
children: [
|
4689
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h1", children: "h1" }),
|
4690
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h2", children: "h2" }),
|
4691
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h3", children: "h3" }),
|
4692
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h4", children: "h4" }),
|
4693
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h5", children: "h5" }),
|
4694
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h6", children: "h6" })
|
4695
|
+
]
|
4696
|
+
}
|
4697
|
+
) }),
|
4433
4698
|
/* @__PURE__ */ jsxs(MainButtons, { children: [
|
4434
|
-
/* @__PURE__ */ jsx(
|
4435
|
-
/* @__PURE__ */ jsx(
|
4436
|
-
/* @__PURE__ */ jsx(
|
4699
|
+
/* @__PURE__ */ jsx(IconButton, { disabled: true, label: "Bold", name: "Bold", children: /* @__PURE__ */ jsx(Bold, {}) }),
|
4700
|
+
/* @__PURE__ */ jsx(IconButton, { disabled: true, label: "Italic", name: "Italic", children: /* @__PURE__ */ jsx(Italic, {}) }),
|
4701
|
+
/* @__PURE__ */ jsx(IconButton, { disabled: true, label: "Underline", name: "Underline", children: /* @__PURE__ */ jsx(Underline, {}) })
|
4437
4702
|
] }),
|
4438
|
-
/* @__PURE__ */ jsx(MoreButton, { disabled: true, label: "More",
|
4703
|
+
/* @__PURE__ */ jsx(MoreButton, { disabled: true, label: "More", children: /* @__PURE__ */ jsx(More, {}) })
|
4439
4704
|
] }),
|
4440
4705
|
!isExpandMode && /* @__PURE__ */ jsx(Button, { onClick: onTogglePreviewMode, variant: "tertiary", children: formatMessage({
|
4441
4706
|
id: "components.Wysiwyg.ToggleMode.markdown-mode",
|
@@ -4453,14 +4718,14 @@ const WysiwygNav = ({
|
|
4453
4718
|
justifyContent: "space-between",
|
4454
4719
|
borderRadius: `0.4rem 0.4rem 0 0`,
|
4455
4720
|
children: [
|
4456
|
-
/* @__PURE__ */ jsxs(
|
4457
|
-
/* @__PURE__ */ jsxs(
|
4721
|
+
/* @__PURE__ */ jsxs(Flex, { children: [
|
4722
|
+
/* @__PURE__ */ jsx(Field.Root, { children: /* @__PURE__ */ jsxs(
|
4458
4723
|
SingleSelect,
|
4459
4724
|
{
|
4460
4725
|
placeholder: selectPlaceholder,
|
4461
|
-
label: selectPlaceholder,
|
4462
|
-
size: "S",
|
4726
|
+
"aria-label": selectPlaceholder,
|
4463
4727
|
onChange: (value) => onActionClick(value, editorRef),
|
4728
|
+
size: "S",
|
4464
4729
|
children: [
|
4465
4730
|
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h1", children: "h1" }),
|
4466
4731
|
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h2", children: "h2" }),
|
@@ -4470,117 +4735,103 @@ const WysiwygNav = ({
|
|
4470
4735
|
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h6", children: "h6" })
|
4471
4736
|
]
|
4472
4737
|
}
|
4473
|
-
),
|
4738
|
+
) }),
|
4474
4739
|
/* @__PURE__ */ jsxs(MainButtons, { children: [
|
4740
|
+
/* @__PURE__ */ jsx(IconButton, { onClick: () => onActionClick("Bold", editorRef), label: "Bold", name: "Bold", children: /* @__PURE__ */ jsx(Bold, {}) }),
|
4475
4741
|
/* @__PURE__ */ jsx(
|
4476
|
-
|
4477
|
-
{
|
4478
|
-
onClick: () => onActionClick("Bold", editorRef),
|
4479
|
-
label: "Bold",
|
4480
|
-
name: "Bold",
|
4481
|
-
icon: /* @__PURE__ */ jsx(Bold, {})
|
4482
|
-
}
|
4483
|
-
),
|
4484
|
-
/* @__PURE__ */ jsx(
|
4485
|
-
CustomIconButton,
|
4742
|
+
IconButton,
|
4486
4743
|
{
|
4487
4744
|
onClick: () => onActionClick("Italic", editorRef),
|
4488
4745
|
label: "Italic",
|
4489
4746
|
name: "Italic",
|
4490
|
-
|
4747
|
+
children: /* @__PURE__ */ jsx(Italic, {})
|
4491
4748
|
}
|
4492
4749
|
),
|
4493
4750
|
/* @__PURE__ */ jsx(
|
4494
|
-
|
4751
|
+
IconButton,
|
4495
4752
|
{
|
4496
4753
|
onClick: () => onActionClick("Underline", editorRef),
|
4497
4754
|
label: "Underline",
|
4498
4755
|
name: "Underline",
|
4499
|
-
|
4756
|
+
children: /* @__PURE__ */ jsx(Underline, {})
|
4500
4757
|
}
|
4501
4758
|
)
|
4502
4759
|
] }),
|
4503
|
-
/* @__PURE__ */
|
4504
|
-
MoreButton,
|
4505
|
-
{
|
4506
|
-
|
4507
|
-
|
4508
|
-
|
4509
|
-
|
4510
|
-
|
4511
|
-
|
4512
|
-
|
4513
|
-
|
4514
|
-
|
4515
|
-
|
4516
|
-
|
4517
|
-
|
4518
|
-
|
4519
|
-
|
4520
|
-
|
4521
|
-
|
4522
|
-
|
4523
|
-
|
4524
|
-
|
4525
|
-
|
4526
|
-
|
4527
|
-
|
4528
|
-
|
4529
|
-
|
4530
|
-
|
4531
|
-
|
4532
|
-
|
4533
|
-
|
4534
|
-
|
4535
|
-
|
4536
|
-
|
4537
|
-
|
4538
|
-
|
4539
|
-
|
4540
|
-
|
4541
|
-
|
4542
|
-
|
4543
|
-
|
4544
|
-
|
4545
|
-
|
4546
|
-
|
4547
|
-
|
4548
|
-
|
4549
|
-
|
4550
|
-
|
4551
|
-
|
4552
|
-
|
4553
|
-
|
4554
|
-
|
4555
|
-
|
4556
|
-
|
4557
|
-
|
4558
|
-
|
4559
|
-
|
4560
|
-
|
4561
|
-
|
4562
|
-
|
4563
|
-
|
4564
|
-
|
4565
|
-
|
4566
|
-
|
4567
|
-
|
4568
|
-
|
4569
|
-
|
4570
|
-
|
4571
|
-
|
4572
|
-
|
4573
|
-
|
4574
|
-
|
4575
|
-
|
4576
|
-
|
4577
|
-
|
4578
|
-
name: "Quote",
|
4579
|
-
icon: /* @__PURE__ */ jsx(Quotes, {})
|
4580
|
-
}
|
4581
|
-
)
|
4582
|
-
] })
|
4583
|
-
] }) })
|
4760
|
+
/* @__PURE__ */ jsxs(Popover.Root, { children: [
|
4761
|
+
/* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx(MoreButton, { label: "More", children: /* @__PURE__ */ jsx(More, {}) }) }),
|
4762
|
+
/* @__PURE__ */ jsx(Popover.Content, { sideOffset: 12, children: /* @__PURE__ */ jsxs(Flex, { padding: 2, children: [
|
4763
|
+
/* @__PURE__ */ jsxs(IconButtonGroupMargin, { children: [
|
4764
|
+
/* @__PURE__ */ jsx(
|
4765
|
+
IconButton,
|
4766
|
+
{
|
4767
|
+
onClick: () => onActionClick("Strikethrough", editorRef, handleTogglePopover),
|
4768
|
+
label: "Strikethrough",
|
4769
|
+
name: "Strikethrough",
|
4770
|
+
children: /* @__PURE__ */ jsx(StrikeThrough, {})
|
4771
|
+
}
|
4772
|
+
),
|
4773
|
+
/* @__PURE__ */ jsx(
|
4774
|
+
IconButton,
|
4775
|
+
{
|
4776
|
+
onClick: () => onActionClick("BulletList", editorRef, handleTogglePopover),
|
4777
|
+
label: "BulletList",
|
4778
|
+
name: "BulletList",
|
4779
|
+
children: /* @__PURE__ */ jsx(BulletList, {})
|
4780
|
+
}
|
4781
|
+
),
|
4782
|
+
/* @__PURE__ */ jsx(
|
4783
|
+
IconButton,
|
4784
|
+
{
|
4785
|
+
onClick: () => onActionClick("NumberList", editorRef, handleTogglePopover),
|
4786
|
+
label: "NumberList",
|
4787
|
+
name: "NumberList",
|
4788
|
+
children: /* @__PURE__ */ jsx(NumberList, {})
|
4789
|
+
}
|
4790
|
+
)
|
4791
|
+
] }),
|
4792
|
+
/* @__PURE__ */ jsxs(IconButtonGroup, { children: [
|
4793
|
+
/* @__PURE__ */ jsx(
|
4794
|
+
IconButton,
|
4795
|
+
{
|
4796
|
+
onClick: () => onActionClick("Code", editorRef, handleTogglePopover),
|
4797
|
+
label: "Code",
|
4798
|
+
name: "Code",
|
4799
|
+
children: /* @__PURE__ */ jsx(Code, {})
|
4800
|
+
}
|
4801
|
+
),
|
4802
|
+
/* @__PURE__ */ jsx(
|
4803
|
+
IconButton,
|
4804
|
+
{
|
4805
|
+
onClick: () => {
|
4806
|
+
handleTogglePopover();
|
4807
|
+
onToggleMediaLib();
|
4808
|
+
},
|
4809
|
+
label: "Image",
|
4810
|
+
name: "Image",
|
4811
|
+
children: /* @__PURE__ */ jsx(Image$1, {})
|
4812
|
+
}
|
4813
|
+
),
|
4814
|
+
/* @__PURE__ */ jsx(
|
4815
|
+
IconButton,
|
4816
|
+
{
|
4817
|
+
onClick: () => onActionClick("Link", editorRef, handleTogglePopover),
|
4818
|
+
label: "Link",
|
4819
|
+
name: "Link",
|
4820
|
+
children: /* @__PURE__ */ jsx(Link$1, {})
|
4821
|
+
}
|
4822
|
+
),
|
4823
|
+
/* @__PURE__ */ jsx(
|
4824
|
+
IconButton,
|
4825
|
+
{
|
4826
|
+
onClick: () => onActionClick("Quote", editorRef, handleTogglePopover),
|
4827
|
+
label: "Quote",
|
4828
|
+
name: "Quote",
|
4829
|
+
children: /* @__PURE__ */ jsx(Quotes, {})
|
4830
|
+
}
|
4831
|
+
)
|
4832
|
+
] })
|
4833
|
+
] }) })
|
4834
|
+
] })
|
4584
4835
|
] }),
|
4585
4836
|
onTogglePreviewMode && /* @__PURE__ */ jsx(Button, { onClick: onTogglePreviewMode, variant: "tertiary", children: formatMessage({
|
4586
4837
|
id: "components.Wysiwyg.ToggleMode.preview-mode",
|
@@ -4590,19 +4841,6 @@ const WysiwygNav = ({
|
|
4590
4841
|
}
|
4591
4842
|
);
|
4592
4843
|
};
|
4593
|
-
const StyledFlex = styled(Flex)`
|
4594
|
-
/* Hide the label, every input needs a label. */
|
4595
|
-
label {
|
4596
|
-
border: 0;
|
4597
|
-
clip: rect(0 0 0 0);
|
4598
|
-
height: 1px;
|
4599
|
-
margin: -1px;
|
4600
|
-
overflow: hidden;
|
4601
|
-
padding: 0;
|
4602
|
-
position: absolute;
|
4603
|
-
width: 1px;
|
4604
|
-
}
|
4605
|
-
`;
|
4606
4844
|
const Wysiwyg = React.forwardRef(
|
4607
4845
|
({ hint, disabled, label, name: name2, placeholder, required, labelAction }, forwardedRef) => {
|
4608
4846
|
const field = useField(name2);
|
@@ -4667,9 +4905,9 @@ const Wysiwyg = React.forwardRef(
|
|
4667
4905
|
insertFile(editorRef, formattedFiles);
|
4668
4906
|
setMediaLibVisible(false);
|
4669
4907
|
};
|
4670
|
-
return /* @__PURE__ */ jsxs(Field, { name: name2, hint, error: field.error, required, children: [
|
4908
|
+
return /* @__PURE__ */ jsxs(Field.Root, { name: name2, hint, error: field.error, required, children: [
|
4671
4909
|
/* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
|
4672
|
-
/* @__PURE__ */ jsx(
|
4910
|
+
/* @__PURE__ */ jsx(Field.Label, { action: labelAction, children: label }),
|
4673
4911
|
/* @__PURE__ */ jsxs(
|
4674
4912
|
EditorLayout,
|
4675
4913
|
{
|
@@ -4710,24 +4948,29 @@ const Wysiwyg = React.forwardRef(
|
|
4710
4948
|
]
|
4711
4949
|
}
|
4712
4950
|
),
|
4713
|
-
/* @__PURE__ */ jsx(
|
4714
|
-
/* @__PURE__ */ jsx(
|
4951
|
+
/* @__PURE__ */ jsx(Field.Hint, {}),
|
4952
|
+
/* @__PURE__ */ jsx(Field.Error, {})
|
4715
4953
|
] }),
|
4716
4954
|
mediaLibVisible && // @ts-expect-error – TODO: fix this way of injecting because it's not really typeable without a registry.
|
4717
4955
|
/* @__PURE__ */ jsx(MediaLibraryDialog, { onClose: handleToggleMediaLib, onSelectAssets: handleSelectAssets })
|
4718
4956
|
] });
|
4719
4957
|
}
|
4720
4958
|
);
|
4959
|
+
const MemoizedWysiwyg = React.memo(Wysiwyg);
|
4721
4960
|
const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
|
4722
|
-
const { id } = useDoc();
|
4961
|
+
const { id, document: document2, collectionType } = useDoc();
|
4723
4962
|
const isFormDisabled = useForm("InputRenderer", (state) => state.disabled);
|
4724
4963
|
const isInDynamicZone = useDynamicZone("isInDynamicZone", (state) => state.isInDynamicZone);
|
4725
4964
|
const canCreateFields = useDocumentRBAC("InputRenderer", (rbac) => rbac.canCreateFields);
|
4726
4965
|
const canReadFields = useDocumentRBAC("InputRenderer", (rbac) => rbac.canReadFields);
|
4727
4966
|
const canUpdateFields = useDocumentRBAC("InputRenderer", (rbac) => rbac.canUpdateFields);
|
4728
4967
|
const canUserAction = useDocumentRBAC("InputRenderer", (rbac) => rbac.canUserAction);
|
4729
|
-
|
4730
|
-
|
4968
|
+
let idToCheck = id;
|
4969
|
+
if (collectionType === SINGLE_TYPES) {
|
4970
|
+
idToCheck = document2?.documentId;
|
4971
|
+
}
|
4972
|
+
const editableFields = idToCheck ? canUpdateFields : canCreateFields;
|
4973
|
+
const readableFields = idToCheck ? canReadFields : canCreateFields;
|
4731
4974
|
const canUserReadField = canUserAction(props.name, readableFields, props.type);
|
4732
4975
|
const canUserEditField = canUserAction(props.name, editableFields, props.type);
|
4733
4976
|
const fields = useStrapiApp("InputRenderer", (app) => app.fields);
|
@@ -4738,6 +4981,7 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
|
|
4738
4981
|
const {
|
4739
4982
|
edit: { components }
|
4740
4983
|
} = useDocLayout();
|
4984
|
+
const field = useField(props.name);
|
4741
4985
|
if (!visible) {
|
4742
4986
|
return null;
|
4743
4987
|
}
|
@@ -4748,7 +4992,7 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
|
|
4748
4992
|
if (attributeHasCustomFieldProperty(props.attribute)) {
|
4749
4993
|
const CustomInput = lazyComponentStore[props.attribute.customField];
|
4750
4994
|
if (CustomInput) {
|
4751
|
-
return /* @__PURE__ */ jsx(CustomInput, { ...props, hint, disabled: fieldIsDisabled });
|
4995
|
+
return /* @__PURE__ */ jsx(CustomInput, { ...props, ...field, hint, disabled: fieldIsDisabled });
|
4752
4996
|
}
|
4753
4997
|
return /* @__PURE__ */ jsx(
|
4754
4998
|
InputRenderer$1,
|
@@ -4767,10 +5011,10 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
|
|
4767
5011
|
}
|
4768
5012
|
switch (props.type) {
|
4769
5013
|
case "blocks":
|
4770
|
-
return /* @__PURE__ */ jsx(
|
5014
|
+
return /* @__PURE__ */ jsx(MemoizedBlocksInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
|
4771
5015
|
case "component":
|
4772
5016
|
return /* @__PURE__ */ jsx(
|
4773
|
-
|
5017
|
+
MemoizedComponentInput,
|
4774
5018
|
{
|
4775
5019
|
...props,
|
4776
5020
|
hint,
|
@@ -4782,11 +5026,11 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
|
|
4782
5026
|
case "dynamiczone":
|
4783
5027
|
return /* @__PURE__ */ jsx(DynamicZone, { ...props, hint, disabled: fieldIsDisabled });
|
4784
5028
|
case "relation":
|
4785
|
-
return /* @__PURE__ */ jsx(
|
5029
|
+
return /* @__PURE__ */ jsx(MemoizedRelationsField, { ...props, hint, disabled: fieldIsDisabled });
|
4786
5030
|
case "richtext":
|
4787
|
-
return /* @__PURE__ */ jsx(
|
5031
|
+
return /* @__PURE__ */ jsx(MemoizedWysiwyg, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
|
4788
5032
|
case "uid":
|
4789
|
-
return /* @__PURE__ */ jsx(
|
5033
|
+
return /* @__PURE__ */ jsx(MemoizedUIDInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
|
4790
5034
|
case "enumeration":
|
4791
5035
|
return /* @__PURE__ */ jsx(
|
4792
5036
|
InputRenderer$1,
|
@@ -4818,7 +5062,9 @@ const useFieldHint = (hint = void 0, attribute) => {
|
|
4818
5062
|
if (!maximum && !minimum) {
|
4819
5063
|
return hint;
|
4820
5064
|
}
|
4821
|
-
const units = !["biginteger", "integer", "number"].includes(
|
5065
|
+
const units = !["biginteger", "integer", "number", "dynamiczone", "component"].includes(
|
5066
|
+
attribute.type
|
5067
|
+
) ? formatMessage(
|
4822
5068
|
{
|
4823
5069
|
id: "content-manager.form.Input.hint.character.unit",
|
4824
5070
|
defaultMessage: "{maxValue, plural, one { character} other { characters}}"
|
@@ -4858,6 +5104,7 @@ const getMinMax = (attribute) => {
|
|
4858
5104
|
return { maximum: void 0, minimum: void 0 };
|
4859
5105
|
}
|
4860
5106
|
};
|
5107
|
+
const MemoizedInputRenderer = memo(InputRenderer);
|
4861
5108
|
const DynamicComponent = ({
|
4862
5109
|
componentUid,
|
4863
5110
|
disabled,
|
@@ -4871,7 +5118,6 @@ const DynamicComponent = ({
|
|
4871
5118
|
dynamicComponentsByCategory = {},
|
4872
5119
|
onAddComponent
|
4873
5120
|
}) => {
|
4874
|
-
const [isOpen, setIsOpen] = React.useState(true);
|
4875
5121
|
const { formatMessage } = useIntl();
|
4876
5122
|
const formValues = useForm("DynamicComponent", (state) => state.values);
|
4877
5123
|
const {
|
@@ -4880,7 +5126,7 @@ const DynamicComponent = ({
|
|
4880
5126
|
const title = React.useMemo(() => {
|
4881
5127
|
const { mainField } = components[componentUid]?.settings ?? { mainField: "id" };
|
4882
5128
|
const mainFieldValue = getIn(formValues, `${name2}.${index}.${mainField}`);
|
4883
|
-
const displayedValue = mainField === "id" ? "" : String(mainFieldValue).trim();
|
5129
|
+
const displayedValue = mainField === "id" || !mainFieldValue ? "" : String(mainFieldValue).trim();
|
4884
5130
|
const mainValue = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;
|
4885
5131
|
return mainValue;
|
4886
5132
|
}, [componentUid, components, formValues, name2, index]);
|
@@ -4891,9 +5137,6 @@ const DynamicComponent = ({
|
|
4891
5137
|
) ?? { icon: null, displayName: null };
|
4892
5138
|
return { icon: icon2, displayName: displayName2 };
|
4893
5139
|
}, [componentUid, dynamicComponentsByCategory]);
|
4894
|
-
const handleToggle = () => {
|
4895
|
-
setIsOpen((s) => !s);
|
4896
|
-
};
|
4897
5140
|
const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop(!disabled, {
|
4898
5141
|
type: `${ItemTypes.DYNAMIC_ZONE}_${name2}`,
|
4899
5142
|
index,
|
@@ -4910,12 +5153,20 @@ const DynamicComponent = ({
|
|
4910
5153
|
React.useEffect(() => {
|
4911
5154
|
dragPreviewRef(getEmptyImage(), { captureDraggingState: false });
|
4912
5155
|
}, [dragPreviewRef, index]);
|
5156
|
+
const accordionValue = React.useId();
|
5157
|
+
const { value = [], rawError } = useField(`${name2}.${index}`);
|
5158
|
+
const [collapseToOpen, setCollapseToOpen] = React.useState("");
|
5159
|
+
React.useEffect(() => {
|
5160
|
+
if (rawError && value) {
|
5161
|
+
setCollapseToOpen(accordionValue);
|
5162
|
+
}
|
5163
|
+
}, [rawError, value, accordionValue]);
|
4913
5164
|
const composedBoxRefs = useComposedRefs(boxRef, dropRef);
|
4914
|
-
const accordionActions = disabled ? null : /* @__PURE__ */ jsxs(
|
5165
|
+
const accordionActions = disabled ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
|
4915
5166
|
/* @__PURE__ */ jsx(
|
4916
|
-
|
5167
|
+
IconButton,
|
4917
5168
|
{
|
4918
|
-
|
5169
|
+
variant: "ghost",
|
4919
5170
|
label: formatMessage(
|
4920
5171
|
{
|
4921
5172
|
id: getTranslation("components.DynamicZone.delete-label"),
|
@@ -4930,10 +5181,7 @@ const DynamicComponent = ({
|
|
4930
5181
|
/* @__PURE__ */ jsx(
|
4931
5182
|
IconButton,
|
4932
5183
|
{
|
4933
|
-
|
4934
|
-
role: "button",
|
4935
|
-
borderWidth: 0,
|
4936
|
-
tabIndex: 0,
|
5184
|
+
variant: "ghost",
|
4937
5185
|
onClick: (e) => e.stopPropagation(),
|
4938
5186
|
"data-handler-id": handlerId,
|
4939
5187
|
ref: dragRef,
|
@@ -4948,7 +5196,7 @@ const DynamicComponent = ({
|
|
4948
5196
|
/* @__PURE__ */ jsxs(Menu.Root, { children: [
|
4949
5197
|
/* @__PURE__ */ jsxs(Menu.Trigger, { size: "S", endIcon: null, paddingLeft: 2, paddingRight: 2, children: [
|
4950
5198
|
/* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false }),
|
4951
|
-
/* @__PURE__ */ jsx(VisuallyHidden, {
|
5199
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { tag: "span", children: formatMessage({
|
4952
5200
|
id: getTranslation("components.DynamicZone.more-actions"),
|
4953
5201
|
defaultMessage: "More actions"
|
4954
5202
|
}) })
|
@@ -4977,42 +5225,56 @@ const DynamicComponent = ({
|
|
4977
5225
|
] })
|
4978
5226
|
] })
|
4979
5227
|
] });
|
4980
|
-
|
5228
|
+
const accordionTitle = title ? `${displayName} ${title}` : displayName;
|
5229
|
+
return /* @__PURE__ */ jsxs(ComponentContainer, { tag: "li", width: "100%", children: [
|
4981
5230
|
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Rectangle, { background: "neutral200" }) }),
|
4982
|
-
/* @__PURE__ */ jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsx(Preview, {}) : /* @__PURE__ */
|
4983
|
-
/* @__PURE__ */
|
4984
|
-
|
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
|
+
/* @__PURE__ */ jsx(
|
5234
|
+
Accordion.Trigger,
|
5235
|
+
{
|
5236
|
+
icon: icon && COMPONENT_ICONS[icon] ? COMPONENT_ICONS[icon] : COMPONENT_ICONS.dashboard,
|
5237
|
+
children: accordionTitle
|
5238
|
+
}
|
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,
|
4985
5244
|
{
|
4986
|
-
|
4987
|
-
|
4988
|
-
|
4989
|
-
|
4990
|
-
|
4991
|
-
|
4992
|
-
|
4993
|
-
|
4994
|
-
|
4995
|
-
|
4996
|
-
|
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
|
+
] }) }) })
|
4997
5276
|
] });
|
4998
5277
|
};
|
4999
|
-
const ActionsFlex = styled(Flex)`
|
5000
|
-
/*
|
5001
|
-
we need to remove the background from the button but we can't
|
5002
|
-
wrap the element in styled because it breaks the forwardedAs which
|
5003
|
-
we need for drag handler to work on firefox
|
5004
|
-
*/
|
5005
|
-
div[role='button'] {
|
5006
|
-
background: transparent;
|
5007
|
-
}
|
5008
|
-
`;
|
5009
|
-
const IconButtonCustom = styled(IconButton)`
|
5010
|
-
background-color: transparent;
|
5011
|
-
|
5012
|
-
svg path {
|
5013
|
-
fill: ${({ theme, expanded }) => expanded ? theme.colors.primary600 : theme.colors.neutral600};
|
5014
|
-
}
|
5015
|
-
`;
|
5016
5278
|
const StyledBox = styled(Box)`
|
5017
5279
|
> div:first-child {
|
5018
5280
|
box-shadow: ${({ theme }) => theme.shadows.tableShadow};
|
@@ -5083,7 +5345,7 @@ const [DynamicZoneProvider, useDynamicZone] = createContext(
|
|
5083
5345
|
);
|
5084
5346
|
const DynamicZone = ({
|
5085
5347
|
attribute,
|
5086
|
-
disabled,
|
5348
|
+
disabled: disabledProp,
|
5087
5349
|
hint,
|
5088
5350
|
label,
|
5089
5351
|
labelAction,
|
@@ -5093,7 +5355,8 @@ const DynamicZone = ({
|
|
5093
5355
|
const { max = Infinity, min = -Infinity } = attribute ?? {};
|
5094
5356
|
const [addComponentIsOpen, setAddComponentIsOpen] = React.useState(false);
|
5095
5357
|
const [liveText, setLiveText] = React.useState("");
|
5096
|
-
const { components } = useDoc();
|
5358
|
+
const { components, isLoading } = useDoc();
|
5359
|
+
const disabled = disabledProp || isLoading;
|
5097
5360
|
const { addFieldRow, removeFieldRow, moveFieldRow } = useForm(
|
5098
5361
|
"DynamicZone",
|
5099
5362
|
({ addFieldRow: addFieldRow2, removeFieldRow: removeFieldRow2, moveFieldRow: moveFieldRow2 }) => ({
|
@@ -5200,7 +5463,7 @@ const DynamicZone = ({
|
|
5200
5463
|
const handleRemoveComponent = (name22, currentIndex) => () => {
|
5201
5464
|
removeFieldRow(name22, currentIndex);
|
5202
5465
|
};
|
5203
|
-
const hasError = error !== void 0
|
5466
|
+
const hasError = error !== void 0;
|
5204
5467
|
const renderButtonLabel = () => {
|
5205
5468
|
if (addComponentIsOpen) {
|
5206
5469
|
return formatMessage({ id: "app.utils.close-label", defaultMessage: "Close" });
|
@@ -5301,19 +5564,19 @@ const DynamicZone = ({
|
|
5301
5564
|
] }) });
|
5302
5565
|
};
|
5303
5566
|
export {
|
5304
|
-
BlocksInput as B,
|
5305
|
-
ComponentInput as C,
|
5306
5567
|
DynamicZone as D,
|
5307
|
-
|
5568
|
+
MemoizedInputRenderer as M,
|
5308
5569
|
NotAllowedInput as N,
|
5309
|
-
UIDInput as U,
|
5310
|
-
Wysiwyg as W,
|
5311
5570
|
useDynamicZone as a,
|
5312
5571
|
useFieldHint as b,
|
5313
5572
|
createDefaultForm as c,
|
5573
|
+
MemoizedUIDInput as d,
|
5574
|
+
MemoizedWysiwyg as e,
|
5575
|
+
MemoizedComponentInput as f,
|
5576
|
+
MemoizedBlocksInput as g,
|
5314
5577
|
prepareTempKeys as p,
|
5315
5578
|
removeFieldsThatDontExistOnSchema as r,
|
5316
5579
|
transformDocument as t,
|
5317
5580
|
useLazyComponents as u
|
5318
5581
|
};
|
5319
|
-
//# sourceMappingURL=Field-
|
5582
|
+
//# sourceMappingURL=Field-Bj_RgtGo.mjs.map
|