@strapi/content-manager 0.0.0-experimental.c592deb623aed3f74ef7fdacfad9757ed59d34f7 → 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 (183) 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-7-qB29e7.mjs → ComponentConfigurationPage-BgCLcjXO.mjs} +4 -4
  4. package/dist/_chunks/{ComponentConfigurationPage-7-qB29e7.mjs.map → ComponentConfigurationPage-BgCLcjXO.mjs.map} +1 -1
  5. package/dist/_chunks/{ComponentConfigurationPage-DP7AC0UU.js → ComponentConfigurationPage-DywpTZeV.js} +5 -6
  6. package/dist/_chunks/{ComponentConfigurationPage-DP7AC0UU.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-CI4XoymK.mjs → EditConfigurationPage-BNjOAHNS.mjs} +4 -4
  11. package/dist/_chunks/{EditConfigurationPage-CI4XoymK.mjs.map → EditConfigurationPage-BNjOAHNS.mjs.map} +1 -1
  12. package/dist/_chunks/{EditConfigurationPage-DITVliEI.js → EditConfigurationPage-CxRlP5if.js} +5 -6
  13. package/dist/_chunks/{EditConfigurationPage-DITVliEI.js.map → EditConfigurationPage-CxRlP5if.js.map} +1 -1
  14. package/dist/_chunks/{EditViewPage-CUS2EAhB.js → EditViewPage-BRewdTqE.js} +45 -10
  15. package/dist/_chunks/EditViewPage-BRewdTqE.js.map +1 -0
  16. package/dist/_chunks/{EditViewPage-Dzpno8xI.mjs → EditViewPage-CD_hqc1J.mjs} +45 -9
  17. package/dist/_chunks/EditViewPage-CD_hqc1J.mjs.map +1 -0
  18. package/dist/_chunks/{Field-B_jG_EV9.mjs → Field-BPkQ-3Ku.mjs} +102 -70
  19. package/dist/_chunks/Field-BPkQ-3Ku.mjs.map +1 -0
  20. package/dist/_chunks/{Field-CtUU1Fg8.js → Field-DwvmENVf.js} +103 -72
  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-DTqO0ymI.js → Form-C_Gwv8P_.js} +6 -7
  25. package/dist/_chunks/Form-C_Gwv8P_.js.map +1 -0
  26. package/dist/_chunks/{Form-BXHao2mZ.mjs → Form-Czi0cf_2.mjs} +4 -4
  27. package/dist/_chunks/Form-Czi0cf_2.mjs.map +1 -0
  28. package/dist/_chunks/{History-C_uSGzO5.js → History-C1TKAig-.js} +42 -100
  29. package/dist/_chunks/History-C1TKAig-.js.map +1 -0
  30. package/dist/_chunks/{History-2Ah2CQ4T.mjs → History-CIQHyi4T.mjs} +43 -100
  31. package/dist/_chunks/History-CIQHyi4T.mjs.map +1 -0
  32. package/dist/_chunks/{ListConfigurationPage-nyuP7OSy.js → ListConfigurationPage-D-NGRLYu.js} +7 -7
  33. package/dist/_chunks/ListConfigurationPage-D-NGRLYu.js.map +1 -0
  34. package/dist/_chunks/{ListConfigurationPage-BjSJlaoC.mjs → ListConfigurationPage-DcZsfyEL.mjs} +7 -6
  35. package/dist/_chunks/ListConfigurationPage-DcZsfyEL.mjs.map +1 -0
  36. package/dist/_chunks/{ListViewPage-B75x3nz2.mjs → ListViewPage-C10McTK1.mjs} +62 -39
  37. package/dist/_chunks/ListViewPage-C10McTK1.mjs.map +1 -0
  38. package/dist/_chunks/{ListViewPage-DHgHD8Xg.js → ListViewPage-xv5IQoZp.js} +63 -41
  39. package/dist/_chunks/ListViewPage-xv5IQoZp.js.map +1 -0
  40. package/dist/_chunks/{NoContentTypePage-DUacQSyF.mjs → NoContentTypePage-CPc0Cd3S.mjs} +2 -2
  41. package/dist/_chunks/{NoContentTypePage-DUacQSyF.mjs.map → NoContentTypePage-CPc0Cd3S.mjs.map} +1 -1
  42. package/dist/_chunks/{NoContentTypePage-CDUKdZ7d.js → NoContentTypePage-Dzw5Yj5u.js} +2 -2
  43. package/dist/_chunks/{NoContentTypePage-CDUKdZ7d.js.map → NoContentTypePage-Dzw5Yj5u.js.map} +1 -1
  44. package/dist/_chunks/{NoPermissionsPage-zwIZydDI.js → NoPermissionsPage-DAe5CDCC.js} +2 -2
  45. package/dist/_chunks/{NoPermissionsPage-zwIZydDI.js.map → NoPermissionsPage-DAe5CDCC.js.map} +1 -1
  46. package/dist/_chunks/{NoPermissionsPage-SFllMekk.mjs → NoPermissionsPage-wfPBh2_0.mjs} +2 -2
  47. package/dist/_chunks/{NoPermissionsPage-SFllMekk.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-NFLaRNPr.js → Relations-BmYR1AjY.js} +68 -39
  53. package/dist/_chunks/Relations-BmYR1AjY.js.map +1 -0
  54. package/dist/_chunks/{Relations-D2NRW8fC.mjs → Relations-JPhWxk-s.mjs} +68 -38
  55. package/dist/_chunks/Relations-JPhWxk-s.mjs.map +1 -0
  56. package/dist/_chunks/{en-BlhnxQfj.js → en-BK8Xyl5I.js} +22 -10
  57. package/dist/_chunks/{en-BlhnxQfj.js.map → en-BK8Xyl5I.js.map} +1 -1
  58. package/dist/_chunks/{en-C8YBvRrK.mjs → en-Dtk_ot79.mjs} +22 -10
  59. package/dist/_chunks/{en-C8YBvRrK.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-ovJRE1FM.js → index-C2Q_PLWj.js} +294 -167
  70. package/dist/_chunks/index-C2Q_PLWj.js.map +1 -0
  71. package/dist/_chunks/{index-C9HxCo5R.mjs → index-DLIkNVnQ.mjs} +297 -170
  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-UNWstw_s.js → layout-7AsWJzZJ.js} +5 -6
  78. package/dist/_chunks/{layout-UNWstw_s.js.map → layout-7AsWJzZJ.js.map} +1 -1
  79. package/dist/_chunks/{layout-DaUjDiWQ.mjs → layout-qE8qkNH_.mjs} +4 -4
  80. package/dist/_chunks/{layout-DaUjDiWQ.mjs.map → layout-qE8qkNH_.mjs.map} +1 -1
  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-D8iFAeRu.mjs → relations-BjHH_1Am.mjs} +6 -7
  86. package/dist/_chunks/relations-BjHH_1Am.mjs.map +1 -0
  87. package/dist/_chunks/{relations-NN3coOG5.js → relations-EifVzf_2.js} +6 -7
  88. package/dist/_chunks/relations-EifVzf_2.js.map +1 -0
  89. package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -1
  90. package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -1
  91. package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js → useDragAndDrop-BMtgCYzL.js} +5 -9
  92. package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js.map → useDragAndDrop-BMtgCYzL.js.map} +1 -1
  93. package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs → useDragAndDrop-DJ6jqvZN.mjs} +4 -7
  94. package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs.map → useDragAndDrop-DJ6jqvZN.mjs.map} +1 -1
  95. package/dist/admin/index.js +1 -1
  96. package/dist/admin/index.mjs +4 -4
  97. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
  98. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
  99. package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
  100. package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
  101. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  102. package/dist/admin/src/preview/constants.d.ts +1 -0
  103. package/dist/admin/src/preview/index.d.ts +4 -0
  104. package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
  105. package/dist/admin/src/preview/routes.d.ts +3 -0
  106. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  107. package/dist/admin/src/router.d.ts +1 -1
  108. package/dist/admin/src/services/documents.d.ts +0 -3
  109. package/dist/server/index.js +426 -190
  110. package/dist/server/index.js.map +1 -1
  111. package/dist/server/index.mjs +426 -189
  112. package/dist/server/index.mjs.map +1 -1
  113. package/dist/server/src/bootstrap.d.ts.map +1 -1
  114. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  115. package/dist/server/src/controllers/index.d.ts.map +1 -1
  116. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  117. package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
  118. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  119. package/dist/server/src/history/services/history.d.ts.map +1 -1
  120. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  121. package/dist/server/src/history/services/utils.d.ts +2 -3
  122. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  123. package/dist/server/src/index.d.ts +4 -4
  124. package/dist/server/src/preview/constants.d.ts +2 -0
  125. package/dist/server/src/preview/constants.d.ts.map +1 -0
  126. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  127. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  128. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  129. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  130. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  131. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  132. package/dist/server/src/preview/index.d.ts +4 -0
  133. package/dist/server/src/preview/index.d.ts.map +1 -0
  134. package/dist/server/src/preview/routes/index.d.ts +8 -0
  135. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  136. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  137. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  138. package/dist/server/src/preview/services/index.d.ts +16 -0
  139. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  140. package/dist/server/src/preview/services/preview-config.d.ts +32 -0
  141. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  142. package/dist/server/src/preview/services/preview.d.ts +12 -0
  143. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  144. package/dist/server/src/preview/utils.d.ts +19 -0
  145. package/dist/server/src/preview/utils.d.ts.map +1 -0
  146. package/dist/server/src/register.d.ts.map +1 -1
  147. package/dist/server/src/routes/index.d.ts.map +1 -1
  148. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  149. package/dist/server/src/services/document-metadata.d.ts +8 -8
  150. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  151. package/dist/server/src/services/index.d.ts +4 -4
  152. package/dist/server/src/services/index.d.ts.map +1 -1
  153. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  154. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  155. package/dist/server/src/utils/index.d.ts +2 -0
  156. package/dist/server/src/utils/index.d.ts.map +1 -1
  157. package/dist/shared/contracts/index.d.ts +1 -0
  158. package/dist/shared/contracts/index.d.ts.map +1 -1
  159. package/dist/shared/contracts/preview.d.ts +27 -0
  160. package/dist/shared/contracts/preview.d.ts.map +1 -0
  161. package/dist/shared/index.js +4 -0
  162. package/dist/shared/index.js.map +1 -1
  163. package/dist/shared/index.mjs +4 -0
  164. package/dist/shared/index.mjs.map +1 -1
  165. package/package.json +12 -12
  166. package/dist/_chunks/EditViewPage-CUS2EAhB.js.map +0 -1
  167. package/dist/_chunks/EditViewPage-Dzpno8xI.mjs.map +0 -1
  168. package/dist/_chunks/Field-B_jG_EV9.mjs.map +0 -1
  169. package/dist/_chunks/Field-CtUU1Fg8.js.map +0 -1
  170. package/dist/_chunks/Form-BXHao2mZ.mjs.map +0 -1
  171. package/dist/_chunks/Form-DTqO0ymI.js.map +0 -1
  172. package/dist/_chunks/History-2Ah2CQ4T.mjs.map +0 -1
  173. package/dist/_chunks/History-C_uSGzO5.js.map +0 -1
  174. package/dist/_chunks/ListConfigurationPage-BjSJlaoC.mjs.map +0 -1
  175. package/dist/_chunks/ListConfigurationPage-nyuP7OSy.js.map +0 -1
  176. package/dist/_chunks/ListViewPage-B75x3nz2.mjs.map +0 -1
  177. package/dist/_chunks/ListViewPage-DHgHD8Xg.js.map +0 -1
  178. package/dist/_chunks/Relations-D2NRW8fC.mjs.map +0 -1
  179. package/dist/_chunks/Relations-NFLaRNPr.js.map +0 -1
  180. package/dist/_chunks/index-C9HxCo5R.mjs.map +0 -1
  181. package/dist/_chunks/index-ovJRE1FM.js.map +0 -1
  182. package/dist/_chunks/relations-D8iFAeRu.mjs.map +0 -1
  183. package/dist/_chunks/relations-NN3coOG5.js.map +0 -1
@@ -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,kBA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AAC;AAEjF,MAAI,WAAW;AACN,WAAA,oBAAC,KAAK,SAAL,EAAa;AAAA,EAAA;AAGnB,MAAA,SAAS,CAAC,OAAO;AAEjB,WAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,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-ovJRE1FM.js");
15
- const useDragAndDrop = require("./useDragAndDrop-J0TUUbR6.js");
16
- const relations = require("./relations-NN3coOG5.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,12 +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)) {
140
- if (relations$1.length > 0) {
141
- field.onChange(`${props.name}.disconnect`, relations$1);
142
- }
175
+ field.value?.connect?.forEach(handleDisconnect);
176
+ relations$1.forEach(handleDisconnect);
143
177
  field.onChange(`${props.name}.connect`, [item]);
144
178
  } else {
145
179
  field.onChange(`${props.name}.connect`, [...field.value?.connect ?? [], item]);
@@ -160,7 +194,7 @@ const RelationsField = React__namespace.forwardRef(
160
194
  RelationsInput,
161
195
  {
162
196
  disabled: isDisabled,
163
- id,
197
+ id: componentUID ? componentId ? `${componentId}` : "" : documentId,
164
198
  label: `${label} ${relationsCount > 0 ? `(${relationsCount})` : ""}`,
165
199
  model,
166
200
  onChange: handleConnect,
@@ -219,7 +253,7 @@ const addLabelAndHref = ({ mainField, href }) => (relations$1) => relations$1.ma
219
253
  // Fallback to `id` if there is no `mainField` value, which will overwrite the above `documentId` property with the exact same data.
220
254
  [mainField?.name ?? "documentId"]: relation[mainField?.name ?? "documentId"],
221
255
  label: relations.getRelationLabel(relation, mainField),
222
- href: `${href}/${relation.documentId}`
256
+ href: `${href}/${relation.documentId}?${relation.locale ? `plugins[i18n][locale]=${relation.locale}` : ""}`
223
257
  };
224
258
  });
225
259
  const RelationsInput = ({
@@ -372,8 +406,6 @@ const RelationsList = ({
372
406
  const [overflow, setOverflow] = React__namespace.useState();
373
407
  const [liveText, setLiveText] = React__namespace.useState("");
374
408
  const field = strapiAdmin.useField(name);
375
- const removeFieldRow = strapiAdmin.useForm("RelationsList", (state) => state.removeFieldRow);
376
- const addFieldRow = strapiAdmin.useForm("RelationsList", (state) => state.addFieldRow);
377
409
  React__namespace.useEffect(() => {
378
410
  if (data.length <= RELATIONS_TO_DISPLAY) {
379
411
  return setOverflow(void 0);
@@ -423,17 +455,25 @@ const RelationsList = ({
423
455
  newData.splice(oldIndex, 1);
424
456
  newData.splice(newIndex, 0, { ...currentRow, __temp_key__: newKey });
425
457
  const connectedRelations = newData.reduce((acc, relation, currentIndex, array) => {
426
- const relationOnServer = serverData.find(
427
- (oldRelation) => oldRelation.documentId === relation.documentId
428
- );
458
+ const relationOnServer = serverData.find((oldRelation) => oldRelation.id === relation.id);
429
459
  const relationInFront = array[currentIndex + 1];
430
460
  if (!relationOnServer || relationOnServer.__temp_key__ !== relation.__temp_key__) {
431
461
  const position = relationInFront ? {
432
462
  before: relationInFront.documentId,
433
463
  locale: relationInFront.locale,
434
- status: relationInFront.status
464
+ status: "publishedAt" in relationInFront && relationInFront.publishedAt ? "published" : "draft"
435
465
  } : { end: true };
436
- 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
+ };
437
477
  return [...acc, relationWithPosition];
438
478
  }
439
479
  return acc;
@@ -484,18 +524,7 @@ const RelationsList = ({
484
524
  )
485
525
  );
486
526
  };
487
- const handleDisconnect = (relation) => {
488
- if (field.value && field.value.connect) {
489
- const indexOfRelationInConnectArray = field.value.connect.findIndex(
490
- (rel) => rel.id === relation.id
491
- );
492
- if (indexOfRelationInConnectArray >= 0) {
493
- removeFieldRow(`${name}.connect`, indexOfRelationInConnectArray);
494
- return;
495
- }
496
- }
497
- addFieldRow(`${name}.disconnect`, { id: relation.id });
498
- };
527
+ const handleDisconnect = useHandleDisconnect(name, "RelationsList");
499
528
  const canReorder = !ONE_WAY_RELATIONS.includes(relationType);
500
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);
501
530
  return /* @__PURE__ */ jsxRuntime.jsxs(ShadowBox, { $overflowDirection: overflow, children: [
@@ -576,7 +605,7 @@ const ListItem = ({ data, index: index$1, style }) => {
576
605
  relations: relations2
577
606
  } = data;
578
607
  const { formatMessage } = reactIntl.useIntl();
579
- const { href, documentId, label, status } = relations2[index$1];
608
+ const { href, id, label, status } = relations2[index$1];
580
609
  const [{ handlerId, isDragging, handleKeyDown }, relationRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop.useDragAndDrop(
581
610
  canDrag && !disabled,
582
611
  {
@@ -585,7 +614,7 @@ const ListItem = ({ data, index: index$1, style }) => {
585
614
  item: {
586
615
  displayedValue: label,
587
616
  status,
588
- id: documentId,
617
+ id,
589
618
  index: index$1
590
619
  },
591
620
  onMoveItem: handleMoveItem,
@@ -715,4 +744,4 @@ exports.FlexWrapper = FlexWrapper;
715
744
  exports.LinkEllipsis = LinkEllipsis;
716
745
  exports.MemoizedRelationsField = MemoizedRelationsField;
717
746
  exports.useComponent = useComponent;
718
- //# sourceMappingURL=Relations-NFLaRNPr.js.map
747
+ //# sourceMappingURL=Relations-BmYR1AjY.js.map