@strapi/content-manager 0.0.0-experimental.e9122b401c96877b6707775c4f893660eab93ae3 → 0.0.0-experimental.eba25ec571b091c6bde1104eb6c753debdf15462

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/dist/_chunks/{ComponentConfigurationPage-CpBFh6_r.mjs → ComponentConfigurationPage-BaJMOQyq.mjs} +4 -4
  2. package/dist/_chunks/{ComponentConfigurationPage-CpBFh6_r.mjs.map → ComponentConfigurationPage-BaJMOQyq.mjs.map} +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-_zF8p6CY.js → ComponentConfigurationPage-N-CTtgQa.js} +4 -4
  4. package/dist/_chunks/{ComponentConfigurationPage-_zF8p6CY.js.map → ComponentConfigurationPage-N-CTtgQa.js.map} +1 -1
  5. package/dist/_chunks/{EditConfigurationPage-_aG2DJSU.js → EditConfigurationPage-BHkjAbxH.js} +4 -4
  6. package/dist/_chunks/{EditConfigurationPage-_aG2DJSU.js.map → EditConfigurationPage-BHkjAbxH.js.map} +1 -1
  7. package/dist/_chunks/{EditConfigurationPage-CE_yavTi.mjs → EditConfigurationPage-CKK-5LfX.mjs} +4 -4
  8. package/dist/_chunks/{EditConfigurationPage-CE_yavTi.mjs.map → EditConfigurationPage-CKK-5LfX.mjs.map} +1 -1
  9. package/dist/_chunks/{EditViewPage-DeTn7rAF.mjs → EditViewPage-B11aeMcf.mjs} +50 -10
  10. package/dist/_chunks/EditViewPage-B11aeMcf.mjs.map +1 -0
  11. package/dist/_chunks/{EditViewPage-G9uNzwYL.js → EditViewPage-QPUftxUd.js} +49 -9
  12. package/dist/_chunks/EditViewPage-QPUftxUd.js.map +1 -0
  13. package/dist/_chunks/{Field-CnCKhI1R.mjs → Field-Bj_RgtGo.mjs} +109 -46
  14. package/dist/_chunks/Field-Bj_RgtGo.mjs.map +1 -0
  15. package/dist/_chunks/{Field-DDHUWEfV.js → Field-DUK83cfh.js} +108 -45
  16. package/dist/_chunks/Field-DUK83cfh.js.map +1 -0
  17. package/dist/_chunks/{Form-DYETaKUX.js → Form-DHmBRlHd.js} +3 -3
  18. package/dist/_chunks/Form-DHmBRlHd.js.map +1 -0
  19. package/dist/_chunks/{Form-IvVVwqRL.mjs → Form-DLMSoXV7.mjs} +3 -3
  20. package/dist/_chunks/Form-DLMSoXV7.mjs.map +1 -0
  21. package/dist/_chunks/{History-BMunT-do.mjs → History-CfCSNlG9.mjs} +43 -100
  22. package/dist/_chunks/History-CfCSNlG9.mjs.map +1 -0
  23. package/dist/_chunks/{History-CnZDctSO.js → History-Di3zm4HT.js} +41 -98
  24. package/dist/_chunks/History-Di3zm4HT.js.map +1 -0
  25. package/dist/_chunks/{ListConfigurationPage-CDqkCxgV.mjs → ListConfigurationPage-0mtv_iqk.mjs} +6 -5
  26. package/dist/_chunks/ListConfigurationPage-0mtv_iqk.mjs.map +1 -0
  27. package/dist/_chunks/{ListConfigurationPage-BynalOp8.js → ListConfigurationPage-Cq361KIt.js} +5 -4
  28. package/dist/_chunks/ListConfigurationPage-Cq361KIt.js.map +1 -0
  29. package/dist/_chunks/{ListViewPage-_5gS-DOF.mjs → ListViewPage-BxLVROX8.mjs} +69 -42
  30. package/dist/_chunks/ListViewPage-BxLVROX8.mjs.map +1 -0
  31. package/dist/_chunks/{ListViewPage-I88Ouzoq.js → ListViewPage-DFDcG8gM.js} +69 -42
  32. package/dist/_chunks/ListViewPage-DFDcG8gM.js.map +1 -0
  33. package/dist/_chunks/{NoContentTypePage-Dht-55hr.mjs → NoContentTypePage-BRfDd67_.mjs} +2 -2
  34. package/dist/_chunks/{NoContentTypePage-Dht-55hr.mjs.map → NoContentTypePage-BRfDd67_.mjs.map} +1 -1
  35. package/dist/_chunks/{NoContentTypePage-BaWQ7HsA.js → NoContentTypePage-BSyvnDZZ.js} +2 -2
  36. package/dist/_chunks/{NoContentTypePage-BaWQ7HsA.js.map → NoContentTypePage-BSyvnDZZ.js.map} +1 -1
  37. package/dist/_chunks/{NoPermissionsPage-Bs8D5W_v.mjs → NoPermissionsPage-CV9V8KWa.mjs} +2 -2
  38. package/dist/_chunks/{NoPermissionsPage-Bs8D5W_v.mjs.map → NoPermissionsPage-CV9V8KWa.mjs.map} +1 -1
  39. package/dist/_chunks/{NoPermissionsPage-DCVUh5at.js → NoPermissionsPage-DyLphsn_.js} +2 -2
  40. package/dist/_chunks/{NoPermissionsPage-DCVUh5at.js.map → NoPermissionsPage-DyLphsn_.js.map} +1 -1
  41. package/dist/_chunks/Preview-C_B1nx3g.mjs +272 -0
  42. package/dist/_chunks/Preview-C_B1nx3g.mjs.map +1 -0
  43. package/dist/_chunks/Preview-D_3aO6Ly.js +291 -0
  44. package/dist/_chunks/Preview-D_3aO6Ly.js.map +1 -0
  45. package/dist/_chunks/{Relations-Chdt5qWc.mjs → Relations-C6pwmDXh.mjs} +72 -36
  46. package/dist/_chunks/Relations-C6pwmDXh.mjs.map +1 -0
  47. package/dist/_chunks/{Relations-BPgFQeGj.js → Relations-Cne2AlrL.js} +71 -35
  48. package/dist/_chunks/Relations-Cne2AlrL.js.map +1 -0
  49. package/dist/_chunks/{en-CPTj6CjC.mjs → en-DhFUjrNW.mjs} +22 -11
  50. package/dist/_chunks/{en-CPTj6CjC.mjs.map → en-DhFUjrNW.mjs.map} +1 -1
  51. package/dist/_chunks/{en-BVzUkPxZ.js → en-Ic0kXjxB.js} +22 -11
  52. package/dist/_chunks/{en-BVzUkPxZ.js.map → en-Ic0kXjxB.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-D4UGPFZC.mjs → index-BpxR3En4.mjs} +887 -726
  62. package/dist/_chunks/index-BpxR3En4.mjs.map +1 -0
  63. package/dist/_chunks/{index-BhbLFX4l.js → index-T-aWjbj2.js} +884 -722
  64. package/dist/_chunks/index-T-aWjbj2.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-CYA7s0qO.js → layout-BEuNwv-F.js} +3 -3
  70. package/dist/_chunks/{layout-CYA7s0qO.js.map → layout-BEuNwv-F.js.map} +1 -1
  71. package/dist/_chunks/{layout-D4HI4_PS.mjs → layout-DhMZ_lDx.mjs} +3 -3
  72. package/dist/_chunks/{layout-D4HI4_PS.mjs.map → layout-DhMZ_lDx.mjs.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-1pXaYpBK.mjs → relations-BdnxoX6f.mjs} +6 -7
  78. package/dist/_chunks/relations-BdnxoX6f.mjs.map +1 -0
  79. package/dist/_chunks/{relations-DDZ9OxNo.js → relations-kLcuobLk.js} +6 -7
  80. package/dist/_chunks/relations-kLcuobLk.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/admin/src/services/documents.d.ts +0 -3
  99. package/dist/server/index.js +421 -160
  100. package/dist/server/index.js.map +1 -1
  101. package/dist/server/index.mjs +422 -161
  102. package/dist/server/index.mjs.map +1 -1
  103. package/dist/server/src/bootstrap.d.ts.map +1 -1
  104. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  105. package/dist/server/src/controllers/index.d.ts.map +1 -1
  106. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  107. package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
  108. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  109. package/dist/server/src/history/services/history.d.ts.map +1 -1
  110. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  111. package/dist/server/src/history/services/utils.d.ts +2 -3
  112. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  113. package/dist/server/src/index.d.ts +4 -4
  114. package/dist/server/src/preview/constants.d.ts +2 -0
  115. package/dist/server/src/preview/constants.d.ts.map +1 -0
  116. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  117. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  118. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  119. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  120. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  121. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  122. package/dist/server/src/preview/index.d.ts +4 -0
  123. package/dist/server/src/preview/index.d.ts.map +1 -0
  124. package/dist/server/src/preview/routes/index.d.ts +8 -0
  125. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  126. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  127. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  128. package/dist/server/src/preview/services/index.d.ts +16 -0
  129. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  130. package/dist/server/src/preview/services/preview-config.d.ts +32 -0
  131. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  132. package/dist/server/src/preview/services/preview.d.ts +12 -0
  133. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  134. package/dist/server/src/preview/utils.d.ts +19 -0
  135. package/dist/server/src/preview/utils.d.ts.map +1 -0
  136. package/dist/server/src/register.d.ts.map +1 -1
  137. package/dist/server/src/routes/index.d.ts.map +1 -1
  138. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  139. package/dist/server/src/services/document-metadata.d.ts +8 -8
  140. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  141. package/dist/server/src/services/index.d.ts +4 -4
  142. package/dist/server/src/services/index.d.ts.map +1 -1
  143. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  144. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  145. package/dist/server/src/utils/index.d.ts +2 -0
  146. package/dist/server/src/utils/index.d.ts.map +1 -1
  147. package/dist/shared/contracts/index.d.ts +1 -0
  148. package/dist/shared/contracts/index.d.ts.map +1 -1
  149. package/dist/shared/contracts/preview.d.ts +27 -0
  150. package/dist/shared/contracts/preview.d.ts.map +1 -0
  151. package/dist/shared/index.js +4 -0
  152. package/dist/shared/index.js.map +1 -1
  153. package/dist/shared/index.mjs +4 -0
  154. package/dist/shared/index.mjs.map +1 -1
  155. package/package.json +13 -13
  156. package/dist/_chunks/EditViewPage-DeTn7rAF.mjs.map +0 -1
  157. package/dist/_chunks/EditViewPage-G9uNzwYL.js.map +0 -1
  158. package/dist/_chunks/Field-CnCKhI1R.mjs.map +0 -1
  159. package/dist/_chunks/Field-DDHUWEfV.js.map +0 -1
  160. package/dist/_chunks/Form-DYETaKUX.js.map +0 -1
  161. package/dist/_chunks/Form-IvVVwqRL.mjs.map +0 -1
  162. package/dist/_chunks/History-BMunT-do.mjs.map +0 -1
  163. package/dist/_chunks/History-CnZDctSO.js.map +0 -1
  164. package/dist/_chunks/ListConfigurationPage-BynalOp8.js.map +0 -1
  165. package/dist/_chunks/ListConfigurationPage-CDqkCxgV.mjs.map +0 -1
  166. package/dist/_chunks/ListViewPage-I88Ouzoq.js.map +0 -1
  167. package/dist/_chunks/ListViewPage-_5gS-DOF.mjs.map +0 -1
  168. package/dist/_chunks/Relations-BPgFQeGj.js.map +0 -1
  169. package/dist/_chunks/Relations-Chdt5qWc.mjs.map +0 -1
  170. package/dist/_chunks/index-BhbLFX4l.js.map +0 -1
  171. package/dist/_chunks/index-D4UGPFZC.mjs.map +0 -1
  172. package/dist/_chunks/relations-1pXaYpBK.mjs.map +0 -1
  173. package/dist/_chunks/relations-DDZ9OxNo.js.map +0 -1
  174. package/strapi-server.js +0 -3
@@ -0,0 +1,291 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const strapiAdmin = require("@strapi/admin/strapi-admin");
6
+ const designSystem = require("@strapi/design-system");
7
+ const reactIntl = require("react-intl");
8
+ const reactRouterDom = require("react-router-dom");
9
+ const index = require("./index-T-aWjbj2.js");
10
+ const Icons = require("@strapi/icons");
11
+ const qs = require("qs");
12
+ const styledComponents = require("styled-components");
13
+ const EditViewPage = require("./EditViewPage-QPUftxUd.js");
14
+ function _interopNamespace(e) {
15
+ if (e && e.__esModule)
16
+ return e;
17
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
18
+ if (e) {
19
+ for (const k in e) {
20
+ if (k !== "default") {
21
+ const d = Object.getOwnPropertyDescriptor(e, k);
22
+ Object.defineProperty(n, k, d.get ? d : {
23
+ enumerable: true,
24
+ get: () => e[k]
25
+ });
26
+ }
27
+ }
28
+ }
29
+ n.default = e;
30
+ return Object.freeze(n);
31
+ }
32
+ const React__namespace = /* @__PURE__ */ _interopNamespace(React);
33
+ const PreviewContent = () => {
34
+ const previewUrl = usePreviewContext("PreviewContent", (state) => state.url);
35
+ const { formatMessage } = reactIntl.useIntl();
36
+ return /* @__PURE__ */ jsxRuntime.jsx(
37
+ designSystem.Box,
38
+ {
39
+ src: previewUrl,
40
+ title: formatMessage({
41
+ id: "content-manager.preview.panel.title",
42
+ defaultMessage: "Preview"
43
+ }),
44
+ width: "100%",
45
+ height: "100%",
46
+ borderWidth: 0,
47
+ tag: "iframe"
48
+ }
49
+ );
50
+ };
51
+ const ClosePreviewButton = () => {
52
+ const [{ query }] = strapiAdmin.useQueryParams();
53
+ const { formatMessage } = reactIntl.useIntl();
54
+ return /* @__PURE__ */ jsxRuntime.jsx(
55
+ designSystem.IconButton,
56
+ {
57
+ tag: reactRouterDom.Link,
58
+ relative: "path",
59
+ to: {
60
+ pathname: "..",
61
+ search: qs.stringify({ plugins: query.plugins }, { encode: false })
62
+ },
63
+ label: formatMessage({
64
+ id: "content-manager.preview.header.close",
65
+ defaultMessage: "Close preview"
66
+ }),
67
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {})
68
+ }
69
+ );
70
+ };
71
+ const Status = () => {
72
+ const document = usePreviewContext("PreviewHeader", (state) => state.document);
73
+ const schema = usePreviewContext("PreviewHeader", (state) => state.schema);
74
+ const meta = usePreviewContext("PreviewHeader", (state) => state.meta);
75
+ const hasDraftAndPublished = schema?.options?.draftAndPublish ?? false;
76
+ if (!hasDraftAndPublished) {
77
+ return null;
78
+ }
79
+ const status = EditViewPage.getDocumentStatus(document, meta);
80
+ return /* @__PURE__ */ jsxRuntime.jsx(index.DocumentStatus, { status, size: "XS" });
81
+ };
82
+ const PreviewTabs = () => {
83
+ const { formatMessage } = reactIntl.useIntl();
84
+ const [{ query }, setQuery] = strapiAdmin.useQueryParams();
85
+ const document = usePreviewContext("PreviewHeader", (state) => state.document);
86
+ const schema = usePreviewContext("PreviewHeader", (state) => state.schema);
87
+ const meta = usePreviewContext("PreviewHeader", (state) => state.meta);
88
+ const hasDraftAndPublish = schema?.options?.draftAndPublish ?? false;
89
+ const documentStatus = EditViewPage.getDocumentStatus(document, meta);
90
+ const handleTabChange = (status) => {
91
+ if (status === "published" || status === "draft") {
92
+ setQuery({ status }, "push", true);
93
+ }
94
+ };
95
+ if (!hasDraftAndPublish) {
96
+ return null;
97
+ }
98
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Root, { variant: "simple", value: query.status || "draft", onValueChange: handleTabChange, children: /* @__PURE__ */ jsxRuntime.jsxs(
99
+ designSystem.Tabs.List,
100
+ {
101
+ "aria-label": formatMessage({
102
+ id: "preview.tabs.label",
103
+ defaultMessage: "Document status"
104
+ }),
105
+ children: [
106
+ /* @__PURE__ */ jsxRuntime.jsx(StatusTab, { value: "draft", children: formatMessage({
107
+ id: "content-manager.containers.List.draft",
108
+ defaultMessage: "draft"
109
+ }) }),
110
+ /* @__PURE__ */ jsxRuntime.jsx(StatusTab, { value: "published", disabled: documentStatus === "draft", children: formatMessage({
111
+ id: "content-manager.containers.List.published",
112
+ defaultMessage: "published"
113
+ }) })
114
+ ]
115
+ }
116
+ ) }) });
117
+ };
118
+ const PreviewHeader = () => {
119
+ const mainField = usePreviewContext("PreviewHeader", (state) => state.mainField);
120
+ const document = usePreviewContext("PreviewHeader", (state) => state.document);
121
+ const title = document[mainField];
122
+ const { formatMessage } = reactIntl.useIntl();
123
+ const { toggleNotification } = strapiAdmin.useNotification();
124
+ const { copy } = strapiAdmin.useClipboard();
125
+ const handleCopyLink = () => {
126
+ copy(window.location.href);
127
+ toggleNotification({
128
+ message: formatMessage({
129
+ id: "content-manager.preview.copy.success",
130
+ defaultMessage: "Copied preview link"
131
+ }),
132
+ type: "success"
133
+ });
134
+ };
135
+ return /* @__PURE__ */ jsxRuntime.jsxs(
136
+ designSystem.Grid.Root,
137
+ {
138
+ gap: 3,
139
+ gridCols: 3,
140
+ paddingLeft: 2,
141
+ paddingRight: 2,
142
+ background: "neutral0",
143
+ borderColor: "neutral150",
144
+ tag: "header",
145
+ children: [
146
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Item, { xs: 1, paddingTop: 2, paddingBottom: 2, gap: 3, children: [
147
+ /* @__PURE__ */ jsxRuntime.jsx(ClosePreviewButton, {}),
148
+ /* @__PURE__ */ jsxRuntime.jsx(PreviewTitle, { tag: "h1", fontWeight: 600, fontSize: 2, maxWidth: "200px", children: title }),
149
+ /* @__PURE__ */ jsxRuntime.jsx(Status, {})
150
+ ] }),
151
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 1, marginBottom: "-1px", alignItems: "end", margin: "auto", children: /* @__PURE__ */ jsxRuntime.jsx(PreviewTabs, {}) }),
152
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 1, justifyContent: "end", paddingTop: 2, paddingBottom: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
153
+ designSystem.IconButton,
154
+ {
155
+ type: "button",
156
+ label: formatMessage({
157
+ id: "preview.copy.label",
158
+ defaultMessage: "Copy preview link"
159
+ }),
160
+ onClick: handleCopyLink,
161
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Link, {})
162
+ }
163
+ ) })
164
+ ]
165
+ }
166
+ );
167
+ };
168
+ const PreviewTitle = styledComponents.styled(designSystem.Typography)`
169
+ overflow: hidden;
170
+ text-overflow: ellipsis;
171
+ white-space: nowrap;
172
+ `;
173
+ const StatusTab = styledComponents.styled(designSystem.Tabs.Trigger)`
174
+ text-transform: uppercase;
175
+ `;
176
+ const [PreviewProvider, usePreviewContext] = strapiAdmin.createContext("PreviewPage");
177
+ const PreviewPage = () => {
178
+ const { formatMessage } = reactIntl.useIntl();
179
+ const {
180
+ slug: model,
181
+ id: documentId,
182
+ collectionType
183
+ } = reactRouterDom.useParams();
184
+ const [{ query }] = strapiAdmin.useQueryParams();
185
+ const params = React__namespace.useMemo(() => index.buildValidParams(query), [query]);
186
+ if (!collectionType) {
187
+ throw new Error("Could not find collectionType in url params");
188
+ }
189
+ if (!model) {
190
+ throw new Error("Could not find model in url params");
191
+ }
192
+ if (collectionType === index.COLLECTION_TYPES && !documentId) {
193
+ throw new Error("Could not find documentId in url params");
194
+ }
195
+ const previewUrlResponse = index.useGetPreviewUrlQuery({
196
+ params: {
197
+ contentType: model
198
+ },
199
+ query: {
200
+ documentId,
201
+ locale: params.locale,
202
+ status: params.status
203
+ }
204
+ });
205
+ const documentResponse = index.useDocument({
206
+ model,
207
+ collectionType,
208
+ documentId,
209
+ params
210
+ });
211
+ const documentLayoutResponse = index.useDocumentLayout(model);
212
+ if (documentResponse.isLoading || previewUrlResponse.isLoading || documentLayoutResponse.isLoading) {
213
+ return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Loading, {});
214
+ }
215
+ if (previewUrlResponse.error || documentLayoutResponse.error || !documentResponse.document || !documentResponse.meta || !documentResponse.schema) {
216
+ return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Error, {});
217
+ }
218
+ if (!previewUrlResponse.data?.data?.url) {
219
+ return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.NoData, {});
220
+ }
221
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
222
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Title, { children: formatMessage(
223
+ {
224
+ id: "content-manager.preview.page-title",
225
+ defaultMessage: "{contentType} preview"
226
+ },
227
+ {
228
+ contentType: documentLayoutResponse.edit.settings.displayName
229
+ }
230
+ ) }),
231
+ /* @__PURE__ */ jsxRuntime.jsx(
232
+ PreviewProvider,
233
+ {
234
+ url: previewUrlResponse.data.data.url,
235
+ mainField: documentLayoutResponse.edit.settings.mainField,
236
+ document: documentResponse.document,
237
+ meta: documentResponse.meta,
238
+ schema: documentResponse.schema,
239
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", height: "100%", alignItems: "stretch", children: [
240
+ /* @__PURE__ */ jsxRuntime.jsx(PreviewHeader, {}),
241
+ /* @__PURE__ */ jsxRuntime.jsx(PreviewContent, {})
242
+ ] })
243
+ }
244
+ )
245
+ ] });
246
+ };
247
+ const ProtectedPreviewPageImpl = () => {
248
+ const { slug: model } = reactRouterDom.useParams();
249
+ const {
250
+ permissions = [],
251
+ isLoading,
252
+ error
253
+ } = strapiAdmin.useRBAC([{ action: "plugin::content-manager.explorer.read", subject: model }]);
254
+ if (isLoading) {
255
+ return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Loading, {});
256
+ }
257
+ if (error || !model) {
258
+ return /* @__PURE__ */ jsxRuntime.jsx(
259
+ designSystem.Box,
260
+ {
261
+ height: "100vh",
262
+ width: "100vw",
263
+ position: "fixed",
264
+ top: 0,
265
+ left: 0,
266
+ zIndex: 2,
267
+ background: "neutral0",
268
+ children: /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Error, {})
269
+ }
270
+ );
271
+ }
272
+ return /* @__PURE__ */ jsxRuntime.jsx(
273
+ designSystem.Box,
274
+ {
275
+ height: "100vh",
276
+ width: "100vw",
277
+ position: "fixed",
278
+ top: 0,
279
+ left: 0,
280
+ zIndex: 2,
281
+ background: "neutral0",
282
+ children: /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Protect, { permissions, children: ({ permissions: permissions2 }) => /* @__PURE__ */ jsxRuntime.jsx(index.DocumentRBAC, { permissions: permissions2, children: /* @__PURE__ */ jsxRuntime.jsx(PreviewPage, {}) }) })
283
+ }
284
+ );
285
+ };
286
+ const ProtectedPreviewPage = () => {
287
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.FocusTrap, { children: /* @__PURE__ */ jsxRuntime.jsx(ProtectedPreviewPageImpl, {}) }) });
288
+ };
289
+ exports.ProtectedPreviewPage = ProtectedPreviewPage;
290
+ exports.usePreviewContext = usePreviewContext;
291
+ //# sourceMappingURL=Preview-D_3aO6Ly.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Preview-D_3aO6Ly.js","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":["useIntl","jsx","Box","useQueryParams","IconButton","Link","stringify","Cross","getDocumentStatus","DocumentStatus","Fragment","Tabs","jsxs","useNotification","useClipboard","Grid","LinkIcon","styled","Typography","createContext","useParams","React","buildValidParams","COLLECTION_TYPES","useGetPreviewUrlQuery","useDocument","useDocumentLayout","Page","Flex","useRBAC","permissions","DocumentRBAC","Portal","FocusTrap"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,iBAAiB,MAAM;AAC3B,QAAM,aAAa,kBAAkB,kBAAkB,CAAC,UAAU,MAAM,GAAG;AAErE,QAAA,EAAE,kBAAkBA,UAAAA;AAGxB,SAAAC,2BAAA;AAAA,IAACC,aAAA;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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AAK,OAAL,CAAA,CAAW;AAAA,MAAA;AAAA,IAAA;AAAA,EAGlB;AAGE,SAAA1B,2BAAA;AAAA,IAACC,aAAA;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,yCAACyB,YAAK,KAAA,SAAL,EAAa,aACX,WAAC,EAAE,aAAAG,aAAY,qCACbC,oBAAa,EAAA,aAAaD,cACzB,UAAC7B,2BAAA,IAAA,aAAA,CAAA,CAAY,EACf,CAAA,GAEJ;AAAA,IAAA;AAAA,EAAA;AAGN;AAEA,MAAM,uBAAuB,MAAM;AACjC,wCACG+B,aACC,QAAA,EAAA,UAAA/B,2BAAA,IAACgC,0BACC,UAAChC,2BAAA,IAAA,0BAAA,CAAyB,CAAA,EAC5B,CAAA,EACF,CAAA;AAEJ;;;"}
@@ -1,6 +1,6 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
- import { createContext, useQueryParams, useField, useNotification, useFocusInputField, useForm } from "@strapi/admin/strapi-admin";
3
+ import { createContext, useQueryParams, useForm, useField, useNotification, useFocusInputField } from "@strapi/admin/strapi-admin";
4
4
  import { Flex, TextButton, Field, Combobox, ComboboxOption, Typography, VisuallyHidden, Box, useComposedRefs, IconButton, Tooltip, Link } from "@strapi/design-system";
5
5
  import { ArrowClockwise, Drag, Cross } from "@strapi/icons";
6
6
  import { generateNKeysBetween } from "fractional-indexing";
@@ -10,15 +10,40 @@ import { useIntl } from "react-intl";
10
10
  import { NavLink } from "react-router-dom";
11
11
  import { FixedSizeList } from "react-window";
12
12
  import { styled } from "styled-components";
13
- import { c as useDoc, d as buildValidParams, C as COLLECTION_TYPES, g as getTranslation, D as DocumentStatus } from "./index-D4UGPFZC.mjs";
13
+ import { c as useDoc, d as buildValidParams, C as COLLECTION_TYPES, g as getTranslation, D as DocumentStatus } from "./index-BpxR3En4.mjs";
14
14
  import { u as useDragAndDrop, I as ItemTypes, D as DROP_SENSITIVITY } from "./useDragAndDrop-DdHgKsqq.mjs";
15
- import { u as useGetRelationsQuery, g as getRelationLabel, a as useLazySearchRelationsQuery } from "./relations-1pXaYpBK.mjs";
15
+ import { u as useGetRelationsQuery, g as getRelationLabel, a as useLazySearchRelationsQuery } from "./relations-BdnxoX6f.mjs";
16
16
  const [ComponentProvider, useComponent] = createContext("ComponentContext", {
17
17
  id: void 0,
18
18
  level: -1,
19
19
  uid: void 0,
20
20
  type: void 0
21
21
  });
22
+ function useHandleDisconnect(fieldName, consumerName) {
23
+ const field = useField(fieldName);
24
+ const removeFieldRow = useForm(consumerName, (state) => state.removeFieldRow);
25
+ const addFieldRow = useForm(consumerName, (state) => state.addFieldRow);
26
+ const handleDisconnect = (relation) => {
27
+ if (field.value && field.value.connect) {
28
+ const indexOfRelationInConnectArray = field.value.connect.findIndex(
29
+ (rel) => rel.id === relation.id
30
+ );
31
+ if (indexOfRelationInConnectArray >= 0) {
32
+ removeFieldRow(`${fieldName}.connect`, indexOfRelationInConnectArray);
33
+ return;
34
+ }
35
+ }
36
+ addFieldRow(`${fieldName}.disconnect`, {
37
+ id: relation.id,
38
+ apiData: {
39
+ id: relation.id,
40
+ documentId: relation.documentId,
41
+ locale: relation.locale
42
+ }
43
+ });
44
+ };
45
+ return handleDisconnect;
46
+ }
22
47
  const RELATIONS_TO_DISPLAY = 5;
23
48
  const ONE_WAY_RELATIONS = ["oneWay", "oneToOne", "manyToOne", "oneToManyMorph", "oneToOneMorph"];
24
49
  const RelationsField = React.forwardRef(
@@ -31,9 +56,16 @@ const RelationsField = React.forwardRef(
31
56
  const params = buildValidParams(query);
32
57
  const isMorph = props.attribute.relation.toLowerCase().includes("morph");
33
58
  const isDisabled = isMorph || disabled;
34
- const { id: componentId, uid } = useComponent("RelationsField", ({ uid: uid2, id: id2 }) => ({ id: id2, uid: uid2 }));
59
+ const { componentId, componentUID } = useComponent("RelationsField", ({ uid, id: id2 }) => ({
60
+ componentId: id2,
61
+ componentUID: uid
62
+ }));
63
+ const isSubmitting = useForm("RelationsList", (state) => state.isSubmitting);
64
+ React.useEffect(() => {
65
+ setCurrentPage(1);
66
+ }, [isSubmitting]);
35
67
  const id = componentId ? componentId.toString() : documentId;
36
- const model = uid ?? documentModel;
68
+ const model = componentUID ?? documentModel;
37
69
  const [targetField] = props.name.split(".").slice(-1);
38
70
  const { data, isLoading, isFetching } = useGetRelationsQuery(
39
71
  {
@@ -99,10 +131,16 @@ const RelationsField = React.forwardRef(
99
131
  props.attribute.targetModel,
100
132
  props.mainField
101
133
  ]);
134
+ const handleDisconnect = useHandleDisconnect(props.name, "RelationsField");
102
135
  const handleConnect = (relation) => {
103
136
  const [lastItemInList] = relations.slice(-1);
104
137
  const item = {
105
138
  id: relation.id,
139
+ apiData: {
140
+ id: relation.id,
141
+ documentId: relation.documentId,
142
+ locale: relation.locale
143
+ },
106
144
  status: relation.status,
107
145
  /**
108
146
  * If there's a last item, that's the first key we use to generate out next one.
@@ -112,9 +150,11 @@ const RelationsField = React.forwardRef(
112
150
  [props.mainField?.name ?? "documentId"]: relation[props.mainField?.name ?? "documentId"],
113
151
  label: getRelationLabel(relation, props.mainField),
114
152
  // @ts-expect-error – targetModel does exist on the attribute, but it's not typed.
115
- href: `../${COLLECTION_TYPES}/${props.attribute.targetModel}/${relation.documentId}`
153
+ href: `../${COLLECTION_TYPES}/${props.attribute.targetModel}/${relation.documentId}?${relation.locale ? `plugins[i18n][locale]=${relation.locale}` : ""}`
116
154
  };
117
155
  if (ONE_WAY_RELATIONS.includes(props.attribute.relation)) {
156
+ field.value?.connect?.forEach(handleDisconnect);
157
+ relations.forEach(handleDisconnect);
118
158
  field.onChange(`${props.name}.connect`, [item]);
119
159
  } else {
120
160
  field.onChange(`${props.name}.connect`, [...field.value?.connect ?? [], item]);
@@ -135,7 +175,7 @@ const RelationsField = React.forwardRef(
135
175
  RelationsInput,
136
176
  {
137
177
  disabled: isDisabled,
138
- id,
178
+ id: componentUID ? componentId ? `${componentId}` : "" : documentId,
139
179
  label: `${label} ${relationsCount > 0 ? `(${relationsCount})` : ""}`,
140
180
  model,
141
181
  onChange: handleConnect,
@@ -194,7 +234,7 @@ const addLabelAndHref = ({ mainField, href }) => (relations) => relations.map((r
194
234
  // Fallback to `id` if there is no `mainField` value, which will overwrite the above `documentId` property with the exact same data.
195
235
  [mainField?.name ?? "documentId"]: relation[mainField?.name ?? "documentId"],
196
236
  label: getRelationLabel(relation, mainField),
197
- href: `${href}/${relation.documentId}`
237
+ href: `${href}/${relation.documentId}?${relation.locale ? `plugins[i18n][locale]=${relation.locale}` : ""}`
198
238
  };
199
239
  });
200
240
  const RelationsInput = ({
@@ -289,7 +329,7 @@ const RelationsInput = ({
289
329
  {
290
330
  ref: fieldRef,
291
331
  name,
292
- autocomplete: "none",
332
+ autocomplete: "list",
293
333
  placeholder: placeholder || formatMessage({
294
334
  id: getTranslation("relation.add"),
295
335
  defaultMessage: "Add relation"
@@ -347,8 +387,6 @@ const RelationsList = ({
347
387
  const [overflow, setOverflow] = React.useState();
348
388
  const [liveText, setLiveText] = React.useState("");
349
389
  const field = useField(name);
350
- const removeFieldRow = useForm("RelationsList", (state) => state.removeFieldRow);
351
- const addFieldRow = useForm("RelationsList", (state) => state.addFieldRow);
352
390
  React.useEffect(() => {
353
391
  if (data.length <= RELATIONS_TO_DISPLAY) {
354
392
  return setOverflow(void 0);
@@ -398,17 +436,25 @@ const RelationsList = ({
398
436
  newData.splice(oldIndex, 1);
399
437
  newData.splice(newIndex, 0, { ...currentRow, __temp_key__: newKey });
400
438
  const connectedRelations = newData.reduce((acc, relation, currentIndex, array) => {
401
- const relationOnServer = serverData.find(
402
- (oldRelation) => oldRelation.documentId === relation.documentId
403
- );
439
+ const relationOnServer = serverData.find((oldRelation) => oldRelation.id === relation.id);
404
440
  const relationInFront = array[currentIndex + 1];
405
441
  if (!relationOnServer || relationOnServer.__temp_key__ !== relation.__temp_key__) {
406
442
  const position = relationInFront ? {
407
443
  before: relationInFront.documentId,
408
444
  locale: relationInFront.locale,
409
- status: relationInFront.status
445
+ status: "publishedAt" in relationInFront && relationInFront.publishedAt ? "published" : "draft"
410
446
  } : { end: true };
411
- const relationWithPosition = { ...relation, position };
447
+ const relationWithPosition = {
448
+ ...relation,
449
+ ...{
450
+ apiData: {
451
+ id: relation.id,
452
+ documentId: relation.documentId,
453
+ locale: relation.locale,
454
+ position
455
+ }
456
+ }
457
+ };
412
458
  return [...acc, relationWithPosition];
413
459
  }
414
460
  return acc;
@@ -459,18 +505,7 @@ const RelationsList = ({
459
505
  )
460
506
  );
461
507
  };
462
- const handleDisconnect = (relation) => {
463
- if (field.value && field.value.connect) {
464
- const indexOfRelationInConnectArray = field.value.connect.findIndex(
465
- (rel) => rel.id === relation.id
466
- );
467
- if (indexOfRelationInConnectArray >= 0) {
468
- removeFieldRow(`${name}.connect`, indexOfRelationInConnectArray);
469
- return;
470
- }
471
- }
472
- addFieldRow(`${name}.disconnect`, { id: relation.id });
473
- };
508
+ const handleDisconnect = useHandleDisconnect(name, "RelationsList");
474
509
  const canReorder = !ONE_WAY_RELATIONS.includes(relationType);
475
510
  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);
476
511
  return /* @__PURE__ */ jsxs(ShadowBox, { $overflowDirection: overflow, children: [
@@ -551,7 +586,7 @@ const ListItem = ({ data, index, style }) => {
551
586
  relations
552
587
  } = data;
553
588
  const { formatMessage } = useIntl();
554
- const { href, documentId, label, status } = relations[index];
589
+ const { href, id, label, status } = relations[index];
555
590
  const [{ handlerId, isDragging, handleKeyDown }, relationRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop(
556
591
  canDrag && !disabled,
557
592
  {
@@ -560,7 +595,7 @@ const ListItem = ({ data, index, style }) => {
560
595
  item: {
561
596
  displayedValue: label,
562
597
  status,
563
- id: documentId,
598
+ id,
564
599
  index
565
600
  },
566
601
  onMoveItem: handleMoveItem,
@@ -620,16 +655,17 @@ const ListItem = ({ data, index, style }) => {
620
655
  ] })
621
656
  ] }),
622
657
  /* @__PURE__ */ jsx(Box, { paddingLeft: 4, children: /* @__PURE__ */ jsx(
623
- DisconnectButton,
658
+ IconButton,
624
659
  {
625
- disabled,
626
- type: "button",
627
660
  onClick: () => handleDisconnect(relations[index]),
628
- "aria-label": formatMessage({
661
+ disabled,
662
+ label: formatMessage({
629
663
  id: getTranslation("relation.disconnect"),
630
664
  defaultMessage: "Remove"
631
665
  }),
632
- children: /* @__PURE__ */ jsx(Cross, { width: "12px" })
666
+ variant: "ghost",
667
+ size: "S",
668
+ children: /* @__PURE__ */ jsx(Cross, {})
633
669
  }
634
670
  ) })
635
671
  ]
@@ -691,4 +727,4 @@ export {
691
727
  MemoizedRelationsField as M,
692
728
  useComponent as u
693
729
  };
694
- //# sourceMappingURL=Relations-Chdt5qWc.mjs.map
730
+ //# sourceMappingURL=Relations-C6pwmDXh.mjs.map