11import React , { FunctionComponent , useState , useEffect } from 'react'
2- import Picker from '@/packages/picker'
3- import { PickerProps } from '@/packages/picker/index'
2+ import Picker , { PickerProps } from '@/packages/picker/index'
43import { useConfig } from '@/packages/configprovider'
54import { usePropsValue } from '@/hooks/use-props-value'
65import { BasicComponent , ComponentDefaults } from '@/utils/typings'
76import { isDate } from '@/utils/is-date'
87import { padZero } from '@/utils/pad-zero'
9- import { PickerOptionItem , PickerValue } from '@/packages/pickerview/index'
8+ import {
9+ PickerOption ,
10+ PickerOptions ,
11+ PickerValue ,
12+ } from '@/packages/pickerview/types'
1013
1114export interface DatePickerProps extends BasicComponent {
1215 value ?: Date
@@ -39,16 +42,16 @@ export interface DatePickerProps extends BasicComponent {
3942 | 'onChange'
4043 >
4144 >
42- formatter : ( type : string , option : PickerOptionItem ) => PickerOptionItem
43- filter : ( type : string , option : PickerOptionItem [ ] ) => PickerOptionItem [ ]
45+ formatter : ( type : string , option : PickerOption ) => PickerOption
46+ filter : ( type : string , options : PickerOptions ) => PickerOptions
4447 onClose : ( ) => void
4548 onCancel : ( ) => void
4649 onConfirm : (
47- selectedOptions : PickerOptionItem [ ] ,
50+ selectedOptions : PickerOptions ,
4851 selectedValue : PickerValue [ ]
4952 ) => void
5053 onChange ?: (
51- selectedOptions : PickerOptionItem [ ] ,
54+ selectedOptions : PickerOptions ,
5255 selectedValue : PickerValue [ ] ,
5356 columnIndex : number
5457 ) => void
@@ -106,7 +109,7 @@ export const DatePicker: FunctionComponent<
106109 seconds : lang . seconds ,
107110 }
108111 const [ pickerValue , setPickerValue ] = useState < PickerValue [ ] > ( [ ] )
109- const [ pickerOptions , setPickerOptions ] = useState < PickerOptionItem [ ] [ ] > ( [ ] )
112+ const [ pickerOptions , setPickerOptions ] = useState < PickerOptions [ ] > ( [ ] )
110113 const formatValue = ( value : Date | null ) => {
111114 if ( ! value || ( value && ! isDate ( value ) ) ) {
112115 value = startDate
@@ -219,7 +222,7 @@ export const DatePicker: FunctionComponent<
219222 const compareDateChange = (
220223 currentDate : number ,
221224 newDate : Date | null ,
222- selectedOptions : PickerOptionItem [ ] ,
225+ selectedOptions : PickerOptions ,
223226 index : number
224227 ) => {
225228 const isEqual = new Date ( currentDate ) ?. getTime ( ) === newDate ?. getTime ( )
@@ -239,7 +242,7 @@ export const DatePicker: FunctionComponent<
239242 }
240243 }
241244 const handlePickerChange = (
242- selectedOptions : PickerOptionItem [ ] ,
245+ selectedOptions : PickerOptions ,
243246 selectedValue : PickerValue [ ] ,
244247 index : number
245248 ) => {
@@ -331,7 +334,7 @@ export const DatePicker: FunctionComponent<
331334 columnIndex : number
332335 ) => {
333336 let cmin = min
334- const arr : Array < PickerOptionItem > = [ ]
337+ const arr : Array < PickerOption > = [ ]
335338 let index = 0
336339 while ( cmin <= max ) {
337340 arr . push ( formatOption ( type , cmin ) )
@@ -409,7 +412,7 @@ export const DatePicker: FunctionComponent<
409412 onCancel = { onCancel }
410413 value = { pickerValue }
411414 onConfirm = { (
412- selectedOptions : PickerOptionItem [ ] ,
415+ selectedOptions : PickerOptions ,
413416 selectedValue : PickerValue [ ]
414417 ) => onConfirm && onConfirm ( selectedOptions , selectedValue ) }
415418 onChange = { ( { value, index, selectedOptions } ) => {
0 commit comments