@firecms/core 3.0.0-canary.169 → 3.0.0-canary.170

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.
@@ -20,11 +20,13 @@ export interface ArrayContainerProps<T> {
20
20
  newDefaultEntry: T;
21
21
  onValueChange: (value: T[]) => void;
22
22
  className?: string;
23
+ min?: number;
24
+ max?: number;
23
25
  }
24
26
  /**
25
27
  * @group Form custom fields
26
28
  */
27
- export declare function ArrayContainer<T>({ droppableId, addLabel, value, disabled, buildEntry, size, onInternalIdAdded, includeAddButton, newDefaultEntry, onValueChange, className }: ArrayContainerProps<T>): import("react/jsx-runtime").JSX.Element;
29
+ export declare function ArrayContainer<T>({ droppableId, addLabel, value, disabled, buildEntry, size, onInternalIdAdded, includeAddButton, newDefaultEntry, onValueChange, className, min, max }: ArrayContainerProps<T>): import("react/jsx-runtime").JSX.Element;
28
30
  type ArrayContainerItemProps = {
29
31
  provided: DraggableProvided;
30
32
  index: number;
@@ -35,18 +37,20 @@ type ArrayContainerItemProps = {
35
37
  remove: (index: number) => void;
36
38
  copy: (index: number) => void;
37
39
  addInIndex?: (index: number) => void;
40
+ includeAddButton?: boolean;
38
41
  isDragging: boolean;
39
42
  storedProps?: object;
40
43
  updateItemCustomProps: (internalId: number, props: object) => void;
41
44
  };
42
- export declare function ArrayContainerItem({ provided, index, internalId, size, disabled, buildEntry, remove, addInIndex, copy, isDragging, storedProps, updateItemCustomProps }: ArrayContainerItemProps): import("react/jsx-runtime").JSX.Element;
43
- export declare function ArrayItemOptions({ direction, disabled, remove, index, provided, copy, addInIndex }: {
45
+ export declare function ArrayContainerItem({ provided, index, internalId, size, disabled, buildEntry, remove, addInIndex, includeAddButton, copy, isDragging, storedProps, updateItemCustomProps }: ArrayContainerItemProps): import("react/jsx-runtime").JSX.Element;
46
+ export declare function ArrayItemOptions({ direction, disabled, remove, index, provided, copy, includeAddButton, addInIndex }: {
44
47
  direction?: "row" | "column";
45
48
  disabled: boolean;
46
49
  remove: (index: number) => void;
47
50
  index: number;
48
51
  provided: any;
49
52
  copy: (index: number) => void;
53
+ includeAddButton?: boolean;
50
54
  addInIndex?: (index: number) => void;
51
55
  }): import("react/jsx-runtime").JSX.Element;
52
56
  export declare function getRandomId(): number;
package/dist/index.es.js CHANGED
@@ -3703,7 +3703,7 @@ const DialogsProvider = (t0) => {
3703
3703
  if ($[7] !== close || $[8] !== dialogEntries) {
3704
3704
  let t72;
3705
3705
  if ($[10] !== close) {
3706
- t72 = (entry, i) => /* @__PURE__ */ jsx(entry.Component, { open: true, closeDialog: close }, `dialog_${i}`);
3706
+ t72 = (entry, i) => /* @__PURE__ */ jsx(entry.Component, { open: true, closeDialog: close, ...entry.props }, `dialog_${i}`);
3707
3707
  $[10] = close;
3708
3708
  $[11] = t72;
3709
3709
  } else {
@@ -13624,7 +13624,9 @@ function ArrayContainer({
13624
13624
  includeAddButton,
13625
13625
  newDefaultEntry,
13626
13626
  onValueChange,
13627
- className
13627
+ className,
13628
+ min = 0,
13629
+ max = Infinity
13628
13630
  }) {
13629
13631
  const hasValue = value && Array.isArray(value) && value.length > 0;
13630
13632
  const internalIdsRef = useRef(buildIdsMap(value));
@@ -13650,7 +13652,7 @@ function ArrayContainer({
13650
13652
  }, [hasValue, internalIds.length, value]);
13651
13653
  const insertInEnd = (e) => {
13652
13654
  e.preventDefault();
13653
- if (disabled) return;
13655
+ if (disabled || value.length >= max) return;
13654
13656
  const id = getRandomId$1();
13655
13657
  const newIds = [...internalIds, id];
13656
13658
  if (onInternalIdAdded) onInternalIdAdded(id);
@@ -13658,22 +13660,25 @@ function ArrayContainer({
13658
13660
  onValueChange([...value ?? [], newDefaultEntry]);
13659
13661
  };
13660
13662
  const remove = (index_0) => {
13663
+ if (value.length <= min) return;
13661
13664
  const newIds_0 = [...internalIds];
13662
13665
  newIds_0.splice(index_0, 1);
13663
13666
  setInternalIds(newIds_0);
13664
13667
  onValueChange(value.filter((_, i) => i !== index_0));
13665
13668
  };
13666
13669
  const copy = (index_1) => {
13670
+ if (value.length >= max) return;
13667
13671
  const id_0 = getRandomId$1();
13668
13672
  const copyingItem = value[index_1];
13669
- const newIds_1 = [...internalIds.splice(0, index_1 + 1), id_0, ...internalIds.splice(index_1 + 1, internalIds.length - index_1 - 1)];
13673
+ const newIds_1 = [...internalIds.slice(0, index_1 + 1), id_0, ...internalIds.slice(index_1 + 1)];
13670
13674
  if (onInternalIdAdded) onInternalIdAdded(id_0);
13671
13675
  setInternalIds(newIds_1);
13672
13676
  onValueChange([...value.slice(0, index_1 + 1), copyingItem, ...value.slice(index_1 + 1)]);
13673
13677
  };
13674
13678
  const addInIndex = (index_2) => {
13679
+ if (value.length >= max) return;
13675
13680
  const id_1 = getRandomId$1();
13676
- const newIds_2 = [...internalIds.splice(0, index_2), id_1, ...internalIds.slice(index_2)];
13681
+ const newIds_2 = [...internalIds.slice(0, index_2), id_1, ...internalIds.slice(index_2)];
13677
13682
  if (onInternalIdAdded) onInternalIdAdded(id_1);
13678
13683
  setInternalIds(newIds_2);
13679
13684
  onValueChange([...value.slice(0, index_2), newDefaultEntry, ...value.slice(index_2)]);
@@ -13694,17 +13699,17 @@ function ArrayContainer({
13694
13699
  return /* @__PURE__ */ jsx(DragDropContext, { onDragEnd, children: /* @__PURE__ */ jsx(Droppable, { droppableId, renderClone: (provided, snapshot, rubric) => {
13695
13700
  const index_3 = rubric.source.index;
13696
13701
  const internalId_0 = internalIds[index_3];
13697
- return /* @__PURE__ */ jsx(ArrayContainerItem, { provided, internalId: internalId_0, index: index_3, size, disabled, buildEntry, remove, copy, isDragging: snapshot.isDragging, storedProps: itemCustomPropsRef.current[internalId_0], updateItemCustomProps, addInIndex });
13702
+ return /* @__PURE__ */ jsx(ArrayContainerItem, { provided, internalId: internalId_0, index: index_3, size, disabled, buildEntry, remove, copy, isDragging: snapshot.isDragging, storedProps: itemCustomPropsRef.current[internalId_0], updateItemCustomProps, addInIndex, includeAddButton });
13698
13703
  }, children: (droppableProvided, droppableSnapshot) => /* @__PURE__ */ jsxs("div", { className: cls("space-y-1", className), ...droppableProvided.droppableProps, ref: droppableProvided.innerRef, children: [
13699
13704
  hasValue && internalIds.map((internalId_1, index_4) => {
13700
- return /* @__PURE__ */ jsx(Draggable, { draggableId: `array_field_${internalId_1}`, isDragDisabled: disabled, index: index_4, children: (provided_0, snapshot_0) => /* @__PURE__ */ jsx(ArrayContainerItem, { provided: provided_0, internalId: internalId_1, index: index_4, size, disabled, buildEntry, remove, copy, isDragging: snapshot_0.isDragging, storedProps: itemCustomPropsRef.current[internalId_1], updateItemCustomProps, addInIndex }) }, `array_field_${internalId_1}`);
13705
+ return /* @__PURE__ */ jsx(Draggable, { draggableId: `array_field_${internalId_1}`, isDragDisabled: disabled, index: index_4, children: (provided_0, snapshot_0) => /* @__PURE__ */ jsx(ArrayContainerItem, { provided: provided_0, internalId: internalId_1, index: index_4, size, disabled, buildEntry, remove, copy, isDragging: snapshot_0.isDragging, storedProps: itemCustomPropsRef.current[internalId_1], updateItemCustomProps, addInIndex, includeAddButton }) }, `array_field_${internalId_1}`);
13701
13706
  }),
13702
13707
  droppableProvided.placeholder,
13703
- includeAddButton && /* @__PURE__ */ jsx("div", { className: "py-4 justify-center text-left", children: /* @__PURE__ */ jsx(Button, { variant: "text", size: size === "small" ? "small" : "medium", color: "primary", disabled, startIcon: /* @__PURE__ */ jsx(AddIcon, {}), onClick: insertInEnd, children: addLabel ?? "Add" }) })
13708
+ includeAddButton && /* @__PURE__ */ jsx("div", { className: "my-4 justify-center text-left", children: /* @__PURE__ */ jsx(Button, { variant: "text", size: size === "small" ? "small" : "medium", color: "primary", disabled: disabled || value.length >= max, startIcon: /* @__PURE__ */ jsx(AddIcon, {}), onClick: insertInEnd, children: addLabel ?? "Add" }) })
13704
13709
  ] }) }) });
13705
13710
  }
13706
13711
  function ArrayContainerItem(t0) {
13707
- const $ = c(28);
13712
+ const $ = c(29);
13708
13713
  const {
13709
13714
  provided,
13710
13715
  index,
@@ -13714,6 +13719,7 @@ function ArrayContainerItem(t0) {
13714
13719
  buildEntry,
13715
13720
  remove,
13716
13721
  addInIndex,
13722
+ includeAddButton,
13717
13723
  copy,
13718
13724
  isDragging,
13719
13725
  storedProps,
@@ -13761,41 +13767,42 @@ function ArrayContainerItem(t0) {
13761
13767
  }
13762
13768
  const t8 = size === "small" ? "row" : "column";
13763
13769
  let t9;
13764
- if ($[12] !== addInIndex || $[13] !== copy || $[14] !== disabled || $[15] !== index || $[16] !== provided || $[17] !== remove || $[18] !== t8) {
13765
- t9 = /* @__PURE__ */ jsx(ArrayItemOptions, { direction: t8, disabled, remove, index, provided, addInIndex, copy });
13770
+ if ($[12] !== addInIndex || $[13] !== copy || $[14] !== disabled || $[15] !== includeAddButton || $[16] !== index || $[17] !== provided || $[18] !== remove || $[19] !== t8) {
13771
+ t9 = /* @__PURE__ */ jsx(ArrayItemOptions, { direction: t8, disabled, remove, index, provided, addInIndex, includeAddButton, copy });
13766
13772
  $[12] = addInIndex;
13767
13773
  $[13] = copy;
13768
13774
  $[14] = disabled;
13769
- $[15] = index;
13770
- $[16] = provided;
13771
- $[17] = remove;
13772
- $[18] = t8;
13773
- $[19] = t9;
13775
+ $[15] = includeAddButton;
13776
+ $[16] = index;
13777
+ $[17] = provided;
13778
+ $[18] = remove;
13779
+ $[19] = t8;
13780
+ $[20] = t9;
13774
13781
  } else {
13775
- t9 = $[19];
13782
+ t9 = $[20];
13776
13783
  }
13777
13784
  let t10;
13778
- if ($[20] !== t7 || $[21] !== t9) {
13785
+ if ($[21] !== t7 || $[22] !== t9) {
13779
13786
  t10 = /* @__PURE__ */ jsxs("div", { className: "flex items-start", children: [
13780
13787
  t7,
13781
13788
  t9
13782
13789
  ] });
13783
- $[20] = t7;
13784
- $[21] = t9;
13785
- $[22] = t10;
13790
+ $[21] = t7;
13791
+ $[22] = t9;
13792
+ $[23] = t10;
13786
13793
  } else {
13787
- t10 = $[22];
13794
+ t10 = $[23];
13788
13795
  }
13789
13796
  let t11;
13790
- if ($[23] !== provided.draggableProps || $[24] !== provided.innerRef || $[25] !== t10 || $[26] !== t4) {
13797
+ if ($[24] !== provided.draggableProps || $[25] !== provided.innerRef || $[26] !== t10 || $[27] !== t4) {
13791
13798
  t11 = /* @__PURE__ */ jsx("div", { ref: t1, ...t2, style: t3, className: t4, children: t10 });
13792
- $[23] = provided.draggableProps;
13793
- $[24] = provided.innerRef;
13794
- $[25] = t10;
13795
- $[26] = t4;
13796
- $[27] = t11;
13799
+ $[24] = provided.draggableProps;
13800
+ $[25] = provided.innerRef;
13801
+ $[26] = t10;
13802
+ $[27] = t4;
13803
+ $[28] = t11;
13797
13804
  } else {
13798
- t11 = $[27];
13805
+ t11 = $[28];
13799
13806
  }
13800
13807
  return t11;
13801
13808
  }
@@ -13806,6 +13813,7 @@ function ArrayItemOptions({
13806
13813
  index,
13807
13814
  provided,
13808
13815
  copy,
13816
+ includeAddButton,
13809
13817
  addInIndex
13810
13818
  }) {
13811
13819
  const [menuOpen, setMenuOpen] = useState(false);
@@ -13833,14 +13841,14 @@ function ArrayItemOptions({
13833
13841
  /* @__PURE__ */ jsx(ContentCopyIcon, { size: "small" }),
13834
13842
  "Copy"
13835
13843
  ] }),
13836
- addInIndex && /* @__PURE__ */ jsxs(MenuItem, { dense: true, onClick: () => {
13844
+ includeAddButton && addInIndex && /* @__PURE__ */ jsxs(MenuItem, { dense: true, onClick: () => {
13837
13845
  setMenuOpen(false);
13838
13846
  addInIndex(index);
13839
13847
  }, children: [
13840
13848
  /* @__PURE__ */ jsx(KeyboardArrowUpIcon, { size: "small" }),
13841
13849
  "Add on top"
13842
13850
  ] }),
13843
- addInIndex && /* @__PURE__ */ jsxs(MenuItem, { dense: true, onClick: () => {
13851
+ includeAddButton && addInIndex && /* @__PURE__ */ jsxs(MenuItem, { dense: true, onClick: () => {
13844
13852
  setMenuOpen(false);
13845
13853
  addInIndex(index + 1);
13846
13854
  }, children: [
@@ -14434,7 +14442,7 @@ function encodePath(input) {
14434
14442
  return encodeURIComponent(removeInitialAndTrailingSlashes(input)).replaceAll("%2F", "/").replaceAll("%23", "#");
14435
14443
  }
14436
14444
  function filterOutNotAllowedCollections(resolvedCollections, authController) {
14437
- return resolvedCollections.filter((c2) => {
14445
+ return resolvedCollections.filter((c2) => Boolean(c2.path)).filter((c2) => {
14438
14446
  if (!c2.permissions) return true;
14439
14447
  const resolvedPermissions = resolvePermissions(c2, authController, c2.path, null);
14440
14448
  return resolvedPermissions?.read !== false;
@@ -21861,7 +21869,6 @@ function useBuildSideDialogsController() {
21861
21869
  let t7;
21862
21870
  if ($[15] !== location || $[16] !== navigate || $[17] !== sidePanels) {
21863
21871
  t7 = (panelProps_0) => {
21864
- console.log("replace", panelProps_0);
21865
21872
  const newPanels_2 = Array.isArray(panelProps_0) ? panelProps_0 : [panelProps_0];
21866
21873
  newPanels_2.forEach((panel_1) => {
21867
21874
  routesStore.current[panel_1.key] = panel_1;
@@ -22677,7 +22684,7 @@ function DrawerLogo(t0) {
22677
22684
  }
22678
22685
  let t4;
22679
22686
  if ($[3] !== drawerOpen || $[4] !== logo) {
22680
- t4 = logo ? /* @__PURE__ */ jsx("img", { src: logo, alt: "Logo", className: cls("max-w-full max-h-full transition-all", drawerOpen ? "w-[96px] h-[96px]" : "w-[32px] h-[32px]") }) : /* @__PURE__ */ jsx(FireCMSLogo, {});
22687
+ t4 = logo ? /* @__PURE__ */ jsx("img", { src: logo, alt: "Logo", className: cls("max-w-full max-h-full transition-all object-contain", drawerOpen ? "w-[96px] h-[96px]" : "w-[32px] h-[32px]") }) : /* @__PURE__ */ jsx(FireCMSLogo, {});
22681
22688
  $[3] = drawerOpen;
22682
22689
  $[4] = logo;
22683
22690
  $[5] = t4;