@king-design/vue 3.6.2 → 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/anchor/constants.d.ts +2 -0
- package/components/anchor/constants.js +2 -0
- package/components/anchor/index.d.ts +41 -0
- package/components/anchor/index.js +141 -0
- package/components/anchor/index.spec.d.ts +1 -0
- package/components/anchor/index.spec.js +230 -0
- package/components/anchor/index.vdt.js +31 -0
- package/components/anchor/link.d.ts +16 -0
- package/components/anchor/link.js +52 -0
- package/components/anchor/link.vdt.js +49 -0
- package/components/anchor/styles.d.ts +5 -0
- package/components/anchor/styles.js +30 -0
- package/components/anchor/useScroll.d.ts +7 -0
- package/components/anchor/useScroll.js +218 -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/dialog/base.vdt.js +1 -1
- package/components/drawer/index.d.ts +3 -0
- package/components/drawer/index.js +22 -3
- package/components/drawer/index.spec.js +83 -0
- package/components/drawer/index.vdt.js +23 -3
- package/components/drawer/styles.js +1 -1
- package/components/drawer/useDrawerResizable.d.ts +10 -0
- package/components/drawer/useDrawerResizable.js +162 -0
- 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/menu/styles.d.ts +1 -0
- package/components/menu/styles.js +4 -1
- package/components/notification/index.d.ts +1 -0
- package/components/notification/index.js +1 -0
- package/components/notification/index.spec.d.ts +1 -0
- package/components/notification/index.spec.js +317 -0
- package/components/notification/notification.d.ts +39 -0
- package/components/notification/notification.js +183 -0
- package/components/notification/notification.vdt.js +56 -0
- package/components/notification/notifications.d.ts +16 -0
- package/components/notification/notifications.js +51 -0
- package/components/notification/notifications.vdt.js +24 -0
- package/components/notification/styles.d.ts +9 -0
- package/components/notification/styles.js +110 -0
- package/components/radio/index.d.ts +3 -3
- package/components/select/styles.js +1 -1
- 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/table/styles.js +1 -1
- package/components/tabs/useActiveBar.js +7 -3
- package/components/tag/base.d.ts +2 -0
- package/components/tag/base.js +3 -0
- package/components/tag/index.spec.js +17 -0
- package/components/tag/index.vdt.js +12 -5
- package/components/tag/styles.d.ts +9 -0
- package/components/tag/styles.js +14 -1
- package/components/tag/useColor.d.ts +7 -0
- package/components/tag/useColor.js +71 -0
- 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/timepicker/index.spec.js +70 -42
- package/components/timepicker/useDefaultValue.js +12 -7
- package/components/timepicker/useStep.js +4 -2
- package/components/transfer/index.d.ts +13 -0
- package/components/transfer/index.js +6 -2
- package/components/transfer/index.spec.js +197 -0
- package/components/transfer/index.vdt.js +28 -5
- package/components/transfer/styles.js +4 -1
- package/components/transfer/useCheck.js +2 -1
- package/components/transfer/usePagination.d.ts +12 -0
- package/components/transfer/usePagination.js +79 -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/fonts/iconfont.eot +0 -0
- package/dist/fonts/iconfont.svg +235 -0
- package/dist/fonts/iconfont.ttf +0 -0
- package/dist/fonts/iconfont.woff +0 -0
- package/dist/fonts/iconfont.woff2 +0 -0
- package/dist/fonts/ionicons.eot +0 -0
- package/dist/fonts/ionicons.svg +2230 -0
- package/dist/fonts/ionicons.ttf +0 -0
- package/dist/fonts/ionicons.woff +0 -0
- package/dist/fonts/ionicons.woff2 +0 -0
- package/dist/i18n/en-US.js +1439 -0
- package/dist/i18n/en-US.js.map +1 -0
- package/dist/i18n/en-US.min.js +1 -0
- package/dist/i18n/index.js +283 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/index.min.js +1 -0
- package/dist/index.js +121177 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +1569 -0
- 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 +11 -2
- package/index.js +11 -2
- package/install.js +2 -0
- package/package.json +10 -2
- package/styles/fonts/iconfont.eot +0 -0
- package/styles/fonts/iconfont.js +1 -1
- package/styles/fonts/iconfont.svg +38 -0
- package/styles/fonts/iconfont.ttf +0 -0
- package/styles/fonts/iconfont.woff +0 -0
- package/styles/fonts/iconfont.woff2 +0 -0
- package/styles/global.js +12 -6
- package/styles/theme.d.ts +8 -0
- package/styles/theme.js +5 -1
- package/yarn-error.log +0 -1013
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Component, TypeDefs } from 'intact-vue-next';
|
|
2
|
+
import type { Events } from '../types';
|
|
3
|
+
import type { FileCardProps, FileCardSize } from './fileCard';
|
|
4
|
+
export interface FileCardListItem extends FileCardProps {
|
|
5
|
+
key?: string | number;
|
|
6
|
+
}
|
|
7
|
+
export interface FileCardListProps {
|
|
8
|
+
items?: FileCardListItem[];
|
|
9
|
+
size?: FileCardSize;
|
|
10
|
+
overflow?: 'wrap' | 'scrollX' | 'scrollY';
|
|
11
|
+
deleteable?: boolean;
|
|
12
|
+
showNameTooltip?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface FileCardListBlocks {
|
|
15
|
+
extension: null;
|
|
16
|
+
}
|
|
17
|
+
export interface FileCardListEvents {
|
|
18
|
+
preview: [FileCardListItem, MouseEvent];
|
|
19
|
+
delete: [FileCardListItem, MouseEvent];
|
|
20
|
+
click: [FileCardListItem, MouseEvent];
|
|
21
|
+
}
|
|
22
|
+
export declare class FileCardList extends Component<FileCardListProps, FileCardListEvents, FileCardListBlocks> {
|
|
23
|
+
static template: string | import('intact-vue-next').Template<any>;
|
|
24
|
+
static typeDefs: Required<TypeDefs<FileCardListProps>>;
|
|
25
|
+
static defaults: () => Partial<FileCardListProps>;
|
|
26
|
+
static events: Events<FileCardListEvents>;
|
|
27
|
+
private config;
|
|
28
|
+
private list;
|
|
29
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
2
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
3
|
+
import { Component } from 'intact-vue-next';
|
|
4
|
+
import template from './list.vdt';
|
|
5
|
+
import { useConfigContext } from '../config';
|
|
6
|
+
import { useFileCardList } from './useFileCardList';
|
|
7
|
+
var typeDefs = {
|
|
8
|
+
items: Array,
|
|
9
|
+
size: ['mini', 'small', 'default', 'large'],
|
|
10
|
+
overflow: ['wrap', 'scrollX', 'scrollY'],
|
|
11
|
+
deleteable: Boolean,
|
|
12
|
+
showNameTooltip: Boolean
|
|
13
|
+
};
|
|
14
|
+
var defaults = function defaults() {
|
|
15
|
+
return {
|
|
16
|
+
items: [],
|
|
17
|
+
size: 'default',
|
|
18
|
+
overflow: 'wrap',
|
|
19
|
+
deleteable: false,
|
|
20
|
+
showNameTooltip: false
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
var events = {
|
|
24
|
+
preview: true,
|
|
25
|
+
delete: true,
|
|
26
|
+
click: true
|
|
27
|
+
};
|
|
28
|
+
export var FileCardList = /*#__PURE__*/function (_Component) {
|
|
29
|
+
_inheritsLoose(FileCardList, _Component);
|
|
30
|
+
function FileCardList() {
|
|
31
|
+
var _context;
|
|
32
|
+
var _this;
|
|
33
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
34
|
+
args[_key] = arguments[_key];
|
|
35
|
+
}
|
|
36
|
+
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
|
|
37
|
+
_this.config = useConfigContext();
|
|
38
|
+
_this.list = useFileCardList();
|
|
39
|
+
return _this;
|
|
40
|
+
}
|
|
41
|
+
return FileCardList;
|
|
42
|
+
}(Component);
|
|
43
|
+
FileCardList.template = template;
|
|
44
|
+
FileCardList.typeDefs = typeDefs;
|
|
45
|
+
FileCardList.defaults = defaults;
|
|
46
|
+
FileCardList.events = events;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
+
import { createVNode as _$cv, className as _$cn, map as _$ma, createUnknownComponentVNode as _$cc, createElementVNode as _$ce } from 'intact-vue-next';
|
|
3
|
+
import { isInvalid, noop } from 'intact-shared';
|
|
4
|
+
import { getRestProps, isEmptyString } from '../utils';
|
|
5
|
+
import { makeStyles } from './styles';
|
|
6
|
+
import { FileCard } from './fileCard';
|
|
7
|
+
export default function ($props, $blocks, $__proto__) {
|
|
8
|
+
var _extends2;
|
|
9
|
+
$blocks || ($blocks = {});
|
|
10
|
+
$props || ($props = {});
|
|
11
|
+
var $this = this;
|
|
12
|
+
var _this$list = this.list,
|
|
13
|
+
getClassNameObj = _this$list.getClassNameObj,
|
|
14
|
+
getItemKey = _this$list.getItemKey,
|
|
15
|
+
getItemSize = _this$list.getItemSize,
|
|
16
|
+
shouldShowDelete = _this$list.shouldShowDelete,
|
|
17
|
+
shouldShowNameTooltip = _this$list.shouldShowNameTooltip,
|
|
18
|
+
onItemPreview = _this$list.onItemPreview,
|
|
19
|
+
onItemDelete = _this$list.onItemDelete,
|
|
20
|
+
onItemClick = _this$list.onItemClick;
|
|
21
|
+
var _this$get = this.get(),
|
|
22
|
+
className = _this$get.className,
|
|
23
|
+
items = _this$get.items;
|
|
24
|
+
var k = this.config.k;
|
|
25
|
+
var isEmptySlot = function isEmptySlot(value) {
|
|
26
|
+
if (isInvalid(value) || isEmptyString(value)) return true;
|
|
27
|
+
if (Array.isArray(value)) return value.every(function (item) {
|
|
28
|
+
return isEmptySlot(item);
|
|
29
|
+
});
|
|
30
|
+
if (value && value.type === 1) return isEmptySlot(value.children);
|
|
31
|
+
return false;
|
|
32
|
+
};
|
|
33
|
+
var extensionSlot = $blocks.extension ? $blocks.extension(noop, items) : undefined;
|
|
34
|
+
var hasExtensionSlot = !isEmptySlot(extensionSlot);
|
|
35
|
+
var classNameObj = _extends({}, getClassNameObj(), (_extends2 = {}, _extends2[className] = className, _extends2[makeStyles(k)] = true, _extends2));
|
|
36
|
+
return _$cv('div', _extends({
|
|
37
|
+
'className': _$cn(classNameObj)
|
|
38
|
+
}, getRestProps(this)), [_$ma(items, function ($value, $key) {
|
|
39
|
+
return _$cc(FileCard, {
|
|
40
|
+
'key': getItemKey($value, $key),
|
|
41
|
+
'name': $value.name,
|
|
42
|
+
'type': $value.type,
|
|
43
|
+
'status': $value.status,
|
|
44
|
+
'src': $value.src,
|
|
45
|
+
'poster': $value.poster,
|
|
46
|
+
'description': $value.description,
|
|
47
|
+
'errorText': $value.errorText,
|
|
48
|
+
'loadingText': $value.loadingText,
|
|
49
|
+
'byte': $value.byte,
|
|
50
|
+
'percent': $value.percent,
|
|
51
|
+
'showPreview': $value.showPreview,
|
|
52
|
+
'showNameTooltip': shouldShowNameTooltip($value),
|
|
53
|
+
'showDelIcon': shouldShowDelete($value),
|
|
54
|
+
'icon': $value.icon,
|
|
55
|
+
'size': getItemSize($value),
|
|
56
|
+
'imageProps': $value.imageProps,
|
|
57
|
+
'videoProps': $value.videoProps,
|
|
58
|
+
'audioProps': $value.audioProps,
|
|
59
|
+
'ev-click': function evClick(value, e) {
|
|
60
|
+
return onItemClick($value, value, e);
|
|
61
|
+
},
|
|
62
|
+
'ev-preview': function evPreview(value, e) {
|
|
63
|
+
return onItemPreview($value, value, e);
|
|
64
|
+
},
|
|
65
|
+
'ev-delete': function evDelete(value, e) {
|
|
66
|
+
return onItemDelete($value, value, e);
|
|
67
|
+
}
|
|
68
|
+
}, getItemKey($value, $key));
|
|
69
|
+
}, $this), hasExtensionSlot ? _$ce(2, 'div', extensionSlot, 0, _$cn(k + "-file-card-list-extension")) : undefined]);
|
|
70
|
+
}
|
|
71
|
+
;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { css } from '@emotion/css';
|
|
2
|
+
import { theme, setDefault } from '../../styles/theme';
|
|
3
|
+
import { deepDefaults, setAlpha } from '../../styles/utils';
|
|
4
|
+
import '../../styles/global';
|
|
5
|
+
import { cache } from '../utils';
|
|
6
|
+
var defaults = {
|
|
7
|
+
radius: '4px',
|
|
8
|
+
border: '1px solid #E5E8EE',
|
|
9
|
+
titleColor: '#3F3F51',
|
|
10
|
+
descriptionColor: '#868A9C',
|
|
11
|
+
progressBg: '#f0f2f4',
|
|
12
|
+
file: {
|
|
13
|
+
mini: {
|
|
14
|
+
width: '160px',
|
|
15
|
+
minHeight: '34px',
|
|
16
|
+
iconSize: '24px',
|
|
17
|
+
padding: '5px 10px',
|
|
18
|
+
gap: '8px'
|
|
19
|
+
},
|
|
20
|
+
small: {
|
|
21
|
+
width: '160px',
|
|
22
|
+
minHeight: '44px',
|
|
23
|
+
iconSize: '32px',
|
|
24
|
+
padding: '6px 12px',
|
|
25
|
+
gap: '8px'
|
|
26
|
+
},
|
|
27
|
+
default: {
|
|
28
|
+
width: '160px',
|
|
29
|
+
minHeight: '54px',
|
|
30
|
+
iconSize: '32px',
|
|
31
|
+
padding: '8px 12px',
|
|
32
|
+
gap: '8px'
|
|
33
|
+
},
|
|
34
|
+
large: {
|
|
35
|
+
width: '192px',
|
|
36
|
+
minHeight: '64px',
|
|
37
|
+
iconSize: '40px',
|
|
38
|
+
padding: '12px 14px',
|
|
39
|
+
gap: '10px'
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
fileIcon: {
|
|
43
|
+
defaultColor: '#596079',
|
|
44
|
+
pdfColor: '#D14343',
|
|
45
|
+
docColor: '#2D6AE3',
|
|
46
|
+
sheetColor: '#228B52',
|
|
47
|
+
slideColor: '#D97706',
|
|
48
|
+
archiveColor: '#6F52D9',
|
|
49
|
+
imageColor: '#0B84C6',
|
|
50
|
+
videoColor: '#D83A74',
|
|
51
|
+
audioColor: '#AF7C00'
|
|
52
|
+
},
|
|
53
|
+
maskBg: 'linear-gradient(180deg, rgba(21, 27, 30, 0.04), rgba(21, 27, 30, 0.62))',
|
|
54
|
+
/** 与 Upload 画廊 `overlap` 一致,用于图片默认预览遮罩 */
|
|
55
|
+
imagePreview: {
|
|
56
|
+
bgColor: 'rgba(21, 27, 30, .5)',
|
|
57
|
+
color: '#fff',
|
|
58
|
+
iconGap: '16px'
|
|
59
|
+
},
|
|
60
|
+
errorMaskBg: 'rgba(21, 27, 30, 0.46)',
|
|
61
|
+
errorTextColor: theme.color.danger,
|
|
62
|
+
actionBg: 'rgba(255, 255, 255, 0.18)',
|
|
63
|
+
actionColor: '#FFFFFF',
|
|
64
|
+
actionHoverBg: 'rgba(255, 255, 255, 0.26)',
|
|
65
|
+
deleteBg: 'rgba(63, 68, 81, 0.72)',
|
|
66
|
+
deleteColor: '#FFFFFF',
|
|
67
|
+
deleteHoverBg: 'rgba(63, 68, 81, 0.82)',
|
|
68
|
+
deleteHoverColor: '#FFFFFF',
|
|
69
|
+
deleteShadow: '0 2px 8px rgba(15, 23, 42, 0.16)',
|
|
70
|
+
listGap: '8px',
|
|
71
|
+
scrollbarThumb: 'rgba(63, 68, 81, 0.26)',
|
|
72
|
+
scrollbarThumbHover: 'rgba(63, 68, 81, 0.42)'
|
|
73
|
+
};
|
|
74
|
+
var fileCard;
|
|
75
|
+
setDefault(function () {
|
|
76
|
+
fileCard = deepDefaults(theme, {
|
|
77
|
+
fileCard: defaults
|
|
78
|
+
}).fileCard;
|
|
79
|
+
makeStyles == null || makeStyles.clearCache();
|
|
80
|
+
});
|
|
81
|
+
export var makeStyles = cache(function makeStyles(k) {
|
|
82
|
+
return /*#__PURE__*/css("&.", k, "-file-card{position:relative;display:inline-flex;flex:0 0 auto;align-self:flex-start;vertical-align:top;width:auto;max-width:100%;min-width:0;border:", fileCard.border, ";border-radius:", fileCard.radius, ";background:#FFFFFF;box-sizing:border-box;overflow:visible;}&.", k, "-file-card.", k, "-file-card-file{width:", fileCard.file.small.width, ";min-height:", fileCard.file.small.minHeight, ";border:", fileCard.border, ";border-radius:", fileCard.radius, ";}&.", k, "-file-card.", k, "-file-card-file.", k, "-file-card-mini{width:", fileCard.file.mini.width, ";min-height:", fileCard.file.mini.minHeight, ";}&.", k, "-file-card.", k, "-file-card-file.", k, "-file-card-small{width:", fileCard.file.small.width, ";min-height:", fileCard.file.small.minHeight, ";}&.", k, "-file-card.", k, "-file-card-file.", k, "-file-card-default{width:", fileCard.file.default.width, ";min-height:", fileCard.file.default.minHeight, ";}&.", k, "-file-card.", k, "-file-card-file.", k, "-file-card-large{width:", fileCard.file.large.width, ";min-height:", fileCard.file.large.minHeight, ";}&.", k, "-file-card.", k, "-file-card-media.", k, "-file-card-type-image{border:none;background:transparent;}&.", k, "-file-card.", k, "-file-card-media.", k, "-file-card-type-video{border:none;background:transparent;}&.", k, "-file-card.", k, "-file-card-media.", k, "-file-card-type-audio{border:none;background:transparent;}.", k, "-file-card-media-shell{position:relative;min-width:0;box-sizing:border-box;}.", k, "-file-card-media-view{display:inline-flex;}.", k, "-file-card-media-status-layer{position:absolute;inset:0;z-index:4;display:flex;align-items:center;justify-content:center;pointer-events:none;}.", k, "-file-card-media-status-layer>*{pointer-events:auto;}.", k, "-file-card-media-error-artwork-content{display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;height:100%;min-width:0;gap:4px;padding:0 4px;border-radius:inherit;background:#F3F5F6;box-sizing:border-box;}.", k, "-file-card-media-error-artwork-icon{display:block;width:32px;height:32px;flex:0 0 auto;}.", k, "-file-card-file-shell{position:relative;width:100%;min-width:0;border-radius:inherit;overflow:hidden;background:linear-gradient(\n 90deg,\n ", fileCard.progressBg, " 0 var(--file-card-progress-percent, 0%),\n #FFFFFF var(--file-card-progress-percent, 0%) 100%\n );}.", k, "-file-card-file-main{display:flex;align-items:center;width:100%;min-width:0;gap:", fileCard.file.small.gap, ";padding:", fileCard.file.small.padding, ";box-sizing:border-box;}&.", k, "-file-card.", k, "-file-card-mini .", k, "-file-card-file-main{gap:", fileCard.file.mini.gap, ";padding:", fileCard.file.mini.padding, ";}&.", k, "-file-card.", k, "-file-card-large .", k, "-file-card-file-main{gap:", fileCard.file.large.gap, ";padding:", fileCard.file.large.padding, ";}&.", k, "-file-card.", k, "-file-card-default .", k, "-file-card-file-main{gap:", fileCard.file.default.gap, ";padding:", fileCard.file.default.padding, ";}.", k, "-file-card-file-icon,.", k, "-file-card-file-media-view{width:", fileCard.file.small.iconSize, ";height:", fileCard.file.small.iconSize, ";flex:0 0 auto;border-radius:4px;overflow:hidden;}.", k, "-file-card-file-icon{display:inline-flex;align-items:center;justify-content:center;font-size:11px;font-weight:700;letter-spacing:0.04em;color:", fileCard.fileIcon.defaultColor, ";}.", k, "-file-card-file-icon .", k, "-icon{font-size:16px;line-height:1;}&.", k, "-file-card.", k, "-file-card-mini .", k, "-file-card-file-icon,&.", k, "-file-card.", k, "-file-card-mini .", k, "-file-card-file-media-view{width:", fileCard.file.mini.iconSize, ";height:", fileCard.file.mini.iconSize, ";}&.", k, "-file-card.", k, "-file-card-mini .", k, "-file-card-file-icon{font-size:10px;}&.", k, "-file-card.", k, "-file-card-default .", k, "-file-card-file-icon,&.", k, "-file-card.", k, "-file-card-default .", k, "-file-card-file-media-view{width:", fileCard.file.default.iconSize, ";height:", fileCard.file.default.iconSize, ";}&.", k, "-file-card.", k, "-file-card-large .", k, "-file-card-file-icon,&.", k, "-file-card.", k, "-file-card-large .", k, "-file-card-file-media-view{width:", fileCard.file.large.iconSize, ";height:", fileCard.file.large.iconSize, ";}.", k, "-file-card-file-icon-img{display:block;width:100%;height:100%;object-fit:cover;}.", k, "-file-card-file-icon-pdf{color:", fileCard.fileIcon.pdfColor, ";}.", k, "-file-card-file-icon-doc{color:", fileCard.fileIcon.docColor, ";}.", k, "-file-card-file-icon-sheet{color:", fileCard.fileIcon.sheetColor, ";}.", k, "-file-card-file-icon-slide{color:", fileCard.fileIcon.slideColor, ";}.", k, "-file-card-file-icon-archive{color:", fileCard.fileIcon.archiveColor, ";}.", k, "-file-card-file-icon-image{color:", fileCard.fileIcon.imageColor, ";}.", k, "-file-card-file-icon-video{color:", fileCard.fileIcon.videoColor, ";}.", k, "-file-card-file-icon-audio{color:", fileCard.fileIcon.audioColor, ";}.", k, "-file-card-file-content{flex:1;min-width:0;}.", k, "-file-card-title{display:flex;align-items:baseline;min-width:0;color:", fileCard.titleColor, ";font-weight:400;}&.", k, "-file-card.", k, "-file-card-mini .", k, "-file-card-title{font-size:13px;line-height:18px;}&.", k, "-file-card.", k, "-file-card-large .", k, "-file-card-title{font-size:15px;line-height:22px;}.", k, "-file-card-title-prefix{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.", k, "-file-card-title-suffix{flex:0 0 auto;white-space:nowrap;}.", k, "-file-card-title-status{color:", fileCard.titleColor, ";}.", k, "-file-card-title-status-error{color:", theme.color.danger, ";}.", k, "-file-card-description{color:", fileCard.descriptionColor, ";font-size:12px;line-height:18px;margin-top:2px;}&.", k, "-file-card.", k, "-file-card-mini .", k, "-file-card-description{display:none;}.", k, "-file-card-action{color:inherit;border-radius:999px;background:transparent;transition:background ", theme.transition.small, ",color ", theme.transition.small, ",opacity ", theme.transition.small, ";}.", k, "-file-card-mask{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;border-radius:inherit;}.", k, "-file-card-mask{gap:10px;background:", fileCard.maskBg, ";opacity:0;transition:opacity ", theme.transition.small, ";pointer-events:none;}.", k, "-file-card-error-text{display:inline-flex;align-items:center;justify-content:center;max-width:100%;min-width:0;color:", fileCard.errorTextColor, ";font-size:12px;line-height:18px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}.", k, "-file-card-media-error-artwork-text{width:auto;max-width:100%;box-sizing:border-box;color:#FF4433;font-size:12px;line-height:12px;text-shadow:none;}.", k, "-file-card-mask>*{pointer-events:auto;}.", k, "-file-card-mask .", k, "-file-card-action{color:", fileCard.actionColor, ";background:", fileCard.actionBg, ";}.", k, "-file-card-mask .", k, "-file-card-action:hover{background:", fileCard.actionHoverBg, ";}&.", k, "-file-card:hover .", k, "-file-card-mask{opacity:1;}&.", k, "-file-card.", k, "-file-card-type-image .", k, "-file-card-mask{background:", fileCard.imagePreview.bgColor, ";gap:", fileCard.imagePreview.iconGap, ";color:", fileCard.imagePreview.color, ";transition:opacity ", theme.transition.middle, ";}&.", k, "-file-card.", k, "-file-card-type-image .", k, "-file-card-mask .", k, "-icon:not(:hover){color:inherit;}.", k, "-file-card-file-mask{background:rgba(255, 255, 255, 0.92);gap:8px;}.", k, "-file-card-file-mask .", k, "-file-card-action{color:#5D6378;background:rgba(63, 68, 81, 0.08);}.", k, "-file-card-file-mask .", k, "-file-card-action:hover{color:", theme.color.primary, ";background:", setAlpha(theme.color.primary, 0.12), ";}.", k, "-file-card-media-loading-text{display:inline-flex;align-items:center;justify-content:center;max-width:100%;min-width:0;color:#FFFFFF;font-size:12px;line-height:18px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-shadow:0 1px 2px rgba(0, 0, 0, 0.28);}&.", k, "-file-card.", k, "-file-card-type-audio .", k, "-file-card-media-loading-text{color:#3A3D52;text-shadow:none;}.", k, "-file-card-media-progress-text{position:absolute;top:3px;left:20px;z-index:4;color:#FFFFFF;font-size:11px;line-height:14px;white-space:nowrap;text-shadow:0 1px 2px rgba(0, 0, 0, 0.35);}&.", k, "-file-card>.", k, "-file-card-delete{position:absolute;top:2px;right:2px;z-index:4;display:inline-flex;align-items:center;justify-content:center;width:16px;min-width:16px;height:16px;min-height:16px;flex:0 0 16px;margin:0;padding:0;border:none;border-radius:50%;cursor:pointer;color:", fileCard.deleteColor, ";background:", fileCard.deleteBg, ";box-shadow:", fileCard.deleteShadow, ";box-sizing:border-box;line-height:1;outline:none;opacity:0;pointer-events:none;transition:background ", theme.transition.small, ",opacity ", theme.transition.small, ";}&.", k, "-file-card>.", k, "-file-card-delete .", k, "-icon{margin:0;color:inherit;font-size:10px;line-height:1;}&.", k, "-file-card.", k, "-file-card-mini>.", k, "-file-card-delete{width:12px;min-width:12px;height:12px;min-height:12px;flex-basis:12px;}&.", k, "-file-card.", k, "-file-card-mini>.", k, "-file-card-delete .", k, "-icon{font-size:8px;}&.", k, "-file-card:hover>.", k, "-file-card-delete{opacity:1;pointer-events:auto;}&.", k, "-file-card>.", k, "-file-card-delete:hover,&.", k, "-file-card>.", k, "-file-card-delete:focus{color:", fileCard.deleteHoverColor, ";background:", fileCard.deleteHoverBg, ";box-shadow:", fileCard.deleteShadow, ";}&.", k, "-file-card.", k, "-file-card-error .", k, "-file-card-description{color:", theme.color.danger, ";}&.", k, "-file-card-list{display:flex;gap:", fileCard.listGap, ";align-items:flex-start;}&.", k, "-file-card-list-wrap{flex-wrap:wrap;align-items:flex-start;}&.", k, "-file-card-list-scrollX{flex-wrap:nowrap;overflow-x:auto;overflow-y:hidden;box-sizing:border-box;width:100%;max-width:100%;min-width:0;scrollbar-width:thin;scrollbar-color:transparent transparent;scrollbar-gutter:stable;}&.", k, "-file-card-list-scrollY{flex-wrap:wrap;align-content:flex-start;overflow-y:auto;overflow-x:hidden;box-sizing:border-box;height:100%;max-height:108px;min-height:0;max-width:100%;padding-right:6px;scrollbar-width:thin;scrollbar-color:transparent transparent;scrollbar-gutter:stable;}&.", k, "-file-card-list-scrollX::-webkit-scrollbar{height:8px;}&.", k, "-file-card-list-scrollY::-webkit-scrollbar{width:8px;}&.", k, "-file-card-list-scrollX::-webkit-scrollbar-track,&.", k, "-file-card-list-scrollY::-webkit-scrollbar-track{background:transparent;}&.", k, "-file-card-list-scrollX::-webkit-scrollbar-thumb,&.", k, "-file-card-list-scrollY::-webkit-scrollbar-thumb{border-radius:999px;border:2px solid transparent;background:transparent;background-clip:content-box;}&.", k, "-file-card-list-scrollX:hover,&.", k, "-file-card-list-scrollY:hover{scrollbar-color:", fileCard.scrollbarThumb, " transparent;}&.", k, "-file-card-list-scrollX:hover::-webkit-scrollbar-thumb,&.", k, "-file-card-list-scrollY:hover::-webkit-scrollbar-thumb{background:", fileCard.scrollbarThumb, ";background-clip:content-box;}&.", k, "-file-card-list-scrollX:hover::-webkit-scrollbar-thumb:hover,&.", k, "-file-card-list-scrollY:hover::-webkit-scrollbar-thumb:hover{background:", fileCard.scrollbarThumbHover, ";background-clip:content-box;}.", k, "-file-card-list-extension{flex:0 0 auto;}");
|
|
83
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { MediaStatus, MediaType } from '../media';
|
|
2
|
+
import type { FileCardValue } from './fileCard';
|
|
3
|
+
export declare function useFileCard(): {
|
|
4
|
+
getRootClassNameObj: () => {
|
|
5
|
+
[x: string]: boolean;
|
|
6
|
+
};
|
|
7
|
+
getProgressStyle: () => string | undefined;
|
|
8
|
+
onClick: (e: MouseEvent) => void;
|
|
9
|
+
isMediaType: () => boolean;
|
|
10
|
+
shouldShowDeleteButton: () => boolean;
|
|
11
|
+
onDelete: (e: MouseEvent) => void;
|
|
12
|
+
getValue: () => FileCardValue;
|
|
13
|
+
onPreview: (media: any, e: MouseEvent) => void;
|
|
14
|
+
isLoading: () => boolean;
|
|
15
|
+
isError: () => boolean;
|
|
16
|
+
getMediaLoadingText: () => string;
|
|
17
|
+
getMediaErrorText: () => string;
|
|
18
|
+
getMediaErrorArtworkIconSrc: () => string;
|
|
19
|
+
shouldShowMediaStatusLayer: () => boolean;
|
|
20
|
+
shouldRenderMediaErrorArtwork: () => boolean;
|
|
21
|
+
shouldUseMediaErrorArtworkLayout: () => boolean;
|
|
22
|
+
shouldShowVisualMediaProgressText: () => boolean;
|
|
23
|
+
getMediaProgressText: () => string;
|
|
24
|
+
getFileBadgeClassName: () => "default" | "audio" | "video" | "image" | "slide" | "sheet" | "pdf" | "doc" | "archive";
|
|
25
|
+
getFileBadgeText: () => string;
|
|
26
|
+
hasCustomIcon: () => boolean;
|
|
27
|
+
getIconSource: () => string;
|
|
28
|
+
hasBuiltinIcon: () => boolean;
|
|
29
|
+
getBuiltinIconSource: () => string;
|
|
30
|
+
getFileName: () => string;
|
|
31
|
+
getFileTitleText: () => string;
|
|
32
|
+
getNamePrefix: () => string;
|
|
33
|
+
hasNameSuffix: () => boolean;
|
|
34
|
+
getNameSuffix: () => string;
|
|
35
|
+
shouldShowMiniFileStatusTitle: () => boolean;
|
|
36
|
+
getDisplayDescription: () => string;
|
|
37
|
+
getMediaType: () => MediaType;
|
|
38
|
+
getFileMediaType: () => MediaType;
|
|
39
|
+
getMediaStatus: () => MediaStatus;
|
|
40
|
+
getMediaShowPreview: () => boolean | undefined;
|
|
41
|
+
onMediaError: () => void;
|
|
42
|
+
getMediaSize: () => import("./fileCard").FileCardSize;
|
|
43
|
+
getFileMediaSize: () => 24 | 32;
|
|
44
|
+
shouldShowFileMedia: () => boolean;
|
|
45
|
+
};
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import _Number$isNaN from "@babel/runtime-corejs3/core-js/number/is-nan";
|
|
2
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/slice";
|
|
3
|
+
import { useInstance } from 'intact-vue-next';
|
|
4
|
+
import { useConfigContext } from '../config';
|
|
5
|
+
import { _$ } from '../../i18n';
|
|
6
|
+
import { fileBadgeClassName, formatBytes, getFileCardDisplayName, guessFileExtension, resolveFileCardType, splitFileName } from './fileCardUtils';
|
|
7
|
+
import { getBuiltinFileIconByExtension } from './fileCardAssets';
|
|
8
|
+
import { mediaAudioCardErrorUrl, mediaImageCardErrorUrl, mediaVideoCardErrorUrl } from '../media/mediaAssets';
|
|
9
|
+
export function useFileCard() {
|
|
10
|
+
var instance = useInstance();
|
|
11
|
+
var config = useConfigContext();
|
|
12
|
+
function getFileName() {
|
|
13
|
+
return getFileCardDisplayName(instance.get('name'), instance.get('src'));
|
|
14
|
+
}
|
|
15
|
+
// 文件行缩略图按真实资源类型识别,显式 type=file 不阻止媒体缩略图。
|
|
16
|
+
function getResourceType() {
|
|
17
|
+
var type = instance.get('type');
|
|
18
|
+
return resolveFileCardType(type === 'file' ? undefined : type, getFileName(), instance.get('src'));
|
|
19
|
+
}
|
|
20
|
+
function getResolvedType() {
|
|
21
|
+
return resolveFileCardType(instance.get('type'), getFileName(), instance.get('src'));
|
|
22
|
+
}
|
|
23
|
+
function getDisplayStatus() {
|
|
24
|
+
return instance.get('status') || 'default';
|
|
25
|
+
}
|
|
26
|
+
function getGuessExtension() {
|
|
27
|
+
return guessFileExtension(instance.get('type'), getFileName());
|
|
28
|
+
}
|
|
29
|
+
function isSpecifiedText(value) {
|
|
30
|
+
return value !== undefined && value !== null && value !== '';
|
|
31
|
+
}
|
|
32
|
+
function getErrorText() {
|
|
33
|
+
var errorText = instance.get('errorText');
|
|
34
|
+
if (errorText === '') return '';
|
|
35
|
+
return isSpecifiedText(errorText) ? errorText : _$('上传失败');
|
|
36
|
+
}
|
|
37
|
+
function getLoadingText() {
|
|
38
|
+
var loadingText = instance.get('loadingText');
|
|
39
|
+
if (loadingText === '') return '';
|
|
40
|
+
return isSpecifiedText(loadingText) ? loadingText : _$('上传中');
|
|
41
|
+
}
|
|
42
|
+
function hasSpecifiedMediaLoadingText() {
|
|
43
|
+
return isSpecifiedText(instance.get('loadingText'));
|
|
44
|
+
}
|
|
45
|
+
function hasSpecifiedMediaErrorText() {
|
|
46
|
+
return isSpecifiedText(instance.get('errorText'));
|
|
47
|
+
}
|
|
48
|
+
function hasPercentProp() {
|
|
49
|
+
var p = instance.get('percent');
|
|
50
|
+
return p !== undefined && p !== null && !_Number$isNaN(p);
|
|
51
|
+
}
|
|
52
|
+
// 进度只影响展示,统一限制在 0 到 100。
|
|
53
|
+
function getProgressPercent() {
|
|
54
|
+
var percent = instance.get('percent');
|
|
55
|
+
if (percent === undefined || percent === null || _Number$isNaN(percent)) return 0;
|
|
56
|
+
return Math.max(0, Math.min(100, percent));
|
|
57
|
+
}
|
|
58
|
+
function getProgressStyle() {
|
|
59
|
+
if (!isLoading() || !hasPercentProp()) return undefined;
|
|
60
|
+
return "--file-card-progress-percent: " + getProgressPercent() + "%;";
|
|
61
|
+
}
|
|
62
|
+
// 文件行状态文案统一带省略号和进度。
|
|
63
|
+
function getInlineStatusText() {
|
|
64
|
+
var status = getDisplayStatus();
|
|
65
|
+
if (status === 'loading') {
|
|
66
|
+
var loadingText = getLoadingText();
|
|
67
|
+
if (!loadingText) return hasPercentProp() ? Math.round(getProgressPercent()) + "%" : '';
|
|
68
|
+
return hasPercentProp() ? loadingText + "... " + Math.round(getProgressPercent()) + "%" : loadingText + "...";
|
|
69
|
+
}
|
|
70
|
+
if (status === 'error') return getErrorText();
|
|
71
|
+
return '';
|
|
72
|
+
}
|
|
73
|
+
function getByteText() {
|
|
74
|
+
var byte = instance.get('byte');
|
|
75
|
+
if (byte === undefined || byte === null || byte < 0) return '';
|
|
76
|
+
return formatBytes(byte);
|
|
77
|
+
}
|
|
78
|
+
function getDisplayDescription() {
|
|
79
|
+
if (isError()) return getErrorText();
|
|
80
|
+
if (isLoading()) return getInlineStatusText();
|
|
81
|
+
var description = instance.get('description');
|
|
82
|
+
if (description !== undefined && description !== null && description !== '') return description;
|
|
83
|
+
var byteText = getByteText();
|
|
84
|
+
var statusText = getInlineStatusText();
|
|
85
|
+
if (byteText && statusText) return byteText + " \xB7 " + statusText;
|
|
86
|
+
return byteText || statusText;
|
|
87
|
+
}
|
|
88
|
+
// 事件回调统一返回当前卡片的结构化信息。
|
|
89
|
+
function getValue() {
|
|
90
|
+
return {
|
|
91
|
+
name: getFileName(),
|
|
92
|
+
type: instance.get('type'),
|
|
93
|
+
resolvedType: getResolvedType(),
|
|
94
|
+
status: getDisplayStatus(),
|
|
95
|
+
src: instance.get('src'),
|
|
96
|
+
poster: instance.get('poster'),
|
|
97
|
+
description: getDisplayDescription(),
|
|
98
|
+
errorText: isError() ? getErrorText() : undefined,
|
|
99
|
+
loadingText: instance.get('loadingText'),
|
|
100
|
+
byte: instance.get('byte'),
|
|
101
|
+
percent: hasPercentProp() ? getProgressPercent() : undefined,
|
|
102
|
+
size: instance.get('size') || 'default'
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function isMediaType() {
|
|
106
|
+
var resolvedType = getResolvedType();
|
|
107
|
+
return resolvedType === 'image' || resolvedType === 'video' || resolvedType === 'audio';
|
|
108
|
+
}
|
|
109
|
+
function isResourceMediaType() {
|
|
110
|
+
var resourceType = getResourceType();
|
|
111
|
+
return resourceType === 'image' || resourceType === 'video' || resourceType === 'audio';
|
|
112
|
+
}
|
|
113
|
+
function isLoading() {
|
|
114
|
+
return getDisplayStatus() === 'loading';
|
|
115
|
+
}
|
|
116
|
+
function isError() {
|
|
117
|
+
return getDisplayStatus() === 'error';
|
|
118
|
+
}
|
|
119
|
+
function isDone() {
|
|
120
|
+
return getDisplayStatus() === 'done';
|
|
121
|
+
}
|
|
122
|
+
function isMini() {
|
|
123
|
+
return (instance.get('size') || 'default') === 'mini';
|
|
124
|
+
}
|
|
125
|
+
function hasSource() {
|
|
126
|
+
return !!instance.get('src');
|
|
127
|
+
}
|
|
128
|
+
function isMediaLoadError() {
|
|
129
|
+
return !!instance.get('$mediaLoadError');
|
|
130
|
+
}
|
|
131
|
+
function setMediaLoadError(value) {
|
|
132
|
+
instance.set('$mediaLoadError', value);
|
|
133
|
+
}
|
|
134
|
+
function shouldShowDeleteButton() {
|
|
135
|
+
return !!instance.get('showDelIcon');
|
|
136
|
+
}
|
|
137
|
+
// mini 文件卡片在 loading/error 时,用状态文案占用标题位置。
|
|
138
|
+
function shouldShowMiniFileStatusTitle() {
|
|
139
|
+
return isMini() && !isMediaType() && (isLoading() || isError()) && !!getInlineStatusText();
|
|
140
|
+
}
|
|
141
|
+
function getFileTitleText() {
|
|
142
|
+
if (shouldShowMiniFileStatusTitle()) return getInlineStatusText();
|
|
143
|
+
return getFileName();
|
|
144
|
+
}
|
|
145
|
+
function getNamePrefix() {
|
|
146
|
+
return splitFileName(getFileName()).prefix;
|
|
147
|
+
}
|
|
148
|
+
function getNameSuffix() {
|
|
149
|
+
return splitFileName(getFileName()).suffix;
|
|
150
|
+
}
|
|
151
|
+
function hasNameSuffix() {
|
|
152
|
+
return !!getNameSuffix();
|
|
153
|
+
}
|
|
154
|
+
function getMediaType() {
|
|
155
|
+
return getResolvedType();
|
|
156
|
+
}
|
|
157
|
+
function isImageOrVideoMedia() {
|
|
158
|
+
var mediaType = getMediaType();
|
|
159
|
+
return mediaType === 'image' || mediaType === 'video';
|
|
160
|
+
}
|
|
161
|
+
function shouldKeepVisualMediaOnError() {
|
|
162
|
+
if (!isError() || !hasSource()) return false;
|
|
163
|
+
if (isMediaLoadError()) return false;
|
|
164
|
+
return isImageOrVideoMedia();
|
|
165
|
+
}
|
|
166
|
+
function getFileMediaType() {
|
|
167
|
+
return getResourceType();
|
|
168
|
+
}
|
|
169
|
+
function getMediaStatus() {
|
|
170
|
+
if (!isMediaType()) return 'default';
|
|
171
|
+
if (shouldKeepVisualMediaOnError()) return 'default';
|
|
172
|
+
return getDisplayStatus();
|
|
173
|
+
}
|
|
174
|
+
function getMediaShowPreview() {
|
|
175
|
+
if (isError()) return false;
|
|
176
|
+
return instance.get('showPreview');
|
|
177
|
+
}
|
|
178
|
+
function getMediaSize() {
|
|
179
|
+
return instance.get('size') || 'default';
|
|
180
|
+
}
|
|
181
|
+
function getFileMediaSize() {
|
|
182
|
+
if (isMini()) return 24;
|
|
183
|
+
return 32;
|
|
184
|
+
}
|
|
185
|
+
function shouldHideMediaStatusTextForSize() {
|
|
186
|
+
var size = getMediaSize();
|
|
187
|
+
return size === 'mini' || size === 'small';
|
|
188
|
+
}
|
|
189
|
+
// 显式媒体卡片只有在指定文案后才展示状态文字,mini/small 不展示。
|
|
190
|
+
function shouldShowMediaStatusLayer() {
|
|
191
|
+
if (!isMediaType()) return false;
|
|
192
|
+
if (shouldHideMediaStatusTextForSize()) return false;
|
|
193
|
+
if (isError()) return hasSpecifiedMediaErrorText();
|
|
194
|
+
if (isLoading()) return hasSpecifiedMediaLoadingText();
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
function getMediaLoadingText() {
|
|
198
|
+
if (!isLoading() || !hasSpecifiedMediaLoadingText()) return '';
|
|
199
|
+
return instance.get('loadingText') || '';
|
|
200
|
+
}
|
|
201
|
+
function getMediaErrorText() {
|
|
202
|
+
if (isError() && hasSpecifiedMediaErrorText()) return instance.get('errorText') || '';
|
|
203
|
+
return '';
|
|
204
|
+
}
|
|
205
|
+
function getMediaErrorArtworkIconSrc() {
|
|
206
|
+
var mediaType = getMediaType();
|
|
207
|
+
if (mediaType === 'audio') return mediaAudioCardErrorUrl;
|
|
208
|
+
if (mediaType === 'video') return mediaVideoCardErrorUrl;
|
|
209
|
+
return mediaImageCardErrorUrl;
|
|
210
|
+
}
|
|
211
|
+
function shouldRenderMediaErrorArtwork() {
|
|
212
|
+
return isMediaType() && isError() && !shouldHideMediaStatusTextForSize() && hasSpecifiedMediaErrorText();
|
|
213
|
+
}
|
|
214
|
+
function shouldUseMediaErrorArtworkLayout() {
|
|
215
|
+
return shouldRenderMediaErrorArtwork() && !shouldKeepVisualMediaOnError();
|
|
216
|
+
}
|
|
217
|
+
// 媒体卡片在 loading 且传入 percent 时都展示进度文本(不限制尺寸)。
|
|
218
|
+
function shouldShowVisualMediaProgressText() {
|
|
219
|
+
var mediaType = getMediaType();
|
|
220
|
+
return isLoading() && hasPercentProp() && (mediaType === 'image' || mediaType === 'video' || mediaType === 'audio');
|
|
221
|
+
}
|
|
222
|
+
function getMediaProgressText() {
|
|
223
|
+
return Math.round(getProgressPercent()) + "%";
|
|
224
|
+
}
|
|
225
|
+
function getFileBadgeText() {
|
|
226
|
+
if (getResourceType() === 'image') return 'IMG';
|
|
227
|
+
if (getResourceType() === 'video') return 'VID';
|
|
228
|
+
if (getResourceType() === 'audio') return 'AUD';
|
|
229
|
+
var ext = getGuessExtension();
|
|
230
|
+
if (!ext) return 'FILE';
|
|
231
|
+
return _sliceInstanceProperty(ext).call(ext, 0, 4).toUpperCase();
|
|
232
|
+
}
|
|
233
|
+
function getFileBadgeClassName() {
|
|
234
|
+
return fileBadgeClassName(getGuessExtension(), getResourceType());
|
|
235
|
+
}
|
|
236
|
+
function hasCustomIcon() {
|
|
237
|
+
return !isResourceMediaType() && !!instance.get('icon');
|
|
238
|
+
}
|
|
239
|
+
function getIconSource() {
|
|
240
|
+
return instance.get('icon') || '';
|
|
241
|
+
}
|
|
242
|
+
function getBuiltinIconSource() {
|
|
243
|
+
return getBuiltinFileIconByExtension(getGuessExtension(), getResourceType());
|
|
244
|
+
}
|
|
245
|
+
function hasBuiltinIcon() {
|
|
246
|
+
return !!getBuiltinIconSource();
|
|
247
|
+
}
|
|
248
|
+
function shouldShowFileMedia() {
|
|
249
|
+
if (isMediaType()) return false;
|
|
250
|
+
if (!isResourceMediaType() || !hasSource()) return false;
|
|
251
|
+
return instance.get('showPreview') !== false;
|
|
252
|
+
}
|
|
253
|
+
// 根节点类名集中描述类型、尺寸与状态,样式层只消费类名。
|
|
254
|
+
function getRootClassNameObj() {
|
|
255
|
+
var _ref;
|
|
256
|
+
var k = config.k;
|
|
257
|
+
var size = instance.get('size') || 'default';
|
|
258
|
+
var resolvedType = getResolvedType();
|
|
259
|
+
return _ref = {}, _ref[k + "-file-card-file"] = !isMediaType(), _ref[k + "-file-card-media"] = isMediaType(), _ref[k + "-file-card-file-media"] = shouldShowFileMedia(), _ref[k + "-file-card-type-" + resolvedType] = true, _ref[k + "-file-card-" + size] = true, _ref[k + "-file-card-loading"] = isLoading(), _ref[k + "-file-card-error"] = isError(), _ref[k + "-file-card-done"] = isDone(), _ref[k + "-file-card-media-error-artwork"] = shouldUseMediaErrorArtworkLayout(), _ref[k + "-file-card-progressing"] = isLoading() && hasPercentProp(), _ref[k + "-file-card-deletable"] = shouldShowDeleteButton(), _ref;
|
|
260
|
+
}
|
|
261
|
+
function onClick(e) {
|
|
262
|
+
instance.trigger('click', getValue(), e);
|
|
263
|
+
}
|
|
264
|
+
function onPreview(media, e) {
|
|
265
|
+
e.stopPropagation();
|
|
266
|
+
instance.trigger('preview', getValue(), e);
|
|
267
|
+
}
|
|
268
|
+
function onDelete(e) {
|
|
269
|
+
e.stopPropagation();
|
|
270
|
+
instance.trigger('delete', getValue(), e);
|
|
271
|
+
}
|
|
272
|
+
function onMediaError() {
|
|
273
|
+
setMediaLoadError(true);
|
|
274
|
+
}
|
|
275
|
+
function bootstrap() {
|
|
276
|
+
instance.set('$mediaLoadError', false, {
|
|
277
|
+
silent: true
|
|
278
|
+
});
|
|
279
|
+
['src', 'type', 'poster'].forEach(function (key) {
|
|
280
|
+
instance.watch(key, function () {
|
|
281
|
+
return setMediaLoadError(false);
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
instance.watch('status', function (status) {
|
|
285
|
+
if (status !== 'error') setMediaLoadError(false);
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
bootstrap();
|
|
289
|
+
return {
|
|
290
|
+
getRootClassNameObj: getRootClassNameObj,
|
|
291
|
+
getProgressStyle: getProgressStyle,
|
|
292
|
+
onClick: onClick,
|
|
293
|
+
isMediaType: isMediaType,
|
|
294
|
+
shouldShowDeleteButton: shouldShowDeleteButton,
|
|
295
|
+
onDelete: onDelete,
|
|
296
|
+
getValue: getValue,
|
|
297
|
+
onPreview: onPreview,
|
|
298
|
+
isLoading: isLoading,
|
|
299
|
+
isError: isError,
|
|
300
|
+
getMediaLoadingText: getMediaLoadingText,
|
|
301
|
+
getMediaErrorText: getMediaErrorText,
|
|
302
|
+
getMediaErrorArtworkIconSrc: getMediaErrorArtworkIconSrc,
|
|
303
|
+
shouldShowMediaStatusLayer: shouldShowMediaStatusLayer,
|
|
304
|
+
shouldRenderMediaErrorArtwork: shouldRenderMediaErrorArtwork,
|
|
305
|
+
shouldUseMediaErrorArtworkLayout: shouldUseMediaErrorArtworkLayout,
|
|
306
|
+
shouldShowVisualMediaProgressText: shouldShowVisualMediaProgressText,
|
|
307
|
+
getMediaProgressText: getMediaProgressText,
|
|
308
|
+
getFileBadgeClassName: getFileBadgeClassName,
|
|
309
|
+
getFileBadgeText: getFileBadgeText,
|
|
310
|
+
hasCustomIcon: hasCustomIcon,
|
|
311
|
+
getIconSource: getIconSource,
|
|
312
|
+
hasBuiltinIcon: hasBuiltinIcon,
|
|
313
|
+
getBuiltinIconSource: getBuiltinIconSource,
|
|
314
|
+
getFileName: getFileName,
|
|
315
|
+
getFileTitleText: getFileTitleText,
|
|
316
|
+
getNamePrefix: getNamePrefix,
|
|
317
|
+
hasNameSuffix: hasNameSuffix,
|
|
318
|
+
getNameSuffix: getNameSuffix,
|
|
319
|
+
shouldShowMiniFileStatusTitle: shouldShowMiniFileStatusTitle,
|
|
320
|
+
getDisplayDescription: getDisplayDescription,
|
|
321
|
+
getMediaType: getMediaType,
|
|
322
|
+
getFileMediaType: getFileMediaType,
|
|
323
|
+
getMediaStatus: getMediaStatus,
|
|
324
|
+
getMediaShowPreview: getMediaShowPreview,
|
|
325
|
+
onMediaError: onMediaError,
|
|
326
|
+
getMediaSize: getMediaSize,
|
|
327
|
+
getFileMediaSize: getFileMediaSize,
|
|
328
|
+
shouldShowFileMedia: shouldShowFileMedia
|
|
329
|
+
};
|
|
330
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FileCardListItem } from './list';
|
|
2
|
+
import type { FileCardValue } from './fileCard';
|
|
3
|
+
export declare function useFileCardList(): {
|
|
4
|
+
getClassNameObj: () => {
|
|
5
|
+
[x: string]: boolean;
|
|
6
|
+
};
|
|
7
|
+
getItemKey: (item: FileCardListItem, index: number) => string | number;
|
|
8
|
+
getItemSize: (item: FileCardListItem) => import("./fileCard").FileCardSize;
|
|
9
|
+
shouldShowDelete: (item: FileCardListItem) => boolean;
|
|
10
|
+
shouldShowNameTooltip: (item: FileCardListItem) => boolean;
|
|
11
|
+
onItemPreview: (item: FileCardListItem, _value: FileCardValue, e: MouseEvent) => void;
|
|
12
|
+
onItemDelete: (item: FileCardListItem, _value: FileCardValue, e: MouseEvent) => void;
|
|
13
|
+
onItemClick: (item: FileCardListItem, _value: FileCardValue, e: MouseEvent) => void;
|
|
14
|
+
};
|