@strapi/content-type-builder 5.0.0-rc.0 → 5.0.0-rc.10

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.
@@ -9,7 +9,7 @@ const Icons = require("@strapi/icons");
9
9
  const reactDom = require("react-dom");
10
10
  const styledComponents = require("styled-components");
11
11
  const upperFirst = require("lodash/upperFirst");
12
- const index$1 = require("./index-hlyv9EE3.js");
12
+ const index$1 = require("./index-DqqaFxyZ.js");
13
13
  const isEqual = require("lodash/isEqual");
14
14
  const get = require("lodash/get");
15
15
  const groupBy = require("lodash/groupBy");
@@ -347,23 +347,28 @@ const useContentTypeBuilderMenu = () => {
347
347
  ].map((section) => {
348
348
  const hasChild = section.links.some((l) => Array.isArray(l.links));
349
349
  if (hasChild) {
350
+ let filteredLinksCount = 0;
350
351
  return {
351
352
  ...section,
352
353
  links: section.links.map((link) => {
353
- const filteredLinks = link.links.filter((link2) => startsWith(link2.title, search));
354
- if (filteredLinks.length === 0) {
354
+ const filteredLinks2 = link.links.filter((link2) => startsWith(link2.title, search));
355
+ if (filteredLinks2.length === 0) {
355
356
  return null;
356
357
  }
358
+ filteredLinksCount += filteredLinks2.length;
357
359
  return {
358
360
  ...link,
359
- links: filteredLinks.sort((a, b) => formatter.compare(a.title, b.title))
361
+ links: filteredLinks2.sort((a, b) => formatter.compare(a.title, b.title))
360
362
  };
361
- }).filter(Boolean)
363
+ }).filter(Boolean),
364
+ linksCount: filteredLinksCount
362
365
  };
363
366
  }
367
+ const filteredLinks = section.links.filter((link) => startsWith(link.title, search)).sort((a, b) => formatter.compare(a.title, b.title));
364
368
  return {
365
369
  ...section,
366
- links: section.links.filter((link) => startsWith(link.title, search)).sort((a, b) => formatter.compare(a.title, b.title))
370
+ links: filteredLinks,
371
+ linksCount: filteredLinks.length
367
372
  };
368
373
  });
369
374
  return {
@@ -372,81 +377,94 @@ const useContentTypeBuilderMenu = () => {
372
377
  onSearchChange: setSearch
373
378
  };
374
379
  };
380
+ const SubNavLinkCustom = styledComponents.styled(designSystem.SubNavLink)`
381
+ div {
382
+ width: inherit;
383
+ span:nth-child(2) {
384
+ white-space: nowrap;
385
+ overflow: hidden;
386
+ text-overflow: ellipsis;
387
+ width: inherit;
388
+ }
389
+ }
390
+ `;
375
391
  const ContentTypeBuilderNav = () => {
376
392
  const { menu, searchValue, onSearchChange } = useContentTypeBuilderMenu();
377
393
  const { formatMessage } = reactIntl.useIntl();
378
- return /* @__PURE__ */ jsxRuntime.jsxs(
379
- designSystem.SubNav,
380
- {
381
- "aria-label": formatMessage({
382
- id: `${getTrad("plugin.name")}`,
383
- defaultMessage: "Content-Types Builder"
384
- }),
385
- children: [
386
- /* @__PURE__ */ jsxRuntime.jsx(
387
- designSystem.SubNavHeader,
388
- {
389
- searchable: true,
390
- value: searchValue,
391
- onClear: () => onSearchChange(""),
392
- onChange: (e) => onSearchChange(e.target.value),
393
- label: formatMessage({
394
- id: `${getTrad("plugin.name")}`,
395
- defaultMessage: "Content-Types Builder"
396
- }),
397
- searchLabel: formatMessage({
398
- id: "global.search",
399
- defaultMessage: "Search"
400
- })
401
- }
402
- ),
403
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SubNavSections, { children: menu.map((section) => /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
404
- /* @__PURE__ */ jsxRuntime.jsx(
405
- designSystem.SubNavSection,
406
- {
407
- label: formatMessage({
408
- id: section.title.id,
409
- defaultMessage: section.title.defaultMessage
410
- }),
411
- collapsable: true,
412
- badgeLabel: section.links.length.toString(),
413
- children: section.links.map((link) => {
414
- if (link.links) {
415
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.SubNavLinkSection, { label: upperFirst__default.default(link.title), children: link.links.map((subLink) => /* @__PURE__ */ jsxRuntime.jsx(
416
- designSystem.SubNavLink,
417
- {
418
- tag: reactRouterDom.NavLink,
419
- to: subLink.to,
420
- active: subLink.active,
421
- isSubSectionChild: true,
422
- children: upperFirst__default.default(
423
- formatMessage({ id: subLink.name, defaultMessage: subLink.title })
424
- )
425
- },
426
- subLink.name
427
- )) }, link.name);
428
- }
429
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.SubNavLink, { tag: reactRouterDom.NavLink, to: link.to, active: link.active, children: upperFirst__default.default(formatMessage({ id: link.name, defaultMessage: link.title })) }, link.name);
430
- })
431
- }
432
- ),
433
- section.customLink && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 7, children: /* @__PURE__ */ jsxRuntime.jsx(
434
- designSystem.TextButton,
435
- {
436
- onClick: section.customLink.onClick,
437
- startIcon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Plus, { width: "0.8rem", height: "0.8rem" }),
438
- marginTop: 2,
439
- cursor: "pointer",
440
- children: formatMessage({
441
- id: section.customLink.id,
442
- defaultMessage: section.customLink.defaultMessage
443
- })
394
+ const pluginName = formatMessage({
395
+ id: getTrad("plugin.name"),
396
+ defaultMessage: "Content-Type Builder"
397
+ });
398
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.SubNav, { "aria-label": pluginName, children: [
399
+ /* @__PURE__ */ jsxRuntime.jsx(
400
+ designSystem.SubNavHeader,
401
+ {
402
+ searchable: true,
403
+ value: searchValue,
404
+ onClear: () => onSearchChange(""),
405
+ onChange: (e) => onSearchChange(e.target.value),
406
+ label: pluginName,
407
+ searchLabel: formatMessage({
408
+ id: "global.search",
409
+ defaultMessage: "Search"
410
+ })
411
+ }
412
+ ),
413
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SubNavSections, { children: menu.map((section) => /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
414
+ /* @__PURE__ */ jsxRuntime.jsx(
415
+ designSystem.SubNavSection,
416
+ {
417
+ label: formatMessage({
418
+ id: section.title.id,
419
+ defaultMessage: section.title.defaultMessage
420
+ }),
421
+ collapsable: true,
422
+ badgeLabel: section.linksCount.toString(),
423
+ children: section.links.map((link) => {
424
+ if (link.links) {
425
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.SubNavLinkSection, { label: upperFirst__default.default(link.title), children: link.links.map((subLink) => /* @__PURE__ */ jsxRuntime.jsx(
426
+ designSystem.SubNavLink,
427
+ {
428
+ tag: reactRouterDom.NavLink,
429
+ to: subLink.to,
430
+ active: subLink.active,
431
+ isSubSectionChild: true,
432
+ children: upperFirst__default.default(
433
+ formatMessage({ id: subLink.name, defaultMessage: subLink.title })
434
+ )
435
+ },
436
+ subLink.name
437
+ )) }, link.name);
444
438
  }
445
- ) })
446
- ] }, section.name)) })
447
- ]
448
- }
449
- );
439
+ return /* @__PURE__ */ jsxRuntime.jsx(
440
+ SubNavLinkCustom,
441
+ {
442
+ tag: reactRouterDom.NavLink,
443
+ to: link.to,
444
+ active: link.active,
445
+ width: "100%",
446
+ children: upperFirst__default.default(formatMessage({ id: link.name, defaultMessage: link.title }))
447
+ },
448
+ link.name
449
+ );
450
+ })
451
+ }
452
+ ),
453
+ section.customLink && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 7, children: /* @__PURE__ */ jsxRuntime.jsx(
454
+ designSystem.TextButton,
455
+ {
456
+ onClick: section.customLink.onClick,
457
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Plus, { width: "0.8rem", height: "0.8rem" }),
458
+ marginTop: 2,
459
+ cursor: "pointer",
460
+ children: formatMessage({
461
+ id: section.customLink.id,
462
+ defaultMessage: section.customLink.defaultMessage
463
+ })
464
+ }
465
+ ) })
466
+ ] }, section.name)) })
467
+ ] });
450
468
  };
451
469
  const isAllowedContentTypesForRelations = (contentType) => {
452
470
  return contentType.kind === "collectionType" && (contentType.restrictRelationsTo === null || Array.isArray(contentType.restrictRelationsTo) && contentType.restrictRelationsTo.length > 0);
@@ -607,7 +625,7 @@ const AttributeOption = ({ type = "text" }) => {
607
625
  const AttributeList = ({ attributes }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.KeyboardNavigable, { tagName: "button", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 8, children: attributes.map((attributeRow, index2) => {
608
626
  return (
609
627
  // eslint-disable-next-line react/no-array-index-key
610
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 3, children: attributeRow.map((attribute) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, children: /* @__PURE__ */ jsxRuntime.jsx(AttributeOption, { type: attribute }) }, attribute)) }, index2)
628
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 3, children: attributeRow.map((attribute) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsx(AttributeOption, { type: attribute }) }, attribute)) }, index2)
611
629
  );
612
630
  }) }) });
613
631
  const CustomFieldOption = ({ customFieldUid, customField }) => {
@@ -688,7 +706,7 @@ const CustomFieldsList = () => {
688
706
  (a, b) => a[1].name > b[1].name ? 1 : -1
689
707
  );
690
708
  return /* @__PURE__ */ jsxRuntime.jsx(designSystem.KeyboardNavigable, { tagName: "button", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 3, children: [
691
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 3, children: sortedCustomFields.map(([uid, customField]) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, children: /* @__PURE__ */ jsxRuntime.jsx(CustomFieldOption, { customFieldUid: uid, customField }, uid) }, uid)) }),
709
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 3, children: sortedCustomFields.map(([uid, customField]) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsx(CustomFieldOption, { customFieldUid: uid, customField }, uid) }, uid)) }),
692
710
  /* @__PURE__ */ jsxRuntime.jsx(
693
711
  designSystem.Link,
694
712
  {
@@ -974,10 +992,19 @@ const DraftAndPublishToggle = ({
974
992
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Checkbox, { checked: value, disabled, onCheckedChange: handleChange, children: label }),
975
993
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
976
994
  ] }),
977
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: showWarning, onOpenChange: (isOpen) => setShowWarning(isOpen), children: /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.ConfirmDialog, { onConfirm: handleConfirm, children: formatMessage({
978
- id: getTrad("popUpWarning.draft-publish.message"),
979
- defaultMessage: "If you disable the draft & publish, your drafts will be deleted."
980
- }) }) })
995
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: showWarning, onOpenChange: (isOpen) => setShowWarning(isOpen), children: /* @__PURE__ */ jsxRuntime.jsx(
996
+ strapiAdmin.ConfirmDialog,
997
+ {
998
+ endAction: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant: "danger", width: "100%", justifyContent: "center", children: formatMessage({
999
+ id: getTrad("popUpWarning.draft-publish.button.confirm"),
1000
+ defaultMessage: "Yes, disable"
1001
+ }) }),
1002
+ children: formatMessage({
1003
+ id: getTrad("popUpWarning.draft-publish.message"),
1004
+ defaultMessage: "If you disable the draft & publish, your drafts will be deleted."
1005
+ })
1006
+ }
1007
+ ) })
981
1008
  ] });
982
1009
  };
983
1010
  const FormModalEndActions = ({
@@ -1742,7 +1769,7 @@ const IconPicker = ({ intlLabel, name, onChange, value = "" }) => {
1742
1769
  id: getTrad("IconPicker.search.button.label"),
1743
1770
  defaultMessage: "Search icon button"
1744
1771
  }),
1745
- borderWidth: 0,
1772
+ variant: "ghost",
1746
1773
  children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Search, {})
1747
1774
  }
1748
1775
  ),
@@ -1762,7 +1789,7 @@ const IconPicker = ({ intlLabel, name, onChange, value = "" }) => {
1762
1789
  id: getTrad("IconPicker.remove.button"),
1763
1790
  defaultMessage: "Remove the selected icon"
1764
1791
  }),
1765
- borderWidth: 0,
1792
+ variant: "ghost",
1766
1793
  children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
1767
1794
  }
1768
1795
  )
@@ -2294,6 +2321,12 @@ const RelationTargetPicker = ({
2294
2321
  ] });
2295
2322
  };
2296
2323
  const MenuTrigger = styledComponents.styled(designSystem.Menu.Trigger)`
2324
+ max-width: 16.8rem;
2325
+ span {
2326
+ white-space: nowrap;
2327
+ overflow: hidden;
2328
+ text-overflow: ellipsis;
2329
+ }
2297
2330
  svg {
2298
2331
  width: 0.6rem;
2299
2332
  height: 0.4rem;
@@ -2498,7 +2531,8 @@ const SelectCategory = ({
2498
2531
  intlLabel,
2499
2532
  name,
2500
2533
  onChange,
2501
- value = void 0
2534
+ value = void 0,
2535
+ isCreating
2502
2536
  }) => {
2503
2537
  const { formatMessage } = reactIntl.useIntl();
2504
2538
  const { allComponentsCategories } = useDataManager();
@@ -2514,7 +2548,17 @@ const SelectCategory = ({
2514
2548
  };
2515
2549
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { error: errorMessage, name, children: [
2516
2550
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: label }),
2517
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Combobox, { onChange: handleChange, onCreateOption: handleCreateOption, value, creatable: true, children: categories.map((category) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.ComboboxOption, { value: category, children: category }, category)) }),
2551
+ /* @__PURE__ */ jsxRuntime.jsx(
2552
+ designSystem.Combobox,
2553
+ {
2554
+ disabled: !isCreating,
2555
+ onChange: handleChange,
2556
+ onCreateOption: handleCreateOption,
2557
+ value,
2558
+ creatable: true,
2559
+ children: categories.map((category) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.ComboboxOption, { value: category, children: category }, category))
2560
+ }
2561
+ ),
2518
2562
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
2519
2563
  ] });
2520
2564
  };
@@ -2836,18 +2880,36 @@ const TabForm = ({
2836
2880
  null
2837
2881
  );
2838
2882
  if (input.type === "pushRight") {
2839
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: input.size || 6, children: /* @__PURE__ */ jsxRuntime.jsx("div", {}) }, input.name || key);
2883
+ return /* @__PURE__ */ jsxRuntime.jsx(
2884
+ designSystem.Grid.Item,
2885
+ {
2886
+ col: input.size || 6,
2887
+ direction: "column",
2888
+ alignItems: "stretch",
2889
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", {})
2890
+ },
2891
+ input.name || key
2892
+ );
2840
2893
  }
2841
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: input.size || 6, children: /* @__PURE__ */ jsxRuntime.jsx(
2842
- MemoizedGenericInput,
2894
+ return /* @__PURE__ */ jsxRuntime.jsx(
2895
+ designSystem.Grid.Item,
2843
2896
  {
2844
- ...input,
2845
- ...genericInputProps,
2846
- error: errorId,
2847
- onChange,
2848
- value
2849
- }
2850
- ) }, input.name || key);
2897
+ col: input.size || 6,
2898
+ direction: "column",
2899
+ alignItems: "stretch",
2900
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2901
+ MemoizedGenericInput,
2902
+ {
2903
+ ...input,
2904
+ ...genericInputProps,
2905
+ error: errorId,
2906
+ onChange,
2907
+ value
2908
+ }
2909
+ )
2910
+ },
2911
+ input.name || key
2912
+ );
2851
2913
  }) })
2852
2914
  ] }, sectionIndex);
2853
2915
  }) });
@@ -6713,11 +6775,11 @@ const FormModalNavigationProvider = ({ children }) => {
6713
6775
  }
6714
6776
  );
6715
6777
  };
6716
- const ListView$1 = React.lazy(() => Promise.resolve().then(() => require("./ListView-g9V7g_tv.js")));
6778
+ const ListView$1 = React.lazy(() => Promise.resolve().then(() => require("./ListView-BSIe0goP.js")));
6717
6779
  const RecursivePath = () => {
6718
6780
  return /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Loading, {}), children: /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Routes, { children: /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: `/:componentUid`, element: /* @__PURE__ */ jsxRuntime.jsx(ListView$1, {}) }) }) });
6719
6781
  };
6720
- const ListView = React.lazy(() => Promise.resolve().then(() => require("./ListView-g9V7g_tv.js")));
6782
+ const ListView = React.lazy(() => Promise.resolve().then(() => require("./ListView-BSIe0goP.js")));
6721
6783
  const App = () => {
6722
6784
  const { formatMessage } = reactIntl.useIntl();
6723
6785
  const title = formatMessage({
@@ -6749,4 +6811,4 @@ exports.getTrad = getTrad;
6749
6811
  exports.index = index;
6750
6812
  exports.useDataManager = useDataManager;
6751
6813
  exports.useFormModalNavigation = useFormModalNavigation;
6752
- //# sourceMappingURL=index-Z-KG7c7n.js.map
6814
+ //# sourceMappingURL=index-DbqNgfVI.js.map