diff --git a/CHANGELOG.en-US.md b/CHANGELOG.en-US.md index f7fb8ac11..dae382fa6 100644 --- a/CHANGELOG.en-US.md +++ b/CHANGELOG.en-US.md @@ -1,5 +1,11 @@ # CHANGELOG +## Pending + +### Fixes + +- Fix `n-calendar`'s `on-update:value` prop type. + ## 2.11.7 ### Fixes diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index 6a86346d8..aee28e2d1 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -1,5 +1,11 @@ # CHANGELOG +## Pending + +### Fixes + +- 修复 `n-calendar` 的 `on-update:value` 属性类型 + ## 2.11.7 ### Fixes diff --git a/src/calendar/src/Calendar.tsx b/src/calendar/src/Calendar.tsx index 0af56b9db..a9734029a 100644 --- a/src/calendar/src/Calendar.tsx +++ b/src/calendar/src/Calendar.tsx @@ -21,6 +21,7 @@ import { useConfig, useLocale, useTheme } from '../../_mixins' import type { ThemeProps } from '../../_mixins' import { calendarLight } from '../styles' import type { CalendarTheme } from '../styles' +import type { OnUpdateValue, DateItem } from './interface' import style from './styles/index.cssr' const calendarProps = { @@ -31,22 +32,12 @@ const calendarProps = { type: Number as PropType, defualt: null }, - 'onUpdate:value': [Function, Array] as PropType< - MaybeArray<(value: number) => void> - >, - onUpdateValue: [Function, Array] as PropType< - MaybeArray<(value: number) => void> - > + 'onUpdate:value': [Function, Array] as PropType>, + onUpdateValue: [Function, Array] as PropType> } as const export type CalendarProps = ExtractPublicPropTypes -interface DateItem { - year: number - month: number - date: number -} - export default defineComponent({ name: 'Calendar', props: calendarProps, @@ -78,6 +69,7 @@ export default defineComponent({ if (_onUpdateValue) { call(_onUpdateValue, value, time) } + console.log(time) uncontrolledValueRef.value = value } diff --git a/src/calendar/src/interface.ts b/src/calendar/src/interface.ts new file mode 100644 index 000000000..ca515e0fc --- /dev/null +++ b/src/calendar/src/interface.ts @@ -0,0 +1,7 @@ +export type OnUpdateValue = (value: number, time: DateItem) => void + +export interface DateItem { + year: number + month: number + date: number +} diff --git a/src/calendar/tests/Calendar.spec.tsx b/src/calendar/tests/Calendar.spec.tsx new file mode 100644 index 000000000..46ed9a71f --- /dev/null +++ b/src/calendar/tests/Calendar.spec.tsx @@ -0,0 +1,21 @@ +import { h } from 'vue' +import { mount } from '@vue/test-utils' +import { NCalendar } from '../index' + +describe('n-button', () => { + it('should work with import on demand', () => { + mount(NCalendar) + }) + it('props.onUpdate has correct type', () => { + ; {}} + /> + }) +})