mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-21 04:50:14 +08:00
fix(calendar): on-update:value
prop type
This commit is contained in:
parent
7033bf9272
commit
5a7b2fa0e2
@ -1,5 +1,11 @@
|
||||
# CHANGELOG
|
||||
|
||||
## Pending
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fix `n-calendar`'s `on-update:value` prop type.
|
||||
|
||||
## 2.11.7
|
||||
|
||||
### Fixes
|
||||
|
@ -1,5 +1,11 @@
|
||||
# CHANGELOG
|
||||
|
||||
## Pending
|
||||
|
||||
### Fixes
|
||||
|
||||
- 修复 `n-calendar` 的 `on-update:value` 属性类型
|
||||
|
||||
## 2.11.7
|
||||
|
||||
### Fixes
|
||||
|
@ -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<number | null>,
|
||||
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<MaybeArray<OnUpdateValue>>,
|
||||
onUpdateValue: [Function, Array] as PropType<MaybeArray<OnUpdateValue>>
|
||||
} as const
|
||||
|
||||
export type CalendarProps = ExtractPublicPropTypes<typeof calendarProps>
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
7
src/calendar/src/interface.ts
Normal file
7
src/calendar/src/interface.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export type OnUpdateValue = (value: number, time: DateItem) => void
|
||||
|
||||
export interface DateItem {
|
||||
year: number
|
||||
month: number
|
||||
date: number
|
||||
}
|
21
src/calendar/tests/Calendar.spec.tsx
Normal file
21
src/calendar/tests/Calendar.spec.tsx
Normal file
@ -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', () => {
|
||||
;<NCalendar
|
||||
onUpdateValue={(
|
||||
value: number,
|
||||
time: {
|
||||
date: number
|
||||
month: number
|
||||
year: number
|
||||
}
|
||||
) => {}}
|
||||
/>
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user