@antdv-next/x 1.0.2 → 1.1.1
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/attachments/index.js +2 -1
- package/dist/folder/DirectoryTree.d.ts +124 -0
- package/dist/folder/DirectoryTree.js +128 -0
- package/dist/folder/FilePreview.d.ts +125 -0
- package/dist/folder/FilePreview.js +170 -0
- package/dist/folder/Folder.d.ts +209 -0
- package/dist/folder/Folder.js +337 -0
- package/dist/folder/index.d.ts +3 -0
- package/dist/folder/index.js +5 -0
- package/dist/folder/interface.d.ts +78 -0
- package/dist/folder/interface.js +0 -0
- package/dist/folder/style/folder.d.ts +7 -0
- package/dist/folder/style/folder.js +89 -0
- package/dist/folder/style/index.d.ts +11 -0
- package/dist/folder/style/index.js +11 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/index.umd.js +755 -35
- package/dist/package.js +1 -1
- package/dist/sender/Sender.d.ts +4 -2
- package/dist/sender/Sender.js +5 -2
- package/dist/sources/Sources.d.ts +2 -1
- package/dist/sources/Sources.js +2 -1
- package/dist/suggestion/Suggestion.d.ts +2 -1
- package/dist/suggestion/Suggestion.js +6 -1
- package/dist/theme/interface/components.d.ts +2 -3
- package/dist/x-provider/context.d.ts +2 -0
- package/dist/x-provider/hooks/use-x-provider-context.d.ts +2 -2
- package/es/{Serializer-y_SfSPKv.js → Serializer-D1JYN1kI.js} +4 -4
- package/es/{_basePickBy-Cy7KVmkk.js → _basePickBy-DFHEGO2M.js} +23 -23
- package/es/{_baseUniq-Ch3HuHeT.js → _baseUniq-BlS7rXTs.js} +83 -83
- package/es/antdv-next-x.esm.js +10909 -7977
- package/es/{arc-caEkbRYF.js → arc-BuXEd18J.js} +3 -3
- package/es/architecture-PBZL5I3N-D7tS55xM.js +3 -0
- package/es/{architectureDiagram-2XIMDMQ5-B4BHdsAL.js → architectureDiagram-2XIMDMQ5-CmfsCwJk.js} +9 -9
- package/es/{blockDiagram-WCTKOSBZ-nXanZ0sc.js → blockDiagram-WCTKOSBZ-lJAan65A.js} +12 -12
- package/es/{c4Diagram-IC4MRINW-C-gVp6th.js → c4Diagram-IC4MRINW-B1c2x_1Q.js} +6 -6
- package/es/channel-DFgF_2F7.js +5 -0
- package/es/{chunk-4BX2VUAB-fLFD6XW0.js → chunk-4BX2VUAB-J2N81Fpp.js} +2 -2
- package/es/{chunk-55IACEB6-OtyKJzCH.js → chunk-55IACEB6-DGtfGRgi.js} +2 -2
- package/es/{chunk-7E7YKBS2-C1dd36rm.js → chunk-7E7YKBS2-CL2d4WAf.js} +2 -2
- package/es/{chunk-7R4GIKGN-DuTRhdsf.js → chunk-7R4GIKGN-QT6IorJ_.js} +3 -3
- package/es/{chunk-C72U2L5F-ClmZGhFC.js → chunk-C72U2L5F-OHTVpS-m.js} +2 -2
- package/es/{chunk-EGIJ26TM-Bar_u1MN.js → chunk-EGIJ26TM-DyMPGYrB.js} +2 -2
- package/es/{chunk-FMBD7UC4-C_uJ_JJA.js → chunk-FMBD7UC4-DCcRjunY.js} +2 -2
- package/es/{chunk-GEFDOKGD-P7WhyrTU.js → chunk-GEFDOKGD-BWpC-zoH.js} +30 -30
- package/es/{chunk-GLR3WWYH-BvazRgdo.js → chunk-GLR3WWYH-DiXcKb5Y.js} +8 -8
- package/es/{chunk-HHEYEP7N-rv5s5WD4.js → chunk-HHEYEP7N-Cxc7E4dX.js} +3 -3
- package/es/{chunk-JSJVCQXG-89HUGe9V.js → chunk-JSJVCQXG-D8_heHOp.js} +4 -4
- package/es/{chunk-KX2RTZJC-pMHnNRQg.js → chunk-KX2RTZJC-D5cc4rj6.js} +3 -3
- package/es/{chunk-KYZI473N-DJmSs1gK.js → chunk-KYZI473N-BHJ3T5Zv.js} +8 -8
- package/es/{chunk-L3YUKLVL-Ck54qytQ.js → chunk-L3YUKLVL-7oGaUOdc.js} +2 -2
- package/es/{chunk-MX3YWQON-MkpK3uBD.js → chunk-MX3YWQON-BxE-Aq9c.js} +2 -2
- package/es/{chunk-NQ4KR5QH-DGshodQv.js → chunk-NQ4KR5QH-EYQBXkqP.js} +7 -7
- package/es/{chunk-O4XLMI2P-e-ZzDQwg.js → chunk-O4XLMI2P-qjOoGpnx.js} +11 -11
- package/es/{chunk-OZEHJAEY-DULNd43V.js → chunk-OZEHJAEY-D82nx27s.js} +2 -2
- package/es/{chunk-PQ6SQG4A-CQ9Csv7s.js → chunk-PQ6SQG4A-D3jtNCWN.js} +3 -3
- package/es/{chunk-PU5JKC2W-DkEFvrjH.js → chunk-PU5JKC2W-DdP8BS-S.js} +16 -16
- package/es/{chunk-QZHKN3VN-qww1plfw.js → chunk-QZHKN3VN-CW3cFN-h.js} +2 -2
- package/es/{chunk-R5LLSJPH-BERXSDGJ.js → chunk-R5LLSJPH-CreI2kO9.js} +2 -2
- package/es/{chunk-WL4C6EOR-C-d8WPS7.js → chunk-WL4C6EOR-BDbxJyGk.js} +9 -9
- package/es/{chunk-XIRO2GV7-CFHofxVB.js → chunk-XIRO2GV7-S5KkbVnN.js} +2 -2
- package/es/{chunk-XPW4576I-DgvoNZkW.js → chunk-XPW4576I-B0KVSHwE.js} +2 -2
- package/es/{chunk-XZSTWKYB-k8_EXrSa.js → chunk-XZSTWKYB-CucN1XvM.js} +93 -93
- package/es/{chunk-YBOYWFTD-BUW4AzEX.js → chunk-YBOYWFTD-CvaddD9G.js} +4 -4
- package/es/classDiagram-VBA2DB6C-Co3LMmg8.js +29 -0
- package/es/classDiagram-v2-RAHNMMFH-BZscgdF2.js +29 -0
- package/es/clone-r3YukIBB.js +8 -0
- package/es/{cose-bilkent-S5V4N54A-CnrS2OC1.js → cose-bilkent-S5V4N54A-B5OQuIhl.js} +3 -3
- package/es/{cytoscape.esm-BY3wHcbp.js → cytoscape.esm-i2CZcWd-.js} +1 -1
- package/es/{dagre-BJOzGlhW.js → dagre-5aGJFKmT.js} +57 -57
- package/es/{dagre-KLK3FWXG-CFC0naVr.js → dagre-KLK3FWXG-BI5QQMXo.js} +16 -16
- package/es/{defaultLocale-BaPFSbai.js → defaultLocale-bckJcYh1.js} +12 -12
- package/es/{diagram-E7M64L7V-DxuJj8ZG.js → diagram-E7M64L7V-Dz62Vz_a.js} +32 -32
- package/es/{diagram-IFDJBPK2-BOpPZ6pu.js → diagram-IFDJBPK2-9fjvFkSc.js} +7 -7
- package/es/{diagram-P4PSJMXO--ChDmcya.js → diagram-P4PSJMXO-BlX6jFjZ.js} +7 -7
- package/es/{dist-DltyvPj3.js → dist-BX_roQzC.js} +1 -1
- package/es/{erDiagram-INFDFZHY-BA3m-v87.js → erDiagram-INFDFZHY-BcRXu8Cp.js} +14 -14
- package/es/{flowDiagram-PKNHOUZH-BCq6k3kr.js → flowDiagram-PKNHOUZH-UeyfgU8z.js} +17 -17
- package/es/{ganttDiagram-A5KZAMGK-DdMePS21.js → ganttDiagram-A5KZAMGK-txCzqgQ5.js} +28 -28
- package/es/gitGraph-HDMCJU4V-CxsS0Qr1.js +3 -0
- package/es/{gitGraphDiagram-K3NZZRJ6-CLbRwChG.js → gitGraphDiagram-K3NZZRJ6-DghWYaFU.js} +7 -7
- package/es/{graphlib-C7ysKz4u.js → graphlib-dRkI1OCL.js} +4 -4
- package/es/{html-C2-_98S6.js → html-B6UxjOv0.js} +1 -1
- package/es/html-Hb1oe8XT.js +2 -0
- package/es/info-3K5VOQVL-COqdvM99.js +3 -0
- package/es/{infoDiagram-LFFYTUFH-DQAZ-vFk.js → infoDiagram-LFFYTUFH-CA-vlAvP.js} +5 -5
- package/es/{init-PAs0hR-b.js → init-B75p2clj.js} +1 -1
- package/es/{isArrayLikeObject-y3HlYDaX.js → isArrayLikeObject-jl2bjkAJ.js} +80 -80
- package/es/{isEmpty-2JxdWtc-.js → isEmpty-CmA-HYrg.js} +3 -3
- package/es/{ishikawaDiagram-PHBUUO56-B0r2IgGz.js → ishikawaDiagram-PHBUUO56-DjdpS9Lb.js} +6 -6
- package/es/{journeyDiagram-4ABVD52K-DnMUhOvg.js → journeyDiagram-4ABVD52K-CIJfC1fp.js} +6 -6
- package/es/{kanban-definition-K7BYSVSG-Da5Y-nJy.js → kanban-definition-K7BYSVSG-CC2vwGck.js} +11 -11
- package/es/{katex-b-xdokOf.js → katex-DCMiIo1z.js} +1 -1
- package/es/{line-h2iCTGsE.js → line-Cu9NTacD.js} +4 -4
- package/es/{linear-Bv7XrZCH.js → linear-C0rAYYmp.js} +23 -23
- package/es/{math-DPzKeDKn.js → math-CoDOuve-.js} +1 -1
- package/es/{mermaid-parser.core-kTgpNO7M.js → mermaid-parser.core-7Wn2L29P.js} +16 -16
- package/es/{mermaid.core-Db1VE3-f.js → mermaid.core-Bvy_Q6Hu.js} +44 -44
- package/es/{mindmap-definition-YRQLILUH-CYeqnCde.js → mindmap-definition-YRQLILUH-BzTYDYmK.js} +16 -16
- package/es/{ordinal-D8PKtxfM.js → ordinal-F3U6aXtP.js} +3 -3
- package/es/packet-RMMSAZCW-2PTjWKLd.js +3 -0
- package/es/{path-DZ-6AyWK.js → path-Dm3C8WEs.js} +3 -3
- package/es/pie-UPGHQEXC-Du8-k-EA.js +3 -0
- package/es/{pieDiagram-SKSYHLDU-DAsfTGvY.js → pieDiagram-SKSYHLDU-COvqE_C6.js} +14 -14
- package/es/{quadrantDiagram-337W2JSQ-CZLbmQS4.js → quadrantDiagram-337W2JSQ-Dgv8ccjt.js} +4 -4
- package/es/radar-KQ55EAFF-jJOhyjxC.js +3 -0
- package/es/{requirementDiagram-Z7DCOOCP-Cb_Ygnfe.js → requirementDiagram-Z7DCOOCP-B2NyhxO-.js} +13 -13
- package/es/{rough.esm-C_hJ3ICT.js → rough.esm-BhGP2Udb.js} +1 -1
- package/es/{sankeyDiagram-WA2Y5GQK-DBe5YfW4.js → sankeyDiagram-WA2Y5GQK-BfnH_gpl.js} +18 -18
- package/es/{sequenceDiagram-2WXFIKYE-C_KUoojT.js → sequenceDiagram-2WXFIKYE-DXssVQOF.js} +8 -8
- package/es/{src-BukXhifV.js → src-CUQ6oOYk.js} +86 -86
- package/es/{stateDiagram-RAJIS63D-boG6DyfW.js → stateDiagram-RAJIS63D-DvDLfupV.js} +17 -17
- package/es/stateDiagram-v2-FVOUBMTO-DIXyaX9W.js +27 -0
- package/es/{timeline-definition-YZTLITO2-pFt6rZ6S.js → timeline-definition-YZTLITO2-ErcRjbZf.js} +4 -4
- package/es/treemap-KZPCXAKY-CvZAIYVa.js +3 -0
- package/es/{vennDiagram-LZ73GAT5-VaCO6k4H.js → vennDiagram-LZ73GAT5-CDTZUtc8.js} +7 -7
- package/es/{vue-DTiWrQBM.js → vue-2aJw7p5p.js} +2 -2
- package/es/{vue-html-BG3Xflut.js → vue-html-DEjI8X9t.js} +1 -1
- package/es/{xychartDiagram-JWTSCODW-xS5ybemA.js → xychartDiagram-JWTSCODW-Y21jBOTg.js} +12 -12
- package/package.json +1 -1
- package/es/architecture-PBZL5I3N-DHfBr78A.js +0 -3
- package/es/channel-DoEe9DF9.js +0 -5
- package/es/classDiagram-VBA2DB6C-DWTAs0Zm.js +0 -29
- package/es/classDiagram-v2-RAHNMMFH-CoxCdmrt.js +0 -29
- package/es/clone-BXDbKCDu.js +0 -8
- package/es/gitGraph-HDMCJU4V-DbzpICZW.js +0 -3
- package/es/html-JbFqcNgP.js +0 -2
- package/es/info-3K5VOQVL-CpUiQuel.js +0 -3
- package/es/packet-RMMSAZCW-UTFQ0FQx.js +0 -3
- package/es/pie-UPGHQEXC-CarAcBSi.js +0 -3
- package/es/radar-KQ55EAFF-NXK5PC9R.js +0 -3
- package/es/stateDiagram-v2-FVOUBMTO-DHCajhrN.js +0 -27
- package/es/treemap-KZPCXAKY-Cj9QakFB.js +0 -3
|
@@ -118,7 +118,7 @@ var XAttachments = /* @__PURE__ */ defineComponent({
|
|
|
118
118
|
default: true
|
|
119
119
|
}
|
|
120
120
|
},
|
|
121
|
-
emits: ["change"],
|
|
121
|
+
emits: ["update:items", "change"],
|
|
122
122
|
setup(props, { attrs, emit, slots, expose }) {
|
|
123
123
|
const configCtx = useConfig();
|
|
124
124
|
const contextConfig = useXComponentConfig("attachments");
|
|
@@ -142,6 +142,7 @@ var XAttachments = /* @__PURE__ */ defineComponent({
|
|
|
142
142
|
});
|
|
143
143
|
const triggerChange = (info) => {
|
|
144
144
|
fileList.value = info.fileList;
|
|
145
|
+
emit("update:items", info.fileList);
|
|
145
146
|
emit("change", info);
|
|
146
147
|
};
|
|
147
148
|
const onUploadChange = (info) => {
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { PropType, VNodeChild } from 'vue';
|
|
2
|
+
import { DirectoryIconsMap, DirectoryTitleRender, FolderProps, FolderTreeData } from './interface';
|
|
3
|
+
export interface DirectoryTreeNode {
|
|
4
|
+
key: string;
|
|
5
|
+
path: string;
|
|
6
|
+
pathSegments: string[];
|
|
7
|
+
title: VNodeChild;
|
|
8
|
+
icon?: VNodeChild;
|
|
9
|
+
isLeaf?: boolean;
|
|
10
|
+
content?: string;
|
|
11
|
+
children?: DirectoryTreeNode[];
|
|
12
|
+
}
|
|
13
|
+
export interface DirectoryTreeProps {
|
|
14
|
+
prefixCls: string;
|
|
15
|
+
treeData: FolderTreeData[];
|
|
16
|
+
directoryIcons?: DirectoryIconsMap;
|
|
17
|
+
selectedKeys?: string[];
|
|
18
|
+
expandedKeys?: string[];
|
|
19
|
+
defaultExpandAll?: boolean;
|
|
20
|
+
showLine?: boolean;
|
|
21
|
+
classes?: FolderProps["classes"];
|
|
22
|
+
styles?: FolderProps["styles"];
|
|
23
|
+
directoryTitle?: DirectoryTitleRender;
|
|
24
|
+
}
|
|
25
|
+
declare const FolderDirectoryTree: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
26
|
+
prefixCls: {
|
|
27
|
+
type: StringConstructor;
|
|
28
|
+
required: true;
|
|
29
|
+
};
|
|
30
|
+
treeData: {
|
|
31
|
+
type: PropType<FolderTreeData[]>;
|
|
32
|
+
default: () => never[];
|
|
33
|
+
};
|
|
34
|
+
directoryIcons: {
|
|
35
|
+
type: PropType<DirectoryIconsMap>;
|
|
36
|
+
default: undefined;
|
|
37
|
+
};
|
|
38
|
+
selectedKeys: {
|
|
39
|
+
type: PropType<string[]>;
|
|
40
|
+
default: () => never[];
|
|
41
|
+
};
|
|
42
|
+
expandedKeys: {
|
|
43
|
+
type: PropType<string[] | undefined>;
|
|
44
|
+
default: undefined;
|
|
45
|
+
};
|
|
46
|
+
defaultExpandAll: {
|
|
47
|
+
type: BooleanConstructor;
|
|
48
|
+
default: boolean;
|
|
49
|
+
};
|
|
50
|
+
showLine: {
|
|
51
|
+
type: BooleanConstructor;
|
|
52
|
+
default: boolean;
|
|
53
|
+
};
|
|
54
|
+
classes: {
|
|
55
|
+
type: PropType<FolderProps["classes"]>;
|
|
56
|
+
default: () => {};
|
|
57
|
+
};
|
|
58
|
+
styles: {
|
|
59
|
+
type: PropType<FolderProps["styles"]>;
|
|
60
|
+
default: () => {};
|
|
61
|
+
};
|
|
62
|
+
directoryTitle: {
|
|
63
|
+
type: PropType<DirectoryTitleRender>;
|
|
64
|
+
default: undefined;
|
|
65
|
+
};
|
|
66
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
67
|
+
select: (_keys: string[], _info: any) => true;
|
|
68
|
+
expand: (_keys: string[], _info: any) => true;
|
|
69
|
+
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
70
|
+
prefixCls: {
|
|
71
|
+
type: StringConstructor;
|
|
72
|
+
required: true;
|
|
73
|
+
};
|
|
74
|
+
treeData: {
|
|
75
|
+
type: PropType<FolderTreeData[]>;
|
|
76
|
+
default: () => never[];
|
|
77
|
+
};
|
|
78
|
+
directoryIcons: {
|
|
79
|
+
type: PropType<DirectoryIconsMap>;
|
|
80
|
+
default: undefined;
|
|
81
|
+
};
|
|
82
|
+
selectedKeys: {
|
|
83
|
+
type: PropType<string[]>;
|
|
84
|
+
default: () => never[];
|
|
85
|
+
};
|
|
86
|
+
expandedKeys: {
|
|
87
|
+
type: PropType<string[] | undefined>;
|
|
88
|
+
default: undefined;
|
|
89
|
+
};
|
|
90
|
+
defaultExpandAll: {
|
|
91
|
+
type: BooleanConstructor;
|
|
92
|
+
default: boolean;
|
|
93
|
+
};
|
|
94
|
+
showLine: {
|
|
95
|
+
type: BooleanConstructor;
|
|
96
|
+
default: boolean;
|
|
97
|
+
};
|
|
98
|
+
classes: {
|
|
99
|
+
type: PropType<FolderProps["classes"]>;
|
|
100
|
+
default: () => {};
|
|
101
|
+
};
|
|
102
|
+
styles: {
|
|
103
|
+
type: PropType<FolderProps["styles"]>;
|
|
104
|
+
default: () => {};
|
|
105
|
+
};
|
|
106
|
+
directoryTitle: {
|
|
107
|
+
type: PropType<DirectoryTitleRender>;
|
|
108
|
+
default: undefined;
|
|
109
|
+
};
|
|
110
|
+
}>> & Readonly<{
|
|
111
|
+
onSelect?: ((_keys: string[], _info: any) => any) | undefined;
|
|
112
|
+
onExpand?: ((_keys: string[], _info: any) => any) | undefined;
|
|
113
|
+
}>, {
|
|
114
|
+
classes: Partial<Record<import('./interface').SemanticType, string>> | undefined;
|
|
115
|
+
styles: Partial<Record<import('./interface').SemanticType, import('vue').CSSProperties>> | undefined;
|
|
116
|
+
selectedKeys: string[];
|
|
117
|
+
directoryTitle: DirectoryTitleRender;
|
|
118
|
+
expandedKeys: string[] | undefined;
|
|
119
|
+
treeData: FolderTreeData[];
|
|
120
|
+
directoryIcons: DirectoryIconsMap;
|
|
121
|
+
defaultExpandAll: boolean;
|
|
122
|
+
showLine: boolean;
|
|
123
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
124
|
+
export default FolderDirectoryTree;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Fragment, computed, createVNode, defineComponent } from "vue";
|
|
2
|
+
import { DirectoryTree } from "antdv-next";
|
|
3
|
+
import { FileOutlined, FolderOutlined } from "@antdv-next/icons";
|
|
4
|
+
//#region components/folder/DirectoryTree.tsx
|
|
5
|
+
function isFolder(node) {
|
|
6
|
+
return !!node.children && node.children.length > 0;
|
|
7
|
+
}
|
|
8
|
+
function buildPathSegments(node, parentSegments) {
|
|
9
|
+
if (node.path === "/" && parentSegments.length === 0) return ["/"];
|
|
10
|
+
return [...parentSegments, node.path].filter((seg) => seg !== "");
|
|
11
|
+
}
|
|
12
|
+
function getIcon(node, directoryIcons) {
|
|
13
|
+
if (directoryIcons === false || directoryIcons === null) return null;
|
|
14
|
+
if (isFolder(node)) {
|
|
15
|
+
const icon = directoryIcons?.directory;
|
|
16
|
+
if (typeof icon === "function") return icon();
|
|
17
|
+
return icon ?? createVNode(FolderOutlined, null, null);
|
|
18
|
+
}
|
|
19
|
+
const ext = node.path.toLowerCase().split(".").pop();
|
|
20
|
+
if (ext) {
|
|
21
|
+
const icon = directoryIcons?.[ext];
|
|
22
|
+
if (icon) return typeof icon === "function" ? icon() : icon;
|
|
23
|
+
}
|
|
24
|
+
return createVNode(FileOutlined, null, null);
|
|
25
|
+
}
|
|
26
|
+
function convertToTreeData(nodes, directoryIcons, parentSegments = []) {
|
|
27
|
+
return nodes.map((node) => {
|
|
28
|
+
const pathSegments = buildPathSegments(node, parentSegments);
|
|
29
|
+
const fullPath = pathSegments.join("/").replace(/^\/+/, "");
|
|
30
|
+
return {
|
|
31
|
+
key: fullPath,
|
|
32
|
+
path: fullPath,
|
|
33
|
+
pathSegments,
|
|
34
|
+
title: node.title,
|
|
35
|
+
icon: getIcon(node, directoryIcons),
|
|
36
|
+
isLeaf: !isFolder(node),
|
|
37
|
+
content: node.content,
|
|
38
|
+
children: node.children ? convertToTreeData(node.children, directoryIcons, pathSegments) : void 0
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
var FolderDirectoryTree = /* @__PURE__ */ defineComponent({
|
|
43
|
+
name: "AxFolderDirectoryTree",
|
|
44
|
+
props: {
|
|
45
|
+
prefixCls: {
|
|
46
|
+
type: String,
|
|
47
|
+
required: true
|
|
48
|
+
},
|
|
49
|
+
treeData: {
|
|
50
|
+
type: Array,
|
|
51
|
+
default: () => []
|
|
52
|
+
},
|
|
53
|
+
directoryIcons: {
|
|
54
|
+
type: [Boolean, Object],
|
|
55
|
+
default: void 0
|
|
56
|
+
},
|
|
57
|
+
selectedKeys: {
|
|
58
|
+
type: Array,
|
|
59
|
+
default: () => []
|
|
60
|
+
},
|
|
61
|
+
expandedKeys: {
|
|
62
|
+
type: Array,
|
|
63
|
+
default: void 0
|
|
64
|
+
},
|
|
65
|
+
defaultExpandAll: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: true
|
|
68
|
+
},
|
|
69
|
+
showLine: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
default: false
|
|
72
|
+
},
|
|
73
|
+
classes: {
|
|
74
|
+
type: Object,
|
|
75
|
+
default: () => ({})
|
|
76
|
+
},
|
|
77
|
+
styles: {
|
|
78
|
+
type: Object,
|
|
79
|
+
default: () => ({})
|
|
80
|
+
},
|
|
81
|
+
directoryTitle: {
|
|
82
|
+
type: [
|
|
83
|
+
Boolean,
|
|
84
|
+
String,
|
|
85
|
+
Number,
|
|
86
|
+
Object,
|
|
87
|
+
Array,
|
|
88
|
+
Function
|
|
89
|
+
],
|
|
90
|
+
default: void 0
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
emits: {
|
|
94
|
+
select: (_keys, _info) => true,
|
|
95
|
+
expand: (_keys, _info) => true
|
|
96
|
+
},
|
|
97
|
+
setup(props, { emit }) {
|
|
98
|
+
const treeDataConverted = computed(() => convertToTreeData(props.treeData, props.directoryIcons));
|
|
99
|
+
const titleNode = computed(() => {
|
|
100
|
+
const t = props.directoryTitle;
|
|
101
|
+
if (t === false || t === null || t === void 0) return null;
|
|
102
|
+
if (typeof t === "function") return t();
|
|
103
|
+
return t;
|
|
104
|
+
});
|
|
105
|
+
return () => {
|
|
106
|
+
const { prefixCls } = props;
|
|
107
|
+
return createVNode(Fragment, null, [titleNode.value ? createVNode("div", {
|
|
108
|
+
"class": [`${prefixCls}-directory-tree-title`, props.classes?.directoryTitle],
|
|
109
|
+
"style": props.styles?.directoryTitle
|
|
110
|
+
}, [titleNode.value]) : null, createVNode(DirectoryTree, {
|
|
111
|
+
treeData: treeDataConverted.value,
|
|
112
|
+
selectedKeys: props.selectedKeys,
|
|
113
|
+
expandedKeys: props.expandedKeys,
|
|
114
|
+
multiple: false,
|
|
115
|
+
blockNode: true,
|
|
116
|
+
showLine: props.showLine,
|
|
117
|
+
defaultExpandAll: props.defaultExpandAll,
|
|
118
|
+
class: [`${prefixCls}-directory-tree-content`, props.classes?.directoryTree],
|
|
119
|
+
style: props.styles?.directoryTree,
|
|
120
|
+
classes: { itemTitle: `${prefixCls}-directory-tree-item-title` },
|
|
121
|
+
onSelect: (keys, info) => emit("select", keys, info),
|
|
122
|
+
onExpand: (keys, info) => emit("expand", keys, info)
|
|
123
|
+
}, null)]);
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
//#endregion
|
|
128
|
+
export { FolderDirectoryTree as default };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { CSSProperties, PropType } from 'vue';
|
|
2
|
+
import { EmptyRender, FolderProps, FolderTreeData, PreviewRender, PreviewTitleRender } from './interface';
|
|
3
|
+
export interface FilePreviewProps {
|
|
4
|
+
prefixCls: string;
|
|
5
|
+
classes?: FolderProps["classes"];
|
|
6
|
+
styles?: FolderProps["styles"];
|
|
7
|
+
selectedFile?: string[] | null;
|
|
8
|
+
fileContent?: string;
|
|
9
|
+
loading?: boolean;
|
|
10
|
+
previewTitle?: PreviewTitleRender;
|
|
11
|
+
previewRender?: PreviewRender;
|
|
12
|
+
emptyRender?: EmptyRender;
|
|
13
|
+
getFileNode?: (path: string[]) => {
|
|
14
|
+
title: FolderTreeData["title"];
|
|
15
|
+
path: string;
|
|
16
|
+
content?: string;
|
|
17
|
+
} | undefined;
|
|
18
|
+
}
|
|
19
|
+
declare const FilePreview: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
20
|
+
prefixCls: {
|
|
21
|
+
type: StringConstructor;
|
|
22
|
+
required: true;
|
|
23
|
+
};
|
|
24
|
+
classes: {
|
|
25
|
+
type: PropType<FilePreviewProps["classes"]>;
|
|
26
|
+
default: () => {};
|
|
27
|
+
};
|
|
28
|
+
styles: {
|
|
29
|
+
type: PropType<FilePreviewProps["styles"]>;
|
|
30
|
+
default: () => {};
|
|
31
|
+
};
|
|
32
|
+
style: {
|
|
33
|
+
type: PropType<CSSProperties>;
|
|
34
|
+
default: undefined;
|
|
35
|
+
};
|
|
36
|
+
selectedFile: {
|
|
37
|
+
type: PropType<string[] | null>;
|
|
38
|
+
default: () => never[];
|
|
39
|
+
};
|
|
40
|
+
fileContent: {
|
|
41
|
+
type: StringConstructor;
|
|
42
|
+
default: string;
|
|
43
|
+
};
|
|
44
|
+
loading: {
|
|
45
|
+
type: BooleanConstructor;
|
|
46
|
+
default: boolean;
|
|
47
|
+
};
|
|
48
|
+
previewTitle: {
|
|
49
|
+
type: PropType<PreviewTitleRender>;
|
|
50
|
+
default: undefined;
|
|
51
|
+
};
|
|
52
|
+
previewRender: {
|
|
53
|
+
type: PropType<PreviewRender>;
|
|
54
|
+
default: undefined;
|
|
55
|
+
};
|
|
56
|
+
emptyRender: {
|
|
57
|
+
type: PropType<EmptyRender>;
|
|
58
|
+
default: undefined;
|
|
59
|
+
};
|
|
60
|
+
getFileNode: {
|
|
61
|
+
type: PropType<FilePreviewProps["getFileNode"]>;
|
|
62
|
+
default: undefined;
|
|
63
|
+
};
|
|
64
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
65
|
+
prefixCls: {
|
|
66
|
+
type: StringConstructor;
|
|
67
|
+
required: true;
|
|
68
|
+
};
|
|
69
|
+
classes: {
|
|
70
|
+
type: PropType<FilePreviewProps["classes"]>;
|
|
71
|
+
default: () => {};
|
|
72
|
+
};
|
|
73
|
+
styles: {
|
|
74
|
+
type: PropType<FilePreviewProps["styles"]>;
|
|
75
|
+
default: () => {};
|
|
76
|
+
};
|
|
77
|
+
style: {
|
|
78
|
+
type: PropType<CSSProperties>;
|
|
79
|
+
default: undefined;
|
|
80
|
+
};
|
|
81
|
+
selectedFile: {
|
|
82
|
+
type: PropType<string[] | null>;
|
|
83
|
+
default: () => never[];
|
|
84
|
+
};
|
|
85
|
+
fileContent: {
|
|
86
|
+
type: StringConstructor;
|
|
87
|
+
default: string;
|
|
88
|
+
};
|
|
89
|
+
loading: {
|
|
90
|
+
type: BooleanConstructor;
|
|
91
|
+
default: boolean;
|
|
92
|
+
};
|
|
93
|
+
previewTitle: {
|
|
94
|
+
type: PropType<PreviewTitleRender>;
|
|
95
|
+
default: undefined;
|
|
96
|
+
};
|
|
97
|
+
previewRender: {
|
|
98
|
+
type: PropType<PreviewRender>;
|
|
99
|
+
default: undefined;
|
|
100
|
+
};
|
|
101
|
+
emptyRender: {
|
|
102
|
+
type: PropType<EmptyRender>;
|
|
103
|
+
default: undefined;
|
|
104
|
+
};
|
|
105
|
+
getFileNode: {
|
|
106
|
+
type: PropType<FilePreviewProps["getFileNode"]>;
|
|
107
|
+
default: undefined;
|
|
108
|
+
};
|
|
109
|
+
}>> & Readonly<{}>, {
|
|
110
|
+
style: CSSProperties;
|
|
111
|
+
loading: boolean;
|
|
112
|
+
classes: Partial<Record<import('./interface').SemanticType, string>> | undefined;
|
|
113
|
+
styles: Partial<Record<import('./interface').SemanticType, CSSProperties>> | undefined;
|
|
114
|
+
previewTitle: PreviewTitleRender;
|
|
115
|
+
previewRender: PreviewRender;
|
|
116
|
+
getFileNode: ((path: string[]) => {
|
|
117
|
+
title: FolderTreeData["title"];
|
|
118
|
+
path: string;
|
|
119
|
+
content?: string;
|
|
120
|
+
} | undefined) | undefined;
|
|
121
|
+
selectedFile: string[] | null;
|
|
122
|
+
fileContent: string;
|
|
123
|
+
emptyRender: EmptyRender;
|
|
124
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
125
|
+
export default FilePreview;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import useXComponentConfig from "../_utils/hooks/use-x-component-config.js";
|
|
2
|
+
import { XActionsCopy } from "../actions/ActionsCopy.js";
|
|
3
|
+
import localeValues from "../locale/en_US.js";
|
|
4
|
+
import useLocale from "../locale/useLocale.js";
|
|
5
|
+
import code_highlighter_default from "../code-highlighter/index.js";
|
|
6
|
+
import style_default from "./style/index.js";
|
|
7
|
+
import { Fragment, computed, createVNode, defineComponent } from "vue";
|
|
8
|
+
import { Empty, Spin } from "antdv-next";
|
|
9
|
+
//#region components/folder/FilePreview.tsx
|
|
10
|
+
function getFileExtension(path = "") {
|
|
11
|
+
const parts = path.split(".");
|
|
12
|
+
return parts[parts.length - 1] || "";
|
|
13
|
+
}
|
|
14
|
+
function getLanguageFromExtension(ext) {
|
|
15
|
+
return ext.toLowerCase() || "txt";
|
|
16
|
+
}
|
|
17
|
+
var FilePreview = /* @__PURE__ */ defineComponent({
|
|
18
|
+
name: "AxFolderFilePreview",
|
|
19
|
+
props: {
|
|
20
|
+
prefixCls: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true
|
|
23
|
+
},
|
|
24
|
+
classes: {
|
|
25
|
+
type: Object,
|
|
26
|
+
default: () => ({})
|
|
27
|
+
},
|
|
28
|
+
styles: {
|
|
29
|
+
type: Object,
|
|
30
|
+
default: () => ({})
|
|
31
|
+
},
|
|
32
|
+
style: {
|
|
33
|
+
type: Object,
|
|
34
|
+
default: void 0
|
|
35
|
+
},
|
|
36
|
+
selectedFile: {
|
|
37
|
+
type: Array,
|
|
38
|
+
default: () => []
|
|
39
|
+
},
|
|
40
|
+
fileContent: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: ""
|
|
43
|
+
},
|
|
44
|
+
loading: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: false
|
|
47
|
+
},
|
|
48
|
+
previewTitle: {
|
|
49
|
+
type: [
|
|
50
|
+
Boolean,
|
|
51
|
+
String,
|
|
52
|
+
Number,
|
|
53
|
+
Object,
|
|
54
|
+
Array,
|
|
55
|
+
Function
|
|
56
|
+
],
|
|
57
|
+
default: void 0
|
|
58
|
+
},
|
|
59
|
+
previewRender: {
|
|
60
|
+
type: [
|
|
61
|
+
String,
|
|
62
|
+
Number,
|
|
63
|
+
Object,
|
|
64
|
+
Array,
|
|
65
|
+
Function
|
|
66
|
+
],
|
|
67
|
+
default: void 0
|
|
68
|
+
},
|
|
69
|
+
emptyRender: {
|
|
70
|
+
type: [
|
|
71
|
+
Boolean,
|
|
72
|
+
String,
|
|
73
|
+
Number,
|
|
74
|
+
Object,
|
|
75
|
+
Array,
|
|
76
|
+
Function
|
|
77
|
+
],
|
|
78
|
+
default: void 0
|
|
79
|
+
},
|
|
80
|
+
getFileNode: {
|
|
81
|
+
type: Function,
|
|
82
|
+
default: void 0
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
setup(props) {
|
|
86
|
+
const [locale] = useLocale("Folder", localeValues.Folder);
|
|
87
|
+
const contextConfig = useXComponentConfig("folder");
|
|
88
|
+
const [hashId, cssVarCls] = style_default(computed(() => props.prefixCls));
|
|
89
|
+
const previewCls = computed(() => `${props.prefixCls}-preview`);
|
|
90
|
+
const renderOriginContent = (fileContent, language) => createVNode(code_highlighter_default, {
|
|
91
|
+
"content": fileContent.replace(/\n$/, ""),
|
|
92
|
+
"language": language,
|
|
93
|
+
"showLanguage": false,
|
|
94
|
+
"showLineNumbers": false,
|
|
95
|
+
"showCopyButton": false,
|
|
96
|
+
"style": {
|
|
97
|
+
background: "transparent",
|
|
98
|
+
border: 0,
|
|
99
|
+
borderRadius: 0,
|
|
100
|
+
padding: 0
|
|
101
|
+
}
|
|
102
|
+
}, null);
|
|
103
|
+
const renderEmpty = () => {
|
|
104
|
+
if (props.emptyRender === false || props.emptyRender === null) return null;
|
|
105
|
+
const node = typeof props.emptyRender === "function" ? props.emptyRender() : props.emptyRender ?? createVNode(Empty, {
|
|
106
|
+
"image": Empty.PRESENTED_IMAGE_SIMPLE,
|
|
107
|
+
"description": locale.value.selectFile
|
|
108
|
+
}, null);
|
|
109
|
+
return createVNode("div", {
|
|
110
|
+
"class": [`${previewCls.value}-empty-container`, props.classes?.previewRender],
|
|
111
|
+
"style": props.styles?.previewRender
|
|
112
|
+
}, [node]);
|
|
113
|
+
};
|
|
114
|
+
const renderContent = () => {
|
|
115
|
+
if (props.loading) return createVNode("div", {
|
|
116
|
+
"class": [`${previewCls.value}-loading-container`, props.classes?.previewRender],
|
|
117
|
+
"style": props.styles?.previewRender
|
|
118
|
+
}, [createVNode(Spin, null, null)]);
|
|
119
|
+
if (!props.selectedFile || props.selectedFile.length === 0) return renderEmpty();
|
|
120
|
+
const selected = props.selectedFile;
|
|
121
|
+
const fileNode = props.getFileNode?.(selected);
|
|
122
|
+
const title = fileNode?.title ?? selected[selected.length - 1];
|
|
123
|
+
const fileName = selected[selected.length - 1];
|
|
124
|
+
const language = getLanguageFromExtension(getFileExtension(fileName));
|
|
125
|
+
let headerNode;
|
|
126
|
+
if (props.previewTitle === false || props.previewTitle === null) headerNode = null;
|
|
127
|
+
else if (props.previewTitle) headerNode = typeof props.previewTitle === "function" ? props.previewTitle({
|
|
128
|
+
title,
|
|
129
|
+
path: selected,
|
|
130
|
+
content: props.fileContent ?? ""
|
|
131
|
+
}) : props.previewTitle;
|
|
132
|
+
else headerNode = createVNode("div", { "class": `${previewCls.value}-title` }, [createVNode("span", { "class": `${previewCls.value}-filename` }, [title]), createVNode(XActionsCopy, {
|
|
133
|
+
"text": props.fileContent ?? "",
|
|
134
|
+
"class": `${previewCls.value}-copy`
|
|
135
|
+
}, null)]);
|
|
136
|
+
const originNode = renderOriginContent(props.fileContent ?? "", language);
|
|
137
|
+
let contentNode;
|
|
138
|
+
if (props.previewRender !== void 0 && props.previewRender !== null) if (typeof props.previewRender === "function") contentNode = props.previewRender({
|
|
139
|
+
content: props.fileContent,
|
|
140
|
+
path: selected,
|
|
141
|
+
title: fileNode?.title,
|
|
142
|
+
language
|
|
143
|
+
}, { originNode });
|
|
144
|
+
else contentNode = props.previewRender;
|
|
145
|
+
else contentNode = originNode;
|
|
146
|
+
return createVNode(Fragment, null, [headerNode && createVNode("div", {
|
|
147
|
+
"class": [`${previewCls.value}-title-wrapper`, props.classes?.previewTitle],
|
|
148
|
+
"style": props.styles?.previewTitle
|
|
149
|
+
}, [headerNode]), createVNode("div", {
|
|
150
|
+
"class": [`${previewCls.value}-content`, props.classes?.previewRender],
|
|
151
|
+
"style": props.styles?.previewRender
|
|
152
|
+
}, [contentNode])]);
|
|
153
|
+
};
|
|
154
|
+
return () => createVNode("div", {
|
|
155
|
+
"class": [
|
|
156
|
+
`${previewCls.value}`,
|
|
157
|
+
props.classes?.filePreview,
|
|
158
|
+
hashId.value,
|
|
159
|
+
cssVarCls.value
|
|
160
|
+
],
|
|
161
|
+
"style": [
|
|
162
|
+
contextConfig.value.styles?.filePreview,
|
|
163
|
+
props.styles?.filePreview,
|
|
164
|
+
props.style
|
|
165
|
+
]
|
|
166
|
+
}, [renderContent()]);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
//#endregion
|
|
170
|
+
export { FilePreview as default };
|