@strapi/content-manager 0.0.0-experimental.e60ec1829240dae21c1e1d29076681c322288813 → 0.0.0-experimental.e9122b401c96877b6707775c4f893660eab93ae3
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-CpBFh6_r.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-BPvzFjM7.mjs.map → ComponentConfigurationPage-CpBFh6_r.mjs.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-DjWJdz6Y.js → ComponentConfigurationPage-_zF8p6CY.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-DjWJdz6Y.js.map → ComponentConfigurationPage-_zF8p6CY.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-DacbqQ_f.mjs → EditConfigurationPage-CE_yavTi.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-DacbqQ_f.mjs.map → EditConfigurationPage-CE_yavTi.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-Dmv83RlS.js → EditConfigurationPage-_aG2DJSU.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-Dmv83RlS.js.map → EditConfigurationPage-_aG2DJSU.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-DDS6H9HO.mjs → EditViewPage-DeTn7rAF.mjs} +59 -48
- package/dist/_chunks/EditViewPage-DeTn7rAF.mjs.map +1 -0
- package/dist/_chunks/{EditViewPage-DvNpQkam.js → EditViewPage-G9uNzwYL.js} +58 -49
- package/dist/_chunks/EditViewPage-G9uNzwYL.js.map +1 -0
- package/dist/_chunks/{Field-6gvGdPBV.mjs → Field-CnCKhI1R.mjs} +995 -795
- package/dist/_chunks/Field-CnCKhI1R.mjs.map +1 -0
- package/dist/_chunks/{Field-DmVKIAOo.js → Field-DDHUWEfV.js} +1041 -842
- package/dist/_chunks/Field-DDHUWEfV.js.map +1 -0
- package/dist/_chunks/{Form-CPZC9vWa.js → Form-DYETaKUX.js} +65 -45
- package/dist/_chunks/Form-DYETaKUX.js.map +1 -0
- package/dist/_chunks/{Form-DW6K1IH-.mjs → Form-IvVVwqRL.mjs} +65 -44
- package/dist/_chunks/Form-IvVVwqRL.mjs.map +1 -0
- package/dist/_chunks/{History-Dmr9fmUA.mjs → History-BMunT-do.mjs} +148 -54
- package/dist/_chunks/History-BMunT-do.mjs.map +1 -0
- package/dist/_chunks/{History-DeAPlvtv.js → History-CnZDctSO.js} +149 -56
- package/dist/_chunks/History-CnZDctSO.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DPCwW5Vr.js → ListConfigurationPage-BynalOp8.js} +67 -58
- package/dist/_chunks/ListConfigurationPage-BynalOp8.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-DhwvYcNv.mjs → ListConfigurationPage-CDqkCxgV.mjs} +63 -53
- package/dist/_chunks/ListConfigurationPage-CDqkCxgV.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-5ySZ-VUs.js → ListViewPage-I88Ouzoq.js} +126 -137
- package/dist/_chunks/ListViewPage-I88Ouzoq.js.map +1 -0
- package/dist/_chunks/{ListViewPage-BtAwuYLE.mjs → ListViewPage-_5gS-DOF.mjs} +123 -134
- package/dist/_chunks/ListViewPage-_5gS-DOF.mjs.map +1 -0
- package/dist/_chunks/{NoContentTypePage-DOC_yWOf.js → NoContentTypePage-BaWQ7HsA.js} +3 -3
- package/dist/_chunks/NoContentTypePage-BaWQ7HsA.js.map +1 -0
- package/dist/_chunks/{NoContentTypePage-DSPxnxxp.mjs → NoContentTypePage-Dht-55hr.mjs} +3 -3
- package/dist/_chunks/NoContentTypePage-Dht-55hr.mjs.map +1 -0
- package/dist/_chunks/{NoPermissionsPage-UWDC-1Tw.mjs → NoPermissionsPage-Bs8D5W_v.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-UWDC-1Tw.mjs.map → NoPermissionsPage-Bs8D5W_v.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-Dwu8rRJu.js → NoPermissionsPage-DCVUh5at.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-Dwu8rRJu.js.map → NoPermissionsPage-DCVUh5at.js.map} +1 -1
- package/dist/_chunks/{Relations-CgWtgnPe.js → Relations-BPgFQeGj.js} +71 -62
- package/dist/_chunks/Relations-BPgFQeGj.js.map +1 -0
- package/dist/_chunks/{Relations-J8cscLlR.mjs → Relations-Chdt5qWc.mjs} +67 -57
- package/dist/_chunks/Relations-Chdt5qWc.mjs.map +1 -0
- package/dist/_chunks/{en-C-V1_90f.js → en-BVzUkPxZ.js} +16 -8
- package/dist/_chunks/{en-C-V1_90f.js.map → en-BVzUkPxZ.js.map} +1 -1
- package/dist/_chunks/{en-MBPul9Su.mjs → en-CPTj6CjC.mjs} +16 -8
- package/dist/_chunks/{en-MBPul9Su.mjs.map → en-CPTj6CjC.mjs.map} +1 -1
- package/dist/_chunks/{index-C6AH2hEl.js → index-BhbLFX4l.js} +1752 -903
- package/dist/_chunks/index-BhbLFX4l.js.map +1 -0
- package/dist/_chunks/{index-CwRRo1V9.mjs → index-D4UGPFZC.mjs} +1778 -928
- package/dist/_chunks/index-D4UGPFZC.mjs.map +1 -0
- package/dist/_chunks/{layout-B_SXLhqf.js → layout-CYA7s0qO.js} +45 -29
- package/dist/_chunks/layout-CYA7s0qO.js.map +1 -0
- package/dist/_chunks/{layout-jIDzX0Fp.mjs → layout-D4HI4_PS.mjs} +45 -27
- package/dist/_chunks/layout-D4HI4_PS.mjs.map +1 -0
- package/dist/_chunks/{relations-CuvIgCqI.mjs → relations-1pXaYpBK.mjs} +2 -2
- package/dist/_chunks/{relations-CuvIgCqI.mjs.map → relations-1pXaYpBK.mjs.map} +1 -1
- package/dist/_chunks/{relations-iBMa_OFG.js → relations-DDZ9OxNo.js} +2 -2
- package/dist/_chunks/{relations-iBMa_OFG.js.map → relations-DDZ9OxNo.js.map} +1 -1
- 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 +2 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +8 -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 +1 -0
- 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 +5 -8
- 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/components/DocumentActions.d.ts +11 -4
- 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 +10 -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/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 -17
- 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 +436 -281
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +444 -289
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/controllers/collection-types.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 +8 -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 +2 -1
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +18 -39
- 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/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 +8 -29
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +18 -39
- 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/populate.d.ts +8 -1
- package/dist/server/src/services/utils/populate.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/relations.d.ts +2 -2
- package/dist/shared/contracts/relations.d.ts.map +1 -1
- package/package.json +14 -15
- 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.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/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
@@ -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, o as useDocLayout } from "./index-D4UGPFZC.mjs";
|
9
9
|
import { generateNKeysBetween } from "fractional-indexing";
|
10
|
-
import { u as useComponent, C as ComponentProvider,
|
10
|
+
import { u as useComponent, C as ComponentProvider, M as MemoizedRelationsField } from "./Relations-Chdt5qWc.mjs";
|
11
11
|
import { Code, HeadingOne, HeadingTwo, HeadingThree, HeadingFour, HeadingFive, HeadingSix, Image as Image$1, NumberList, BulletList, Paragraph, Quotes, Link as Link$1, Drag, Collapse, Bold, Italic, Underline, StrikeThrough, Expand, PlusCircle, Plus, Trash, EyeStriked, CheckCircle, WarningCircle, Loader, ArrowClockwise, More } from "@strapi/icons";
|
12
|
-
import styled,
|
13
|
-
import { C as ComponentIcon } from "./ComponentIcon-
|
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
16
|
import { g as getIn } from "./objects-mKMAmfec.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,9 +453,61 @@ 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(
|
510
|
+
renderElement: (props) => /* @__PURE__ */ jsx(CodeEditor, { ...props }),
|
244
511
|
icon: Code,
|
245
512
|
label: {
|
246
513
|
id: "components.Blocks.blocks.code",
|
@@ -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,30 +2620,27 @@ 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
|
-
field.error && /* @__PURE__ */ jsx(Typography, { textColor: "danger600", variant: "pi", children: field.error })
|
2333
|
-
] });
|
2623
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
2624
|
+
Box,
|
2625
|
+
{
|
2626
|
+
tag: "button",
|
2627
|
+
background: "neutral100",
|
2628
|
+
borderColor: field.error ? "danger600" : "neutral200",
|
2629
|
+
hasRadius: true,
|
2630
|
+
disabled,
|
2631
|
+
onClick,
|
2632
|
+
paddingTop: 9,
|
2633
|
+
paddingBottom: 9,
|
2634
|
+
type: "button",
|
2635
|
+
children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
|
2636
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(CircleIcon, {}) }),
|
2637
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Typography, { textColor: "primary600", variant: "pi", fontWeight: "bold", children: formatMessage({
|
2638
|
+
id: getTranslation("components.empty-repeatable"),
|
2639
|
+
defaultMessage: "No entry yet. Click on the button below to add one."
|
2640
|
+
}) }) })
|
2641
|
+
] })
|
2642
|
+
}
|
2643
|
+
) });
|
2334
2644
|
};
|
2335
2645
|
const CircleIcon = styled(PlusCircle)`
|
2336
2646
|
width: 2.4rem;
|
@@ -2362,9 +2672,20 @@ 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
|
-
return /* @__PURE__ */ jsx(
|
2677
|
+
return /* @__PURE__ */ jsx(
|
2678
|
+
Grid$1.Item,
|
2679
|
+
{
|
2680
|
+
col: size,
|
2681
|
+
s: 12,
|
2682
|
+
xs: 12,
|
2683
|
+
direction: "column",
|
2684
|
+
alignItems: "stretch",
|
2685
|
+
children: children({ ...field, name: completeFieldName })
|
2686
|
+
},
|
2687
|
+
completeFieldName
|
2688
|
+
);
|
2368
2689
|
}) }, index);
|
2369
2690
|
}) })
|
2370
2691
|
}
|
@@ -2388,7 +2709,7 @@ const RepeatableComponent = ({
|
|
2388
2709
|
const moveFieldRow = useForm("RepeatableComponent", (state) => state.moveFieldRow);
|
2389
2710
|
const removeFieldRow = useForm("RepeatableComponent", (state) => state.removeFieldRow);
|
2390
2711
|
const { max = Infinity } = attribute;
|
2391
|
-
const [collapseToOpen, setCollapseToOpen] = React.useState(
|
2712
|
+
const [collapseToOpen, setCollapseToOpen] = React.useState("");
|
2392
2713
|
const [liveText, setLiveText] = React.useState("");
|
2393
2714
|
const componentTmpKeyWithFocussedField = React.useMemo(() => {
|
2394
2715
|
if (search.has("field")) {
|
@@ -2404,13 +2725,19 @@ const RepeatableComponent = ({
|
|
2404
2725
|
}
|
2405
2726
|
return void 0;
|
2406
2727
|
}, [search, name2, value]);
|
2728
|
+
const prevValue = usePrev(value);
|
2407
2729
|
React.useEffect(() => {
|
2408
|
-
if (
|
2730
|
+
if (prevValue && prevValue.length < value.length) {
|
2731
|
+
setCollapseToOpen(value[value.length - 1].__temp_key__);
|
2732
|
+
}
|
2733
|
+
}, [value, prevValue]);
|
2734
|
+
React.useEffect(() => {
|
2735
|
+
if (typeof componentTmpKeyWithFocussedField === "string") {
|
2409
2736
|
setCollapseToOpen(componentTmpKeyWithFocussedField);
|
2410
2737
|
}
|
2411
2738
|
}, [componentTmpKeyWithFocussedField]);
|
2412
2739
|
const toggleCollapses = () => {
|
2413
|
-
setCollapseToOpen(
|
2740
|
+
setCollapseToOpen("");
|
2414
2741
|
};
|
2415
2742
|
const handleClick = () => {
|
2416
2743
|
if (value.length < max) {
|
@@ -2442,12 +2769,8 @@ const RepeatableComponent = ({
|
|
2442
2769
|
);
|
2443
2770
|
moveFieldRow(name2, currentIndex, newIndex);
|
2444
2771
|
};
|
2445
|
-
const
|
2446
|
-
|
2447
|
-
setCollapseToOpen(null);
|
2448
|
-
} else {
|
2449
|
-
setCollapseToOpen(key);
|
2450
|
-
}
|
2772
|
+
const handleValueChange = (key) => {
|
2773
|
+
setCollapseToOpen(key);
|
2451
2774
|
};
|
2452
2775
|
const getItemPos = (index) => `${index + 1} of ${value.length}`;
|
2453
2776
|
const handleCancel = (index) => {
|
@@ -2502,158 +2825,115 @@ const RepeatableComponent = ({
|
|
2502
2825
|
defaultMessage: `Press spacebar to grab and re-order`
|
2503
2826
|
}) }),
|
2504
2827
|
/* @__PURE__ */ jsx(VisuallyHidden, { "aria-live": "assertive", children: liveText }),
|
2505
|
-
/* @__PURE__ */ jsxs(
|
2506
|
-
|
2507
|
-
|
2508
|
-
|
2509
|
-
|
2510
|
-
|
2511
|
-
|
2512
|
-
|
2513
|
-
|
2514
|
-
|
2515
|
-
|
2516
|
-
|
2828
|
+
/* @__PURE__ */ jsxs(
|
2829
|
+
AccordionRoot,
|
2830
|
+
{
|
2831
|
+
$error: error,
|
2832
|
+
value: collapseToOpen,
|
2833
|
+
onValueChange: handleValueChange,
|
2834
|
+
"aria-describedby": ariaDescriptionId,
|
2835
|
+
children: [
|
2836
|
+
value.map(({ __temp_key__: key, id }, index) => {
|
2837
|
+
const nameWithIndex = `${name2}.${index}`;
|
2838
|
+
return /* @__PURE__ */ jsx(
|
2839
|
+
ComponentProvider,
|
2517
2840
|
{
|
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
|
-
|
2841
|
+
id,
|
2842
|
+
uid: attribute.component,
|
2843
|
+
level: level + 1,
|
2844
|
+
type: "repeatable",
|
2845
|
+
children: /* @__PURE__ */ jsx(
|
2846
|
+
Component,
|
2847
|
+
{
|
2848
|
+
disabled,
|
2849
|
+
name: nameWithIndex,
|
2850
|
+
attribute,
|
2851
|
+
index,
|
2852
|
+
mainField,
|
2853
|
+
onMoveItem: handleMoveComponentField,
|
2854
|
+
onDeleteComponent: () => {
|
2855
|
+
removeFieldRow(name2, index);
|
2856
|
+
toggleCollapses();
|
2857
|
+
},
|
2858
|
+
toggleCollapses,
|
2859
|
+
onCancel: handleCancel,
|
2860
|
+
onDropItem: handleDropItem,
|
2861
|
+
onGrabItem: handleGrabItem,
|
2862
|
+
__temp_key__: key,
|
2863
|
+
children: layout.map((row, index2) => {
|
2864
|
+
return /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: row.map(({ size, ...field }) => {
|
2865
|
+
const completeFieldName = `${nameWithIndex}.${field.name}`;
|
2866
|
+
return /* @__PURE__ */ jsx(
|
2867
|
+
Grid$1.Item,
|
2868
|
+
{
|
2869
|
+
col: size,
|
2870
|
+
s: 12,
|
2871
|
+
xs: 12,
|
2872
|
+
direction: "column",
|
2873
|
+
alignItems: "stretch",
|
2874
|
+
children: children({ ...field, name: completeFieldName })
|
2875
|
+
},
|
2876
|
+
completeFieldName
|
2877
|
+
);
|
2878
|
+
}) }, index2);
|
2879
|
+
})
|
2880
|
+
}
|
2881
|
+
)
|
2882
|
+
},
|
2883
|
+
key
|
2884
|
+
);
|
2885
|
+
}),
|
2886
|
+
/* @__PURE__ */ jsx(TextButtonCustom, { disabled, onClick: handleClick, startIcon: /* @__PURE__ */ jsx(Plus, {}), children: formatMessage({
|
2887
|
+
id: getTranslation("containers.EditView.add.new-entry"),
|
2888
|
+
defaultMessage: "Add an entry"
|
2889
|
+
}) })
|
2890
|
+
]
|
2891
|
+
}
|
2892
|
+
)
|
2551
2893
|
] });
|
2552
2894
|
};
|
2895
|
+
const AccordionRoot = styled(Accordion.Root)`
|
2896
|
+
border: 1px solid
|
2897
|
+
${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
|
2898
|
+
`;
|
2553
2899
|
const TextButtonCustom = styled(TextButton)`
|
2554
|
-
height: 100%;
|
2555
2900
|
width: 100%;
|
2556
|
-
border-radius: 0 0 4px 4px;
|
2557
2901
|
display: flex;
|
2558
2902
|
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
|
-
}
|
2579
|
-
|
2580
|
-
/* the top accordion _does_ need a border though */
|
2581
|
-
& > div:first-child > div {
|
2582
|
-
border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
|
2583
|
-
}
|
2584
|
-
|
2585
|
-
/* Reset all the border-radius' */
|
2586
|
-
& > div > div,
|
2587
|
-
& > div > div > div {
|
2588
|
-
border-radius: unset;
|
2589
|
-
}
|
2903
|
+
border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
|
2904
|
+
padding-inline: ${(props) => props.theme.spaces[6]};
|
2905
|
+
padding-block: ${(props) => props.theme.spaces[3]};
|
2590
2906
|
|
2591
|
-
|
2592
|
-
|
2593
|
-
& > div:first-child > div > div {
|
2594
|
-
border-radius: ${({ theme }) => theme.borderRadius} ${({ theme }) => theme.borderRadius} 0 0;
|
2595
|
-
}
|
2907
|
+
&:not([disabled]) {
|
2908
|
+
cursor: pointer;
|
2596
2909
|
|
2597
|
-
|
2598
|
-
|
2910
|
+
&:hover {
|
2911
|
+
background-color: ${(props) => props.theme.colors.primary100};
|
2912
|
+
}
|
2599
2913
|
}
|
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
2914
|
|
2610
|
-
|
2611
|
-
|
2612
|
-
|
2613
|
-
|
2915
|
+
span {
|
2916
|
+
font-weight: 600;
|
2917
|
+
font-size: 1.4rem;
|
2918
|
+
line-height: 2.4rem;
|
2614
2919
|
}
|
2615
2920
|
|
2616
|
-
|
2617
|
-
|
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
|
-
}
|
2921
|
+
@media (prefers-reduced-motion: no-preference) {
|
2922
|
+
transition: background-color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
|
2642
2923
|
}
|
2643
2924
|
`;
|
2644
2925
|
const Component = ({
|
2645
2926
|
disabled,
|
2646
2927
|
index,
|
2647
|
-
isOpen,
|
2648
2928
|
name: name2,
|
2649
2929
|
mainField = {
|
2650
2930
|
name: "id",
|
2651
2931
|
type: "integer"
|
2652
2932
|
},
|
2653
2933
|
children,
|
2654
|
-
onClickToggle,
|
2655
2934
|
onDeleteComponent,
|
2656
2935
|
toggleCollapses,
|
2936
|
+
__temp_key__,
|
2657
2937
|
...dragProps
|
2658
2938
|
}) => {
|
2659
2939
|
const { formatMessage } = useIntl();
|
@@ -2678,50 +2958,44 @@ const Component = ({
|
|
2678
2958
|
dragPreviewRef(getEmptyImage(), { captureDraggingState: false });
|
2679
2959
|
}, [dragPreviewRef, index]);
|
2680
2960
|
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(
|
2961
|
+
const composedBoxRefs = useComposedRefs(
|
2962
|
+
boxRef,
|
2963
|
+
dropRef
|
2964
|
+
);
|
2965
|
+
return /* @__PURE__ */ jsx(Fragment, { children: isDragging ? /* @__PURE__ */ jsx(Preview$1, {}) : /* @__PURE__ */ jsxs(Accordion.Item, { ref: composedBoxRefs, value: __temp_key__, children: [
|
2966
|
+
/* @__PURE__ */ jsxs(Accordion.Header, { children: [
|
2967
|
+
/* @__PURE__ */ jsx(Accordion.Trigger, { children: displayValue }),
|
2968
|
+
/* @__PURE__ */ jsxs(Accordion.Actions, { children: [
|
2969
|
+
/* @__PURE__ */ jsx(
|
2970
|
+
IconButton,
|
2971
|
+
{
|
2972
|
+
variant: "ghost",
|
2973
|
+
onClick: onDeleteComponent,
|
2974
|
+
label: formatMessage({
|
2975
|
+
id: getTranslation("containers.Edit.delete"),
|
2976
|
+
defaultMessage: "Delete"
|
2977
|
+
}),
|
2978
|
+
children: /* @__PURE__ */ jsx(Trash, {})
|
2979
|
+
}
|
2980
|
+
),
|
2981
|
+
/* @__PURE__ */ jsx(
|
2982
|
+
IconButton,
|
2983
|
+
{
|
2984
|
+
ref: composedAccordionRefs,
|
2985
|
+
variant: "ghost",
|
2986
|
+
onClick: (e) => e.stopPropagation(),
|
2987
|
+
"data-handler-id": handlerId,
|
2988
|
+
label: formatMessage({
|
2989
|
+
id: getTranslation("components.DragHandle-label"),
|
2990
|
+
defaultMessage: "Drag"
|
2991
|
+
}),
|
2992
|
+
onKeyDown: handleKeyDown,
|
2993
|
+
children: /* @__PURE__ */ jsx(Drag, {})
|
2994
|
+
}
|
2995
|
+
)
|
2996
|
+
] })
|
2997
|
+
] }),
|
2998
|
+
/* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(
|
2725
2999
|
Flex,
|
2726
3000
|
{
|
2727
3001
|
direction: "column",
|
@@ -2735,7 +3009,7 @@ const Component = ({
|
|
2735
3009
|
] }) });
|
2736
3010
|
};
|
2737
3011
|
const Preview$1 = () => {
|
2738
|
-
return /* @__PURE__ */ jsx(StyledSpan, {
|
3012
|
+
return /* @__PURE__ */ jsx(StyledSpan, { tag: "span", padding: 6, background: "primary100" });
|
2739
3013
|
};
|
2740
3014
|
const StyledSpan = styled(Box)`
|
2741
3015
|
display: block;
|
@@ -2761,29 +3035,15 @@ const ComponentInput = ({
|
|
2761
3035
|
const data = transformDocument(schema, components)(form);
|
2762
3036
|
field.onChange(name2, data);
|
2763
3037
|
};
|
2764
|
-
return /* @__PURE__ */ jsxs(
|
3038
|
+
return /* @__PURE__ */ jsxs(Field.Root, { error: field.error, required, children: [
|
2765
3039
|
/* @__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 })
|
3040
|
+
/* @__PURE__ */ jsxs(Field.Label, { action: labelAction, children: [
|
3041
|
+
label,
|
3042
|
+
attribute.repeatable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
3043
|
+
" (",
|
3044
|
+
Array.isArray(field.value) ? field.value.length : 0,
|
3045
|
+
")"
|
3046
|
+
] })
|
2787
3047
|
] }),
|
2788
3048
|
showResetComponent && /* @__PURE__ */ jsx(
|
2789
3049
|
IconButton,
|
@@ -2792,21 +3052,21 @@ const ComponentInput = ({
|
|
2792
3052
|
id: getTranslation("components.reset-entry"),
|
2793
3053
|
defaultMessage: "Reset Entry"
|
2794
3054
|
}),
|
2795
|
-
|
2796
|
-
borderWidth: 0,
|
3055
|
+
variant: "ghost",
|
2797
3056
|
onClick: () => {
|
2798
3057
|
field.onChange(name2, null);
|
2799
|
-
}
|
3058
|
+
},
|
3059
|
+
children: /* @__PURE__ */ jsx(Trash, {})
|
2800
3060
|
}
|
2801
3061
|
)
|
2802
3062
|
] }),
|
2803
|
-
/* @__PURE__ */
|
2804
|
-
|
2805
|
-
|
2806
|
-
|
2807
|
-
] })
|
3063
|
+
!attribute.repeatable && !field.value && /* @__PURE__ */ jsx(Initializer, { disabled, name: name2, onClick: handleInitialisationClick }),
|
3064
|
+
!attribute.repeatable && field.value ? /* @__PURE__ */ jsx(NonRepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }) : null,
|
3065
|
+
attribute.repeatable && /* @__PURE__ */ jsx(RepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }),
|
3066
|
+
/* @__PURE__ */ jsx(Field.Error, {})
|
2808
3067
|
] });
|
2809
3068
|
};
|
3069
|
+
const MemoizedComponentInput = React.memo(ComponentInput);
|
2810
3070
|
const AddComponentButton = ({
|
2811
3071
|
hasError,
|
2812
3072
|
isDisabled,
|
@@ -2821,15 +3081,12 @@ const AddComponentButton = ({
|
|
2821
3081
|
onClick,
|
2822
3082
|
disabled: isDisabled,
|
2823
3083
|
background: "neutral0",
|
2824
|
-
paddingTop: 3,
|
2825
|
-
paddingBottom: 3,
|
2826
|
-
paddingLeft: 4,
|
2827
|
-
paddingRight: 4,
|
2828
3084
|
style: { cursor: isDisabled ? "not-allowed" : "pointer" },
|
2829
|
-
|
3085
|
+
variant: "tertiary",
|
3086
|
+
children: /* @__PURE__ */ jsxs(Flex, { tag: "span", gap: 2, children: [
|
2830
3087
|
/* @__PURE__ */ jsx(StyledAddIcon, { "aria-hidden": true, $isOpen: isOpen, $hasError: hasError && !isOpen }),
|
2831
3088
|
/* @__PURE__ */ jsx(
|
2832
|
-
|
3089
|
+
AddComponentTitle,
|
2833
3090
|
{
|
2834
3091
|
variant: "pi",
|
2835
3092
|
fontWeight: "bold",
|
@@ -2853,13 +3110,15 @@ const StyledAddIcon = styled(PlusCircle)`
|
|
2853
3110
|
fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral600};
|
2854
3111
|
}
|
2855
3112
|
`;
|
2856
|
-
const
|
3113
|
+
const AddComponentTitle = styled(Typography)``;
|
3114
|
+
const StyledButton = styled(Button)`
|
2857
3115
|
border-radius: 26px;
|
2858
3116
|
border-color: ${({ theme }) => theme.colors.neutral150};
|
2859
3117
|
box-shadow: ${({ theme }) => theme.shadows.filterShadow};
|
3118
|
+
height: 5rem;
|
2860
3119
|
|
2861
3120
|
&:hover {
|
2862
|
-
${
|
3121
|
+
${AddComponentTitle} {
|
2863
3122
|
color: ${({ theme }) => theme.colors.primary600};
|
2864
3123
|
}
|
2865
3124
|
|
@@ -2868,12 +3127,12 @@ const StyledButton = styled(BaseButton)`
|
|
2868
3127
|
fill: ${({ theme }) => theme.colors.primary600};
|
2869
3128
|
}
|
2870
3129
|
> path {
|
2871
|
-
fill: ${({ theme }) => theme.colors.
|
3130
|
+
fill: ${({ theme }) => theme.colors.primary600};
|
2872
3131
|
}
|
2873
3132
|
}
|
2874
3133
|
}
|
2875
3134
|
&:active {
|
2876
|
-
${
|
3135
|
+
${AddComponentTitle} {
|
2877
3136
|
color: ${({ theme }) => theme.colors.primary600};
|
2878
3137
|
}
|
2879
3138
|
${StyledAddIcon} {
|
@@ -2890,27 +3149,15 @@ const ComponentCategory = ({
|
|
2890
3149
|
category,
|
2891
3150
|
components = [],
|
2892
3151
|
variant = "primary",
|
2893
|
-
|
2894
|
-
onAddComponent,
|
2895
|
-
onToggle
|
3152
|
+
onAddComponent
|
2896
3153
|
}) => {
|
2897
3154
|
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(
|
3155
|
+
return /* @__PURE__ */ jsxs(Accordion.Item, { value: category, children: [
|
3156
|
+
/* @__PURE__ */ jsx(Accordion.Header, { variant, children: /* @__PURE__ */ jsx(Accordion.Trigger, { children: formatMessage({ id: category, defaultMessage: category }) }) }),
|
3157
|
+
/* @__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
3158
|
ComponentBox,
|
2912
3159
|
{
|
2913
|
-
|
3160
|
+
tag: "button",
|
2914
3161
|
type: "button",
|
2915
3162
|
background: "neutral100",
|
2916
3163
|
justifyContent: "center",
|
@@ -2920,34 +3167,32 @@ const ComponentCategory = ({
|
|
2920
3167
|
shrink: 0,
|
2921
3168
|
borderColor: "neutral200",
|
2922
3169
|
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",
|
3170
|
+
/* @__PURE__ */ jsx(ComponentIcon, { color: "currentColor", background: "primary200", icon }),
|
3171
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", children: displayName })
|
2925
3172
|
] })
|
2926
3173
|
},
|
2927
3174
|
uid
|
2928
|
-
)) }) })
|
3175
|
+
)) }) })
|
2929
3176
|
] });
|
2930
3177
|
};
|
2931
|
-
const Grid = styled
|
3178
|
+
const Grid = styled(Box)`
|
2932
3179
|
display: grid;
|
2933
3180
|
grid-template-columns: repeat(auto-fit, 14rem);
|
2934
3181
|
grid-gap: ${({ theme }) => theme.spaces[1]};
|
2935
3182
|
`;
|
2936
3183
|
const ComponentBox = styled(Flex)`
|
3184
|
+
color: ${({ theme }) => theme.colors.neutral600};
|
3185
|
+
cursor: pointer;
|
3186
|
+
|
3187
|
+
@media (prefers-reduced-motion: no-preference) {
|
3188
|
+
transition: color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
|
3189
|
+
}
|
3190
|
+
|
2937
3191
|
&:focus,
|
2938
3192
|
&:hover {
|
2939
3193
|
border: 1px solid ${({ theme }) => theme.colors.primary200};
|
2940
3194
|
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
|
-
}
|
3195
|
+
color: ${({ theme }) => theme.colors.primary600};
|
2951
3196
|
}
|
2952
3197
|
`;
|
2953
3198
|
const ComponentPicker = ({
|
@@ -2956,19 +3201,8 @@ const ComponentPicker = ({
|
|
2956
3201
|
onClickAddComponent
|
2957
3202
|
}) => {
|
2958
3203
|
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
3204
|
const handleAddComponentToDz = (componentUid) => () => {
|
2967
3205
|
onClickAddComponent(componentUid);
|
2968
|
-
setCategoryToOpen("");
|
2969
|
-
};
|
2970
|
-
const handleClickToggle = (categoryName) => {
|
2971
|
-
setCategoryToOpen((currentCat) => currentCat === categoryName ? "" : categoryName);
|
2972
3206
|
};
|
2973
3207
|
if (!isOpen) {
|
2974
3208
|
return null;
|
@@ -2989,14 +3223,12 @@ const ComponentPicker = ({
|
|
2989
3223
|
id: getTranslation("components.DynamicZone.ComponentPicker-label"),
|
2990
3224
|
defaultMessage: "Pick one component"
|
2991
3225
|
}) }) }),
|
2992
|
-
/* @__PURE__ */ jsx(Box, { paddingTop: 2, children: /* @__PURE__ */ jsx(
|
3226
|
+
/* @__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
3227
|
ComponentCategory,
|
2994
3228
|
{
|
2995
3229
|
category,
|
2996
3230
|
components,
|
2997
3231
|
onAddComponent: handleAddComponentToDz,
|
2998
|
-
isOpen: category === categoryToOpen,
|
2999
|
-
onToggle: handleClickToggle,
|
3000
3232
|
variant: index % 2 === 1 ? "primary" : "secondary"
|
3001
3233
|
},
|
3002
3234
|
category
|
@@ -3011,39 +3243,21 @@ const NotAllowedInput = ({ hint, label, required, name: name2 }) => {
|
|
3011
3243
|
id: "components.NotAllowedInput.text",
|
3012
3244
|
defaultMessage: "No permissions to see this field"
|
3013
3245
|
});
|
3014
|
-
return /* @__PURE__ */
|
3015
|
-
|
3016
|
-
|
3017
|
-
|
3018
|
-
|
3019
|
-
|
3020
|
-
|
3021
|
-
|
3022
|
-
|
3023
|
-
|
3024
|
-
|
3025
|
-
|
3026
|
-
|
3027
|
-
|
3028
|
-
);
|
3246
|
+
return /* @__PURE__ */ jsxs(Field.Root, { id: name2, hint, name: name2, required, children: [
|
3247
|
+
/* @__PURE__ */ jsx(Field.Label, { children: label }),
|
3248
|
+
/* @__PURE__ */ jsx(
|
3249
|
+
TextInput,
|
3250
|
+
{
|
3251
|
+
disabled: true,
|
3252
|
+
placeholder,
|
3253
|
+
startAction: /* @__PURE__ */ jsx(EyeStriked, { fill: "neutral600" }),
|
3254
|
+
type: "text",
|
3255
|
+
value: ""
|
3256
|
+
}
|
3257
|
+
),
|
3258
|
+
/* @__PURE__ */ jsx(Field.Hint, {})
|
3259
|
+
] });
|
3029
3260
|
};
|
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
3261
|
const uidApi = contentManagerApi.injectEndpoints({
|
3048
3262
|
endpoints: (builder) => ({
|
3049
3263
|
getDefaultUID: builder.query({
|
@@ -3078,194 +3292,206 @@ const uidApi = contentManagerApi.injectEndpoints({
|
|
3078
3292
|
config: {
|
3079
3293
|
params
|
3080
3294
|
}
|
3081
|
-
})
|
3295
|
+
}),
|
3296
|
+
providesTags: (_res, _error, params) => [
|
3297
|
+
{ type: "UidAvailability", id: params.contentTypeUID }
|
3298
|
+
]
|
3082
3299
|
})
|
3083
3300
|
})
|
3084
3301
|
});
|
3085
3302
|
const { useGenerateUIDMutation, useGetDefaultUIDQuery, useGetAvailabilityQuery } = uidApi;
|
3086
3303
|
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({
|
3304
|
+
const UIDInput = React.forwardRef(
|
3305
|
+
({ hint, label, labelAction, name: name2, required, ...props }, ref) => {
|
3306
|
+
const { model, id } = useDoc();
|
3307
|
+
const allFormValues = useForm("InputUID", (form) => form.values);
|
3308
|
+
const [availability, setAvailability] = React.useState();
|
3309
|
+
const [showRegenerate, setShowRegenerate] = React.useState(false);
|
3310
|
+
const isCloning = useMatch(CLONE_PATH) !== null;
|
3311
|
+
const field = useField(name2);
|
3312
|
+
const debouncedValue = useDebounce(field.value, 300);
|
3313
|
+
const hasChanged = debouncedValue !== field.initialValue;
|
3314
|
+
const { toggleNotification } = useNotification();
|
3315
|
+
const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
|
3316
|
+
const { formatMessage } = useIntl();
|
3317
|
+
const [{ query }] = useQueryParams();
|
3318
|
+
const params = React.useMemo(() => buildValidParams(query), [query]);
|
3319
|
+
const {
|
3320
|
+
data: defaultGeneratedUID,
|
3321
|
+
isLoading: isGeneratingDefaultUID,
|
3322
|
+
error: apiError
|
3323
|
+
} = useGetDefaultUIDQuery(
|
3324
|
+
{
|
3134
3325
|
contentTypeUID: model,
|
3135
|
-
field:
|
3136
|
-
data: {
|
3326
|
+
field: name2,
|
3327
|
+
data: {
|
3328
|
+
id: id ?? "",
|
3329
|
+
...allFormValues
|
3330
|
+
},
|
3137
3331
|
params
|
3138
|
-
}
|
3139
|
-
|
3140
|
-
field.
|
3141
|
-
}
|
3332
|
+
},
|
3333
|
+
{
|
3334
|
+
skip: field.value || !required
|
3335
|
+
}
|
3336
|
+
);
|
3337
|
+
React.useEffect(() => {
|
3338
|
+
if (apiError) {
|
3142
3339
|
toggleNotification({
|
3143
|
-
type: "
|
3144
|
-
message: formatAPIError(
|
3340
|
+
type: "warning",
|
3341
|
+
message: formatAPIError(apiError)
|
3145
3342
|
});
|
3146
3343
|
}
|
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);
|
3344
|
+
}, [apiError, formatAPIError, toggleNotification]);
|
3345
|
+
React.useEffect(() => {
|
3346
|
+
if (defaultGeneratedUID && field.value === void 0) {
|
3347
|
+
field.onChange(name2, defaultGeneratedUID);
|
3348
|
+
}
|
3349
|
+
}, [defaultGeneratedUID, field, name2]);
|
3350
|
+
const [generateUID, { isLoading: isGeneratingUID }] = useGenerateUIDMutation();
|
3351
|
+
const handleRegenerateClick = async () => {
|
3352
|
+
try {
|
3353
|
+
const res = await generateUID({
|
3354
|
+
contentTypeUID: model,
|
3355
|
+
field: name2,
|
3356
|
+
data: { id: id ?? "", ...allFormValues },
|
3357
|
+
params
|
3358
|
+
});
|
3359
|
+
if ("data" in res) {
|
3360
|
+
field.onChange(name2, res.data);
|
3361
|
+
} else {
|
3362
|
+
toggleNotification({
|
3363
|
+
type: "danger",
|
3364
|
+
message: formatAPIError(res.error)
|
3365
|
+
});
|
3366
|
+
}
|
3367
|
+
} catch (err) {
|
3368
|
+
toggleNotification({
|
3369
|
+
type: "danger",
|
3370
|
+
message: formatMessage({
|
3371
|
+
id: "notification.error",
|
3372
|
+
defaultMessage: "An error occurred."
|
3373
|
+
})
|
3374
|
+
});
|
3193
3375
|
}
|
3194
3376
|
};
|
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,
|
3377
|
+
const {
|
3378
|
+
data: availabilityData,
|
3379
|
+
isLoading: isCheckingAvailability,
|
3380
|
+
error: availabilityError
|
3381
|
+
} = useGetAvailabilityQuery(
|
3203
3382
|
{
|
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
|
-
|
3383
|
+
contentTypeUID: model,
|
3384
|
+
field: name2,
|
3385
|
+
value: debouncedValue ? debouncedValue.trim() : "",
|
3386
|
+
params
|
3387
|
+
},
|
3388
|
+
{
|
3389
|
+
// Don't check availability if the value is empty or wasn't changed
|
3390
|
+
skip: !Boolean(
|
3391
|
+
(hasChanged || isCloning) && debouncedValue && UID_REGEX.test(debouncedValue.trim())
|
3392
|
+
)
|
3393
|
+
}
|
3394
|
+
);
|
3395
|
+
React.useEffect(() => {
|
3396
|
+
if (availabilityError) {
|
3397
|
+
toggleNotification({
|
3398
|
+
type: "warning",
|
3399
|
+
message: formatAPIError(availabilityError)
|
3400
|
+
});
|
3401
|
+
}
|
3402
|
+
}, [availabilityError, formatAPIError, toggleNotification]);
|
3403
|
+
React.useEffect(() => {
|
3404
|
+
setAvailability(availabilityData);
|
3405
|
+
let timer;
|
3406
|
+
if (availabilityData?.isAvailable) {
|
3407
|
+
timer = window.setTimeout(() => {
|
3408
|
+
setAvailability(void 0);
|
3409
|
+
}, 4e3);
|
3410
|
+
}
|
3411
|
+
return () => {
|
3412
|
+
if (timer) {
|
3413
|
+
clearTimeout(timer);
|
3414
|
+
}
|
3415
|
+
};
|
3416
|
+
}, [availabilityData]);
|
3417
|
+
const isLoading = isGeneratingDefaultUID || isGeneratingUID || isCheckingAvailability;
|
3418
|
+
const fieldRef = useFocusInputField(name2);
|
3419
|
+
const composedRefs = useComposedRefs(ref, fieldRef);
|
3420
|
+
const shouldShowAvailability = (hasChanged || isCloning) && debouncedValue != null && availability && !showRegenerate;
|
3421
|
+
return /* @__PURE__ */ jsxs(Field.Root, { hint, name: name2, error: field.error, required, children: [
|
3422
|
+
/* @__PURE__ */ jsx(Field.Label, { action: labelAction, children: label }),
|
3423
|
+
/* @__PURE__ */ jsx(
|
3424
|
+
TextInput,
|
3425
|
+
{
|
3426
|
+
ref: composedRefs,
|
3427
|
+
disabled: props.disabled,
|
3428
|
+
endAction: /* @__PURE__ */ jsxs(Flex, { position: "relative", gap: 1, children: [
|
3429
|
+
shouldShowAvailability && /* @__PURE__ */ jsxs(
|
3430
|
+
TextValidation,
|
3248
3431
|
{
|
3249
|
-
|
3250
|
-
|
3251
|
-
|
3252
|
-
|
3253
|
-
|
3254
|
-
|
3255
|
-
|
3256
|
-
|
3432
|
+
alignItems: "center",
|
3433
|
+
gap: 1,
|
3434
|
+
justifyContent: "flex-end",
|
3435
|
+
$available: !!availability?.isAvailable,
|
3436
|
+
"data-not-here-outer": true,
|
3437
|
+
position: "absolute",
|
3438
|
+
pointerEvents: "none",
|
3439
|
+
right: 6,
|
3440
|
+
width: "100px",
|
3441
|
+
children: [
|
3442
|
+
availability?.isAvailable ? /* @__PURE__ */ jsx(CheckCircle, {}) : /* @__PURE__ */ jsx(WarningCircle, {}),
|
3443
|
+
/* @__PURE__ */ jsx(
|
3444
|
+
Typography,
|
3445
|
+
{
|
3446
|
+
textColor: availability.isAvailable ? "success600" : "danger600",
|
3447
|
+
variant: "pi",
|
3448
|
+
children: formatMessage(
|
3449
|
+
availability.isAvailable ? {
|
3450
|
+
id: "content-manager.components.uid.available",
|
3451
|
+
defaultMessage: "Available"
|
3452
|
+
} : {
|
3453
|
+
id: "content-manager.components.uid.unavailable",
|
3454
|
+
defaultMessage: "Unavailable"
|
3455
|
+
}
|
3456
|
+
)
|
3457
|
+
}
|
3458
|
+
)
|
3459
|
+
]
|
3257
3460
|
}
|
3258
|
-
)
|
3259
|
-
|
3260
|
-
|
3261
|
-
|
3262
|
-
|
3263
|
-
|
3264
|
-
|
3265
|
-
|
3266
|
-
|
3267
|
-
|
3268
|
-
|
3461
|
+
),
|
3462
|
+
!props.disabled && /* @__PURE__ */ jsxs(Fragment, { children: [
|
3463
|
+
showRegenerate && /* @__PURE__ */ jsx(TextValidation, { alignItems: "center", justifyContent: "flex-end", gap: 1, children: /* @__PURE__ */ jsx(Typography, { textColor: "primary600", variant: "pi", children: formatMessage({
|
3464
|
+
id: "content-manager.components.uid.regenerate",
|
3465
|
+
defaultMessage: "Regenerate"
|
3466
|
+
}) }) }),
|
3467
|
+
/* @__PURE__ */ jsx(
|
3468
|
+
FieldActionWrapper,
|
3469
|
+
{
|
3470
|
+
onClick: handleRegenerateClick,
|
3471
|
+
label: formatMessage({
|
3472
|
+
id: "content-manager.components.uid.regenerate",
|
3473
|
+
defaultMessage: "Regenerate"
|
3474
|
+
}),
|
3475
|
+
onMouseEnter: () => setShowRegenerate(true),
|
3476
|
+
onMouseLeave: () => setShowRegenerate(false),
|
3477
|
+
children: isLoading ? /* @__PURE__ */ jsx(LoadingWrapper, { "data-testid": "loading-wrapper", children: /* @__PURE__ */ jsx(Loader, {}) }) : /* @__PURE__ */ jsx(ArrowClockwise, {})
|
3478
|
+
}
|
3479
|
+
)
|
3480
|
+
] })
|
3481
|
+
] }),
|
3482
|
+
onChange: field.onChange,
|
3483
|
+
value: field.value ?? "",
|
3484
|
+
...props
|
3485
|
+
}
|
3486
|
+
),
|
3487
|
+
/* @__PURE__ */ jsx(Field.Error, {}),
|
3488
|
+
/* @__PURE__ */ jsx(Field.Hint, {})
|
3489
|
+
] });
|
3490
|
+
}
|
3491
|
+
);
|
3492
|
+
const FieldActionWrapper = styled(Field.Action)`
|
3493
|
+
width: 1.6rem;
|
3494
|
+
|
3269
3495
|
svg {
|
3270
3496
|
height: 1.6rem;
|
3271
3497
|
width: 1.6rem;
|
@@ -3286,7 +3512,7 @@ const TextValidation = styled(Flex)`
|
|
3286
3512
|
width: 1.2rem;
|
3287
3513
|
|
3288
3514
|
path {
|
3289
|
-
fill: ${({ theme, available }) => available ? theme.colors.success600 : theme.colors.danger600};
|
3515
|
+
fill: ${({ theme, $available }) => $available ? theme.colors.success600 : theme.colors.danger600};
|
3290
3516
|
}
|
3291
3517
|
}
|
3292
3518
|
`;
|
@@ -3301,6 +3527,7 @@ const rotation = keyframes`
|
|
3301
3527
|
const LoadingWrapper = styled(Flex)`
|
3302
3528
|
animation: ${rotation} 2s infinite linear;
|
3303
3529
|
`;
|
3530
|
+
const MemoizedUIDInput = React.memo(UIDInput);
|
3304
3531
|
const md = new Markdown({
|
3305
3532
|
html: true,
|
3306
3533
|
// Enable HTML tags in source
|
@@ -3635,7 +3862,7 @@ const Editor = React.forwardRef(
|
|
3635
3862
|
[editorRef]
|
3636
3863
|
);
|
3637
3864
|
return /* @__PURE__ */ jsxs(EditorAndPreviewWrapper, { children: [
|
3638
|
-
/* @__PURE__ */ jsx(EditorStylesContainer, { isExpandMode, disabled: disabled || isPreviewMode, children: /* @__PURE__ */ jsx("textarea", { ref: textareaRef }) }),
|
3865
|
+
/* @__PURE__ */ jsx(EditorStylesContainer, { $isExpandMode: isExpandMode, $disabled: disabled || isPreviewMode, children: /* @__PURE__ */ jsx("textarea", { ref: textareaRef }) }),
|
3639
3866
|
isPreviewMode && /* @__PURE__ */ jsx(PreviewWysiwyg, { data: value })
|
3640
3867
|
] });
|
3641
3868
|
}
|
@@ -3645,7 +3872,7 @@ const EditorAndPreviewWrapper = styled.div`
|
|
3645
3872
|
height: calc(100% - 48px);
|
3646
3873
|
`;
|
3647
3874
|
const EditorStylesContainer = styled.div`
|
3648
|
-
cursor: ${({ disabled }) => disabled ? "not-allowed !important" : "auto"};
|
3875
|
+
cursor: ${({ $disabled }) => $disabled ? "not-allowed !important" : "auto"};
|
3649
3876
|
height: 100%;
|
3650
3877
|
/* BASICS */
|
3651
3878
|
.CodeMirror-placeholder {
|
@@ -3655,7 +3882,7 @@ const EditorStylesContainer = styled.div`
|
|
3655
3882
|
.CodeMirror {
|
3656
3883
|
/* Set height, width, borders, and global font properties here */
|
3657
3884
|
font-size: 1.4rem;
|
3658
|
-
height: ${({ isExpandMode }) => isExpandMode ? "100%" : "410px"}; // 512px(total height) - 48px (header) - 52px(footer) - 2px border
|
3885
|
+
height: ${({ $isExpandMode }) => $isExpandMode ? "100%" : "410px"}; // 512px(total height) - 48px (header) - 52px(footer) - 2px border
|
3659
3886
|
color: ${({ theme }) => theme.colors.neutral800};
|
3660
3887
|
direction: ltr;
|
3661
3888
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
|
@@ -4033,7 +4260,7 @@ const EditorLayout = ({
|
|
4033
4260
|
justifyContent: "flex-end",
|
4034
4261
|
shrink: 0,
|
4035
4262
|
width: "100%",
|
4036
|
-
children: /* @__PURE__ */ jsxs(ExpandButton$1, { onClick: onCollapse, children: [
|
4263
|
+
children: /* @__PURE__ */ jsxs(ExpandButton$1, { onClick: onCollapse, variant: "tertiary", size: "M", children: [
|
4037
4264
|
/* @__PURE__ */ jsx(Typography, { children: formatMessage({
|
4038
4265
|
id: "components.Wysiwyg.collapse",
|
4039
4266
|
defaultMessage: "Collapse"
|
@@ -4051,12 +4278,14 @@ const EditorLayout = ({
|
|
4051
4278
|
) }) });
|
4052
4279
|
}
|
4053
4280
|
return /* @__PURE__ */ jsx(
|
4054
|
-
|
4281
|
+
Flex,
|
4055
4282
|
{
|
4056
4283
|
borderColor: error ? "danger600" : "neutral200",
|
4057
4284
|
borderStyle: "solid",
|
4058
4285
|
borderWidth: "1px",
|
4059
4286
|
hasRadius: true,
|
4287
|
+
direction: "column",
|
4288
|
+
alignItems: "stretch",
|
4060
4289
|
children
|
4061
4290
|
}
|
4062
4291
|
);
|
@@ -4067,11 +4296,19 @@ const ExpandWrapper = styled(Flex)`
|
|
4067
4296
|
const BoxWithBorder = styled(Box)`
|
4068
4297
|
border-right: 1px solid ${({ theme }) => theme.colors.neutral200};
|
4069
4298
|
`;
|
4070
|
-
const ExpandButton$1 = styled(
|
4299
|
+
const ExpandButton$1 = styled(Button)`
|
4071
4300
|
background-color: transparent;
|
4072
4301
|
border: none;
|
4073
4302
|
align-items: center;
|
4074
4303
|
|
4304
|
+
& > span {
|
4305
|
+
display: flex;
|
4306
|
+
justify-content: space-between;
|
4307
|
+
align-items: center;
|
4308
|
+
width: 100%;
|
4309
|
+
font-weight: ${({ theme }) => theme.fontWeights.regular};
|
4310
|
+
}
|
4311
|
+
|
4075
4312
|
svg {
|
4076
4313
|
margin-left: ${({ theme }) => `${theme.spaces[2]}`};
|
4077
4314
|
|
@@ -4338,42 +4575,28 @@ const quoteAndCodeHandler = (editor, markdownType) => {
|
|
4338
4575
|
insertWithoutTextToEdit(editor, markdownType, line, contentLength);
|
4339
4576
|
}
|
4340
4577
|
};
|
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
4578
|
const MainButtons = styled(IconButtonGroup)`
|
4358
4579
|
margin-left: ${({ theme }) => theme.spaces[4]};
|
4359
4580
|
`;
|
4360
4581
|
const MoreButton = styled(IconButton)`
|
4361
4582
|
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
4583
|
`;
|
4369
4584
|
const IconButtonGroupMargin = styled(IconButtonGroup)`
|
4370
4585
|
margin-right: ${({ theme }) => `${theme.spaces[2]}`};
|
4371
4586
|
`;
|
4372
|
-
const ExpandButton = styled(
|
4587
|
+
const ExpandButton = styled(Button)`
|
4373
4588
|
background-color: transparent;
|
4374
4589
|
border: none;
|
4375
4590
|
align-items: center;
|
4376
4591
|
|
4592
|
+
& > span {
|
4593
|
+
display: flex;
|
4594
|
+
justify-content: space-between;
|
4595
|
+
align-items: center;
|
4596
|
+
width: 100%;
|
4597
|
+
font-weight: ${({ theme }) => theme.fontWeights.regular};
|
4598
|
+
}
|
4599
|
+
|
4377
4600
|
svg {
|
4378
4601
|
margin-left: ${({ theme }) => `${theme.spaces[2]}`};
|
4379
4602
|
path {
|
@@ -4385,8 +4608,8 @@ const ExpandButton = styled(BaseButton)`
|
|
4385
4608
|
`;
|
4386
4609
|
const WysiwygFooter = ({ onToggleExpand }) => {
|
4387
4610
|
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({
|
4611
|
+
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: [
|
4612
|
+
/* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: formatMessage({
|
4390
4613
|
id: "components.WysiwygBottomControls.fullscreen",
|
4391
4614
|
defaultMessage: "Expand"
|
4392
4615
|
}) }),
|
@@ -4408,7 +4631,7 @@ const WysiwygNav = ({
|
|
4408
4631
|
id: "components.Wysiwyg.selectOptions.title",
|
4409
4632
|
defaultMessage: "Add a title"
|
4410
4633
|
});
|
4411
|
-
|
4634
|
+
React.useRef(null);
|
4412
4635
|
const handleTogglePopover = () => {
|
4413
4636
|
setVisiblePopover((prev) => !prev);
|
4414
4637
|
};
|
@@ -4421,21 +4644,30 @@ const WysiwygNav = ({
|
|
4421
4644
|
justifyContent: "space-between",
|
4422
4645
|
borderRadius: `0.4rem 0.4rem 0 0`,
|
4423
4646
|
children: [
|
4424
|
-
/* @__PURE__ */ jsxs(
|
4425
|
-
/* @__PURE__ */
|
4426
|
-
|
4427
|
-
|
4428
|
-
|
4429
|
-
|
4430
|
-
|
4431
|
-
|
4432
|
-
|
4647
|
+
/* @__PURE__ */ jsxs(Flex, { children: [
|
4648
|
+
/* @__PURE__ */ jsx(Field.Root, { children: /* @__PURE__ */ jsxs(
|
4649
|
+
SingleSelect,
|
4650
|
+
{
|
4651
|
+
disabled: true,
|
4652
|
+
placeholder: selectPlaceholder,
|
4653
|
+
"aria-label": selectPlaceholder,
|
4654
|
+
size: "S",
|
4655
|
+
children: [
|
4656
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h1", children: "h1" }),
|
4657
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h2", children: "h2" }),
|
4658
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h3", children: "h3" }),
|
4659
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h4", children: "h4" }),
|
4660
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h5", children: "h5" }),
|
4661
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h6", children: "h6" })
|
4662
|
+
]
|
4663
|
+
}
|
4664
|
+
) }),
|
4433
4665
|
/* @__PURE__ */ jsxs(MainButtons, { children: [
|
4434
|
-
/* @__PURE__ */ jsx(
|
4435
|
-
/* @__PURE__ */ jsx(
|
4436
|
-
/* @__PURE__ */ jsx(
|
4666
|
+
/* @__PURE__ */ jsx(IconButton, { disabled: true, label: "Bold", name: "Bold", children: /* @__PURE__ */ jsx(Bold, {}) }),
|
4667
|
+
/* @__PURE__ */ jsx(IconButton, { disabled: true, label: "Italic", name: "Italic", children: /* @__PURE__ */ jsx(Italic, {}) }),
|
4668
|
+
/* @__PURE__ */ jsx(IconButton, { disabled: true, label: "Underline", name: "Underline", children: /* @__PURE__ */ jsx(Underline, {}) })
|
4437
4669
|
] }),
|
4438
|
-
/* @__PURE__ */ jsx(MoreButton, { disabled: true, label: "More",
|
4670
|
+
/* @__PURE__ */ jsx(MoreButton, { disabled: true, label: "More", children: /* @__PURE__ */ jsx(More, {}) })
|
4439
4671
|
] }),
|
4440
4672
|
!isExpandMode && /* @__PURE__ */ jsx(Button, { onClick: onTogglePreviewMode, variant: "tertiary", children: formatMessage({
|
4441
4673
|
id: "components.Wysiwyg.ToggleMode.markdown-mode",
|
@@ -4453,14 +4685,14 @@ const WysiwygNav = ({
|
|
4453
4685
|
justifyContent: "space-between",
|
4454
4686
|
borderRadius: `0.4rem 0.4rem 0 0`,
|
4455
4687
|
children: [
|
4456
|
-
/* @__PURE__ */ jsxs(
|
4457
|
-
/* @__PURE__ */ jsxs(
|
4688
|
+
/* @__PURE__ */ jsxs(Flex, { children: [
|
4689
|
+
/* @__PURE__ */ jsx(Field.Root, { children: /* @__PURE__ */ jsxs(
|
4458
4690
|
SingleSelect,
|
4459
4691
|
{
|
4460
4692
|
placeholder: selectPlaceholder,
|
4461
|
-
label: selectPlaceholder,
|
4462
|
-
size: "S",
|
4693
|
+
"aria-label": selectPlaceholder,
|
4463
4694
|
onChange: (value) => onActionClick(value, editorRef),
|
4695
|
+
size: "S",
|
4464
4696
|
children: [
|
4465
4697
|
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h1", children: "h1" }),
|
4466
4698
|
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h2", children: "h2" }),
|
@@ -4470,117 +4702,103 @@ const WysiwygNav = ({
|
|
4470
4702
|
/* @__PURE__ */ jsx(SingleSelectOption, { value: "h6", children: "h6" })
|
4471
4703
|
]
|
4472
4704
|
}
|
4473
|
-
),
|
4705
|
+
) }),
|
4474
4706
|
/* @__PURE__ */ jsxs(MainButtons, { children: [
|
4707
|
+
/* @__PURE__ */ jsx(IconButton, { onClick: () => onActionClick("Bold", editorRef), label: "Bold", name: "Bold", children: /* @__PURE__ */ jsx(Bold, {}) }),
|
4475
4708
|
/* @__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,
|
4709
|
+
IconButton,
|
4486
4710
|
{
|
4487
4711
|
onClick: () => onActionClick("Italic", editorRef),
|
4488
4712
|
label: "Italic",
|
4489
4713
|
name: "Italic",
|
4490
|
-
|
4714
|
+
children: /* @__PURE__ */ jsx(Italic, {})
|
4491
4715
|
}
|
4492
4716
|
),
|
4493
4717
|
/* @__PURE__ */ jsx(
|
4494
|
-
|
4718
|
+
IconButton,
|
4495
4719
|
{
|
4496
4720
|
onClick: () => onActionClick("Underline", editorRef),
|
4497
4721
|
label: "Underline",
|
4498
4722
|
name: "Underline",
|
4499
|
-
|
4723
|
+
children: /* @__PURE__ */ jsx(Underline, {})
|
4500
4724
|
}
|
4501
4725
|
)
|
4502
4726
|
] }),
|
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
|
-
] }) })
|
4727
|
+
/* @__PURE__ */ jsxs(Popover.Root, { children: [
|
4728
|
+
/* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx(MoreButton, { label: "More", children: /* @__PURE__ */ jsx(More, {}) }) }),
|
4729
|
+
/* @__PURE__ */ jsx(Popover.Content, { sideOffset: 12, children: /* @__PURE__ */ jsxs(Flex, { padding: 2, children: [
|
4730
|
+
/* @__PURE__ */ jsxs(IconButtonGroupMargin, { children: [
|
4731
|
+
/* @__PURE__ */ jsx(
|
4732
|
+
IconButton,
|
4733
|
+
{
|
4734
|
+
onClick: () => onActionClick("Strikethrough", editorRef, handleTogglePopover),
|
4735
|
+
label: "Strikethrough",
|
4736
|
+
name: "Strikethrough",
|
4737
|
+
children: /* @__PURE__ */ jsx(StrikeThrough, {})
|
4738
|
+
}
|
4739
|
+
),
|
4740
|
+
/* @__PURE__ */ jsx(
|
4741
|
+
IconButton,
|
4742
|
+
{
|
4743
|
+
onClick: () => onActionClick("BulletList", editorRef, handleTogglePopover),
|
4744
|
+
label: "BulletList",
|
4745
|
+
name: "BulletList",
|
4746
|
+
children: /* @__PURE__ */ jsx(BulletList, {})
|
4747
|
+
}
|
4748
|
+
),
|
4749
|
+
/* @__PURE__ */ jsx(
|
4750
|
+
IconButton,
|
4751
|
+
{
|
4752
|
+
onClick: () => onActionClick("NumberList", editorRef, handleTogglePopover),
|
4753
|
+
label: "NumberList",
|
4754
|
+
name: "NumberList",
|
4755
|
+
children: /* @__PURE__ */ jsx(NumberList, {})
|
4756
|
+
}
|
4757
|
+
)
|
4758
|
+
] }),
|
4759
|
+
/* @__PURE__ */ jsxs(IconButtonGroup, { children: [
|
4760
|
+
/* @__PURE__ */ jsx(
|
4761
|
+
IconButton,
|
4762
|
+
{
|
4763
|
+
onClick: () => onActionClick("Code", editorRef, handleTogglePopover),
|
4764
|
+
label: "Code",
|
4765
|
+
name: "Code",
|
4766
|
+
children: /* @__PURE__ */ jsx(Code, {})
|
4767
|
+
}
|
4768
|
+
),
|
4769
|
+
/* @__PURE__ */ jsx(
|
4770
|
+
IconButton,
|
4771
|
+
{
|
4772
|
+
onClick: () => {
|
4773
|
+
handleTogglePopover();
|
4774
|
+
onToggleMediaLib();
|
4775
|
+
},
|
4776
|
+
label: "Image",
|
4777
|
+
name: "Image",
|
4778
|
+
children: /* @__PURE__ */ jsx(Image$1, {})
|
4779
|
+
}
|
4780
|
+
),
|
4781
|
+
/* @__PURE__ */ jsx(
|
4782
|
+
IconButton,
|
4783
|
+
{
|
4784
|
+
onClick: () => onActionClick("Link", editorRef, handleTogglePopover),
|
4785
|
+
label: "Link",
|
4786
|
+
name: "Link",
|
4787
|
+
children: /* @__PURE__ */ jsx(Link$1, {})
|
4788
|
+
}
|
4789
|
+
),
|
4790
|
+
/* @__PURE__ */ jsx(
|
4791
|
+
IconButton,
|
4792
|
+
{
|
4793
|
+
onClick: () => onActionClick("Quote", editorRef, handleTogglePopover),
|
4794
|
+
label: "Quote",
|
4795
|
+
name: "Quote",
|
4796
|
+
children: /* @__PURE__ */ jsx(Quotes, {})
|
4797
|
+
}
|
4798
|
+
)
|
4799
|
+
] })
|
4800
|
+
] }) })
|
4801
|
+
] })
|
4584
4802
|
] }),
|
4585
4803
|
onTogglePreviewMode && /* @__PURE__ */ jsx(Button, { onClick: onTogglePreviewMode, variant: "tertiary", children: formatMessage({
|
4586
4804
|
id: "components.Wysiwyg.ToggleMode.preview-mode",
|
@@ -4590,19 +4808,6 @@ const WysiwygNav = ({
|
|
4590
4808
|
}
|
4591
4809
|
);
|
4592
4810
|
};
|
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
4811
|
const Wysiwyg = React.forwardRef(
|
4607
4812
|
({ hint, disabled, label, name: name2, placeholder, required, labelAction }, forwardedRef) => {
|
4608
4813
|
const field = useField(name2);
|
@@ -4667,9 +4872,9 @@ const Wysiwyg = React.forwardRef(
|
|
4667
4872
|
insertFile(editorRef, formattedFiles);
|
4668
4873
|
setMediaLibVisible(false);
|
4669
4874
|
};
|
4670
|
-
return /* @__PURE__ */ jsxs(Field, { name: name2, hint, error: field.error, required, children: [
|
4875
|
+
return /* @__PURE__ */ jsxs(Field.Root, { name: name2, hint, error: field.error, required, children: [
|
4671
4876
|
/* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
|
4672
|
-
/* @__PURE__ */ jsx(
|
4877
|
+
/* @__PURE__ */ jsx(Field.Label, { action: labelAction, children: label }),
|
4673
4878
|
/* @__PURE__ */ jsxs(
|
4674
4879
|
EditorLayout,
|
4675
4880
|
{
|
@@ -4710,14 +4915,15 @@ const Wysiwyg = React.forwardRef(
|
|
4710
4915
|
]
|
4711
4916
|
}
|
4712
4917
|
),
|
4713
|
-
/* @__PURE__ */ jsx(
|
4714
|
-
/* @__PURE__ */ jsx(
|
4918
|
+
/* @__PURE__ */ jsx(Field.Hint, {}),
|
4919
|
+
/* @__PURE__ */ jsx(Field.Error, {})
|
4715
4920
|
] }),
|
4716
4921
|
mediaLibVisible && // @ts-expect-error – TODO: fix this way of injecting because it's not really typeable without a registry.
|
4717
4922
|
/* @__PURE__ */ jsx(MediaLibraryDialog, { onClose: handleToggleMediaLib, onSelectAssets: handleSelectAssets })
|
4718
4923
|
] });
|
4719
4924
|
}
|
4720
4925
|
);
|
4926
|
+
const MemoizedWysiwyg = React.memo(Wysiwyg);
|
4721
4927
|
const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
|
4722
4928
|
const { id } = useDoc();
|
4723
4929
|
const isFormDisabled = useForm("InputRenderer", (state) => state.disabled);
|
@@ -4767,10 +4973,10 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
|
|
4767
4973
|
}
|
4768
4974
|
switch (props.type) {
|
4769
4975
|
case "blocks":
|
4770
|
-
return /* @__PURE__ */ jsx(
|
4976
|
+
return /* @__PURE__ */ jsx(MemoizedBlocksInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
|
4771
4977
|
case "component":
|
4772
4978
|
return /* @__PURE__ */ jsx(
|
4773
|
-
|
4979
|
+
MemoizedComponentInput,
|
4774
4980
|
{
|
4775
4981
|
...props,
|
4776
4982
|
hint,
|
@@ -4782,11 +4988,11 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
|
|
4782
4988
|
case "dynamiczone":
|
4783
4989
|
return /* @__PURE__ */ jsx(DynamicZone, { ...props, hint, disabled: fieldIsDisabled });
|
4784
4990
|
case "relation":
|
4785
|
-
return /* @__PURE__ */ jsx(
|
4991
|
+
return /* @__PURE__ */ jsx(MemoizedRelationsField, { ...props, hint, disabled: fieldIsDisabled });
|
4786
4992
|
case "richtext":
|
4787
|
-
return /* @__PURE__ */ jsx(
|
4993
|
+
return /* @__PURE__ */ jsx(MemoizedWysiwyg, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
|
4788
4994
|
case "uid":
|
4789
|
-
return /* @__PURE__ */ jsx(
|
4995
|
+
return /* @__PURE__ */ jsx(MemoizedUIDInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
|
4790
4996
|
case "enumeration":
|
4791
4997
|
return /* @__PURE__ */ jsx(
|
4792
4998
|
InputRenderer$1,
|
@@ -4818,7 +5024,9 @@ const useFieldHint = (hint = void 0, attribute) => {
|
|
4818
5024
|
if (!maximum && !minimum) {
|
4819
5025
|
return hint;
|
4820
5026
|
}
|
4821
|
-
const units = !["biginteger", "integer", "number"].includes(
|
5027
|
+
const units = !["biginteger", "integer", "number", "dynamiczone", "component"].includes(
|
5028
|
+
attribute.type
|
5029
|
+
) ? formatMessage(
|
4822
5030
|
{
|
4823
5031
|
id: "content-manager.form.Input.hint.character.unit",
|
4824
5032
|
defaultMessage: "{maxValue, plural, one { character} other { characters}}"
|
@@ -4858,6 +5066,7 @@ const getMinMax = (attribute) => {
|
|
4858
5066
|
return { maximum: void 0, minimum: void 0 };
|
4859
5067
|
}
|
4860
5068
|
};
|
5069
|
+
const MemoizedInputRenderer = memo(InputRenderer);
|
4861
5070
|
const DynamicComponent = ({
|
4862
5071
|
componentUid,
|
4863
5072
|
disabled,
|
@@ -4871,7 +5080,6 @@ const DynamicComponent = ({
|
|
4871
5080
|
dynamicComponentsByCategory = {},
|
4872
5081
|
onAddComponent
|
4873
5082
|
}) => {
|
4874
|
-
const [isOpen, setIsOpen] = React.useState(true);
|
4875
5083
|
const { formatMessage } = useIntl();
|
4876
5084
|
const formValues = useForm("DynamicComponent", (state) => state.values);
|
4877
5085
|
const {
|
@@ -4880,7 +5088,7 @@ const DynamicComponent = ({
|
|
4880
5088
|
const title = React.useMemo(() => {
|
4881
5089
|
const { mainField } = components[componentUid]?.settings ?? { mainField: "id" };
|
4882
5090
|
const mainFieldValue = getIn(formValues, `${name2}.${index}.${mainField}`);
|
4883
|
-
const displayedValue = mainField === "id" ? "" : String(mainFieldValue).trim();
|
5091
|
+
const displayedValue = mainField === "id" || !mainFieldValue ? "" : String(mainFieldValue).trim();
|
4884
5092
|
const mainValue = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;
|
4885
5093
|
return mainValue;
|
4886
5094
|
}, [componentUid, components, formValues, name2, index]);
|
@@ -4891,9 +5099,6 @@ const DynamicComponent = ({
|
|
4891
5099
|
) ?? { icon: null, displayName: null };
|
4892
5100
|
return { icon: icon2, displayName: displayName2 };
|
4893
5101
|
}, [componentUid, dynamicComponentsByCategory]);
|
4894
|
-
const handleToggle = () => {
|
4895
|
-
setIsOpen((s) => !s);
|
4896
|
-
};
|
4897
5102
|
const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop(!disabled, {
|
4898
5103
|
type: `${ItemTypes.DYNAMIC_ZONE}_${name2}`,
|
4899
5104
|
index,
|
@@ -4911,11 +5116,11 @@ const DynamicComponent = ({
|
|
4911
5116
|
dragPreviewRef(getEmptyImage(), { captureDraggingState: false });
|
4912
5117
|
}, [dragPreviewRef, index]);
|
4913
5118
|
const composedBoxRefs = useComposedRefs(boxRef, dropRef);
|
4914
|
-
const accordionActions = disabled ? null : /* @__PURE__ */ jsxs(
|
5119
|
+
const accordionActions = disabled ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
|
4915
5120
|
/* @__PURE__ */ jsx(
|
4916
|
-
|
5121
|
+
IconButton,
|
4917
5122
|
{
|
4918
|
-
|
5123
|
+
variant: "ghost",
|
4919
5124
|
label: formatMessage(
|
4920
5125
|
{
|
4921
5126
|
id: getTranslation("components.DynamicZone.delete-label"),
|
@@ -4930,10 +5135,7 @@ const DynamicComponent = ({
|
|
4930
5135
|
/* @__PURE__ */ jsx(
|
4931
5136
|
IconButton,
|
4932
5137
|
{
|
4933
|
-
|
4934
|
-
role: "button",
|
4935
|
-
borderWidth: 0,
|
4936
|
-
tabIndex: 0,
|
5138
|
+
variant: "ghost",
|
4937
5139
|
onClick: (e) => e.stopPropagation(),
|
4938
5140
|
"data-handler-id": handlerId,
|
4939
5141
|
ref: dragRef,
|
@@ -4948,7 +5150,7 @@ const DynamicComponent = ({
|
|
4948
5150
|
/* @__PURE__ */ jsxs(Menu.Root, { children: [
|
4949
5151
|
/* @__PURE__ */ jsxs(Menu.Trigger, { size: "S", endIcon: null, paddingLeft: 2, paddingRight: 2, children: [
|
4950
5152
|
/* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false }),
|
4951
|
-
/* @__PURE__ */ jsx(VisuallyHidden, {
|
5153
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { tag: "span", children: formatMessage({
|
4952
5154
|
id: getTranslation("components.DynamicZone.more-actions"),
|
4953
5155
|
defaultMessage: "More actions"
|
4954
5156
|
}) })
|
@@ -4977,42 +5179,39 @@ const DynamicComponent = ({
|
|
4977
5179
|
] })
|
4978
5180
|
] })
|
4979
5181
|
] });
|
4980
|
-
|
5182
|
+
const accordionTitle = title ? `${displayName} ${title}` : displayName;
|
5183
|
+
const accordionValue = React.useId();
|
5184
|
+
return /* @__PURE__ */ jsxs(ComponentContainer, { tag: "li", width: "100%", children: [
|
4981
5185
|
/* @__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
|
-
|
4985
|
-
|
4986
|
-
|
4987
|
-
|
4988
|
-
|
4989
|
-
|
4990
|
-
|
4991
|
-
|
4992
|
-
|
5186
|
+
/* @__PURE__ */ jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsx(Preview, {}) : /* @__PURE__ */ jsx(Accordion.Root, { children: /* @__PURE__ */ jsxs(Accordion.Item, { value: accordionValue, children: [
|
5187
|
+
/* @__PURE__ */ jsxs(Accordion.Header, { children: [
|
5188
|
+
/* @__PURE__ */ jsx(
|
5189
|
+
Accordion.Trigger,
|
5190
|
+
{
|
5191
|
+
icon: icon && COMPONENT_ICONS[icon] ? COMPONENT_ICONS[icon] : COMPONENT_ICONS.dashboard,
|
5192
|
+
children: accordionTitle
|
5193
|
+
}
|
5194
|
+
),
|
5195
|
+
/* @__PURE__ */ jsx(Accordion.Actions, { children: accordionActions })
|
5196
|
+
] }),
|
5197
|
+
/* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(AccordionContentRadius, { background: "neutral0", children: /* @__PURE__ */ jsx(Box, { paddingLeft: 6, paddingRight: 6, paddingTop: 6, paddingBottom: 6, children: components[componentUid]?.layout?.map((row, rowInd) => /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: row.map(({ size, ...field }) => {
|
4993
5198
|
const fieldName = `${name2}.${index}.${field.name}`;
|
4994
|
-
return /* @__PURE__ */ jsx(
|
5199
|
+
return /* @__PURE__ */ jsx(
|
5200
|
+
Grid$1.Item,
|
5201
|
+
{
|
5202
|
+
col: size,
|
5203
|
+
s: 12,
|
5204
|
+
xs: 12,
|
5205
|
+
direction: "column",
|
5206
|
+
alignItems: "stretch",
|
5207
|
+
children: /* @__PURE__ */ jsx(MemoizedInputRenderer, { ...field, name: fieldName })
|
5208
|
+
},
|
5209
|
+
fieldName
|
5210
|
+
);
|
4995
5211
|
}) }, rowInd)) }) }) })
|
4996
|
-
] }) })
|
5212
|
+
] }) }) })
|
4997
5213
|
] });
|
4998
5214
|
};
|
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
5215
|
const StyledBox = styled(Box)`
|
5017
5216
|
> div:first-child {
|
5018
5217
|
box-shadow: ${({ theme }) => theme.shadows.tableShadow};
|
@@ -5083,7 +5282,7 @@ const [DynamicZoneProvider, useDynamicZone] = createContext(
|
|
5083
5282
|
);
|
5084
5283
|
const DynamicZone = ({
|
5085
5284
|
attribute,
|
5086
|
-
disabled,
|
5285
|
+
disabled: disabledProp,
|
5087
5286
|
hint,
|
5088
5287
|
label,
|
5089
5288
|
labelAction,
|
@@ -5093,7 +5292,8 @@ const DynamicZone = ({
|
|
5093
5292
|
const { max = Infinity, min = -Infinity } = attribute ?? {};
|
5094
5293
|
const [addComponentIsOpen, setAddComponentIsOpen] = React.useState(false);
|
5095
5294
|
const [liveText, setLiveText] = React.useState("");
|
5096
|
-
const { components } = useDoc();
|
5295
|
+
const { components, isLoading } = useDoc();
|
5296
|
+
const disabled = disabledProp || isLoading;
|
5097
5297
|
const { addFieldRow, removeFieldRow, moveFieldRow } = useForm(
|
5098
5298
|
"DynamicZone",
|
5099
5299
|
({ addFieldRow: addFieldRow2, removeFieldRow: removeFieldRow2, moveFieldRow: moveFieldRow2 }) => ({
|
@@ -5200,7 +5400,7 @@ const DynamicZone = ({
|
|
5200
5400
|
const handleRemoveComponent = (name22, currentIndex) => () => {
|
5201
5401
|
removeFieldRow(name22, currentIndex);
|
5202
5402
|
};
|
5203
|
-
const hasError = error !== void 0
|
5403
|
+
const hasError = error !== void 0;
|
5204
5404
|
const renderButtonLabel = () => {
|
5205
5405
|
if (addComponentIsOpen) {
|
5206
5406
|
return formatMessage({ id: "app.utils.close-label", defaultMessage: "Close" });
|
@@ -5301,19 +5501,19 @@ const DynamicZone = ({
|
|
5301
5501
|
] }) });
|
5302
5502
|
};
|
5303
5503
|
export {
|
5304
|
-
BlocksInput as B,
|
5305
|
-
ComponentInput as C,
|
5306
5504
|
DynamicZone as D,
|
5307
|
-
|
5505
|
+
MemoizedInputRenderer as M,
|
5308
5506
|
NotAllowedInput as N,
|
5309
|
-
UIDInput as U,
|
5310
|
-
Wysiwyg as W,
|
5311
5507
|
useDynamicZone as a,
|
5312
5508
|
useFieldHint as b,
|
5313
5509
|
createDefaultForm as c,
|
5510
|
+
MemoizedUIDInput as d,
|
5511
|
+
MemoizedWysiwyg as e,
|
5512
|
+
MemoizedComponentInput as f,
|
5513
|
+
MemoizedBlocksInput as g,
|
5314
5514
|
prepareTempKeys as p,
|
5315
5515
|
removeFieldsThatDontExistOnSchema as r,
|
5316
5516
|
transformDocument as t,
|
5317
5517
|
useLazyComponents as u
|
5318
5518
|
};
|
5319
|
-
//# sourceMappingURL=Field-
|
5519
|
+
//# sourceMappingURL=Field-CnCKhI1R.mjs.map
|