@king-design/vue 3.7.0 → 3.8.0-beta.0

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 (227) hide show
  1. package/__tests__/__snapshots__/Vue Next Demos.md +399 -0
  2. package/components/bubble/bubble.d.ts +61 -0
  3. package/components/bubble/bubble.js +81 -0
  4. package/components/bubble/bubble.vdt.js +85 -0
  5. package/components/bubble/index.d.ts +1 -0
  6. package/components/bubble/index.js +1 -0
  7. package/components/bubble/index.spec.d.ts +1 -0
  8. package/components/bubble/index.spec.js +771 -0
  9. package/components/bubble/styles.d.ts +5 -0
  10. package/components/bubble/styles.js +53 -0
  11. package/components/bubble/useBubbleDisplay.d.ts +18 -0
  12. package/components/bubble/useBubbleDisplay.js +300 -0
  13. package/components/bubbleList/bubbleList.d.ts +87 -0
  14. package/components/bubbleList/bubbleList.js +75 -0
  15. package/components/bubbleList/bubbleList.vdt.js +143 -0
  16. package/components/bubbleList/index.d.ts +1 -0
  17. package/components/bubbleList/index.js +1 -0
  18. package/components/bubbleList/index.spec.d.ts +1 -0
  19. package/components/bubbleList/index.spec.js +1268 -0
  20. package/components/bubbleList/item.d.ts +16 -0
  21. package/components/bubbleList/item.js +27 -0
  22. package/components/bubbleList/item.vdt.js +36 -0
  23. package/components/bubbleList/styles.d.ts +5 -0
  24. package/components/bubbleList/styles.js +33 -0
  25. package/components/bubbleList/useBubbleList.d.ts +28 -0
  26. package/components/bubbleList/useBubbleList.js +455 -0
  27. package/components/checkbox/index.d.ts +3 -3
  28. package/components/fileCard/fileCard.d.ts +65 -0
  29. package/components/fileCard/fileCard.js +72 -0
  30. package/components/fileCard/fileCard.vdt.js +161 -0
  31. package/components/fileCard/fileCardAssets.d.ts +1 -0
  32. package/components/fileCard/fileCardAssets.js +54 -0
  33. package/components/fileCard/fileCardUtils.d.ts +14 -0
  34. package/components/fileCard/fileCardUtils.js +94 -0
  35. package/components/fileCard/index.d.ts +2 -0
  36. package/components/fileCard/index.js +2 -0
  37. package/components/fileCard/index.spec.d.ts +1 -0
  38. package/components/fileCard/index.spec.js +1096 -0
  39. package/components/fileCard/list.d.ts +29 -0
  40. package/components/fileCard/list.js +46 -0
  41. package/components/fileCard/list.vdt.js +71 -0
  42. package/components/fileCard/styles.d.ts +5 -0
  43. package/components/fileCard/styles.js +83 -0
  44. package/components/fileCard/useFileCard.d.ts +45 -0
  45. package/components/fileCard/useFileCard.js +330 -0
  46. package/components/fileCard/useFileCardList.d.ts +14 -0
  47. package/components/fileCard/useFileCardList.js +49 -0
  48. package/components/form/form.js +2 -1
  49. package/components/media/context.d.ts +6 -0
  50. package/components/media/context.js +2 -0
  51. package/components/media/group.d.ts +12 -0
  52. package/components/media/group.js +32 -0
  53. package/components/media/group.vdt.js +50 -0
  54. package/components/media/index.d.ts +2 -0
  55. package/components/media/index.js +2 -0
  56. package/components/media/index.spec.d.ts +1 -0
  57. package/components/media/index.spec.js +1691 -0
  58. package/components/media/media.d.ts +37 -0
  59. package/components/media/media.js +67 -0
  60. package/components/media/media.vdt.js +202 -0
  61. package/components/media/mediaAssets.d.ts +4 -0
  62. package/components/media/mediaAssets.js +9 -0
  63. package/components/media/mediaUtils.d.ts +6 -0
  64. package/components/media/mediaUtils.js +66 -0
  65. package/components/media/styles.d.ts +13 -0
  66. package/components/media/styles.js +52 -0
  67. package/components/media/types.d.ts +37 -0
  68. package/components/media/types.js +1 -0
  69. package/components/media/useMedia.d.ts +70 -0
  70. package/components/media/useMedia.js +471 -0
  71. package/components/media/useMediaGroup.d.ts +15 -0
  72. package/components/media/useMediaGroup.js +136 -0
  73. package/components/media/useMediaViewer.d.ts +14 -0
  74. package/components/media/useMediaViewer.js +129 -0
  75. package/components/media/viewer.d.ts +24 -0
  76. package/components/media/viewer.js +54 -0
  77. package/components/media/viewer.vdt.js +100 -0
  78. package/components/radio/index.d.ts +3 -3
  79. package/components/sender/icons.d.ts +3 -0
  80. package/components/sender/icons.js +17 -0
  81. package/components/sender/index.d.ts +1 -0
  82. package/components/sender/index.js +1 -0
  83. package/components/sender/index.spec.d.ts +1 -0
  84. package/components/sender/index.spec.js +1597 -0
  85. package/components/sender/sender.d.ts +104 -0
  86. package/components/sender/sender.js +111 -0
  87. package/components/sender/sender.vdt.js +230 -0
  88. package/components/sender/styles.d.ts +5 -0
  89. package/components/sender/styles.js +56 -0
  90. package/components/sender/useAutoResize.d.ts +4 -0
  91. package/components/sender/useAutoResize.js +99 -0
  92. package/components/sender/useSenderDrag.d.ts +6 -0
  93. package/components/sender/useSenderDrag.js +320 -0
  94. package/components/sender/useSenderInput.d.ts +16 -0
  95. package/components/sender/useSenderInput.js +101 -0
  96. package/components/sender/useSenderPaste.d.ts +5 -0
  97. package/components/sender/useSenderPaste.js +36 -0
  98. package/components/sender/useSenderUpload.d.ts +11 -0
  99. package/components/sender/useSenderUpload.js +395 -0
  100. package/components/skeleton/skeleton.d.ts +2 -1
  101. package/components/skeleton/skeleton.js +1 -1
  102. package/components/think/index.d.ts +1 -0
  103. package/components/think/index.js +1 -0
  104. package/components/think/index.spec.d.ts +1 -0
  105. package/components/think/index.spec.js +345 -0
  106. package/components/think/index.vdt.js +82 -0
  107. package/components/think/styles.d.ts +5 -0
  108. package/components/think/styles.js +25 -0
  109. package/components/think/think.d.ts +28 -0
  110. package/components/think/think.js +48 -0
  111. package/components/think/useThinkExpand.d.ts +10 -0
  112. package/components/think/useThinkExpand.js +56 -0
  113. package/components/types.d.ts +4 -2
  114. package/components/upload/ajaxUploader.d.ts +1 -0
  115. package/components/upload/ajaxUploader.js +6 -0
  116. package/components/xmarkdown/index.d.ts +2 -0
  117. package/components/xmarkdown/index.js +1 -0
  118. package/components/xmarkdown/index.spec.d.ts +1 -0
  119. package/components/xmarkdown/index.spec.js +1666 -0
  120. package/components/xmarkdown/markdown/codeBlockRenderer.d.ts +8 -0
  121. package/components/xmarkdown/markdown/codeBlockRenderer.js +52 -0
  122. package/components/xmarkdown/markdown/codeblock.d.ts +8 -0
  123. package/components/xmarkdown/markdown/codeblock.js +74 -0
  124. package/components/xmarkdown/markdown/highlight.d.ts +17 -0
  125. package/components/xmarkdown/markdown/highlight.js +83 -0
  126. package/components/xmarkdown/markdown/index.d.ts +14 -0
  127. package/components/xmarkdown/markdown/index.js +14 -0
  128. package/components/xmarkdown/markdown/mermaid.d.ts +8 -0
  129. package/components/xmarkdown/markdown/mermaid.js +104 -0
  130. package/components/xmarkdown/markdown/renderTree.d.ts +54 -0
  131. package/components/xmarkdown/markdown/renderTree.js +386 -0
  132. package/components/xmarkdown/markdown/renderer.d.ts +18 -0
  133. package/components/xmarkdown/markdown/renderer.js +461 -0
  134. package/components/xmarkdown/markdown/streaming.d.ts +24 -0
  135. package/components/xmarkdown/markdown/streaming.js +513 -0
  136. package/components/xmarkdown/markdown/types.d.ts +124 -0
  137. package/components/xmarkdown/markdown/types.js +6 -0
  138. package/components/xmarkdown/markdown/utils.d.ts +7 -0
  139. package/components/xmarkdown/markdown/utils.js +9 -0
  140. package/components/xmarkdown/markdown.d.ts +1 -0
  141. package/components/xmarkdown/markdown.js +1 -0
  142. package/components/xmarkdown/styles.d.ts +5 -0
  143. package/components/xmarkdown/styles.js +50 -0
  144. package/components/xmarkdown/useMermaid.d.ts +27 -0
  145. package/components/xmarkdown/useMermaid.js +745 -0
  146. package/components/xmarkdown/useXMarkdownContent.d.ts +14 -0
  147. package/components/xmarkdown/useXMarkdownContent.js +218 -0
  148. package/components/xmarkdown/useXMarkdownDisplay.d.ts +26 -0
  149. package/components/xmarkdown/useXMarkdownDisplay.js +569 -0
  150. package/components/xmarkdown/xmarkdown.d.ts +61 -0
  151. package/components/xmarkdown/xmarkdown.js +109 -0
  152. package/components/xmarkdown/xmarkdown.vdt.js +43 -0
  153. package/dist/fonts/KaTeX_AMS-Regular.ttf +0 -0
  154. package/dist/fonts/KaTeX_AMS-Regular.woff +0 -0
  155. package/dist/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  156. package/dist/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
  157. package/dist/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
  158. package/dist/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  159. package/dist/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
  160. package/dist/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
  161. package/dist/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  162. package/dist/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
  163. package/dist/fonts/KaTeX_Fraktur-Bold.woff +0 -0
  164. package/dist/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  165. package/dist/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
  166. package/dist/fonts/KaTeX_Fraktur-Regular.woff +0 -0
  167. package/dist/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  168. package/dist/fonts/KaTeX_Main-Bold.ttf +0 -0
  169. package/dist/fonts/KaTeX_Main-Bold.woff +0 -0
  170. package/dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
  171. package/dist/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
  172. package/dist/fonts/KaTeX_Main-BoldItalic.woff +0 -0
  173. package/dist/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  174. package/dist/fonts/KaTeX_Main-Italic.ttf +0 -0
  175. package/dist/fonts/KaTeX_Main-Italic.woff +0 -0
  176. package/dist/fonts/KaTeX_Main-Italic.woff2 +0 -0
  177. package/dist/fonts/KaTeX_Main-Regular.ttf +0 -0
  178. package/dist/fonts/KaTeX_Main-Regular.woff +0 -0
  179. package/dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
  180. package/dist/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
  181. package/dist/fonts/KaTeX_Math-BoldItalic.woff +0 -0
  182. package/dist/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  183. package/dist/fonts/KaTeX_Math-Italic.ttf +0 -0
  184. package/dist/fonts/KaTeX_Math-Italic.woff +0 -0
  185. package/dist/fonts/KaTeX_Math-Italic.woff2 +0 -0
  186. package/dist/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
  187. package/dist/fonts/KaTeX_SansSerif-Bold.woff +0 -0
  188. package/dist/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  189. package/dist/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
  190. package/dist/fonts/KaTeX_SansSerif-Italic.woff +0 -0
  191. package/dist/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  192. package/dist/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
  193. package/dist/fonts/KaTeX_SansSerif-Regular.woff +0 -0
  194. package/dist/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  195. package/dist/fonts/KaTeX_Script-Regular.ttf +0 -0
  196. package/dist/fonts/KaTeX_Script-Regular.woff +0 -0
  197. package/dist/fonts/KaTeX_Script-Regular.woff2 +0 -0
  198. package/dist/fonts/KaTeX_Size1-Regular.ttf +0 -0
  199. package/dist/fonts/KaTeX_Size1-Regular.woff +0 -0
  200. package/dist/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  201. package/dist/fonts/KaTeX_Size2-Regular.ttf +0 -0
  202. package/dist/fonts/KaTeX_Size2-Regular.woff +0 -0
  203. package/dist/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  204. package/dist/fonts/KaTeX_Size3-Regular.ttf +0 -0
  205. package/dist/fonts/KaTeX_Size3-Regular.woff +0 -0
  206. package/dist/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  207. package/dist/fonts/KaTeX_Size4-Regular.ttf +0 -0
  208. package/dist/fonts/KaTeX_Size4-Regular.woff +0 -0
  209. package/dist/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  210. package/dist/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
  211. package/dist/fonts/KaTeX_Typewriter-Regular.woff +0 -0
  212. package/dist/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  213. package/dist/i18n/en-US.js +29 -1
  214. package/dist/i18n/en-US.js.map +1 -1
  215. package/dist/i18n/en-US.min.js +1 -1
  216. package/dist/index.js +100506 -37457
  217. package/dist/index.js.map +1 -1
  218. package/dist/index.min.js +1569 -1
  219. package/dist/kpc.css +4 -0
  220. package/dist/ksyun.css +4 -0
  221. package/i18n/en-US.d.ts +27 -0
  222. package/i18n/en-US.js +29 -1
  223. package/index.d.ts +9 -2
  224. package/index.js +9 -2
  225. package/package.json +8 -2
  226. package/styles/global.js +12 -6
  227. package/yarn-error.log +0 -1012
@@ -0,0 +1,320 @@
1
+ import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
3
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js/instance/includes";
4
+ import _Array$from from "@babel/runtime-corejs3/core-js/array/from";
5
+ import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/splice";
6
+ import _Promise from "@babel/runtime-corejs3/core-js/promise";
7
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
8
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
9
+ import { onBeforeUnmount, onMounted, useInstance } from 'intact-vue-next';
10
+ import { useState } from '../../hooks/useState';
11
+ var controllers = [];
12
+ var isListening = false;
13
+ function isFileDrag(e) {
14
+ var _e$dataTransfer, _context;
15
+ var types = (_e$dataTransfer = e.dataTransfer) == null ? void 0 : _e$dataTransfer.types;
16
+ return !!types && _includesInstanceProperty(_context = _Array$from(types)).call(_context, 'Files');
17
+ }
18
+ function getActiveController() {
19
+ for (var i = controllers.length - 1; i >= 0; i--) {
20
+ if (controllers[i].isEnabled()) {
21
+ return controllers[i];
22
+ }
23
+ }
24
+ }
25
+ function toggleGlobalListeners() {
26
+ var hasEnabledController = !!getActiveController();
27
+ if (hasEnabledController === isListening) return;
28
+ if (hasEnabledController) {
29
+ document.addEventListener('dragenter', handleDocumentDragEnter);
30
+ document.addEventListener('dragover', handleDocumentDragOver);
31
+ document.addEventListener('dragleave', handleDocumentDragLeave);
32
+ document.addEventListener('drop', handleDocumentDrop);
33
+ } else {
34
+ document.removeEventListener('dragenter', handleDocumentDragEnter);
35
+ document.removeEventListener('dragover', handleDocumentDragOver);
36
+ document.removeEventListener('dragleave', handleDocumentDragLeave);
37
+ document.removeEventListener('drop', handleDocumentDrop);
38
+ }
39
+ isListening = hasEnabledController;
40
+ }
41
+ function registerController(controller) {
42
+ unregisterController(controller);
43
+ controllers.push(controller);
44
+ toggleGlobalListeners();
45
+ }
46
+ function unregisterController(controller) {
47
+ var index = controllers.indexOf(controller);
48
+ if (index > -1) {
49
+ _spliceInstanceProperty(controllers).call(controllers, index, 1);
50
+ }
51
+ controller.reset();
52
+ toggleGlobalListeners();
53
+ }
54
+ function handleDocumentDragEnter(e) {
55
+ var controller = getActiveController();
56
+ if (!controller || !isFileDrag(e)) return;
57
+ controller.stopEvent(e);
58
+ controller.onDragEnter(e);
59
+ }
60
+ function handleDocumentDragOver(e) {
61
+ var controller = getActiveController();
62
+ if (!controller || !isFileDrag(e)) return;
63
+ controller.stopEvent(e);
64
+ if (e.dataTransfer) {
65
+ e.dataTransfer.dropEffect = 'copy'; // 让浏览器允许 drop 文件
66
+ }
67
+ }
68
+ function handleDocumentDragLeave(e) {
69
+ var controller = getActiveController();
70
+ if (!controller || !isFileDrag(e)) return;
71
+ controller.stopEvent(e);
72
+ controller.onDragLeave();
73
+ }
74
+ function handleDocumentDrop(e) {
75
+ var controller = getActiveController();
76
+ if (!controller || !isFileDrag(e)) return;
77
+ controller.onDrop(e);
78
+ }
79
+ function defineRelativePath(file, relativePath) {
80
+ if (!relativePath) return file;
81
+ Object.defineProperty(file, 'webkitRelativePath', {
82
+ value: relativePath,
83
+ configurable: true
84
+ });
85
+ return file;
86
+ }
87
+ function readFileEntry(entry, relativePath) {
88
+ return new _Promise(function (resolve) {
89
+ entry.file(function (file) {
90
+ return resolve(defineRelativePath(file, relativePath));
91
+ }, function () {
92
+ return resolve(null);
93
+ });
94
+ });
95
+ }
96
+ function readDirectoryEntries(reader) {
97
+ return new _Promise(function (resolve) {
98
+ var result = [];
99
+ function next() {
100
+ reader.readEntries(function (entries) {
101
+ if (!entries.length) {
102
+ resolve(result);
103
+ return;
104
+ }
105
+ result.push.apply(result, entries);
106
+ next();
107
+ }, function () {
108
+ return resolve(result);
109
+ });
110
+ }
111
+ next();
112
+ });
113
+ }
114
+ function extractEntryFiles(_x, _x2, _x3) {
115
+ return _extractEntryFiles.apply(this, arguments);
116
+ }
117
+ function _extractEntryFiles() {
118
+ _extractEntryFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(entry, directoryEnabled, parentPath) {
119
+ var _ref2;
120
+ var relativePath, file, reader, entries, groups;
121
+ return _regeneratorRuntime.wrap(function _callee2$(_context3) {
122
+ while (1) switch (_context3.prev = _context3.next) {
123
+ case 0:
124
+ if (parentPath === void 0) {
125
+ parentPath = '';
126
+ }
127
+ relativePath = parentPath ? parentPath + "/" + entry.name : entry.name;
128
+ if (!entry.isFile) {
129
+ _context3.next = 7;
130
+ break;
131
+ }
132
+ _context3.next = 5;
133
+ return readFileEntry(entry, relativePath);
134
+ case 5:
135
+ file = _context3.sent;
136
+ return _context3.abrupt("return", file ? [file] : []);
137
+ case 7:
138
+ if (!(!entry.isDirectory || !directoryEnabled)) {
139
+ _context3.next = 9;
140
+ break;
141
+ }
142
+ return _context3.abrupt("return", []);
143
+ case 9:
144
+ reader = entry.createReader();
145
+ _context3.next = 12;
146
+ return readDirectoryEntries(reader);
147
+ case 12:
148
+ entries = _context3.sent;
149
+ _context3.next = 15;
150
+ return _Promise.all(_mapInstanceProperty(entries).call(entries, function (item) {
151
+ return extractEntryFiles(item, directoryEnabled, relativePath);
152
+ }));
153
+ case 15:
154
+ groups = _context3.sent;
155
+ return _context3.abrupt("return", _concatInstanceProperty(_ref2 = []).apply(_ref2, groups));
156
+ case 17:
157
+ case "end":
158
+ return _context3.stop();
159
+ }
160
+ }, _callee2);
161
+ }));
162
+ return _extractEntryFiles.apply(this, arguments);
163
+ }
164
+ function extractDroppedFiles(_x4, _x5) {
165
+ return _extractDroppedFiles.apply(this, arguments);
166
+ } // Sender 的全屏拖拽上传只负责“页面级 drop 入口”;
167
+ // 真正的数量/类型/大小校验与上传动作仍统一复用 useSenderUpload.addFiles。
168
+ function _extractDroppedFiles() {
169
+ _extractDroppedFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(dataTransfer, directoryEnabled) {
170
+ var _dataTransfer$files;
171
+ var items, _ref4, groups, files;
172
+ return _regeneratorRuntime.wrap(function _callee4$(_context5) {
173
+ while (1) switch (_context5.prev = _context5.next) {
174
+ case 0:
175
+ if (dataTransfer) {
176
+ _context5.next = 2;
177
+ break;
178
+ }
179
+ return _context5.abrupt("return", []);
180
+ case 2:
181
+ items = dataTransfer.items ? _Array$from(dataTransfer.items) : [];
182
+ if (!items.length) {
183
+ _context5.next = 10;
184
+ break;
185
+ }
186
+ _context5.next = 6;
187
+ return _Promise.all(_mapInstanceProperty(items).call(items, /*#__PURE__*/function () {
188
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(item) {
189
+ var entry, file;
190
+ return _regeneratorRuntime.wrap(function _callee3$(_context4) {
191
+ while (1) switch (_context4.prev = _context4.next) {
192
+ case 0:
193
+ entry = item.webkitGetAsEntry == null ? void 0 : item.webkitGetAsEntry();
194
+ if (!entry) {
195
+ _context4.next = 3;
196
+ break;
197
+ }
198
+ return _context4.abrupt("return", extractEntryFiles(entry, directoryEnabled));
199
+ case 3:
200
+ file = item.getAsFile == null ? void 0 : item.getAsFile();
201
+ return _context4.abrupt("return", file ? [file] : []);
202
+ case 5:
203
+ case "end":
204
+ return _context4.stop();
205
+ }
206
+ }, _callee3);
207
+ }));
208
+ return function (_x6) {
209
+ return _ref3.apply(this, arguments);
210
+ };
211
+ }()));
212
+ case 6:
213
+ groups = _context5.sent;
214
+ files = _concatInstanceProperty(_ref4 = []).apply(_ref4, groups);
215
+ if (!files.length) {
216
+ _context5.next = 10;
217
+ break;
218
+ }
219
+ return _context5.abrupt("return", files);
220
+ case 10:
221
+ return _context5.abrupt("return", (_dataTransfer$files = dataTransfer.files) != null && _dataTransfer$files.length ? _Array$from(dataTransfer.files) : []);
222
+ case 11:
223
+ case "end":
224
+ return _context5.stop();
225
+ }
226
+ }, _callee4);
227
+ }));
228
+ return _extractDroppedFiles.apply(this, arguments);
229
+ }
230
+ export function useSenderDrag(addFiles) {
231
+ var instance = useInstance();
232
+ var dragOver = useState(false);
233
+ function isEnabled() {
234
+ return !!instance.get('dragFile') && !instance.get('disabled');
235
+ }
236
+ var controller = {
237
+ dragOver: dragOver,
238
+ counter: 0,
239
+ isEnabled: isEnabled,
240
+ stopEvent: function stopEvent(e) {
241
+ e.preventDefault();
242
+ e.stopPropagation();
243
+ },
244
+ onDragEnter: function onDragEnter() {
245
+ if (instance.get('disabled')) return;
246
+ controller.counter++;
247
+ if (!dragOver.value) {
248
+ dragOver.set(true);
249
+ }
250
+ },
251
+ onDragLeave: function onDragLeave() {
252
+ if (!controller.counter) return;
253
+ controller.counter--;
254
+ if (!controller.counter && dragOver.value) {
255
+ dragOver.set(false);
256
+ }
257
+ },
258
+ onDrop: function onDrop(e) {
259
+ var _instance$get, _e$dataTransfer2;
260
+ controller.stopEvent(e);
261
+ controller.reset();
262
+ if (instance.get('disabled')) return;
263
+ var directoryEnabled = !!((_instance$get = instance.get('uploadProps')) != null && _instance$get.directory);
264
+ var directFiles = (_e$dataTransfer2 = e.dataTransfer) == null ? void 0 : _e$dataTransfer2.files;
265
+ if (!directoryEnabled && directFiles != null && directFiles.length) {
266
+ addFiles(directFiles);
267
+ return;
268
+ }
269
+ void _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
270
+ var files;
271
+ return _regeneratorRuntime.wrap(function _callee$(_context2) {
272
+ while (1) switch (_context2.prev = _context2.next) {
273
+ case 0:
274
+ _context2.next = 2;
275
+ return extractDroppedFiles(e.dataTransfer, directoryEnabled);
276
+ case 2:
277
+ files = _context2.sent;
278
+ if (files.length) {
279
+ _context2.next = 5;
280
+ break;
281
+ }
282
+ return _context2.abrupt("return");
283
+ case 5:
284
+ addFiles(files);
285
+ case 6:
286
+ case "end":
287
+ return _context2.stop();
288
+ }
289
+ }, _callee);
290
+ }))();
291
+ },
292
+ reset: function reset() {
293
+ controller.counter = 0;
294
+ if (dragOver.value) {
295
+ dragOver.set(false);
296
+ }
297
+ }
298
+ };
299
+ function syncController() {
300
+ if (isEnabled()) {
301
+ registerController(controller);
302
+ } else {
303
+ unregisterController(controller);
304
+ }
305
+ }
306
+ onMounted(syncController);
307
+ onBeforeUnmount(function () {
308
+ return unregisterController(controller);
309
+ });
310
+ instance.watch('dragFile', syncController);
311
+ instance.watch('disabled', function (disabled) {
312
+ if (disabled) {
313
+ controller.reset();
314
+ }
315
+ syncController();
316
+ });
317
+ return {
318
+ dragOver: dragOver
319
+ };
320
+ }
@@ -0,0 +1,16 @@
1
+ import { RefObject } from 'intact-vue-next';
2
+ export declare function useSenderInput(textareaRef: RefObject<HTMLTextAreaElement>): {
3
+ isFocus: import("../../hooks/useState").State<boolean>;
4
+ isDisabled: () => boolean;
5
+ isGenerating: () => boolean;
6
+ isLoading: () => boolean;
7
+ isSendButtonDisabled: () => boolean;
8
+ send: () => void;
9
+ stopGenerate: () => void;
10
+ handleKeydown: (e: KeyboardEvent) => void;
11
+ handleInput: (e: Event) => void;
12
+ handleFocus: (e: FocusEvent) => void;
13
+ handleBlur: (e: FocusEvent) => void;
14
+ handleSendClick: () => void;
15
+ focusTextarea: () => void | undefined;
16
+ };
@@ -0,0 +1,101 @@
1
+ import _trimInstanceProperty from "@babel/runtime-corejs3/core-js/instance/trim";
2
+ import { useInstance } from 'intact-vue-next';
3
+ import { useState } from '../../hooks/useState';
4
+ // 输入框相关的交互:focus 状态、键盘事件、发送/停止按钮的状态机。
5
+ // 内部不维护 value,完全依赖 props 受控流。
6
+ export function useSenderInput(textareaRef) {
7
+ var instance = useInstance();
8
+ var isFocus = useState(false);
9
+ function getCurrentAttachments() {
10
+ return instance.get('attachments') || [];
11
+ }
12
+ function getValueText() {
13
+ return instance.get('value') || '';
14
+ }
15
+ /** 是否因为「内容为空且没有附件」而需要禁用发送按钮 */
16
+ function isSendButtonAutoDisabled() {
17
+ var _context;
18
+ return !_trimInstanceProperty(_context = getValueText()).call(_context) && getCurrentAttachments().length === 0;
19
+ }
20
+ function isDisabled() {
21
+ return !!instance.get('disabled');
22
+ }
23
+ function isGenerating() {
24
+ return !!instance.get('generating');
25
+ }
26
+ function isLoading() {
27
+ return !!instance.get('loading');
28
+ }
29
+ /** 发送按钮的最终禁用态:业务强制 disabled 优先,其余按内容自动判定 */
30
+ function isSendButtonDisabled() {
31
+ if (isDisabled() || isLoading()) return true;
32
+ if (isGenerating()) return false;
33
+ return isSendButtonAutoDisabled();
34
+ }
35
+ // 发送消息
36
+ function send() {
37
+ if (isGenerating() || isSendButtonDisabled()) return;
38
+ var value = getValueText();
39
+ var attachments = getCurrentAttachments();
40
+ instance.trigger('messageSend', {
41
+ value: value,
42
+ attachments: attachments
43
+ });
44
+ // 发送后清空输入框和附件
45
+ if (instance.get('clearOnSend')) {
46
+ instance.set('value', '');
47
+ if (attachments.length > 0) {
48
+ instance.set('attachments', []);
49
+ }
50
+ }
51
+ }
52
+ function stopGenerate() {
53
+ instance.trigger('stopGenerate');
54
+ }
55
+ function handleKeydown(e) {
56
+ if (e.key !== 'Enter' || !instance.get('submitOnEnter') || isDisabled() || instance.get('readonly')) return;
57
+ // Shift / 中文 IME 期间不触发提交
58
+ if (e.shiftKey || e.isComposing || e.keyCode === 229) return;
59
+ e.preventDefault();
60
+ instance.trigger('pressEnter', e);
61
+ if (isGenerating()) return;
62
+ send();
63
+ }
64
+ function handleInput(e) {
65
+ var next = e.target.value;
66
+ instance.set('value', next);
67
+ }
68
+ function handleFocus(e) {
69
+ isFocus.set(true);
70
+ instance.trigger('focus', e);
71
+ }
72
+ function handleBlur(e) {
73
+ isFocus.set(false);
74
+ instance.trigger('blur', e);
75
+ }
76
+ function handleSendClick() {
77
+ if (isGenerating()) {
78
+ stopGenerate();
79
+ return;
80
+ }
81
+ send();
82
+ }
83
+ return {
84
+ isFocus: isFocus,
85
+ isDisabled: isDisabled,
86
+ isGenerating: isGenerating,
87
+ isLoading: isLoading,
88
+ isSendButtonDisabled: isSendButtonDisabled,
89
+ send: send,
90
+ stopGenerate: stopGenerate,
91
+ handleKeydown: handleKeydown,
92
+ handleInput: handleInput,
93
+ handleFocus: handleFocus,
94
+ handleBlur: handleBlur,
95
+ handleSendClick: handleSendClick,
96
+ focusTextarea: function focusTextarea() {
97
+ var _textareaRef$value;
98
+ return (_textareaRef$value = textareaRef.value) == null ? void 0 : _textareaRef$value.focus();
99
+ }
100
+ };
101
+ }
@@ -0,0 +1,5 @@
1
+ type AddFiles = (fileList: FileList | File[]) => void;
2
+ export declare function useSenderPaste(addFiles: AddFiles): {
3
+ handlePaste: (e: ClipboardEvent) => void;
4
+ };
5
+ export {};
@@ -0,0 +1,36 @@
1
+ import _Array$from from "@babel/runtime-corejs3/core-js/array/from";
2
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js/instance/filter";
3
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
4
+ import { useInstance } from 'intact-vue-next';
5
+ function getClipboardFiles(e) {
6
+ var _clipboardData$files;
7
+ var clipboardData = e.clipboardData;
8
+ if (!clipboardData) return [];
9
+ var items = clipboardData.items ? _Array$from(clipboardData.items) : [];
10
+ if (items.length) {
11
+ var _context, _context2;
12
+ return _filterInstanceProperty(_context = _mapInstanceProperty(_context2 = _filterInstanceProperty(items).call(items, function (item) {
13
+ return item.kind === 'file';
14
+ })).call(_context2, function (item) {
15
+ return item.getAsFile();
16
+ })).call(_context, function (file) {
17
+ return !!file;
18
+ });
19
+ }
20
+ return (_clipboardData$files = clipboardData.files) != null && _clipboardData$files.length ? _Array$from(clipboardData.files) : [];
21
+ }
22
+ // 粘贴上传只负责把剪贴板里的文件交给统一上传入口;
23
+ // 没有文件时保留原生粘贴文本行为。
24
+ export function useSenderPaste(addFiles) {
25
+ var instance = useInstance();
26
+ function handlePaste(e) {
27
+ if (!instance.get('pasteFile') || instance.get('disabled') || instance.get('readonly')) return;
28
+ var files = getClipboardFiles(e);
29
+ if (!files.length) return;
30
+ e.preventDefault();
31
+ addFiles(files);
32
+ }
33
+ return {
34
+ handlePaste: handlePaste
35
+ };
36
+ }
@@ -0,0 +1,11 @@
1
+ import { RefObject } from 'intact-vue-next';
2
+ import type { SenderAttachment } from './sender';
3
+ export declare function useSenderUpload(fileInputRef: RefObject<HTMLInputElement>): {
4
+ getAcceptAttr: () => string | undefined;
5
+ isMultiple: () => boolean;
6
+ addFiles: (fileList: FileList | File[]) => Promise<void>;
7
+ removeAttachment: (item: SenderAttachment, runBefore?: boolean) => Promise<void>;
8
+ clearAttachments: () => Promise<void>;
9
+ onInputChange: (e: Event) => void;
10
+ pickFiles: () => void;
11
+ };