ptechcore_ui 1.0.23 → 1.0.25
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.cjs +1122 -4
- package/dist/index.d.cts +110 -1
- package/dist/index.d.ts +110 -1
- package/dist/index.js +1128 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -712,7 +712,7 @@ import { createContext as createContext2, useContext as useContext2, useEffect a
|
|
|
712
712
|
|
|
713
713
|
// src/services/api.ts
|
|
714
714
|
var chooseEnv = localStorage.getItem("env") ?? "prod";
|
|
715
|
-
var ADDRESS_IP = chooseEnv === "prod" ? "
|
|
715
|
+
var ADDRESS_IP = chooseEnv === "prod" ? "backend-core.rewise.praedium-tech.com" : "localhost:8000";
|
|
716
716
|
var ADDRESS_IP_URL = chooseEnv === "prod" ? `https://${ADDRESS_IP}/` : `http://${ADDRESS_IP}/`;
|
|
717
717
|
var API_URL = `${ADDRESS_IP_URL}api`;
|
|
718
718
|
var FetchApi = class {
|
|
@@ -1661,13 +1661,13 @@ var MODULE_URLS = {
|
|
|
1661
1661
|
wiseAsset: "#",
|
|
1662
1662
|
wiseCash: "https://rewise.praedium-tech.com/admin/finance/dashboard/",
|
|
1663
1663
|
wiseCollect: "https://rewise.praedium-tech.com/admin/recovery/collection/dashboard/",
|
|
1664
|
-
wiseProcure: "https://
|
|
1664
|
+
wiseProcure: "https://wiseprocure.praedium-tech.com/",
|
|
1665
1665
|
wiseHR: "https://rewise.praedium-tech.com/admin/human-capital/dashboard/"
|
|
1666
1666
|
},
|
|
1667
1667
|
development: {
|
|
1668
1668
|
wiseConnect: "http://localhost:5173/admin/crm/trade-strategy/lead-insight/",
|
|
1669
1669
|
wiseReach: "http://localhost:5173/admin/marketing/dashboard/",
|
|
1670
|
-
wiseOps: "http://localhost:
|
|
1670
|
+
wiseOps: "http://localhost:5173/",
|
|
1671
1671
|
wiseGuard: "http://localhost:5173/admin/security/dashboard/",
|
|
1672
1672
|
wiseThrive: "http://localhost:5173/admin/thrive/scorecard/dashboard/financial/",
|
|
1673
1673
|
wiseView: "http://localhost:5175/",
|
|
@@ -1686,7 +1686,8 @@ var getModuleUrls = (token) => {
|
|
|
1686
1686
|
const urls = env === "localhost" ? MODULE_URLS.development : MODULE_URLS.production;
|
|
1687
1687
|
return {
|
|
1688
1688
|
...urls,
|
|
1689
|
-
wiseOps: token ? `${urls.wiseOps}?tkn=${token}` : urls.wiseOps
|
|
1689
|
+
wiseOps: token ? `${urls.wiseOps}?tkn=${token}` : urls.wiseOps,
|
|
1690
|
+
wiseProcure: token ? `${urls.wiseProcure}?tkn=${token}` : urls.wiseProcure
|
|
1690
1691
|
};
|
|
1691
1692
|
};
|
|
1692
1693
|
var MODULE_CODE_MAP = {
|
|
@@ -6603,6 +6604,1123 @@ var CountrySelector = ({
|
|
|
6603
6604
|
`country-${value}`
|
|
6604
6605
|
);
|
|
6605
6606
|
};
|
|
6607
|
+
|
|
6608
|
+
// src/components/common/FileManager/FileManager.tsx
|
|
6609
|
+
import { useState as useState18 } from "react";
|
|
6610
|
+
import { Menu as Menu3, X as X9 } from "lucide-react";
|
|
6611
|
+
|
|
6612
|
+
// src/components/common/FileManager/FileManagerContext.tsx
|
|
6613
|
+
import { createContext as createContext5, useContext as useContext5, useState as useState14, useCallback as useCallback3, useMemo } from "react";
|
|
6614
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
6615
|
+
var defaultTexts = {
|
|
6616
|
+
createFolder: "Cr\xE9er un dossier",
|
|
6617
|
+
uploadFiles: "Uploader des fichiers",
|
|
6618
|
+
rename: "Renommer",
|
|
6619
|
+
delete: "Supprimer",
|
|
6620
|
+
download: "T\xE9l\xE9charger",
|
|
6621
|
+
open: "Ouvrir",
|
|
6622
|
+
deselectAll: "Tout d\xE9s\xE9lectionner",
|
|
6623
|
+
newFolderName: "Nom du dossier",
|
|
6624
|
+
confirmDelete: "Voulez-vous vraiment supprimer",
|
|
6625
|
+
noFiles: "Aucun fichier",
|
|
6626
|
+
dropFilesHere: "D\xE9posez vos fichiers ici",
|
|
6627
|
+
cancel: "Annuler",
|
|
6628
|
+
confirm: "Confirmer"
|
|
6629
|
+
};
|
|
6630
|
+
var FileManagerContext = createContext5(null);
|
|
6631
|
+
var useFileManager = () => {
|
|
6632
|
+
const context = useContext5(FileManagerContext);
|
|
6633
|
+
if (!context) {
|
|
6634
|
+
throw new Error("useFileManager must be used within a FileManagerProvider");
|
|
6635
|
+
}
|
|
6636
|
+
return context;
|
|
6637
|
+
};
|
|
6638
|
+
var FileManagerProvider = ({
|
|
6639
|
+
children,
|
|
6640
|
+
data,
|
|
6641
|
+
rootName = "Fichiers",
|
|
6642
|
+
viewMode: initialViewMode = "grid",
|
|
6643
|
+
allowMultiSelect = true,
|
|
6644
|
+
allowUpload = true,
|
|
6645
|
+
allowCreateFolder = true,
|
|
6646
|
+
allowRename = true,
|
|
6647
|
+
allowDelete = true,
|
|
6648
|
+
allowDownload = true,
|
|
6649
|
+
texts: customTexts = {},
|
|
6650
|
+
onCreateFolder,
|
|
6651
|
+
onUploadFiles,
|
|
6652
|
+
onRename,
|
|
6653
|
+
onDelete,
|
|
6654
|
+
onDownload,
|
|
6655
|
+
onOpen,
|
|
6656
|
+
onSelect
|
|
6657
|
+
}) => {
|
|
6658
|
+
const rootFolder = useMemo(
|
|
6659
|
+
() => ({
|
|
6660
|
+
id: "__root__",
|
|
6661
|
+
name: rootName,
|
|
6662
|
+
type: "folder",
|
|
6663
|
+
path: "/",
|
|
6664
|
+
children: data
|
|
6665
|
+
}),
|
|
6666
|
+
[data, rootName]
|
|
6667
|
+
);
|
|
6668
|
+
const [currentFolder, setCurrentFolder] = useState14(rootFolder);
|
|
6669
|
+
const [pathHistory, setPathHistory] = useState14([rootFolder]);
|
|
6670
|
+
const [selectedItems, setSelectedItems] = useState14([]);
|
|
6671
|
+
const [viewMode, setViewMode] = useState14(initialViewMode);
|
|
6672
|
+
const [renamingItem, setRenamingItem] = useState14(null);
|
|
6673
|
+
const [contextMenu, setContextMenu] = useState14({
|
|
6674
|
+
visible: false,
|
|
6675
|
+
position: { x: 0, y: 0 },
|
|
6676
|
+
item: null
|
|
6677
|
+
});
|
|
6678
|
+
const texts = useMemo(() => ({ ...defaultTexts, ...customTexts }), [customTexts]);
|
|
6679
|
+
const currentFolderContents = useMemo(() => {
|
|
6680
|
+
return currentFolder?.children || [];
|
|
6681
|
+
}, [currentFolder]);
|
|
6682
|
+
const navigateToFolder = useCallback3(
|
|
6683
|
+
(folder) => {
|
|
6684
|
+
if (!folder) {
|
|
6685
|
+
setCurrentFolder(rootFolder);
|
|
6686
|
+
setPathHistory([rootFolder]);
|
|
6687
|
+
} else {
|
|
6688
|
+
setCurrentFolder(folder);
|
|
6689
|
+
setPathHistory((prev) => [...prev, folder]);
|
|
6690
|
+
}
|
|
6691
|
+
setSelectedItems([]);
|
|
6692
|
+
setContextMenu({ visible: false, position: { x: 0, y: 0 }, item: null });
|
|
6693
|
+
},
|
|
6694
|
+
[rootFolder]
|
|
6695
|
+
);
|
|
6696
|
+
const navigateBack = useCallback3(() => {
|
|
6697
|
+
if (pathHistory.length > 1) {
|
|
6698
|
+
const newHistory = [...pathHistory];
|
|
6699
|
+
newHistory.pop();
|
|
6700
|
+
const previousFolder = newHistory[newHistory.length - 1];
|
|
6701
|
+
setCurrentFolder(previousFolder);
|
|
6702
|
+
setPathHistory(newHistory);
|
|
6703
|
+
setSelectedItems([]);
|
|
6704
|
+
}
|
|
6705
|
+
}, [pathHistory]);
|
|
6706
|
+
const navigateToPath = useCallback3(
|
|
6707
|
+
(index) => {
|
|
6708
|
+
if (index < pathHistory.length - 1) {
|
|
6709
|
+
const newHistory = pathHistory.slice(0, index + 1);
|
|
6710
|
+
setCurrentFolder(newHistory[newHistory.length - 1]);
|
|
6711
|
+
setPathHistory(newHistory);
|
|
6712
|
+
setSelectedItems([]);
|
|
6713
|
+
}
|
|
6714
|
+
},
|
|
6715
|
+
[pathHistory]
|
|
6716
|
+
);
|
|
6717
|
+
const selectItem = useCallback3(
|
|
6718
|
+
(item, multiSelect = false) => {
|
|
6719
|
+
setSelectedItems((prev) => {
|
|
6720
|
+
if (multiSelect && allowMultiSelect) {
|
|
6721
|
+
const isSelected = prev.some((i) => i.id === item.id);
|
|
6722
|
+
if (isSelected) {
|
|
6723
|
+
return prev.filter((i) => i.id !== item.id);
|
|
6724
|
+
}
|
|
6725
|
+
return [...prev, item];
|
|
6726
|
+
}
|
|
6727
|
+
return [item];
|
|
6728
|
+
});
|
|
6729
|
+
if (onSelect) {
|
|
6730
|
+
const newSelection = allowMultiSelect && multiSelect ? selectedItems.some((i) => i.id === item.id) ? selectedItems.filter((i) => i.id !== item.id) : [...selectedItems, item] : [item];
|
|
6731
|
+
onSelect(newSelection);
|
|
6732
|
+
}
|
|
6733
|
+
},
|
|
6734
|
+
[allowMultiSelect, onSelect, selectedItems]
|
|
6735
|
+
);
|
|
6736
|
+
const deselectAll = useCallback3(() => {
|
|
6737
|
+
setSelectedItems([]);
|
|
6738
|
+
if (onSelect) {
|
|
6739
|
+
onSelect([]);
|
|
6740
|
+
}
|
|
6741
|
+
}, [onSelect]);
|
|
6742
|
+
const showContextMenu = useCallback3((item, position) => {
|
|
6743
|
+
setContextMenu({
|
|
6744
|
+
visible: true,
|
|
6745
|
+
position,
|
|
6746
|
+
item
|
|
6747
|
+
});
|
|
6748
|
+
}, []);
|
|
6749
|
+
const hideContextMenu = useCallback3(() => {
|
|
6750
|
+
setContextMenu((prev) => ({ ...prev, visible: false }));
|
|
6751
|
+
}, []);
|
|
6752
|
+
const startRenaming = useCallback3((item) => {
|
|
6753
|
+
setRenamingItem(item);
|
|
6754
|
+
hideContextMenu();
|
|
6755
|
+
}, [hideContextMenu]);
|
|
6756
|
+
const stopRenaming = useCallback3(() => {
|
|
6757
|
+
setRenamingItem(null);
|
|
6758
|
+
}, []);
|
|
6759
|
+
const contextValue = useMemo(
|
|
6760
|
+
() => ({
|
|
6761
|
+
data,
|
|
6762
|
+
currentFolder,
|
|
6763
|
+
currentFolderContents,
|
|
6764
|
+
pathHistory,
|
|
6765
|
+
selectedItems,
|
|
6766
|
+
viewMode,
|
|
6767
|
+
contextMenu,
|
|
6768
|
+
renamingItem,
|
|
6769
|
+
navigateToFolder,
|
|
6770
|
+
navigateBack,
|
|
6771
|
+
navigateToPath,
|
|
6772
|
+
selectItem,
|
|
6773
|
+
deselectAll,
|
|
6774
|
+
setViewMode,
|
|
6775
|
+
showContextMenu,
|
|
6776
|
+
hideContextMenu,
|
|
6777
|
+
startRenaming,
|
|
6778
|
+
stopRenaming,
|
|
6779
|
+
onCreateFolder,
|
|
6780
|
+
onUploadFiles,
|
|
6781
|
+
onRename,
|
|
6782
|
+
onDelete,
|
|
6783
|
+
onDownload,
|
|
6784
|
+
onOpen,
|
|
6785
|
+
allowUpload,
|
|
6786
|
+
allowCreateFolder,
|
|
6787
|
+
allowRename,
|
|
6788
|
+
allowDelete,
|
|
6789
|
+
allowDownload,
|
|
6790
|
+
allowMultiSelect,
|
|
6791
|
+
texts
|
|
6792
|
+
}),
|
|
6793
|
+
[
|
|
6794
|
+
data,
|
|
6795
|
+
currentFolder,
|
|
6796
|
+
currentFolderContents,
|
|
6797
|
+
pathHistory,
|
|
6798
|
+
selectedItems,
|
|
6799
|
+
viewMode,
|
|
6800
|
+
contextMenu,
|
|
6801
|
+
renamingItem,
|
|
6802
|
+
navigateToFolder,
|
|
6803
|
+
navigateBack,
|
|
6804
|
+
navigateToPath,
|
|
6805
|
+
selectItem,
|
|
6806
|
+
deselectAll,
|
|
6807
|
+
showContextMenu,
|
|
6808
|
+
hideContextMenu,
|
|
6809
|
+
startRenaming,
|
|
6810
|
+
stopRenaming,
|
|
6811
|
+
onCreateFolder,
|
|
6812
|
+
onUploadFiles,
|
|
6813
|
+
onRename,
|
|
6814
|
+
onDelete,
|
|
6815
|
+
onDownload,
|
|
6816
|
+
onOpen,
|
|
6817
|
+
allowUpload,
|
|
6818
|
+
allowCreateFolder,
|
|
6819
|
+
allowRename,
|
|
6820
|
+
allowDelete,
|
|
6821
|
+
allowDownload,
|
|
6822
|
+
allowMultiSelect,
|
|
6823
|
+
texts
|
|
6824
|
+
]
|
|
6825
|
+
);
|
|
6826
|
+
return /* @__PURE__ */ jsx20(FileManagerContext.Provider, { value: contextValue, children });
|
|
6827
|
+
};
|
|
6828
|
+
|
|
6829
|
+
// src/components/common/FileManager/components/FolderTree.tsx
|
|
6830
|
+
import { useState as useState15 } from "react";
|
|
6831
|
+
import { ChevronRight as ChevronRight2, ChevronDown as ChevronDown3, Folder, FolderOpen } from "lucide-react";
|
|
6832
|
+
import { jsx as jsx21, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
6833
|
+
var FolderTreeItem = ({ item, level }) => {
|
|
6834
|
+
const { currentFolder, navigateToFolder, pathHistory } = useFileManager();
|
|
6835
|
+
const [isExpanded, setIsExpanded] = useState15(
|
|
6836
|
+
pathHistory.some((f) => f.id === item.id) || level === 0
|
|
6837
|
+
);
|
|
6838
|
+
const isSelected = currentFolder?.id === item.id;
|
|
6839
|
+
const hasChildren = item.children?.some((child) => child.type === "folder");
|
|
6840
|
+
const folderChildren = item.children?.filter((child) => child.type === "folder") || [];
|
|
6841
|
+
const handleToggle = (e) => {
|
|
6842
|
+
e.stopPropagation();
|
|
6843
|
+
setIsExpanded(!isExpanded);
|
|
6844
|
+
};
|
|
6845
|
+
const handleClick = () => {
|
|
6846
|
+
navigateToFolder(item);
|
|
6847
|
+
if (!isExpanded) {
|
|
6848
|
+
setIsExpanded(true);
|
|
6849
|
+
}
|
|
6850
|
+
};
|
|
6851
|
+
return /* @__PURE__ */ jsxs16("div", { children: [
|
|
6852
|
+
/* @__PURE__ */ jsxs16(
|
|
6853
|
+
"div",
|
|
6854
|
+
{
|
|
6855
|
+
className: cn(
|
|
6856
|
+
"flex items-center gap-1 py-1.5 px-2 rounded-lg cursor-pointer transition-colors",
|
|
6857
|
+
"hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
6858
|
+
isSelected && "bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300"
|
|
6859
|
+
),
|
|
6860
|
+
style: { paddingLeft: `${level * 12 + 8}px` },
|
|
6861
|
+
onClick: handleClick,
|
|
6862
|
+
children: [
|
|
6863
|
+
hasChildren ? /* @__PURE__ */ jsx21(
|
|
6864
|
+
"button",
|
|
6865
|
+
{
|
|
6866
|
+
onClick: handleToggle,
|
|
6867
|
+
className: "p-0.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",
|
|
6868
|
+
children: isExpanded ? /* @__PURE__ */ jsx21(ChevronDown3, { className: "w-4 h-4 text-gray-500 dark:text-gray-400" }) : /* @__PURE__ */ jsx21(ChevronRight2, { className: "w-4 h-4 text-gray-500 dark:text-gray-400" })
|
|
6869
|
+
}
|
|
6870
|
+
) : /* @__PURE__ */ jsx21("span", { className: "w-5" }),
|
|
6871
|
+
isExpanded ? /* @__PURE__ */ jsx21(FolderOpen, { className: "w-4 h-4 text-yellow-500 flex-shrink-0" }) : /* @__PURE__ */ jsx21(Folder, { className: "w-4 h-4 text-yellow-500 flex-shrink-0" }),
|
|
6872
|
+
/* @__PURE__ */ jsx21(
|
|
6873
|
+
"span",
|
|
6874
|
+
{
|
|
6875
|
+
className: cn(
|
|
6876
|
+
"text-sm truncate",
|
|
6877
|
+
isSelected ? "font-medium" : "text-gray-700 dark:text-gray-300"
|
|
6878
|
+
),
|
|
6879
|
+
children: item.name
|
|
6880
|
+
}
|
|
6881
|
+
)
|
|
6882
|
+
]
|
|
6883
|
+
}
|
|
6884
|
+
),
|
|
6885
|
+
isExpanded && folderChildren.length > 0 && /* @__PURE__ */ jsx21("div", { children: folderChildren.map((child) => /* @__PURE__ */ jsx21(FolderTreeItem, { item: child, level: level + 1 }, child.id)) })
|
|
6886
|
+
] });
|
|
6887
|
+
};
|
|
6888
|
+
var FolderTree = () => {
|
|
6889
|
+
const { data, currentFolder, navigateToFolder } = useFileManager();
|
|
6890
|
+
const rootItem = {
|
|
6891
|
+
id: "__root__",
|
|
6892
|
+
name: "Fichiers",
|
|
6893
|
+
type: "folder",
|
|
6894
|
+
path: "/",
|
|
6895
|
+
children: data
|
|
6896
|
+
};
|
|
6897
|
+
const isRootSelected = currentFolder?.id === "__root__";
|
|
6898
|
+
return /* @__PURE__ */ jsxs16("div", { className: "h-full overflow-y-auto py-2", children: [
|
|
6899
|
+
/* @__PURE__ */ jsxs16(
|
|
6900
|
+
"div",
|
|
6901
|
+
{
|
|
6902
|
+
className: cn(
|
|
6903
|
+
"flex items-center gap-2 py-1.5 px-3 rounded-lg cursor-pointer transition-colors mb-1",
|
|
6904
|
+
"hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
6905
|
+
isRootSelected && "bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300"
|
|
6906
|
+
),
|
|
6907
|
+
onClick: () => navigateToFolder(rootItem),
|
|
6908
|
+
children: [
|
|
6909
|
+
/* @__PURE__ */ jsx21(Folder, { className: "w-4 h-4 text-yellow-500" }),
|
|
6910
|
+
/* @__PURE__ */ jsx21("span", { className: cn("text-sm", isRootSelected && "font-medium"), children: rootItem.name })
|
|
6911
|
+
]
|
|
6912
|
+
}
|
|
6913
|
+
),
|
|
6914
|
+
data.filter((item) => item.type === "folder").map((folder) => /* @__PURE__ */ jsx21(FolderTreeItem, { item: folder, level: 1 }, folder.id))
|
|
6915
|
+
] });
|
|
6916
|
+
};
|
|
6917
|
+
|
|
6918
|
+
// src/components/common/FileManager/components/FileGrid.tsx
|
|
6919
|
+
import { FolderPlus } from "lucide-react";
|
|
6920
|
+
|
|
6921
|
+
// src/components/common/FileManager/components/FileCard.tsx
|
|
6922
|
+
import { useState as useState16, useRef as useRef3, useEffect as useEffect11 } from "react";
|
|
6923
|
+
|
|
6924
|
+
// src/components/common/FileManager/utils.ts
|
|
6925
|
+
import {
|
|
6926
|
+
Folder as Folder2,
|
|
6927
|
+
FolderOpen as FolderOpen2,
|
|
6928
|
+
File,
|
|
6929
|
+
FileText as FileText3,
|
|
6930
|
+
FileImage,
|
|
6931
|
+
FileSpreadsheet as FileSpreadsheet2,
|
|
6932
|
+
FileType,
|
|
6933
|
+
FileArchive,
|
|
6934
|
+
FileVideo,
|
|
6935
|
+
FileAudio,
|
|
6936
|
+
FileCode
|
|
6937
|
+
} from "lucide-react";
|
|
6938
|
+
var getFileIcon = (mimeType, isFolder, isOpen) => {
|
|
6939
|
+
if (isFolder) {
|
|
6940
|
+
return isOpen ? FolderOpen2 : Folder2;
|
|
6941
|
+
}
|
|
6942
|
+
if (!mimeType) {
|
|
6943
|
+
return File;
|
|
6944
|
+
}
|
|
6945
|
+
const type = mimeType.toLowerCase();
|
|
6946
|
+
if (type.startsWith("image/")) {
|
|
6947
|
+
return FileImage;
|
|
6948
|
+
}
|
|
6949
|
+
if (type === "application/pdf") {
|
|
6950
|
+
return FileText3;
|
|
6951
|
+
}
|
|
6952
|
+
if (type === "application/msword" || type === "application/vnd.openxmlformats-officedocument.wordprocessingml.document" || type.includes("word")) {
|
|
6953
|
+
return FileType;
|
|
6954
|
+
}
|
|
6955
|
+
if (type === "application/vnd.ms-excel" || type === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" || type.includes("excel") || type.includes("spreadsheet")) {
|
|
6956
|
+
return FileSpreadsheet2;
|
|
6957
|
+
}
|
|
6958
|
+
if (type === "application/vnd.ms-powerpoint" || type === "application/vnd.openxmlformats-officedocument.presentationml.presentation" || type.includes("powerpoint") || type.includes("presentation")) {
|
|
6959
|
+
return FileType;
|
|
6960
|
+
}
|
|
6961
|
+
if (type === "application/zip" || type === "application/x-rar-compressed" || type === "application/x-7z-compressed" || type === "application/gzip" || type.includes("archive") || type.includes("compressed")) {
|
|
6962
|
+
return FileArchive;
|
|
6963
|
+
}
|
|
6964
|
+
if (type.startsWith("video/")) {
|
|
6965
|
+
return FileVideo;
|
|
6966
|
+
}
|
|
6967
|
+
if (type.startsWith("audio/")) {
|
|
6968
|
+
return FileAudio;
|
|
6969
|
+
}
|
|
6970
|
+
if (type.includes("javascript") || type.includes("typescript") || type.includes("json") || type.includes("xml") || type.includes("html") || type.includes("css")) {
|
|
6971
|
+
return FileCode;
|
|
6972
|
+
}
|
|
6973
|
+
if (type.startsWith("text/")) {
|
|
6974
|
+
return FileText3;
|
|
6975
|
+
}
|
|
6976
|
+
return File;
|
|
6977
|
+
};
|
|
6978
|
+
var formatFileSize = (bytes) => {
|
|
6979
|
+
if (bytes === void 0 || bytes === null) {
|
|
6980
|
+
return "-";
|
|
6981
|
+
}
|
|
6982
|
+
if (bytes === 0) {
|
|
6983
|
+
return "0 B";
|
|
6984
|
+
}
|
|
6985
|
+
const units = ["B", "KB", "MB", "GB", "TB"];
|
|
6986
|
+
const k = 1024;
|
|
6987
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
6988
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(1))} ${units[i]}`;
|
|
6989
|
+
};
|
|
6990
|
+
var formatDate = (date) => {
|
|
6991
|
+
if (!date) {
|
|
6992
|
+
return "-";
|
|
6993
|
+
}
|
|
6994
|
+
const d = typeof date === "string" ? new Date(date) : date;
|
|
6995
|
+
if (isNaN(d.getTime())) {
|
|
6996
|
+
return "-";
|
|
6997
|
+
}
|
|
6998
|
+
return d.toLocaleDateString("fr-FR", {
|
|
6999
|
+
day: "2-digit",
|
|
7000
|
+
month: "2-digit",
|
|
7001
|
+
year: "numeric"
|
|
7002
|
+
});
|
|
7003
|
+
};
|
|
7004
|
+
|
|
7005
|
+
// src/components/common/FileManager/components/FileCard.tsx
|
|
7006
|
+
import { jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
7007
|
+
var FileCard = ({ item, variant = "grid" }) => {
|
|
7008
|
+
const {
|
|
7009
|
+
selectedItems,
|
|
7010
|
+
selectItem,
|
|
7011
|
+
navigateToFolder,
|
|
7012
|
+
showContextMenu,
|
|
7013
|
+
renamingItem,
|
|
7014
|
+
stopRenaming,
|
|
7015
|
+
onRename,
|
|
7016
|
+
onOpen,
|
|
7017
|
+
onDownload,
|
|
7018
|
+
allowRename
|
|
7019
|
+
} = useFileManager();
|
|
7020
|
+
const [renameValue, setRenameValue] = useState16(item.name);
|
|
7021
|
+
const inputRef = useRef3(null);
|
|
7022
|
+
const isSelected = selectedItems.some((i) => i.id === item.id);
|
|
7023
|
+
const isRenaming = renamingItem?.id === item.id;
|
|
7024
|
+
const isFolder = item.type === "folder";
|
|
7025
|
+
const Icon = getFileIcon(item.mimeType, isFolder);
|
|
7026
|
+
useEffect11(() => {
|
|
7027
|
+
if (isRenaming && inputRef.current) {
|
|
7028
|
+
inputRef.current.focus();
|
|
7029
|
+
inputRef.current.select();
|
|
7030
|
+
}
|
|
7031
|
+
}, [isRenaming]);
|
|
7032
|
+
useEffect11(() => {
|
|
7033
|
+
setRenameValue(item.name);
|
|
7034
|
+
}, [item.name]);
|
|
7035
|
+
const handleClick = (e) => {
|
|
7036
|
+
e.stopPropagation();
|
|
7037
|
+
selectItem(item, e.ctrlKey || e.metaKey);
|
|
7038
|
+
};
|
|
7039
|
+
const handleDoubleClick = (e) => {
|
|
7040
|
+
e.stopPropagation();
|
|
7041
|
+
if (isFolder) {
|
|
7042
|
+
navigateToFolder(item);
|
|
7043
|
+
} else {
|
|
7044
|
+
if (onOpen) {
|
|
7045
|
+
onOpen(item);
|
|
7046
|
+
} else if (onDownload) {
|
|
7047
|
+
onDownload(item);
|
|
7048
|
+
}
|
|
7049
|
+
}
|
|
7050
|
+
};
|
|
7051
|
+
const handleContextMenu = (e) => {
|
|
7052
|
+
e.preventDefault();
|
|
7053
|
+
e.stopPropagation();
|
|
7054
|
+
showContextMenu(item, { x: e.clientX, y: e.clientY });
|
|
7055
|
+
};
|
|
7056
|
+
const handleRenameSubmit = async () => {
|
|
7057
|
+
if (renameValue.trim() && renameValue !== item.name && onRename && allowRename) {
|
|
7058
|
+
try {
|
|
7059
|
+
await onRename(item, renameValue.trim());
|
|
7060
|
+
} catch (error) {
|
|
7061
|
+
setRenameValue(item.name);
|
|
7062
|
+
}
|
|
7063
|
+
} else {
|
|
7064
|
+
setRenameValue(item.name);
|
|
7065
|
+
}
|
|
7066
|
+
stopRenaming();
|
|
7067
|
+
};
|
|
7068
|
+
const handleRenameKeyDown = (e) => {
|
|
7069
|
+
if (e.key === "Enter") {
|
|
7070
|
+
handleRenameSubmit();
|
|
7071
|
+
} else if (e.key === "Escape") {
|
|
7072
|
+
setRenameValue(item.name);
|
|
7073
|
+
stopRenaming();
|
|
7074
|
+
}
|
|
7075
|
+
};
|
|
7076
|
+
if (variant === "list") {
|
|
7077
|
+
return /* @__PURE__ */ jsxs17(
|
|
7078
|
+
"div",
|
|
7079
|
+
{
|
|
7080
|
+
className: cn(
|
|
7081
|
+
"flex items-center gap-3 px-3 py-2 rounded-lg cursor-pointer transition-all duration-200",
|
|
7082
|
+
"hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
7083
|
+
isSelected && "bg-blue-50 dark:bg-blue-900/30 ring-1 ring-blue-500"
|
|
7084
|
+
),
|
|
7085
|
+
onClick: handleClick,
|
|
7086
|
+
onDoubleClick: handleDoubleClick,
|
|
7087
|
+
onContextMenu: handleContextMenu,
|
|
7088
|
+
children: [
|
|
7089
|
+
/* @__PURE__ */ jsx22(
|
|
7090
|
+
Icon,
|
|
7091
|
+
{
|
|
7092
|
+
className: cn(
|
|
7093
|
+
"w-5 h-5 flex-shrink-0",
|
|
7094
|
+
isFolder ? "text-yellow-500" : "text-gray-500 dark:text-gray-400"
|
|
7095
|
+
)
|
|
7096
|
+
}
|
|
7097
|
+
),
|
|
7098
|
+
/* @__PURE__ */ jsx22("div", { className: "flex-1 min-w-0", children: isRenaming ? /* @__PURE__ */ jsx22(
|
|
7099
|
+
"input",
|
|
7100
|
+
{
|
|
7101
|
+
ref: inputRef,
|
|
7102
|
+
type: "text",
|
|
7103
|
+
value: renameValue,
|
|
7104
|
+
onChange: (e) => setRenameValue(e.target.value),
|
|
7105
|
+
onBlur: handleRenameSubmit,
|
|
7106
|
+
onKeyDown: handleRenameKeyDown,
|
|
7107
|
+
className: "w-full px-2 py-0.5 text-sm border border-blue-500 rounded outline-none bg-white dark:bg-gray-900",
|
|
7108
|
+
onClick: (e) => e.stopPropagation()
|
|
7109
|
+
}
|
|
7110
|
+
) : /* @__PURE__ */ jsx22("span", { className: "block truncate text-sm text-gray-900 dark:text-gray-100", children: item.name }) }),
|
|
7111
|
+
/* @__PURE__ */ jsx22("span", { className: "text-xs text-gray-500 dark:text-gray-400 w-20 text-right", children: !isFolder && formatFileSize(item.size) }),
|
|
7112
|
+
/* @__PURE__ */ jsx22("span", { className: "text-xs text-gray-500 dark:text-gray-400 w-24 text-right", children: formatDate(item.updatedAt || item.createdAt) })
|
|
7113
|
+
]
|
|
7114
|
+
}
|
|
7115
|
+
);
|
|
7116
|
+
}
|
|
7117
|
+
return /* @__PURE__ */ jsxs17(
|
|
7118
|
+
"div",
|
|
7119
|
+
{
|
|
7120
|
+
className: cn(
|
|
7121
|
+
"flex flex-col items-center p-3 rounded-xl cursor-pointer transition-all duration-200",
|
|
7122
|
+
"hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
7123
|
+
isSelected && "bg-blue-50 dark:bg-blue-900/30 ring-2 ring-blue-500"
|
|
7124
|
+
),
|
|
7125
|
+
onClick: handleClick,
|
|
7126
|
+
onDoubleClick: handleDoubleClick,
|
|
7127
|
+
onContextMenu: handleContextMenu,
|
|
7128
|
+
children: [
|
|
7129
|
+
/* @__PURE__ */ jsx22("div", { className: "w-16 h-16 flex items-center justify-center mb-2", children: /* @__PURE__ */ jsx22(
|
|
7130
|
+
Icon,
|
|
7131
|
+
{
|
|
7132
|
+
className: cn(
|
|
7133
|
+
"w-12 h-12",
|
|
7134
|
+
isFolder ? "text-yellow-500" : "text-gray-500 dark:text-gray-400"
|
|
7135
|
+
)
|
|
7136
|
+
}
|
|
7137
|
+
) }),
|
|
7138
|
+
/* @__PURE__ */ jsx22("div", { className: "w-full text-center", children: isRenaming ? /* @__PURE__ */ jsx22(
|
|
7139
|
+
"input",
|
|
7140
|
+
{
|
|
7141
|
+
ref: inputRef,
|
|
7142
|
+
type: "text",
|
|
7143
|
+
value: renameValue,
|
|
7144
|
+
onChange: (e) => setRenameValue(e.target.value),
|
|
7145
|
+
onBlur: handleRenameSubmit,
|
|
7146
|
+
onKeyDown: handleRenameKeyDown,
|
|
7147
|
+
className: "w-full px-2 py-0.5 text-xs border border-blue-500 rounded outline-none text-center bg-white dark:bg-gray-900",
|
|
7148
|
+
onClick: (e) => e.stopPropagation()
|
|
7149
|
+
}
|
|
7150
|
+
) : /* @__PURE__ */ jsx22("span", { className: "block text-xs text-gray-900 dark:text-gray-100 truncate px-1", children: item.name }) }),
|
|
7151
|
+
!isFolder && /* @__PURE__ */ jsx22("span", { className: "text-[10px] text-gray-500 dark:text-gray-400 mt-1", children: formatFileSize(item.size) })
|
|
7152
|
+
]
|
|
7153
|
+
}
|
|
7154
|
+
);
|
|
7155
|
+
};
|
|
7156
|
+
|
|
7157
|
+
// src/components/common/FileManager/components/FileGrid.tsx
|
|
7158
|
+
import { jsx as jsx23, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
7159
|
+
var FileGrid = () => {
|
|
7160
|
+
const { currentFolderContents, texts, deselectAll, hideContextMenu } = useFileManager();
|
|
7161
|
+
const sortedItems = [...currentFolderContents].sort((a, b) => {
|
|
7162
|
+
if (a.type === "folder" && b.type !== "folder") return -1;
|
|
7163
|
+
if (a.type !== "folder" && b.type === "folder") return 1;
|
|
7164
|
+
return a.name.localeCompare(b.name);
|
|
7165
|
+
});
|
|
7166
|
+
const handleContainerClick = () => {
|
|
7167
|
+
deselectAll();
|
|
7168
|
+
hideContextMenu();
|
|
7169
|
+
};
|
|
7170
|
+
if (sortedItems.length === 0) {
|
|
7171
|
+
return /* @__PURE__ */ jsxs18(
|
|
7172
|
+
"div",
|
|
7173
|
+
{
|
|
7174
|
+
className: "flex-1 flex flex-col items-center justify-center text-gray-500 dark:text-gray-400 p-8",
|
|
7175
|
+
onClick: handleContainerClick,
|
|
7176
|
+
children: [
|
|
7177
|
+
/* @__PURE__ */ jsx23(FolderPlus, { className: "w-16 h-16 mb-4 opacity-50" }),
|
|
7178
|
+
/* @__PURE__ */ jsx23("p", { className: "text-lg", children: texts.noFiles }),
|
|
7179
|
+
/* @__PURE__ */ jsx23("p", { className: "text-sm mt-2", children: texts.dropFilesHere })
|
|
7180
|
+
]
|
|
7181
|
+
}
|
|
7182
|
+
);
|
|
7183
|
+
}
|
|
7184
|
+
return /* @__PURE__ */ jsx23(
|
|
7185
|
+
"div",
|
|
7186
|
+
{
|
|
7187
|
+
className: "flex-1 overflow-y-auto p-4",
|
|
7188
|
+
onClick: handleContainerClick,
|
|
7189
|
+
children: /* @__PURE__ */ jsx23("div", { className: "grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-2", children: sortedItems.map((item) => /* @__PURE__ */ jsx23(FileCard, { item, variant: "grid" }, item.id)) })
|
|
7190
|
+
}
|
|
7191
|
+
);
|
|
7192
|
+
};
|
|
7193
|
+
|
|
7194
|
+
// src/components/common/FileManager/components/FileList.tsx
|
|
7195
|
+
import { FolderPlus as FolderPlus2 } from "lucide-react";
|
|
7196
|
+
import { jsx as jsx24, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
7197
|
+
var FileList = () => {
|
|
7198
|
+
const { currentFolderContents, texts, deselectAll, hideContextMenu } = useFileManager();
|
|
7199
|
+
const sortedItems = [...currentFolderContents].sort((a, b) => {
|
|
7200
|
+
if (a.type === "folder" && b.type !== "folder") return -1;
|
|
7201
|
+
if (a.type !== "folder" && b.type === "folder") return 1;
|
|
7202
|
+
return a.name.localeCompare(b.name);
|
|
7203
|
+
});
|
|
7204
|
+
const handleContainerClick = () => {
|
|
7205
|
+
deselectAll();
|
|
7206
|
+
hideContextMenu();
|
|
7207
|
+
};
|
|
7208
|
+
if (sortedItems.length === 0) {
|
|
7209
|
+
return /* @__PURE__ */ jsxs19(
|
|
7210
|
+
"div",
|
|
7211
|
+
{
|
|
7212
|
+
className: "flex-1 flex flex-col items-center justify-center text-gray-500 dark:text-gray-400 p-8",
|
|
7213
|
+
onClick: handleContainerClick,
|
|
7214
|
+
children: [
|
|
7215
|
+
/* @__PURE__ */ jsx24(FolderPlus2, { className: "w-16 h-16 mb-4 opacity-50" }),
|
|
7216
|
+
/* @__PURE__ */ jsx24("p", { className: "text-lg", children: texts.noFiles }),
|
|
7217
|
+
/* @__PURE__ */ jsx24("p", { className: "text-sm mt-2", children: texts.dropFilesHere })
|
|
7218
|
+
]
|
|
7219
|
+
}
|
|
7220
|
+
);
|
|
7221
|
+
}
|
|
7222
|
+
return /* @__PURE__ */ jsxs19(
|
|
7223
|
+
"div",
|
|
7224
|
+
{
|
|
7225
|
+
className: "flex-1 overflow-y-auto p-4",
|
|
7226
|
+
onClick: handleContainerClick,
|
|
7227
|
+
children: [
|
|
7228
|
+
/* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-3 px-3 py-2 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider border-b border-gray-200 dark:border-gray-700 mb-2", children: [
|
|
7229
|
+
/* @__PURE__ */ jsx24("span", { className: "w-5" }),
|
|
7230
|
+
" ",
|
|
7231
|
+
/* @__PURE__ */ jsx24("span", { className: "flex-1", children: "Nom" }),
|
|
7232
|
+
/* @__PURE__ */ jsx24("span", { className: "w-20 text-right", children: "Taille" }),
|
|
7233
|
+
/* @__PURE__ */ jsx24("span", { className: "w-24 text-right", children: "Modifi\xE9" })
|
|
7234
|
+
] }),
|
|
7235
|
+
/* @__PURE__ */ jsx24("div", { className: "space-y-1", children: sortedItems.map((item) => /* @__PURE__ */ jsx24(FileCard, { item, variant: "list" }, item.id)) })
|
|
7236
|
+
]
|
|
7237
|
+
}
|
|
7238
|
+
);
|
|
7239
|
+
};
|
|
7240
|
+
|
|
7241
|
+
// src/components/common/FileManager/components/Breadcrumb.tsx
|
|
7242
|
+
import React15 from "react";
|
|
7243
|
+
import { ChevronRight as ChevronRight3, ChevronLeft as ChevronLeft3 } from "lucide-react";
|
|
7244
|
+
import { jsx as jsx25, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
7245
|
+
var Breadcrumb = () => {
|
|
7246
|
+
const { pathHistory, navigateBack, navigateToPath } = useFileManager();
|
|
7247
|
+
return /* @__PURE__ */ jsxs20("div", { className: "flex items-center gap-1 px-2 py-2 bg-gray-50 dark:bg-gray-800/50 rounded-lg", children: [
|
|
7248
|
+
/* @__PURE__ */ jsx25(
|
|
7249
|
+
"button",
|
|
7250
|
+
{
|
|
7251
|
+
onClick: navigateBack,
|
|
7252
|
+
disabled: pathHistory.length <= 1,
|
|
7253
|
+
className: cn(
|
|
7254
|
+
"p-1.5 rounded-md transition-colors",
|
|
7255
|
+
pathHistory.length > 1 ? "hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300" : "text-gray-400 dark:text-gray-600 cursor-not-allowed"
|
|
7256
|
+
),
|
|
7257
|
+
title: "Retour",
|
|
7258
|
+
children: /* @__PURE__ */ jsx25(ChevronLeft3, { className: "w-4 h-4" })
|
|
7259
|
+
}
|
|
7260
|
+
),
|
|
7261
|
+
/* @__PURE__ */ jsx25("div", { className: "flex items-center gap-1 overflow-x-auto scrollbar-thin", children: pathHistory.map((folder, index) => /* @__PURE__ */ jsxs20(React15.Fragment, { children: [
|
|
7262
|
+
index > 0 && /* @__PURE__ */ jsx25(ChevronRight3, { className: "w-4 h-4 text-gray-400 dark:text-gray-600 flex-shrink-0" }),
|
|
7263
|
+
/* @__PURE__ */ jsx25(
|
|
7264
|
+
"button",
|
|
7265
|
+
{
|
|
7266
|
+
onClick: () => navigateToPath(index),
|
|
7267
|
+
className: cn(
|
|
7268
|
+
"px-2 py-1 text-sm rounded-md transition-colors whitespace-nowrap",
|
|
7269
|
+
index === pathHistory.length - 1 ? "text-gray-900 dark:text-gray-100 font-medium" : "text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 hover:bg-gray-200 dark:hover:bg-gray-700"
|
|
7270
|
+
),
|
|
7271
|
+
children: folder.name
|
|
7272
|
+
}
|
|
7273
|
+
)
|
|
7274
|
+
] }, folder.id)) })
|
|
7275
|
+
] });
|
|
7276
|
+
};
|
|
7277
|
+
|
|
7278
|
+
// src/components/common/FileManager/components/Toolbar.tsx
|
|
7279
|
+
import React16, { useRef as useRef4, useState as useState17 } from "react";
|
|
7280
|
+
import { FolderPlus as FolderPlus3, Upload as Upload2, Grid, List, X as X8 } from "lucide-react";
|
|
7281
|
+
import { Fragment as Fragment7, jsx as jsx26, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
7282
|
+
var CreateFolderModal = ({
|
|
7283
|
+
isOpen,
|
|
7284
|
+
onClose,
|
|
7285
|
+
onSubmit,
|
|
7286
|
+
texts
|
|
7287
|
+
}) => {
|
|
7288
|
+
const [folderName, setFolderName] = useState17("");
|
|
7289
|
+
const inputRef = useRef4(null);
|
|
7290
|
+
React16.useEffect(() => {
|
|
7291
|
+
if (isOpen && inputRef.current) {
|
|
7292
|
+
inputRef.current.focus();
|
|
7293
|
+
}
|
|
7294
|
+
if (!isOpen) {
|
|
7295
|
+
setFolderName("");
|
|
7296
|
+
}
|
|
7297
|
+
}, [isOpen]);
|
|
7298
|
+
const handleSubmit = (e) => {
|
|
7299
|
+
e.preventDefault();
|
|
7300
|
+
if (folderName.trim()) {
|
|
7301
|
+
onSubmit(folderName.trim());
|
|
7302
|
+
setFolderName("");
|
|
7303
|
+
onClose();
|
|
7304
|
+
}
|
|
7305
|
+
};
|
|
7306
|
+
if (!isOpen) return null;
|
|
7307
|
+
return /* @__PURE__ */ jsx26("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50", children: /* @__PURE__ */ jsxs21("div", { className: "bg-white dark:bg-gray-900 rounded-xl shadow-xl p-6 w-full max-w-md mx-4", children: [
|
|
7308
|
+
/* @__PURE__ */ jsxs21("div", { className: "flex items-center justify-between mb-4", children: [
|
|
7309
|
+
/* @__PURE__ */ jsx26("h3", { className: "text-lg font-semibold text-gray-900 dark:text-gray-100", children: texts.createFolder }),
|
|
7310
|
+
/* @__PURE__ */ jsx26(
|
|
7311
|
+
"button",
|
|
7312
|
+
{
|
|
7313
|
+
onClick: onClose,
|
|
7314
|
+
className: "p-1 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",
|
|
7315
|
+
children: /* @__PURE__ */ jsx26(X8, { className: "w-5 h-5 text-gray-500" })
|
|
7316
|
+
}
|
|
7317
|
+
)
|
|
7318
|
+
] }),
|
|
7319
|
+
/* @__PURE__ */ jsxs21("form", { onSubmit: handleSubmit, children: [
|
|
7320
|
+
/* @__PURE__ */ jsx26("label", { className: "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2", children: texts.newFolderName }),
|
|
7321
|
+
/* @__PURE__ */ jsx26(
|
|
7322
|
+
"input",
|
|
7323
|
+
{
|
|
7324
|
+
ref: inputRef,
|
|
7325
|
+
type: "text",
|
|
7326
|
+
value: folderName,
|
|
7327
|
+
onChange: (e) => setFolderName(e.target.value),
|
|
7328
|
+
className: "w-full px-3 py-2 border border-gray-300 dark:border-gray-700 rounded-lg\r\n bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100\r\n focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none",
|
|
7329
|
+
placeholder: "Nouveau dossier"
|
|
7330
|
+
}
|
|
7331
|
+
),
|
|
7332
|
+
/* @__PURE__ */ jsxs21("div", { className: "flex justify-end gap-3 mt-6", children: [
|
|
7333
|
+
/* @__PURE__ */ jsx26(
|
|
7334
|
+
"button",
|
|
7335
|
+
{
|
|
7336
|
+
type: "button",
|
|
7337
|
+
onClick: onClose,
|
|
7338
|
+
className: "px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300\r\n hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",
|
|
7339
|
+
children: texts.cancel
|
|
7340
|
+
}
|
|
7341
|
+
),
|
|
7342
|
+
/* @__PURE__ */ jsx26(
|
|
7343
|
+
"button",
|
|
7344
|
+
{
|
|
7345
|
+
type: "submit",
|
|
7346
|
+
disabled: !folderName.trim(),
|
|
7347
|
+
className: cn(
|
|
7348
|
+
"px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors",
|
|
7349
|
+
folderName.trim() ? "bg-blue-600 hover:bg-blue-700" : "bg-gray-400 cursor-not-allowed"
|
|
7350
|
+
),
|
|
7351
|
+
children: texts.confirm
|
|
7352
|
+
}
|
|
7353
|
+
)
|
|
7354
|
+
] })
|
|
7355
|
+
] })
|
|
7356
|
+
] }) });
|
|
7357
|
+
};
|
|
7358
|
+
var Toolbar = () => {
|
|
7359
|
+
const {
|
|
7360
|
+
currentFolder,
|
|
7361
|
+
selectedItems,
|
|
7362
|
+
viewMode,
|
|
7363
|
+
setViewMode,
|
|
7364
|
+
deselectAll,
|
|
7365
|
+
onCreateFolder,
|
|
7366
|
+
onUploadFiles,
|
|
7367
|
+
allowCreateFolder,
|
|
7368
|
+
allowUpload,
|
|
7369
|
+
texts
|
|
7370
|
+
} = useFileManager();
|
|
7371
|
+
const [showCreateModal, setShowCreateModal] = useState17(false);
|
|
7372
|
+
const fileInputRef = useRef4(null);
|
|
7373
|
+
const handleCreateFolder = async (name) => {
|
|
7374
|
+
if (onCreateFolder && currentFolder) {
|
|
7375
|
+
try {
|
|
7376
|
+
await onCreateFolder(name, currentFolder.id);
|
|
7377
|
+
} catch (error) {
|
|
7378
|
+
console.error("Create folder failed:", error);
|
|
7379
|
+
}
|
|
7380
|
+
}
|
|
7381
|
+
};
|
|
7382
|
+
const handleUploadClick = () => {
|
|
7383
|
+
fileInputRef.current?.click();
|
|
7384
|
+
};
|
|
7385
|
+
const handleFileChange = async (e) => {
|
|
7386
|
+
const files = e.target.files;
|
|
7387
|
+
if (files && files.length > 0 && onUploadFiles && currentFolder) {
|
|
7388
|
+
try {
|
|
7389
|
+
await onUploadFiles(Array.from(files), currentFolder.id);
|
|
7390
|
+
} catch (error) {
|
|
7391
|
+
console.error("Upload failed:", error);
|
|
7392
|
+
}
|
|
7393
|
+
}
|
|
7394
|
+
if (fileInputRef.current) {
|
|
7395
|
+
fileInputRef.current.value = "";
|
|
7396
|
+
}
|
|
7397
|
+
};
|
|
7398
|
+
return /* @__PURE__ */ jsxs21(Fragment7, { children: [
|
|
7399
|
+
/* @__PURE__ */ jsxs21("div", { className: "flex items-center justify-between gap-4 flex-wrap", children: [
|
|
7400
|
+
/* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-2", children: [
|
|
7401
|
+
allowCreateFolder && /* @__PURE__ */ jsxs21(
|
|
7402
|
+
"button",
|
|
7403
|
+
{
|
|
7404
|
+
onClick: () => setShowCreateModal(true),
|
|
7405
|
+
className: cn(
|
|
7406
|
+
"flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-lg transition-colors",
|
|
7407
|
+
"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300",
|
|
7408
|
+
"hover:bg-gray-200 dark:hover:bg-gray-700"
|
|
7409
|
+
),
|
|
7410
|
+
children: [
|
|
7411
|
+
/* @__PURE__ */ jsx26(FolderPlus3, { className: "w-4 h-4" }),
|
|
7412
|
+
/* @__PURE__ */ jsx26("span", { className: "hidden sm:inline", children: texts.createFolder })
|
|
7413
|
+
]
|
|
7414
|
+
}
|
|
7415
|
+
),
|
|
7416
|
+
allowUpload && /* @__PURE__ */ jsxs21(Fragment7, { children: [
|
|
7417
|
+
/* @__PURE__ */ jsxs21(
|
|
7418
|
+
"button",
|
|
7419
|
+
{
|
|
7420
|
+
onClick: handleUploadClick,
|
|
7421
|
+
className: cn(
|
|
7422
|
+
"flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-lg transition-colors",
|
|
7423
|
+
"bg-blue-600 text-white hover:bg-blue-700"
|
|
7424
|
+
),
|
|
7425
|
+
children: [
|
|
7426
|
+
/* @__PURE__ */ jsx26(Upload2, { className: "w-4 h-4" }),
|
|
7427
|
+
/* @__PURE__ */ jsx26("span", { className: "hidden sm:inline", children: texts.uploadFiles })
|
|
7428
|
+
]
|
|
7429
|
+
}
|
|
7430
|
+
),
|
|
7431
|
+
/* @__PURE__ */ jsx26(
|
|
7432
|
+
"input",
|
|
7433
|
+
{
|
|
7434
|
+
ref: fileInputRef,
|
|
7435
|
+
type: "file",
|
|
7436
|
+
multiple: true,
|
|
7437
|
+
onChange: handleFileChange,
|
|
7438
|
+
className: "hidden",
|
|
7439
|
+
accept: ".jpg,.jpeg,.png,.gif,.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.csv,.zip,.rar"
|
|
7440
|
+
}
|
|
7441
|
+
)
|
|
7442
|
+
] })
|
|
7443
|
+
] }),
|
|
7444
|
+
/* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-2", children: [
|
|
7445
|
+
selectedItems.length > 0 && /* @__PURE__ */ jsxs21(
|
|
7446
|
+
"button",
|
|
7447
|
+
{
|
|
7448
|
+
onClick: deselectAll,
|
|
7449
|
+
className: "flex items-center gap-2 px-3 py-2 text-sm text-gray-600 dark:text-gray-400\r\n hover:text-gray-900 dark:hover:text-gray-100 transition-colors",
|
|
7450
|
+
children: [
|
|
7451
|
+
/* @__PURE__ */ jsx26(X8, { className: "w-4 h-4" }),
|
|
7452
|
+
texts.deselectAll,
|
|
7453
|
+
" (",
|
|
7454
|
+
selectedItems.length,
|
|
7455
|
+
")"
|
|
7456
|
+
]
|
|
7457
|
+
}
|
|
7458
|
+
),
|
|
7459
|
+
/* @__PURE__ */ jsxs21("div", { className: "flex items-center bg-gray-100 dark:bg-gray-800 rounded-lg p-1", children: [
|
|
7460
|
+
/* @__PURE__ */ jsx26(
|
|
7461
|
+
"button",
|
|
7462
|
+
{
|
|
7463
|
+
onClick: () => setViewMode("grid"),
|
|
7464
|
+
className: cn(
|
|
7465
|
+
"p-1.5 rounded-md transition-colors",
|
|
7466
|
+
viewMode === "grid" ? "bg-white dark:bg-gray-700 shadow-sm text-gray-900 dark:text-gray-100" : "text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"
|
|
7467
|
+
),
|
|
7468
|
+
title: "Vue grille",
|
|
7469
|
+
children: /* @__PURE__ */ jsx26(Grid, { className: "w-4 h-4" })
|
|
7470
|
+
}
|
|
7471
|
+
),
|
|
7472
|
+
/* @__PURE__ */ jsx26(
|
|
7473
|
+
"button",
|
|
7474
|
+
{
|
|
7475
|
+
onClick: () => setViewMode("list"),
|
|
7476
|
+
className: cn(
|
|
7477
|
+
"p-1.5 rounded-md transition-colors",
|
|
7478
|
+
viewMode === "list" ? "bg-white dark:bg-gray-700 shadow-sm text-gray-900 dark:text-gray-100" : "text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"
|
|
7479
|
+
),
|
|
7480
|
+
title: "Vue liste",
|
|
7481
|
+
children: /* @__PURE__ */ jsx26(List, { className: "w-4 h-4" })
|
|
7482
|
+
}
|
|
7483
|
+
)
|
|
7484
|
+
] })
|
|
7485
|
+
] })
|
|
7486
|
+
] }),
|
|
7487
|
+
/* @__PURE__ */ jsx26(
|
|
7488
|
+
CreateFolderModal,
|
|
7489
|
+
{
|
|
7490
|
+
isOpen: showCreateModal,
|
|
7491
|
+
onClose: () => setShowCreateModal(false),
|
|
7492
|
+
onSubmit: handleCreateFolder,
|
|
7493
|
+
texts
|
|
7494
|
+
}
|
|
7495
|
+
)
|
|
7496
|
+
] });
|
|
7497
|
+
};
|
|
7498
|
+
|
|
7499
|
+
// src/components/common/FileManager/components/ContextMenu.tsx
|
|
7500
|
+
import { useEffect as useEffect12, useRef as useRef5 } from "react";
|
|
7501
|
+
import { FolderOpen as FolderOpen3, Edit3 as Edit32, Download as Download3, Trash2 as Trash24 } from "lucide-react";
|
|
7502
|
+
import { Fragment as Fragment8, jsx as jsx27, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
7503
|
+
var ContextMenu = () => {
|
|
7504
|
+
const {
|
|
7505
|
+
contextMenu,
|
|
7506
|
+
hideContextMenu,
|
|
7507
|
+
navigateToFolder,
|
|
7508
|
+
startRenaming,
|
|
7509
|
+
onDownload,
|
|
7510
|
+
onDelete,
|
|
7511
|
+
onOpen,
|
|
7512
|
+
allowRename,
|
|
7513
|
+
allowDelete,
|
|
7514
|
+
allowDownload,
|
|
7515
|
+
texts
|
|
7516
|
+
} = useFileManager();
|
|
7517
|
+
const menuRef = useRef5(null);
|
|
7518
|
+
useEffect12(() => {
|
|
7519
|
+
const handleClickOutside = (e) => {
|
|
7520
|
+
if (menuRef.current && !menuRef.current.contains(e.target)) {
|
|
7521
|
+
hideContextMenu();
|
|
7522
|
+
}
|
|
7523
|
+
};
|
|
7524
|
+
const handleEscape = (e) => {
|
|
7525
|
+
if (e.key === "Escape") {
|
|
7526
|
+
hideContextMenu();
|
|
7527
|
+
}
|
|
7528
|
+
};
|
|
7529
|
+
if (contextMenu.visible) {
|
|
7530
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
7531
|
+
document.addEventListener("keydown", handleEscape);
|
|
7532
|
+
}
|
|
7533
|
+
return () => {
|
|
7534
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
7535
|
+
document.removeEventListener("keydown", handleEscape);
|
|
7536
|
+
};
|
|
7537
|
+
}, [contextMenu.visible, hideContextMenu]);
|
|
7538
|
+
if (!contextMenu.visible || !contextMenu.item) {
|
|
7539
|
+
return null;
|
|
7540
|
+
}
|
|
7541
|
+
const { item, position } = contextMenu;
|
|
7542
|
+
const isFolder = item.type === "folder";
|
|
7543
|
+
const handleOpen = () => {
|
|
7544
|
+
if (isFolder) {
|
|
7545
|
+
navigateToFolder(item);
|
|
7546
|
+
} else if (onOpen) {
|
|
7547
|
+
onOpen(item);
|
|
7548
|
+
} else if (onDownload) {
|
|
7549
|
+
onDownload(item);
|
|
7550
|
+
}
|
|
7551
|
+
hideContextMenu();
|
|
7552
|
+
};
|
|
7553
|
+
const handleRename = () => {
|
|
7554
|
+
startRenaming(item);
|
|
7555
|
+
};
|
|
7556
|
+
const handleDownload = () => {
|
|
7557
|
+
if (onDownload) {
|
|
7558
|
+
onDownload(item);
|
|
7559
|
+
}
|
|
7560
|
+
hideContextMenu();
|
|
7561
|
+
};
|
|
7562
|
+
const handleDelete = async () => {
|
|
7563
|
+
if (onDelete) {
|
|
7564
|
+
try {
|
|
7565
|
+
await onDelete(item);
|
|
7566
|
+
} catch (error) {
|
|
7567
|
+
console.error("Delete failed:", error);
|
|
7568
|
+
}
|
|
7569
|
+
}
|
|
7570
|
+
hideContextMenu();
|
|
7571
|
+
};
|
|
7572
|
+
const menuStyle = {
|
|
7573
|
+
position: "fixed",
|
|
7574
|
+
top: position.y,
|
|
7575
|
+
left: position.x,
|
|
7576
|
+
zIndex: 9999
|
|
7577
|
+
};
|
|
7578
|
+
if (typeof window !== "undefined") {
|
|
7579
|
+
const menuWidth = 180;
|
|
7580
|
+
const menuHeight = 200;
|
|
7581
|
+
if (position.x + menuWidth > window.innerWidth) {
|
|
7582
|
+
menuStyle.left = position.x - menuWidth;
|
|
7583
|
+
}
|
|
7584
|
+
if (position.y + menuHeight > window.innerHeight) {
|
|
7585
|
+
menuStyle.top = position.y - menuHeight;
|
|
7586
|
+
}
|
|
7587
|
+
}
|
|
7588
|
+
return /* @__PURE__ */ jsxs22(
|
|
7589
|
+
"div",
|
|
7590
|
+
{
|
|
7591
|
+
ref: menuRef,
|
|
7592
|
+
style: menuStyle,
|
|
7593
|
+
className: "bg-white dark:bg-gray-900 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 py-1 min-w-[160px]",
|
|
7594
|
+
children: [
|
|
7595
|
+
/* @__PURE__ */ jsxs22(
|
|
7596
|
+
"button",
|
|
7597
|
+
{
|
|
7598
|
+
onClick: handleOpen,
|
|
7599
|
+
className: cn(
|
|
7600
|
+
"w-full flex items-center gap-3 px-4 py-2 text-sm text-left",
|
|
7601
|
+
"text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors"
|
|
7602
|
+
),
|
|
7603
|
+
children: [
|
|
7604
|
+
/* @__PURE__ */ jsx27(FolderOpen3, { className: "w-4 h-4" }),
|
|
7605
|
+
texts.open
|
|
7606
|
+
]
|
|
7607
|
+
}
|
|
7608
|
+
),
|
|
7609
|
+
allowRename && /* @__PURE__ */ jsxs22(
|
|
7610
|
+
"button",
|
|
7611
|
+
{
|
|
7612
|
+
onClick: handleRename,
|
|
7613
|
+
className: cn(
|
|
7614
|
+
"w-full flex items-center gap-3 px-4 py-2 text-sm text-left",
|
|
7615
|
+
"text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors"
|
|
7616
|
+
),
|
|
7617
|
+
children: [
|
|
7618
|
+
/* @__PURE__ */ jsx27(Edit32, { className: "w-4 h-4" }),
|
|
7619
|
+
texts.rename
|
|
7620
|
+
]
|
|
7621
|
+
}
|
|
7622
|
+
),
|
|
7623
|
+
allowDownload && /* @__PURE__ */ jsxs22(
|
|
7624
|
+
"button",
|
|
7625
|
+
{
|
|
7626
|
+
onClick: handleDownload,
|
|
7627
|
+
className: cn(
|
|
7628
|
+
"w-full flex items-center gap-3 px-4 py-2 text-sm text-left",
|
|
7629
|
+
"text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors"
|
|
7630
|
+
),
|
|
7631
|
+
children: [
|
|
7632
|
+
/* @__PURE__ */ jsx27(Download3, { className: "w-4 h-4" }),
|
|
7633
|
+
texts.download
|
|
7634
|
+
]
|
|
7635
|
+
}
|
|
7636
|
+
),
|
|
7637
|
+
allowDelete && /* @__PURE__ */ jsxs22(Fragment8, { children: [
|
|
7638
|
+
/* @__PURE__ */ jsx27("div", { className: "border-t border-gray-200 dark:border-gray-700 my-1" }),
|
|
7639
|
+
/* @__PURE__ */ jsxs22(
|
|
7640
|
+
"button",
|
|
7641
|
+
{
|
|
7642
|
+
onClick: handleDelete,
|
|
7643
|
+
className: cn(
|
|
7644
|
+
"w-full flex items-center gap-3 px-4 py-2 text-sm text-left",
|
|
7645
|
+
"text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors"
|
|
7646
|
+
),
|
|
7647
|
+
children: [
|
|
7648
|
+
/* @__PURE__ */ jsx27(Trash24, { className: "w-4 h-4" }),
|
|
7649
|
+
texts.delete
|
|
7650
|
+
]
|
|
7651
|
+
}
|
|
7652
|
+
)
|
|
7653
|
+
] })
|
|
7654
|
+
]
|
|
7655
|
+
}
|
|
7656
|
+
);
|
|
7657
|
+
};
|
|
7658
|
+
|
|
7659
|
+
// src/components/common/FileManager/FileManager.tsx
|
|
7660
|
+
import { jsx as jsx28, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
7661
|
+
var FileManagerContent = ({ className }) => {
|
|
7662
|
+
const { viewMode, hideContextMenu } = useFileManager();
|
|
7663
|
+
const [sidebarOpen, setSidebarOpen] = useState18(false);
|
|
7664
|
+
const handleMainClick = () => {
|
|
7665
|
+
hideContextMenu();
|
|
7666
|
+
};
|
|
7667
|
+
return /* @__PURE__ */ jsxs23(
|
|
7668
|
+
"div",
|
|
7669
|
+
{
|
|
7670
|
+
className: cn(
|
|
7671
|
+
"flex h-full bg-white dark:bg-gray-900 rounded-xl border border-gray-200 dark:border-gray-800 overflow-hidden",
|
|
7672
|
+
className
|
|
7673
|
+
),
|
|
7674
|
+
onClick: handleMainClick,
|
|
7675
|
+
children: [
|
|
7676
|
+
/* @__PURE__ */ jsx28(
|
|
7677
|
+
"button",
|
|
7678
|
+
{
|
|
7679
|
+
onClick: (e) => {
|
|
7680
|
+
e.stopPropagation();
|
|
7681
|
+
setSidebarOpen(!sidebarOpen);
|
|
7682
|
+
},
|
|
7683
|
+
className: "md:hidden fixed bottom-4 left-4 z-50 p-3 bg-blue-600 text-white rounded-full shadow-lg hover:bg-blue-700 transition-colors",
|
|
7684
|
+
children: sidebarOpen ? /* @__PURE__ */ jsx28(X9, { className: "w-6 h-6" }) : /* @__PURE__ */ jsx28(Menu3, { className: "w-6 h-6" })
|
|
7685
|
+
}
|
|
7686
|
+
),
|
|
7687
|
+
sidebarOpen && /* @__PURE__ */ jsx28(
|
|
7688
|
+
"div",
|
|
7689
|
+
{
|
|
7690
|
+
className: "md:hidden fixed inset-0 bg-black/50 z-40",
|
|
7691
|
+
onClick: () => setSidebarOpen(false)
|
|
7692
|
+
}
|
|
7693
|
+
),
|
|
7694
|
+
/* @__PURE__ */ jsxs23(
|
|
7695
|
+
"aside",
|
|
7696
|
+
{
|
|
7697
|
+
className: cn(
|
|
7698
|
+
"w-64 border-r border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/50 flex-shrink-0",
|
|
7699
|
+
"md:relative md:translate-x-0",
|
|
7700
|
+
"fixed inset-y-0 left-0 z-50 transition-transform duration-300",
|
|
7701
|
+
sidebarOpen ? "translate-x-0" : "-translate-x-full md:translate-x-0"
|
|
7702
|
+
),
|
|
7703
|
+
children: [
|
|
7704
|
+
/* @__PURE__ */ jsx28("div", { className: "p-3 border-b border-gray-200 dark:border-gray-800", children: /* @__PURE__ */ jsx28("h2", { className: "text-sm font-semibold text-gray-900 dark:text-gray-100", children: "Dossiers" }) }),
|
|
7705
|
+
/* @__PURE__ */ jsx28(FolderTree, {})
|
|
7706
|
+
]
|
|
7707
|
+
}
|
|
7708
|
+
),
|
|
7709
|
+
/* @__PURE__ */ jsxs23("main", { className: "flex-1 flex flex-col min-w-0", children: [
|
|
7710
|
+
/* @__PURE__ */ jsxs23("header", { className: "p-4 border-b border-gray-200 dark:border-gray-800 space-y-3", children: [
|
|
7711
|
+
/* @__PURE__ */ jsx28(Toolbar, {}),
|
|
7712
|
+
/* @__PURE__ */ jsx28(Breadcrumb, {})
|
|
7713
|
+
] }),
|
|
7714
|
+
viewMode === "grid" ? /* @__PURE__ */ jsx28(FileGrid, {}) : /* @__PURE__ */ jsx28(FileList, {})
|
|
7715
|
+
] }),
|
|
7716
|
+
/* @__PURE__ */ jsx28(ContextMenu, {})
|
|
7717
|
+
]
|
|
7718
|
+
}
|
|
7719
|
+
);
|
|
7720
|
+
};
|
|
7721
|
+
var FileManager = (props) => {
|
|
7722
|
+
return /* @__PURE__ */ jsx28(FileManagerProvider, { ...props, children: /* @__PURE__ */ jsx28(FileManagerContent, { className: props.className }) });
|
|
7723
|
+
};
|
|
6606
7724
|
export {
|
|
6607
7725
|
Alert_default as Alert,
|
|
6608
7726
|
AlertProvider,
|
|
@@ -6618,6 +7736,8 @@ export {
|
|
|
6618
7736
|
FDrawer,
|
|
6619
7737
|
FetchApi,
|
|
6620
7738
|
FileInput,
|
|
7739
|
+
FileManager,
|
|
7740
|
+
FileManagerProvider,
|
|
6621
7741
|
ForeignCurrencySelector,
|
|
6622
7742
|
InputField,
|
|
6623
7743
|
InvoiceTypeSelector,
|
|
@@ -6642,7 +7762,11 @@ export {
|
|
|
6642
7762
|
Toast_default as ToastContainer,
|
|
6643
7763
|
ToastProvider,
|
|
6644
7764
|
UserServices,
|
|
7765
|
+
formatDate,
|
|
7766
|
+
formatFileSize,
|
|
7767
|
+
getFileIcon,
|
|
6645
7768
|
useAlert,
|
|
7769
|
+
useFileManager,
|
|
6646
7770
|
useSession,
|
|
6647
7771
|
useToast
|
|
6648
7772
|
};
|