@firecms/core 3.5.2-canary.09e1281 → 3.5.2-canary.a36570e
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/components/EntityCollectionView/utils.d.ts +1 -0
- package/dist/index.es.js +69 -185
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +69 -185
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
- package/src/components/EntityCollectionView/EntityIdHeaderWidget.tsx +50 -8
- package/src/components/EntityCollectionView/utils.ts +6 -0
package/dist/index.umd.js
CHANGED
|
@@ -21084,6 +21084,11 @@
|
|
|
21084
21084
|
function getRecentIds(key) {
|
|
21085
21085
|
return getLocalStorageJSON("recent_id_searches::" + key, []);
|
|
21086
21086
|
}
|
|
21087
|
+
function removeRecentIds(key, ids) {
|
|
21088
|
+
const remaining = getRecentIds(key).filter((id) => !ids.includes(id));
|
|
21089
|
+
saveSearchedIdsLocally(key, remaining);
|
|
21090
|
+
return remaining;
|
|
21091
|
+
}
|
|
21087
21092
|
const editEntityAction = {
|
|
21088
21093
|
icon: /* @__PURE__ */ jsxRuntime.jsx(ui.EditIcon, { size: "small" }),
|
|
21089
21094
|
key: "edit",
|
|
@@ -26595,164 +26600,86 @@
|
|
|
26595
26600
|
return key_0.toString();
|
|
26596
26601
|
}
|
|
26597
26602
|
const DEFAULT_ENTITY_OPEN_MODE$1 = "side_panel";
|
|
26598
|
-
function EntityIdHeaderWidget(
|
|
26599
|
-
|
|
26600
|
-
|
|
26601
|
-
|
|
26602
|
-
|
|
26603
|
-
|
|
26604
|
-
fullIdPath
|
|
26605
|
-
} = t0;
|
|
26603
|
+
function EntityIdHeaderWidget({
|
|
26604
|
+
collection,
|
|
26605
|
+
path,
|
|
26606
|
+
pathSegments,
|
|
26607
|
+
fullIdPath
|
|
26608
|
+
}) {
|
|
26606
26609
|
const navigation = useNavigationController();
|
|
26610
|
+
const dataSource = useDataSource();
|
|
26607
26611
|
const [openPopup, setOpenPopup] = React.useState(false);
|
|
26608
26612
|
const [searchString, setSearchString] = React.useState("");
|
|
26609
|
-
|
|
26610
|
-
|
|
26611
|
-
t1 = () => getRecentIds(fullIdPath);
|
|
26612
|
-
$[0] = fullIdPath;
|
|
26613
|
-
$[1] = t1;
|
|
26614
|
-
} else {
|
|
26615
|
-
t1 = $[1];
|
|
26616
|
-
}
|
|
26617
|
-
const [recentIds, setRecentIds] = React.useState(t1);
|
|
26613
|
+
const [recentIds, setRecentIds] = React.useState([]);
|
|
26614
|
+
const latestCheck = React.useRef(0);
|
|
26618
26615
|
const sideEntityController = useSideEntityController();
|
|
26619
26616
|
const {
|
|
26620
26617
|
t
|
|
26621
26618
|
} = useTranslation();
|
|
26619
|
+
const resolvedPath = navigation.resolveIdsFrom(path, pathSegments);
|
|
26620
|
+
const resolvedPathSegments = pathSegments ? navigation.resolveSegmentsFrom?.(pathSegments) ?? pathSegments : void 0;
|
|
26621
|
+
const entityExists = React.useCallback(async (entityId) => {
|
|
26622
|
+
try {
|
|
26623
|
+
const entity = await dataSource.fetchEntity({
|
|
26624
|
+
path: resolvedPath,
|
|
26625
|
+
pathSegments: resolvedPathSegments,
|
|
26626
|
+
entityId,
|
|
26627
|
+
collection
|
|
26628
|
+
});
|
|
26629
|
+
return Boolean(entity?.values);
|
|
26630
|
+
} catch (e) {
|
|
26631
|
+
return void 0;
|
|
26632
|
+
}
|
|
26633
|
+
}, [dataSource, resolvedPath, resolvedPathSegments, collection]);
|
|
26634
|
+
const refreshRecentIds = () => {
|
|
26635
|
+
const ids = getRecentIds(fullIdPath);
|
|
26636
|
+
const check = ++latestCheck.current;
|
|
26637
|
+
Promise.all(ids.map(entityExists)).then((results) => {
|
|
26638
|
+
if (check !== latestCheck.current) return;
|
|
26639
|
+
const missing = ids.filter((_, i) => results[i] === false);
|
|
26640
|
+
if (missing.length > 0) removeRecentIds(fullIdPath, missing);
|
|
26641
|
+
setRecentIds(ids.filter((__0, i_0) => results[i_0] === true));
|
|
26642
|
+
});
|
|
26643
|
+
};
|
|
26622
26644
|
const openEntityMode = collection?.openEntityMode ?? DEFAULT_ENTITY_OPEN_MODE$1;
|
|
26623
|
-
|
|
26624
|
-
|
|
26625
|
-
|
|
26626
|
-
|
|
26627
|
-
|
|
26628
|
-
|
|
26629
|
-
|
|
26630
|
-
|
|
26631
|
-
}
|
|
26632
|
-
let t3;
|
|
26633
|
-
if ($[5] !== fullIdPath) {
|
|
26634
|
-
t3 = (open) => {
|
|
26635
|
-
if (open) {
|
|
26636
|
-
setRecentIds(getRecentIds(fullIdPath));
|
|
26637
|
-
}
|
|
26638
|
-
setOpenPopup(open);
|
|
26639
|
-
};
|
|
26640
|
-
$[5] = fullIdPath;
|
|
26641
|
-
$[6] = t3;
|
|
26642
|
-
} else {
|
|
26643
|
-
t3 = $[6];
|
|
26644
|
-
}
|
|
26645
|
-
let t4;
|
|
26646
|
-
let t5;
|
|
26647
|
-
if ($[7] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
26648
|
-
t4 = /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(ui.SearchIcon, { size: "small" }) });
|
|
26649
|
-
t5 = ui.cls("my-2 rounded-lg bg-surface-50 dark:bg-surface-950 text-surface-900 dark:text-white");
|
|
26650
|
-
$[7] = t4;
|
|
26651
|
-
$[8] = t5;
|
|
26652
|
-
} else {
|
|
26653
|
-
t4 = $[7];
|
|
26654
|
-
t5 = $[8];
|
|
26655
|
-
}
|
|
26656
|
-
let t6;
|
|
26657
|
-
if ($[9] !== collection || $[10] !== fullIdPath || $[11] !== navigation || $[12] !== openEntityMode || $[13] !== path || $[14] !== pathSegments || $[15] !== searchString || $[16] !== sideEntityController) {
|
|
26658
|
-
t6 = (e) => {
|
|
26659
|
-
e.preventDefault();
|
|
26660
|
-
const entityId = searchString.trim();
|
|
26661
|
-
if (!entityId) {
|
|
26662
|
-
return;
|
|
26663
|
-
}
|
|
26645
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: !openPopup ? t("find_by_id") : void 0, asChild: false, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Popover, { open: openPopup, onOpenChange: (open) => {
|
|
26646
|
+
if (open) refreshRecentIds();
|
|
26647
|
+
setOpenPopup(open);
|
|
26648
|
+
}, sideOffset: 0, align: "start", alignOffset: -117, trigger: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(ui.SearchIcon, { size: "small" }) }), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls("my-2 rounded-lg bg-surface-50 dark:bg-surface-950 text-surface-900 dark:text-white"), children: [
|
|
26649
|
+
/* @__PURE__ */ jsxRuntime.jsx("form", { noValidate: true, onSubmit: (e_0) => {
|
|
26650
|
+
e_0.preventDefault();
|
|
26651
|
+
const entityId_0 = searchString.trim();
|
|
26652
|
+
if (!entityId_0) return;
|
|
26664
26653
|
setOpenPopup(false);
|
|
26665
|
-
|
|
26654
|
+
entityExists(entityId_0).then((exists) => {
|
|
26655
|
+
if (exists) addRecentId(fullIdPath, entityId_0);
|
|
26656
|
+
});
|
|
26666
26657
|
navigateToEntity({
|
|
26667
26658
|
openEntityMode,
|
|
26668
26659
|
collection,
|
|
26669
|
-
entityId,
|
|
26660
|
+
entityId: entityId_0,
|
|
26670
26661
|
path,
|
|
26671
26662
|
pathSegments,
|
|
26672
26663
|
fullIdPath,
|
|
26673
26664
|
sideEntityController,
|
|
26674
26665
|
navigation
|
|
26675
26666
|
});
|
|
26676
|
-
}
|
|
26677
|
-
|
|
26678
|
-
|
|
26679
|
-
|
|
26680
|
-
|
|
26681
|
-
|
|
26682
|
-
|
|
26683
|
-
|
|
26684
|
-
|
|
26685
|
-
|
|
26686
|
-
|
|
26687
|
-
|
|
26688
|
-
|
|
26689
|
-
|
|
26690
|
-
|
|
26691
|
-
|
|
26692
|
-
$[18] = t;
|
|
26693
|
-
$[19] = t7;
|
|
26694
|
-
} else {
|
|
26695
|
-
t7 = $[19];
|
|
26696
|
-
}
|
|
26697
|
-
let t8;
|
|
26698
|
-
if ($[20] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
26699
|
-
t8 = (e_0) => {
|
|
26700
|
-
setSearchString(e_0.target.value);
|
|
26701
|
-
};
|
|
26702
|
-
$[20] = t8;
|
|
26703
|
-
} else {
|
|
26704
|
-
t8 = $[20];
|
|
26705
|
-
}
|
|
26706
|
-
let t9;
|
|
26707
|
-
if ($[21] !== openPopup || $[22] !== searchString || $[23] !== t7) {
|
|
26708
|
-
t9 = /* @__PURE__ */ jsxRuntime.jsx("input", { autoFocus: openPopup, placeholder: t7, onChange: t8, value: searchString, className: "rounded-lg bg-white dark:bg-surface-800 flex-grow bg-transparent outline-none p-2 " + ui.focusedDisabled });
|
|
26709
|
-
$[21] = openPopup;
|
|
26710
|
-
$[22] = searchString;
|
|
26711
|
-
$[23] = t7;
|
|
26712
|
-
$[24] = t9;
|
|
26713
|
-
} else {
|
|
26714
|
-
t9 = $[24];
|
|
26715
|
-
}
|
|
26716
|
-
const t10 = !searchString.trim();
|
|
26717
|
-
let t11;
|
|
26718
|
-
if ($[25] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
26719
|
-
t11 = /* @__PURE__ */ jsxRuntime.jsx(ui.KeyboardTabIcon, {});
|
|
26720
|
-
$[25] = t11;
|
|
26721
|
-
} else {
|
|
26722
|
-
t11 = $[25];
|
|
26723
|
-
}
|
|
26724
|
-
let t12;
|
|
26725
|
-
if ($[26] !== t10) {
|
|
26726
|
-
t12 = /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "text", disabled: t10, type: "submit", children: t11 });
|
|
26727
|
-
$[26] = t10;
|
|
26728
|
-
$[27] = t12;
|
|
26729
|
-
} else {
|
|
26730
|
-
t12 = $[27];
|
|
26731
|
-
}
|
|
26732
|
-
let t13;
|
|
26733
|
-
if ($[28] !== t12 || $[29] !== t9) {
|
|
26734
|
-
t13 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex p-2 w-full gap-2", children: [
|
|
26735
|
-
t9,
|
|
26736
|
-
t12
|
|
26737
|
-
] });
|
|
26738
|
-
$[28] = t12;
|
|
26739
|
-
$[29] = t9;
|
|
26740
|
-
$[30] = t13;
|
|
26741
|
-
} else {
|
|
26742
|
-
t13 = $[30];
|
|
26743
|
-
}
|
|
26744
|
-
let t14;
|
|
26745
|
-
if ($[31] !== t13 || $[32] !== t6) {
|
|
26746
|
-
t14 = /* @__PURE__ */ jsxRuntime.jsx("form", { noValidate: true, onSubmit: t6, className: "w-96 max-w-full", children: t13 });
|
|
26747
|
-
$[31] = t13;
|
|
26748
|
-
$[32] = t6;
|
|
26749
|
-
$[33] = t14;
|
|
26750
|
-
} else {
|
|
26751
|
-
t14 = $[33];
|
|
26752
|
-
}
|
|
26753
|
-
let t15;
|
|
26754
|
-
if ($[34] !== collection || $[35] !== fullIdPath || $[36] !== navigation || $[37] !== openEntityMode || $[38] !== path || $[39] !== pathSegments || $[40] !== recentIds || $[41] !== sideEntityController) {
|
|
26755
|
-
t15 = recentIds && recentIds.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2 p-2", children: recentIds.map((id) => /* @__PURE__ */ jsxRuntime.jsx(ReferencePreview, { reference: new EntityReference(id, path, void 0, pathSegments), hover: true, onClick: () => {
|
|
26667
|
+
}, className: "w-96 max-w-full", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex p-2 w-full gap-2", children: [
|
|
26668
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
26669
|
+
"input",
|
|
26670
|
+
{
|
|
26671
|
+
autoFocus: openPopup,
|
|
26672
|
+
placeholder: t("find_entity_by_id"),
|
|
26673
|
+
onChange: (e_1) => {
|
|
26674
|
+
setSearchString(e_1.target.value);
|
|
26675
|
+
},
|
|
26676
|
+
value: searchString,
|
|
26677
|
+
className: "rounded-lg bg-white dark:bg-surface-800 flex-grow bg-transparent outline-none p-2 " + ui.focusedDisabled
|
|
26678
|
+
}
|
|
26679
|
+
),
|
|
26680
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "text", disabled: !searchString.trim(), type: "submit", children: /* @__PURE__ */ jsxRuntime.jsx(ui.KeyboardTabIcon, {}) })
|
|
26681
|
+
] }) }),
|
|
26682
|
+
recentIds && recentIds.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2 p-2", children: recentIds.map((id) => /* @__PURE__ */ jsxRuntime.jsx(ReferencePreview, { reference: new EntityReference(id, path, void 0, pathSegments), hover: true, onClick: () => {
|
|
26756
26683
|
setOpenPopup(false);
|
|
26757
26684
|
navigateToEntity({
|
|
26758
26685
|
openEntityMode,
|
|
@@ -26764,51 +26691,8 @@
|
|
|
26764
26691
|
sideEntityController,
|
|
26765
26692
|
navigation
|
|
26766
26693
|
});
|
|
26767
|
-
}, includeEntityLink: false, size: "small" }, id)) })
|
|
26768
|
-
|
|
26769
|
-
$[35] = fullIdPath;
|
|
26770
|
-
$[36] = navigation;
|
|
26771
|
-
$[37] = openEntityMode;
|
|
26772
|
-
$[38] = path;
|
|
26773
|
-
$[39] = pathSegments;
|
|
26774
|
-
$[40] = recentIds;
|
|
26775
|
-
$[41] = sideEntityController;
|
|
26776
|
-
$[42] = t15;
|
|
26777
|
-
} else {
|
|
26778
|
-
t15 = $[42];
|
|
26779
|
-
}
|
|
26780
|
-
let t16;
|
|
26781
|
-
if ($[43] !== t14 || $[44] !== t15) {
|
|
26782
|
-
t16 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t5, children: [
|
|
26783
|
-
t14,
|
|
26784
|
-
t15
|
|
26785
|
-
] });
|
|
26786
|
-
$[43] = t14;
|
|
26787
|
-
$[44] = t15;
|
|
26788
|
-
$[45] = t16;
|
|
26789
|
-
} else {
|
|
26790
|
-
t16 = $[45];
|
|
26791
|
-
}
|
|
26792
|
-
let t17;
|
|
26793
|
-
if ($[46] !== openPopup || $[47] !== t16 || $[48] !== t3) {
|
|
26794
|
-
t17 = /* @__PURE__ */ jsxRuntime.jsx(ui.Popover, { open: openPopup, onOpenChange: t3, sideOffset: 0, align: "start", alignOffset: -117, trigger: t4, children: t16 });
|
|
26795
|
-
$[46] = openPopup;
|
|
26796
|
-
$[47] = t16;
|
|
26797
|
-
$[48] = t3;
|
|
26798
|
-
$[49] = t17;
|
|
26799
|
-
} else {
|
|
26800
|
-
t17 = $[49];
|
|
26801
|
-
}
|
|
26802
|
-
let t18;
|
|
26803
|
-
if ($[50] !== t17 || $[51] !== t2) {
|
|
26804
|
-
t18 = /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: t2, asChild: false, children: t17 });
|
|
26805
|
-
$[50] = t17;
|
|
26806
|
-
$[51] = t2;
|
|
26807
|
-
$[52] = t18;
|
|
26808
|
-
} else {
|
|
26809
|
-
t18 = $[52];
|
|
26810
|
-
}
|
|
26811
|
-
return t18;
|
|
26694
|
+
}, includeEntityLink: false, size: "small" }, id)) })
|
|
26695
|
+
] }) }) });
|
|
26812
26696
|
}
|
|
26813
26697
|
const collectionScrollCache = /* @__PURE__ */ new Map();
|
|
26814
26698
|
function useScrollRestoration() {
|