@strapi/content-manager 0.0.0-experimental.a6728ad43ac70ae19dabb624dbfca1f2d9610a86 → 0.0.0-experimental.aa9d061a97e250ce2c7dc88ef3e41668bbf64351

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 (154) hide show
  1. package/dist/_chunks/{ComponentConfigurationPage-_6osrv39.js → ComponentConfigurationPage-CpJNPBgk.js} +4 -4
  2. package/dist/_chunks/{ComponentConfigurationPage-_6osrv39.js.map → ComponentConfigurationPage-CpJNPBgk.js.map} +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-DJ5voqEK.mjs → ComponentConfigurationPage-TYDPg5WG.mjs} +4 -4
  4. package/dist/_chunks/{ComponentConfigurationPage-DJ5voqEK.mjs.map → ComponentConfigurationPage-TYDPg5WG.mjs.map} +1 -1
  5. package/dist/_chunks/{EditConfigurationPage-ZN3s568V.js → EditConfigurationPage-CFDe6SA1.js} +4 -4
  6. package/dist/_chunks/{EditConfigurationPage-ZN3s568V.js.map → EditConfigurationPage-CFDe6SA1.js.map} +1 -1
  7. package/dist/_chunks/{EditConfigurationPage-CZofxSLy.mjs → EditConfigurationPage-DqL8Pq5r.mjs} +4 -4
  8. package/dist/_chunks/{EditConfigurationPage-CZofxSLy.mjs.map → EditConfigurationPage-DqL8Pq5r.mjs.map} +1 -1
  9. package/dist/_chunks/{EditViewPage-HYljoEY7.mjs → EditViewPage-RXrFLav2.mjs} +15 -5
  10. package/dist/_chunks/EditViewPage-RXrFLav2.mjs.map +1 -0
  11. package/dist/_chunks/{EditViewPage-Co2IKQZH.js → EditViewPage-khfP2CR3.js} +15 -5
  12. package/dist/_chunks/EditViewPage-khfP2CR3.js.map +1 -0
  13. package/dist/_chunks/{Field-BOPUMZ1u.mjs → Field--rQeS6Zj.mjs} +71 -27
  14. package/dist/_chunks/Field--rQeS6Zj.mjs.map +1 -0
  15. package/dist/_chunks/{Field-G9CkFUtP.js → Field-C1ftmTe9.js} +71 -27
  16. package/dist/_chunks/Field-C1ftmTe9.js.map +1 -0
  17. package/dist/_chunks/{Form-CDwNp7pU.mjs → Form-COtGXyUE.mjs} +3 -3
  18. package/dist/_chunks/Form-COtGXyUE.mjs.map +1 -0
  19. package/dist/_chunks/{Form-crsbkGxI.js → Form-CwdX5oLw.js} +3 -3
  20. package/dist/_chunks/Form-CwdX5oLw.js.map +1 -0
  21. package/dist/_chunks/{History-BDZrgfZ3.mjs → History-BevwkPO1.mjs} +38 -41
  22. package/dist/_chunks/History-BevwkPO1.mjs.map +1 -0
  23. package/dist/_chunks/{History-CWcM9HnW.js → History-DKS2aqqM.js} +37 -40
  24. package/dist/_chunks/History-DKS2aqqM.js.map +1 -0
  25. package/dist/_chunks/{ListConfigurationPage-BZ3ScUna.mjs → ListConfigurationPage-DNfZDtDA.mjs} +3 -3
  26. package/dist/_chunks/{ListConfigurationPage-BZ3ScUna.mjs.map → ListConfigurationPage-DNfZDtDA.mjs.map} +1 -1
  27. package/dist/_chunks/{ListConfigurationPage-DGzoQD_I.js → ListConfigurationPage-LSYSPZHH.js} +3 -3
  28. package/dist/_chunks/{ListConfigurationPage-DGzoQD_I.js.map → ListConfigurationPage-LSYSPZHH.js.map} +1 -1
  29. package/dist/_chunks/{ListViewPage-CsX7tWx-.mjs → ListViewPage-C1PyuYRS.mjs} +16 -5
  30. package/dist/_chunks/{ListViewPage-CsX7tWx-.mjs.map → ListViewPage-C1PyuYRS.mjs.map} +1 -1
  31. package/dist/_chunks/{ListViewPage-BBAC9aPu.js → ListViewPage-DlUpqLIo.js} +16 -5
  32. package/dist/_chunks/ListViewPage-DlUpqLIo.js.map +1 -0
  33. package/dist/_chunks/{NoContentTypePage-LClTUPWs.mjs → NoContentTypePage-C9q744z1.mjs} +2 -2
  34. package/dist/_chunks/{NoContentTypePage-LClTUPWs.mjs.map → NoContentTypePage-C9q744z1.mjs.map} +1 -1
  35. package/dist/_chunks/{NoContentTypePage-CwVDx_YC.js → NoContentTypePage-m8wt3sf6.js} +2 -2
  36. package/dist/_chunks/{NoContentTypePage-CwVDx_YC.js.map → NoContentTypePage-m8wt3sf6.js.map} +1 -1
  37. package/dist/_chunks/{NoPermissionsPage-S4Re3FwO.mjs → NoPermissionsPage-8BM-LWta.mjs} +2 -2
  38. package/dist/_chunks/{NoPermissionsPage-S4Re3FwO.mjs.map → NoPermissionsPage-8BM-LWta.mjs.map} +1 -1
  39. package/dist/_chunks/{NoPermissionsPage-D2iWw-sn.js → NoPermissionsPage-DLfPsA0Q.js} +2 -2
  40. package/dist/_chunks/{NoPermissionsPage-D2iWw-sn.js.map → NoPermissionsPage-DLfPsA0Q.js.map} +1 -1
  41. package/dist/_chunks/{Relations-Dmv0Tpe5.mjs → Relations-D25xRcFy.mjs} +72 -36
  42. package/dist/_chunks/Relations-D25xRcFy.mjs.map +1 -0
  43. package/dist/_chunks/{Relations-jwuTFGOV.js → Relations-OMriCP_L.js} +71 -35
  44. package/dist/_chunks/Relations-OMriCP_L.js.map +1 -0
  45. package/dist/_chunks/{en-BlhnxQfj.js → en-Bdpa50w3.js} +12 -8
  46. package/dist/_chunks/{en-BlhnxQfj.js.map → en-Bdpa50w3.js.map} +1 -1
  47. package/dist/_chunks/{en-C8YBvRrK.mjs → en-CZw4xdPY.mjs} +12 -8
  48. package/dist/_chunks/{en-C8YBvRrK.mjs.map → en-CZw4xdPY.mjs.map} +1 -1
  49. package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
  50. package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
  51. package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
  52. package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
  53. package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
  54. package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
  55. package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
  56. package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
  57. package/dist/_chunks/{index-BmUAydCA.mjs → index-BvGihCJp.mjs} +206 -88
  58. package/dist/_chunks/index-BvGihCJp.mjs.map +1 -0
  59. package/dist/_chunks/{index-CBX6KyXv.js → index-DqZnjo8F.js} +205 -86
  60. package/dist/_chunks/index-DqZnjo8F.js.map +1 -0
  61. package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
  62. package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
  63. package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
  64. package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
  65. package/dist/_chunks/{layout-CxxkX9jY.js → layout-CmaemAO3.js} +3 -3
  66. package/dist/_chunks/{layout-CxxkX9jY.js.map → layout-CmaemAO3.js.map} +1 -1
  67. package/dist/_chunks/{layout-ClP-DC72.mjs → layout-ykHSe2KQ.mjs} +3 -3
  68. package/dist/_chunks/{layout-ClP-DC72.mjs.map → layout-ykHSe2KQ.mjs.map} +1 -1
  69. package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
  70. package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
  71. package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
  72. package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
  73. package/dist/_chunks/{relations-DIjTADIu.js → relations-D9fKsCLY.js} +3 -7
  74. package/dist/_chunks/relations-D9fKsCLY.js.map +1 -0
  75. package/dist/_chunks/{relations-op89RClB.mjs → relations-u-Vz51Ea.mjs} +3 -7
  76. package/dist/_chunks/relations-u-Vz51Ea.mjs.map +1 -0
  77. package/dist/admin/index.js +1 -1
  78. package/dist/admin/index.mjs +1 -1
  79. package/dist/admin/src/hooks/useDocument.d.ts +2 -0
  80. package/dist/admin/src/pages/EditView/components/Header.d.ts +1 -0
  81. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  82. package/dist/admin/src/preview/constants.d.ts +1 -0
  83. package/dist/admin/src/preview/index.d.ts +4 -0
  84. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  85. package/dist/server/index.js +371 -158
  86. package/dist/server/index.js.map +1 -1
  87. package/dist/server/index.mjs +371 -158
  88. package/dist/server/index.mjs.map +1 -1
  89. package/dist/server/src/bootstrap.d.ts.map +1 -1
  90. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  91. package/dist/server/src/controllers/index.d.ts.map +1 -1
  92. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  93. package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
  94. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  95. package/dist/server/src/history/services/history.d.ts.map +1 -1
  96. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  97. package/dist/server/src/history/services/utils.d.ts +2 -3
  98. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  99. package/dist/server/src/index.d.ts +4 -4
  100. package/dist/server/src/preview/constants.d.ts +2 -0
  101. package/dist/server/src/preview/constants.d.ts.map +1 -0
  102. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  103. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  104. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  105. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  106. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  107. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  108. package/dist/server/src/preview/index.d.ts +4 -0
  109. package/dist/server/src/preview/index.d.ts.map +1 -0
  110. package/dist/server/src/preview/routes/index.d.ts +8 -0
  111. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  112. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  113. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  114. package/dist/server/src/preview/services/index.d.ts +15 -0
  115. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  116. package/dist/server/src/preview/services/preview-config.d.ts +30 -0
  117. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  118. package/dist/server/src/preview/services/preview.d.ts +12 -0
  119. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  120. package/dist/server/src/preview/utils.d.ts +18 -0
  121. package/dist/server/src/preview/utils.d.ts.map +1 -0
  122. package/dist/server/src/routes/index.d.ts.map +1 -1
  123. package/dist/server/src/services/document-metadata.d.ts +8 -8
  124. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  125. package/dist/server/src/services/index.d.ts +4 -4
  126. package/dist/server/src/services/index.d.ts.map +1 -1
  127. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  128. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  129. package/dist/server/src/utils/index.d.ts +2 -0
  130. package/dist/server/src/utils/index.d.ts.map +1 -1
  131. package/dist/shared/contracts/index.d.ts +1 -0
  132. package/dist/shared/contracts/index.d.ts.map +1 -1
  133. package/dist/shared/contracts/preview.d.ts +27 -0
  134. package/dist/shared/contracts/preview.d.ts.map +1 -0
  135. package/dist/shared/index.js +4 -0
  136. package/dist/shared/index.js.map +1 -1
  137. package/dist/shared/index.mjs +4 -0
  138. package/dist/shared/index.mjs.map +1 -1
  139. package/package.json +10 -10
  140. package/dist/_chunks/EditViewPage-Co2IKQZH.js.map +0 -1
  141. package/dist/_chunks/EditViewPage-HYljoEY7.mjs.map +0 -1
  142. package/dist/_chunks/Field-BOPUMZ1u.mjs.map +0 -1
  143. package/dist/_chunks/Field-G9CkFUtP.js.map +0 -1
  144. package/dist/_chunks/Form-CDwNp7pU.mjs.map +0 -1
  145. package/dist/_chunks/Form-crsbkGxI.js.map +0 -1
  146. package/dist/_chunks/History-BDZrgfZ3.mjs.map +0 -1
  147. package/dist/_chunks/History-CWcM9HnW.js.map +0 -1
  148. package/dist/_chunks/ListViewPage-BBAC9aPu.js.map +0 -1
  149. package/dist/_chunks/Relations-Dmv0Tpe5.mjs.map +0 -1
  150. package/dist/_chunks/Relations-jwuTFGOV.js.map +0 -1
  151. package/dist/_chunks/index-BmUAydCA.mjs.map +0 -1
  152. package/dist/_chunks/index-CBX6KyXv.js.map +0 -1
  153. package/dist/_chunks/relations-DIjTADIu.js.map +0 -1
  154. package/dist/_chunks/relations-op89RClB.mjs.map +0 -1
@@ -4,6 +4,7 @@ const jsxRuntime = require("react/jsx-runtime");
4
4
  const strapiAdmin = require("@strapi/admin/strapi-admin");
5
5
  const React = require("react");
6
6
  const designSystem = require("@strapi/design-system");
7
+ const mapValues = require("lodash/fp/mapValues");
7
8
  const reactIntl = require("react-intl");
8
9
  const reactRouterDom = require("react-router-dom");
9
10
  const yup = require("yup");
@@ -32,6 +33,7 @@ function _interopNamespace(e) {
32
33
  return Object.freeze(n);
33
34
  }
34
35
  const React__namespace = /* @__PURE__ */ _interopNamespace(React);
36
+ const mapValues__default = /* @__PURE__ */ _interopDefault(mapValues);
35
37
  const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
36
38
  const pipe__default = /* @__PURE__ */ _interopDefault(pipe);
37
39
  const __variableDynamicImportRuntimeHelper = (glob, path) => {
@@ -121,6 +123,7 @@ const DocumentRBAC = ({ children, permissions }) => {
121
123
  if (!slug) {
122
124
  throw new Error("Cannot find the slug param in the URL");
123
125
  }
126
+ const [{ rawQuery }] = strapiAdmin.useQueryParams();
124
127
  const userPermissions = strapiAdmin.useAuth("DocumentRBAC", (state) => state.permissions);
125
128
  const contentTypePermissions = React__namespace.useMemo(() => {
126
129
  const contentTypePermissions2 = userPermissions.filter(
@@ -131,7 +134,14 @@ const DocumentRBAC = ({ children, permissions }) => {
131
134
  return { ...acc, [action]: [permission] };
132
135
  }, {});
133
136
  }, [slug, userPermissions]);
134
- const { isLoading, allowedActions } = strapiAdmin.useRBAC(contentTypePermissions, permissions ?? void 0);
137
+ const { isLoading, allowedActions } = strapiAdmin.useRBAC(
138
+ contentTypePermissions,
139
+ permissions ?? void 0,
140
+ // TODO: useRBAC context should be typed and built differently
141
+ // We are passing raw query as context to the hook so that it can
142
+ // rely on the locale provided from DocumentRBAC for its permission calculations.
143
+ rawQuery
144
+ );
135
145
  const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
136
146
  const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
137
147
  const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
@@ -482,6 +492,24 @@ const buildValidParams = (query) => {
482
492
  const isBaseQueryError = (error) => {
483
493
  return error.name !== void 0;
484
494
  };
495
+ const arrayValidator = (attribute, options) => ({
496
+ message: strapiAdmin.translatedErrors.required,
497
+ test(value) {
498
+ if (options.status === "draft") {
499
+ return true;
500
+ }
501
+ if (!attribute.required) {
502
+ return true;
503
+ }
504
+ if (!value) {
505
+ return false;
506
+ }
507
+ if (Array.isArray(value) && value.length === 0) {
508
+ return false;
509
+ }
510
+ return true;
511
+ }
512
+ });
485
513
  const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
486
514
  const createModelSchema = (attributes2) => yup__namespace.object().shape(
487
515
  Object.entries(attributes2).reduce((acc, [name, attribute]) => {
@@ -489,6 +517,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
489
517
  return acc;
490
518
  }
491
519
  const validations = [
520
+ addNullableValidation,
492
521
  addRequiredValidation,
493
522
  addMinLengthValidation,
494
523
  addMaxLengthValidation,
@@ -505,12 +534,12 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
505
534
  ...acc,
506
535
  [name]: transformSchema(
507
536
  yup__namespace.array().of(createModelSchema(attributes3).nullable(false))
508
- )
537
+ ).test(arrayValidator(attribute, options))
509
538
  };
510
539
  } else {
511
540
  return {
512
541
  ...acc,
513
- [name]: transformSchema(createModelSchema(attributes3))
542
+ [name]: transformSchema(createModelSchema(attributes3).nullable())
514
543
  };
515
544
  }
516
545
  }
@@ -532,7 +561,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
532
561
  }
533
562
  )
534
563
  )
535
- )
564
+ ).test(arrayValidator(attribute, options))
536
565
  };
537
566
  case "relation":
538
567
  return {
@@ -544,7 +573,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
544
573
  } else if (Array.isArray(value)) {
545
574
  return yup__namespace.array().of(
546
575
  yup__namespace.object().shape({
547
- id: yup__namespace.string().required()
576
+ id: yup__namespace.number().required()
548
577
  })
549
578
  );
550
579
  } else if (typeof value === "object") {
@@ -630,17 +659,17 @@ const nullableSchema = (schema) => {
630
659
  schema
631
660
  );
632
661
  };
662
+ const addNullableValidation = () => (schema) => {
663
+ return nullableSchema(schema);
664
+ };
633
665
  const addRequiredValidation = (attribute, options) => (schema) => {
634
- if (options.status === "draft") {
635
- return nullableSchema(schema);
636
- }
637
- if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
638
- return schema.min(1, strapiAdmin.translatedErrors.required);
666
+ if (options.status === "draft" || !attribute.required) {
667
+ return schema;
639
668
  }
640
- if (attribute.required && attribute.type !== "relation") {
669
+ if (attribute.required && "required" in schema) {
641
670
  return schema.required(strapiAdmin.translatedErrors.required);
642
671
  }
643
- return nullableSchema(schema);
672
+ return schema;
644
673
  };
645
674
  const addMinLengthValidation = (attribute, options) => (schema) => {
646
675
  if (options.status === "draft") {
@@ -668,31 +697,12 @@ const addMaxLengthValidation = (attribute) => (schema) => {
668
697
  return schema;
669
698
  };
670
699
  const addMinValidation = (attribute, options) => (schema) => {
671
- if ("min" in attribute) {
700
+ if (options.status === "draft") {
701
+ return schema;
702
+ }
703
+ if ("min" in attribute && "min" in schema) {
672
704
  const min = toInteger(attribute.min);
673
- if (attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") {
674
- if (options.status !== "draft" && !attribute.required && "test" in schema && min) {
675
- return schema.test(
676
- "custom-min",
677
- {
678
- ...strapiAdmin.translatedErrors.min,
679
- values: {
680
- min: attribute.min
681
- }
682
- },
683
- (value) => {
684
- if (!value) {
685
- return true;
686
- }
687
- if (Array.isArray(value) && value.length === 0) {
688
- return true;
689
- }
690
- return value.length >= min;
691
- }
692
- );
693
- }
694
- }
695
- if ("min" in schema && min) {
705
+ if (min) {
696
706
  return schema.min(min, {
697
707
  ...strapiAdmin.translatedErrors.min,
698
708
  values: {
@@ -981,9 +991,10 @@ const formatEditLayout = (data, {
981
991
  currentPanelIndex += 2;
982
992
  } else {
983
993
  if (!panels[currentPanelIndex]) {
984
- panels.push([]);
994
+ panels.push([row]);
995
+ } else {
996
+ panels[currentPanelIndex].push(row);
985
997
  }
986
- panels[currentPanelIndex].push(row);
987
998
  }
988
999
  return panels;
989
1000
  }, []);
@@ -1165,11 +1176,13 @@ const useDocument = (args, opts) => {
1165
1176
  [validationSchema]
1166
1177
  );
1167
1178
  const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
1179
+ const hasError = !!error;
1168
1180
  return {
1169
1181
  components,
1170
1182
  document: data?.data,
1171
1183
  meta: data?.meta,
1172
1184
  isLoading,
1185
+ hasError,
1173
1186
  schema,
1174
1187
  schemas,
1175
1188
  validate
@@ -1185,16 +1198,18 @@ const useDoc = () => {
1185
1198
  if (!slug) {
1186
1199
  throw new Error("Could not find model in url params");
1187
1200
  }
1201
+ const document = useDocument(
1202
+ { documentId: origin || id, model: slug, collectionType, params },
1203
+ {
1204
+ skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
1205
+ }
1206
+ );
1207
+ const returnId = origin || id === "create" ? void 0 : id;
1188
1208
  return {
1189
1209
  collectionType,
1190
1210
  model: slug,
1191
- id: origin || id === "create" ? void 0 : id,
1192
- ...useDocument(
1193
- { documentId: origin || id, model: slug, collectionType, params },
1194
- {
1195
- skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
1196
- }
1197
- )
1211
+ id: returnId,
1212
+ ...document
1198
1213
  };
1199
1214
  };
1200
1215
  const useContentManagerContext = () => {
@@ -1237,9 +1252,6 @@ const useContentManagerContext = () => {
1237
1252
  };
1238
1253
  };
1239
1254
  const prefixPluginTranslations = (trad, pluginId) => {
1240
- if (!pluginId) {
1241
- throw new TypeError("pluginId can't be empty");
1242
- }
1243
1255
  return Object.keys(trad).reduce((acc, current) => {
1244
1256
  acc[`${pluginId}.${current}`] = trad[current];
1245
1257
  return acc;
@@ -1674,7 +1686,7 @@ const useDocumentActions = () => {
1674
1686
  };
1675
1687
  };
1676
1688
  const ProtectedHistoryPage = React.lazy(
1677
- () => Promise.resolve().then(() => require("./History-CWcM9HnW.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1689
+ () => Promise.resolve().then(() => require("./History-DKS2aqqM.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1678
1690
  );
1679
1691
  const routes$1 = [
1680
1692
  {
@@ -1687,31 +1699,31 @@ const routes$1 = [
1687
1699
  }
1688
1700
  ];
1689
1701
  const ProtectedEditViewPage = React.lazy(
1690
- () => Promise.resolve().then(() => require("./EditViewPage-Co2IKQZH.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1702
+ () => Promise.resolve().then(() => require("./EditViewPage-khfP2CR3.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1691
1703
  );
1692
1704
  const ProtectedListViewPage = React.lazy(
1693
- () => Promise.resolve().then(() => require("./ListViewPage-BBAC9aPu.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1705
+ () => Promise.resolve().then(() => require("./ListViewPage-DlUpqLIo.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1694
1706
  );
1695
1707
  const ProtectedListConfiguration = React.lazy(
1696
- () => Promise.resolve().then(() => require("./ListConfigurationPage-DGzoQD_I.js")).then((mod) => ({
1708
+ () => Promise.resolve().then(() => require("./ListConfigurationPage-LSYSPZHH.js")).then((mod) => ({
1697
1709
  default: mod.ProtectedListConfiguration
1698
1710
  }))
1699
1711
  );
1700
1712
  const ProtectedEditConfigurationPage = React.lazy(
1701
- () => Promise.resolve().then(() => require("./EditConfigurationPage-ZN3s568V.js")).then((mod) => ({
1713
+ () => Promise.resolve().then(() => require("./EditConfigurationPage-CFDe6SA1.js")).then((mod) => ({
1702
1714
  default: mod.ProtectedEditConfigurationPage
1703
1715
  }))
1704
1716
  );
1705
1717
  const ProtectedComponentConfigurationPage = React.lazy(
1706
- () => Promise.resolve().then(() => require("./ComponentConfigurationPage-_6osrv39.js")).then((mod) => ({
1718
+ () => Promise.resolve().then(() => require("./ComponentConfigurationPage-CpJNPBgk.js")).then((mod) => ({
1707
1719
  default: mod.ProtectedComponentConfigurationPage
1708
1720
  }))
1709
1721
  );
1710
1722
  const NoPermissions = React.lazy(
1711
- () => Promise.resolve().then(() => require("./NoPermissionsPage-D2iWw-sn.js")).then((mod) => ({ default: mod.NoPermissions }))
1723
+ () => Promise.resolve().then(() => require("./NoPermissionsPage-DLfPsA0Q.js")).then((mod) => ({ default: mod.NoPermissions }))
1712
1724
  );
1713
1725
  const NoContentType = React.lazy(
1714
- () => Promise.resolve().then(() => require("./NoContentTypePage-CwVDx_YC.js")).then((mod) => ({ default: mod.NoContentType }))
1726
+ () => Promise.resolve().then(() => require("./NoContentTypePage-m8wt3sf6.js")).then((mod) => ({ default: mod.NoContentType }))
1715
1727
  );
1716
1728
  const CollectionTypePages = () => {
1717
1729
  const { collectionType } = reactRouterDom.useParams();
@@ -2065,6 +2077,18 @@ const DocumentActionModal = ({
2065
2077
  typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
2066
2078
  ] }) });
2067
2079
  };
2080
+ const transformData = (data) => {
2081
+ if (Array.isArray(data)) {
2082
+ return data.map(transformData);
2083
+ }
2084
+ if (typeof data === "object" && data !== null) {
2085
+ if ("apiData" in data) {
2086
+ return data.apiData;
2087
+ }
2088
+ return mapValues__default.default(transformData)(data);
2089
+ }
2090
+ return data;
2091
+ };
2068
2092
  const PublishAction$1 = ({
2069
2093
  activeTab,
2070
2094
  documentId,
@@ -2158,7 +2182,9 @@ const PublishAction$1 = ({
2158
2182
  const performPublish = async () => {
2159
2183
  setSubmitting(true);
2160
2184
  try {
2161
- const { errors } = await validate();
2185
+ const { errors } = await validate(true, {
2186
+ status: "published"
2187
+ });
2162
2188
  if (errors) {
2163
2189
  toggleNotification({
2164
2190
  type: "danger",
@@ -2176,7 +2202,7 @@ const PublishAction$1 = ({
2176
2202
  documentId,
2177
2203
  params
2178
2204
  },
2179
- formValues
2205
+ transformData(formValues)
2180
2206
  );
2181
2207
  if ("data" in res && collectionType !== SINGLE_TYPES) {
2182
2208
  navigate({
@@ -2272,18 +2298,18 @@ const UpdateAction = ({
2272
2298
  onClick: async () => {
2273
2299
  setSubmitting(true);
2274
2300
  try {
2275
- if (activeTab !== "draft") {
2276
- const { errors } = await validate();
2277
- if (errors) {
2278
- toggleNotification({
2279
- type: "danger",
2280
- message: formatMessage({
2281
- id: "content-manager.validation.error",
2282
- defaultMessage: "There are validation errors in your document. Please fix them before saving."
2283
- })
2284
- });
2285
- return;
2286
- }
2301
+ const { errors } = await validate(true, {
2302
+ status: "draft"
2303
+ });
2304
+ if (errors) {
2305
+ toggleNotification({
2306
+ type: "danger",
2307
+ message: formatMessage({
2308
+ id: "content-manager.validation.error",
2309
+ defaultMessage: "There are validation errors in your document. Please fix them before saving."
2310
+ })
2311
+ });
2312
+ return;
2287
2313
  }
2288
2314
  if (isCloning) {
2289
2315
  const res = await clone(
@@ -2292,7 +2318,7 @@ const UpdateAction = ({
2292
2318
  documentId: cloneMatch.params.origin,
2293
2319
  params
2294
2320
  },
2295
- document
2321
+ transformData(document)
2296
2322
  );
2297
2323
  if ("data" in res) {
2298
2324
  navigate(
@@ -2313,7 +2339,7 @@ const UpdateAction = ({
2313
2339
  documentId,
2314
2340
  params
2315
2341
  },
2316
- document
2342
+ transformData(document)
2317
2343
  );
2318
2344
  if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
2319
2345
  setErrors(formatValidationErrors(res.error));
@@ -2326,7 +2352,7 @@ const UpdateAction = ({
2326
2352
  model,
2327
2353
  params
2328
2354
  },
2329
- document
2355
+ transformData(document)
2330
2356
  );
2331
2357
  if ("data" in res && collectionType !== SINGLE_TYPES) {
2332
2358
  navigate(
@@ -2665,12 +2691,12 @@ const Information = ({ activeTab }) => {
2665
2691
  isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
2666
2692
  label: formatMessage({
2667
2693
  id: "content-manager.containers.edit.information.last-published.label",
2668
- defaultMessage: "Last published"
2694
+ defaultMessage: "Published"
2669
2695
  }),
2670
2696
  value: formatMessage(
2671
2697
  {
2672
2698
  id: "content-manager.containers.edit.information.last-published.value",
2673
- defaultMessage: `Published {time}{isAnonymous, select, true {} other { by {author}}}`
2699
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2674
2700
  },
2675
2701
  {
2676
2702
  time: /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
@@ -2683,12 +2709,12 @@ const Information = ({ activeTab }) => {
2683
2709
  isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
2684
2710
  label: formatMessage({
2685
2711
  id: "content-manager.containers.edit.information.last-draft.label",
2686
- defaultMessage: "Last draft"
2712
+ defaultMessage: "Updated"
2687
2713
  }),
2688
2714
  value: formatMessage(
2689
2715
  {
2690
2716
  id: "content-manager.containers.edit.information.last-draft.value",
2691
- defaultMessage: `Modified {time}{isAnonymous, select, true {} other { by {author}}}`
2717
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2692
2718
  },
2693
2719
  {
2694
2720
  time: /* @__PURE__ */ jsxRuntime.jsx(
@@ -2706,12 +2732,12 @@ const Information = ({ activeTab }) => {
2706
2732
  isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
2707
2733
  label: formatMessage({
2708
2734
  id: "content-manager.containers.edit.information.document.label",
2709
- defaultMessage: "Document"
2735
+ defaultMessage: "Created"
2710
2736
  }),
2711
2737
  value: formatMessage(
2712
2738
  {
2713
2739
  id: "content-manager.containers.edit.information.document.value",
2714
- defaultMessage: `Created {time}{isAnonymous, select, true {} other { by {author}}}`
2740
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2715
2741
  },
2716
2742
  {
2717
2743
  time: /* @__PURE__ */ jsxRuntime.jsx(
@@ -2769,10 +2795,9 @@ const HeaderActions = ({ actions: actions2 }) => {
2769
2795
  designSystem.SingleSelect,
2770
2796
  {
2771
2797
  size: "S",
2772
- disabled: action.disabled,
2773
- "aria-label": action.label,
2774
2798
  onChange: action.onSelect,
2775
- value: action.value,
2799
+ "aria-label": action.label,
2800
+ ...action,
2776
2801
  children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { ...option, children: label }, option.value))
2777
2802
  },
2778
2803
  action.id
@@ -3015,7 +3040,7 @@ const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
3015
3040
  justifyContent: "stretch",
3016
3041
  alignItems: "flex-start",
3017
3042
  children: [
3018
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
3043
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", textColor: "neutral600", children: title }),
3019
3044
  children
3020
3045
  ]
3021
3046
  }
@@ -3998,6 +4023,97 @@ const { setInitialData } = actions;
3998
4023
  const reducer = toolkit.combineReducers({
3999
4024
  app: reducer$1
4000
4025
  });
4026
+ const previewApi = contentManagerApi.injectEndpoints({
4027
+ endpoints: (builder) => ({
4028
+ getPreviewUrl: builder.query({
4029
+ query({ query, params }) {
4030
+ return {
4031
+ url: `/content-manager/preview/url/${params.contentType}`,
4032
+ method: "GET",
4033
+ config: {
4034
+ params: query
4035
+ }
4036
+ };
4037
+ }
4038
+ })
4039
+ })
4040
+ });
4041
+ const { useGetPreviewUrlQuery } = previewApi;
4042
+ const PreviewSidePanel = ({ model, documentId, document }) => {
4043
+ const { formatMessage } = reactIntl.useIntl();
4044
+ const { toggleNotification } = strapiAdmin.useNotification();
4045
+ const { copy } = strapiAdmin.useClipboard();
4046
+ const { trackUsage } = strapiAdmin.useTracking();
4047
+ const { data, error } = useGetPreviewUrlQuery({
4048
+ params: {
4049
+ contentType: model
4050
+ },
4051
+ query: {
4052
+ documentId,
4053
+ locale: document?.locale,
4054
+ status: document?.status
4055
+ }
4056
+ });
4057
+ if (!data?.data?.url || error) {
4058
+ return null;
4059
+ }
4060
+ const { url } = data.data;
4061
+ const handleCopyLink = () => {
4062
+ copy(url);
4063
+ toggleNotification({
4064
+ message: formatMessage({
4065
+ id: "content-manager.preview.copy.success",
4066
+ defaultMessage: "Copied preview link"
4067
+ }),
4068
+ type: "success"
4069
+ });
4070
+ };
4071
+ const handleClick = () => {
4072
+ trackUsage("willOpenPreview");
4073
+ };
4074
+ return {
4075
+ title: formatMessage({ id: "content-manager.preview.panel.title", defaultMessage: "Preview" }),
4076
+ content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, width: "100%", children: [
4077
+ /* @__PURE__ */ jsxRuntime.jsx(
4078
+ designSystem.Button,
4079
+ {
4080
+ variant: "tertiary",
4081
+ tag: reactRouterDom.Link,
4082
+ to: url,
4083
+ onClick: handleClick,
4084
+ target: "_blank",
4085
+ flex: "auto",
4086
+ children: formatMessage({
4087
+ id: "content-manager.preview.panel.button",
4088
+ defaultMessage: "Open preview"
4089
+ })
4090
+ }
4091
+ ),
4092
+ /* @__PURE__ */ jsxRuntime.jsx(
4093
+ designSystem.IconButton,
4094
+ {
4095
+ type: "button",
4096
+ label: formatMessage({
4097
+ id: "preview.copy.label",
4098
+ defaultMessage: "Copy preview link"
4099
+ }),
4100
+ onClick: handleCopyLink,
4101
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Link, {})
4102
+ }
4103
+ )
4104
+ ] })
4105
+ };
4106
+ };
4107
+ const FEATURE_ID = "preview";
4108
+ const previewAdmin = {
4109
+ bootstrap(app) {
4110
+ if (!window.strapi.future.isEnabled(FEATURE_ID)) {
4111
+ return;
4112
+ }
4113
+ const contentManagerPluginApis = app.getPlugin("content-manager").apis;
4114
+ contentManagerPluginApis.addEditViewSidePanel([PreviewSidePanel]);
4115
+ }
4116
+ };
4001
4117
  const index = {
4002
4118
  register(app) {
4003
4119
  const cm = new ContentManagerPlugin();
@@ -4017,7 +4133,7 @@ const index = {
4017
4133
  app.router.addRoute({
4018
4134
  path: "content-manager/*",
4019
4135
  lazy: async () => {
4020
- const { Layout } = await Promise.resolve().then(() => require("./layout-CxxkX9jY.js"));
4136
+ const { Layout } = await Promise.resolve().then(() => require("./layout-CmaemAO3.js"));
4021
4137
  return {
4022
4138
  Component: Layout
4023
4139
  };
@@ -4030,11 +4146,14 @@ const index = {
4030
4146
  if (typeof historyAdmin.bootstrap === "function") {
4031
4147
  historyAdmin.bootstrap(app);
4032
4148
  }
4149
+ if (typeof previewAdmin.bootstrap === "function") {
4150
+ previewAdmin.bootstrap(app);
4151
+ }
4033
4152
  },
4034
4153
  async registerTrads({ locales }) {
4035
4154
  const importedTrads = await Promise.all(
4036
4155
  locales.map((locale) => {
4037
- return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => Promise.resolve().then(() => require("./ar-BUUWXIYu.js")), "./translations/ca.json": () => Promise.resolve().then(() => require("./ca-Cmk45QO6.js")), "./translations/cs.json": () => Promise.resolve().then(() => require("./cs-CkJy6B2v.js")), "./translations/de.json": () => Promise.resolve().then(() => require("./de-CCEmbAah.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-BlhnxQfj.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-EUonQTon.js")), "./translations/eu.json": () => Promise.resolve().then(() => require("./eu-VDH-3ovk.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-B7kGGg3E.js")), "./translations/gu.json": () => Promise.resolve().then(() => require("./gu-BRmF601H.js")), "./translations/hi.json": () => Promise.resolve().then(() => require("./hi-CCJBptSq.js")), "./translations/hu.json": () => Promise.resolve().then(() => require("./hu-sNV_yLYy.js")), "./translations/id.json": () => Promise.resolve().then(() => require("./id-B5Ser98A.js")), "./translations/it.json": () => Promise.resolve().then(() => require("./it-DkBIs7vD.js")), "./translations/ja.json": () => Promise.resolve().then(() => require("./ja-CcFe8diO.js")), "./translations/ko.json": () => Promise.resolve().then(() => require("./ko-woFZPmLk.js")), "./translations/ml.json": () => Promise.resolve().then(() => require("./ml-C2W8N8k1.js")), "./translations/ms.json": () => Promise.resolve().then(() => require("./ms-BuFotyP_.js")), "./translations/nl.json": () => Promise.resolve().then(() => require("./nl-bbEOHChV.js")), "./translations/pl.json": () => Promise.resolve().then(() => require("./pl-uzwG-hk7.js")), "./translations/pt-BR.json": () => Promise.resolve().then(() => require("./pt-BR-BiOz37D9.js")), "./translations/pt.json": () => Promise.resolve().then(() => require("./pt-CeXQuq50.js")), "./translations/ru.json": () => Promise.resolve().then(() => require("./ru-BT3ybNny.js")), "./translations/sa.json": () => Promise.resolve().then(() => require("./sa-CcvkYInH.js")), "./translations/sk.json": () => Promise.resolve().then(() => require("./sk-CvY09Xjv.js")), "./translations/sv.json": () => Promise.resolve().then(() => require("./sv-MYDuzgvT.js")), "./translations/th.json": () => Promise.resolve().then(() => require("./th-D9_GfAjc.js")), "./translations/tr.json": () => Promise.resolve().then(() => require("./tr-D9UH-O_R.js")), "./translations/uk.json": () => Promise.resolve().then(() => require("./uk-C8EiqJY7.js")), "./translations/vi.json": () => Promise.resolve().then(() => require("./vi-CJlYDheJ.js")), "./translations/zh-Hans.json": () => Promise.resolve().then(() => require("./zh-Hans-9kOncHGw.js")), "./translations/zh.json": () => Promise.resolve().then(() => require("./zh-CQQfszqR.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
4156
+ return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => Promise.resolve().then(() => require("./ar-BUUWXIYu.js")), "./translations/ca.json": () => Promise.resolve().then(() => require("./ca-Cmk45QO6.js")), "./translations/cs.json": () => Promise.resolve().then(() => require("./cs-CkJy6B2v.js")), "./translations/de.json": () => Promise.resolve().then(() => require("./de-CCEmbAah.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-Bdpa50w3.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-9K52xZIr.js")), "./translations/eu.json": () => Promise.resolve().then(() => require("./eu-VDH-3ovk.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-B2Kyv8Z9.js")), "./translations/gu.json": () => Promise.resolve().then(() => require("./gu-BRmF601H.js")), "./translations/hi.json": () => Promise.resolve().then(() => require("./hi-CCJBptSq.js")), "./translations/hu.json": () => Promise.resolve().then(() => require("./hu-sNV_yLYy.js")), "./translations/id.json": () => Promise.resolve().then(() => require("./id-B5Ser98A.js")), "./translations/it.json": () => Promise.resolve().then(() => require("./it-DkBIs7vD.js")), "./translations/ja.json": () => Promise.resolve().then(() => require("./ja-7sfIbjxE.js")), "./translations/ko.json": () => Promise.resolve().then(() => require("./ko-woFZPmLk.js")), "./translations/ml.json": () => Promise.resolve().then(() => require("./ml-C2W8N8k1.js")), "./translations/ms.json": () => Promise.resolve().then(() => require("./ms-BuFotyP_.js")), "./translations/nl.json": () => Promise.resolve().then(() => require("./nl-bbEOHChV.js")), "./translations/pl.json": () => Promise.resolve().then(() => require("./pl-uzwG-hk7.js")), "./translations/pt-BR.json": () => Promise.resolve().then(() => require("./pt-BR-BiOz37D9.js")), "./translations/pt.json": () => Promise.resolve().then(() => require("./pt-CeXQuq50.js")), "./translations/ru.json": () => Promise.resolve().then(() => require("./ru-BT3ybNny.js")), "./translations/sa.json": () => Promise.resolve().then(() => require("./sa-CcvkYInH.js")), "./translations/sk.json": () => Promise.resolve().then(() => require("./sk-CvY09Xjv.js")), "./translations/sv.json": () => Promise.resolve().then(() => require("./sv-MYDuzgvT.js")), "./translations/th.json": () => Promise.resolve().then(() => require("./th-D9_GfAjc.js")), "./translations/tr.json": () => Promise.resolve().then(() => require("./tr-D9UH-O_R.js")), "./translations/uk.json": () => Promise.resolve().then(() => require("./uk-C8EiqJY7.js")), "./translations/vi.json": () => Promise.resolve().then(() => require("./vi-CJlYDheJ.js")), "./translations/zh-Hans.json": () => Promise.resolve().then(() => require("./zh-Hans-9kOncHGw.js")), "./translations/zh.json": () => Promise.resolve().then(() => require("./zh-CQQfszqR.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
4038
4157
  return {
4039
4158
  data: prefixPluginTranslations(data, PLUGIN_ID),
4040
4159
  locale
@@ -4093,4 +4212,4 @@ exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
4093
4212
  exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
4094
4213
  exports.useGetInitialDataQuery = useGetInitialDataQuery;
4095
4214
  exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
4096
- //# sourceMappingURL=index-CBX6KyXv.js.map
4215
+ //# sourceMappingURL=index-DqZnjo8F.js.map