@strapi/content-manager 0.0.0-experimental.cb311d9fcfbd8e441f790aea232f0a39bdd90e16 → 0.0.0-experimental.cb74730ce5154c26404d4dccca14976a22319002

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.
Files changed (210) hide show
  1. package/dist/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -1
  2. package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-D0dyDTwq.mjs → ComponentConfigurationPage-BgCLcjXO.mjs} +4 -4
  4. package/dist/_chunks/{ComponentConfigurationPage-D0dyDTwq.mjs.map → ComponentConfigurationPage-BgCLcjXO.mjs.map} +1 -1
  5. package/dist/_chunks/{ComponentConfigurationPage-DL1MHO8i.js → ComponentConfigurationPage-DywpTZeV.js} +5 -6
  6. package/dist/_chunks/{ComponentConfigurationPage-DL1MHO8i.js.map → ComponentConfigurationPage-DywpTZeV.js.map} +1 -1
  7. package/dist/_chunks/{ComponentIcon-BXdiCGQp.js → ComponentIcon-CRbtQEUV.js} +2 -3
  8. package/dist/_chunks/{ComponentIcon-BXdiCGQp.js.map → ComponentIcon-CRbtQEUV.js.map} +1 -1
  9. package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -1
  10. package/dist/_chunks/{EditConfigurationPage-13b7S5Cq.mjs → EditConfigurationPage-BNjOAHNS.mjs} +4 -4
  11. package/dist/_chunks/{EditConfigurationPage-13b7S5Cq.mjs.map → EditConfigurationPage-BNjOAHNS.mjs.map} +1 -1
  12. package/dist/_chunks/{EditConfigurationPage-CMaOf-A-.js → EditConfigurationPage-CxRlP5if.js} +5 -6
  13. package/dist/_chunks/{EditConfigurationPage-CMaOf-A-.js.map → EditConfigurationPage-CxRlP5if.js.map} +1 -1
  14. package/dist/_chunks/{EditViewPage-BSVmMpRd.js → EditViewPage-BRewdTqE.js} +63 -13
  15. package/dist/_chunks/EditViewPage-BRewdTqE.js.map +1 -0
  16. package/dist/_chunks/{EditViewPage-C3tIZ8F5.mjs → EditViewPage-CD_hqc1J.mjs} +63 -12
  17. package/dist/_chunks/EditViewPage-CD_hqc1J.mjs.map +1 -0
  18. package/dist/_chunks/{Field-BvuT8cGL.mjs → Field-BPkQ-3Ku.mjs} +230 -158
  19. package/dist/_chunks/Field-BPkQ-3Ku.mjs.map +1 -0
  20. package/dist/_chunks/{Field-DUCVth4C.js → Field-DwvmENVf.js} +233 -162
  21. package/dist/_chunks/Field-DwvmENVf.js.map +1 -0
  22. package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -1
  23. package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -1
  24. package/dist/_chunks/{Form-Cpl4W1ak.js → Form-C_Gwv8P_.js} +39 -21
  25. package/dist/_chunks/Form-C_Gwv8P_.js.map +1 -0
  26. package/dist/_chunks/{Form-BZmDNVr9.mjs → Form-Czi0cf_2.mjs} +37 -18
  27. package/dist/_chunks/Form-Czi0cf_2.mjs.map +1 -0
  28. package/dist/_chunks/{History-D4U2YISB.js → History-C1TKAig-.js} +42 -100
  29. package/dist/_chunks/History-C1TKAig-.js.map +1 -0
  30. package/dist/_chunks/{History-Cq_Hrzuu.mjs → History-CIQHyi4T.mjs} +43 -100
  31. package/dist/_chunks/History-CIQHyi4T.mjs.map +1 -0
  32. package/dist/_chunks/{ListConfigurationPage-Bny6CdWe.js → ListConfigurationPage-D-NGRLYu.js} +19 -9
  33. package/dist/_chunks/ListConfigurationPage-D-NGRLYu.js.map +1 -0
  34. package/dist/_chunks/{ListConfigurationPage-W-KQHmBv.mjs → ListConfigurationPage-DcZsfyEL.mjs} +19 -8
  35. package/dist/_chunks/ListConfigurationPage-DcZsfyEL.mjs.map +1 -0
  36. package/dist/_chunks/{ListViewPage-HBBnJa8K.mjs → ListViewPage-C10McTK1.mjs} +99 -72
  37. package/dist/_chunks/ListViewPage-C10McTK1.mjs.map +1 -0
  38. package/dist/_chunks/{ListViewPage-O8F1pBJo.js → ListViewPage-xv5IQoZp.js} +103 -77
  39. package/dist/_chunks/ListViewPage-xv5IQoZp.js.map +1 -0
  40. package/dist/_chunks/{NoContentTypePage-B-gIhHWM.mjs → NoContentTypePage-CPc0Cd3S.mjs} +2 -2
  41. package/dist/_chunks/{NoContentTypePage-B-gIhHWM.mjs.map → NoContentTypePage-CPc0Cd3S.mjs.map} +1 -1
  42. package/dist/_chunks/{NoContentTypePage-CQWChGPw.js → NoContentTypePage-Dzw5Yj5u.js} +2 -2
  43. package/dist/_chunks/{NoContentTypePage-CQWChGPw.js.map → NoContentTypePage-Dzw5Yj5u.js.map} +1 -1
  44. package/dist/_chunks/{NoPermissionsPage-CY46zxnM.js → NoPermissionsPage-DAe5CDCC.js} +2 -2
  45. package/dist/_chunks/{NoPermissionsPage-CY46zxnM.js.map → NoPermissionsPage-DAe5CDCC.js.map} +1 -1
  46. package/dist/_chunks/{NoPermissionsPage-XhOPl8wx.mjs → NoPermissionsPage-wfPBh2_0.mjs} +2 -2
  47. package/dist/_chunks/{NoPermissionsPage-XhOPl8wx.mjs.map → NoPermissionsPage-wfPBh2_0.mjs.map} +1 -1
  48. package/dist/_chunks/Preview-B7LyGT_b.js +290 -0
  49. package/dist/_chunks/Preview-B7LyGT_b.js.map +1 -0
  50. package/dist/_chunks/Preview-BVFFm7uB.mjs +272 -0
  51. package/dist/_chunks/Preview-BVFFm7uB.mjs.map +1 -0
  52. package/dist/_chunks/{Relations-C4gGfZRv.js → Relations-BmYR1AjY.js} +76 -43
  53. package/dist/_chunks/Relations-BmYR1AjY.js.map +1 -0
  54. package/dist/_chunks/{Relations-vFZ6Wasg.mjs → Relations-JPhWxk-s.mjs} +76 -42
  55. package/dist/_chunks/Relations-JPhWxk-s.mjs.map +1 -0
  56. package/dist/_chunks/{en-uOUIxfcQ.js → en-BK8Xyl5I.js} +28 -15
  57. package/dist/_chunks/{en-uOUIxfcQ.js.map → en-BK8Xyl5I.js.map} +1 -1
  58. package/dist/_chunks/{en-BrCTWlZv.mjs → en-Dtk_ot79.mjs} +28 -15
  59. package/dist/_chunks/{en-BrCTWlZv.mjs.map → en-Dtk_ot79.mjs.map} +1 -1
  60. package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
  61. package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
  62. package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
  63. package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
  64. package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
  65. package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
  66. package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
  67. package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
  68. package/dist/_chunks/hooks-BAaaKPS_.js.map +1 -1
  69. package/dist/_chunks/{index-5EMXLEM_.js → index-C2Q_PLWj.js} +1199 -927
  70. package/dist/_chunks/index-C2Q_PLWj.js.map +1 -0
  71. package/dist/_chunks/{index-Dpxg3ctD.mjs → index-DLIkNVnQ.mjs} +1217 -945
  72. package/dist/_chunks/index-DLIkNVnQ.mjs.map +1 -0
  73. package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
  74. package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
  75. package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
  76. package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
  77. package/dist/_chunks/{layout-P3eKO1Qy.js → layout-7AsWJzZJ.js} +10 -10
  78. package/dist/_chunks/layout-7AsWJzZJ.js.map +1 -0
  79. package/dist/_chunks/{layout-C0INpKap.mjs → layout-qE8qkNH_.mjs} +9 -8
  80. package/dist/_chunks/layout-qE8qkNH_.mjs.map +1 -0
  81. package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
  82. package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
  83. package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
  84. package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
  85. package/dist/_chunks/{relations-FBRRBWeO.mjs → relations-BjHH_1Am.mjs} +6 -7
  86. package/dist/_chunks/relations-BjHH_1Am.mjs.map +1 -0
  87. package/dist/_chunks/{relations-B1y0K6LE.js → relations-EifVzf_2.js} +6 -7
  88. package/dist/_chunks/relations-EifVzf_2.js.map +1 -0
  89. package/dist/_chunks/{usePrev-B9w_-eYc.js → useDebounce-CtcjDB3L.js} +14 -1
  90. package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
  91. package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
  92. package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -0
  93. package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js → useDragAndDrop-BMtgCYzL.js} +5 -9
  94. package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js.map → useDragAndDrop-BMtgCYzL.js.map} +1 -1
  95. package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs → useDragAndDrop-DJ6jqvZN.mjs} +4 -7
  96. package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs.map → useDragAndDrop-DJ6jqvZN.mjs.map} +1 -1
  97. package/dist/admin/index.js +2 -1
  98. package/dist/admin/index.js.map +1 -1
  99. package/dist/admin/index.mjs +5 -4
  100. package/dist/admin/src/exports.d.ts +1 -1
  101. package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
  102. package/dist/admin/src/hooks/useDocument.d.ts +32 -1
  103. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
  104. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
  105. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +2 -2
  106. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
  107. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +4 -48
  108. package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
  109. package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
  110. package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
  111. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  112. package/dist/admin/src/preview/constants.d.ts +1 -0
  113. package/dist/admin/src/preview/index.d.ts +4 -0
  114. package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
  115. package/dist/admin/src/preview/routes.d.ts +3 -0
  116. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  117. package/dist/admin/src/router.d.ts +1 -1
  118. package/dist/admin/src/services/api.d.ts +1 -1
  119. package/dist/admin/src/services/components.d.ts +2 -2
  120. package/dist/admin/src/services/contentTypes.d.ts +3 -3
  121. package/dist/admin/src/services/documents.d.ts +19 -20
  122. package/dist/admin/src/services/init.d.ts +1 -1
  123. package/dist/admin/src/services/relations.d.ts +2 -2
  124. package/dist/admin/src/services/uid.d.ts +3 -3
  125. package/dist/admin/src/utils/validation.d.ts +4 -1
  126. package/dist/server/index.js +486 -219
  127. package/dist/server/index.js.map +1 -1
  128. package/dist/server/index.mjs +486 -218
  129. package/dist/server/index.mjs.map +1 -1
  130. package/dist/server/src/bootstrap.d.ts.map +1 -1
  131. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  132. package/dist/server/src/controllers/index.d.ts.map +1 -1
  133. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  134. package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
  135. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  136. package/dist/server/src/history/services/history.d.ts.map +1 -1
  137. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  138. package/dist/server/src/history/services/utils.d.ts +3 -3
  139. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  140. package/dist/server/src/index.d.ts +4 -4
  141. package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
  142. package/dist/server/src/preview/constants.d.ts +2 -0
  143. package/dist/server/src/preview/constants.d.ts.map +1 -0
  144. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  145. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  146. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  147. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  148. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  149. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  150. package/dist/server/src/preview/index.d.ts +4 -0
  151. package/dist/server/src/preview/index.d.ts.map +1 -0
  152. package/dist/server/src/preview/routes/index.d.ts +8 -0
  153. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  154. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  155. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  156. package/dist/server/src/preview/services/index.d.ts +16 -0
  157. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  158. package/dist/server/src/preview/services/preview-config.d.ts +32 -0
  159. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  160. package/dist/server/src/preview/services/preview.d.ts +12 -0
  161. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  162. package/dist/server/src/preview/utils.d.ts +19 -0
  163. package/dist/server/src/preview/utils.d.ts.map +1 -0
  164. package/dist/server/src/register.d.ts.map +1 -1
  165. package/dist/server/src/routes/index.d.ts.map +1 -1
  166. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  167. package/dist/server/src/services/document-metadata.d.ts +8 -8
  168. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  169. package/dist/server/src/services/index.d.ts +4 -4
  170. package/dist/server/src/services/index.d.ts.map +1 -1
  171. package/dist/server/src/services/permission-checker.d.ts.map +1 -1
  172. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  173. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  174. package/dist/server/src/utils/index.d.ts +2 -0
  175. package/dist/server/src/utils/index.d.ts.map +1 -1
  176. package/dist/shared/contracts/collection-types.d.ts +3 -1
  177. package/dist/shared/contracts/collection-types.d.ts.map +1 -1
  178. package/dist/shared/contracts/index.d.ts +1 -0
  179. package/dist/shared/contracts/index.d.ts.map +1 -1
  180. package/dist/shared/contracts/preview.d.ts +27 -0
  181. package/dist/shared/contracts/preview.d.ts.map +1 -0
  182. package/dist/shared/index.js +4 -0
  183. package/dist/shared/index.js.map +1 -1
  184. package/dist/shared/index.mjs +4 -0
  185. package/dist/shared/index.mjs.map +1 -1
  186. package/package.json +15 -15
  187. package/dist/_chunks/EditViewPage-BSVmMpRd.js.map +0 -1
  188. package/dist/_chunks/EditViewPage-C3tIZ8F5.mjs.map +0 -1
  189. package/dist/_chunks/Field-BvuT8cGL.mjs.map +0 -1
  190. package/dist/_chunks/Field-DUCVth4C.js.map +0 -1
  191. package/dist/_chunks/Form-BZmDNVr9.mjs.map +0 -1
  192. package/dist/_chunks/Form-Cpl4W1ak.js.map +0 -1
  193. package/dist/_chunks/History-Cq_Hrzuu.mjs.map +0 -1
  194. package/dist/_chunks/History-D4U2YISB.js.map +0 -1
  195. package/dist/_chunks/ListConfigurationPage-Bny6CdWe.js.map +0 -1
  196. package/dist/_chunks/ListConfigurationPage-W-KQHmBv.mjs.map +0 -1
  197. package/dist/_chunks/ListViewPage-HBBnJa8K.mjs.map +0 -1
  198. package/dist/_chunks/ListViewPage-O8F1pBJo.js.map +0 -1
  199. package/dist/_chunks/Relations-C4gGfZRv.js.map +0 -1
  200. package/dist/_chunks/Relations-vFZ6Wasg.mjs.map +0 -1
  201. package/dist/_chunks/index-5EMXLEM_.js.map +0 -1
  202. package/dist/_chunks/index-Dpxg3ctD.mjs.map +0 -1
  203. package/dist/_chunks/layout-C0INpKap.mjs.map +0 -1
  204. package/dist/_chunks/layout-P3eKO1Qy.js.map +0 -1
  205. package/dist/_chunks/relations-B1y0K6LE.js.map +0 -1
  206. package/dist/_chunks/relations-FBRRBWeO.mjs.map +0 -1
  207. package/dist/_chunks/usePrev-B9w_-eYc.js.map +0 -1
  208. package/dist/_chunks/usePrev-DH6iah0A.mjs +0 -16
  209. package/dist/_chunks/usePrev-DH6iah0A.mjs.map +0 -1
  210. package/strapi-server.js +0 -3
@@ -0,0 +1,272 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { useNotification, useClipboard, useQueryParams, createContext, useRBAC, Page } from "@strapi/admin/strapi-admin";
4
+ import { Box, Typography, Tabs, Grid, IconButton, Portal, FocusTrap, Flex } from "@strapi/design-system";
5
+ import { useIntl } from "react-intl";
6
+ import { Link as Link$1, useParams } from "react-router-dom";
7
+ import { D as DocumentStatus, l as DocumentRBAC, d as buildValidParams, C as COLLECTION_TYPES, K as useGetPreviewUrlQuery, J as useDocument, h as useDocumentLayout } from "./index-DLIkNVnQ.mjs";
8
+ import { Link, Cross } from "@strapi/icons";
9
+ import { stringify } from "qs";
10
+ import { styled } from "styled-components";
11
+ import { getDocumentStatus } from "./EditViewPage-CD_hqc1J.mjs";
12
+ const PreviewContent = () => {
13
+ const previewUrl = usePreviewContext("PreviewContent", (state) => state.url);
14
+ const { formatMessage } = useIntl();
15
+ return /* @__PURE__ */ jsx(
16
+ Box,
17
+ {
18
+ src: previewUrl,
19
+ title: formatMessage({
20
+ id: "content-manager.preview.panel.title",
21
+ defaultMessage: "Preview"
22
+ }),
23
+ width: "100%",
24
+ height: "100%",
25
+ borderWidth: 0,
26
+ tag: "iframe"
27
+ }
28
+ );
29
+ };
30
+ const ClosePreviewButton = () => {
31
+ const [{ query }] = useQueryParams();
32
+ const { formatMessage } = useIntl();
33
+ return /* @__PURE__ */ jsx(
34
+ IconButton,
35
+ {
36
+ tag: Link$1,
37
+ relative: "path",
38
+ to: {
39
+ pathname: "..",
40
+ search: stringify({ plugins: query.plugins }, { encode: false })
41
+ },
42
+ label: formatMessage({
43
+ id: "content-manager.preview.header.close",
44
+ defaultMessage: "Close preview"
45
+ }),
46
+ children: /* @__PURE__ */ jsx(Cross, {})
47
+ }
48
+ );
49
+ };
50
+ const Status = () => {
51
+ const document = usePreviewContext("PreviewHeader", (state) => state.document);
52
+ const schema = usePreviewContext("PreviewHeader", (state) => state.schema);
53
+ const meta = usePreviewContext("PreviewHeader", (state) => state.meta);
54
+ const hasDraftAndPublished = schema?.options?.draftAndPublish ?? false;
55
+ if (!hasDraftAndPublished) {
56
+ return null;
57
+ }
58
+ const status = getDocumentStatus(document, meta);
59
+ return /* @__PURE__ */ jsx(DocumentStatus, { status, size: "XS" });
60
+ };
61
+ const PreviewTabs = () => {
62
+ const { formatMessage } = useIntl();
63
+ const [{ query }, setQuery] = useQueryParams();
64
+ const document = usePreviewContext("PreviewHeader", (state) => state.document);
65
+ const schema = usePreviewContext("PreviewHeader", (state) => state.schema);
66
+ const meta = usePreviewContext("PreviewHeader", (state) => state.meta);
67
+ const hasDraftAndPublish = schema?.options?.draftAndPublish ?? false;
68
+ const documentStatus = getDocumentStatus(document, meta);
69
+ const handleTabChange = (status) => {
70
+ if (status === "published" || status === "draft") {
71
+ setQuery({ status }, "push", true);
72
+ }
73
+ };
74
+ if (!hasDraftAndPublish) {
75
+ return null;
76
+ }
77
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Tabs.Root, { variant: "simple", value: query.status || "draft", onValueChange: handleTabChange, children: /* @__PURE__ */ jsxs(
78
+ Tabs.List,
79
+ {
80
+ "aria-label": formatMessage({
81
+ id: "preview.tabs.label",
82
+ defaultMessage: "Document status"
83
+ }),
84
+ children: [
85
+ /* @__PURE__ */ jsx(StatusTab, { value: "draft", children: formatMessage({
86
+ id: "content-manager.containers.List.draft",
87
+ defaultMessage: "draft"
88
+ }) }),
89
+ /* @__PURE__ */ jsx(StatusTab, { value: "published", disabled: documentStatus === "draft", children: formatMessage({
90
+ id: "content-manager.containers.List.published",
91
+ defaultMessage: "published"
92
+ }) })
93
+ ]
94
+ }
95
+ ) }) });
96
+ };
97
+ const PreviewHeader = () => {
98
+ const mainField = usePreviewContext("PreviewHeader", (state) => state.mainField);
99
+ const document = usePreviewContext("PreviewHeader", (state) => state.document);
100
+ const title = document[mainField];
101
+ const { formatMessage } = useIntl();
102
+ const { toggleNotification } = useNotification();
103
+ const { copy } = useClipboard();
104
+ const handleCopyLink = () => {
105
+ copy(window.location.href);
106
+ toggleNotification({
107
+ message: formatMessage({
108
+ id: "content-manager.preview.copy.success",
109
+ defaultMessage: "Copied preview link"
110
+ }),
111
+ type: "success"
112
+ });
113
+ };
114
+ return /* @__PURE__ */ jsxs(
115
+ Grid.Root,
116
+ {
117
+ gap: 3,
118
+ gridCols: 3,
119
+ paddingLeft: 2,
120
+ paddingRight: 2,
121
+ background: "neutral0",
122
+ borderColor: "neutral150",
123
+ tag: "header",
124
+ children: [
125
+ /* @__PURE__ */ jsxs(Grid.Item, { xs: 1, paddingTop: 2, paddingBottom: 2, gap: 3, children: [
126
+ /* @__PURE__ */ jsx(ClosePreviewButton, {}),
127
+ /* @__PURE__ */ jsx(PreviewTitle, { tag: "h1", fontWeight: 600, fontSize: 2, maxWidth: "200px", children: title }),
128
+ /* @__PURE__ */ jsx(Status, {})
129
+ ] }),
130
+ /* @__PURE__ */ jsx(Grid.Item, { xs: 1, marginBottom: "-1px", alignItems: "end", margin: "auto", children: /* @__PURE__ */ jsx(PreviewTabs, {}) }),
131
+ /* @__PURE__ */ jsx(Grid.Item, { xs: 1, justifyContent: "end", paddingTop: 2, paddingBottom: 2, children: /* @__PURE__ */ jsx(
132
+ IconButton,
133
+ {
134
+ type: "button",
135
+ label: formatMessage({
136
+ id: "preview.copy.label",
137
+ defaultMessage: "Copy preview link"
138
+ }),
139
+ onClick: handleCopyLink,
140
+ children: /* @__PURE__ */ jsx(Link, {})
141
+ }
142
+ ) })
143
+ ]
144
+ }
145
+ );
146
+ };
147
+ const PreviewTitle = styled(Typography)`
148
+ overflow: hidden;
149
+ text-overflow: ellipsis;
150
+ white-space: nowrap;
151
+ `;
152
+ const StatusTab = styled(Tabs.Trigger)`
153
+ text-transform: uppercase;
154
+ `;
155
+ const [PreviewProvider, usePreviewContext] = createContext("PreviewPage");
156
+ const PreviewPage = () => {
157
+ const { formatMessage } = useIntl();
158
+ const {
159
+ slug: model,
160
+ id: documentId,
161
+ collectionType
162
+ } = useParams();
163
+ const [{ query }] = useQueryParams();
164
+ const params = React.useMemo(() => buildValidParams(query), [query]);
165
+ if (!collectionType) {
166
+ throw new Error("Could not find collectionType in url params");
167
+ }
168
+ if (!model) {
169
+ throw new Error("Could not find model in url params");
170
+ }
171
+ if (collectionType === COLLECTION_TYPES && !documentId) {
172
+ throw new Error("Could not find documentId in url params");
173
+ }
174
+ const previewUrlResponse = useGetPreviewUrlQuery({
175
+ params: {
176
+ contentType: model
177
+ },
178
+ query: {
179
+ documentId,
180
+ locale: params.locale,
181
+ status: params.status
182
+ }
183
+ });
184
+ const documentResponse = useDocument({
185
+ model,
186
+ collectionType,
187
+ documentId,
188
+ params
189
+ });
190
+ const documentLayoutResponse = useDocumentLayout(model);
191
+ if (documentResponse.isLoading || previewUrlResponse.isLoading || documentLayoutResponse.isLoading) {
192
+ return /* @__PURE__ */ jsx(Page.Loading, {});
193
+ }
194
+ if (previewUrlResponse.error || documentLayoutResponse.error || !documentResponse.document || !documentResponse.meta || !documentResponse.schema) {
195
+ return /* @__PURE__ */ jsx(Page.Error, {});
196
+ }
197
+ if (!previewUrlResponse.data?.data?.url) {
198
+ return /* @__PURE__ */ jsx(Page.NoData, {});
199
+ }
200
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
201
+ /* @__PURE__ */ jsx(Page.Title, { children: formatMessage(
202
+ {
203
+ id: "content-manager.preview.page-title",
204
+ defaultMessage: "{contentType} preview"
205
+ },
206
+ {
207
+ contentType: documentLayoutResponse.edit.settings.displayName
208
+ }
209
+ ) }),
210
+ /* @__PURE__ */ jsx(
211
+ PreviewProvider,
212
+ {
213
+ url: previewUrlResponse.data.data.url,
214
+ mainField: documentLayoutResponse.edit.settings.mainField,
215
+ document: documentResponse.document,
216
+ meta: documentResponse.meta,
217
+ schema: documentResponse.schema,
218
+ children: /* @__PURE__ */ jsxs(Flex, { direction: "column", height: "100%", alignItems: "stretch", children: [
219
+ /* @__PURE__ */ jsx(PreviewHeader, {}),
220
+ /* @__PURE__ */ jsx(PreviewContent, {})
221
+ ] })
222
+ }
223
+ )
224
+ ] });
225
+ };
226
+ const ProtectedPreviewPageImpl = () => {
227
+ const { slug: model } = useParams();
228
+ const {
229
+ permissions = [],
230
+ isLoading,
231
+ error
232
+ } = useRBAC([{ action: "plugin::content-manager.explorer.read", subject: model }]);
233
+ if (isLoading) {
234
+ return /* @__PURE__ */ jsx(Page.Loading, {});
235
+ }
236
+ if (error || !model) {
237
+ return /* @__PURE__ */ jsx(
238
+ Box,
239
+ {
240
+ height: "100vh",
241
+ width: "100vw",
242
+ position: "fixed",
243
+ top: 0,
244
+ left: 0,
245
+ zIndex: 2,
246
+ background: "neutral0",
247
+ children: /* @__PURE__ */ jsx(Page.Error, {})
248
+ }
249
+ );
250
+ }
251
+ return /* @__PURE__ */ jsx(
252
+ Box,
253
+ {
254
+ height: "100vh",
255
+ width: "100vw",
256
+ position: "fixed",
257
+ top: 0,
258
+ left: 0,
259
+ zIndex: 2,
260
+ background: "neutral0",
261
+ children: /* @__PURE__ */ jsx(Page.Protect, { permissions, children: ({ permissions: permissions2 }) => /* @__PURE__ */ jsx(DocumentRBAC, { permissions: permissions2, children: /* @__PURE__ */ jsx(PreviewPage, {}) }) })
262
+ }
263
+ );
264
+ };
265
+ const ProtectedPreviewPage = () => {
266
+ return /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(FocusTrap, { children: /* @__PURE__ */ jsx(ProtectedPreviewPageImpl, {}) }) });
267
+ };
268
+ export {
269
+ ProtectedPreviewPage,
270
+ usePreviewContext
271
+ };
272
+ //# sourceMappingURL=Preview-BVFFm7uB.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Preview-BVFFm7uB.mjs","sources":["../../admin/src/preview/components/PreviewContent.tsx","../../admin/src/preview/components/PreviewHeader.tsx","../../admin/src/preview/pages/Preview.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\n\nimport { usePreviewContext } from '../pages/Preview';\n\nconst PreviewContent = () => {\n const previewUrl = usePreviewContext('PreviewContent', (state) => state.url);\n\n const { formatMessage } = useIntl();\n\n return (\n <Box\n src={previewUrl}\n title={formatMessage({\n id: 'content-manager.preview.panel.title',\n defaultMessage: 'Preview',\n })}\n width=\"100%\"\n height=\"100%\"\n borderWidth={0}\n tag=\"iframe\"\n />\n );\n};\n\nexport { PreviewContent };\n","import * as React from 'react';\n\nimport { useClipboard, useNotification, useQueryParams } from '@strapi/admin/strapi-admin';\nimport {\n Box,\n type BoxProps,\n Flex,\n IconButton,\n Tabs,\n Typography,\n Grid,\n} from '@strapi/design-system';\nimport { Cross, Link as LinkIcon } from '@strapi/icons';\nimport { stringify } from 'qs';\nimport { type MessageDescriptor, useIntl } from 'react-intl';\nimport { Link } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { DocumentStatus } from '../../pages/EditView/components/DocumentStatus';\nimport { getDocumentStatus } from '../../pages/EditView/EditViewPage';\nimport { usePreviewContext } from '../pages/Preview';\n\n/* -------------------------------------------------------------------------------------------------\n * ClosePreviewButton\n * -----------------------------------------------------------------------------------------------*/\n\nconst ClosePreviewButton = () => {\n const [{ query }] = useQueryParams<{\n plugins?: Record<string, unknown>;\n }>();\n const { formatMessage } = useIntl();\n\n return (\n <IconButton\n tag={Link}\n relative=\"path\"\n to={{\n pathname: '..',\n search: stringify({ plugins: query.plugins }, { encode: false }),\n }}\n label={formatMessage({\n id: 'content-manager.preview.header.close',\n defaultMessage: 'Close preview',\n })}\n >\n <Cross />\n </IconButton>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Status\n * -----------------------------------------------------------------------------------------------*/\n\nconst Status = () => {\n // Get status\n const document = usePreviewContext('PreviewHeader', (state) => state.document);\n const schema = usePreviewContext('PreviewHeader', (state) => state.schema);\n const meta = usePreviewContext('PreviewHeader', (state) => state.meta);\n const hasDraftAndPublished = schema?.options?.draftAndPublish ?? false;\n\n if (!hasDraftAndPublished) {\n return null;\n }\n\n const status = getDocumentStatus(document, meta);\n\n return <DocumentStatus status={status} size=\"XS\" />;\n};\n\nconst PreviewTabs = () => {\n const { formatMessage } = useIntl();\n\n // URL query params\n const [{ query }, setQuery] = useQueryParams<{ status: 'draft' | 'published' }>();\n\n // Get status\n const document = usePreviewContext('PreviewHeader', (state) => state.document);\n const schema = usePreviewContext('PreviewHeader', (state) => state.schema);\n const meta = usePreviewContext('PreviewHeader', (state) => state.meta);\n const hasDraftAndPublish = schema?.options?.draftAndPublish ?? false;\n const documentStatus = getDocumentStatus(document, meta);\n\n const handleTabChange = (status: string) => {\n if (status === 'published' || status === 'draft') {\n setQuery({ status }, 'push', true);\n }\n };\n\n if (!hasDraftAndPublish) {\n return null;\n }\n\n return (\n <>\n <Tabs.Root variant=\"simple\" value={query.status || 'draft'} onValueChange={handleTabChange}>\n <Tabs.List\n aria-label={formatMessage({\n id: 'preview.tabs.label',\n defaultMessage: 'Document status',\n })}\n >\n <StatusTab value=\"draft\">\n {formatMessage({\n id: 'content-manager.containers.List.draft',\n defaultMessage: 'draft',\n })}\n </StatusTab>\n <StatusTab value=\"published\" disabled={documentStatus === 'draft'}>\n {formatMessage({\n id: 'content-manager.containers.List.published',\n defaultMessage: 'published',\n })}\n </StatusTab>\n </Tabs.List>\n </Tabs.Root>\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * PreviewHeader\n * -----------------------------------------------------------------------------------------------*/\n\nconst PreviewHeader = () => {\n // Get main field\n const mainField = usePreviewContext('PreviewHeader', (state) => state.mainField);\n const document = usePreviewContext('PreviewHeader', (state) => state.document);\n const title = document[mainField];\n\n const { formatMessage } = useIntl();\n const { toggleNotification } = useNotification();\n const { copy } = useClipboard();\n\n const handleCopyLink = () => {\n copy(window.location.href);\n toggleNotification({\n message: formatMessage({\n id: 'content-manager.preview.copy.success',\n defaultMessage: 'Copied preview link',\n }),\n type: 'success',\n });\n };\n\n return (\n <Grid.Root\n gap={3}\n gridCols={3}\n paddingLeft={2}\n paddingRight={2}\n background=\"neutral0\"\n borderColor=\"neutral150\"\n tag=\"header\"\n >\n {/* Title and status */}\n <Grid.Item xs={1} paddingTop={2} paddingBottom={2} gap={3}>\n <ClosePreviewButton />\n <PreviewTitle tag=\"h1\" fontWeight={600} fontSize={2} maxWidth=\"200px\">\n {title}\n </PreviewTitle>\n <Status />\n </Grid.Item>\n {/* Tabs */}\n <Grid.Item xs={1} marginBottom=\"-1px\" alignItems=\"end\" margin=\"auto\">\n <PreviewTabs />\n </Grid.Item>\n {/* Copy link */}\n <Grid.Item xs={1} justifyContent=\"end\" paddingTop={2} paddingBottom={2}>\n <IconButton\n type=\"button\"\n label={formatMessage({\n id: 'preview.copy.label',\n defaultMessage: 'Copy preview link',\n })}\n onClick={handleCopyLink}\n >\n <LinkIcon />\n </IconButton>\n </Grid.Item>\n </Grid.Root>\n );\n};\n\nconst PreviewTitle = styled(Typography)`\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n`;\n\nconst StatusTab = styled(Tabs.Trigger)`\n text-transform: uppercase;\n`;\n\nexport { PreviewHeader };\n","import * as React from 'react';\n\nimport { Page, useQueryParams, useRBAC, createContext } from '@strapi/admin/strapi-admin';\nimport { Box, Flex, FocusTrap, Portal } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { useParams } from 'react-router-dom';\n\nimport { GetPreviewUrl } from '../../../../shared/contracts/preview';\nimport { COLLECTION_TYPES } from '../../constants/collections';\nimport { DocumentRBAC } from '../../features/DocumentRBAC';\nimport { type UseDocument, useDocument } from '../../hooks/useDocument';\nimport { useDocumentLayout } from '../../hooks/useDocumentLayout';\nimport { buildValidParams } from '../../utils/api';\nimport { PreviewContent } from '../components/PreviewContent';\nimport { PreviewHeader } from '../components/PreviewHeader';\nimport { useGetPreviewUrlQuery } from '../services/preview';\n\nimport type { UID } from '@strapi/types';\n\n/* -------------------------------------------------------------------------------------------------\n * PreviewProvider\n * -----------------------------------------------------------------------------------------------*/\n\ninterface PreviewContextValue {\n url: string;\n mainField: string;\n document: NonNullable<ReturnType<UseDocument>['document']>;\n meta: NonNullable<ReturnType<UseDocument>['meta']>;\n schema: NonNullable<ReturnType<UseDocument>['schema']>;\n}\n\nconst [PreviewProvider, usePreviewContext] = createContext<PreviewContextValue>('PreviewPage');\n\n/* -------------------------------------------------------------------------------------------------\n * PreviewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst PreviewPage = () => {\n const { formatMessage } = useIntl();\n\n // Read all the necessary data from the URL to find the right preview URL\n const {\n slug: model,\n id: documentId,\n collectionType,\n } = useParams<{\n slug: UID.ContentType;\n id: string;\n collectionType: string;\n }>();\n const [{ query }] = useQueryParams<{\n plugins?: Record<string, unknown>;\n }>();\n\n const params = React.useMemo(() => buildValidParams(query), [query]);\n\n if (!collectionType) {\n throw new Error('Could not find collectionType in url params');\n }\n\n if (!model) {\n throw new Error('Could not find model in url params');\n }\n\n // Only collection types must have a documentId\n if (collectionType === COLLECTION_TYPES && !documentId) {\n throw new Error('Could not find documentId in url params');\n }\n\n const previewUrlResponse = useGetPreviewUrlQuery({\n params: {\n contentType: model,\n },\n query: {\n documentId,\n locale: params.locale,\n status: params.status as GetPreviewUrl.Request['query']['status'],\n },\n });\n\n const documentResponse = useDocument({\n model,\n collectionType,\n documentId,\n params,\n });\n\n const documentLayoutResponse = useDocumentLayout(model);\n\n if (\n documentResponse.isLoading ||\n previewUrlResponse.isLoading ||\n documentLayoutResponse.isLoading\n ) {\n return <Page.Loading />;\n }\n\n if (\n previewUrlResponse.error ||\n documentLayoutResponse.error ||\n !documentResponse.document ||\n !documentResponse.meta ||\n !documentResponse.schema\n ) {\n return <Page.Error />;\n }\n\n if (!previewUrlResponse.data?.data?.url) {\n return <Page.NoData />;\n }\n\n return (\n <>\n <Page.Title>\n {formatMessage(\n {\n id: 'content-manager.preview.page-title',\n defaultMessage: '{contentType} preview',\n },\n {\n contentType: documentLayoutResponse.edit.settings.displayName,\n }\n )}\n </Page.Title>\n <PreviewProvider\n url={previewUrlResponse.data.data.url}\n mainField={documentLayoutResponse.edit.settings.mainField}\n document={documentResponse.document}\n meta={documentResponse.meta}\n schema={documentResponse.schema}\n >\n <Flex direction=\"column\" height=\"100%\" alignItems={'stretch'}>\n <PreviewHeader />\n <PreviewContent />\n </Flex>\n </PreviewProvider>\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ProtectedPreviewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst ProtectedPreviewPageImpl = () => {\n const { slug: model } = useParams<{\n slug: string;\n }>();\n const {\n permissions = [],\n isLoading,\n error,\n } = useRBAC([{ action: 'plugin::content-manager.explorer.read', subject: model }]);\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || !model) {\n return (\n <Box\n height=\"100vh\"\n width=\"100vw\"\n position=\"fixed\"\n top={0}\n left={0}\n zIndex={2}\n background=\"neutral0\"\n >\n <Page.Error />\n </Box>\n );\n }\n\n return (\n <Box\n height=\"100vh\"\n width=\"100vw\"\n position=\"fixed\"\n top={0}\n left={0}\n zIndex={2}\n background=\"neutral0\"\n >\n <Page.Protect permissions={permissions}>\n {({ permissions }) => (\n <DocumentRBAC permissions={permissions}>\n <PreviewPage />\n </DocumentRBAC>\n )}\n </Page.Protect>\n </Box>\n );\n};\n\nconst ProtectedPreviewPage = () => {\n return (\n <Portal>\n <FocusTrap>\n <ProtectedPreviewPageImpl />\n </FocusTrap>\n </Portal>\n );\n};\n\nexport { ProtectedPreviewPage, usePreviewContext };\n"],"names":["Link","LinkIcon","permissions"],"mappings":";;;;;;;;;;;AAOA,MAAM,iBAAiB,MAAM;AAC3B,QAAM,aAAa,kBAAkB,kBAAkB,CAAC,UAAU,MAAM,GAAG;AAErE,QAAA,EAAE,cAAc,IAAI,QAAQ;AAGhC,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAK;AAAA,MACL,OAAO,cAAc;AAAA,QACnB,IAAI;AAAA,QACJ,gBAAgB;AAAA,MAAA,CACjB;AAAA,MACD,OAAM;AAAA,MACN,QAAO;AAAA,MACP,aAAa;AAAA,MACb,KAAI;AAAA,IAAA;AAAA,EACN;AAEJ;ACCA,MAAM,qBAAqB,MAAM;AAC/B,QAAM,CAAC,EAAE,OAAO,IAAI,eAEjB;AACG,QAAA,EAAE,cAAc,IAAI,QAAQ;AAGhC,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAKA;AAAAA,MACL,UAAS;AAAA,MACT,IAAI;AAAA,QACF,UAAU;AAAA,QACV,QAAQ,UAAU,EAAE,SAAS,MAAM,WAAW,EAAE,QAAQ,MAAO,CAAA;AAAA,MACjE;AAAA,MACA,OAAO,cAAc;AAAA,QACnB,IAAI;AAAA,QACJ,gBAAgB;AAAA,MAAA,CACjB;AAAA,MAED,8BAAC,OAAM,CAAA,CAAA;AAAA,IAAA;AAAA,EACT;AAEJ;AAMA,MAAM,SAAS,MAAM;AAEnB,QAAM,WAAW,kBAAkB,iBAAiB,CAAC,UAAU,MAAM,QAAQ;AAC7E,QAAM,SAAS,kBAAkB,iBAAiB,CAAC,UAAU,MAAM,MAAM;AACzE,QAAM,OAAO,kBAAkB,iBAAiB,CAAC,UAAU,MAAM,IAAI;AAC/D,QAAA,uBAAuB,QAAQ,SAAS,mBAAmB;AAEjE,M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ACC,QAAO;AAAA,QACP,OAAM;AAAA,QACN,UAAS;AAAA,QACT,KAAK;AAAA,QACL,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,YAAW;AAAA,QAEX,UAAA,oBAAC,KAAK,OAAL,CAAW,CAAA;AAAA,MAAA;AAAA,IACd;AAAA,EAAA;AAKF,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,QAAO;AAAA,MACP,OAAM;AAAA,MACN,UAAS;AAAA,MACT,KAAK;AAAA,MACL,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,YAAW;AAAA,MAEX,8BAAC,KAAK,SAAL,EAAa,aACX,WAAC,EAAE,aAAAC,aAAY,0BACb,cAAa,EAAA,aAAaA,cACzB,UAAC,oBAAA,aAAA,EAAY,GACf,EAEJ,CAAA;AAAA,IAAA;AAAA,EACF;AAEJ;AAEA,MAAM,uBAAuB,MAAM;AACjC,6BACG,QACC,EAAA,UAAA,oBAAC,aACC,UAAC,oBAAA,0BAAA,EAAyB,GAC5B,EACF,CAAA;AAEJ;"}
@@ -11,13 +11,12 @@ const reactIntl = require("react-intl");
11
11
  const reactRouterDom = require("react-router-dom");
12
12
  const reactWindow = require("react-window");
13
13
  const styledComponents = require("styled-components");
14
- const index = require("./index-5EMXLEM_.js");
15
- const useDragAndDrop = require("./useDragAndDrop-J0TUUbR6.js");
16
- const relations = require("./relations-B1y0K6LE.js");
14
+ const index = require("./index-C2Q_PLWj.js");
15
+ const useDragAndDrop = require("./useDragAndDrop-BMtgCYzL.js");
16
+ const relations = require("./relations-EifVzf_2.js");
17
17
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
18
18
  function _interopNamespace(e) {
19
- if (e && e.__esModule)
20
- return e;
19
+ if (e && e.__esModule) return e;
21
20
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
22
21
  if (e) {
23
22
  for (const k in e) {
@@ -41,6 +40,31 @@ const [ComponentProvider, useComponent] = strapiAdmin.createContext("ComponentCo
41
40
  uid: void 0,
42
41
  type: void 0
43
42
  });
43
+ function useHandleDisconnect(fieldName, consumerName) {
44
+ const field = strapiAdmin.useField(fieldName);
45
+ const removeFieldRow = strapiAdmin.useForm(consumerName, (state) => state.removeFieldRow);
46
+ const addFieldRow = strapiAdmin.useForm(consumerName, (state) => state.addFieldRow);
47
+ const handleDisconnect = (relation) => {
48
+ if (field.value && field.value.connect) {
49
+ const indexOfRelationInConnectArray = field.value.connect.findIndex(
50
+ (rel) => rel.id === relation.id
51
+ );
52
+ if (indexOfRelationInConnectArray >= 0) {
53
+ removeFieldRow(`${fieldName}.connect`, indexOfRelationInConnectArray);
54
+ return;
55
+ }
56
+ }
57
+ addFieldRow(`${fieldName}.disconnect`, {
58
+ id: relation.id,
59
+ apiData: {
60
+ id: relation.id,
61
+ documentId: relation.documentId,
62
+ locale: relation.locale
63
+ }
64
+ });
65
+ };
66
+ return handleDisconnect;
67
+ }
44
68
  const RELATIONS_TO_DISPLAY = 5;
45
69
  const ONE_WAY_RELATIONS = ["oneWay", "oneToOne", "manyToOne", "oneToManyMorph", "oneToOneMorph"];
46
70
  const RelationsField = React__namespace.forwardRef(
@@ -53,9 +77,16 @@ const RelationsField = React__namespace.forwardRef(
53
77
  const params = index.buildValidParams(query);
54
78
  const isMorph = props.attribute.relation.toLowerCase().includes("morph");
55
79
  const isDisabled = isMorph || disabled;
56
- const { id: componentId, uid } = useComponent("RelationsField", ({ uid: uid2, id: id2 }) => ({ id: id2, uid: uid2 }));
80
+ const { componentId, componentUID } = useComponent("RelationsField", ({ uid, id: id2 }) => ({
81
+ componentId: id2,
82
+ componentUID: uid
83
+ }));
84
+ const isSubmitting = strapiAdmin.useForm("RelationsList", (state) => state.isSubmitting);
85
+ React__namespace.useEffect(() => {
86
+ setCurrentPage(1);
87
+ }, [isSubmitting]);
57
88
  const id = componentId ? componentId.toString() : documentId;
58
- const model = uid ?? documentModel;
89
+ const model = componentUID ?? documentModel;
59
90
  const [targetField] = props.name.split(".").slice(-1);
60
91
  const { data, isLoading, isFetching } = relations.useGetRelationsQuery(
61
92
  {
@@ -108,10 +139,8 @@ const RelationsField = React__namespace.forwardRef(
108
139
  );
109
140
  const transformedRels = transformations([...data.results]);
110
141
  return [...transformedRels, ...field.value?.connect ?? []].sort((a, b) => {
111
- if (a.__temp_key__ < b.__temp_key__)
112
- return -1;
113
- if (a.__temp_key__ > b.__temp_key__)
114
- return 1;
142
+ if (a.__temp_key__ < b.__temp_key__) return -1;
143
+ if (a.__temp_key__ > b.__temp_key__) return 1;
115
144
  return 0;
116
145
  });
117
146
  }, [
@@ -121,10 +150,16 @@ const RelationsField = React__namespace.forwardRef(
121
150
  props.attribute.targetModel,
122
151
  props.mainField
123
152
  ]);
153
+ const handleDisconnect = useHandleDisconnect(props.name, "RelationsField");
124
154
  const handleConnect = (relation) => {
125
155
  const [lastItemInList] = relations$1.slice(-1);
126
156
  const item = {
127
157
  id: relation.id,
158
+ apiData: {
159
+ id: relation.id,
160
+ documentId: relation.documentId,
161
+ locale: relation.locale
162
+ },
128
163
  status: relation.status,
129
164
  /**
130
165
  * If there's a last item, that's the first key we use to generate out next one.
@@ -134,9 +169,11 @@ const RelationsField = React__namespace.forwardRef(
134
169
  [props.mainField?.name ?? "documentId"]: relation[props.mainField?.name ?? "documentId"],
135
170
  label: relations.getRelationLabel(relation, props.mainField),
136
171
  // @ts-expect-error – targetModel does exist on the attribute, but it's not typed.
137
- href: `../${index.COLLECTION_TYPES}/${props.attribute.targetModel}/${relation.documentId}`
172
+ href: `../${index.COLLECTION_TYPES}/${props.attribute.targetModel}/${relation.documentId}?${relation.locale ? `plugins[i18n][locale]=${relation.locale}` : ""}`
138
173
  };
139
174
  if (ONE_WAY_RELATIONS.includes(props.attribute.relation)) {
175
+ field.value?.connect?.forEach(handleDisconnect);
176
+ relations$1.forEach(handleDisconnect);
140
177
  field.onChange(`${props.name}.connect`, [item]);
141
178
  } else {
142
179
  field.onChange(`${props.name}.connect`, [...field.value?.connect ?? [], item]);
@@ -157,7 +194,7 @@ const RelationsField = React__namespace.forwardRef(
157
194
  RelationsInput,
158
195
  {
159
196
  disabled: isDisabled,
160
- id,
197
+ id: componentUID ? componentId ? `${componentId}` : "" : documentId,
161
198
  label: `${label} ${relationsCount > 0 ? `(${relationsCount})` : ""}`,
162
199
  model,
163
200
  onChange: handleConnect,
@@ -216,7 +253,7 @@ const addLabelAndHref = ({ mainField, href }) => (relations$1) => relations$1.ma
216
253
  // Fallback to `id` if there is no `mainField` value, which will overwrite the above `documentId` property with the exact same data.
217
254
  [mainField?.name ?? "documentId"]: relation[mainField?.name ?? "documentId"],
218
255
  label: relations.getRelationLabel(relation, mainField),
219
- href: `${href}/${relation.documentId}`
256
+ href: `${href}/${relation.documentId}?${relation.locale ? `plugins[i18n][locale]=${relation.locale}` : ""}`
220
257
  };
221
258
  });
222
259
  const RelationsInput = ({
@@ -311,7 +348,7 @@ const RelationsInput = ({
311
348
  {
312
349
  ref: fieldRef,
313
350
  name,
314
- autocomplete: "none",
351
+ autocomplete: "list",
315
352
  placeholder: placeholder || formatMessage({
316
353
  id: index.getTranslation("relation.add"),
317
354
  defaultMessage: "Add relation"
@@ -369,8 +406,6 @@ const RelationsList = ({
369
406
  const [overflow, setOverflow] = React__namespace.useState();
370
407
  const [liveText, setLiveText] = React__namespace.useState("");
371
408
  const field = strapiAdmin.useField(name);
372
- const removeFieldRow = strapiAdmin.useForm("RelationsList", (state) => state.removeFieldRow);
373
- const addFieldRow = strapiAdmin.useForm("RelationsList", (state) => state.addFieldRow);
374
409
  React__namespace.useEffect(() => {
375
410
  if (data.length <= RELATIONS_TO_DISPLAY) {
376
411
  return setOverflow(void 0);
@@ -420,17 +455,25 @@ const RelationsList = ({
420
455
  newData.splice(oldIndex, 1);
421
456
  newData.splice(newIndex, 0, { ...currentRow, __temp_key__: newKey });
422
457
  const connectedRelations = newData.reduce((acc, relation, currentIndex, array) => {
423
- const relationOnServer = serverData.find(
424
- (oldRelation) => oldRelation.documentId === relation.documentId
425
- );
458
+ const relationOnServer = serverData.find((oldRelation) => oldRelation.id === relation.id);
426
459
  const relationInFront = array[currentIndex + 1];
427
460
  if (!relationOnServer || relationOnServer.__temp_key__ !== relation.__temp_key__) {
428
461
  const position = relationInFront ? {
429
462
  before: relationInFront.documentId,
430
463
  locale: relationInFront.locale,
431
- status: relationInFront.status
464
+ status: "publishedAt" in relationInFront && relationInFront.publishedAt ? "published" : "draft"
432
465
  } : { end: true };
433
- const relationWithPosition = { ...relation, position };
466
+ const relationWithPosition = {
467
+ ...relation,
468
+ ...{
469
+ apiData: {
470
+ id: relation.id,
471
+ documentId: relation.documentId,
472
+ locale: relation.locale,
473
+ position
474
+ }
475
+ }
476
+ };
434
477
  return [...acc, relationWithPosition];
435
478
  }
436
479
  return acc;
@@ -481,18 +524,7 @@ const RelationsList = ({
481
524
  )
482
525
  );
483
526
  };
484
- const handleDisconnect = (relation) => {
485
- if (field.value && field.value.connect) {
486
- const indexOfRelationInConnectArray = field.value.connect.findIndex(
487
- (rel) => rel.id === relation.id
488
- );
489
- if (indexOfRelationInConnectArray >= 0) {
490
- removeFieldRow(`${name}.connect`, indexOfRelationInConnectArray);
491
- return;
492
- }
493
- }
494
- addFieldRow(`${name}.disconnect`, { id: relation.id });
495
- };
527
+ const handleDisconnect = useHandleDisconnect(name, "RelationsList");
496
528
  const canReorder = !ONE_WAY_RELATIONS.includes(relationType);
497
529
  const dynamicListHeight = data.length > RELATIONS_TO_DISPLAY ? Math.min(data.length, RELATIONS_TO_DISPLAY) * (RELATION_ITEM_HEIGHT + RELATION_GUTTER) + RELATION_ITEM_HEIGHT / 2 : Math.min(data.length, RELATIONS_TO_DISPLAY) * (RELATION_ITEM_HEIGHT + RELATION_GUTTER);
498
530
  return /* @__PURE__ */ jsxRuntime.jsxs(ShadowBox, { $overflowDirection: overflow, children: [
@@ -573,7 +605,7 @@ const ListItem = ({ data, index: index$1, style }) => {
573
605
  relations: relations2
574
606
  } = data;
575
607
  const { formatMessage } = reactIntl.useIntl();
576
- const { href, documentId, label, status } = relations2[index$1];
608
+ const { href, id, label, status } = relations2[index$1];
577
609
  const [{ handlerId, isDragging, handleKeyDown }, relationRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop.useDragAndDrop(
578
610
  canDrag && !disabled,
579
611
  {
@@ -582,7 +614,7 @@ const ListItem = ({ data, index: index$1, style }) => {
582
614
  item: {
583
615
  displayedValue: label,
584
616
  status,
585
- id: documentId,
617
+ id,
586
618
  index: index$1
587
619
  },
588
620
  onMoveItem: handleMoveItem,
@@ -630,7 +662,7 @@ const ListItem = ({ data, index: index$1, style }) => {
630
662
  id: index.getTranslation("components.RelationInput.icon-button-aria-label"),
631
663
  defaultMessage: "Drag"
632
664
  }),
633
- borderWidth: 0,
665
+ variant: "ghost",
634
666
  onKeyDown: handleKeyDown,
635
667
  disabled,
636
668
  children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, {})
@@ -642,16 +674,17 @@ const ListItem = ({ data, index: index$1, style }) => {
642
674
  ] })
643
675
  ] }),
644
676
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 4, children: /* @__PURE__ */ jsxRuntime.jsx(
645
- DisconnectButton,
677
+ designSystem.IconButton,
646
678
  {
647
- disabled,
648
- type: "button",
649
679
  onClick: () => handleDisconnect(relations2[index$1]),
650
- "aria-label": formatMessage({
680
+ disabled,
681
+ label: formatMessage({
651
682
  id: index.getTranslation("relation.disconnect"),
652
683
  defaultMessage: "Remove"
653
684
  }),
654
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, { width: "12px" })
685
+ variant: "ghost",
686
+ size: "S",
687
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {})
655
688
  }
656
689
  ) })
657
690
  ]
@@ -711,4 +744,4 @@ exports.FlexWrapper = FlexWrapper;
711
744
  exports.LinkEllipsis = LinkEllipsis;
712
745
  exports.MemoizedRelationsField = MemoizedRelationsField;
713
746
  exports.useComponent = useComponent;
714
- //# sourceMappingURL=Relations-C4gGfZRv.js.map
747
+ //# sourceMappingURL=Relations-BmYR1AjY.js.map