Skip to content

Commit

Permalink
chore: release 1.11.1-naruto (#3531)
Browse files Browse the repository at this point in the history
* ci: add pkg.pr.new (#3503)

* fix(select): enhance type handling and improve tag removal logic (#3509)

* fix: fix cjs bundle (#3512)

* fix: code spell error (#3526)

* feat(imageViewer): custom Download Callback (#3516)

* fix: fix cjs build (#3515)

* fix: fix cjs build

* fix: fix cjs build

* chore: fix build

* fix(upload): integrate form disabled state into upload component (#3525)

* fix(Message): fix messagePlugin instance error (#3514)

* fix(Dialog):  custom `cancelBtn` text retains `t-dialog__cancel` className (#3528)

* refactor(DatePicker): `useDisableDate` to use common `isEnabledDate` (#3511)

* chore: release 1.11.1 (#3530)

* chore: release 1.11.1

* chore: optimize

* chore: changelog's changes

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* chore: release 1.11.1-naruto

---------

Co-authored-by: liweijie0812 <674416404@qq.com>
Co-authored-by: betavs <34408516+betavs@users.noreply.github.com>
Co-authored-by: 阿菜 Cai <jimmyrss1102@gmail.com>
Co-authored-by: Wesley <69622989+Wesley-0808@users.noreply.github.com>
Co-authored-by: 阿菜 Cai <1064425721@qq.com>
Co-authored-by: maoyiluo <43943796+maoyiluo@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
8 people authored Mar 7, 2025
1 parent 554e544 commit 2ec2016
Show file tree
Hide file tree
Showing 22 changed files with 196 additions and 109 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/pkg-pr-new.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Publish_Any_Commit
on:
push:
branches: [develop]
pull_request:
branches: [develop]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions/setup-node@v4
with:
node-version: 18

- run: npm install

- run: npm run build

- run: npx pkg-pr-new publish --compact
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ toc: false
docClass: timeline
---

## 🌈 1.11.1 `2025-03-07`
### 🚀 Features
- `ImageViewer` @Wesley-0808
- 新增`imageReferrerpolicy`API,适用于需要配置`Referrerpolicy`的场景([#3516](https://github.com/Tencent/tdesign-vue/pull/3516))
- 新增`onDownload`API,用于需要自定义下载回调的场景 ([#3516](https://github.com/Tencent/tdesign-vue/pull/3516))
- `DatePicker`: 调整组件禁用日期`before``after`参数的逻辑,调整为禁用`before`定义之前和`after`定义之后的日期选择,更符合使用习惯。此前有使用相关 API 请注意此改动 @RSS1102 ([#3511](https://github.com/Tencent/tdesign-vue/pull/3511))
- `Upload`: 支持表单禁用功能作用到上传组件 @RSS1102 ([#3525](https://github.com/Tencent/tdesign-vue/pull/3525))

### 🐞 Bug Fixes
- `Select`: 修复多选情况下移除标签时,`trigger` 参数值错误的问题 @betavs ([#3509](https://github.com/Tencent/tdesign-vue/pull/3509))
- `Message`: 修复连续调用messagePlugin时,返回的实例不正确的问题 @maoyiluo ([#3514](https://github.com/Tencent/tdesign-vue/pull/3514))
- `Dialog`: 自定义 `cancelBtn` 文本时保留 `t-dialog__cancel` 样式 @RSS1102 ([#3528](https://github.com/Tencent/tdesign-vue/pull/3528))
- `Bundle`: 修复`1.11.0`的产物中的`cjs` 在 node 20 以下的使用异常的问题 @uyarn ([#3512](https://github.com/Tencent/tdesign-vue/pull/3512))

## 🌈 1.11.0 `2025-02-21`
### 🚀 Features
- `Drawer`: sizeDraggable支持SizeDragLimit类型 @huangchen1031 ([#3465](https://github.com/Tencent/tdesign-vue/pull/3465))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tdesign-vue",
"purename": "tdesign",
"version": "1.11.0-naruto",
"version": "1.11.1-naruto",
"description": "tdesign-vue",
"title": "tdesign-vue",
"keywords": [
Expand Down
6 changes: 4 additions & 2 deletions script/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import ignoreImport from 'rollup-plugin-ignore-import';
import pkg from '../package.json';

const name = 'tdesign';
const externalDeps = Object.keys(pkg.dependencies || {}).concat([/lodash/, /@babel\/runtime/]);
const externalDeps = Object.keys(pkg.dependencies || {}).concat([/@babel\/runtime/]);
const externalPeerDeps = Object.keys(pkg.peerDependencies || {});
const banner = `/**
* ${name} v${pkg.version}
Expand Down Expand Up @@ -179,10 +179,12 @@ const libConfig = {
},
};

const cjsExternalException = ['lodash-es'];
const cjsExternal = externalDeps.concat(externalPeerDeps).filter((value) => !cjsExternalException.includes(value));
/** @type {import('rollup').RollupOptions} */
const cjsConfig = {
input: inputList,
external: externalDeps.concat(externalPeerDeps),
external: cjsExternal,
plugins: [multiInput()].concat(getPlugins({ env: 'production' })),
output: {
banner,
Expand Down
69 changes: 14 additions & 55 deletions src/date-picker/hooks/useDisableDate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import dayjs from 'dayjs';
import { isObject } from 'lodash-es';
import dayjs from 'dayjs';
import { isEnabledDate } from '../../_common/js/date-picker/utils';
import type { TdDatePickerProps, TdDateRangePickerProps } from '../type';

export interface disableDateProps {
Expand All @@ -11,64 +12,22 @@ export interface disableDateProps {
}

export default function useDisableDate(props: disableDateProps) {
const {
disableDate, format, mode, start, end,
} = props;

return {
disableDate: (value: Date) => !isEnabled({
disableDate: props.disableDate,
format: props.format,
mode: props.mode,
disableDate: (value: Date) => !isEnabledDate({
disableDate,
format,
mode,
value,
}),
minDate:
isObject(props.disableDate) && 'before' in props.disableDate ? new Date(props.disableDate.before) : props.start,
isObject(disableDate) && 'before' in disableDate
? new Date(dayjs(disableDate.before).startOf('day').format())
: start,
maxDate:
isObject(props.disableDate) && 'after' in props.disableDate ? new Date(props.disableDate.after) : props.end,
isObject(disableDate) && 'after' in disableDate ? new Date(dayjs(disableDate.after).endOf('day').format()) : end,
};
}

function isEnabled(props: any): boolean {
if (!props.disableDate) return true;

let isEnabled = true;
// 值类型为 Function 则表示返回值为 true 的日期会被禁用
if (typeof props.disableDate === 'function') {
return !props.disableDate(props.value);
}

// 禁用日期,示例:['A', 'B'] 表示日期 A 和日期 B 会被禁用。
if (Array.isArray(props.disableDate)) {
let isIncludes = false;
const formattedDisabledDate = props.disableDate.map((item: string) => dayjs(item, props.format));
formattedDisabledDate.forEach((item: any) => {
if (item.isSame(dayjs(props.value))) {
isIncludes = true;
}
});
return !isIncludes;
}

// { from: 'A', to: 'B' } 表示在 A 到 B 之间的日期会被禁用。
if (props.disableDate.from && props.disableDate.to) {
const compareMin = dayjs(new Date(props.disableDate.from));
const compareMax = dayjs(new Date(props.disableDate.to));

return !dayjs(props.value).isBetween(compareMin, compareMax, props.mode, '[]');
}

const min = props.disableDate.before ? new Date(props.disableDate.before) : null;
const max = props.disableDate.after ? new Date(props.disableDate.after) : null;

// { before: 'A', after: 'B' } 表示在 A 之前和在 B 之后的日期都会被禁用。
if (max && min) {
const compareMin = dayjs(new Date(min));
const compareMax = dayjs(new Date(max));

isEnabled = dayjs(props.value).isBetween(compareMin, compareMax, props.mode, '[]');
} else if (min) {
const compareMin = dayjs(new Date(min));
isEnabled = !dayjs(props.value).isBefore(compareMin, props.mode);
} else if (max) {
const compareMax = dayjs(new Date(max));
isEnabled = !dayjs(props.value).isAfter(compareMax, props.mode);
}
return isEnabled;
}
2 changes: 1 addition & 1 deletion src/dialog/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default Vue.extend({
}
// 如果属性存在,优先返回属性配置
if (cancelBtn && ['string', 'object'].includes(typeof cancelBtn)) {
return this.getButtonByProps(cancelBtn as string | ButtonProps, { defaultButtonProps });
return this.getButtonByProps(cancelBtn as string | ButtonProps, { defaultButtonProps, className });
}
// 渲染插槽 或 function 类型的 confirmBtn,属性优先级更高
return renderTNodeJSX(this, 'cancelBtn');
Expand Down
6 changes: 6 additions & 0 deletions src/image-viewer/base/ImageItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useConfig } from '../../hooks/useConfig';
import { useDrag } from '../hooks';
import { setTransform } from '../../utils/helper';
import { useImagePreviewUrl } from '../../hooks';
import { TdImageViewerProps } from '../type';

export default defineComponent({
name: 'TImageItem',
Expand All @@ -15,6 +16,7 @@ export default defineComponent({
mirror: Number,
src: [String, Object] as PropType<string | File>,
placementSrc: [String, Object] as PropType<string | File>,
imageReferrerpolicy: String as PropType<TdImageViewerProps['imageReferrerpolicy']>,
},

setup(props) {
Expand Down Expand Up @@ -87,6 +89,8 @@ export default defineComponent({
style={this.placementImgStyle}
alt="image"
draggable="false"
// @ts-ignore
referrerpolicy={this.imageReferrerpolicy}
/>
)}

Expand All @@ -103,6 +107,8 @@ export default defineComponent({
style={this.imgStyle}
alt="image"
draggable="false"
// @ts-ignore
referrerpolicy={this.imageReferrerpolicy}
/>
)}
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/image-viewer/base/ImageViewerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const defaultProps = {
zoomInHandler: Function as PropType<() => void>,
zoomOutHandler: Function as PropType<() => void>,
mirrorHandler: Function as PropType<() => void>,
downloadHandler: Function as PropType<(url: string) => void>,
resetHandler: Function as PropType<() => void>,
closeHandler: props.onClose,
draggable: {
Expand All @@ -40,6 +41,7 @@ const defaultProps = {
showOverlay: Boolean,
closeBtn: props.closeBtn,
title: String,
imageReferrerpolicy: props.imageReferrerpolicy,
};

export default defineComponent({
Expand Down Expand Up @@ -85,6 +87,7 @@ export default defineComponent({
rotateHandler={this.rotateHandler}
mirrorHandler={this.mirrorHandler}
resetHandler={this.resetHandler}
downloadHandler={this.downloadHandler}
/>
</div>
)}
Expand All @@ -96,6 +99,7 @@ export default defineComponent({
mirror={this.mirror}
src={this.currentImage.mainImage}
placementSrc={this.currentImage.thumbnail}
imageReferrerpolicy={this.imageReferrerpolicy}
/>
</div>
</TDialog>
Expand Down
4 changes: 2 additions & 2 deletions src/image-viewer/base/ImageViewerUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
import TImageViewerIcon from './ImageModalIcon';
import TToolTip from '../../tooltip';
import { useConfig } from '../../hooks/useConfig';
import { downloadFile } from '../utils';
import { useImagePreviewUrl } from '../../hooks';
import { ImageInfo } from '../type';

Expand All @@ -25,6 +24,7 @@ export default defineComponent({
zoomOutHandler: Function as PropType<() => void>,
mirrorHandler: Function as PropType<() => void>,
resetHandler: Function as PropType<() => void>,
downloadHandler: Function as PropType<(url: string) => void>,
currentImage,
},
setup(props) {
Expand Down Expand Up @@ -87,7 +87,7 @@ export default defineComponent({
<TImageViewerIcon
icon={() => <DownloadIcon size="medium" />}
clickHandler={() => {
downloadFile(this.previewUrl);
this.downloadHandler(this.previewUrl);
}}
/>
)}
Expand Down
6 changes: 5 additions & 1 deletion src/image-viewer/image-viewer.en-US.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
:: BASE_DOC ::

## API

### ImageViewer Props

name | type | default | description | required
Expand All @@ -9,8 +10,9 @@ closeBtn | Boolean / Slot / Function | true | Typescript:`boolean \| TNode`。
closeOnEscKeydown | Boolean | true | trigger image viewer close event on `ESC` keydown | N
closeOnOverlay | Boolean | - | \- | N
draggable | Boolean | undefined | \- | N
imageReferrerpolicy | String | - | attribute of `<img>`, [MDN Definition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy)。options: no-referrer/no-referrer-when-downgrade/origin/origin-when-cross-origin/same-origin/strict-origin/strict-origin-when-cross-origin/unsafe-url | N
imageScale | Object | - | Typescript:`ImageScale` `interface ImageScale { max: number; min: number; step: number; defaultScale?: number; }`[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/image-viewer/type.ts) | N
images | Array | [] | Typescript:`Array<string \| File \| ImageInfo>` `interface ImageInfo { mainImage: string \| File; thumbnail?: string \| File; download?: boolean }`[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/image-viewer/type.ts) | N
images | Array | [] | Typescript:`Array<string \| File \| ImageInfo>` `interface ImageInfo { mainImage: string \| File; thumbnail?: string \| File; download?: boolean; isSvg?: boolean }`[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/image-viewer/type.ts) | N
index | Number | 0 | `.sync` is supported | N
defaultIndex | Number | 0 | uncontrolled property | N
mode | String | modal | options: modal/modeless | N
Expand All @@ -23,11 +25,13 @@ visible | Boolean | false | hide or show image viewer。`v-model` is supported |
defaultVisible | Boolean | false | hide or show image viewer。uncontrolled property | N
zIndex | Number | - | \- | N
onClose | Function | | Typescript:`(context: { trigger: 'close-btn' \| 'overlay' \| 'esc'; e: MouseEvent \| KeyboardEvent }) => void`<br/> | N
onDownload | Function | | Typescript:`(url: string) => void`<br/> | N
onIndexChange | Function | | Typescript:`(index: number, context: { trigger: 'prev' \| 'next' \| 'current' }) => void`<br/> | N

### ImageViewer Events

name | params | description
-- | -- | --
close | `(context: { trigger: 'close-btn' \| 'overlay' \| 'esc'; e: MouseEvent \| KeyboardEvent })` | \-
download | `(url: string \| File)` | \-
index-change | `(index: number, context: { trigger: 'prev' \| 'next' \| 'current' })` | \-
7 changes: 5 additions & 2 deletions src/image-viewer/image-viewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
## API
### ImageViewer Props

名称 | 类型 | 默认值 | 说明 | 必传
名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
closeBtn | Boolean / Slot / Function | true | 是否展示关闭按钮,值为 `true` 显示默认关闭按钮;值为 `false` 则不显示关闭按钮;也可以完全自定义关闭按钮。TS 类型:`boolean \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N
closeOnEscKeydown | Boolean | true | 按下 ESC 时是否触发图片预览器关闭事件 | N
closeOnOverlay | Boolean | - | 是否在点击遮罩层时,触发预览关闭 | N
draggable | Boolean | undefined | 是否允许拖拽调整位置。`mode=modal` 时,默认不允许拖拽;`mode=modeless` 时,默认允许拖拽 | N
imageReferrerpolicy | String | - | 图片预览中的 `<img>` 标签的原生属性,[MDN 定义](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy)。可选项:no-referrer/no-referrer-when-downgrade/origin/origin-when-cross-origin/same-origin/strict-origin/strict-origin-when-cross-origin/unsafe-url | N
imageScale | Object | - | 图片缩放相关配置。`imageScale.max` 缩放的最大比例;`imageScale.min` 缩放的最小比例;`imageScale.step` 缩放的步长速度; `imageScale.defaultScale` 默认的缩放比例。TS 类型:`ImageScale` `interface ImageScale { max: number; min: number; step: number; defaultScale?: number; }`[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/image-viewer/type.ts) | N
images | Array | [] | 图片数组。`mainImage` 表示主图,必传;`thumbnail` 表示缩略图,如果不存在,则使用主图显示;`download` 是否允许下载图片,默认允许下载。示例: `['img_url_1', 'img_url_2']``[{ thumbnail: 'small_image_url', mainImage: 'big_image_url', download: false }]`。TS 类型:`Array<string \| File \| ImageInfo>` `interface ImageInfo { mainImage: string \| File; thumbnail?: string \| File; download?: boolean }`[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/image-viewer/type.ts) | N
images | Array | [] | 图片数组。`mainImage` 表示主图,必传;`thumbnail` 表示缩略图,如果不存在,则使用主图显示;`download` 是否允许下载图片,默认允许下载。示例: `['img_url_1', 'img_url_2']``[{ thumbnail: 'small_image_url', mainImage: 'big_image_url', download: false }]`。TS 类型:`Array<string \| File \| ImageInfo>` `interface ImageInfo { mainImage: string \| File; thumbnail?: string \| File; download?: boolean; isSvg?: boolean }`[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/image-viewer/type.ts) | N
index | Number | 0 | 当前预览图片所在的下标。支持语法糖 `.sync` | N
defaultIndex | Number | 0 | 当前预览图片所在的下标。非受控属性 | N
mode | String | modal | 模态预览(modal)和非模态预览(modeless)。可选项:modal/modeless | N
Expand All @@ -23,11 +24,13 @@ visible | Boolean | false | 隐藏/显示预览。支持语法糖 `v-model` | N
defaultVisible | Boolean | false | 隐藏/显示预览。非受控属性 | N
zIndex | Number | - | 层级,默认为 2000 | N
onClose | Function | | TS 类型:`(context: { trigger: 'close-btn' \| 'overlay' \| 'esc'; e: MouseEvent \| KeyboardEvent }) => void`<br/>关闭时触发,事件参数包含触发关闭的来源:关闭按钮、遮罩层、ESC 键 | N
onDownload | Function | | TS 类型:`(url: string) => void`<br/>自定义预览图片下载操作,url为图片链接 | N
onIndexChange | Function | | TS 类型:`(index: number, context: { trigger: 'prev' \| 'next' \| 'current' }) => void`<br/>预览图片切换时触发,`context.prev` 切换到上一张图片,`context.next` 切换到下一张图片 | N

### ImageViewer Events

名称 | 参数 | 描述
-- | -- | --
close | `(context: { trigger: 'close-btn' \| 'overlay' \| 'esc'; e: MouseEvent \| KeyboardEvent })` | 关闭时触发,事件参数包含触发关闭的来源:关闭按钮、遮罩层、ESC 键
download | `(url: string \| File)` | 自定义预览图片下载操作,url为图片链接
index-change | `(index: number, context: { trigger: 'prev' \| 'next' \| 'current' })` | 预览图片切换时触发,`context.prev` 切换到上一张图片,`context.next` 切换到下一张图片
Loading

0 comments on commit 2ec2016

Please sign in to comment.