@firecms/core 3.0.0-canary.126 → 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.
package/dist/index.umd.js CHANGED
@@ -2964,9 +2964,11 @@
2964
2964
  function makePropertiesEditable(properties) {
2965
2965
  Object.keys(properties).forEach((key) => {
2966
2966
  const property = properties[key];
2967
- property.editable = true;
2968
- if (property.dataType === "map" && property.properties) {
2969
- makePropertiesEditable(property.properties);
2967
+ if (property) {
2968
+ property.editable = true;
2969
+ if (property.dataType === "map" && property.properties) {
2970
+ makePropertiesEditable(property.properties);
2971
+ }
2970
2972
  }
2971
2973
  });
2972
2974
  return properties;
@@ -2974,13 +2976,19 @@
2974
2976
  function makePropertiesNonEditable(properties) {
2975
2977
  return Object.entries(properties).reduce((acc, [key, property]) => {
2976
2978
  if (!isPropertyBuilder(property) && property.dataType === "map" && property.properties) {
2977
- const updated = { ...property, properties: makePropertiesNonEditable(property.properties) };
2979
+ const updated = {
2980
+ ...property,
2981
+ properties: makePropertiesNonEditable(property.properties)
2982
+ };
2978
2983
  acc[key] = updated;
2979
2984
  }
2980
2985
  if (isPropertyBuilder(property)) {
2981
2986
  acc[key] = property;
2982
2987
  } else {
2983
- acc[key] = { ...property, editable: false };
2988
+ acc[key] = {
2989
+ ...property,
2990
+ editable: false
2991
+ };
2984
2992
  }
2985
2993
  return acc;
2986
2994
  }, {});
@@ -10786,6 +10794,23 @@
10786
10794
  }
10787
10795
  );
10788
10796
  }
10797
+ function addRecentId(collectionId, id) {
10798
+ const recentIds = getRecentIds(collectionId);
10799
+ const newRecentIds = [id, ...recentIds.filter((i) => i !== id)];
10800
+ if (newRecentIds.length > 5) {
10801
+ newRecentIds.pop();
10802
+ }
10803
+ saveSearchedIdsLocally(collectionId, newRecentIds);
10804
+ return newRecentIds;
10805
+ }
10806
+ function saveSearchedIdsLocally(collectionId, ids) {
10807
+ localStorage.setItem("recent_id_searches::" + collectionId, JSON.stringify(ids));
10808
+ }
10809
+ function getRecentIds(collectionId) {
10810
+ const stored = localStorage.getItem("recent_id_searches::" + collectionId);
10811
+ if (!stored) return [];
10812
+ return JSON.parse(stored);
10813
+ }
10789
10814
  const editEntityAction = {
10790
10815
  icon: /* @__PURE__ */ jsxRuntime.jsx(ui.KeyboardTabIcon, {}),
10791
10816
  name: "Edit",
@@ -10803,6 +10828,9 @@
10803
10828
  path: entity.path,
10804
10829
  entityId: entity.id
10805
10830
  });
10831
+ if (collection) {
10832
+ addRecentId(collection.id, entity.id);
10833
+ }
10806
10834
  const path = collection?.collectionGroup ? entity.path : fullPath ?? entity.path;
10807
10835
  context.sideEntityController.open({
10808
10836
  entityId: entity.id,
@@ -12841,6 +12869,7 @@
12841
12869
  }) {
12842
12870
  const [openPopup, setOpenPopup] = React.useState(false);
12843
12871
  const [searchString, setSearchString] = React.useState("");
12872
+ const [recentIds, setRecentIds] = React.useState(getRecentIds(collection.id));
12844
12873
  const sideEntityController = useSideEntityController();
12845
12874
  return /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: !openPopup ? "Find by ID" : void 0, asChild: false, children: /* @__PURE__ */ jsxRuntime.jsx(
12846
12875
  ui.Popover,
@@ -12851,47 +12880,69 @@
12851
12880
  align: "start",
12852
12881
  alignOffset: -117,
12853
12882
  trigger: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(ui.SearchIcon, { size: "small" }) }),
12854
- children: /* @__PURE__ */ jsxRuntime.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
- });
12883
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls("my-2 rounded-lg bg-gray-50 dark:bg-gray-950 text-gray-900 dark:text-white"), children: [
12884
+ /* @__PURE__ */ jsxRuntime.jsx(
12885
+ "form",
12886
+ {
12887
+ noValidate: true,
12888
+ onSubmit: (e) => {
12889
+ e.preventDefault();
12890
+ if (!searchString) return;
12891
+ setOpenPopup(false);
12892
+ setRecentIds(addRecentId(collection.id, searchString.trim()));
12893
+ return sideEntityController.open({
12894
+ entityId: searchString.trim(),
12895
+ path,
12896
+ collection,
12897
+ updateUrl: true
12898
+ });
12899
+ },
12900
+ className: "w-96 max-w-full",
12901
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex p-2 w-full gap-2", children: [
12902
+ /* @__PURE__ */ jsxRuntime.jsx(
12903
+ "input",
12904
+ {
12905
+ autoFocus: openPopup,
12906
+ placeholder: "Find entity by ID",
12907
+ onChange: (e) => {
12908
+ setSearchString(e.target.value);
12909
+ },
12910
+ value: searchString,
12911
+ className: "rounded-lg bg-white dark:bg-gray-800 flex-grow bg-transparent outline-none p-2 " + ui.focusedDisabled
12912
+ }
12913
+ ),
12914
+ /* @__PURE__ */ jsxRuntime.jsx(
12915
+ ui.Button,
12916
+ {
12917
+ variant: "text",
12918
+ disabled: !searchString.trim(),
12919
+ type: "submit",
12920
+ children: /* @__PURE__ */ jsxRuntime.jsx(ui.KeyboardTabIcon, {})
12921
+ }
12922
+ )
12923
+ ] })
12924
+ }
12925
+ ),
12926
+ recentIds && recentIds.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2 p-2", children: recentIds.map((id) => /* @__PURE__ */ jsxRuntime.jsx(
12927
+ ReferencePreview,
12928
+ {
12929
+ reference: new EntityReference(id, path),
12930
+ hover: true,
12931
+ onClick: () => {
12932
+ setOpenPopup(false);
12933
+ sideEntityController.open({
12934
+ entityId: id,
12935
+ path,
12936
+ collection,
12937
+ updateUrl: true
12938
+ });
12939
+ },
12940
+ includeEntityLink: false,
12941
+ size: "small"
12868
12942
  },
12869
- className: "text-gray-900 dark:text-white w-96 max-w-full",
12870
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex p-2 w-full gap-4", children: [
12871
- /* @__PURE__ */ jsxRuntime.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 " + ui.focusedDisabled
12881
- }
12882
- ),
12883
- /* @__PURE__ */ jsxRuntime.jsx(
12884
- ui.Button,
12885
- {
12886
- variant: "outlined",
12887
- disabled: !searchString.trim(),
12888
- type: "submit",
12889
- children: "Go"
12890
- }
12891
- )
12892
- ] })
12893
- }
12894
- )
12943
+ id
12944
+ )) })
12945
+ ] })
12895
12946
  }
12896
12947
  ) });
12897
12948
  }