Skip to content

Commit df82d6b

Browse files
authored
refactor: datepicker (#3023)
* feat: 初始化pickerview * feat: add pickerView * feat: add tiled demo * refactor: 重构h5 * fix: 适配demo * feat: 增加级联功能 * fix: 级联优化 * feat: pickerview增加级联效果 * fix: 更新taro版本 * fix: 移除冗余代码+解决form中滚动未结束死循环问题 * fix: 移除console * fix: 更新pickerview * fix: update test * fix: update error * fix: update error * fix: update demo * fix: update test * feat: 添加异步demo * fix: update doc * fix: 同步pickerview变更 * fix: 解决小程序控制条样式问题+demo7取消不还原问题 * fix: datepicker类型同步更新 * fix: update test * fix: 修改标签 * feat: add test * fix: update doc and test * fix: adjust the dependency package location * fix: adjust the dependency package path * fix: adjust the dependency package path * fix: adjust the dependency package path * fix: update doc props type * fix: adjust note * fix: adjust the dependency package path * fix: optimize details * fix: update test * fix: path not compilable * fix: key error * fix: update datepicker test * fix: hidden entry * fix: modify config * fix: remove repeat config * fix: datepicker优化 * fix: datepicker优化 * fix: 取消后还原初始值 * fix: 受控的使用 * fix: 支持指令式调用 * refactor: datepicker taro * chore: 移除注释 * chore: 更新单测引入方式+picker提取pickerProps * fix: ts类型修正 * fix: 修改组件引入路径 * fix: ts类型和单测修正 * fix: 弹窗动效还原 * fix: remove console * fix: 弹窗动效还原 * fix: 修改pickerprops路径 * fix: 修改类型 * fix: demo修正同步 * fix: pickerprops导出路径修改 * fix: popover demo修改 * fix: taro导出文件修改+demo ts类型修改
1 parent d4dfbc4 commit df82d6b

29 files changed

Lines changed: 971 additions & 798 deletions

src/packages/calendar/demos/h5/demo6.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import React, { useRef, useState } from 'react'
2-
import { Cell, Calendar, DatePicker, CalendarDay } from '@nutui/nutui-react'
2+
import {
3+
Cell,
4+
Calendar,
5+
DatePicker,
6+
CalendarDay,
7+
PickerValue,
8+
PickerOptions,
9+
} from '@nutui/nutui-react'
310

411
const padZero = (num: number | string, targetLength = 2) => {
512
let str = `${num}`
@@ -32,14 +39,18 @@ const Demo6 = () => {
3239
const dateArr = [...[chooseData[0][3], chooseData[1][3]]]
3340
setDate([...dateArr])
3441
}
35-
const confirm = (values: (string | number)[], options: any[]) => {
42+
const confirm = (values: PickerValue[], options: PickerOptions) => {
3643
if (desc.current === 1) {
3744
setDesc1(
38-
options.map((option) => padZero(parseInt(option.text))).join(':')
45+
options
46+
.map((option) => padZero(parseInt(option.label as string)))
47+
.join(':')
3948
)
4049
} else {
4150
setDesc2(
42-
options.map((option) => padZero(parseInt(option.text))).join(':')
51+
options
52+
.map((option) => padZero(parseInt(option.label as string)))
53+
.join(':')
4354
)
4455
}
4556
}

src/packages/calendar/demos/taro/demo6.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {
44
Calendar,
55
DatePicker,
66
CalendarDay,
7+
PickerValue,
8+
PickerOptions,
79
} from '@nutui/nutui-react-taro'
810
import { View } from '@tarojs/components'
911

@@ -33,14 +35,18 @@ const Demo6 = () => {
3335
const dateArr = [...[chooseData[0][3], chooseData[1][3]]]
3436
setDate([...dateArr])
3537
}
36-
const confirm = (values: (string | number)[], options: any[]) => {
38+
const confirm = (values: PickerValue[], options: PickerOptions) => {
3739
if (desc.current === 1) {
3840
setDesc1(
39-
options.map((option) => padZero(parseInt(option.text))).join(':')
41+
options
42+
.map((option) => padZero(parseInt(option.label as string)))
43+
.join(':')
4044
)
4145
} else {
4246
setDesc2(
43-
options.map((option) => padZero(parseInt(option.text))).join(':')
47+
options
48+
.map((option) => padZero(parseInt(option.label as string)))
49+
.join(':')
4450
)
4551
}
4652
}

src/packages/datepicker/__test__/datepicker.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import { render, waitFor, fireEvent } from '@testing-library/react'
33
import '@testing-library/jest-dom'
4-
import { DatePicker } from '../datepicker'
4+
import DatePicker from '../datepicker'
55

66
const currentYear = new Date().getFullYear()
77
test('Show Chinese', async () => {

0 commit comments

Comments
 (0)