Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(1.4.7): weekly sync update to 2.7 #2576

Merged
merged 41 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
fe1a9c9
Release/1.4.0 (#2481)
xiaosansiji Jun 6, 2023
70c4ca1
fix: 1.4.0 changelog render error (#2482)
xiaosansiji Jun 6, 2023
7cdde4e
fix(input-number): do not set value if value is undefined/null (#2483)
chaishi Jun 7, 2023
f2b2863
docs: update documentation for vue2.7 support (#2491)
uyarn Jun 8, 2023
033d77c
feat: move popup align style to less from inline style (#2496)
xiaosansiji Jun 9, 2023
8b960c0
chore: add 2.7 infra (#2497)
uyarn Jun 9, 2023
e19b84b
chore(deps-dev): bump workbox-precaching from 6.6.1 to 7.0.0 (#2467)
dependabot[bot] Jun 12, 2023
58c168e
fix(timeline): async timeline render (#2501)
uyarn Jun 12, 2023
e28b2fa
Feat/submenu popup props (#2504)
xiaosansiji Jun 13, 2023
3bced74
fix(table): 通过current修改分页,序列号没有变化问题修复 (#2506)
LoopZhou Jun 13, 2023
08c094b
fix(colorpicker): support empty initial value for graident color (#2511)
uyarn Jun 13, 2023
d0bdbe1
feat: release 1.4.1 (#2512)
xiaosansiji Jun 13, 2023
6f4e831
feat: release 1.4.2 (#2515)
xiaosansiji Jun 13, 2023
dc556a2
fix(Drawer): 修复destroyOnClose不符合预期问题 (#2517)
liect Jun 16, 2023
93ab803
docs: provide en-version docs (#2520)
uyarn Jun 16, 2023
04cffc1
feat(dropdown): 新增带图标的下拉菜单示例 (#2523)
aomnisz Jun 19, 2023
aea51ed
fix: textarea auto height (#2527)
xiaosansiji Jun 20, 2023
09f6b4f
fix(swiper): navigation slot (#2514)
uyarn Jun 20, 2023
2b667de
Release/1.4.3 (#2528)
xiaosansiji Jun 20, 2023
24db8d9
feat: release 1.4.4 (#2532)
xiaosansiji Jun 20, 2023
6d795f4
feat: dialog support full-screen mode (#2529)
Ghostdar Jun 23, 2023
6de693f
[Table] 修复列配置和列宽调整场景,列数量由多变少时未能更新宽度;新增事件 onColumnResizeChange (#2535)
chaishi Jun 25, 2023
39740e2
chore: setup with pnpm (#2536)
uyarn Jun 26, 2023
f007839
docs: add EN version site (#2521)
uyarn Jun 27, 2023
b4f43a6
feat: release 1.4.5 (#2539)
xiaosansiji Jun 27, 2023
be8c70c
chore: complete en docs (#2541)
uyarn Jun 27, 2023
e243010
feat(DatePicker): 新增 onConfirm事件 (#2545)
liweijie0812 Jun 30, 2023
f76c9f4
fix(input-number): calibration invalid for value=0 (#2546)
imp2002 Jun 30, 2023
7fb99bf
chore: fix test script (#2553)
uyarn Jul 3, 2023
f04ddf2
feat(table): add new class name t-table-tr--level-${level} to table r…
chaishi Jul 3, 2023
781b27a
fix(input): fix limit disabled bg color (#2557)
uyarn Jul 3, 2023
16b7049
chore: update helper tips (#2544)
liweijie0812 Jul 4, 2023
0980ca9
feat: release 1.4.6 (#2560)
xiaosansiji Jul 4, 2023
4fe2003
chore(deps-dev): bump @commitlint/cli from 17.4.4 to 17.6.6 (#2552)
dependabot[bot] Jul 9, 2023
d9ef04e
chore(deps-dev): bump @babel/core from 7.16.12 to 7.22.5 (#2551)
dependabot[bot] Jul 9, 2023
91a7c42
fix: alert opacity style when closed (#2571)
xiaosansiji Jul 10, 2023
5db901a
[Upload] `theme=image` fileListDisplay support, click fileName to op…
chaishi Jul 11, 2023
777218b
fix(popup): fix comparison of initial state (#2573)
ikeq Jul 11, 2023
91d7af5
feat: release 1.4.7 (#2574)
xiaosansiji Jul 11, 2023
3e6fdb0
Merge branch 'develop' of github.com:Tencent/tdesign-vue into feat/2.…
uyarn Jul 12, 2023
ad9ccfe
chore: update snapshot
uyarn Jul 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ toc: false
docClass: timeline
---

## 🌈 1.4.7 `2023-07-11`
### 🚀 Features
- `Upload`: @chaishi ([#2568](https://github.com/Tencent/tdesign-vue/pull/2568))
- 新增组件实例方法,`uploadFilePercent` 用于更新文件上传进度
- `theme=image`,支持使用 `fileListDisplay` 自定义 UI 内容
- `theme=image`,支持点击名称打开新窗口访问图片,[issue#2338](https://github.com/Tencent/tdesign-vue/issues/2338)
- 拖拽上传场景,支持 `accept` 文件类型限制,[issue#3075](https://github.com/Tencent/tdesign-vue-next/issues/3075)
- `Dialog`: 为内容区域增加超长时滚动条样式实现 @liweijie0812 ([common#1523](https://github.com/Tencent/tdesign-common/pull/1523))
### 🐞 Bug Fixes
- `Alert`: 修复内部自定义元素透明度变化,意外导致 Alert 隐藏的问题 @xiaosansiji ([#2571](https://github.com/Tencent/tdesign-vue/pull/2571))
- `Upload`: 自定义上传方法,修复未能正确返回上传成功或失败后的文件问题 @chaishi ([#2568](https://github.com/Tencent/tdesign-vue/pull/2568))
- `Popup`: 修复 `trigger=hover` 时首次鼠标快速移动导致父级关闭的问题 @ikeq ([#2573](https://github.com/Tencent/tdesign-vue/pull/2573))

## 🌈 1.4.6 `2023-07-04`
### 🚀 Features
- `DatePicker`: 新增 `onConfirm` 事件 @liweijie0812 ([#2545](https://github.com/Tencent/tdesign-vue/pull/2545))
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tdesign-vue",
"purename": "tdesign",
"version": "1.4.6-naruto",
"version": "1.4.7-naruto",
"description": "tdesign-vue",
"title": "tdesign-vue",
"keywords": [
Expand Down Expand Up @@ -105,14 +105,14 @@
},
"devDependencies": {
"@babel/cli": "^7.5.5",
"@babel/core": "~7.16.0",
"@babel/core": "~7.22.5",
"@babel/eslint-parser": "~7.19.1",
"@babel/plugin-transform-class-properties": "^7.22.3",
"@babel/plugin-transform-modules-commonjs": "^7.9.6",
"@babel/plugin-transform-object-assign": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.14.5",
"@babel/preset-env": "^7.5.5",
"@commitlint/cli": "~17.4.4",
"@commitlint/cli": "~17.6.6",
"@commitlint/config-conventional": "~17.6.5",
"@rollup/plugin-babel": "^5.1.0",
"@rollup/plugin-commonjs": "^18.0.0",
Expand Down
3 changes: 2 additions & 1 deletion src/alert/alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ export default mixins(getConfigReceiverMixins<Vue, AlertConfig>('alert'), getGlo
},

handleCloseEnd(e: TransitionEvent) {
if (e.propertyName === 'opacity') {
// 只有当前 Alert DOM 元素 opacity 变化时才触发,防止自定义子元素影响
if (e.propertyName === 'opacity' && e.target === this.$el) {
this.visible = false;
this.$emit('closed', { e });
if (this.onClosed) {
Expand Down
2 changes: 1 addition & 1 deletion src/popup/popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export default mixins(classPrefixMixins).extend({
});
},
emitPopVisible(visible: boolean, context: PopupVisibleChangeContext) {
if (this.disabled || visible === this.visible) return;
if (this.disabled || visible === !!this.visible) return;
if (!visible && this.visibleState > 1) return;
if (visible && this.mouseInRange) return;
this.$emit('visible-change', visible, context);
Expand Down
8 changes: 7 additions & 1 deletion src/upload/_example/image.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
theme="image"
tips="请选择单张图片文件上传(上传成功状态演示)"
accept="image/*"
></t-upload>
>
<!-- custom UI -->
<!-- <template #fileListDisplay="{ files }">
<div>{{ JSON.stringify(files) }}</div>
</template> -->
</t-upload>

<t-upload
ref="uploadRef2"
Expand Down Expand Up @@ -57,6 +62,7 @@
:formatResponse="formatImgResponse"
></t-upload>

<!-- if you want to hide image name, set .t-upload__card-name { display: none } -->
<t-upload
ref="uploadRef4"
action="https://service-bv448zsw-1257786608.gz.apigw.tencentcs.com/api/upload-demo"
Expand Down
26 changes: 20 additions & 6 deletions src/upload/_example/request-method.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
</t-radio-group>
</div>

<t-upload v-model="files" :requestMethod="requestMethod" tips="自定义上传方法需要返回成功或失败信息"></t-upload>
<t-upload
ref="uploadRef"
v-model="files"
:requestMethod="requestMethod"
tips="自定义上传方法需要返回成功或失败信息"
></t-upload>
</div>
</template>
<script>
Expand Down Expand Up @@ -35,15 +40,24 @@ export default {
requestSuccessMethod(file /** UploadFile */) {
console.log(file, file.raw);
return new Promise((resolve) => {
// file.percent 用于控制上传进度,如果不希望显示上传进度,则不对 file.percent 设置值即可。
// 如果代码规范不能设置 file.percent,也可以设置 this.files
file.percent = 0;
// 控制上传进度
let percent = 0;
const percentTimer = setInterval(() => {
if (percent + 10 < 99) {
percent += 10;
this.$refs.uploadRef.uploadFilePercent({ file, percent });
} else {
clearInterval(percentTimer);
}
}, 100);

const timer = setTimeout(() => {
// resolve 参数为关键代码
resolve({ status: 'success', response: { url: 'https://tdesign.gtimg.com/site/avatar.jpg' } });
file.percent = 100;

clearTimeout(timer);
}, 500);
clearInterval(percentTimer);
}, 800);
});
},
requestFailMethod(file /** UploadFile */) {
Expand Down
1 change: 1 addition & 0 deletions src/upload/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { PropType } from 'vue';
import { CommonDisplayFileProps } from './interface';

export const commonProps = {
accept: String,
files: Array as PropType<CommonDisplayFileProps['files']>,
toUploadFiles: Array as PropType<CommonDisplayFileProps['toUploadFiles']>,
displayFiles: Array as PropType<CommonDisplayFileProps['displayFiles']>,
Expand Down
16 changes: 11 additions & 5 deletions src/upload/hooks/useDrag.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
import { ref } from 'vue';
import { Ref, ref } from 'vue';
import { getFileList } from '../../_common/js/upload/utils';
import { TdUploadProps } from '../type';

export interface UploadDragEvents {
onDragFileChange?: (e: DragEvent) => void;
onDragFileChange?: (files: File[]) => void;
onDragenter?: TdUploadProps['onDragenter'];
onDragleave?: TdUploadProps['onDragleave'];
onDrop?: TdUploadProps['onDrop'];
}

export default function useDrag(props: UploadDragEvents) {
export default function useDrag(props: UploadDragEvents, accept: Ref<string>) {
const target = ref(null);
const dragActive = ref(false);

const handleDrop = (event: DragEvent) => {
event.preventDefault();
props.onDragFileChange?.(event);
props.onDrop?.({ e: event });
dragActive.value = false;

const { files } = event.dataTransfer;
const dragFiles: File[] = getFileList(files, accept.value);
if (!dragFiles.length) return;

props.onDragFileChange?.(dragFiles);
props.onDrop?.({ e: event });
};

const handleDragenter = (event: DragEvent) => {
Expand Down
21 changes: 15 additions & 6 deletions src/upload/hooks/useUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
getDisplayFiles,
formatToUploadFile,
} from '../../_common/js/upload/main';
import { getFileUrlByFileRaw } from '../../_common/js/upload/utils';
import { getFileUrlByFileRaw, getFileList } from '../../_common/js/upload/utils';
import useVModel from '../../hooks/useVModel';
import {
InnerProgressContext,
Expand Down Expand Up @@ -88,6 +88,14 @@ export default function useUpload(props: TdUploadProps, context: SetupContext) {
isBatchUpload: isBatchUpload.value,
}));

const uploadFilePercent = (params: { file: UploadFile; percent: number }) => {
const { file, percent } = params;
const index = toUploadFiles.value.findIndex((item) => file.raw === item.raw);
const newFiles = [...toUploadFiles.value];
newFiles[index] = { ...newFiles[index], percent };
toUploadFiles.value = newFiles;
};

const updateFilesProgress = () => {
if (props.autoUpload) {
toUploadFiles.value = [...toUploadFiles.value];
Expand Down Expand Up @@ -188,7 +196,7 @@ export default function useUpload(props: TdUploadProps, context: SetupContext) {
toUploadFiles.value = [];
};

const onFileChange = (files: FileList) => {
const onFileChange = (files: File[]) => {
if (innerDisabled.value) return;

const params = { currentSelectedFiles: formatToUploadFile([...files], props.format) };
Expand All @@ -197,7 +205,6 @@ export default function useUpload(props: TdUploadProps, context: SetupContext) {

validateFile({
uploadValue: uploadValue.value,
// @ts-ignore
files: [...files],
allowUploadDuplicateFile: props.allowUploadDuplicateFile,
max: props.max,
Expand Down Expand Up @@ -266,11 +273,12 @@ export default function useUpload(props: TdUploadProps, context: SetupContext) {
};

const onNormalFileChange = (e: InputEvent) => {
onFileChange?.((e.target as HTMLInputElement).files);
const fileList = getFileList((e.target as HTMLInputElement).files);
onFileChange?.(fileList);
};

function onDragFileChange(e: DragEvent) {
onFileChange?.(e.dataTransfer.files);
function onDragFileChange(files: File[]) {
onFileChange?.(files);
}

/**
Expand Down Expand Up @@ -453,6 +461,7 @@ export default function useUpload(props: TdUploadProps, context: SetupContext) {
innerDisabled,
xhrReq,
uploadFiles,
uploadFilePercent,
onFileChange,
onNormalFileChange,
onDragFileChange,
Expand Down
1 change: 1 addition & 0 deletions src/upload/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { GlobalConfigProvider } from '../config-provider/type';
import { TNode } from '../common';

export interface CommonDisplayFileProps {
accept: string;
files: TdUploadProps['files'];
toUploadFiles: TdUploadProps['files'];
displayFiles: TdUploadProps['files'];
Expand Down
8 changes: 5 additions & 3 deletions src/upload/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default {
type: Boolean,
default: true,
},
/** 如果是自动上传模式 `autoUpload=true`,表示全部文件上传之前的钩子函数,函数参数为上传的文件,函数返回值决定是否继续上传,若返回值为 `false` 则终止上传。<br/>如果是非自动上传模式 `autoUpload=false`,则函数返回值为 `false` 时表示不触发文件变化 */
/** 如果是自动上传模式 `autoUpload=true`,表示全部文件上传之前的钩子函数,函数参数为上传的文件,函数返回值决定是否继续上传,若返回值为 `false` 则终止上传。<br/>如果是非自动上传模式 `autoUpload=false`,则函数返回值为 `false` 时表示本次选中的文件不会加入到文件列表中,即不触发 `onChange` 事件 */
beforeAllFilesUpload: {
type: Function as PropType<TdUploadProps['beforeAllFilesUpload']>,
},
Expand All @@ -56,7 +56,7 @@ export default {
type: Boolean,
default: undefined,
},
/** 用于完全自定义文件列表内容 */
/** 用于完全自定义文件列表界面内容(UI),单文件和多文件均有效 */
fileListDisplay: {
type: Function as PropType<TdUploadProps['fileListDisplay']>,
},
Expand Down Expand Up @@ -170,6 +170,8 @@ export default {
},
/** 是否在同一个请求中上传全部文件,默认一个请求上传一个文件。多文件上传时有效 */
uploadAllFilesInOneRequest: Boolean,
/** 是否允许粘贴上传剪贴板中的文件 */
uploadPastedFiles: Boolean,
/** 是否在请求时间超过 300ms 后显示模拟进度。上传进度有模拟进度和真实进度两种。一般大小的文件上传,真实的上传进度只有 0 和 100,不利于交互呈现,因此组件内置模拟上传进度。真实上传进度一般用于大文件上传。 */
useMockProgress: {
type: Boolean,
Expand Down Expand Up @@ -205,7 +207,7 @@ export default {
onOneFileSuccess: Function as PropType<TdUploadProps['onOneFileSuccess']>,
/** 点击图片预览时触发,文件没有预览 */
onPreview: Function as PropType<TdUploadProps['onPreview']>,
/** 上传进度变化时触发,真实进度和模拟进度都会触发。`type=real` 表示真实上传进度,`type=mock` 表示模拟上传进度 */
/** 上传进度变化时触发,真实进度和模拟进度都会触发。<br/>⚠️ 原始上传请求,小文件的上传进度只有 0 和 100,故而不会触发 `progress` 事件;只有大文件才有真实的中间进度。如果你希望很小的文件也显示上传进度,保证 `useMockProgress=true` 的情况下,设置 `mockProgressDuration` 为更小的值。<br/>参数 `options.type=real` 表示真实上传进度,`options.type=mock` 表示模拟上传进度 */
onProgress: Function as PropType<TdUploadProps['onProgress']>,
/** 移除文件时触发 */
onRemove: Function as PropType<TdUploadProps['onRemove']>,
Expand Down
6 changes: 4 additions & 2 deletions src/upload/themes/custom-file.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineComponent, PropType } from 'vue';
import { defineComponent, PropType, toRefs } from 'vue';
import isFunction from 'lodash/isFunction';
import useDrag, { UploadDragEvents } from '../hooks/useDrag';
import { CommonDisplayFileProps } from '../interface';
Expand Down Expand Up @@ -31,7 +31,9 @@ export default defineComponent({
},

setup(props) {
const drag = useDrag(props.dragEvents);
const { accept } = toRefs(props);

const drag = useDrag(props.dragEvents, accept);
const { dragActive } = drag;

return {
Expand Down
4 changes: 2 additions & 2 deletions src/upload/themes/dragger-file.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ export default defineComponent({
},

setup(props) {
const { displayFiles } = toRefs(props);
const { displayFiles, accept } = toRefs(props);
const locale = toRef(props, 'locale') as Ref<UploadConfig>;

const { sizeClassNames } = useCommonClassName();
const uploadPrefix = `${props.classPrefix}-upload`;

const drag = useDrag(props.dragEvents);
const drag = useDrag(props.dragEvents, accept);
const { dragActive } = drag;

const draggerFileRef = ref();
Expand Down
20 changes: 19 additions & 1 deletion src/upload/themes/image-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { CommonDisplayFileProps } from '../interface';
import { commonProps } from '../constants';
import { TdUploadProps, UploadFile } from '../type';
import { abridgeName } from '../../_common/js/upload/utils';
import { renderTNodeJSX } from '../../utils/render-tnode';
import Link from '../../link';

export interface ImageCardUploadProps extends CommonDisplayFileProps {
multiple: TdUploadProps['multiple'];
Expand Down Expand Up @@ -128,6 +130,14 @@ export default defineComponent({
},

render() {
// render custom UI with fileListDisplay
const customList = renderTNodeJSX(this, 'fileListDisplay', {
params: {
files: this.displayFiles,
},
});
if (customList) return customList;

const cardItemClasses = `${this.classPrefix}-upload__card-item ${this.classPrefix}-is-background`;
const { AddIcon } = this.icons;

Expand All @@ -137,12 +147,20 @@ export default defineComponent({
{this.displayFiles?.map((file: UploadFile, index: number) => {
const loadCard = `${this.classPrefix}-upload__card-container ${this.classPrefix}-upload__card-box`;
const fileName = this.abridgeName ? abridgeName(file.name, ...this.abridgeName) : file.name;
const fileNameClassName = `${this.classPrefix}-upload__card-name`;
return (
<li class={cardItemClasses} key={index}>
{file.status === 'progress' && this.renderProgressFile(file, loadCard)}
{file.status === 'fail' && this.renderFailFile(file, index, loadCard)}
{!['progress', 'fail'].includes(file.status) && file.url && this.renderMainContent(file, index)}
<div class={`${this.classPrefix}-upload__card-name`}>{fileName}</div>
{fileName
&& (file.url ? (
<Link href={file.url} class={fileNameClassName} target="_blank" hover="color" size="small">
{fileName}
</Link>
) : (
<span class={fileNameClassName}>{fileName}</span>
))}
</li>
);
})}
Expand Down
4 changes: 2 additions & 2 deletions src/upload/themes/multiple-flow-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default defineComponent({

setup(props) {
// locale 已经在 useUpload 中统一处理优先级
const { uploading, classPrefix } = toRefs(props);
const { uploading, classPrefix, accept } = toRefs(props);
const locale = toRef(props, 'locale') as Ref<UploadConfig>;
const uploadPrefix = `${classPrefix.value}-upload`;

Expand All @@ -58,7 +58,7 @@ export default defineComponent({
TimeFilledIcon: TdTimeFilledIcon,
});

const drag = useDrag(props.dragEvents);
const drag = useDrag(props.dragEvents, accept);

const uploadText = computed(() => {
if (uploading.value) return `${locale.value.progress.uploadingText}`;
Expand Down
Loading