@strapi/content-manager 0.0.0-experimental.f2351bcfa3965c60f063a492da51faa2c636eee8 → 0.0.0-experimental.f49f46a1c17445a39e8af3f63124bcccf73842e6

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 (171) hide show
  1. package/dist/_chunks/{ComponentConfigurationPage-BlAzljQ6.js → ComponentConfigurationPage-ClKl_TA2.js} +4 -4
  2. package/dist/_chunks/{ComponentConfigurationPage-BlAzljQ6.js.map → ComponentConfigurationPage-ClKl_TA2.js.map} +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-Ccwb19Qj.mjs → ComponentConfigurationPage-D3ZWDAHG.mjs} +4 -4
  4. package/dist/_chunks/{ComponentConfigurationPage-Ccwb19Qj.mjs.map → ComponentConfigurationPage-D3ZWDAHG.mjs.map} +1 -1
  5. package/dist/_chunks/{EditConfigurationPage-C19b_9RL.mjs → EditConfigurationPage-BYCBSJxP.mjs} +4 -4
  6. package/dist/_chunks/{EditConfigurationPage-C19b_9RL.mjs.map → EditConfigurationPage-BYCBSJxP.mjs.map} +1 -1
  7. package/dist/_chunks/{EditConfigurationPage-BPoOzhCM.js → EditConfigurationPage-OWez0Kxp.js} +4 -4
  8. package/dist/_chunks/{EditConfigurationPage-BPoOzhCM.js.map → EditConfigurationPage-OWez0Kxp.js.map} +1 -1
  9. package/dist/_chunks/{EditViewPage-nmrHNiJ9.mjs → EditViewPage-5pdbvsO_.mjs} +50 -10
  10. package/dist/_chunks/EditViewPage-5pdbvsO_.mjs.map +1 -0
  11. package/dist/_chunks/{EditViewPage-D9xH8HYD.js → EditViewPage-BEs5iGDi.js} +49 -9
  12. package/dist/_chunks/EditViewPage-BEs5iGDi.js.map +1 -0
  13. package/dist/_chunks/{Field-BB_pHo6D.js → Field-DNHm4wHx.js} +107 -44
  14. package/dist/_chunks/Field-DNHm4wHx.js.map +1 -0
  15. package/dist/_chunks/{Field--kmlJuSb.mjs → Field-DcKuFHYK.mjs} +107 -44
  16. package/dist/_chunks/Field-DcKuFHYK.mjs.map +1 -0
  17. package/dist/_chunks/{Form-CUtOiC4S.mjs → Form-CGwM_-5c.mjs} +3 -3
  18. package/dist/_chunks/Form-CGwM_-5c.mjs.map +1 -0
  19. package/dist/_chunks/{Form-iwbkoaAF.js → Form-CoRxWJOz.js} +3 -3
  20. package/dist/_chunks/Form-CoRxWJOz.js.map +1 -0
  21. package/dist/_chunks/{History-guuZF4lR.js → History-BcUTQrfG.js} +40 -97
  22. package/dist/_chunks/History-BcUTQrfG.js.map +1 -0
  23. package/dist/_chunks/{History-BKR3KyU3.mjs → History-DEvr3Q_V.mjs} +42 -99
  24. package/dist/_chunks/History-DEvr3Q_V.mjs.map +1 -0
  25. package/dist/_chunks/{ListConfigurationPage-Cu26t5sE.js → ListConfigurationPage-BE_Ho7tV.js} +5 -4
  26. package/dist/_chunks/ListConfigurationPage-BE_Ho7tV.js.map +1 -0
  27. package/dist/_chunks/{ListConfigurationPage-B_O3hiLT.mjs → ListConfigurationPage-BM4zZZcM.mjs} +6 -5
  28. package/dist/_chunks/ListConfigurationPage-BM4zZZcM.mjs.map +1 -0
  29. package/dist/_chunks/{ListViewPage-B4sTBfu6.mjs → ListViewPage-BK2mkrql.mjs} +29 -7
  30. package/dist/_chunks/{ListViewPage-B4sTBfu6.mjs.map → ListViewPage-BK2mkrql.mjs.map} +1 -1
  31. package/dist/_chunks/{ListViewPage-DWqqGno8.js → ListViewPage-BkT8Eao0.js} +29 -7
  32. package/dist/_chunks/ListViewPage-BkT8Eao0.js.map +1 -0
  33. package/dist/_chunks/{NoContentTypePage-Daktt4t9.mjs → NoContentTypePage-BvcAutu9.mjs} +2 -2
  34. package/dist/_chunks/{NoContentTypePage-Daktt4t9.mjs.map → NoContentTypePage-BvcAutu9.mjs.map} +1 -1
  35. package/dist/_chunks/{NoContentTypePage-TTkwA8uk.js → NoContentTypePage-C8mtyc4H.js} +2 -2
  36. package/dist/_chunks/{NoContentTypePage-TTkwA8uk.js.map → NoContentTypePage-C8mtyc4H.js.map} +1 -1
  37. package/dist/_chunks/{NoPermissionsPage-D8_k39Q0.js → NoPermissionsPage-B5Y9Y78B.js} +2 -2
  38. package/dist/_chunks/{NoPermissionsPage-D8_k39Q0.js.map → NoPermissionsPage-B5Y9Y78B.js.map} +1 -1
  39. package/dist/_chunks/{NoPermissionsPage-CBUXY2Pt.mjs → NoPermissionsPage-BmbRz7PR.mjs} +2 -2
  40. package/dist/_chunks/{NoPermissionsPage-CBUXY2Pt.mjs.map → NoPermissionsPage-BmbRz7PR.mjs.map} +1 -1
  41. package/dist/_chunks/Preview-BF8ZDYqS.js +286 -0
  42. package/dist/_chunks/Preview-BF8ZDYqS.js.map +1 -0
  43. package/dist/_chunks/Preview-DcexhKJE.mjs +267 -0
  44. package/dist/_chunks/Preview-DcexhKJE.mjs.map +1 -0
  45. package/dist/_chunks/{Relations-DjvmZ_XQ.js → Relations-BKnoK1R0.js} +71 -35
  46. package/dist/_chunks/Relations-BKnoK1R0.js.map +1 -0
  47. package/dist/_chunks/{Relations-HKmXF7eO.mjs → Relations-BjIzc4EK.mjs} +72 -36
  48. package/dist/_chunks/Relations-BjIzc4EK.mjs.map +1 -0
  49. package/dist/_chunks/{en-CPTj6CjC.mjs → en-CfIXaZf9.mjs} +21 -10
  50. package/dist/_chunks/{en-CPTj6CjC.mjs.map → en-CfIXaZf9.mjs.map} +1 -1
  51. package/dist/_chunks/{en-BVzUkPxZ.js → en-DTWPCdTS.js} +21 -10
  52. package/dist/_chunks/{en-BVzUkPxZ.js.map → en-DTWPCdTS.js.map} +1 -1
  53. package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
  54. package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
  55. package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
  56. package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
  57. package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
  58. package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
  59. package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
  60. package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
  61. package/dist/_chunks/{index-CB1AN26E.mjs → index-BW-rXkjn.mjs} +882 -721
  62. package/dist/_chunks/index-BW-rXkjn.mjs.map +1 -0
  63. package/dist/_chunks/{index-jDJgW_Lf.js → index-DOzAG2cq.js} +879 -717
  64. package/dist/_chunks/index-DOzAG2cq.js.map +1 -0
  65. package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
  66. package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
  67. package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
  68. package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
  69. package/dist/_chunks/{layout-BCzDsMgN.mjs → layout-DFVbgjp2.mjs} +3 -3
  70. package/dist/_chunks/{layout-BCzDsMgN.mjs.map → layout-DFVbgjp2.mjs.map} +1 -1
  71. package/dist/_chunks/{layout-D6A3K-ut.js → layout-RC3W2obV.js} +3 -3
  72. package/dist/_chunks/{layout-D6A3K-ut.js.map → layout-RC3W2obV.js.map} +1 -1
  73. package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
  74. package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
  75. package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
  76. package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
  77. package/dist/_chunks/{relations-B5Jnw32V.mjs → relations-Dogh8HWI.mjs} +6 -7
  78. package/dist/_chunks/relations-Dogh8HWI.mjs.map +1 -0
  79. package/dist/_chunks/{relations-C10QoukP.js → relations-zam7-5H7.js} +6 -7
  80. package/dist/_chunks/relations-zam7-5H7.js.map +1 -0
  81. package/dist/admin/index.js +2 -1
  82. package/dist/admin/index.js.map +1 -1
  83. package/dist/admin/index.mjs +4 -3
  84. package/dist/admin/src/exports.d.ts +1 -1
  85. package/dist/admin/src/hooks/useDocument.d.ts +32 -1
  86. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
  87. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
  88. package/dist/admin/src/pages/EditView/components/Header.d.ts +1 -0
  89. package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
  90. package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
  91. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  92. package/dist/admin/src/preview/constants.d.ts +1 -0
  93. package/dist/admin/src/preview/index.d.ts +4 -0
  94. package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
  95. package/dist/admin/src/preview/routes.d.ts +3 -0
  96. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  97. package/dist/admin/src/router.d.ts +1 -1
  98. package/dist/server/index.js +374 -160
  99. package/dist/server/index.js.map +1 -1
  100. package/dist/server/index.mjs +374 -160
  101. package/dist/server/index.mjs.map +1 -1
  102. package/dist/server/src/bootstrap.d.ts.map +1 -1
  103. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  104. package/dist/server/src/controllers/index.d.ts.map +1 -1
  105. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  106. package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
  107. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  108. package/dist/server/src/history/services/history.d.ts.map +1 -1
  109. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  110. package/dist/server/src/history/services/utils.d.ts +2 -3
  111. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  112. package/dist/server/src/index.d.ts +4 -4
  113. package/dist/server/src/preview/constants.d.ts +2 -0
  114. package/dist/server/src/preview/constants.d.ts.map +1 -0
  115. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  116. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  117. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  118. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  119. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  120. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  121. package/dist/server/src/preview/index.d.ts +4 -0
  122. package/dist/server/src/preview/index.d.ts.map +1 -0
  123. package/dist/server/src/preview/routes/index.d.ts +8 -0
  124. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  125. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  126. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  127. package/dist/server/src/preview/services/index.d.ts +15 -0
  128. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  129. package/dist/server/src/preview/services/preview-config.d.ts +30 -0
  130. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  131. package/dist/server/src/preview/services/preview.d.ts +12 -0
  132. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  133. package/dist/server/src/preview/utils.d.ts +18 -0
  134. package/dist/server/src/preview/utils.d.ts.map +1 -0
  135. package/dist/server/src/routes/index.d.ts.map +1 -1
  136. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  137. package/dist/server/src/services/document-metadata.d.ts +8 -8
  138. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  139. package/dist/server/src/services/index.d.ts +4 -4
  140. package/dist/server/src/services/index.d.ts.map +1 -1
  141. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  142. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  143. package/dist/server/src/utils/index.d.ts +2 -0
  144. package/dist/server/src/utils/index.d.ts.map +1 -1
  145. package/dist/shared/contracts/index.d.ts +1 -0
  146. package/dist/shared/contracts/index.d.ts.map +1 -1
  147. package/dist/shared/contracts/preview.d.ts +27 -0
  148. package/dist/shared/contracts/preview.d.ts.map +1 -0
  149. package/dist/shared/index.js +4 -0
  150. package/dist/shared/index.js.map +1 -1
  151. package/dist/shared/index.mjs +4 -0
  152. package/dist/shared/index.mjs.map +1 -1
  153. package/package.json +13 -13
  154. package/dist/_chunks/EditViewPage-D9xH8HYD.js.map +0 -1
  155. package/dist/_chunks/EditViewPage-nmrHNiJ9.mjs.map +0 -1
  156. package/dist/_chunks/Field--kmlJuSb.mjs.map +0 -1
  157. package/dist/_chunks/Field-BB_pHo6D.js.map +0 -1
  158. package/dist/_chunks/Form-CUtOiC4S.mjs.map +0 -1
  159. package/dist/_chunks/Form-iwbkoaAF.js.map +0 -1
  160. package/dist/_chunks/History-BKR3KyU3.mjs.map +0 -1
  161. package/dist/_chunks/History-guuZF4lR.js.map +0 -1
  162. package/dist/_chunks/ListConfigurationPage-B_O3hiLT.mjs.map +0 -1
  163. package/dist/_chunks/ListConfigurationPage-Cu26t5sE.js.map +0 -1
  164. package/dist/_chunks/ListViewPage-DWqqGno8.js.map +0 -1
  165. package/dist/_chunks/Relations-DjvmZ_XQ.js.map +0 -1
  166. package/dist/_chunks/Relations-HKmXF7eO.mjs.map +0 -1
  167. package/dist/_chunks/index-CB1AN26E.mjs.map +0 -1
  168. package/dist/_chunks/index-jDJgW_Lf.js.map +0 -1
  169. package/dist/_chunks/relations-B5Jnw32V.mjs.map +0 -1
  170. package/dist/_chunks/relations-C10QoukP.js.map +0 -1
  171. package/strapi-server.js +0 -3
@@ -0,0 +1,267 @@
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, Tabs, Grid, Typography, 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-BW-rXkjn.mjs";
8
+ import { Link, Cross } from "@strapi/icons";
9
+ import { stringify } from "qs";
10
+ import { styled } from "styled-components";
11
+ import { getDocumentStatus } from "./EditViewPage-5pdbvsO_.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(Typography, { 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 StatusTab = styled(Tabs.Trigger)`
148
+ text-transform: uppercase;
149
+ `;
150
+ const [PreviewProvider, usePreviewContext] = createContext("PreviewPage");
151
+ const PreviewPage = () => {
152
+ const { formatMessage } = useIntl();
153
+ const {
154
+ slug: model,
155
+ id: documentId,
156
+ collectionType
157
+ } = useParams();
158
+ const [{ query }] = useQueryParams();
159
+ const params = React.useMemo(() => buildValidParams(query), [query]);
160
+ if (!collectionType) {
161
+ throw new Error("Could not find collectionType in url params");
162
+ }
163
+ if (!model) {
164
+ throw new Error("Could not find model in url params");
165
+ }
166
+ if (collectionType === COLLECTION_TYPES && !documentId) {
167
+ throw new Error("Could not find documentId in url params");
168
+ }
169
+ const previewUrlResponse = useGetPreviewUrlQuery({
170
+ params: {
171
+ contentType: model
172
+ },
173
+ query: {
174
+ documentId,
175
+ locale: params.locale,
176
+ status: params.status
177
+ }
178
+ });
179
+ const documentResponse = useDocument({
180
+ model,
181
+ collectionType,
182
+ documentId,
183
+ params
184
+ });
185
+ const documentLayoutResponse = useDocumentLayout(model);
186
+ if (documentResponse.isLoading || previewUrlResponse.isLoading || documentLayoutResponse.isLoading) {
187
+ return /* @__PURE__ */ jsx(Page.Loading, {});
188
+ }
189
+ if (previewUrlResponse.error || documentLayoutResponse.error || !documentResponse.document || !documentResponse.meta || !documentResponse.schema) {
190
+ return /* @__PURE__ */ jsx(Page.Error, {});
191
+ }
192
+ if (!previewUrlResponse.data?.data?.url) {
193
+ return /* @__PURE__ */ jsx(Page.NoData, {});
194
+ }
195
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
196
+ /* @__PURE__ */ jsx(Page.Title, { children: formatMessage(
197
+ {
198
+ id: "content-manager.preview.page-title",
199
+ defaultMessage: "{contentType} preview"
200
+ },
201
+ {
202
+ contentType: documentLayoutResponse.edit.settings.displayName
203
+ }
204
+ ) }),
205
+ /* @__PURE__ */ jsx(
206
+ PreviewProvider,
207
+ {
208
+ url: previewUrlResponse.data.data.url,
209
+ mainField: documentLayoutResponse.edit.settings.mainField,
210
+ document: documentResponse.document,
211
+ meta: documentResponse.meta,
212
+ schema: documentResponse.schema,
213
+ children: /* @__PURE__ */ jsxs(Flex, { direction: "column", height: "100%", alignItems: "stretch", children: [
214
+ /* @__PURE__ */ jsx(PreviewHeader, {}),
215
+ /* @__PURE__ */ jsx(PreviewContent, {})
216
+ ] })
217
+ }
218
+ )
219
+ ] });
220
+ };
221
+ const ProtectedPreviewPageImpl = () => {
222
+ const { slug: model } = useParams();
223
+ const {
224
+ permissions = [],
225
+ isLoading,
226
+ error
227
+ } = useRBAC([{ action: "plugin::content-manager.explorer.read", subject: model }]);
228
+ if (isLoading) {
229
+ return /* @__PURE__ */ jsx(Page.Loading, {});
230
+ }
231
+ if (error || !model) {
232
+ return /* @__PURE__ */ jsx(
233
+ Box,
234
+ {
235
+ height: "100vh",
236
+ width: "100vw",
237
+ position: "fixed",
238
+ top: 0,
239
+ left: 0,
240
+ zIndex: 2,
241
+ background: "neutral0",
242
+ children: /* @__PURE__ */ jsx(Page.Error, {})
243
+ }
244
+ );
245
+ }
246
+ return /* @__PURE__ */ jsx(
247
+ Box,
248
+ {
249
+ height: "100vh",
250
+ width: "100vw",
251
+ position: "fixed",
252
+ top: 0,
253
+ left: 0,
254
+ zIndex: 2,
255
+ background: "neutral0",
256
+ children: /* @__PURE__ */ jsx(Page.Protect, { permissions, children: ({ permissions: permissions2 }) => /* @__PURE__ */ jsx(DocumentRBAC, { permissions: permissions2, children: /* @__PURE__ */ jsx(PreviewPage, {}) }) })
257
+ }
258
+ );
259
+ };
260
+ const ProtectedPreviewPage = () => {
261
+ return /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(FocusTrap, { children: /* @__PURE__ */ jsx(ProtectedPreviewPageImpl, {}) }) });
262
+ };
263
+ export {
264
+ ProtectedPreviewPage,
265
+ usePreviewContext
266
+ };
267
+ //# sourceMappingURL=Preview-DcexhKJE.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Preview-DcexhKJE.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 <Typography tag=\"h1\" fontWeight={600} fontSize={2} maxWidth=\"200px\">\n {title}\n </Typography>\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 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,kBAAkB;AAGxB,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,EAAA;AAGV;ACCA,MAAM,qBAAqB,MAAM;AAC/B,QAAM,CAAC,EAAE,OAAO,IAAI,eAEjB;AACG,QAAA,EAAE,kBAAkB;AAGxB,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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AM,MAAM,IAAI,UAErB;AACG,QAAA;AAAA,IACJ,cAAc,CAAC;AAAA,IACf;AAAA,IACA;AAAA,EAAA,IACE,QAAQ,CAAC,EAAE,QAAQ,yCAAyC,SAAS,MAAO,CAAA,CAAC;AAEjF,MAAI,WAAW;AACN,WAAA,oBAAC,KAAK,SAAL,CAAa,CAAA;AAAA,EACvB;AAEI,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,CAAA,CAAW;AAAA,MAAA;AAAA,IAAA;AAAA,EAGlB;AAGE,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,CAAA,CAAY,EACf,CAAA,GAEJ;AAAA,IAAA;AAAA,EAAA;AAGN;AAEA,MAAM,uBAAuB,MAAM;AACjC,6BACG,QACC,EAAA,UAAA,oBAAC,aACC,UAAC,oBAAA,0BAAA,CAAyB,CAAA,EAC5B,CAAA,EACF,CAAA;AAEJ;"}
@@ -11,9 +11,9 @@ 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-jDJgW_Lf.js");
14
+ const index = require("./index-DOzAG2cq.js");
15
15
  const useDragAndDrop = require("./useDragAndDrop-J0TUUbR6.js");
16
- const relations = require("./relations-C10QoukP.js");
16
+ const relations = require("./relations-zam7-5H7.js");
17
17
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
18
18
  function _interopNamespace(e) {
19
19
  if (e && e.__esModule)
@@ -41,6 +41,31 @@ const [ComponentProvider, useComponent] = strapiAdmin.createContext("ComponentCo
41
41
  uid: void 0,
42
42
  type: void 0
43
43
  });
44
+ function useHandleDisconnect(fieldName, consumerName) {
45
+ const field = strapiAdmin.useField(fieldName);
46
+ const removeFieldRow = strapiAdmin.useForm(consumerName, (state) => state.removeFieldRow);
47
+ const addFieldRow = strapiAdmin.useForm(consumerName, (state) => state.addFieldRow);
48
+ const handleDisconnect = (relation) => {
49
+ if (field.value && field.value.connect) {
50
+ const indexOfRelationInConnectArray = field.value.connect.findIndex(
51
+ (rel) => rel.id === relation.id
52
+ );
53
+ if (indexOfRelationInConnectArray >= 0) {
54
+ removeFieldRow(`${fieldName}.connect`, indexOfRelationInConnectArray);
55
+ return;
56
+ }
57
+ }
58
+ addFieldRow(`${fieldName}.disconnect`, {
59
+ id: relation.id,
60
+ apiData: {
61
+ id: relation.id,
62
+ documentId: relation.documentId,
63
+ locale: relation.locale
64
+ }
65
+ });
66
+ };
67
+ return handleDisconnect;
68
+ }
44
69
  const RELATIONS_TO_DISPLAY = 5;
45
70
  const ONE_WAY_RELATIONS = ["oneWay", "oneToOne", "manyToOne", "oneToManyMorph", "oneToOneMorph"];
46
71
  const RelationsField = React__namespace.forwardRef(
@@ -53,9 +78,16 @@ const RelationsField = React__namespace.forwardRef(
53
78
  const params = index.buildValidParams(query);
54
79
  const isMorph = props.attribute.relation.toLowerCase().includes("morph");
55
80
  const isDisabled = isMorph || disabled;
56
- const { id: componentId, uid } = useComponent("RelationsField", ({ uid: uid2, id: id2 }) => ({ id: id2, uid: uid2 }));
81
+ const { componentId, componentUID } = useComponent("RelationsField", ({ uid, id: id2 }) => ({
82
+ componentId: id2,
83
+ componentUID: uid
84
+ }));
85
+ const isSubmitting = strapiAdmin.useForm("RelationsList", (state) => state.isSubmitting);
86
+ React__namespace.useEffect(() => {
87
+ setCurrentPage(1);
88
+ }, [isSubmitting]);
57
89
  const id = componentId ? componentId.toString() : documentId;
58
- const model = uid ?? documentModel;
90
+ const model = componentUID ?? documentModel;
59
91
  const [targetField] = props.name.split(".").slice(-1);
60
92
  const { data, isLoading, isFetching } = relations.useGetRelationsQuery(
61
93
  {
@@ -121,10 +153,16 @@ const RelationsField = React__namespace.forwardRef(
121
153
  props.attribute.targetModel,
122
154
  props.mainField
123
155
  ]);
156
+ const handleDisconnect = useHandleDisconnect(props.name, "RelationsField");
124
157
  const handleConnect = (relation) => {
125
158
  const [lastItemInList] = relations$1.slice(-1);
126
159
  const item = {
127
160
  id: relation.id,
161
+ apiData: {
162
+ id: relation.id,
163
+ documentId: relation.documentId,
164
+ locale: relation.locale
165
+ },
128
166
  status: relation.status,
129
167
  /**
130
168
  * If there's a last item, that's the first key we use to generate out next one.
@@ -134,9 +172,11 @@ const RelationsField = React__namespace.forwardRef(
134
172
  [props.mainField?.name ?? "documentId"]: relation[props.mainField?.name ?? "documentId"],
135
173
  label: relations.getRelationLabel(relation, props.mainField),
136
174
  // @ts-expect-error – targetModel does exist on the attribute, but it's not typed.
137
- href: `../${index.COLLECTION_TYPES}/${props.attribute.targetModel}/${relation.documentId}`
175
+ href: `../${index.COLLECTION_TYPES}/${props.attribute.targetModel}/${relation.documentId}?${relation.locale ? `plugins[i18n][locale]=${relation.locale}` : ""}`
138
176
  };
139
177
  if (ONE_WAY_RELATIONS.includes(props.attribute.relation)) {
178
+ field.value?.connect?.forEach(handleDisconnect);
179
+ relations$1.forEach(handleDisconnect);
140
180
  field.onChange(`${props.name}.connect`, [item]);
141
181
  } else {
142
182
  field.onChange(`${props.name}.connect`, [...field.value?.connect ?? [], item]);
@@ -157,7 +197,7 @@ const RelationsField = React__namespace.forwardRef(
157
197
  RelationsInput,
158
198
  {
159
199
  disabled: isDisabled,
160
- id,
200
+ id: componentUID ? componentId ? `${componentId}` : "" : documentId,
161
201
  label: `${label} ${relationsCount > 0 ? `(${relationsCount})` : ""}`,
162
202
  model,
163
203
  onChange: handleConnect,
@@ -216,7 +256,7 @@ const addLabelAndHref = ({ mainField, href }) => (relations$1) => relations$1.ma
216
256
  // Fallback to `id` if there is no `mainField` value, which will overwrite the above `documentId` property with the exact same data.
217
257
  [mainField?.name ?? "documentId"]: relation[mainField?.name ?? "documentId"],
218
258
  label: relations.getRelationLabel(relation, mainField),
219
- href: `${href}/${relation.documentId}`
259
+ href: `${href}/${relation.documentId}?${relation.locale ? `plugins[i18n][locale]=${relation.locale}` : ""}`
220
260
  };
221
261
  });
222
262
  const RelationsInput = ({
@@ -311,7 +351,7 @@ const RelationsInput = ({
311
351
  {
312
352
  ref: fieldRef,
313
353
  name,
314
- autocomplete: "none",
354
+ autocomplete: "list",
315
355
  placeholder: placeholder || formatMessage({
316
356
  id: index.getTranslation("relation.add"),
317
357
  defaultMessage: "Add relation"
@@ -369,8 +409,6 @@ const RelationsList = ({
369
409
  const [overflow, setOverflow] = React__namespace.useState();
370
410
  const [liveText, setLiveText] = React__namespace.useState("");
371
411
  const field = strapiAdmin.useField(name);
372
- const removeFieldRow = strapiAdmin.useForm("RelationsList", (state) => state.removeFieldRow);
373
- const addFieldRow = strapiAdmin.useForm("RelationsList", (state) => state.addFieldRow);
374
412
  React__namespace.useEffect(() => {
375
413
  if (data.length <= RELATIONS_TO_DISPLAY) {
376
414
  return setOverflow(void 0);
@@ -420,17 +458,25 @@ const RelationsList = ({
420
458
  newData.splice(oldIndex, 1);
421
459
  newData.splice(newIndex, 0, { ...currentRow, __temp_key__: newKey });
422
460
  const connectedRelations = newData.reduce((acc, relation, currentIndex, array) => {
423
- const relationOnServer = serverData.find(
424
- (oldRelation) => oldRelation.documentId === relation.documentId
425
- );
461
+ const relationOnServer = serverData.find((oldRelation) => oldRelation.id === relation.id);
426
462
  const relationInFront = array[currentIndex + 1];
427
463
  if (!relationOnServer || relationOnServer.__temp_key__ !== relation.__temp_key__) {
428
464
  const position = relationInFront ? {
429
465
  before: relationInFront.documentId,
430
466
  locale: relationInFront.locale,
431
- status: relationInFront.status
467
+ status: "publishedAt" in relationInFront && relationInFront.publishedAt ? "published" : "draft"
432
468
  } : { end: true };
433
- const relationWithPosition = { ...relation, position };
469
+ const relationWithPosition = {
470
+ ...relation,
471
+ ...{
472
+ apiData: {
473
+ id: relation.id,
474
+ documentId: relation.documentId,
475
+ locale: relation.locale,
476
+ position
477
+ }
478
+ }
479
+ };
434
480
  return [...acc, relationWithPosition];
435
481
  }
436
482
  return acc;
@@ -481,18 +527,7 @@ const RelationsList = ({
481
527
  )
482
528
  );
483
529
  };
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
- };
530
+ const handleDisconnect = useHandleDisconnect(name, "RelationsList");
496
531
  const canReorder = !ONE_WAY_RELATIONS.includes(relationType);
497
532
  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
533
  return /* @__PURE__ */ jsxRuntime.jsxs(ShadowBox, { $overflowDirection: overflow, children: [
@@ -573,7 +608,7 @@ const ListItem = ({ data, index: index$1, style }) => {
573
608
  relations: relations2
574
609
  } = data;
575
610
  const { formatMessage } = reactIntl.useIntl();
576
- const { href, documentId, label, status } = relations2[index$1];
611
+ const { href, id, label, status } = relations2[index$1];
577
612
  const [{ handlerId, isDragging, handleKeyDown }, relationRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop.useDragAndDrop(
578
613
  canDrag && !disabled,
579
614
  {
@@ -582,7 +617,7 @@ const ListItem = ({ data, index: index$1, style }) => {
582
617
  item: {
583
618
  displayedValue: label,
584
619
  status,
585
- id: documentId,
620
+ id,
586
621
  index: index$1
587
622
  },
588
623
  onMoveItem: handleMoveItem,
@@ -642,16 +677,17 @@ const ListItem = ({ data, index: index$1, style }) => {
642
677
  ] })
643
678
  ] }),
644
679
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 4, children: /* @__PURE__ */ jsxRuntime.jsx(
645
- DisconnectButton,
680
+ designSystem.IconButton,
646
681
  {
647
- disabled,
648
- type: "button",
649
682
  onClick: () => handleDisconnect(relations2[index$1]),
650
- "aria-label": formatMessage({
683
+ disabled,
684
+ label: formatMessage({
651
685
  id: index.getTranslation("relation.disconnect"),
652
686
  defaultMessage: "Remove"
653
687
  }),
654
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, { width: "12px" })
688
+ variant: "ghost",
689
+ size: "S",
690
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {})
655
691
  }
656
692
  ) })
657
693
  ]
@@ -711,4 +747,4 @@ exports.FlexWrapper = FlexWrapper;
711
747
  exports.LinkEllipsis = LinkEllipsis;
712
748
  exports.MemoizedRelationsField = MemoizedRelationsField;
713
749
  exports.useComponent = useComponent;
714
- //# sourceMappingURL=Relations-DjvmZ_XQ.js.map
750
+ //# sourceMappingURL=Relations-BKnoK1R0.js.map