@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.
Files changed (134) hide show
  1. package/dist/attachments/index.js +2 -1
  2. package/dist/folder/DirectoryTree.d.ts +124 -0
  3. package/dist/folder/DirectoryTree.js +128 -0
  4. package/dist/folder/FilePreview.d.ts +125 -0
  5. package/dist/folder/FilePreview.js +170 -0
  6. package/dist/folder/Folder.d.ts +209 -0
  7. package/dist/folder/Folder.js +337 -0
  8. package/dist/folder/index.d.ts +3 -0
  9. package/dist/folder/index.js +5 -0
  10. package/dist/folder/interface.d.ts +78 -0
  11. package/dist/folder/interface.js +0 -0
  12. package/dist/folder/style/folder.d.ts +7 -0
  13. package/dist/folder/style/folder.js +89 -0
  14. package/dist/folder/style/index.d.ts +11 -0
  15. package/dist/folder/style/index.js +11 -0
  16. package/dist/index.d.ts +3 -1
  17. package/dist/index.js +3 -1
  18. package/dist/index.umd.js +755 -35
  19. package/dist/package.js +1 -1
  20. package/dist/sender/Sender.d.ts +4 -2
  21. package/dist/sender/Sender.js +5 -2
  22. package/dist/sources/Sources.d.ts +2 -1
  23. package/dist/sources/Sources.js +2 -1
  24. package/dist/suggestion/Suggestion.d.ts +2 -1
  25. package/dist/suggestion/Suggestion.js +6 -1
  26. package/dist/theme/interface/components.d.ts +2 -3
  27. package/dist/x-provider/context.d.ts +2 -0
  28. package/dist/x-provider/hooks/use-x-provider-context.d.ts +2 -2
  29. package/es/{Serializer-y_SfSPKv.js → Serializer-D1JYN1kI.js} +4 -4
  30. package/es/{_basePickBy-Cy7KVmkk.js → _basePickBy-DFHEGO2M.js} +23 -23
  31. package/es/{_baseUniq-Ch3HuHeT.js → _baseUniq-BlS7rXTs.js} +83 -83
  32. package/es/antdv-next-x.esm.js +10909 -7977
  33. package/es/{arc-caEkbRYF.js → arc-BuXEd18J.js} +3 -3
  34. package/es/architecture-PBZL5I3N-D7tS55xM.js +3 -0
  35. package/es/{architectureDiagram-2XIMDMQ5-B4BHdsAL.js → architectureDiagram-2XIMDMQ5-CmfsCwJk.js} +9 -9
  36. package/es/{blockDiagram-WCTKOSBZ-nXanZ0sc.js → blockDiagram-WCTKOSBZ-lJAan65A.js} +12 -12
  37. package/es/{c4Diagram-IC4MRINW-C-gVp6th.js → c4Diagram-IC4MRINW-B1c2x_1Q.js} +6 -6
  38. package/es/channel-DFgF_2F7.js +5 -0
  39. package/es/{chunk-4BX2VUAB-fLFD6XW0.js → chunk-4BX2VUAB-J2N81Fpp.js} +2 -2
  40. package/es/{chunk-55IACEB6-OtyKJzCH.js → chunk-55IACEB6-DGtfGRgi.js} +2 -2
  41. package/es/{chunk-7E7YKBS2-C1dd36rm.js → chunk-7E7YKBS2-CL2d4WAf.js} +2 -2
  42. package/es/{chunk-7R4GIKGN-DuTRhdsf.js → chunk-7R4GIKGN-QT6IorJ_.js} +3 -3
  43. package/es/{chunk-C72U2L5F-ClmZGhFC.js → chunk-C72U2L5F-OHTVpS-m.js} +2 -2
  44. package/es/{chunk-EGIJ26TM-Bar_u1MN.js → chunk-EGIJ26TM-DyMPGYrB.js} +2 -2
  45. package/es/{chunk-FMBD7UC4-C_uJ_JJA.js → chunk-FMBD7UC4-DCcRjunY.js} +2 -2
  46. package/es/{chunk-GEFDOKGD-P7WhyrTU.js → chunk-GEFDOKGD-BWpC-zoH.js} +30 -30
  47. package/es/{chunk-GLR3WWYH-BvazRgdo.js → chunk-GLR3WWYH-DiXcKb5Y.js} +8 -8
  48. package/es/{chunk-HHEYEP7N-rv5s5WD4.js → chunk-HHEYEP7N-Cxc7E4dX.js} +3 -3
  49. package/es/{chunk-JSJVCQXG-89HUGe9V.js → chunk-JSJVCQXG-D8_heHOp.js} +4 -4
  50. package/es/{chunk-KX2RTZJC-pMHnNRQg.js → chunk-KX2RTZJC-D5cc4rj6.js} +3 -3
  51. package/es/{chunk-KYZI473N-DJmSs1gK.js → chunk-KYZI473N-BHJ3T5Zv.js} +8 -8
  52. package/es/{chunk-L3YUKLVL-Ck54qytQ.js → chunk-L3YUKLVL-7oGaUOdc.js} +2 -2
  53. package/es/{chunk-MX3YWQON-MkpK3uBD.js → chunk-MX3YWQON-BxE-Aq9c.js} +2 -2
  54. package/es/{chunk-NQ4KR5QH-DGshodQv.js → chunk-NQ4KR5QH-EYQBXkqP.js} +7 -7
  55. package/es/{chunk-O4XLMI2P-e-ZzDQwg.js → chunk-O4XLMI2P-qjOoGpnx.js} +11 -11
  56. package/es/{chunk-OZEHJAEY-DULNd43V.js → chunk-OZEHJAEY-D82nx27s.js} +2 -2
  57. package/es/{chunk-PQ6SQG4A-CQ9Csv7s.js → chunk-PQ6SQG4A-D3jtNCWN.js} +3 -3
  58. package/es/{chunk-PU5JKC2W-DkEFvrjH.js → chunk-PU5JKC2W-DdP8BS-S.js} +16 -16
  59. package/es/{chunk-QZHKN3VN-qww1plfw.js → chunk-QZHKN3VN-CW3cFN-h.js} +2 -2
  60. package/es/{chunk-R5LLSJPH-BERXSDGJ.js → chunk-R5LLSJPH-CreI2kO9.js} +2 -2
  61. package/es/{chunk-WL4C6EOR-C-d8WPS7.js → chunk-WL4C6EOR-BDbxJyGk.js} +9 -9
  62. package/es/{chunk-XIRO2GV7-CFHofxVB.js → chunk-XIRO2GV7-S5KkbVnN.js} +2 -2
  63. package/es/{chunk-XPW4576I-DgvoNZkW.js → chunk-XPW4576I-B0KVSHwE.js} +2 -2
  64. package/es/{chunk-XZSTWKYB-k8_EXrSa.js → chunk-XZSTWKYB-CucN1XvM.js} +93 -93
  65. package/es/{chunk-YBOYWFTD-BUW4AzEX.js → chunk-YBOYWFTD-CvaddD9G.js} +4 -4
  66. package/es/classDiagram-VBA2DB6C-Co3LMmg8.js +29 -0
  67. package/es/classDiagram-v2-RAHNMMFH-BZscgdF2.js +29 -0
  68. package/es/clone-r3YukIBB.js +8 -0
  69. package/es/{cose-bilkent-S5V4N54A-CnrS2OC1.js → cose-bilkent-S5V4N54A-B5OQuIhl.js} +3 -3
  70. package/es/{cytoscape.esm-BY3wHcbp.js → cytoscape.esm-i2CZcWd-.js} +1 -1
  71. package/es/{dagre-BJOzGlhW.js → dagre-5aGJFKmT.js} +57 -57
  72. package/es/{dagre-KLK3FWXG-CFC0naVr.js → dagre-KLK3FWXG-BI5QQMXo.js} +16 -16
  73. package/es/{defaultLocale-BaPFSbai.js → defaultLocale-bckJcYh1.js} +12 -12
  74. package/es/{diagram-E7M64L7V-DxuJj8ZG.js → diagram-E7M64L7V-Dz62Vz_a.js} +32 -32
  75. package/es/{diagram-IFDJBPK2-BOpPZ6pu.js → diagram-IFDJBPK2-9fjvFkSc.js} +7 -7
  76. package/es/{diagram-P4PSJMXO--ChDmcya.js → diagram-P4PSJMXO-BlX6jFjZ.js} +7 -7
  77. package/es/{dist-DltyvPj3.js → dist-BX_roQzC.js} +1 -1
  78. package/es/{erDiagram-INFDFZHY-BA3m-v87.js → erDiagram-INFDFZHY-BcRXu8Cp.js} +14 -14
  79. package/es/{flowDiagram-PKNHOUZH-BCq6k3kr.js → flowDiagram-PKNHOUZH-UeyfgU8z.js} +17 -17
  80. package/es/{ganttDiagram-A5KZAMGK-DdMePS21.js → ganttDiagram-A5KZAMGK-txCzqgQ5.js} +28 -28
  81. package/es/gitGraph-HDMCJU4V-CxsS0Qr1.js +3 -0
  82. package/es/{gitGraphDiagram-K3NZZRJ6-CLbRwChG.js → gitGraphDiagram-K3NZZRJ6-DghWYaFU.js} +7 -7
  83. package/es/{graphlib-C7ysKz4u.js → graphlib-dRkI1OCL.js} +4 -4
  84. package/es/{html-C2-_98S6.js → html-B6UxjOv0.js} +1 -1
  85. package/es/html-Hb1oe8XT.js +2 -0
  86. package/es/info-3K5VOQVL-COqdvM99.js +3 -0
  87. package/es/{infoDiagram-LFFYTUFH-DQAZ-vFk.js → infoDiagram-LFFYTUFH-CA-vlAvP.js} +5 -5
  88. package/es/{init-PAs0hR-b.js → init-B75p2clj.js} +1 -1
  89. package/es/{isArrayLikeObject-y3HlYDaX.js → isArrayLikeObject-jl2bjkAJ.js} +80 -80
  90. package/es/{isEmpty-2JxdWtc-.js → isEmpty-CmA-HYrg.js} +3 -3
  91. package/es/{ishikawaDiagram-PHBUUO56-B0r2IgGz.js → ishikawaDiagram-PHBUUO56-DjdpS9Lb.js} +6 -6
  92. package/es/{journeyDiagram-4ABVD52K-DnMUhOvg.js → journeyDiagram-4ABVD52K-CIJfC1fp.js} +6 -6
  93. package/es/{kanban-definition-K7BYSVSG-Da5Y-nJy.js → kanban-definition-K7BYSVSG-CC2vwGck.js} +11 -11
  94. package/es/{katex-b-xdokOf.js → katex-DCMiIo1z.js} +1 -1
  95. package/es/{line-h2iCTGsE.js → line-Cu9NTacD.js} +4 -4
  96. package/es/{linear-Bv7XrZCH.js → linear-C0rAYYmp.js} +23 -23
  97. package/es/{math-DPzKeDKn.js → math-CoDOuve-.js} +1 -1
  98. package/es/{mermaid-parser.core-kTgpNO7M.js → mermaid-parser.core-7Wn2L29P.js} +16 -16
  99. package/es/{mermaid.core-Db1VE3-f.js → mermaid.core-Bvy_Q6Hu.js} +44 -44
  100. package/es/{mindmap-definition-YRQLILUH-CYeqnCde.js → mindmap-definition-YRQLILUH-BzTYDYmK.js} +16 -16
  101. package/es/{ordinal-D8PKtxfM.js → ordinal-F3U6aXtP.js} +3 -3
  102. package/es/packet-RMMSAZCW-2PTjWKLd.js +3 -0
  103. package/es/{path-DZ-6AyWK.js → path-Dm3C8WEs.js} +3 -3
  104. package/es/pie-UPGHQEXC-Du8-k-EA.js +3 -0
  105. package/es/{pieDiagram-SKSYHLDU-DAsfTGvY.js → pieDiagram-SKSYHLDU-COvqE_C6.js} +14 -14
  106. package/es/{quadrantDiagram-337W2JSQ-CZLbmQS4.js → quadrantDiagram-337W2JSQ-Dgv8ccjt.js} +4 -4
  107. package/es/radar-KQ55EAFF-jJOhyjxC.js +3 -0
  108. package/es/{requirementDiagram-Z7DCOOCP-Cb_Ygnfe.js → requirementDiagram-Z7DCOOCP-B2NyhxO-.js} +13 -13
  109. package/es/{rough.esm-C_hJ3ICT.js → rough.esm-BhGP2Udb.js} +1 -1
  110. package/es/{sankeyDiagram-WA2Y5GQK-DBe5YfW4.js → sankeyDiagram-WA2Y5GQK-BfnH_gpl.js} +18 -18
  111. package/es/{sequenceDiagram-2WXFIKYE-C_KUoojT.js → sequenceDiagram-2WXFIKYE-DXssVQOF.js} +8 -8
  112. package/es/{src-BukXhifV.js → src-CUQ6oOYk.js} +86 -86
  113. package/es/{stateDiagram-RAJIS63D-boG6DyfW.js → stateDiagram-RAJIS63D-DvDLfupV.js} +17 -17
  114. package/es/stateDiagram-v2-FVOUBMTO-DIXyaX9W.js +27 -0
  115. package/es/{timeline-definition-YZTLITO2-pFt6rZ6S.js → timeline-definition-YZTLITO2-ErcRjbZf.js} +4 -4
  116. package/es/treemap-KZPCXAKY-CvZAIYVa.js +3 -0
  117. package/es/{vennDiagram-LZ73GAT5-VaCO6k4H.js → vennDiagram-LZ73GAT5-CDTZUtc8.js} +7 -7
  118. package/es/{vue-DTiWrQBM.js → vue-2aJw7p5p.js} +2 -2
  119. package/es/{vue-html-BG3Xflut.js → vue-html-DEjI8X9t.js} +1 -1
  120. package/es/{xychartDiagram-JWTSCODW-xS5ybemA.js → xychartDiagram-JWTSCODW-Y21jBOTg.js} +12 -12
  121. package/package.json +1 -1
  122. package/es/architecture-PBZL5I3N-DHfBr78A.js +0 -3
  123. package/es/channel-DoEe9DF9.js +0 -5
  124. package/es/classDiagram-VBA2DB6C-DWTAs0Zm.js +0 -29
  125. package/es/classDiagram-v2-RAHNMMFH-CoxCdmrt.js +0 -29
  126. package/es/clone-BXDbKCDu.js +0 -8
  127. package/es/gitGraph-HDMCJU4V-DbzpICZW.js +0 -3
  128. package/es/html-JbFqcNgP.js +0 -2
  129. package/es/info-3K5VOQVL-CpUiQuel.js +0 -3
  130. package/es/packet-RMMSAZCW-UTFQ0FQx.js +0 -3
  131. package/es/pie-UPGHQEXC-CarAcBSi.js +0 -3
  132. package/es/radar-KQ55EAFF-NXK5PC9R.js +0 -3
  133. package/es/stateDiagram-v2-FVOUBMTO-DHCajhrN.js +0 -27
  134. package/es/treemap-KZPCXAKY-Cj9QakFB.js +0 -3
@@ -0,0 +1,209 @@
1
+ import { CSSProperties, PropType, SlotsType, StyleValue, VNodeChild } from 'vue';
2
+ import { DirectoryIconsMap, DirectoryTitleRender, EmptyRender, FileContentService, FolderProps, FolderSlots, FolderTreeData, PreviewRender, PreviewTitleRender, SemanticType } from './interface';
3
+ declare const XFolder: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
4
+ prefixCls: {
5
+ type: StringConstructor;
6
+ default: string;
7
+ };
8
+ rootClass: {
9
+ type: StringConstructor;
10
+ default: string;
11
+ };
12
+ class: {
13
+ type: PropType<FolderProps["class"]>;
14
+ default: undefined;
15
+ };
16
+ style: {
17
+ type: PropType<StyleValue>;
18
+ default: undefined;
19
+ };
20
+ classes: {
21
+ type: PropType<Partial<Record<SemanticType, string>>>;
22
+ default: () => {};
23
+ };
24
+ styles: {
25
+ type: PropType<Partial<Record<SemanticType, CSSProperties>>>;
26
+ default: () => {};
27
+ };
28
+ treeData: {
29
+ type: PropType<FolderTreeData[]>;
30
+ default: () => never[];
31
+ };
32
+ directoryIcons: {
33
+ type: PropType<DirectoryIconsMap>;
34
+ default: undefined;
35
+ };
36
+ selectable: {
37
+ type: BooleanConstructor;
38
+ default: boolean;
39
+ };
40
+ selectedFile: {
41
+ type: PropType<string[] | undefined>;
42
+ default: undefined;
43
+ };
44
+ defaultSelectedFile: {
45
+ type: PropType<string[] | undefined>;
46
+ default: undefined;
47
+ };
48
+ directoryTreeWith: {
49
+ type: PropType<number | string>;
50
+ default: number;
51
+ };
52
+ emptyRender: {
53
+ type: PropType<EmptyRender>;
54
+ default: undefined;
55
+ };
56
+ previewRender: {
57
+ type: PropType<PreviewRender>;
58
+ default: undefined;
59
+ };
60
+ defaultExpandedPaths: {
61
+ type: PropType<string[] | undefined>;
62
+ default: undefined;
63
+ };
64
+ expandedPaths: {
65
+ type: PropType<string[] | undefined>;
66
+ default: undefined;
67
+ };
68
+ defaultExpandAll: {
69
+ type: BooleanConstructor;
70
+ default: boolean;
71
+ };
72
+ fileContentService: {
73
+ type: PropType<FileContentService>;
74
+ default: undefined;
75
+ };
76
+ directoryTitle: {
77
+ type: PropType<DirectoryTitleRender>;
78
+ default: undefined;
79
+ };
80
+ previewTitle: {
81
+ type: PropType<PreviewTitleRender>;
82
+ default: undefined;
83
+ };
84
+ }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
85
+ selectedFileChange: (_file: {
86
+ path: string[];
87
+ title?: VNodeChild;
88
+ content?: string;
89
+ }) => true;
90
+ fileClick: (_path: string, _content?: string) => true;
91
+ folderClick: (_path: string) => true;
92
+ expandedPathsChange: (_paths: string[]) => true;
93
+ "update:selectedFile": (_paths: string[]) => true;
94
+ "update:expandedPaths": (_paths: string[]) => true;
95
+ }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
96
+ prefixCls: {
97
+ type: StringConstructor;
98
+ default: string;
99
+ };
100
+ rootClass: {
101
+ type: StringConstructor;
102
+ default: string;
103
+ };
104
+ class: {
105
+ type: PropType<FolderProps["class"]>;
106
+ default: undefined;
107
+ };
108
+ style: {
109
+ type: PropType<StyleValue>;
110
+ default: undefined;
111
+ };
112
+ classes: {
113
+ type: PropType<Partial<Record<SemanticType, string>>>;
114
+ default: () => {};
115
+ };
116
+ styles: {
117
+ type: PropType<Partial<Record<SemanticType, CSSProperties>>>;
118
+ default: () => {};
119
+ };
120
+ treeData: {
121
+ type: PropType<FolderTreeData[]>;
122
+ default: () => never[];
123
+ };
124
+ directoryIcons: {
125
+ type: PropType<DirectoryIconsMap>;
126
+ default: undefined;
127
+ };
128
+ selectable: {
129
+ type: BooleanConstructor;
130
+ default: boolean;
131
+ };
132
+ selectedFile: {
133
+ type: PropType<string[] | undefined>;
134
+ default: undefined;
135
+ };
136
+ defaultSelectedFile: {
137
+ type: PropType<string[] | undefined>;
138
+ default: undefined;
139
+ };
140
+ directoryTreeWith: {
141
+ type: PropType<number | string>;
142
+ default: number;
143
+ };
144
+ emptyRender: {
145
+ type: PropType<EmptyRender>;
146
+ default: undefined;
147
+ };
148
+ previewRender: {
149
+ type: PropType<PreviewRender>;
150
+ default: undefined;
151
+ };
152
+ defaultExpandedPaths: {
153
+ type: PropType<string[] | undefined>;
154
+ default: undefined;
155
+ };
156
+ expandedPaths: {
157
+ type: PropType<string[] | undefined>;
158
+ default: undefined;
159
+ };
160
+ defaultExpandAll: {
161
+ type: BooleanConstructor;
162
+ default: boolean;
163
+ };
164
+ fileContentService: {
165
+ type: PropType<FileContentService>;
166
+ default: undefined;
167
+ };
168
+ directoryTitle: {
169
+ type: PropType<DirectoryTitleRender>;
170
+ default: undefined;
171
+ };
172
+ previewTitle: {
173
+ type: PropType<PreviewTitleRender>;
174
+ default: undefined;
175
+ };
176
+ }>> & Readonly<{
177
+ onSelectedFileChange?: ((_file: {
178
+ path: string[];
179
+ title?: VNodeChild;
180
+ content?: string;
181
+ }) => any) | undefined;
182
+ onFileClick?: ((_path: string, _content?: string | undefined) => any) | undefined;
183
+ onFolderClick?: ((_path: string) => any) | undefined;
184
+ onExpandedPathsChange?: ((_paths: string[]) => any) | undefined;
185
+ "onUpdate:selectedFile"?: ((_paths: string[]) => any) | undefined;
186
+ "onUpdate:expandedPaths"?: ((_paths: string[]) => any) | undefined;
187
+ }>, {
188
+ prefixCls: string;
189
+ style: StyleValue;
190
+ rootClass: string;
191
+ class: any;
192
+ classes: Partial<Record<SemanticType, string>>;
193
+ styles: Partial<Record<SemanticType, CSSProperties>>;
194
+ selectable: boolean;
195
+ directoryTitle: DirectoryTitleRender;
196
+ previewTitle: PreviewTitleRender;
197
+ previewRender: PreviewRender;
198
+ treeData: FolderTreeData[];
199
+ directoryIcons: DirectoryIconsMap;
200
+ defaultExpandAll: boolean;
201
+ selectedFile: string[] | undefined;
202
+ emptyRender: EmptyRender;
203
+ defaultSelectedFile: string[] | undefined;
204
+ directoryTreeWith: string | number;
205
+ defaultExpandedPaths: string[] | undefined;
206
+ expandedPaths: string[] | undefined;
207
+ fileContentService: FileContentService;
208
+ }, SlotsType<FolderSlots>, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
209
+ export default XFolder;
@@ -0,0 +1,337 @@
1
+ import useXComponentConfig from "../_utils/hooks/use-x-component-config.js";
2
+ import localeValues from "../locale/en_US.js";
3
+ import useLocale from "../locale/useLocale.js";
4
+ import FolderDirectoryTree from "./DirectoryTree.js";
5
+ import style_default from "./style/index.js";
6
+ import FilePreview from "./FilePreview.js";
7
+ import { computed, createVNode, defineComponent, mergeProps, ref, useAttrs, watch } from "vue";
8
+ import { useConfig } from "antdv-next/config-provider/context";
9
+ import { Flex, Splitter, SplitterPanel } from "antdv-next";
10
+ //#region components/folder/Folder.tsx
11
+ function findNode(nodes, segments, index = 0) {
12
+ if (index >= segments.length) return void 0;
13
+ const current = segments[index];
14
+ for (const node of nodes) if (node.path === current) {
15
+ if (index === segments.length - 1) return node;
16
+ return node.children ? findNode(node.children, segments, index + 1) : void 0;
17
+ }
18
+ }
19
+ function findNodeAndValidate(treeData, path, validateAsFile = false) {
20
+ if (!path) return {
21
+ node: void 0,
22
+ isValid: false
23
+ };
24
+ const segments = Array.isArray(path) ? path.filter(Boolean) : path.split("/").filter(Boolean);
25
+ if (segments.length === 0) return {
26
+ node: void 0,
27
+ isValid: false
28
+ };
29
+ const node = findNode(treeData, segments);
30
+ return {
31
+ node,
32
+ isValid: validateAsFile ? !!node && (!node?.children || node.children.length === 0) : !!node
33
+ };
34
+ }
35
+ var XFolder = /* @__PURE__ */ defineComponent({
36
+ name: "AxFolder",
37
+ inheritAttrs: false,
38
+ props: {
39
+ prefixCls: {
40
+ type: String,
41
+ default: "antd-folder"
42
+ },
43
+ rootClass: {
44
+ type: String,
45
+ default: ""
46
+ },
47
+ class: {
48
+ type: [
49
+ String,
50
+ Array,
51
+ Object
52
+ ],
53
+ default: void 0
54
+ },
55
+ style: {
56
+ type: [
57
+ String,
58
+ Object,
59
+ Array
60
+ ],
61
+ default: void 0
62
+ },
63
+ classes: {
64
+ type: Object,
65
+ default: () => ({})
66
+ },
67
+ styles: {
68
+ type: Object,
69
+ default: () => ({})
70
+ },
71
+ treeData: {
72
+ type: Array,
73
+ default: () => []
74
+ },
75
+ directoryIcons: {
76
+ type: [Boolean, Object],
77
+ default: void 0
78
+ },
79
+ selectable: {
80
+ type: Boolean,
81
+ default: true
82
+ },
83
+ selectedFile: {
84
+ type: Array,
85
+ default: void 0
86
+ },
87
+ defaultSelectedFile: {
88
+ type: Array,
89
+ default: void 0
90
+ },
91
+ directoryTreeWith: {
92
+ type: [Number, String],
93
+ default: 278
94
+ },
95
+ emptyRender: {
96
+ type: [
97
+ Boolean,
98
+ String,
99
+ Number,
100
+ Object,
101
+ Array,
102
+ Function
103
+ ],
104
+ default: void 0
105
+ },
106
+ previewRender: {
107
+ type: [
108
+ String,
109
+ Number,
110
+ Object,
111
+ Array,
112
+ Function
113
+ ],
114
+ default: void 0
115
+ },
116
+ defaultExpandedPaths: {
117
+ type: Array,
118
+ default: void 0
119
+ },
120
+ expandedPaths: {
121
+ type: Array,
122
+ default: void 0
123
+ },
124
+ defaultExpandAll: {
125
+ type: Boolean,
126
+ default: true
127
+ },
128
+ fileContentService: {
129
+ type: Object,
130
+ default: void 0
131
+ },
132
+ directoryTitle: {
133
+ type: [
134
+ Boolean,
135
+ String,
136
+ Number,
137
+ Object,
138
+ Array,
139
+ Function
140
+ ],
141
+ default: void 0
142
+ },
143
+ previewTitle: {
144
+ type: [
145
+ Boolean,
146
+ String,
147
+ Number,
148
+ Object,
149
+ Array,
150
+ Function
151
+ ],
152
+ default: void 0
153
+ }
154
+ },
155
+ emits: {
156
+ selectedFileChange: (_file) => true,
157
+ fileClick: (_path, _content) => true,
158
+ folderClick: (_path) => true,
159
+ expandedPathsChange: (_paths) => true,
160
+ "update:selectedFile": (_paths) => true,
161
+ "update:expandedPaths": (_paths) => true
162
+ },
163
+ slots: Object,
164
+ setup(props, { emit, expose, slots }) {
165
+ const attrs = useAttrs();
166
+ const configCtx = useConfig();
167
+ const contextConfig = useXComponentConfig("folder");
168
+ const [hashId, cssVarCls] = style_default(computed(() => props.prefixCls));
169
+ const [locale] = useLocale("Folder", localeValues.Folder);
170
+ const rootRef = ref();
171
+ const isValidSelectedFile = (filePath) => !!(filePath && filePath.length > 0 && findNodeAndValidate(props.treeData, filePath, true).isValid);
172
+ const innerSelectedFile = ref(isValidSelectedFile(props.defaultSelectedFile) ? props.defaultSelectedFile ?? [] : []);
173
+ const mergedSelectedFile = computed(() => props.selectedFile !== void 0 ? props.selectedFile : innerSelectedFile.value);
174
+ const validSelectedFile = ref(isValidSelectedFile(props.selectedFile ?? props.defaultSelectedFile));
175
+ watch(() => [
176
+ props.selectedFile,
177
+ props.defaultSelectedFile,
178
+ props.treeData
179
+ ], () => {
180
+ validSelectedFile.value = isValidSelectedFile(props.selectedFile ?? props.defaultSelectedFile ?? []);
181
+ }, { deep: true });
182
+ const innerExpandedPaths = ref(props.defaultExpandedPaths);
183
+ const mergedExpandedPaths = computed(() => props.expandedPaths !== void 0 ? props.expandedPaths : innerExpandedPaths.value);
184
+ const fileContent = ref("");
185
+ const loadingContent = ref(false);
186
+ const loadFileContent = async () => {
187
+ if (!validSelectedFile.value || mergedSelectedFile.value.length === 0) {
188
+ fileContent.value = "";
189
+ loadingContent.value = false;
190
+ return;
191
+ }
192
+ const filePath = mergedSelectedFile.value.join("/");
193
+ const segments = filePath.split("/").filter((s) => s !== "");
194
+ const { node } = findNodeAndValidate(props.treeData, segments);
195
+ if (props.fileContentService) {
196
+ loadingContent.value = true;
197
+ try {
198
+ fileContent.value = await props.fileContentService.loadFileContent(filePath);
199
+ } catch (error) {
200
+ fileContent.value = `// ${locale.value.loadError}: ${error instanceof Error ? error.message : "Unknown error"}`;
201
+ } finally {
202
+ loadingContent.value = false;
203
+ }
204
+ return;
205
+ }
206
+ if (node?.content) {
207
+ fileContent.value = node.content;
208
+ loadingContent.value = false;
209
+ return;
210
+ }
211
+ fileContent.value = `// ${locale.value.noService}`;
212
+ loadingContent.value = false;
213
+ };
214
+ watch([
215
+ validSelectedFile,
216
+ mergedSelectedFile,
217
+ () => props.treeData,
218
+ () => props.fileContentService
219
+ ], () => {
220
+ loadFileContent();
221
+ }, {
222
+ immediate: true,
223
+ deep: true
224
+ });
225
+ const handleSelect = (keys, info) => {
226
+ const nodes = Array.isArray(info?.selectedNodes) ? info.selectedNodes : info?.selectedNodes ? [info.selectedNodes] : [];
227
+ if (nodes.some((node) => !node?.isLeaf)) {
228
+ if (nodes.length === 1) emit("folderClick", nodes[0]?.path ?? "");
229
+ return;
230
+ }
231
+ const pathArray = keys[0]?.split("/").filter(Boolean) ?? [];
232
+ if (pathArray.length === 0) return;
233
+ const selectedNode = nodes[0];
234
+ const fileName = selectedNode?.title;
235
+ const fileContentValue = selectedNode?.content;
236
+ emit("selectedFileChange", {
237
+ path: pathArray,
238
+ title: fileName,
239
+ content: fileContentValue
240
+ });
241
+ if (!(props.selectedFile !== void 0)) {
242
+ validSelectedFile.value = true;
243
+ innerSelectedFile.value = pathArray;
244
+ emit("update:selectedFile", pathArray);
245
+ }
246
+ if (nodes.length === 1) {
247
+ const node = nodes[0];
248
+ emit("fileClick", node?.path ?? "", node?.content);
249
+ }
250
+ };
251
+ const handleExpand = (keys) => {
252
+ const newPaths = keys ?? [];
253
+ if (props.expandedPaths === void 0) innerExpandedPaths.value = newPaths;
254
+ emit("update:expandedPaths", newPaths);
255
+ emit("expandedPathsChange", newPaths);
256
+ };
257
+ const domAttrs = computed(() => {
258
+ const { class: _c, style: _s, ...rest } = attrs;
259
+ return rest;
260
+ });
261
+ expose({ get nativeElement() {
262
+ return rootRef.value;
263
+ } });
264
+ const mergedDirectoryTitle = computed(() => slots.directoryTitle ?? props.directoryTitle);
265
+ const mergedPreviewTitle = computed(() => slots.previewTitle ?? props.previewTitle);
266
+ const mergedPreviewRender = computed(() => {
267
+ if (slots.previewRender) return (file, info) => slots.previewRender({
268
+ file,
269
+ originNode: info.originNode
270
+ });
271
+ return props.previewRender;
272
+ });
273
+ const mergedEmptyRender = computed(() => slots.emptyRender ?? props.emptyRender);
274
+ return () => {
275
+ const prefixCls = props.prefixCls;
276
+ return createVNode("div", mergeProps({ "ref": rootRef }, domAttrs.value, {
277
+ "class": [
278
+ prefixCls,
279
+ contextConfig.value.classes?.root,
280
+ props.rootClass,
281
+ props.classes?.root,
282
+ hashId.value,
283
+ cssVarCls.value,
284
+ attrs.class,
285
+ props.class,
286
+ {
287
+ [`${prefixCls}-rtl`]: configCtx.value.direction === "rtl",
288
+ [`${prefixCls}-selectable`]: props.selectable
289
+ }
290
+ ],
291
+ "style": [
292
+ contextConfig.value.style,
293
+ contextConfig.value.styles?.root,
294
+ props.styles?.root,
295
+ attrs.style,
296
+ props.style
297
+ ]
298
+ }), [createVNode(Flex, { "class": `${prefixCls}-container` }, { default: () => [createVNode(Splitter, null, { default: () => [createVNode(SplitterPanel, { "defaultSize": props.directoryTreeWith }, { default: () => [createVNode("div", {
299
+ "class": [`${prefixCls}-directory-tree`, props.classes?.directoryTree],
300
+ "style": [contextConfig.value.styles?.directoryTree, props.styles?.directoryTree]
301
+ }, [createVNode(FolderDirectoryTree, {
302
+ "prefixCls": prefixCls,
303
+ "directoryIcons": props.directoryIcons,
304
+ "treeData": props.treeData,
305
+ "selectedKeys": props.selectable && mergedSelectedFile.value && validSelectedFile.value ? [mergedSelectedFile.value.join("/")] : [],
306
+ "classes": props.classes,
307
+ "styles": props.styles,
308
+ "expandedKeys": mergedExpandedPaths.value,
309
+ "defaultExpandAll": props.defaultExpandAll,
310
+ "directoryTitle": mergedDirectoryTitle.value,
311
+ "onSelect": handleSelect,
312
+ "onExpand": handleExpand
313
+ }, null)])] }), createVNode(SplitterPanel, null, { default: () => [createVNode(FilePreview, {
314
+ "prefixCls": prefixCls,
315
+ "classes": props.classes,
316
+ "styles": props.styles,
317
+ "selectedFile": validSelectedFile.value ? mergedSelectedFile.value : [],
318
+ "fileContent": fileContent.value,
319
+ "loading": loadingContent.value,
320
+ "previewTitle": mergedPreviewTitle.value,
321
+ "previewRender": mergedPreviewRender.value,
322
+ "emptyRender": mergedEmptyRender.value,
323
+ "getFileNode": (path) => {
324
+ if (!path || path.length === 0) return void 0;
325
+ const { node } = findNodeAndValidate(props.treeData, path);
326
+ return node ? {
327
+ title: node.title,
328
+ path: node.path,
329
+ content: node.content
330
+ } : void 0;
331
+ }
332
+ }, null)] })] })] })]);
333
+ };
334
+ }
335
+ });
336
+ //#endregion
337
+ export { XFolder as default };
@@ -0,0 +1,3 @@
1
+ import { default as Folder } from './Folder';
2
+ export type { DirectoryIconsMap, DirectoryTitleRender, EmptyRender, FileContentService, FolderProps, FolderRef, FolderSlots, FolderTreeData, PreviewFileInfo, PreviewRender, PreviewTitleRender, SelectedFileInfo, SemanticType as FolderSemanticType, } from './interface';
3
+ export default Folder;
@@ -0,0 +1,5 @@
1
+ import XFolder from "./Folder.js";
2
+ //#region components/folder/index.ts
3
+ var folder_default = XFolder;
4
+ //#endregion
5
+ export { folder_default as default };
@@ -0,0 +1,78 @@
1
+ import { CSSProperties, HTMLAttributes, StyleValue, VNodeChild } from 'vue';
2
+ export type SemanticType = "root" | "directoryTree" | "directoryTitle" | "filePreview" | "previewTitle" | "previewRender";
3
+ export interface FolderTreeData {
4
+ title: VNodeChild;
5
+ path: string;
6
+ content?: string;
7
+ children?: FolderTreeData[];
8
+ }
9
+ export interface FileContentService {
10
+ loadFileContent: (filePath: string) => Promise<string>;
11
+ }
12
+ export type DirectoryIconRenderer = VNodeChild | (() => VNodeChild);
13
+ export type DirectoryIconsMap = false | (Record<string, DirectoryIconRenderer> & {
14
+ directory?: DirectoryIconRenderer;
15
+ });
16
+ export interface PreviewFileInfo {
17
+ content?: string;
18
+ path: string[];
19
+ title?: FolderTreeData["title"];
20
+ language: string;
21
+ }
22
+ export interface SelectedFileInfo {
23
+ path: string[];
24
+ title?: FolderTreeData["title"];
25
+ content?: string;
26
+ }
27
+ export type EmptyRender = false | null | VNodeChild | (() => VNodeChild);
28
+ export type PreviewTitleRender = false | null | VNodeChild | ((info: {
29
+ title: VNodeChild;
30
+ path: string[];
31
+ content: string;
32
+ }) => VNodeChild);
33
+ export type PreviewRender = VNodeChild | ((file: PreviewFileInfo, info: {
34
+ originNode: VNodeChild;
35
+ }) => VNodeChild);
36
+ export type DirectoryTitleRender = false | null | VNodeChild | (() => VNodeChild);
37
+ export interface FolderProps extends Omit<HTMLAttributes, "title"> {
38
+ prefixCls?: string;
39
+ rootClass?: string;
40
+ class?: any;
41
+ style?: StyleValue;
42
+ classes?: Partial<Record<SemanticType, string>>;
43
+ styles?: Partial<Record<SemanticType, CSSProperties>>;
44
+ treeData: FolderTreeData[];
45
+ directoryIcons?: DirectoryIconsMap;
46
+ selectable?: boolean;
47
+ selectedFile?: string[];
48
+ defaultSelectedFile?: string[];
49
+ onSelectedFileChange?: (file: SelectedFileInfo) => void;
50
+ directoryTreeWith?: number | string;
51
+ emptyRender?: EmptyRender;
52
+ previewRender?: PreviewRender;
53
+ defaultExpandedPaths?: string[];
54
+ expandedPaths?: string[];
55
+ defaultExpandAll?: boolean;
56
+ onExpandedPathsChange?: (paths: string[]) => void;
57
+ fileContentService?: FileContentService;
58
+ onFileClick?: (filePath: string, content?: string) => void;
59
+ onFolderClick?: (folderPath: string) => void;
60
+ directoryTitle?: DirectoryTitleRender;
61
+ previewTitle?: PreviewTitleRender;
62
+ }
63
+ export interface FolderRef {
64
+ nativeElement: HTMLDivElement;
65
+ }
66
+ export interface FolderSlots {
67
+ directoryTitle?: () => VNodeChild;
68
+ previewTitle?: (info: {
69
+ title: VNodeChild;
70
+ path: string[];
71
+ content: string;
72
+ }) => VNodeChild;
73
+ previewRender?: (info: {
74
+ file: PreviewFileInfo;
75
+ originNode: VNodeChild;
76
+ }) => VNodeChild;
77
+ emptyRender?: () => VNodeChild;
78
+ }
File without changes
@@ -0,0 +1,7 @@
1
+ import { FullToken, GenerateStyle } from '../../theme/interface';
2
+ export interface FolderToken extends FullToken<"Folder"> {
3
+ colorBgDirectory: string;
4
+ }
5
+ declare const genFolderStyle: GenerateStyle<FolderToken>;
6
+ export declare const genFilePreviewStyle: GenerateStyle<FolderToken>;
7
+ export default genFolderStyle;