@strapi/content-manager 0.0.0-next.959c5589d0d3efa25d7ca014656d9ff48c173399 → 0.0.0-next.ac654f8b8646bf964ebd39d4313c4afab0917a24

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 (144) hide show
  1. package/dist/_chunks/{ComponentConfigurationPage-gsCd80MU.js → ComponentConfigurationPage-CuKGBO3B.js} +3 -3
  2. package/dist/_chunks/{ComponentConfigurationPage-gsCd80MU.js.map → ComponentConfigurationPage-CuKGBO3B.js.map} +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-CIjXcRAB.mjs → ComponentConfigurationPage-DITz-KUa.mjs} +3 -3
  4. package/dist/_chunks/{ComponentConfigurationPage-CIjXcRAB.mjs.map → ComponentConfigurationPage-DITz-KUa.mjs.map} +1 -1
  5. package/dist/_chunks/{EditConfigurationPage-DHDQKBzw.js → EditConfigurationPage-aJ6Nk-e2.js} +3 -3
  6. package/dist/_chunks/{EditConfigurationPage-DHDQKBzw.js.map → EditConfigurationPage-aJ6Nk-e2.js.map} +1 -1
  7. package/dist/_chunks/{EditConfigurationPage-BglmD_BF.mjs → EditConfigurationPage-dpdSMBbB.mjs} +3 -3
  8. package/dist/_chunks/{EditConfigurationPage-BglmD_BF.mjs.map → EditConfigurationPage-dpdSMBbB.mjs.map} +1 -1
  9. package/dist/_chunks/{EditViewPage-C4iTxUPU.js → EditViewPage-CUUoPbuf.js} +37 -7
  10. package/dist/_chunks/EditViewPage-CUUoPbuf.js.map +1 -0
  11. package/dist/_chunks/{EditViewPage-CiwVPMaK.mjs → EditViewPage-HR-LggHQ.mjs} +38 -8
  12. package/dist/_chunks/EditViewPage-HR-LggHQ.mjs.map +1 -0
  13. package/dist/_chunks/{Field-DIjL1b5d.mjs → Field-D8UDC53O.mjs} +43 -24
  14. package/dist/_chunks/Field-D8UDC53O.mjs.map +1 -0
  15. package/dist/_chunks/{Field-DhXEK8y1.js → Field-PPOGQJFw.js} +42 -23
  16. package/dist/_chunks/Field-PPOGQJFw.js.map +1 -0
  17. package/dist/_chunks/{Form-CmNesrvR.mjs → Form-B63Fj3Fj.mjs} +2 -2
  18. package/dist/_chunks/{Form-CmNesrvR.mjs.map → Form-B63Fj3Fj.mjs.map} +1 -1
  19. package/dist/_chunks/{Form-CwmJ4sWe.js → Form-BcGPmYEy.js} +2 -2
  20. package/dist/_chunks/{Form-CwmJ4sWe.js.map → Form-BcGPmYEy.js.map} +1 -1
  21. package/dist/_chunks/{History-BLCCNgCt.js → History-2wgFZpc9.js} +20 -90
  22. package/dist/_chunks/History-2wgFZpc9.js.map +1 -0
  23. package/dist/_chunks/{History-D-99Wh30.mjs → History-HLNHu2qZ.mjs} +21 -91
  24. package/dist/_chunks/History-HLNHu2qZ.mjs.map +1 -0
  25. package/dist/_chunks/{ListConfigurationPage-JPWZz7Kg.mjs → ListConfigurationPage-CdZ3dURz.mjs} +5 -4
  26. package/dist/_chunks/ListConfigurationPage-CdZ3dURz.mjs.map +1 -0
  27. package/dist/_chunks/{ListConfigurationPage-DxWpeZrO.js → ListConfigurationPage-DJpH0BQ7.js} +4 -3
  28. package/dist/_chunks/ListConfigurationPage-DJpH0BQ7.js.map +1 -0
  29. package/dist/_chunks/{ListViewPage-CIQekSFz.js → ListViewPage-BSlwetiz.js} +62 -39
  30. package/dist/_chunks/ListViewPage-BSlwetiz.js.map +1 -0
  31. package/dist/_chunks/{ListViewPage-DSK3f0ST.mjs → ListViewPage-DmNN9hbm.mjs} +62 -39
  32. package/dist/_chunks/ListViewPage-DmNN9hbm.mjs.map +1 -0
  33. package/dist/_chunks/{NoContentTypePage-D99LU1YP.mjs → NoContentTypePage-Bn5ihosL.mjs} +2 -2
  34. package/dist/_chunks/{NoContentTypePage-D99LU1YP.mjs.map → NoContentTypePage-Bn5ihosL.mjs.map} +1 -1
  35. package/dist/_chunks/{NoContentTypePage-C5cxKvC2.js → NoContentTypePage-T65BK8ML.js} +2 -2
  36. package/dist/_chunks/{NoContentTypePage-C5cxKvC2.js.map → NoContentTypePage-T65BK8ML.js.map} +1 -1
  37. package/dist/_chunks/{NoPermissionsPage-DBrBw-0y.mjs → NoPermissionsPage-DaUbhwgn.mjs} +2 -2
  38. package/dist/_chunks/{NoPermissionsPage-DBrBw-0y.mjs.map → NoPermissionsPage-DaUbhwgn.mjs.map} +1 -1
  39. package/dist/_chunks/{NoPermissionsPage-Oy4tmUrW.js → NoPermissionsPage-DzKfa6Jp.js} +2 -2
  40. package/dist/_chunks/{NoPermissionsPage-Oy4tmUrW.js.map → NoPermissionsPage-DzKfa6Jp.js.map} +1 -1
  41. package/dist/_chunks/Preview-DfMsSYsj.js +286 -0
  42. package/dist/_chunks/Preview-DfMsSYsj.js.map +1 -0
  43. package/dist/_chunks/Preview-KmWscqhk.mjs +267 -0
  44. package/dist/_chunks/Preview-KmWscqhk.mjs.map +1 -0
  45. package/dist/_chunks/{Relations-BBmhcWFV.mjs → Relations-7f9zi6m0.mjs} +6 -3
  46. package/dist/_chunks/Relations-7f9zi6m0.mjs.map +1 -0
  47. package/dist/_chunks/{Relations-eG-9p_qS.js → Relations-DvizPJ_G.js} +6 -3
  48. package/dist/_chunks/Relations-DvizPJ_G.js.map +1 -0
  49. package/dist/_chunks/{en-DKV44jRb.mjs → en-CfIXaZf9.mjs} +14 -3
  50. package/dist/_chunks/{en-DKV44jRb.mjs.map → en-CfIXaZf9.mjs.map} +1 -1
  51. package/dist/_chunks/{en-Bm0D0IWz.js → en-DTWPCdTS.js} +14 -3
  52. package/dist/_chunks/{en-Bm0D0IWz.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-BIWDoFLK.js → index-Bi9g8evM.js} +147 -74
  62. package/dist/_chunks/index-Bi9g8evM.js.map +1 -0
  63. package/dist/_chunks/{index-BrUzbQ30.mjs → index-Dh8PRBs6.mjs} +151 -78
  64. package/dist/_chunks/index-Dh8PRBs6.mjs.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-lMc9i1-Z.js → layout-B5gVWKG8.js} +3 -3
  70. package/dist/_chunks/{layout-lMc9i1-Z.js.map → layout-B5gVWKG8.js.map} +1 -1
  71. package/dist/_chunks/{layout-_5-cXs34.mjs → layout-BUFUpPWR.mjs} +3 -3
  72. package/dist/_chunks/{layout-_5-cXs34.mjs.map → layout-BUFUpPWR.mjs.map} +1 -1
  73. package/dist/_chunks/{relations-BRHithi8.js → relations-BUm40kVE.js} +6 -3
  74. package/dist/_chunks/relations-BUm40kVE.js.map +1 -0
  75. package/dist/_chunks/{relations-B_VLk-DD.mjs → relations-CDnV9k0m.mjs} +6 -3
  76. package/dist/_chunks/relations-CDnV9k0m.mjs.map +1 -0
  77. package/dist/admin/index.js +1 -1
  78. package/dist/admin/index.mjs +4 -4
  79. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
  80. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
  81. package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
  82. package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
  83. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  84. package/dist/admin/src/preview/index.d.ts +1 -1
  85. package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
  86. package/dist/admin/src/preview/routes.d.ts +3 -0
  87. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  88. package/dist/admin/src/router.d.ts +1 -1
  89. package/dist/server/index.js +344 -136
  90. package/dist/server/index.js.map +1 -1
  91. package/dist/server/index.mjs +345 -137
  92. package/dist/server/index.mjs.map +1 -1
  93. package/dist/server/src/controllers/index.d.ts.map +1 -1
  94. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  95. package/dist/server/src/history/services/utils.d.ts +2 -3
  96. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  97. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  98. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  99. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  100. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  101. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  102. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  103. package/dist/server/src/preview/index.d.ts.map +1 -1
  104. package/dist/server/src/preview/routes/index.d.ts +8 -0
  105. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  106. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  107. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  108. package/dist/server/src/preview/services/index.d.ts +16 -0
  109. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  110. package/dist/server/src/preview/services/preview-config.d.ts +32 -0
  111. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  112. package/dist/server/src/preview/services/preview.d.ts +12 -0
  113. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  114. package/dist/server/src/preview/utils.d.ts +19 -0
  115. package/dist/server/src/preview/utils.d.ts.map +1 -0
  116. package/dist/server/src/register.d.ts.map +1 -1
  117. package/dist/server/src/routes/index.d.ts.map +1 -1
  118. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  119. package/dist/server/src/services/index.d.ts.map +1 -1
  120. package/dist/shared/contracts/index.d.ts +1 -0
  121. package/dist/shared/contracts/index.d.ts.map +1 -1
  122. package/dist/shared/contracts/preview.d.ts +27 -0
  123. package/dist/shared/contracts/preview.d.ts.map +1 -0
  124. package/dist/shared/index.js +4 -0
  125. package/dist/shared/index.js.map +1 -1
  126. package/dist/shared/index.mjs +4 -0
  127. package/dist/shared/index.mjs.map +1 -1
  128. package/package.json +10 -10
  129. package/dist/_chunks/EditViewPage-C4iTxUPU.js.map +0 -1
  130. package/dist/_chunks/EditViewPage-CiwVPMaK.mjs.map +0 -1
  131. package/dist/_chunks/Field-DIjL1b5d.mjs.map +0 -1
  132. package/dist/_chunks/Field-DhXEK8y1.js.map +0 -1
  133. package/dist/_chunks/History-BLCCNgCt.js.map +0 -1
  134. package/dist/_chunks/History-D-99Wh30.mjs.map +0 -1
  135. package/dist/_chunks/ListConfigurationPage-DxWpeZrO.js.map +0 -1
  136. package/dist/_chunks/ListConfigurationPage-JPWZz7Kg.mjs.map +0 -1
  137. package/dist/_chunks/ListViewPage-CIQekSFz.js.map +0 -1
  138. package/dist/_chunks/ListViewPage-DSK3f0ST.mjs.map +0 -1
  139. package/dist/_chunks/Relations-BBmhcWFV.mjs.map +0 -1
  140. package/dist/_chunks/Relations-eG-9p_qS.js.map +0 -1
  141. package/dist/_chunks/index-BIWDoFLK.js.map +0 -1
  142. package/dist/_chunks/index-BrUzbQ30.mjs.map +0 -1
  143. package/dist/_chunks/relations-BRHithi8.js.map +0 -1
  144. package/dist/_chunks/relations-B_VLk-DD.mjs.map +0 -1
@@ -0,0 +1,286 @@
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-Bi9g8evM.js");
10
+ const Icons = require("@strapi/icons");
11
+ const qs = require("qs");
12
+ const styledComponents = require("styled-components");
13
+ const EditViewPage = require("./EditViewPage-CUUoPbuf.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(designSystem.Typography, { 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 StatusTab = styledComponents.styled(designSystem.Tabs.Trigger)`
169
+ text-transform: uppercase;
170
+ `;
171
+ const [PreviewProvider, usePreviewContext] = strapiAdmin.createContext("PreviewPage");
172
+ const PreviewPage = () => {
173
+ const { formatMessage } = reactIntl.useIntl();
174
+ const {
175
+ slug: model,
176
+ id: documentId,
177
+ collectionType
178
+ } = reactRouterDom.useParams();
179
+ const [{ query }] = strapiAdmin.useQueryParams();
180
+ const params = React__namespace.useMemo(() => index.buildValidParams(query), [query]);
181
+ if (!collectionType) {
182
+ throw new Error("Could not find collectionType in url params");
183
+ }
184
+ if (!model) {
185
+ throw new Error("Could not find model in url params");
186
+ }
187
+ if (collectionType === index.COLLECTION_TYPES && !documentId) {
188
+ throw new Error("Could not find documentId in url params");
189
+ }
190
+ const previewUrlResponse = index.useGetPreviewUrlQuery({
191
+ params: {
192
+ contentType: model
193
+ },
194
+ query: {
195
+ documentId,
196
+ locale: params.locale,
197
+ status: params.status
198
+ }
199
+ });
200
+ const documentResponse = index.useDocument({
201
+ model,
202
+ collectionType,
203
+ documentId,
204
+ params
205
+ });
206
+ const documentLayoutResponse = index.useDocumentLayout(model);
207
+ if (documentResponse.isLoading || previewUrlResponse.isLoading || documentLayoutResponse.isLoading) {
208
+ return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Loading, {});
209
+ }
210
+ if (previewUrlResponse.error || documentLayoutResponse.error || !documentResponse.document || !documentResponse.meta || !documentResponse.schema) {
211
+ return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Error, {});
212
+ }
213
+ if (!previewUrlResponse.data?.data?.url) {
214
+ return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.NoData, {});
215
+ }
216
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
217
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Title, { children: formatMessage(
218
+ {
219
+ id: "content-manager.preview.page-title",
220
+ defaultMessage: "{contentType} preview"
221
+ },
222
+ {
223
+ contentType: documentLayoutResponse.edit.settings.displayName
224
+ }
225
+ ) }),
226
+ /* @__PURE__ */ jsxRuntime.jsx(
227
+ PreviewProvider,
228
+ {
229
+ url: previewUrlResponse.data.data.url,
230
+ mainField: documentLayoutResponse.edit.settings.mainField,
231
+ document: documentResponse.document,
232
+ meta: documentResponse.meta,
233
+ schema: documentResponse.schema,
234
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", height: "100%", alignItems: "stretch", children: [
235
+ /* @__PURE__ */ jsxRuntime.jsx(PreviewHeader, {}),
236
+ /* @__PURE__ */ jsxRuntime.jsx(PreviewContent, {})
237
+ ] })
238
+ }
239
+ )
240
+ ] });
241
+ };
242
+ const ProtectedPreviewPageImpl = () => {
243
+ const { slug: model } = reactRouterDom.useParams();
244
+ const {
245
+ permissions = [],
246
+ isLoading,
247
+ error
248
+ } = strapiAdmin.useRBAC([{ action: "plugin::content-manager.explorer.read", subject: model }]);
249
+ if (isLoading) {
250
+ return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Loading, {});
251
+ }
252
+ if (error || !model) {
253
+ return /* @__PURE__ */ jsxRuntime.jsx(
254
+ designSystem.Box,
255
+ {
256
+ height: "100vh",
257
+ width: "100vw",
258
+ position: "fixed",
259
+ top: 0,
260
+ left: 0,
261
+ zIndex: 2,
262
+ background: "neutral0",
263
+ children: /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Error, {})
264
+ }
265
+ );
266
+ }
267
+ return /* @__PURE__ */ jsxRuntime.jsx(
268
+ designSystem.Box,
269
+ {
270
+ height: "100vh",
271
+ width: "100vw",
272
+ position: "fixed",
273
+ top: 0,
274
+ left: 0,
275
+ zIndex: 2,
276
+ background: "neutral0",
277
+ children: /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Protect, { permissions, children: ({ permissions: permissions2 }) => /* @__PURE__ */ jsxRuntime.jsx(index.DocumentRBAC, { permissions: permissions2, children: /* @__PURE__ */ jsxRuntime.jsx(PreviewPage, {}) }) })
278
+ }
279
+ );
280
+ };
281
+ const ProtectedPreviewPage = () => {
282
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.FocusTrap, { children: /* @__PURE__ */ jsxRuntime.jsx(ProtectedPreviewPageImpl, {}) }) });
283
+ };
284
+ exports.ProtectedPreviewPage = ProtectedPreviewPage;
285
+ exports.usePreviewContext = usePreviewContext;
286
+ //# sourceMappingURL=Preview-DfMsSYsj.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Preview-DfMsSYsj.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 <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":["useIntl","jsx","Box","useQueryParams","IconButton","Link","stringify","Cross","getDocumentStatus","DocumentStatus","Fragment","Tabs","jsxs","useNotification","useClipboard","Grid","Typography","LinkIcon","styled","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/B,QAAM,CAAC,EAAE,OAAO,IAAIC,YAEjB,eAAA;AACG,QAAA,EAAE,kBAA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P,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;;;"}
@@ -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-Dh8PRBs6.mjs";
8
+ import { Link, Cross } from "@strapi/icons";
9
+ import { stringify } from "qs";
10
+ import { styled } from "styled-components";
11
+ import { getDocumentStatus } from "./EditViewPage-HR-LggHQ.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-KmWscqhk.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Preview-KmWscqhk.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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