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

chore: release 1.10.5-naruto #3391

Merged
merged 10 commits into from
Nov 8, 2024
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.10.5 `2024-11-08`
### 🚀 Features
- `Switch`: 新增 `before-change` API, 用于需要发起异步请求的场景 @centuryPark ([#3386](https://github.com/Tencent/tdesign-vue/pull/3386))
- `DatePicker`: 新增 `disableTime` API,在日期时间选择器场景下使用 @myronliu347 ([#3324](https://github.com/Tencent/tdesign-vue/pull/3324))
- `Cascader`: 单选模式下当`trigger`为`hover`时,选中选项后自动关闭面板 @uyarn ([#3389](https://github.com/Tencent/tdesign-vue/pull/3389))
### 🐞 Bug Fixes
- `DatePicker`: `DateRangePickerPanel`组件`mode`为`week`时无法通过左右箭头调整月份 @RSS1102 ([#3370](https://github.com/Tencent/tdesign-vue/pull/3370))
- `Table`: 修复多级表头下的通过`colspan`合并表头的问题 @wangyang0210 ([#3372](https://github.com/Tencent/tdesign-vue/pull/3372))
- `ColorPicker`: 修复最近使用颜色删除的缺陷,调整为选中才能删除 @superNos ([#3384](https://github.com/Tencent/tdesign-vue/pull/3384))
- `TagInput`: 修复在`readonly` 模式下仍可以通过`Backspace` 删除已选项的缺陷 @RSS1102 ([#3376](https://github.com/Tencent/tdesign-vue/pull/3376))
### 🚧 Others
- `Drawer`: 修复 `live demo` 中头部配置展示异常的问题 @cszhjh ([#3385](https://github.com/Tencent/tdesign-vue/pull/3385))

## 🌈 1.10.4 `2024-10-18`
### 🚀 Features
- `TimePicker`: 新增 `autoSwap` API,支持`1.10.2` 版本之后仍支持保持选定的左右侧时间大小顺序 @uyarn ([#3363](https://github.com/Tencent/tdesign-vue/pull/3363))
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.10.4-naruto",
"version": "1.10.5-naruto",
"description": "tdesign-vue",
"title": "tdesign-vue",
"keywords": [
Expand Down
3 changes: 2 additions & 1 deletion script/generate-usage/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,8 @@ module.exports = {
drawer: `
<div>
<t-button @click="handleClick">Open Drawer</t-button>
<t-drawer v-bind="configProps" :visible.sync="visible" header="header">
<t-drawer v-bind="configProps" :visible.sync="visible">
<template #header>header</template>
<p>This is a Drawer</p>
</t-drawer>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/cascader/core/effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export function expendClickEffect(
// 非受控状态下更新状态
setValue(valueType === 'single' ? value : node.getPath().map((item) => item.value), 'check', node.getModel());

if (!checkStrictly) {
// 当 trigger 为 hover 时 ,点击节点一定是关闭 panel 的操作
if (!checkStrictly || propsTrigger === 'hover') {
setVisible(false, {});
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/color-picker/panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,10 @@ export default defineComponent({
},
render() {
const {
baseClassName, statusClassNames, t, global, recentColors, swatchColors, previewColorStyle, isGradient,
baseClassName, statusClassNames, t, global, swatchColors, previewColorStyle, isGradient,
} = this;

const showUsedColors = recentColors !== null && recentColors !== false;
const showUsedColors = this.recentlyUsedColors !== null && this.recentlyUsedColors !== false;

let systemColors = swatchColors;
if (systemColors === undefined) {
Expand Down
9 changes: 3 additions & 6 deletions src/color-picker/panel/swatches.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,10 @@ export default defineComponent({
* 移除颜色
*/
const handleRemoveColor = () => {
const colors = [...props.colors];
const { colors } = props;
const selectedIndex = selectedColorIndex.value;
if (selectedIndex > -1) {
colors.splice(selectedIndex, 1);
} else {
colors.length = 0;
}
if (selectedIndex === -1) return;
colors.splice(selectedIndex, 1);
props.handleChange?.(colors);
setVisiblePopConfirm(false);
};
Expand Down
1 change: 1 addition & 0 deletions src/date-picker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export default defineComponent({
presets: props.presets,
time: time.value as string,
disableDate: props.disableDate,
disableTime: props.disableTime,
firstDayOfWeek: props.firstDayOfWeek,
timePickerProps: props.timePickerProps,
enableTimePicker: props.enableTimePicker,
Expand Down
1 change: 1 addition & 0 deletions src/date-picker/DateRangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ export default defineComponent({
presets: props.presets,
time: time.value,
disableDate: props.disableDate,
disableTime: props.disableTime,
firstDayOfWeek: props.firstDayOfWeek,
timePickerProps: props.timePickerProps,
enableTimePicker: props.enableTimePicker,
Expand Down
10 changes: 9 additions & 1 deletion src/date-picker/DateRangePickerPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default defineComponent({
defaultValue: dateRangePickerProps.defaultValue,
disabled: dateRangePickerProps.disabled,
disableDate: dateRangePickerProps.disableDate,
disableTime: dateRangePickerProps.disableTime,
enableTimePicker: dateRangePickerProps.enableTimePicker,
firstDayOfWeek: dateRangePickerProps.firstDayOfWeek,
format: dateRangePickerProps.format,
Expand Down Expand Up @@ -135,7 +136,13 @@ export default defineComponent({
prev: 'arrow-previous',
next: 'arrow-next',
};
const monthCountMap = { date: 1, month: 12, year: 120 };
const monthCountMap = {
date: 1,
week: 1,
month: 12,
quarter: 12,
year: 120,
};
const monthCount = monthCountMap[props.mode] || 0;
const current = new Date(year.value[partialIndex], month.value[partialIndex]);

Expand Down Expand Up @@ -385,6 +392,7 @@ export default defineComponent({
presets: props.presets,
time: time.value,
disableDate: props.disableDate,
disableTime: props.disableTime,
firstDayOfWeek: props.firstDayOfWeek,
timePickerProps: props.timePickerProps,
enableTimePicker: props.enableTimePicker,
Expand Down
23 changes: 9 additions & 14 deletions src/date-picker/_example-composition/disable-date.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
placeholder="禁用日期精确到时间"
enable-time-picker
:disable-date="{ before: dayjs().subtract(1, 'day').format() }"
:time-picker-props="timePickerProps"
@pick="(date) => (pickDate = dayjs(date).format('YYYY-MM-DD'))"
:disable-time="disableTime"
/>
<t-date-range-picker
placeholder="禁用最近 5 天外的日期"
Expand All @@ -37,18 +36,14 @@
</template>

<script setup>
import { ref, computed } from 'vue';
import dayjs from 'dayjs';

const pickDate = ref('');
const timePickerProps = computed(() => ({
disableTime: () => {
if (pickDate.value === dayjs().format('YYYY-MM-DD')) {
return {
hour: [0, 1, 2, 3, 4, 5, 6],
};
}
return {};
},
}));
const disableTime = (time) => {
if (dayjs(time).format('YYYY-MM-DD') === dayjs().format('YYYY-MM-DD')) {
return {
hour: [0, 1, 2, 3, 4, 5, 6],
};
}
return {};
};
</script>
25 changes: 10 additions & 15 deletions src/date-picker/_example/disable-date.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
placeholder="禁用日期精确到时间"
enable-time-picker
:disable-date="{ before: dayjs().subtract(1, 'day').format() }"
:time-picker-props="timePickerProps"
@pick="(date) => (pickDate = dayjs(date).format('YYYY-MM-DD'))"
:disable-time="disableTime"
/>
<t-date-range-picker
placeholder="禁用最近 5 天外的日期"
Expand All @@ -41,20 +40,16 @@ import dayjs from 'dayjs';

export default {
data() {
return { pickDate: '', dayjs };
return { dayjs };
},
computed: {
timePickerProps() {
return {
disableTime: () => {
if (this.pickDate === dayjs().format('YYYY-MM-DD')) {
return {
hour: [0, 1, 2, 3, 4, 5, 6],
};
}
return {};
},
};
methods: {
disableTime: (time) => {
if (dayjs(time).format('YYYY-MM-DD') === dayjs().format('YYYY-MM-DD')) {
return {
hour: [0, 1, 2, 3, 4, 5, 6],
};
}
return {};
},
},
};
Expand Down
4 changes: 3 additions & 1 deletion src/date-picker/date-picker.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ borderless | Boolean | false | \- | N
clearable | Boolean | false | \- | N
defaultTime | String | '00:00:00' | Time selector default value | N
disableDate | Object / Array / Function | - | Typescript:`DisableDate` `type DisableDate = Array<DateValue> \| DisableDateObj \| ((date: DateValue) => boolean)` `interface DisableDateObj { from?: string; to?: string; before?: string; after?: string }`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts) | N
disableTime | Function | - | disable time config function。Typescript:`(time: Date) => Partial<{ hour: Array<number>, minute: Array<number>, second: Array<number>, millisecond: Array<number> }>`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts) | N
disabled | Boolean | - | make DatePicker to be disabled | N
enableTimePicker | Boolean | false | \- | N
firstDayOfWeek | Number | 7 | options: 1/2/3/4/5/6/7 | N
Expand Down Expand Up @@ -60,6 +61,7 @@ borderless | Boolean | false | \- | N
clearable | Boolean | false | \- | N
defaultTime | Array | ["00:00:00", "23:59:59"] | Time selector default value。Typescript:`string[]` | N
disableDate | Object / Array / Function | - | Typescript:`DisableRangeDate` `type DisableRangeDate = Array<DateValue> \| DisableDateObj \| ((context: { date: DateRangeValue; partial: DateRangePickerPartial }) => boolean)` `interface DisableDateObj { from?: string; to?: string; before?: string; after?: string }` `type DateRangePickerPartial = 'start' \| 'end'`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts) | N
disableTime | Function | - | Typescript:`(times: [Date \| null, Date \| null], context: { partial: DateRangePickerPartial }) => Partial<{ hour: Array<number>, minute: Array<number>, second: Array<number> }>`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts) | N
disabled | Boolean | - | \- | N
enableTimePicker | Boolean | false | \- | N
firstDayOfWeek | Number | - | options: 1/2/3/4/5/6/7 | N
Expand Down Expand Up @@ -108,7 +110,7 @@ preset-click | `(context: { preset: PresetDate, e: MouseEvent })` | \-
name | type | default | description | required
-- | -- | -- | -- | --
defaultTime | String | '00:00:00' | Time selector default value | N
`Pick<DatePickerProps, 'value' \| 'defaultValue' \| 'disableDate' \| 'enableTimePicker' \| 'firstDayOfWeek' \| 'format' \| 'mode' \| 'presets' \| 'presetsPlacement' \| 'timePickerProps'>` | \- | - | extends `Pick<DatePickerProps, 'value' \| 'defaultValue' \| 'disableDate' \| 'enableTimePicker' \| 'firstDayOfWeek' \| 'format' \| 'mode' \| 'presets' \| 'presetsPlacement' \| 'timePickerProps'>` | N
`Pick<DatePickerProps, 'value' \| 'defaultValue' \| 'disableDate' \| 'disableTime' \| 'enableTimePicker' \| 'firstDayOfWeek' \| 'format' \| 'mode' \| 'presets' \| 'presetsPlacement' \| 'timePickerProps'>` | \- | - | extends `Pick<DatePickerProps, 'value' \| 'defaultValue' \| 'disableDate' \| 'disableTime' \| 'enableTimePicker' \| 'firstDayOfWeek' \| 'format' \| 'mode' \| 'presets' \| 'presetsPlacement' \| 'timePickerProps'>` | N
onCellClick | Function | | Typescript:`(context: { date: Date, e: MouseEvent }) => void`<br/> | N
onChange | Function | | Typescript:`(value: DateValue, context: { dayjsValue?: Dayjs, e?: MouseEvent, trigger?: DatePickerTriggerSource }) => void`<br/> | N
onConfirm | Function | | Typescript:`(context: { date: Date, e: MouseEvent }) => void`<br/> | N
Expand Down
6 changes: 4 additions & 2 deletions src/date-picker/date-picker.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ borderless | Boolean | false | 无边框模式 | N
clearable | Boolean | false | 是否显示清除按钮 | N
defaultTime | String | '00:00:00' | 时间选择器默认值,当 value/defaultValue 未设置值时有效 | N
disableDate | Object / Array / Function | - | 禁用日期,示例:['A', 'B'] 表示日期 A 和日期 B 会被禁用。`{ from: 'A', to: 'B' }` 表示在 A 到 B 之间的日期会被禁用。`{ before: 'A', after: 'B' }` 表示在 A 之前和在 B 之后的日期都会被禁用。其中 A = '2021-01-01',B = '2021-02-01'。值类型为 Function 则表示返回值为 true 的日期会被禁用。TS 类型:`DisableDate` `type DisableDate = Array<DateValue> \| DisableDateObj \| ((date: DateValue) => boolean)` `interface DisableDateObj { from?: string; to?: string; before?: string; after?: string }`。[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts) | N
disableTime | Function | - | 禁用时间项的配置函数,仅在日期时间选择器中可用。TS 类型:`(time: Date) => Partial<{ hour: Array<number>, minute: Array<number>, second: Array<number>, millisecond: Array<number> }>`。[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts) | N
disabled | Boolean | - | 是否禁用组件 | N
enableTimePicker | Boolean | false | 是否显示时间选择 | N
firstDayOfWeek | Number | 7 | 第一天从星期几开始。可选项:1/2/3/4/5/6/7 | N
Expand Down Expand Up @@ -60,6 +61,7 @@ borderless | Boolean | false | 无边框模式 | N
clearable | Boolean | false | 是否显示清除按钮 | N
defaultTime | Array | ["00:00:00", "23:59:59"] | 时间选择器默认值,当 value/defaultValue 未设置值时有效。TS 类型:`string[]` | N
disableDate | Object / Array / Function | - | 禁用日期,示例:['A', 'B'] 表示日期 A 和日期 B 会被禁用。{ from: 'A', to: 'B' } 表示在 A 到 B 之间的日期会被禁用。{ before: 'A', after: 'B' } 表示在 A 之前和在 B 之后的日期都会被禁用。其中 A = '2021-01-01',B = '2021-02-01'。值类型为 Function 则表示返回值为 true 的日期会被禁用。TS 类型:`DisableRangeDate` `type DisableRangeDate = Array<DateValue> \| DisableDateObj \| ((context: { date: DateRangeValue; partial: DateRangePickerPartial }) => boolean)` `interface DisableDateObj { from?: string; to?: string; before?: string; after?: string }` `type DateRangePickerPartial = 'start' \| 'end'`。[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts) | N
disableTime | Function | - | 禁用时间项的配置函数,仅在日期区间选择器中开启时间展示时可用。TS 类型:`(times: [Date \| null, Date \| null], context: { partial: DateRangePickerPartial }) => Partial<{ hour: Array<number>, minute: Array<number>, second: Array<number> }>`。[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts) | N
disabled | Boolean | - | 是否禁用组件 | N
enableTimePicker | Boolean | false | 是否显示时间选择 | N
firstDayOfWeek | Number | - | 第一天从星期几开始。可选项:1/2/3/4/5/6/7 | N
Expand Down Expand Up @@ -108,7 +110,7 @@ preset-click | `(context: { preset: PresetDate, e: MouseEvent })` | 点击预设
名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
defaultTime | String | '00:00:00' | 时间选择器默认值,当 value/defaultValue 未设置值时有效 | N
`Pick<DatePickerProps, 'value' \| 'defaultValue' \| 'disableDate' \| 'enableTimePicker' \| 'firstDayOfWeek' \| 'format' \| 'mode' \| 'presets' \| 'presetsPlacement' \| 'timePickerProps'>` | \- | - | 继承 `Pick<DatePickerProps, 'value' \| 'defaultValue' \| 'disableDate' \| 'enableTimePicker' \| 'firstDayOfWeek' \| 'format' \| 'mode' \| 'presets' \| 'presetsPlacement' \| 'timePickerProps'>` 中的全部属性 | N
`Pick<DatePickerProps, 'value' \| 'defaultValue' \| 'disableDate' \| 'disableTime' \| 'enableTimePicker' \| 'firstDayOfWeek' \| 'format' \| 'mode' \| 'presets' \| 'presetsPlacement' \| 'timePickerProps'>` | \- | - | 继承 `Pick<DatePickerProps, 'value' \| 'defaultValue' \| 'disableDate' \| 'disableTime' \| 'enableTimePicker' \| 'firstDayOfWeek' \| 'format' \| 'mode' \| 'presets' \| 'presetsPlacement' \| 'timePickerProps'>` 中的全部属性 | N
onCellClick | Function | | TS 类型:`(context: { date: Date, e: MouseEvent }) => void`<br/>点击日期单元格时触发 | N
onChange | Function | | TS 类型:`(value: DateValue, context: { dayjsValue?: Dayjs, e?: MouseEvent, trigger?: DatePickerTriggerSource }) => void`<br/>选中值发生变化时触发。参数 `context.trigger` 表示触发当前事件的来源,不同的模式触发来源也会不同 | N
onConfirm | Function | | TS 类型:`(context: { date: Date, e: MouseEvent }) => void`<br/>如果存在“确定”按钮,则点击“确定”按钮时触发 | N
Expand Down Expand Up @@ -137,7 +139,7 @@ year-change | `(context: { year: number, date: Date, trigger: DatePickerYearChan
名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
defaultTime | Array | ["00:00:00", "23:59:59"] | 时间选择器默认值,当 value/defaultValue 未设置值时有效。TS 类型:`string[]` | N
`Pick<DateRangePickerProps, 'value'\| 'defaultValue' \| 'disableDate' \| 'enableTimePicker' \| 'firstDayOfWeek' \| 'format' \| 'mode' \| 'presets' \| 'presetsPlacement' \| 'panelPreselection' \| 'timePickerProps'>` | \- | - | 继承 `Pick<DateRangePickerProps, 'value'\| 'defaultValue' \| 'disableDate' \| 'enableTimePicker' \| 'firstDayOfWeek' \| 'format' \| 'mode' \| 'presets' \| 'presetsPlacement' \| 'panelPreselection' \| 'timePickerProps'>` 中的全部属性 | N
`Pick<DateRangePickerProps, 'value'\| 'defaultValue' \| 'disableDate' \| 'disableTime' \| 'enableTimePicker' \| 'firstDayOfWeek' \| 'format' \| 'mode' \| 'presets' \| 'presetsPlacement' \| 'panelPreselection' \| 'timePickerProps'>` | \- | - | 继承 `Pick<DateRangePickerProps, 'value'\| 'defaultValue' \| 'disableDate' \| 'disableTime' \| 'enableTimePicker' \| 'firstDayOfWeek' \| 'format' \| 'mode' \| 'presets' \| 'presetsPlacement' \| 'panelPreselection' \| 'timePickerProps'>` 中的全部属性 | N
onCellClick | Function | | TS 类型:`(context: { date: Date[], partial: DateRangePickerPartial, e: MouseEvent }) => void`<br/>点击日期单元格时触发 | N
onChange | Function | | TS 类型:`(value: DateRangeValue, context: { dayjsValue?: Dayjs[], partial: DateRangePickerPartial, e?: MouseEvent, trigger?: DatePickerTriggerSource }) => void`<br/>选中值发生变化时触发。参数 `context.trigger` 表示触发当前事件的来源,不同的模式触发来源也会不同 | N
onConfirm | Function | | TS 类型:`(context: { date: Date[], e: MouseEvent }) => void`<br/>如果存在“确定”按钮,则点击“确定”按钮时触发 | N
Expand Down
4 changes: 4 additions & 0 deletions src/date-picker/date-range-picker-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export default {
disableDate: {
type: [Object, Array, Function] as PropType<TdDateRangePickerProps['disableDate']>,
},
/** 禁用时间项的配置函数,仅在日期区间选择器中开启时间展示时可用 */
disableTime: {
type: Function as PropType<TdDateRangePickerProps['disableTime']>,
},
/** 是否禁用组件 */
disabled: Boolean,
/** 只读状态,值为真会隐藏输入框,且无法打开下拉框 */
Expand Down
1 change: 1 addition & 0 deletions src/date-picker/panel/PanelContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default defineComponent({
{...{
key: this.partial,
props: {
position: this.partial,
format: timeFormat,
value: this.time,
onChange: this.onTimePickerChange,
Expand Down
Loading
Loading