@firecms/core 3.0.0-canary.125 → 3.0.0-canary.127

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.
@@ -0,0 +1,3 @@
1
+ export declare function addRecentId(collectionId: string, id: string): string[];
2
+ export declare function saveSearchedIdsLocally(collectionId: string, ids: string[]): void;
3
+ export declare function getRecentIds(collectionId: string): string[];
@@ -7,7 +7,7 @@ export type EntityPreviewProps = {
7
7
  collection?: EntityCollection;
8
8
  hover?: boolean;
9
9
  previewProperties?: string[];
10
- disabled: undefined | boolean;
10
+ disabled?: boolean;
11
11
  entity: Entity<any>;
12
12
  includeId?: boolean;
13
13
  includeEntityLink?: boolean;
package/dist/index.es.js CHANGED
@@ -2960,9 +2960,11 @@ function getArrayValuesCount(array) {
2960
2960
  function makePropertiesEditable(properties) {
2961
2961
  Object.keys(properties).forEach((key) => {
2962
2962
  const property = properties[key];
2963
- property.editable = true;
2964
- if (property.dataType === "map" && property.properties) {
2965
- makePropertiesEditable(property.properties);
2963
+ if (property) {
2964
+ property.editable = true;
2965
+ if (property.dataType === "map" && property.properties) {
2966
+ makePropertiesEditable(property.properties);
2967
+ }
2966
2968
  }
2967
2969
  });
2968
2970
  return properties;
@@ -2970,13 +2972,19 @@ function makePropertiesEditable(properties) {
2970
2972
  function makePropertiesNonEditable(properties) {
2971
2973
  return Object.entries(properties).reduce((acc, [key, property]) => {
2972
2974
  if (!isPropertyBuilder(property) && property.dataType === "map" && property.properties) {
2973
- const updated = { ...property, properties: makePropertiesNonEditable(property.properties) };
2975
+ const updated = {
2976
+ ...property,
2977
+ properties: makePropertiesNonEditable(property.properties)
2978
+ };
2974
2979
  acc[key] = updated;
2975
2980
  }
2976
2981
  if (isPropertyBuilder(property)) {
2977
2982
  acc[key] = property;
2978
2983
  } else {
2979
- acc[key] = { ...property, editable: false };
2984
+ acc[key] = {
2985
+ ...property,
2986
+ editable: false
2987
+ };
2980
2988
  }
2981
2989
  return acc;
2982
2990
  }, {});
@@ -6997,7 +7005,7 @@ function StorageUpload$1({
6997
7005
  onDropRejected: (fileRejections, event) => {
6998
7006
  for (const fileRejection of fileRejections) {
6999
7007
  for (const error2 of fileRejection.errors) {
7000
- console.log("Error uploading file: ", error2);
7008
+ console.error("Error uploading file: ", error2);
7001
7009
  if (error2.code === "file-too-large") {
7002
7010
  snackbarContext.open({
7003
7011
  type: "error",
@@ -7161,7 +7169,6 @@ const TableReferenceFieldInternal = React__default.memo(
7161
7169
  updateValue(entity ? getReferenceFrom(entity) : null);
7162
7170
  }, [updateValue]);
7163
7171
  const onMultipleEntitiesSelected = useCallback((entities) => {
7164
- console.log("onMultipleEntitiesSelected", entities);
7165
7172
  updateValue(entities.map((e) => getReferenceFrom(e)));
7166
7173
  }, [updateValue]);
7167
7174
  const selectedEntityIds = internalValue ? Array.isArray(internalValue) ? internalValue.map((ref) => ref.id) : internalValue.id ? [internalValue.id] : [] : [];
@@ -9602,7 +9609,6 @@ function StringNumberFilterField({
9602
9609
  }
9603
9610
  }
9604
9611
  const multiple = multipleSelectOperations$1.includes(operation);
9605
- console.log("internalValue", { internalValue });
9606
9612
  return /* @__PURE__ */ jsxs("div", { className: "flex w-[440px]", children: [
9607
9613
  /* @__PURE__ */ jsx("div", { className: "w-[80px]", children: /* @__PURE__ */ jsx(
9608
9614
  Select,
@@ -10784,6 +10790,23 @@ function DeleteEntityDialog({
10784
10790
  }
10785
10791
  );
10786
10792
  }
10793
+ function addRecentId(collectionId, id) {
10794
+ const recentIds = getRecentIds(collectionId);
10795
+ const newRecentIds = [id, ...recentIds.filter((i) => i !== id)];
10796
+ if (newRecentIds.length > 5) {
10797
+ newRecentIds.pop();
10798
+ }
10799
+ saveSearchedIdsLocally(collectionId, newRecentIds);
10800
+ return newRecentIds;
10801
+ }
10802
+ function saveSearchedIdsLocally(collectionId, ids) {
10803
+ localStorage.setItem("recent_id_searches::" + collectionId, JSON.stringify(ids));
10804
+ }
10805
+ function getRecentIds(collectionId) {
10806
+ const stored = localStorage.getItem("recent_id_searches::" + collectionId);
10807
+ if (!stored) return [];
10808
+ return JSON.parse(stored);
10809
+ }
10787
10810
  const editEntityAction = {
10788
10811
  icon: /* @__PURE__ */ jsx(KeyboardTabIcon, {}),
10789
10812
  name: "Edit",
@@ -10801,6 +10824,9 @@ const editEntityAction = {
10801
10824
  path: entity.path,
10802
10825
  entityId: entity.id
10803
10826
  });
10827
+ if (collection) {
10828
+ addRecentId(collection.id, entity.id);
10829
+ }
10804
10830
  const path = collection?.collectionGroup ? entity.path : fullPath ?? entity.path;
10805
10831
  context.sideEntityController.open({
10806
10832
  entityId: entity.id,
@@ -11532,7 +11558,6 @@ function DefaultHomePage({
11532
11558
  setFilteredUrls(null);
11533
11559
  } else {
11534
11560
  const searchResult = fuse.current?.search(value);
11535
- console.log("Search result", searchResult);
11536
11561
  if (searchResult) {
11537
11562
  setFilteredUrls(searchResult.map((e) => e.item.url));
11538
11563
  }
@@ -12333,7 +12358,6 @@ const EntityCollectionView = React__default.memo(
12333
12358
  tableController.setPopupCell?.(void 0);
12334
12359
  }, [tableController.setPopupCell]);
12335
12360
  const onEntityClick = useCallback((clickedEntity) => {
12336
- console.log("Entity clicked", clickedEntity);
12337
12361
  const collection2 = collectionRef.current;
12338
12362
  setHighlightedEntity(clickedEntity);
12339
12363
  analyticsController.onAnalyticsEvent?.("edit_entity_clicked", {
@@ -12841,6 +12865,7 @@ function EntityIdHeaderWidget({
12841
12865
  }) {
12842
12866
  const [openPopup, setOpenPopup] = React__default.useState(false);
12843
12867
  const [searchString, setSearchString] = React__default.useState("");
12868
+ const [recentIds, setRecentIds] = React__default.useState(getRecentIds(collection.id));
12844
12869
  const sideEntityController = useSideEntityController();
12845
12870
  return /* @__PURE__ */ jsx(Tooltip, { title: !openPopup ? "Find by ID" : void 0, asChild: false, children: /* @__PURE__ */ jsx(
12846
12871
  Popover,
@@ -12851,47 +12876,69 @@ function EntityIdHeaderWidget({
12851
12876
  align: "start",
12852
12877
  alignOffset: -117,
12853
12878
  trigger: /* @__PURE__ */ jsx(IconButton, { size: "small", children: /* @__PURE__ */ jsx(SearchIcon, { size: "small" }) }),
12854
- children: /* @__PURE__ */ jsx(
12855
- "form",
12856
- {
12857
- noValidate: true,
12858
- onSubmit: (e) => {
12859
- e.preventDefault();
12860
- if (!searchString) return;
12861
- setOpenPopup(false);
12862
- return sideEntityController.open({
12863
- entityId: searchString.trim(),
12864
- path,
12865
- collection,
12866
- updateUrl: true
12867
- });
12879
+ children: /* @__PURE__ */ jsxs("div", { className: cls("my-2 rounded-lg bg-gray-50 dark:bg-gray-950 text-gray-900 dark:text-white"), children: [
12880
+ /* @__PURE__ */ jsx(
12881
+ "form",
12882
+ {
12883
+ noValidate: true,
12884
+ onSubmit: (e) => {
12885
+ e.preventDefault();
12886
+ if (!searchString) return;
12887
+ setOpenPopup(false);
12888
+ setRecentIds(addRecentId(collection.id, searchString.trim()));
12889
+ return sideEntityController.open({
12890
+ entityId: searchString.trim(),
12891
+ path,
12892
+ collection,
12893
+ updateUrl: true
12894
+ });
12895
+ },
12896
+ className: "w-96 max-w-full",
12897
+ children: /* @__PURE__ */ jsxs("div", { className: "flex p-2 w-full gap-2", children: [
12898
+ /* @__PURE__ */ jsx(
12899
+ "input",
12900
+ {
12901
+ autoFocus: openPopup,
12902
+ placeholder: "Find entity by ID",
12903
+ onChange: (e) => {
12904
+ setSearchString(e.target.value);
12905
+ },
12906
+ value: searchString,
12907
+ className: "rounded-lg bg-white dark:bg-gray-800 flex-grow bg-transparent outline-none p-2 " + focusedDisabled
12908
+ }
12909
+ ),
12910
+ /* @__PURE__ */ jsx(
12911
+ Button,
12912
+ {
12913
+ variant: "text",
12914
+ disabled: !searchString.trim(),
12915
+ type: "submit",
12916
+ children: /* @__PURE__ */ jsx(KeyboardTabIcon, {})
12917
+ }
12918
+ )
12919
+ ] })
12920
+ }
12921
+ ),
12922
+ recentIds && recentIds.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2 p-2", children: recentIds.map((id) => /* @__PURE__ */ jsx(
12923
+ ReferencePreview,
12924
+ {
12925
+ reference: new EntityReference(id, path),
12926
+ hover: true,
12927
+ onClick: () => {
12928
+ setOpenPopup(false);
12929
+ sideEntityController.open({
12930
+ entityId: id,
12931
+ path,
12932
+ collection,
12933
+ updateUrl: true
12934
+ });
12935
+ },
12936
+ includeEntityLink: false,
12937
+ size: "small"
12868
12938
  },
12869
- className: "text-gray-900 dark:text-white w-96 max-w-full",
12870
- children: /* @__PURE__ */ jsxs("div", { className: "flex p-2 w-full gap-4", children: [
12871
- /* @__PURE__ */ jsx(
12872
- "input",
12873
- {
12874
- autoFocus: openPopup,
12875
- placeholder: "Find entity by ID",
12876
- onChange: (e) => {
12877
- setSearchString(e.target.value);
12878
- },
12879
- value: searchString,
12880
- className: "flex-grow bg-transparent outline-none p-1 " + focusedDisabled
12881
- }
12882
- ),
12883
- /* @__PURE__ */ jsx(
12884
- Button,
12885
- {
12886
- variant: "outlined",
12887
- disabled: !searchString.trim(),
12888
- type: "submit",
12889
- children: "Go"
12890
- }
12891
- )
12892
- ] })
12893
- }
12894
- )
12939
+ id
12940
+ )) })
12941
+ ] })
12895
12942
  }
12896
12943
  ) });
12897
12944
  }
@@ -13746,7 +13793,6 @@ function SearchIconsView({
13746
13793
  };
13747
13794
  }, [query, updateSearchResults]);
13748
13795
  const icons = keys === null ? coolIconKeys : keys;
13749
- console.log("Icons", icons);
13750
13796
  return /* @__PURE__ */ jsxs(Fragment, { children: [
13751
13797
  /* @__PURE__ */ jsx(
13752
13798
  SearchBar,
@@ -14437,7 +14483,7 @@ function FileDropComponent({
14437
14483
  onDropRejected: (fileRejections, event) => {
14438
14484
  for (const fileRejection of fileRejections) {
14439
14485
  for (const error of fileRejection.errors) {
14440
- console.log("Error uploading file: ", error);
14486
+ console.error("Error uploading file: ", error);
14441
14487
  if (error.code === "file-too-large") {
14442
14488
  snackbarContext.open({
14443
14489
  type: "error",
@@ -17494,7 +17540,6 @@ function EntityEditViewInner({
17494
17540
  if (onUpdate)
17495
17541
  onUpdate({ entity: updatedEntity });
17496
17542
  if (closeAfterSave) {
17497
- console.log("Closing side dialog");
17498
17543
  sideDialogContext.setBlocked(false);
17499
17544
  sideDialogContext.close(true);
17500
17545
  onClose?.();
@@ -18344,7 +18389,6 @@ function SideDialogView({
18344
18389
  const handleDrawerCloseOk = () => {
18345
18390
  setBlocked(false);
18346
18391
  setDrawerCloseRequested(false);
18347
- console.log("handleDrawerCloseOk");
18348
18392
  sideDialogsController.close();
18349
18393
  panel?.onClose?.();
18350
18394
  };
@@ -19527,7 +19571,7 @@ function DefaultDrawer({
19527
19571
  Object.values(navigationEntries).filter((e) => e.group === group).map((view, index) => /* @__PURE__ */ jsx(
19528
19572
  DrawerNavigationItem,
19529
19573
  {
19530
- icon: /* @__PURE__ */ jsx(IconForView, { collectionOrView: view.collection ?? view.view }),
19574
+ icon: /* @__PURE__ */ jsx(IconForView, { collectionOrView: view.collection ?? view.view, size: "small" }),
19531
19575
  tooltipsOpen,
19532
19576
  adminMenuOpen,
19533
19577
  drawerOpen,