@strapi/content-manager 5.0.0-rc.29 → 5.0.0-rc.30

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 (67) hide show
  1. package/dist/_chunks/{ComponentConfigurationPage-Q3MBki6o.mjs → ComponentConfigurationPage-DfFSZQxe.mjs} +3 -3
  2. package/dist/_chunks/{ComponentConfigurationPage-Q3MBki6o.mjs.map → ComponentConfigurationPage-DfFSZQxe.mjs.map} +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-DA2b7951.js → ComponentConfigurationPage-FqfsxQ1j.js} +3 -3
  4. package/dist/_chunks/{ComponentConfigurationPage-DA2b7951.js.map → ComponentConfigurationPage-FqfsxQ1j.js.map} +1 -1
  5. package/dist/_chunks/{EditConfigurationPage-DcTgCayV.js → EditConfigurationPage-Cn0e8t3I.js} +3 -3
  6. package/dist/_chunks/{EditConfigurationPage-DcTgCayV.js.map → EditConfigurationPage-Cn0e8t3I.js.map} +1 -1
  7. package/dist/_chunks/{EditConfigurationPage-DtC0dCd4.mjs → EditConfigurationPage-DdPNAbl3.mjs} +3 -3
  8. package/dist/_chunks/{EditConfigurationPage-DtC0dCd4.mjs.map → EditConfigurationPage-DdPNAbl3.mjs.map} +1 -1
  9. package/dist/_chunks/{EditViewPage-BUTIgX0k.mjs → EditViewPage-B82x_x1b.mjs} +10 -4
  10. package/dist/_chunks/EditViewPage-B82x_x1b.mjs.map +1 -0
  11. package/dist/_chunks/{EditViewPage-CHTPxX7w.js → EditViewPage-DlxEHhUt.js} +10 -4
  12. package/dist/_chunks/EditViewPage-DlxEHhUt.js.map +1 -0
  13. package/dist/_chunks/{Field-BACD32AC.js → Field-COL25JiC.js} +34 -6
  14. package/dist/_chunks/Field-COL25JiC.js.map +1 -0
  15. package/dist/_chunks/{Field-CHz1D7f2.mjs → Field-DufHXW17.mjs} +34 -6
  16. package/dist/_chunks/Field-DufHXW17.mjs.map +1 -0
  17. package/dist/_chunks/{Form-CfZc-7D2.js → Form-BssUwrTO.js} +3 -3
  18. package/dist/_chunks/Form-BssUwrTO.js.map +1 -0
  19. package/dist/_chunks/{Form-QYM4wJ96.mjs → Form-u_kAOhwB.mjs} +3 -3
  20. package/dist/_chunks/Form-u_kAOhwB.mjs.map +1 -0
  21. package/dist/_chunks/{History-uzOvP0v7.js → History-C9t9UqpO.js} +4 -4
  22. package/dist/_chunks/{History-uzOvP0v7.js.map → History-C9t9UqpO.js.map} +1 -1
  23. package/dist/_chunks/{History-DnYsXm6Y.mjs → History-DRwA3oMM.mjs} +4 -4
  24. package/dist/_chunks/{History-DnYsXm6Y.mjs.map → History-DRwA3oMM.mjs.map} +1 -1
  25. package/dist/_chunks/{ListConfigurationPage-Bt0pWaEe.js → ListConfigurationPage-BXYPohh-.js} +2 -2
  26. package/dist/_chunks/{ListConfigurationPage-Bt0pWaEe.js.map → ListConfigurationPage-BXYPohh-.js.map} +1 -1
  27. package/dist/_chunks/{ListConfigurationPage-gDyBUhVg.mjs → ListConfigurationPage-BxfQJzPk.mjs} +2 -2
  28. package/dist/_chunks/{ListConfigurationPage-gDyBUhVg.mjs.map → ListConfigurationPage-BxfQJzPk.mjs.map} +1 -1
  29. package/dist/_chunks/{ListViewPage-BbIAk2tn.mjs → ListViewPage-CELx2ysp.mjs} +3 -3
  30. package/dist/_chunks/{ListViewPage-BbIAk2tn.mjs.map → ListViewPage-CELx2ysp.mjs.map} +1 -1
  31. package/dist/_chunks/{ListViewPage-wFTl4mhg.js → ListViewPage-D2VD8Szg.js} +3 -3
  32. package/dist/_chunks/{ListViewPage-wFTl4mhg.js.map → ListViewPage-D2VD8Szg.js.map} +1 -1
  33. package/dist/_chunks/{NoContentTypePage-C00E-YlW.js → NoContentTypePage-BV9IjJSM.js} +2 -2
  34. package/dist/_chunks/{NoContentTypePage-C00E-YlW.js.map → NoContentTypePage-BV9IjJSM.js.map} +1 -1
  35. package/dist/_chunks/{NoContentTypePage-D1lqRImn.mjs → NoContentTypePage-DtJ9jcfk.mjs} +2 -2
  36. package/dist/_chunks/{NoContentTypePage-D1lqRImn.mjs.map → NoContentTypePage-DtJ9jcfk.mjs.map} +1 -1
  37. package/dist/_chunks/{NoPermissionsPage-Dw6EuQRg.mjs → NoPermissionsPage-DWleVYK7.mjs} +2 -2
  38. package/dist/_chunks/{NoPermissionsPage-Dw6EuQRg.mjs.map → NoPermissionsPage-DWleVYK7.mjs.map} +1 -1
  39. package/dist/_chunks/{NoPermissionsPage-CoPjjrjk.js → NoPermissionsPage-Dp8NpF9I.js} +2 -2
  40. package/dist/_chunks/{NoPermissionsPage-CoPjjrjk.js.map → NoPermissionsPage-Dp8NpF9I.js.map} +1 -1
  41. package/dist/_chunks/{Relations-BIwBQsRs.mjs → Relations-BTcf5xaw.mjs} +3 -3
  42. package/dist/_chunks/{Relations-BIwBQsRs.mjs.map → Relations-BTcf5xaw.mjs.map} +1 -1
  43. package/dist/_chunks/{Relations-CcvUrZ05.js → Relations-DR7EUgyC.js} +3 -3
  44. package/dist/_chunks/{Relations-CcvUrZ05.js.map → Relations-DR7EUgyC.js.map} +1 -1
  45. package/dist/_chunks/{index-DtUjHZAE.js → index-BdMf2lfT.js} +59 -57
  46. package/dist/_chunks/index-BdMf2lfT.js.map +1 -0
  47. package/dist/_chunks/{index-1E1riyM7.mjs → index-wnqzm4Q8.mjs} +59 -57
  48. package/dist/_chunks/index-wnqzm4Q8.mjs.map +1 -0
  49. package/dist/_chunks/{layout-Bn9hdVmT.mjs → layout-2CfjL0T9.mjs} +3 -3
  50. package/dist/_chunks/{layout-Bn9hdVmT.mjs.map → layout-2CfjL0T9.mjs.map} +1 -1
  51. package/dist/_chunks/{layout-DQUYYv3O.js → layout-B2MyZU-_.js} +3 -3
  52. package/dist/_chunks/{layout-DQUYYv3O.js.map → layout-B2MyZU-_.js.map} +1 -1
  53. package/dist/_chunks/{relations-Cg5peQZL.js → relations-BH7JJGGe.js} +2 -2
  54. package/dist/_chunks/{relations-Cg5peQZL.js.map → relations-BH7JJGGe.js.map} +1 -1
  55. package/dist/_chunks/{relations-BvUTlaYl.mjs → relations-C0w0GcXi.mjs} +2 -2
  56. package/dist/_chunks/{relations-BvUTlaYl.mjs.map → relations-C0w0GcXi.mjs.map} +1 -1
  57. package/dist/admin/index.js +1 -1
  58. package/dist/admin/index.mjs +1 -1
  59. package/package.json +6 -6
  60. package/dist/_chunks/EditViewPage-BUTIgX0k.mjs.map +0 -1
  61. package/dist/_chunks/EditViewPage-CHTPxX7w.js.map +0 -1
  62. package/dist/_chunks/Field-BACD32AC.js.map +0 -1
  63. package/dist/_chunks/Field-CHz1D7f2.mjs.map +0 -1
  64. package/dist/_chunks/Form-CfZc-7D2.js.map +0 -1
  65. package/dist/_chunks/Form-QYM4wJ96.mjs.map +0 -1
  66. package/dist/_chunks/index-1E1riyM7.mjs.map +0 -1
  67. package/dist/_chunks/index-DtUjHZAE.js.map +0 -1
@@ -490,6 +490,24 @@ const buildValidParams = (query) => {
490
490
  const isBaseQueryError = (error) => {
491
491
  return error.name !== void 0;
492
492
  };
493
+ const arrayValidator = (attribute, options) => ({
494
+ message: strapiAdmin.translatedErrors.required,
495
+ test(value) {
496
+ if (options.status === "draft") {
497
+ return true;
498
+ }
499
+ if (!attribute.required) {
500
+ return true;
501
+ }
502
+ if (!value) {
503
+ return false;
504
+ }
505
+ if (Array.isArray(value) && value.length === 0) {
506
+ return false;
507
+ }
508
+ return true;
509
+ }
510
+ });
493
511
  const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
494
512
  const createModelSchema = (attributes2) => yup__namespace.object().shape(
495
513
  Object.entries(attributes2).reduce((acc, [name, attribute]) => {
@@ -497,6 +515,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
497
515
  return acc;
498
516
  }
499
517
  const validations = [
518
+ addNullableValidation,
500
519
  addRequiredValidation,
501
520
  addMinLengthValidation,
502
521
  addMaxLengthValidation,
@@ -513,12 +532,12 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
513
532
  ...acc,
514
533
  [name]: transformSchema(
515
534
  yup__namespace.array().of(createModelSchema(attributes3).nullable(false))
516
- )
535
+ ).test(arrayValidator(attribute, options))
517
536
  };
518
537
  } else {
519
538
  return {
520
539
  ...acc,
521
- [name]: transformSchema(createModelSchema(attributes3))
540
+ [name]: transformSchema(createModelSchema(attributes3).nullable())
522
541
  };
523
542
  }
524
543
  }
@@ -540,7 +559,7 @@ const createYupSchema = (attributes = {}, components = {}, options = { status: n
540
559
  }
541
560
  )
542
561
  )
543
- )
562
+ ).test(arrayValidator(attribute, options))
544
563
  };
545
564
  case "relation":
546
565
  return {
@@ -638,17 +657,17 @@ const nullableSchema = (schema) => {
638
657
  schema
639
658
  );
640
659
  };
660
+ const addNullableValidation = () => (schema) => {
661
+ return nullableSchema(schema);
662
+ };
641
663
  const addRequiredValidation = (attribute, options) => (schema) => {
642
- if (options.status === "draft") {
643
- return nullableSchema(schema);
644
- }
645
- if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
646
- return schema.min(1, strapiAdmin.translatedErrors.required);
664
+ if (options.status === "draft" || !attribute.required) {
665
+ return schema;
647
666
  }
648
- if (attribute.required && attribute.type !== "relation") {
667
+ if (attribute.required && "required" in schema) {
649
668
  return schema.required(strapiAdmin.translatedErrors.required);
650
669
  }
651
- return nullableSchema(schema);
670
+ return schema;
652
671
  };
653
672
  const addMinLengthValidation = (attribute, options) => (schema) => {
654
673
  if (options.status === "draft") {
@@ -676,31 +695,12 @@ const addMaxLengthValidation = (attribute) => (schema) => {
676
695
  return schema;
677
696
  };
678
697
  const addMinValidation = (attribute, options) => (schema) => {
679
- if ("min" in attribute) {
698
+ if (options.status === "draft") {
699
+ return schema;
700
+ }
701
+ if ("min" in attribute && "min" in schema) {
680
702
  const min = toInteger(attribute.min);
681
- if (attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") {
682
- if (options.status !== "draft" && !attribute.required && "test" in schema && min) {
683
- return schema.test(
684
- "custom-min",
685
- {
686
- ...strapiAdmin.translatedErrors.min,
687
- values: {
688
- min: attribute.min
689
- }
690
- },
691
- (value) => {
692
- if (!value) {
693
- return true;
694
- }
695
- if (Array.isArray(value) && value.length === 0) {
696
- return true;
697
- }
698
- return value.length >= min;
699
- }
700
- );
701
- }
702
- }
703
- if ("min" in schema && min) {
703
+ if (min) {
704
704
  return schema.min(min, {
705
705
  ...strapiAdmin.translatedErrors.min,
706
706
  values: {
@@ -1686,7 +1686,7 @@ const useDocumentActions = () => {
1686
1686
  };
1687
1687
  };
1688
1688
  const ProtectedHistoryPage = React.lazy(
1689
- () => Promise.resolve().then(() => require("./History-uzOvP0v7.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1689
+ () => Promise.resolve().then(() => require("./History-C9t9UqpO.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1690
1690
  );
1691
1691
  const routes$1 = [
1692
1692
  {
@@ -1699,31 +1699,31 @@ const routes$1 = [
1699
1699
  }
1700
1700
  ];
1701
1701
  const ProtectedEditViewPage = React.lazy(
1702
- () => Promise.resolve().then(() => require("./EditViewPage-CHTPxX7w.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1702
+ () => Promise.resolve().then(() => require("./EditViewPage-DlxEHhUt.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1703
1703
  );
1704
1704
  const ProtectedListViewPage = React.lazy(
1705
- () => Promise.resolve().then(() => require("./ListViewPage-wFTl4mhg.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1705
+ () => Promise.resolve().then(() => require("./ListViewPage-D2VD8Szg.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1706
1706
  );
1707
1707
  const ProtectedListConfiguration = React.lazy(
1708
- () => Promise.resolve().then(() => require("./ListConfigurationPage-Bt0pWaEe.js")).then((mod) => ({
1708
+ () => Promise.resolve().then(() => require("./ListConfigurationPage-BXYPohh-.js")).then((mod) => ({
1709
1709
  default: mod.ProtectedListConfiguration
1710
1710
  }))
1711
1711
  );
1712
1712
  const ProtectedEditConfigurationPage = React.lazy(
1713
- () => Promise.resolve().then(() => require("./EditConfigurationPage-DcTgCayV.js")).then((mod) => ({
1713
+ () => Promise.resolve().then(() => require("./EditConfigurationPage-Cn0e8t3I.js")).then((mod) => ({
1714
1714
  default: mod.ProtectedEditConfigurationPage
1715
1715
  }))
1716
1716
  );
1717
1717
  const ProtectedComponentConfigurationPage = React.lazy(
1718
- () => Promise.resolve().then(() => require("./ComponentConfigurationPage-DA2b7951.js")).then((mod) => ({
1718
+ () => Promise.resolve().then(() => require("./ComponentConfigurationPage-FqfsxQ1j.js")).then((mod) => ({
1719
1719
  default: mod.ProtectedComponentConfigurationPage
1720
1720
  }))
1721
1721
  );
1722
1722
  const NoPermissions = React.lazy(
1723
- () => Promise.resolve().then(() => require("./NoPermissionsPage-CoPjjrjk.js")).then((mod) => ({ default: mod.NoPermissions }))
1723
+ () => Promise.resolve().then(() => require("./NoPermissionsPage-Dp8NpF9I.js")).then((mod) => ({ default: mod.NoPermissions }))
1724
1724
  );
1725
1725
  const NoContentType = React.lazy(
1726
- () => Promise.resolve().then(() => require("./NoContentTypePage-C00E-YlW.js")).then((mod) => ({ default: mod.NoContentType }))
1726
+ () => Promise.resolve().then(() => require("./NoContentTypePage-BV9IjJSM.js")).then((mod) => ({ default: mod.NoContentType }))
1727
1727
  );
1728
1728
  const CollectionTypePages = () => {
1729
1729
  const { collectionType } = reactRouterDom.useParams();
@@ -2170,7 +2170,9 @@ const PublishAction$1 = ({
2170
2170
  const performPublish = async () => {
2171
2171
  setSubmitting(true);
2172
2172
  try {
2173
- const { errors } = await validate();
2173
+ const { errors } = await validate(true, {
2174
+ status: "published"
2175
+ });
2174
2176
  if (errors) {
2175
2177
  toggleNotification({
2176
2178
  type: "danger",
@@ -2284,18 +2286,18 @@ const UpdateAction = ({
2284
2286
  onClick: async () => {
2285
2287
  setSubmitting(true);
2286
2288
  try {
2287
- if (activeTab !== "draft") {
2288
- const { errors } = await validate();
2289
- if (errors) {
2290
- toggleNotification({
2291
- type: "danger",
2292
- message: formatMessage({
2293
- id: "content-manager.validation.error",
2294
- defaultMessage: "There are validation errors in your document. Please fix them before saving."
2295
- })
2296
- });
2297
- return;
2298
- }
2289
+ const { errors } = await validate(true, {
2290
+ status: "draft"
2291
+ });
2292
+ if (errors) {
2293
+ toggleNotification({
2294
+ type: "danger",
2295
+ message: formatMessage({
2296
+ id: "content-manager.validation.error",
2297
+ defaultMessage: "There are validation errors in your document. Please fix them before saving."
2298
+ })
2299
+ });
2300
+ return;
2299
2301
  }
2300
2302
  if (isCloning) {
2301
2303
  const res = await clone(
@@ -4028,7 +4030,7 @@ const index = {
4028
4030
  app.router.addRoute({
4029
4031
  path: "content-manager/*",
4030
4032
  lazy: async () => {
4031
- const { Layout } = await Promise.resolve().then(() => require("./layout-DQUYYv3O.js"));
4033
+ const { Layout } = await Promise.resolve().then(() => require("./layout-B2MyZU-_.js"));
4032
4034
  return {
4033
4035
  Component: Layout
4034
4036
  };
@@ -4104,4 +4106,4 @@ exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
4104
4106
  exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
4105
4107
  exports.useGetInitialDataQuery = useGetInitialDataQuery;
4106
4108
  exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
4107
- //# sourceMappingURL=index-DtUjHZAE.js.map
4109
+ //# sourceMappingURL=index-BdMf2lfT.js.map