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

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.
@@ -10,7 +10,7 @@ import { ArrowClockwise, Clock, Plus, Sparkle, ArrowLeft, Search, Trash, Eye, Ey
10
10
  import { createPortal } from "react-dom";
11
11
  import { keyframes, styled } from "styled-components";
12
12
  import upperFirst from "lodash/upperFirst";
13
- import { p as pluginId, n as nameToSlug, O as ON_CHANGE_RELATION_TARGET, a as ON_CHANGE_RELATION_TYPE, g as getRelationType, M as MAX_COMPONENT_DEPTH, c as createComponentUid, b as createUid, i as initialState, S as SET_DATA_TO_EDIT, d as SET_DYNAMIC_ZONE_DATA_SCHEMA, e as SET_CUSTOM_FIELD_DATA_SCHEMA, f as SET_ATTRIBUTE_DATA_SCHEMA, R as RESET_PROPS, h as SET_ERRORS, j as ON_CHANGE, k as RESET_PROPS_AND_SET_THE_FORM_FOR_ADDING_A_COMPO_TO_A_DZ, l as RESET_PROPS_AND_SET_FORM_FOR_ADDING_AN_EXISTING_COMPO, m as RESET_PROPS_AND_SAVE_CURRENT_DATA, o as initialState$1, q as makeUnique, G as GET_DATA_SUCCEEDED, r as RELOAD_PLUGIN, s as retrieveComponentsFromSchema, t as SET_MODIFIED_DATA, A as ADD_CUSTOM_FIELD_ATTRIBUTE, E as EDIT_CUSTOM_FIELD_ATTRIBUTE, u as ADD_CREATED_COMPONENT_TO_DYNAMIC_ZONE, C as CHANGE_DYNAMIC_ZONE_COMPONENTS, D as DELETE_NOT_SAVED_TYPE, v as REMOVE_COMPONENT_FROM_DYNAMIC_ZONE, U as UPDATE_INITIAL_STATE, w as UPDATE_SCHEMA, x as EDIT_ATTRIBUTE, y as ADD_ATTRIBUTE, z as CREATE_SCHEMA, B as CREATE_COMPONENT_SCHEMA, F as REMOVE_FIELD_FROM_DISPLAYED_COMPONENT, H as REMOVE_FIELD, P as PERMISSIONS } from "./index-BLvlfjLT.mjs";
13
+ import { p as pluginId, n as nameToSlug, O as ON_CHANGE_RELATION_TARGET, a as ON_CHANGE_RELATION_TYPE, g as getRelationType, M as MAX_COMPONENT_DEPTH, c as createComponentUid, b as createUid, i as initialState, S as SET_DATA_TO_EDIT, d as SET_DYNAMIC_ZONE_DATA_SCHEMA, e as SET_CUSTOM_FIELD_DATA_SCHEMA, f as SET_ATTRIBUTE_DATA_SCHEMA, R as RESET_PROPS, h as SET_ERRORS, j as ON_CHANGE, k as RESET_PROPS_AND_SET_THE_FORM_FOR_ADDING_A_COMPO_TO_A_DZ, l as RESET_PROPS_AND_SET_FORM_FOR_ADDING_AN_EXISTING_COMPO, m as RESET_PROPS_AND_SAVE_CURRENT_DATA, o as initialState$1, q as makeUnique, G as GET_DATA_SUCCEEDED, r as RELOAD_PLUGIN, s as retrieveComponentsFromSchema, t as SET_MODIFIED_DATA, A as ADD_CUSTOM_FIELD_ATTRIBUTE, E as EDIT_CUSTOM_FIELD_ATTRIBUTE, u as ADD_CREATED_COMPONENT_TO_DYNAMIC_ZONE, C as CHANGE_DYNAMIC_ZONE_COMPONENTS, D as DELETE_NOT_SAVED_TYPE, v as REMOVE_COMPONENT_FROM_DYNAMIC_ZONE, U as UPDATE_INITIAL_STATE, w as UPDATE_SCHEMA, x as EDIT_ATTRIBUTE, y as ADD_ATTRIBUTE, z as CREATE_SCHEMA, B as CREATE_COMPONENT_SCHEMA, F as REMOVE_FIELD_FROM_DISPLAYED_COMPONENT, H as REMOVE_FIELD, P as PERMISSIONS } from "./index-4pWiYAr9.mjs";
14
14
  import isEqual from "lodash/isEqual";
15
15
  import get from "lodash/get";
16
16
  import groupBy from "lodash/groupBy";
@@ -308,23 +308,28 @@ const useContentTypeBuilderMenu = () => {
308
308
  ].map((section) => {
309
309
  const hasChild = section.links.some((l) => Array.isArray(l.links));
310
310
  if (hasChild) {
311
+ let filteredLinksCount = 0;
311
312
  return {
312
313
  ...section,
313
314
  links: section.links.map((link) => {
314
- const filteredLinks = link.links.filter((link2) => startsWith(link2.title, search));
315
- if (filteredLinks.length === 0) {
315
+ const filteredLinks2 = link.links.filter((link2) => startsWith(link2.title, search));
316
+ if (filteredLinks2.length === 0) {
316
317
  return null;
317
318
  }
319
+ filteredLinksCount += filteredLinks2.length;
318
320
  return {
319
321
  ...link,
320
- links: filteredLinks.sort((a, b) => formatter.compare(a.title, b.title))
322
+ links: filteredLinks2.sort((a, b) => formatter.compare(a.title, b.title))
321
323
  };
322
- }).filter(Boolean)
324
+ }).filter(Boolean),
325
+ linksCount: filteredLinksCount
323
326
  };
324
327
  }
328
+ const filteredLinks = section.links.filter((link) => startsWith(link.title, search)).sort((a, b) => formatter.compare(a.title, b.title));
325
329
  return {
326
330
  ...section,
327
- links: section.links.filter((link) => startsWith(link.title, search)).sort((a, b) => formatter.compare(a.title, b.title))
331
+ links: filteredLinks,
332
+ linksCount: filteredLinks.length
328
333
  };
329
334
  });
330
335
  return {
@@ -336,78 +341,70 @@ const useContentTypeBuilderMenu = () => {
336
341
  const ContentTypeBuilderNav = () => {
337
342
  const { menu, searchValue, onSearchChange } = useContentTypeBuilderMenu();
338
343
  const { formatMessage } = useIntl();
339
- return /* @__PURE__ */ jsxs(
340
- SubNav,
341
- {
342
- "aria-label": formatMessage({
343
- id: `${getTrad("plugin.name")}`,
344
- defaultMessage: "Content-Types Builder"
345
- }),
346
- children: [
347
- /* @__PURE__ */ jsx(
348
- SubNavHeader,
349
- {
350
- searchable: true,
351
- value: searchValue,
352
- onClear: () => onSearchChange(""),
353
- onChange: (e) => onSearchChange(e.target.value),
354
- label: formatMessage({
355
- id: `${getTrad("plugin.name")}`,
356
- defaultMessage: "Content-Types Builder"
357
- }),
358
- searchLabel: formatMessage({
359
- id: "global.search",
360
- defaultMessage: "Search"
361
- })
362
- }
363
- ),
364
- /* @__PURE__ */ jsx(SubNavSections, { children: menu.map((section) => /* @__PURE__ */ jsxs(Fragment, { children: [
365
- /* @__PURE__ */ jsx(
366
- SubNavSection,
367
- {
368
- label: formatMessage({
369
- id: section.title.id,
370
- defaultMessage: section.title.defaultMessage
371
- }),
372
- collapsable: true,
373
- badgeLabel: section.links.length.toString(),
374
- children: section.links.map((link) => {
375
- if (link.links) {
376
- return /* @__PURE__ */ jsx(SubNavLinkSection, { label: upperFirst(link.title), children: link.links.map((subLink) => /* @__PURE__ */ jsx(
377
- SubNavLink,
378
- {
379
- tag: NavLink,
380
- to: subLink.to,
381
- active: subLink.active,
382
- isSubSectionChild: true,
383
- children: upperFirst(
384
- formatMessage({ id: subLink.name, defaultMessage: subLink.title })
385
- )
386
- },
387
- subLink.name
388
- )) }, link.name);
389
- }
390
- return /* @__PURE__ */ jsx(SubNavLink, { tag: NavLink, to: link.to, active: link.active, children: upperFirst(formatMessage({ id: link.name, defaultMessage: link.title })) }, link.name);
391
- })
392
- }
393
- ),
394
- section.customLink && /* @__PURE__ */ jsx(Box, { paddingLeft: 7, children: /* @__PURE__ */ jsx(
395
- TextButton,
396
- {
397
- onClick: section.customLink.onClick,
398
- startIcon: /* @__PURE__ */ jsx(Plus, { width: "0.8rem", height: "0.8rem" }),
399
- marginTop: 2,
400
- cursor: "pointer",
401
- children: formatMessage({
402
- id: section.customLink.id,
403
- defaultMessage: section.customLink.defaultMessage
404
- })
344
+ const pluginName = formatMessage({
345
+ id: getTrad("plugin.name"),
346
+ defaultMessage: "Content-Type Builder"
347
+ });
348
+ return /* @__PURE__ */ jsxs(SubNav, { "aria-label": pluginName, children: [
349
+ /* @__PURE__ */ jsx(
350
+ SubNavHeader,
351
+ {
352
+ searchable: true,
353
+ value: searchValue,
354
+ onClear: () => onSearchChange(""),
355
+ onChange: (e) => onSearchChange(e.target.value),
356
+ label: pluginName,
357
+ searchLabel: formatMessage({
358
+ id: "global.search",
359
+ defaultMessage: "Search"
360
+ })
361
+ }
362
+ ),
363
+ /* @__PURE__ */ jsx(SubNavSections, { children: menu.map((section) => /* @__PURE__ */ jsxs(Fragment, { children: [
364
+ /* @__PURE__ */ jsx(
365
+ SubNavSection,
366
+ {
367
+ label: formatMessage({
368
+ id: section.title.id,
369
+ defaultMessage: section.title.defaultMessage
370
+ }),
371
+ collapsable: true,
372
+ badgeLabel: section.linksCount.toString(),
373
+ children: section.links.map((link) => {
374
+ if (link.links) {
375
+ return /* @__PURE__ */ jsx(SubNavLinkSection, { label: upperFirst(link.title), children: link.links.map((subLink) => /* @__PURE__ */ jsx(
376
+ SubNavLink,
377
+ {
378
+ tag: NavLink,
379
+ to: subLink.to,
380
+ active: subLink.active,
381
+ isSubSectionChild: true,
382
+ children: upperFirst(
383
+ formatMessage({ id: subLink.name, defaultMessage: subLink.title })
384
+ )
385
+ },
386
+ subLink.name
387
+ )) }, link.name);
405
388
  }
406
- ) })
407
- ] }, section.name)) })
408
- ]
409
- }
410
- );
389
+ return /* @__PURE__ */ jsx(SubNavLink, { tag: NavLink, to: link.to, active: link.active, children: upperFirst(formatMessage({ id: link.name, defaultMessage: link.title })) }, link.name);
390
+ })
391
+ }
392
+ ),
393
+ section.customLink && /* @__PURE__ */ jsx(Box, { paddingLeft: 7, children: /* @__PURE__ */ jsx(
394
+ TextButton,
395
+ {
396
+ onClick: section.customLink.onClick,
397
+ startIcon: /* @__PURE__ */ jsx(Plus, { width: "0.8rem", height: "0.8rem" }),
398
+ marginTop: 2,
399
+ cursor: "pointer",
400
+ children: formatMessage({
401
+ id: section.customLink.id,
402
+ defaultMessage: section.customLink.defaultMessage
403
+ })
404
+ }
405
+ ) })
406
+ ] }, section.name)) })
407
+ ] });
411
408
  };
412
409
  const isAllowedContentTypesForRelations = (contentType) => {
413
410
  return contentType.kind === "collectionType" && (contentType.restrictRelationsTo === null || Array.isArray(contentType.restrictRelationsTo) && contentType.restrictRelationsTo.length > 0);
@@ -2459,7 +2456,8 @@ const SelectCategory = ({
2459
2456
  intlLabel,
2460
2457
  name,
2461
2458
  onChange,
2462
- value = void 0
2459
+ value = void 0,
2460
+ isCreating
2463
2461
  }) => {
2464
2462
  const { formatMessage } = useIntl();
2465
2463
  const { allComponentsCategories } = useDataManager();
@@ -2475,7 +2473,17 @@ const SelectCategory = ({
2475
2473
  };
2476
2474
  return /* @__PURE__ */ jsxs(Field.Root, { error: errorMessage, name, children: [
2477
2475
  /* @__PURE__ */ jsx(Field.Label, { children: label }),
2478
- /* @__PURE__ */ jsx(Combobox, { onChange: handleChange, onCreateOption: handleCreateOption, value, creatable: true, children: categories.map((category) => /* @__PURE__ */ jsx(ComboboxOption, { value: category, children: category }, category)) }),
2476
+ /* @__PURE__ */ jsx(
2477
+ Combobox,
2478
+ {
2479
+ disabled: !isCreating,
2480
+ onChange: handleChange,
2481
+ onCreateOption: handleCreateOption,
2482
+ value,
2483
+ creatable: true,
2484
+ children: categories.map((category) => /* @__PURE__ */ jsx(ComboboxOption, { value: category, children: category }, category))
2485
+ }
2486
+ ),
2479
2487
  /* @__PURE__ */ jsx(Field.Error, {})
2480
2488
  ] });
2481
2489
  };
@@ -6674,11 +6682,11 @@ const FormModalNavigationProvider = ({ children }) => {
6674
6682
  }
6675
6683
  );
6676
6684
  };
6677
- const ListView$1 = lazy(() => import("./ListView-CY9uKqop.mjs"));
6685
+ const ListView$1 = lazy(() => import("./ListView-CYfzT9Ss.mjs"));
6678
6686
  const RecursivePath = () => {
6679
6687
  return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Page.Loading, {}), children: /* @__PURE__ */ jsx(Routes, { children: /* @__PURE__ */ jsx(Route, { path: `/:componentUid`, element: /* @__PURE__ */ jsx(ListView$1, {}) }) }) });
6680
6688
  };
6681
- const ListView = lazy(() => import("./ListView-CY9uKqop.mjs"));
6689
+ const ListView = lazy(() => import("./ListView-CYfzT9Ss.mjs"));
6682
6690
  const App = () => {
6683
6691
  const { formatMessage } = useIntl();
6684
6692
  const title = formatMessage({
@@ -6712,4 +6720,4 @@ export {
6712
6720
  index as i,
6713
6721
  useDataManager as u
6714
6722
  };
6715
- //# sourceMappingURL=index-BpIP_u5V.mjs.map
6723
+ //# sourceMappingURL=index-KxDs8xjD.mjs.map