@tutti-os/workspace-file-reference 0.0.57 → 0.0.58
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/ui/index.js +77 -18
- package/dist/ui/index.js.map +1 -1
- package/package.json +5 -5
package/dist/ui/index.js
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
DialogTitle,
|
|
21
21
|
cn as cn2
|
|
22
22
|
} from "@tutti-os/ui-system";
|
|
23
|
+
import { useEffect as useEffect2 } from "react";
|
|
23
24
|
|
|
24
25
|
// src/ui/internal/reference/WorkspaceFileReferencePickerSections.tsx
|
|
25
26
|
import { useId, useState as useState2 } from "react";
|
|
@@ -635,6 +636,28 @@ function WorkspaceFileReferencePicker({
|
|
|
635
636
|
open,
|
|
636
637
|
workspaceId
|
|
637
638
|
});
|
|
639
|
+
useEffect2(() => {
|
|
640
|
+
if (!open) {
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
const handleEscapeKeyDown = (event) => {
|
|
644
|
+
if (event.key !== "Escape") {
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
647
|
+
event.preventDefault();
|
|
648
|
+
event.stopPropagation();
|
|
649
|
+
event.stopImmediatePropagation();
|
|
650
|
+
onClose();
|
|
651
|
+
};
|
|
652
|
+
document.addEventListener("keydown", handleEscapeKeyDown, {
|
|
653
|
+
capture: true
|
|
654
|
+
});
|
|
655
|
+
return () => {
|
|
656
|
+
document.removeEventListener("keydown", handleEscapeKeyDown, {
|
|
657
|
+
capture: true
|
|
658
|
+
});
|
|
659
|
+
};
|
|
660
|
+
}, [onClose, open]);
|
|
638
661
|
return /* @__PURE__ */ jsx3(
|
|
639
662
|
Dialog,
|
|
640
663
|
{
|
|
@@ -651,6 +674,11 @@ function WorkspaceFileReferencePicker({
|
|
|
651
674
|
className: cn2(
|
|
652
675
|
"nodrag flex h-[min(88vh,44rem)] w-full max-w-5xl flex-col gap-0 overflow-hidden border-[var(--line-1)] bg-[var(--background-fronted)] p-0 text-[var(--text-primary)] shadow-panel [-webkit-app-region:no-drag] sm:h-[min(82vh,44rem)] sm:max-w-5xl"
|
|
653
676
|
),
|
|
677
|
+
onEscapeKeyDown: (event) => {
|
|
678
|
+
event.preventDefault();
|
|
679
|
+
event.stopPropagation();
|
|
680
|
+
onClose();
|
|
681
|
+
},
|
|
654
682
|
overlayClassName: cn2("nodrag", scoped && "!absolute"),
|
|
655
683
|
portaled: !scoped,
|
|
656
684
|
children: [
|
|
@@ -703,7 +731,7 @@ function WorkspaceFileReferencePicker({
|
|
|
703
731
|
|
|
704
732
|
// src/ui/internal/reference/ReferenceSourcePicker.tsx
|
|
705
733
|
import {
|
|
706
|
-
useEffect as
|
|
734
|
+
useEffect as useEffect4,
|
|
707
735
|
useId as useId2,
|
|
708
736
|
useMemo as useMemo2,
|
|
709
737
|
useRef as useRef2,
|
|
@@ -748,7 +776,7 @@ import {
|
|
|
748
776
|
} from "@tutti-os/workspace-file-manager";
|
|
749
777
|
|
|
750
778
|
// src/react/internal/reference/useReferenceSourcePickerView.ts
|
|
751
|
-
import { useCallback, useEffect as
|
|
779
|
+
import { useCallback, useEffect as useEffect3, useMemo, useRef, useState as useState3 } from "react";
|
|
752
780
|
import { useSnapshot } from "valtio";
|
|
753
781
|
import {
|
|
754
782
|
resolveWorkspaceFileOpenWithCacheKey,
|
|
@@ -813,7 +841,7 @@ function useReferenceSourcePickerView({
|
|
|
813
841
|
);
|
|
814
842
|
const autoEnteredSourcesRef = useRef(/* @__PURE__ */ new Set());
|
|
815
843
|
const appliedInitialTargetRef = useRef(null);
|
|
816
|
-
|
|
844
|
+
useEffect3(() => {
|
|
817
845
|
if (!open) {
|
|
818
846
|
return;
|
|
819
847
|
}
|
|
@@ -827,7 +855,7 @@ function useReferenceSourcePickerView({
|
|
|
827
855
|
controller.close();
|
|
828
856
|
};
|
|
829
857
|
}, [controller, open]);
|
|
830
|
-
|
|
858
|
+
useEffect3(() => {
|
|
831
859
|
const target = initialTarget;
|
|
832
860
|
if (!open || !target || appliedInitialTargetRef.current === target) {
|
|
833
861
|
return;
|
|
@@ -944,7 +972,7 @@ function useReferenceSourcePickerView({
|
|
|
944
972
|
sourceId: activeSourceId,
|
|
945
973
|
nodeId: WORKSPACE_ROOT_GROUP_NODE_ID
|
|
946
974
|
}) : null;
|
|
947
|
-
|
|
975
|
+
useEffect3(() => {
|
|
948
976
|
controller.setSearchScope(searchScopeNodeId);
|
|
949
977
|
}, [controller, searchScopeNodeId]);
|
|
950
978
|
const setActiveSource = useCallback(
|
|
@@ -981,7 +1009,7 @@ function useReferenceSourcePickerView({
|
|
|
981
1009
|
},
|
|
982
1010
|
[controller, shouldRefreshChildrenOnEnter]
|
|
983
1011
|
);
|
|
984
|
-
|
|
1012
|
+
useEffect3(() => {
|
|
985
1013
|
if (!open || !activeSourceId) {
|
|
986
1014
|
return;
|
|
987
1015
|
}
|
|
@@ -1000,7 +1028,7 @@ function useReferenceSourcePickerView({
|
|
|
1000
1028
|
autoEnteredSourcesRef.current.add(activeSourceId);
|
|
1001
1029
|
enterFolder(firstGroup);
|
|
1002
1030
|
}, [open, activeSourceId, sidebarGroups, breadcrumbBySource, enterFolder]);
|
|
1003
|
-
|
|
1031
|
+
useEffect3(() => {
|
|
1004
1032
|
if (!open) {
|
|
1005
1033
|
return;
|
|
1006
1034
|
}
|
|
@@ -1155,7 +1183,7 @@ function useReferenceSourcePickerView({
|
|
|
1155
1183
|
previewObjectUrlRef.current = null;
|
|
1156
1184
|
}
|
|
1157
1185
|
}, []);
|
|
1158
|
-
|
|
1186
|
+
useEffect3(() => {
|
|
1159
1187
|
const node = focusedNode;
|
|
1160
1188
|
if (!node) {
|
|
1161
1189
|
revokePreviewObjectUrl();
|
|
@@ -1271,7 +1299,7 @@ function useReferenceSourcePickerView({
|
|
|
1271
1299
|
cancelled = true;
|
|
1272
1300
|
};
|
|
1273
1301
|
}, [aggregator, focusedNode, revokePreviewObjectUrl, scope]);
|
|
1274
|
-
|
|
1302
|
+
useEffect3(() => revokePreviewObjectUrl, [revokePreviewObjectUrl]);
|
|
1275
1303
|
return {
|
|
1276
1304
|
tabs: snapshot.tabs,
|
|
1277
1305
|
activeSourceId,
|
|
@@ -1518,6 +1546,28 @@ function ReferenceSourcePicker({
|
|
|
1518
1546
|
onCommit: view.setSearchQuery,
|
|
1519
1547
|
value: view.searchQuery
|
|
1520
1548
|
});
|
|
1549
|
+
useEffect4(() => {
|
|
1550
|
+
if (!open) {
|
|
1551
|
+
return;
|
|
1552
|
+
}
|
|
1553
|
+
const handleEscapeKeyDown = (event) => {
|
|
1554
|
+
if (event.key !== "Escape") {
|
|
1555
|
+
return;
|
|
1556
|
+
}
|
|
1557
|
+
event.preventDefault();
|
|
1558
|
+
event.stopPropagation();
|
|
1559
|
+
event.stopImmediatePropagation();
|
|
1560
|
+
onClose();
|
|
1561
|
+
};
|
|
1562
|
+
document.addEventListener("keydown", handleEscapeKeyDown, {
|
|
1563
|
+
capture: true
|
|
1564
|
+
});
|
|
1565
|
+
return () => {
|
|
1566
|
+
document.removeEventListener("keydown", handleEscapeKeyDown, {
|
|
1567
|
+
capture: true
|
|
1568
|
+
});
|
|
1569
|
+
};
|
|
1570
|
+
}, [onClose, open]);
|
|
1521
1571
|
const layoutRef = useRef2(null);
|
|
1522
1572
|
const menuBoundaryRef = useRef2(null);
|
|
1523
1573
|
const contextMenuRef = useRef2(null);
|
|
@@ -1553,7 +1603,7 @@ function ReferenceSourcePicker({
|
|
|
1553
1603
|
includeImageThumbnails: resolveEntryIconUrl !== void 0,
|
|
1554
1604
|
resolveEntryIconUrl
|
|
1555
1605
|
});
|
|
1556
|
-
|
|
1606
|
+
useEffect4(() => {
|
|
1557
1607
|
if (!contextMenu || !fileManagerCopy) {
|
|
1558
1608
|
setOpenWithApplications([]);
|
|
1559
1609
|
setOpenWithLoading(false);
|
|
@@ -1587,7 +1637,7 @@ function ReferenceSourcePicker({
|
|
|
1587
1637
|
cancelled = true;
|
|
1588
1638
|
};
|
|
1589
1639
|
}, [contextMenu?.node, fileManagerCopy]);
|
|
1590
|
-
|
|
1640
|
+
useEffect4(() => {
|
|
1591
1641
|
if (!contextMenu) {
|
|
1592
1642
|
return;
|
|
1593
1643
|
}
|
|
@@ -1642,12 +1692,21 @@ function ReferenceSourcePicker({
|
|
|
1642
1692
|
middlePanelRef.current,
|
|
1643
1693
|
56
|
|
1644
1694
|
);
|
|
1695
|
+
const handleReferencePickerKeyDownCapture = (event) => {
|
|
1696
|
+
if (event.key !== "Escape") {
|
|
1697
|
+
return;
|
|
1698
|
+
}
|
|
1699
|
+
event.preventDefault();
|
|
1700
|
+
event.stopPropagation();
|
|
1701
|
+
onClose();
|
|
1702
|
+
};
|
|
1645
1703
|
const dialog = /* @__PURE__ */ jsx4(
|
|
1646
1704
|
"div",
|
|
1647
1705
|
{
|
|
1648
1706
|
className: "nodrag fixed inset-0 grid place-items-center bg-[var(--backdrop)] px-3 py-4 backdrop-blur-md [-webkit-app-region:no-drag] sm:px-6 sm:py-8",
|
|
1649
1707
|
style: { zIndex: "var(--z-panel)" },
|
|
1650
1708
|
onClick: onClose,
|
|
1709
|
+
onKeyDownCapture: handleReferencePickerKeyDownCapture,
|
|
1651
1710
|
children: /* @__PURE__ */ jsxs4(
|
|
1652
1711
|
Card,
|
|
1653
1712
|
{
|
|
@@ -1990,7 +2049,7 @@ function ReferenceSourceContentPane({
|
|
|
1990
2049
|
onClose: noopVoid,
|
|
1991
2050
|
onConfirm: noopVoid
|
|
1992
2051
|
});
|
|
1993
|
-
|
|
2052
|
+
useEffect4(() => {
|
|
1994
2053
|
if (!initialNodeRef) {
|
|
1995
2054
|
return;
|
|
1996
2055
|
}
|
|
@@ -2054,7 +2113,7 @@ function ReferenceSourceContentPane({
|
|
|
2054
2113
|
includeImageThumbnails: resolveEntryIconUrl !== void 0,
|
|
2055
2114
|
resolveEntryIconUrl
|
|
2056
2115
|
});
|
|
2057
|
-
|
|
2116
|
+
useEffect4(() => {
|
|
2058
2117
|
if (!contextMenu || !fileManagerCopy) {
|
|
2059
2118
|
setOpenWithApplications([]);
|
|
2060
2119
|
setOpenWithLoading(false);
|
|
@@ -2088,7 +2147,7 @@ function ReferenceSourceContentPane({
|
|
|
2088
2147
|
cancelled = true;
|
|
2089
2148
|
};
|
|
2090
2149
|
}, [contextMenu?.node, fileManagerCopy]);
|
|
2091
|
-
|
|
2150
|
+
useEffect4(() => {
|
|
2092
2151
|
if (!contextMenu) {
|
|
2093
2152
|
return;
|
|
2094
2153
|
}
|
|
@@ -2332,7 +2391,7 @@ function SourceSidebar({
|
|
|
2332
2391
|
contentRef
|
|
2333
2392
|
}) {
|
|
2334
2393
|
const selectedGroupRef = useRef2(null);
|
|
2335
|
-
|
|
2394
|
+
useEffect4(() => {
|
|
2336
2395
|
selectedGroupRef.current?.scrollIntoView({ block: "nearest" });
|
|
2337
2396
|
}, [view.selectedGroupKey]);
|
|
2338
2397
|
const [shownBySource, setShownBySource] = useState4(
|
|
@@ -2791,7 +2850,7 @@ function FilterCategoryFilter({
|
|
|
2791
2850
|
}) {
|
|
2792
2851
|
const [open, setOpen] = useState4(false);
|
|
2793
2852
|
const containerRef = useRef2(null);
|
|
2794
|
-
|
|
2853
|
+
useEffect4(() => {
|
|
2795
2854
|
if (!open) {
|
|
2796
2855
|
return;
|
|
2797
2856
|
}
|
|
@@ -2912,12 +2971,12 @@ function TreeNodeRow({
|
|
|
2912
2971
|
const active = selected || focused && selectable;
|
|
2913
2972
|
const focusedRowRef = useRef2(null);
|
|
2914
2973
|
const [shouldRenderChildContent, setShouldRenderChildContent] = useState4(expanded);
|
|
2915
|
-
|
|
2974
|
+
useEffect4(() => {
|
|
2916
2975
|
if (focused) {
|
|
2917
2976
|
focusedRowRef.current?.scrollIntoView({ block: "nearest" });
|
|
2918
2977
|
}
|
|
2919
2978
|
}, [focused]);
|
|
2920
|
-
|
|
2979
|
+
useEffect4(() => {
|
|
2921
2980
|
if (expanded) {
|
|
2922
2981
|
setShouldRenderChildContent(true);
|
|
2923
2982
|
return;
|