@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.
- package/__tests__/__snapshots__/Vue Next Demos.md +399 -0
- package/components/bubble/bubble.d.ts +61 -0
- package/components/bubble/bubble.js +81 -0
- package/components/bubble/bubble.vdt.js +85 -0
- package/components/bubble/index.d.ts +1 -0
- package/components/bubble/index.js +1 -0
- package/components/bubble/index.spec.d.ts +1 -0
- package/components/bubble/index.spec.js +771 -0
- package/components/bubble/styles.d.ts +5 -0
- package/components/bubble/styles.js +53 -0
- package/components/bubble/useBubbleDisplay.d.ts +18 -0
- package/components/bubble/useBubbleDisplay.js +300 -0
- package/components/bubbleList/bubbleList.d.ts +87 -0
- package/components/bubbleList/bubbleList.js +75 -0
- package/components/bubbleList/bubbleList.vdt.js +143 -0
- package/components/bubbleList/index.d.ts +1 -0
- package/components/bubbleList/index.js +1 -0
- package/components/bubbleList/index.spec.d.ts +1 -0
- package/components/bubbleList/index.spec.js +1268 -0
- package/components/bubbleList/item.d.ts +16 -0
- package/components/bubbleList/item.js +27 -0
- package/components/bubbleList/item.vdt.js +36 -0
- package/components/bubbleList/styles.d.ts +5 -0
- package/components/bubbleList/styles.js +33 -0
- package/components/bubbleList/useBubbleList.d.ts +28 -0
- package/components/bubbleList/useBubbleList.js +455 -0
- package/components/checkbox/index.d.ts +3 -3
- package/components/fileCard/fileCard.d.ts +65 -0
- package/components/fileCard/fileCard.js +72 -0
- package/components/fileCard/fileCard.vdt.js +161 -0
- package/components/fileCard/fileCardAssets.d.ts +1 -0
- package/components/fileCard/fileCardAssets.js +54 -0
- package/components/fileCard/fileCardUtils.d.ts +14 -0
- package/components/fileCard/fileCardUtils.js +94 -0
- package/components/fileCard/index.d.ts +2 -0
- package/components/fileCard/index.js +2 -0
- package/components/fileCard/index.spec.d.ts +1 -0
- package/components/fileCard/index.spec.js +1096 -0
- package/components/fileCard/list.d.ts +29 -0
- package/components/fileCard/list.js +46 -0
- package/components/fileCard/list.vdt.js +71 -0
- package/components/fileCard/styles.d.ts +5 -0
- package/components/fileCard/styles.js +83 -0
- package/components/fileCard/useFileCard.d.ts +45 -0
- package/components/fileCard/useFileCard.js +330 -0
- package/components/fileCard/useFileCardList.d.ts +14 -0
- package/components/fileCard/useFileCardList.js +49 -0
- package/components/form/form.js +2 -1
- package/components/media/context.d.ts +6 -0
- package/components/media/context.js +2 -0
- package/components/media/group.d.ts +12 -0
- package/components/media/group.js +32 -0
- package/components/media/group.vdt.js +50 -0
- package/components/media/index.d.ts +2 -0
- package/components/media/index.js +2 -0
- package/components/media/index.spec.d.ts +1 -0
- package/components/media/index.spec.js +1691 -0
- package/components/media/media.d.ts +37 -0
- package/components/media/media.js +67 -0
- package/components/media/media.vdt.js +202 -0
- package/components/media/mediaAssets.d.ts +4 -0
- package/components/media/mediaAssets.js +9 -0
- package/components/media/mediaUtils.d.ts +6 -0
- package/components/media/mediaUtils.js +66 -0
- package/components/media/styles.d.ts +13 -0
- package/components/media/styles.js +52 -0
- package/components/media/types.d.ts +37 -0
- package/components/media/types.js +1 -0
- package/components/media/useMedia.d.ts +70 -0
- package/components/media/useMedia.js +471 -0
- package/components/media/useMediaGroup.d.ts +15 -0
- package/components/media/useMediaGroup.js +136 -0
- package/components/media/useMediaViewer.d.ts +14 -0
- package/components/media/useMediaViewer.js +129 -0
- package/components/media/viewer.d.ts +24 -0
- package/components/media/viewer.js +54 -0
- package/components/media/viewer.vdt.js +100 -0
- package/components/radio/index.d.ts +3 -3
- package/components/sender/icons.d.ts +3 -0
- package/components/sender/icons.js +17 -0
- package/components/sender/index.d.ts +1 -0
- package/components/sender/index.js +1 -0
- package/components/sender/index.spec.d.ts +1 -0
- package/components/sender/index.spec.js +1597 -0
- package/components/sender/sender.d.ts +104 -0
- package/components/sender/sender.js +111 -0
- package/components/sender/sender.vdt.js +230 -0
- package/components/sender/styles.d.ts +5 -0
- package/components/sender/styles.js +56 -0
- package/components/sender/useAutoResize.d.ts +4 -0
- package/components/sender/useAutoResize.js +99 -0
- package/components/sender/useSenderDrag.d.ts +6 -0
- package/components/sender/useSenderDrag.js +320 -0
- package/components/sender/useSenderInput.d.ts +16 -0
- package/components/sender/useSenderInput.js +101 -0
- package/components/sender/useSenderPaste.d.ts +5 -0
- package/components/sender/useSenderPaste.js +36 -0
- package/components/sender/useSenderUpload.d.ts +11 -0
- package/components/sender/useSenderUpload.js +395 -0
- package/components/skeleton/skeleton.d.ts +2 -1
- package/components/skeleton/skeleton.js +1 -1
- package/components/think/index.d.ts +1 -0
- package/components/think/index.js +1 -0
- package/components/think/index.spec.d.ts +1 -0
- package/components/think/index.spec.js +345 -0
- package/components/think/index.vdt.js +82 -0
- package/components/think/styles.d.ts +5 -0
- package/components/think/styles.js +25 -0
- package/components/think/think.d.ts +28 -0
- package/components/think/think.js +48 -0
- package/components/think/useThinkExpand.d.ts +10 -0
- package/components/think/useThinkExpand.js +56 -0
- package/components/types.d.ts +4 -2
- package/components/upload/ajaxUploader.d.ts +1 -0
- package/components/upload/ajaxUploader.js +6 -0
- package/components/xmarkdown/index.d.ts +2 -0
- package/components/xmarkdown/index.js +1 -0
- package/components/xmarkdown/index.spec.d.ts +1 -0
- package/components/xmarkdown/index.spec.js +1666 -0
- package/components/xmarkdown/markdown/codeBlockRenderer.d.ts +8 -0
- package/components/xmarkdown/markdown/codeBlockRenderer.js +52 -0
- package/components/xmarkdown/markdown/codeblock.d.ts +8 -0
- package/components/xmarkdown/markdown/codeblock.js +74 -0
- package/components/xmarkdown/markdown/highlight.d.ts +17 -0
- package/components/xmarkdown/markdown/highlight.js +83 -0
- package/components/xmarkdown/markdown/index.d.ts +14 -0
- package/components/xmarkdown/markdown/index.js +14 -0
- package/components/xmarkdown/markdown/mermaid.d.ts +8 -0
- package/components/xmarkdown/markdown/mermaid.js +104 -0
- package/components/xmarkdown/markdown/renderTree.d.ts +54 -0
- package/components/xmarkdown/markdown/renderTree.js +386 -0
- package/components/xmarkdown/markdown/renderer.d.ts +18 -0
- package/components/xmarkdown/markdown/renderer.js +461 -0
- package/components/xmarkdown/markdown/streaming.d.ts +24 -0
- package/components/xmarkdown/markdown/streaming.js +513 -0
- package/components/xmarkdown/markdown/types.d.ts +124 -0
- package/components/xmarkdown/markdown/types.js +6 -0
- package/components/xmarkdown/markdown/utils.d.ts +7 -0
- package/components/xmarkdown/markdown/utils.js +9 -0
- package/components/xmarkdown/markdown.d.ts +1 -0
- package/components/xmarkdown/markdown.js +1 -0
- package/components/xmarkdown/styles.d.ts +5 -0
- package/components/xmarkdown/styles.js +50 -0
- package/components/xmarkdown/useMermaid.d.ts +27 -0
- package/components/xmarkdown/useMermaid.js +745 -0
- package/components/xmarkdown/useXMarkdownContent.d.ts +14 -0
- package/components/xmarkdown/useXMarkdownContent.js +218 -0
- package/components/xmarkdown/useXMarkdownDisplay.d.ts +26 -0
- package/components/xmarkdown/useXMarkdownDisplay.js +569 -0
- package/components/xmarkdown/xmarkdown.d.ts +61 -0
- package/components/xmarkdown/xmarkdown.js +109 -0
- package/components/xmarkdown/xmarkdown.vdt.js +43 -0
- package/dist/fonts/KaTeX_AMS-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_AMS-Regular.woff +0 -0
- package/dist/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Italic.woff +0 -0
- package/dist/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/dist/fonts/KaTeX_Math-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_Math-Italic.woff +0 -0
- package/dist/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Script-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Script-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/dist/i18n/en-US.js +29 -1
- package/dist/i18n/en-US.js.map +1 -1
- package/dist/i18n/en-US.min.js +1 -1
- package/dist/index.js +100506 -37457
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1569 -1
- package/dist/kpc.css +4 -0
- package/dist/ksyun.css +4 -0
- package/i18n/en-US.d.ts +27 -0
- package/i18n/en-US.js +29 -1
- package/index.d.ts +9 -2
- package/index.js +9 -2
- package/package.json +8 -2
- package/styles/global.js +12 -6
- package/yarn-error.log +0 -1012
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import _Symbol from "@babel/runtime-corejs3/core-js/symbol";
|
|
2
|
+
import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-method";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
4
|
+
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
5
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
+
function _unsupportedIterableToArray(o, minLen) { var _context10; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context10 = Object.prototype.toString.call(o)).call(_context10, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
|
+
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
9
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js/instance/filter";
|
|
10
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
|
|
11
|
+
import _trimInstanceProperty from "@babel/runtime-corejs3/core-js/instance/trim";
|
|
12
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js/instance/includes";
|
|
13
|
+
import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js/instance/starts-with";
|
|
14
|
+
import _endsWithInstanceProperty from "@babel/runtime-corejs3/core-js/instance/ends-with";
|
|
15
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/slice";
|
|
16
|
+
import _URL from "@babel/runtime-corejs3/core-js/url";
|
|
17
|
+
import _findIndexInstanceProperty from "@babel/runtime-corejs3/core-js/instance/find-index";
|
|
18
|
+
import _Array$from from "@babel/runtime-corejs3/core-js/array/from";
|
|
19
|
+
import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/splice";
|
|
20
|
+
import { useInstance } from 'intact-vue-next';
|
|
21
|
+
import { request } from '../upload/ajaxUploader';
|
|
22
|
+
import { _$ } from '../../i18n';
|
|
23
|
+
import { isFunction } from 'intact-shared';
|
|
24
|
+
// 用一个递增 id 给本地附件分配 key,与 Upload 组件保持一致策略。
|
|
25
|
+
var uid = 0;
|
|
26
|
+
// 视觉模型默认 accept;普通文本模式不限制。
|
|
27
|
+
var IMAGE_ACCEPT = 'image/*';
|
|
28
|
+
// 内置的「文件选择 + XHR 上传」逻辑。
|
|
29
|
+
// 不直接复用 Upload 内部 hook,因为它强依赖 useInstance() as Upload 的状态形状;
|
|
30
|
+
// 这里直接复用更底层的 request() 和上传约束规则,避免在 Sender 里渲染额外的 Upload 节点。
|
|
31
|
+
export function useSenderUpload(fileInputRef) {
|
|
32
|
+
var instance = useInstance();
|
|
33
|
+
function getUploadProps() {
|
|
34
|
+
return instance.get('uploadProps') || {};
|
|
35
|
+
}
|
|
36
|
+
function getAcceptAttr() {
|
|
37
|
+
var _getUploadProps = getUploadProps(),
|
|
38
|
+
accept = _getUploadProps.accept;
|
|
39
|
+
if (accept) return accept;
|
|
40
|
+
if (instance.get('type') === 'image') return IMAGE_ACCEPT;
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
function isMultiple() {
|
|
44
|
+
var _getUploadProps2 = getUploadProps(),
|
|
45
|
+
multiple = _getUploadProps2.multiple;
|
|
46
|
+
if (multiple !== undefined) return multiple;
|
|
47
|
+
// 默认允许多选,符合常见 AI 对话场景
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
function getAttachments() {
|
|
51
|
+
return instance.get('attachments') || [];
|
|
52
|
+
}
|
|
53
|
+
function setAttachments(next) {
|
|
54
|
+
// 触发 change:attachments,配合 Vue v-model:attachments / React onChangeAttachments
|
|
55
|
+
instance.set('attachments', next);
|
|
56
|
+
}
|
|
57
|
+
function isAcceptValid(file, accept) {
|
|
58
|
+
var _context, _context2;
|
|
59
|
+
if (!accept) return true;
|
|
60
|
+
var tokens = _filterInstanceProperty(_context = _mapInstanceProperty(_context2 = accept.split(',')).call(_context2, function (s) {
|
|
61
|
+
return _trimInstanceProperty(s).call(s);
|
|
62
|
+
})).call(_context, Boolean);
|
|
63
|
+
if (!tokens.length) return true;
|
|
64
|
+
var name = file.name || '';
|
|
65
|
+
var ext = _includesInstanceProperty(name).call(name, '.') ? '.' + name.split('.').pop().toLowerCase() : '';
|
|
66
|
+
var mime = (file.type || '').toLowerCase();
|
|
67
|
+
return tokens.some(function (token) {
|
|
68
|
+
var t = token.toLowerCase();
|
|
69
|
+
if (_startsWithInstanceProperty(t).call(t, '.')) return ext === t;
|
|
70
|
+
if (_endsWithInstanceProperty(t).call(t, '/*')) return _startsWithInstanceProperty(mime).call(mime, _sliceInstanceProperty(t).call(t, 0, -1));
|
|
71
|
+
return mime === t;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/** 把 File 投影成 FileCardListItem 形状的附件 */
|
|
75
|
+
function makeAttachment(file) {
|
|
76
|
+
var _getUploadProps$mapAt, _getUploadProps3;
|
|
77
|
+
var relativePath = file.webkitRelativePath || '';
|
|
78
|
+
var baseItem = {
|
|
79
|
+
uid: uid++,
|
|
80
|
+
name: relativePath || file.name,
|
|
81
|
+
byte: file.size,
|
|
82
|
+
type: file.type,
|
|
83
|
+
status: 'loading',
|
|
84
|
+
percent: 0,
|
|
85
|
+
raw: file,
|
|
86
|
+
relativePath: relativePath || undefined
|
|
87
|
+
};
|
|
88
|
+
baseItem.key = baseItem.uid;
|
|
89
|
+
if (typeof _URL !== 'undefined' && _URL.createObjectURL) {
|
|
90
|
+
// 本地预览 URL,无论上传成功与否都能显示缩略图
|
|
91
|
+
baseItem.src = _URL.createObjectURL(file);
|
|
92
|
+
}
|
|
93
|
+
// 允许业务在运行时补充附件展示字段(如 loadingText / errorText / poster),
|
|
94
|
+
// 但核心上传状态字段仍由 Sender 内部管理。
|
|
95
|
+
var mapped = ((_getUploadProps$mapAt = (_getUploadProps3 = getUploadProps()).mapAttachment) == null ? void 0 : _getUploadProps$mapAt.call(_getUploadProps3, file, baseItem)) || {};
|
|
96
|
+
return _extends({}, baseItem, mapped, {
|
|
97
|
+
uid: baseItem.uid,
|
|
98
|
+
key: baseItem.key,
|
|
99
|
+
raw: baseItem.raw,
|
|
100
|
+
request: baseItem.request,
|
|
101
|
+
byte: baseItem.byte,
|
|
102
|
+
relativePath: baseItem.relativePath,
|
|
103
|
+
status: baseItem.status,
|
|
104
|
+
percent: baseItem.percent
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function updateAttachment(uidVal, patch) {
|
|
108
|
+
var _context3;
|
|
109
|
+
if (uidVal === undefined) return;
|
|
110
|
+
var list = _sliceInstanceProperty(_context3 = getAttachments()).call(_context3, 0);
|
|
111
|
+
var index = _findIndexInstanceProperty(list).call(list, function (a) {
|
|
112
|
+
return a.uid === uidVal;
|
|
113
|
+
});
|
|
114
|
+
if (index === -1) return;
|
|
115
|
+
list[index] = _extends({}, list[index], patch);
|
|
116
|
+
setAttachments(list);
|
|
117
|
+
}
|
|
118
|
+
function performUpload(_x) {
|
|
119
|
+
return _performUpload.apply(this, arguments);
|
|
120
|
+
}
|
|
121
|
+
function _performUpload() {
|
|
122
|
+
_performUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(item) {
|
|
123
|
+
var _extends2;
|
|
124
|
+
var props, action, headers, withCredentials, data, name, timeout, fieldName, extra;
|
|
125
|
+
return _regeneratorRuntime.wrap(function _callee$(_context4) {
|
|
126
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
127
|
+
case 0:
|
|
128
|
+
props = getUploadProps();
|
|
129
|
+
action = props.action, headers = props.headers, withCredentials = props.withCredentials, data = props.data, name = props.name, timeout = props.timeout;
|
|
130
|
+
if (action) {
|
|
131
|
+
_context4.next = 6;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
// 没配 action 视为「仅本地暂存」,立即标记完成;保留 src/raw 让用户在 onMessageSend 时自行处理
|
|
135
|
+
updateAttachment(item.uid, {
|
|
136
|
+
status: 'done',
|
|
137
|
+
percent: 100
|
|
138
|
+
});
|
|
139
|
+
instance.trigger('uploadSuccess', null, item);
|
|
140
|
+
return _context4.abrupt("return");
|
|
141
|
+
case 6:
|
|
142
|
+
fieldName = name || 'file';
|
|
143
|
+
extra = isFunction(data) ? data(item) : data || {};
|
|
144
|
+
item.request = request({
|
|
145
|
+
action: action,
|
|
146
|
+
timeout: timeout,
|
|
147
|
+
headers: headers,
|
|
148
|
+
withCredentials: withCredentials,
|
|
149
|
+
data: _extends((_extends2 = {}, _extends2[fieldName] = item.raw, _extends2), extra),
|
|
150
|
+
onProgress: function onProgress(e, percent) {
|
|
151
|
+
// loading 阶段最多展示到 99%,避免“100% 但仍在上传中”的错觉。
|
|
152
|
+
updateAttachment(item.uid, {
|
|
153
|
+
status: 'loading',
|
|
154
|
+
percent: Math.min(99, percent)
|
|
155
|
+
});
|
|
156
|
+
instance.trigger('uploadProgress', e, item);
|
|
157
|
+
},
|
|
158
|
+
onError: function onError(err) {
|
|
159
|
+
updateAttachment(item.uid, {
|
|
160
|
+
status: 'error',
|
|
161
|
+
errorText: item.errorText || _$('上传失败')
|
|
162
|
+
});
|
|
163
|
+
instance.trigger('uploadError', err, item);
|
|
164
|
+
},
|
|
165
|
+
onSuccess: function onSuccess(res) {
|
|
166
|
+
updateAttachment(item.uid, {
|
|
167
|
+
status: 'done',
|
|
168
|
+
percent: 100
|
|
169
|
+
});
|
|
170
|
+
instance.trigger('uploadSuccess', res, item);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
case 9:
|
|
174
|
+
case "end":
|
|
175
|
+
return _context4.stop();
|
|
176
|
+
}
|
|
177
|
+
}, _callee);
|
|
178
|
+
}));
|
|
179
|
+
return _performUpload.apply(this, arguments);
|
|
180
|
+
}
|
|
181
|
+
function addFiles(_x2) {
|
|
182
|
+
return _addFiles.apply(this, arguments);
|
|
183
|
+
}
|
|
184
|
+
function _addFiles() {
|
|
185
|
+
_addFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(fileList) {
|
|
186
|
+
var props, accept, limit, maxSize, _props$autoUpload, autoUpload, beforeUpload, current, incoming, err, next, queued, _iterator, _step, file, _err, _err2, _item, _i, _queued, item, ok;
|
|
187
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context5) {
|
|
188
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
189
|
+
case 0:
|
|
190
|
+
props = getUploadProps();
|
|
191
|
+
accept = getAcceptAttr();
|
|
192
|
+
limit = props.limit, maxSize = props.maxSize, _props$autoUpload = props.autoUpload, autoUpload = _props$autoUpload === void 0 ? true : _props$autoUpload, beforeUpload = props.beforeUpload;
|
|
193
|
+
current = getAttachments();
|
|
194
|
+
incoming = _Array$from(fileList);
|
|
195
|
+
if (!(limit && current.length + incoming.length > limit)) {
|
|
196
|
+
_context5.next = 9;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
err = new Error(_$('超出文件数量最大限制:{limit}', {
|
|
200
|
+
limit: limit
|
|
201
|
+
}));
|
|
202
|
+
instance.trigger('uploadError', err, undefined);
|
|
203
|
+
return _context5.abrupt("return");
|
|
204
|
+
case 9:
|
|
205
|
+
next = _sliceInstanceProperty(current).call(current, 0); // 暂存待上传项,先一次性入列再异步发起请求,避免 UI 抖动
|
|
206
|
+
queued = [];
|
|
207
|
+
_iterator = _createForOfIteratorHelperLoose(incoming);
|
|
208
|
+
case 12:
|
|
209
|
+
if ((_step = _iterator()).done) {
|
|
210
|
+
_context5.next = 27;
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
file = _step.value;
|
|
214
|
+
if (!(maxSize && file.size > maxSize * 1024)) {
|
|
215
|
+
_context5.next = 18;
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
_err = new Error(_$('"{name}" 超出文件最大限制:{maxSize}kb', {
|
|
219
|
+
name: file.name,
|
|
220
|
+
maxSize: maxSize
|
|
221
|
+
}));
|
|
222
|
+
instance.trigger('uploadError', _err, undefined);
|
|
223
|
+
return _context5.abrupt("continue", 25);
|
|
224
|
+
case 18:
|
|
225
|
+
if (isAcceptValid(file, accept)) {
|
|
226
|
+
_context5.next = 22;
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
_err2 = new Error(_$('"{name}" 文件类型不合法', {
|
|
230
|
+
name: file.name
|
|
231
|
+
}));
|
|
232
|
+
instance.trigger('uploadError', _err2, undefined);
|
|
233
|
+
return _context5.abrupt("continue", 25);
|
|
234
|
+
case 22:
|
|
235
|
+
_item = makeAttachment(file);
|
|
236
|
+
queued.push(_item);
|
|
237
|
+
next.push(_item);
|
|
238
|
+
case 25:
|
|
239
|
+
_context5.next = 12;
|
|
240
|
+
break;
|
|
241
|
+
case 27:
|
|
242
|
+
setAttachments(next);
|
|
243
|
+
_i = 0, _queued = queued;
|
|
244
|
+
case 29:
|
|
245
|
+
if (!(_i < _queued.length)) {
|
|
246
|
+
_context5.next = 42;
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
item = _queued[_i];
|
|
250
|
+
if (!beforeUpload) {
|
|
251
|
+
_context5.next = 38;
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
_context5.next = 34;
|
|
255
|
+
return beforeUpload(item, getAttachments());
|
|
256
|
+
case 34:
|
|
257
|
+
ok = _context5.sent;
|
|
258
|
+
if (ok) {
|
|
259
|
+
_context5.next = 38;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
removeAttachment(item, false);
|
|
263
|
+
return _context5.abrupt("continue", 39);
|
|
264
|
+
case 38:
|
|
265
|
+
if (autoUpload) {
|
|
266
|
+
performUpload(item);
|
|
267
|
+
} else {
|
|
268
|
+
updateAttachment(item.uid, {
|
|
269
|
+
status: 'default'
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
case 39:
|
|
273
|
+
_i++;
|
|
274
|
+
_context5.next = 29;
|
|
275
|
+
break;
|
|
276
|
+
case 42:
|
|
277
|
+
case "end":
|
|
278
|
+
return _context5.stop();
|
|
279
|
+
}
|
|
280
|
+
}, _callee2);
|
|
281
|
+
}));
|
|
282
|
+
return _addFiles.apply(this, arguments);
|
|
283
|
+
}
|
|
284
|
+
function removeAttachment(_x3, _x4) {
|
|
285
|
+
return _removeAttachment.apply(this, arguments);
|
|
286
|
+
}
|
|
287
|
+
function _removeAttachment() {
|
|
288
|
+
_removeAttachment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(item, runBefore) {
|
|
289
|
+
var _context6;
|
|
290
|
+
var props, list, index, ok, next;
|
|
291
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context7) {
|
|
292
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
293
|
+
case 0:
|
|
294
|
+
if (runBefore === void 0) {
|
|
295
|
+
runBefore = true;
|
|
296
|
+
}
|
|
297
|
+
props = getUploadProps();
|
|
298
|
+
list = getAttachments();
|
|
299
|
+
index = _findIndexInstanceProperty(list).call(list, function (a) {
|
|
300
|
+
return a.uid === item.uid;
|
|
301
|
+
});
|
|
302
|
+
if (!(index === -1)) {
|
|
303
|
+
_context7.next = 6;
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
return _context7.abrupt("return");
|
|
307
|
+
case 6:
|
|
308
|
+
if (!(runBefore && props.beforeRemove)) {
|
|
309
|
+
_context7.next = 12;
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
_context7.next = 9;
|
|
313
|
+
return props.beforeRemove(item, list);
|
|
314
|
+
case 9:
|
|
315
|
+
ok = _context7.sent;
|
|
316
|
+
if (ok) {
|
|
317
|
+
_context7.next = 12;
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
return _context7.abrupt("return");
|
|
321
|
+
case 12:
|
|
322
|
+
if (item.request) {
|
|
323
|
+
try {
|
|
324
|
+
item.request.abort();
|
|
325
|
+
} catch (_e) {/* ignore */}
|
|
326
|
+
}
|
|
327
|
+
if (item.src && _startsWithInstanceProperty(_context6 = item.src).call(_context6, 'blob:') && typeof _URL !== 'undefined' && _URL.revokeObjectURL) {
|
|
328
|
+
_URL.revokeObjectURL(item.src);
|
|
329
|
+
}
|
|
330
|
+
next = _sliceInstanceProperty(list).call(list, 0);
|
|
331
|
+
_spliceInstanceProperty(next).call(next, index, 1);
|
|
332
|
+
setAttachments(next);
|
|
333
|
+
case 17:
|
|
334
|
+
case "end":
|
|
335
|
+
return _context7.stop();
|
|
336
|
+
}
|
|
337
|
+
}, _callee3);
|
|
338
|
+
}));
|
|
339
|
+
return _removeAttachment.apply(this, arguments);
|
|
340
|
+
}
|
|
341
|
+
function clearAttachments() {
|
|
342
|
+
return _clearAttachments.apply(this, arguments);
|
|
343
|
+
}
|
|
344
|
+
/** 从原生 file input 拿到 FileList 后清空它,确保用户重新选择同一个文件也能触发 change */
|
|
345
|
+
function _clearAttachments() {
|
|
346
|
+
_clearAttachments = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
347
|
+
var _context8;
|
|
348
|
+
var list, _iterator2, _step2, item;
|
|
349
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context9) {
|
|
350
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
351
|
+
case 0:
|
|
352
|
+
list = _sliceInstanceProperty(_context8 = getAttachments()).call(_context8, 0);
|
|
353
|
+
_iterator2 = _createForOfIteratorHelperLoose(list);
|
|
354
|
+
case 2:
|
|
355
|
+
if ((_step2 = _iterator2()).done) {
|
|
356
|
+
_context9.next = 8;
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
item = _step2.value;
|
|
360
|
+
_context9.next = 6;
|
|
361
|
+
return removeAttachment(item, false);
|
|
362
|
+
case 6:
|
|
363
|
+
_context9.next = 2;
|
|
364
|
+
break;
|
|
365
|
+
case 8:
|
|
366
|
+
case "end":
|
|
367
|
+
return _context9.stop();
|
|
368
|
+
}
|
|
369
|
+
}, _callee4);
|
|
370
|
+
}));
|
|
371
|
+
return _clearAttachments.apply(this, arguments);
|
|
372
|
+
}
|
|
373
|
+
function onInputChange(e) {
|
|
374
|
+
var input = e.target;
|
|
375
|
+
if (input.files && input.files.length) {
|
|
376
|
+
addFiles(input.files);
|
|
377
|
+
}
|
|
378
|
+
input.value = '';
|
|
379
|
+
}
|
|
380
|
+
/** 触发左下角 + 号按钮的文件选择 */
|
|
381
|
+
function pickFiles() {
|
|
382
|
+
var _fileInputRef$value;
|
|
383
|
+
if (instance.get('disabled')) return;
|
|
384
|
+
(_fileInputRef$value = fileInputRef.value) == null || _fileInputRef$value.click();
|
|
385
|
+
}
|
|
386
|
+
return {
|
|
387
|
+
getAcceptAttr: getAcceptAttr,
|
|
388
|
+
isMultiple: isMultiple,
|
|
389
|
+
addFiles: addFiles,
|
|
390
|
+
removeAttachment: removeAttachment,
|
|
391
|
+
clearAttachments: clearAttachments,
|
|
392
|
+
onInputChange: onInputChange,
|
|
393
|
+
pickFiles: pickFiles
|
|
394
|
+
};
|
|
395
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Component, TypeDefs } from 'intact-vue-next';
|
|
2
|
+
import { Sizes } from '../types';
|
|
2
3
|
export interface SkeletonProps {
|
|
3
4
|
loading: boolean;
|
|
4
5
|
animated?: boolean;
|
|
5
6
|
rows?: number;
|
|
6
7
|
avator?: boolean;
|
|
7
|
-
size?:
|
|
8
|
+
size?: Sizes;
|
|
8
9
|
}
|
|
9
10
|
export interface SkeletonEvents {
|
|
10
11
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './think';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './think';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|