@strapi/content-manager 5.0.0-rc.7 → 5.0.0-rc.9

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 (82) hide show
  1. package/dist/_chunks/{ComponentConfigurationPage-BNxtMIfV.js → ComponentConfigurationPage-BOKmq7mz.js} +3 -3
  2. package/dist/_chunks/{ComponentConfigurationPage-BNxtMIfV.js.map → ComponentConfigurationPage-BOKmq7mz.js.map} +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-BWOQWCv2.mjs → ComponentConfigurationPage-BwnO0su2.mjs} +3 -3
  4. package/dist/_chunks/{ComponentConfigurationPage-BWOQWCv2.mjs.map → ComponentConfigurationPage-BwnO0su2.mjs.map} +1 -1
  5. package/dist/_chunks/{EditConfigurationPage-GTp-Ucnw.mjs → EditConfigurationPage-DJDSIf3D.mjs} +3 -3
  6. package/dist/_chunks/{EditConfigurationPage-GTp-Ucnw.mjs.map → EditConfigurationPage-DJDSIf3D.mjs.map} +1 -1
  7. package/dist/_chunks/{EditConfigurationPage-D340bYlT.js → EditConfigurationPage-N3OaN53v.js} +3 -3
  8. package/dist/_chunks/{EditConfigurationPage-D340bYlT.js.map → EditConfigurationPage-N3OaN53v.js.map} +1 -1
  9. package/dist/_chunks/{EditViewPage-BVMS5hT-.mjs → EditViewPage-IZbGSeL3.mjs} +19 -8
  10. package/dist/_chunks/EditViewPage-IZbGSeL3.mjs.map +1 -0
  11. package/dist/_chunks/{EditViewPage-CXkmnAvI.js → EditViewPage-l9qOdDUI.js} +19 -8
  12. package/dist/_chunks/EditViewPage-l9qOdDUI.js.map +1 -0
  13. package/dist/_chunks/{Field-Ibi32diw.js → Field-CWjyW47-.js} +89 -30
  14. package/dist/_chunks/Field-CWjyW47-.js.map +1 -0
  15. package/dist/_chunks/{Field-nNgv5bpd.mjs → Field-D3mNj-iY.mjs} +90 -31
  16. package/dist/_chunks/Field-D3mNj-iY.mjs.map +1 -0
  17. package/dist/_chunks/{Form-Dhnh34ym.js → Form-DFXXFrJV.js} +22 -11
  18. package/dist/_chunks/Form-DFXXFrJV.js.map +1 -0
  19. package/dist/_chunks/{Form-DodJsI2A.mjs → Form-Ddy3XYS-.mjs} +22 -11
  20. package/dist/_chunks/Form-Ddy3XYS-.mjs.map +1 -0
  21. package/dist/_chunks/{History-CKCSQXz_.mjs → History-BEFrLZfz.mjs} +4 -4
  22. package/dist/_chunks/{History-CKCSQXz_.mjs.map → History-BEFrLZfz.mjs.map} +1 -1
  23. package/dist/_chunks/{History-C9auUkDi.js → History-pesEeFFT.js} +4 -4
  24. package/dist/_chunks/{History-C9auUkDi.js.map → History-pesEeFFT.js.map} +1 -1
  25. package/dist/_chunks/{ListConfigurationPage-Bg4rWUjX.js → ListConfigurationPage-BIoi-Sog.js} +14 -4
  26. package/dist/_chunks/ListConfigurationPage-BIoi-Sog.js.map +1 -0
  27. package/dist/_chunks/{ListConfigurationPage-CKEC4ttG.mjs → ListConfigurationPage-CB_lBFVX.mjs} +14 -4
  28. package/dist/_chunks/ListConfigurationPage-CB_lBFVX.mjs.map +1 -0
  29. package/dist/_chunks/{ListViewPage-C2gIeYHG.js → ListViewPage-C6FK36UI.js} +3 -3
  30. package/dist/_chunks/{ListViewPage-C2gIeYHG.js.map → ListViewPage-C6FK36UI.js.map} +1 -1
  31. package/dist/_chunks/{ListViewPage-B7_WJUjG.mjs → ListViewPage-DBbH7Esr.mjs} +3 -3
  32. package/dist/_chunks/{ListViewPage-B7_WJUjG.mjs.map → ListViewPage-DBbH7Esr.mjs.map} +1 -1
  33. package/dist/_chunks/{NoContentTypePage-Ckem6Ll6.mjs → NoContentTypePage-BU9Omzp4.mjs} +2 -2
  34. package/dist/_chunks/{NoContentTypePage-Ckem6Ll6.mjs.map → NoContentTypePage-BU9Omzp4.mjs.map} +1 -1
  35. package/dist/_chunks/{NoContentTypePage-DqgdUfyn.js → NoContentTypePage-Dod8M_xM.js} +2 -2
  36. package/dist/_chunks/{NoContentTypePage-DqgdUfyn.js.map → NoContentTypePage-Dod8M_xM.js.map} +1 -1
  37. package/dist/_chunks/{NoPermissionsPage-BO-GEjA4.mjs → NoPermissionsPage-B88W05rh.mjs} +2 -2
  38. package/dist/_chunks/{NoPermissionsPage-BO-GEjA4.mjs.map → NoPermissionsPage-B88W05rh.mjs.map} +1 -1
  39. package/dist/_chunks/{NoPermissionsPage-CF29Q-sW.js → NoPermissionsPage-CMLH3uMk.js} +2 -2
  40. package/dist/_chunks/{NoPermissionsPage-CF29Q-sW.js.map → NoPermissionsPage-CMLH3uMk.js.map} +1 -1
  41. package/dist/_chunks/{Relations-DItV5eow.mjs → Relations-BBJRxopY.mjs} +4 -4
  42. package/dist/_chunks/{Relations-DItV5eow.mjs.map → Relations-BBJRxopY.mjs.map} +1 -1
  43. package/dist/_chunks/{Relations-C0uC9J4f.js → Relations-OXbsEvNt.js} +4 -4
  44. package/dist/_chunks/{Relations-C0uC9J4f.js.map → Relations-OXbsEvNt.js.map} +1 -1
  45. package/dist/_chunks/{index-DrNe6ctw.mjs → index-BgiNQ7Q9.mjs} +93 -37
  46. package/dist/_chunks/index-BgiNQ7Q9.mjs.map +1 -0
  47. package/dist/_chunks/{index-Dd0nXyJF.js → index-Bj8wwbdx.js} +92 -36
  48. package/dist/_chunks/index-Bj8wwbdx.js.map +1 -0
  49. package/dist/_chunks/{layout-CLLtt_5O.js → layout-DBvOIgWG.js} +6 -6
  50. package/dist/_chunks/layout-DBvOIgWG.js.map +1 -0
  51. package/dist/_chunks/{layout-B3ez7kvr.mjs → layout-LOFMsdWo.mjs} +6 -6
  52. package/dist/_chunks/layout-LOFMsdWo.mjs.map +1 -0
  53. package/dist/_chunks/{relations-bRxcNv1q.js → relations-BLilXMyN.js} +2 -2
  54. package/dist/_chunks/{relations-bRxcNv1q.js.map → relations-BLilXMyN.js.map} +1 -1
  55. package/dist/_chunks/{relations-B0hlsUU_.mjs → relations-BTQKCDqX.mjs} +2 -2
  56. package/dist/_chunks/{relations-B0hlsUU_.mjs.map → relations-BTQKCDqX.mjs.map} +1 -1
  57. package/dist/admin/index.js +1 -1
  58. package/dist/admin/index.mjs +1 -1
  59. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +2 -2
  60. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
  61. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +10 -22
  62. package/dist/admin/src/utils/validation.d.ts +4 -1
  63. package/dist/server/index.js +29 -18
  64. package/dist/server/index.js.map +1 -1
  65. package/dist/server/index.mjs +29 -18
  66. package/dist/server/index.mjs.map +1 -1
  67. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  68. package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
  69. package/dist/server/src/services/permission-checker.d.ts.map +1 -1
  70. package/package.json +8 -8
  71. package/dist/_chunks/EditViewPage-BVMS5hT-.mjs.map +0 -1
  72. package/dist/_chunks/EditViewPage-CXkmnAvI.js.map +0 -1
  73. package/dist/_chunks/Field-Ibi32diw.js.map +0 -1
  74. package/dist/_chunks/Field-nNgv5bpd.mjs.map +0 -1
  75. package/dist/_chunks/Form-Dhnh34ym.js.map +0 -1
  76. package/dist/_chunks/Form-DodJsI2A.mjs.map +0 -1
  77. package/dist/_chunks/ListConfigurationPage-Bg4rWUjX.js.map +0 -1
  78. package/dist/_chunks/ListConfigurationPage-CKEC4ttG.mjs.map +0 -1
  79. package/dist/_chunks/index-Dd0nXyJF.js.map +0 -1
  80. package/dist/_chunks/index-DrNe6ctw.mjs.map +0 -1
  81. package/dist/_chunks/layout-B3ez7kvr.mjs.map +0 -1
  82. package/dist/_chunks/layout-CLLtt_5O.js.map +0 -1
@@ -324,6 +324,11 @@ const documentApi = contentManagerApi.injectEndpoints({
324
324
  {
325
325
  type: "Document",
326
326
  id: collectionType !== SINGLE_TYPES ? `${model}_${result && "documentId" in result ? result.documentId : documentId}` : model
327
+ },
328
+ // Make it easy to invalidate all individual documents queries for a model
329
+ {
330
+ type: "Document",
331
+ id: `${model}_ALL_ITEMS`
327
332
  }
328
333
  ];
329
334
  }
@@ -470,7 +475,7 @@ const buildValidParams = (query) => {
470
475
  const isBaseQueryError = (error) => {
471
476
  return error.name !== void 0;
472
477
  };
473
- const createYupSchema = (attributes = {}, components = {}) => {
478
+ const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
474
479
  const createModelSchema = (attributes2) => yup__namespace.object().shape(
475
480
  Object.entries(attributes2).reduce((acc, [name, attribute]) => {
476
481
  if (DOCUMENT_META_FIELDS.includes(name)) {
@@ -483,7 +488,7 @@ const createYupSchema = (attributes = {}, components = {}) => {
483
488
  addMinValidation,
484
489
  addMaxValidation,
485
490
  addRegexValidation
486
- ].map((fn) => fn(attribute));
491
+ ].map((fn) => fn(attribute, options));
487
492
  const transformSchema = pipe__default.default(...validations);
488
493
  switch (attribute.type) {
489
494
  case "component": {
@@ -584,6 +589,14 @@ const createAttributeSchema = (attribute) => {
584
589
  if (!value || typeof value === "string" && value.length === 0) {
585
590
  return true;
586
591
  }
592
+ if (typeof value === "object") {
593
+ try {
594
+ JSON.stringify(value);
595
+ return true;
596
+ } catch (err) {
597
+ return false;
598
+ }
599
+ }
587
600
  try {
588
601
  JSON.parse(value);
589
602
  return true;
@@ -602,13 +615,7 @@ const createAttributeSchema = (attribute) => {
602
615
  return yup__namespace.mixed();
603
616
  }
604
617
  };
605
- const addRequiredValidation = (attribute) => (schema) => {
606
- if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
607
- return schema.min(1, strapiAdmin.translatedErrors.required);
608
- }
609
- if (attribute.required && attribute.type !== "relation") {
610
- return schema.required(strapiAdmin.translatedErrors.required);
611
- }
618
+ const nullableSchema = (schema) => {
612
619
  return schema?.nullable ? schema.nullable() : (
613
620
  // In some cases '.nullable' will not be available on the schema.
614
621
  // e.g. when the schema has been built using yup.lazy (e.g. for relations).
@@ -616,7 +623,22 @@ const addRequiredValidation = (attribute) => (schema) => {
616
623
  schema
617
624
  );
618
625
  };
619
- const addMinLengthValidation = (attribute) => (schema) => {
626
+ const addRequiredValidation = (attribute, options) => (schema) => {
627
+ if (options.status === "draft") {
628
+ return nullableSchema(schema);
629
+ }
630
+ if ((attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") && attribute.required && "min" in schema) {
631
+ return schema.min(1, strapiAdmin.translatedErrors.required);
632
+ }
633
+ if (attribute.required && attribute.type !== "relation") {
634
+ return schema.required(strapiAdmin.translatedErrors.required);
635
+ }
636
+ return nullableSchema(schema);
637
+ };
638
+ const addMinLengthValidation = (attribute, options) => (schema) => {
639
+ if (options.status === "draft") {
640
+ return schema;
641
+ }
620
642
  if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
621
643
  return schema.min(attribute.minLength, {
622
644
  ...strapiAdmin.translatedErrors.minLength,
@@ -638,11 +660,11 @@ const addMaxLengthValidation = (attribute) => (schema) => {
638
660
  }
639
661
  return schema;
640
662
  };
641
- const addMinValidation = (attribute) => (schema) => {
663
+ const addMinValidation = (attribute, options) => (schema) => {
642
664
  if ("min" in attribute) {
643
665
  const min = toInteger(attribute.min);
644
666
  if (attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone") {
645
- if (!attribute.required && "test" in schema && min) {
667
+ if (options.status !== "draft" && !attribute.required && "test" in schema && min) {
646
668
  return schema.test(
647
669
  "custom-min",
648
670
  {
@@ -1293,7 +1315,7 @@ const useDocumentActions = () => {
1293
1315
  };
1294
1316
  };
1295
1317
  const ProtectedHistoryPage = React.lazy(
1296
- () => Promise.resolve().then(() => require("./History-C9auUkDi.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1318
+ () => Promise.resolve().then(() => require("./History-pesEeFFT.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1297
1319
  );
1298
1320
  const routes$1 = [
1299
1321
  {
@@ -1306,31 +1328,31 @@ const routes$1 = [
1306
1328
  }
1307
1329
  ];
1308
1330
  const ProtectedEditViewPage = React.lazy(
1309
- () => Promise.resolve().then(() => require("./EditViewPage-CXkmnAvI.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1331
+ () => Promise.resolve().then(() => require("./EditViewPage-l9qOdDUI.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1310
1332
  );
1311
1333
  const ProtectedListViewPage = React.lazy(
1312
- () => Promise.resolve().then(() => require("./ListViewPage-C2gIeYHG.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1334
+ () => Promise.resolve().then(() => require("./ListViewPage-C6FK36UI.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1313
1335
  );
1314
1336
  const ProtectedListConfiguration = React.lazy(
1315
- () => Promise.resolve().then(() => require("./ListConfigurationPage-Bg4rWUjX.js")).then((mod) => ({
1337
+ () => Promise.resolve().then(() => require("./ListConfigurationPage-BIoi-Sog.js")).then((mod) => ({
1316
1338
  default: mod.ProtectedListConfiguration
1317
1339
  }))
1318
1340
  );
1319
1341
  const ProtectedEditConfigurationPage = React.lazy(
1320
- () => Promise.resolve().then(() => require("./EditConfigurationPage-D340bYlT.js")).then((mod) => ({
1342
+ () => Promise.resolve().then(() => require("./EditConfigurationPage-N3OaN53v.js")).then((mod) => ({
1321
1343
  default: mod.ProtectedEditConfigurationPage
1322
1344
  }))
1323
1345
  );
1324
1346
  const ProtectedComponentConfigurationPage = React.lazy(
1325
- () => Promise.resolve().then(() => require("./ComponentConfigurationPage-BNxtMIfV.js")).then((mod) => ({
1347
+ () => Promise.resolve().then(() => require("./ComponentConfigurationPage-BOKmq7mz.js")).then((mod) => ({
1326
1348
  default: mod.ProtectedComponentConfigurationPage
1327
1349
  }))
1328
1350
  );
1329
1351
  const NoPermissions = React.lazy(
1330
- () => Promise.resolve().then(() => require("./NoPermissionsPage-CF29Q-sW.js")).then((mod) => ({ default: mod.NoPermissions }))
1352
+ () => Promise.resolve().then(() => require("./NoPermissionsPage-CMLH3uMk.js")).then((mod) => ({ default: mod.NoPermissions }))
1331
1353
  );
1332
1354
  const NoContentType = React.lazy(
1333
- () => Promise.resolve().then(() => require("./NoContentTypePage-DqgdUfyn.js")).then((mod) => ({ default: mod.NoContentType }))
1355
+ () => Promise.resolve().then(() => require("./NoContentTypePage-Dod8M_xM.js")).then((mod) => ({ default: mod.NoContentType }))
1334
1356
  );
1335
1357
  const CollectionTypePages = () => {
1336
1358
  const { collectionType } = reactRouterDom.useParams();
@@ -1444,12 +1466,14 @@ const DocumentActionButton = (action) => {
1444
1466
  /* @__PURE__ */ jsxRuntime.jsx(
1445
1467
  designSystem.Button,
1446
1468
  {
1447
- flex: 1,
1469
+ flex: "auto",
1448
1470
  startIcon: action.icon,
1449
1471
  disabled: action.disabled,
1450
1472
  onClick: handleClick(action),
1451
1473
  justifyContent: "center",
1452
1474
  variant: action.variant || "default",
1475
+ paddingTop: "7px",
1476
+ paddingBottom: "7px",
1453
1477
  children: action.label
1454
1478
  }
1455
1479
  ),
@@ -1509,7 +1533,7 @@ const DocumentActionsMenu = ({
1509
1533
  };
1510
1534
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Root, { open: isOpen, onOpenChange: setIsOpen, children: [
1511
1535
  /* @__PURE__ */ jsxRuntime.jsxs(
1512
- designSystem.Menu.Trigger,
1536
+ StyledMoreButton,
1513
1537
  {
1514
1538
  disabled: isDisabled,
1515
1539
  size: "S",
@@ -1543,7 +1567,14 @@ const DocumentActionsMenu = ({
1543
1567
  gap: 2,
1544
1568
  tag: "span",
1545
1569
  children: [
1546
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: action.icon }),
1570
+ /* @__PURE__ */ jsxRuntime.jsx(
1571
+ designSystem.Flex,
1572
+ {
1573
+ tag: "span",
1574
+ color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
1575
+ children: action.icon
1576
+ }
1577
+ ),
1547
1578
  action.label
1548
1579
  ]
1549
1580
  }
@@ -1606,6 +1637,23 @@ const convertActionVariantToColor = (variant = "secondary") => {
1606
1637
  return "primary600";
1607
1638
  }
1608
1639
  };
1640
+ const convertActionVariantToIconColor = (variant = "secondary") => {
1641
+ switch (variant) {
1642
+ case "danger":
1643
+ return "danger600";
1644
+ case "secondary":
1645
+ return "neutral500";
1646
+ case "success":
1647
+ return "success600";
1648
+ default:
1649
+ return "primary600";
1650
+ }
1651
+ };
1652
+ const StyledMoreButton = styledComponents.styled(designSystem.Menu.Trigger)`
1653
+ & > span {
1654
+ display: flex;
1655
+ }
1656
+ `;
1609
1657
  const DocumentActionConfirmDialog = ({
1610
1658
  onClose,
1611
1659
  onCancel,
@@ -1877,16 +1925,18 @@ const UpdateAction = ({
1877
1925
  onClick: async () => {
1878
1926
  setSubmitting(true);
1879
1927
  try {
1880
- const { errors } = await validate();
1881
- if (errors) {
1882
- toggleNotification({
1883
- type: "danger",
1884
- message: formatMessage({
1885
- id: "content-manager.validation.error",
1886
- defaultMessage: "There are validation errors in your document. Please fix them before saving."
1887
- })
1888
- });
1889
- return;
1928
+ if (activeTab !== "draft") {
1929
+ const { errors } = await validate();
1930
+ if (errors) {
1931
+ toggleNotification({
1932
+ type: "danger",
1933
+ message: formatMessage({
1934
+ id: "content-manager.validation.error",
1935
+ defaultMessage: "There are validation errors in your document. Please fix them before saving."
1936
+ })
1937
+ });
1938
+ return;
1939
+ }
1890
1940
  }
1891
1941
  if (isCloning) {
1892
1942
  const res = await clone(
@@ -3170,7 +3220,13 @@ const SelectedEntriesModalContent = ({
3170
3220
  );
3171
3221
  const { rows, validationErrors } = React__namespace.useMemo(() => {
3172
3222
  if (data.length > 0 && schema) {
3173
- const validate = createYupSchema(schema.attributes, components);
3223
+ const validate = createYupSchema(
3224
+ schema.attributes,
3225
+ components,
3226
+ // Since this is the "Publish" action, the validation
3227
+ // schema must enforce the rules for published entities
3228
+ { status: "published" }
3229
+ );
3174
3230
  const validationErrors2 = {};
3175
3231
  const rows2 = data.map((entry) => {
3176
3232
  try {
@@ -3862,7 +3918,7 @@ const index = {
3862
3918
  app.router.addRoute({
3863
3919
  path: "content-manager/*",
3864
3920
  lazy: async () => {
3865
- const { Layout } = await Promise.resolve().then(() => require("./layout-CLLtt_5O.js"));
3921
+ const { Layout } = await Promise.resolve().then(() => require("./layout-DBvOIgWG.js"));
3866
3922
  return {
3867
3923
  Component: Layout
3868
3924
  };
@@ -3936,4 +3992,4 @@ exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
3936
3992
  exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
3937
3993
  exports.useGetInitialDataQuery = useGetInitialDataQuery;
3938
3994
  exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
3939
- //# sourceMappingURL=index-Dd0nXyJF.js.map
3995
+ //# sourceMappingURL=index-Bj8wwbdx.js.map