Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
1c1ef86
feat: 初始化pickerview
irisSong Jan 16, 2025
3acf368
feat: add pickerView
irisSong Jan 22, 2025
2e3a00a
feat: add tiled demo
irisSong Jan 22, 2025
c651e62
refactor: 重构h5
irisSong Jan 24, 2025
e60df8e
fix: 适配demo
irisSong Jan 24, 2025
43fc55a
feat: 增加级联功能
irisSong Jan 26, 2025
4ce2688
fix: 级联优化
irisSong Feb 10, 2025
28c4e2c
feat: pickerview增加级联效果
irisSong Feb 11, 2025
bc3fb35
fix: 更新taro版本
irisSong Feb 11, 2025
b0b635c
fix: 移除冗余代码+解决form中滚动未结束死循环问题
irisSong Feb 11, 2025
85d5d40
fix: 移除console
irisSong Feb 12, 2025
7a27934
fix: 更新pickerview
irisSong Feb 12, 2025
a030ff4
fix: update test
irisSong Feb 12, 2025
f436c51
fix: update error
irisSong Feb 12, 2025
6a6bc39
fix: update error
irisSong Feb 12, 2025
10be5cd
fix: update demo
irisSong Feb 12, 2025
80f20a1
Merge remote-tracking branch 'upstream/feat_v3.x' into feat_v3.x_pick…
irisSong Feb 12, 2025
8ad7392
fix: update test
irisSong Feb 12, 2025
95b5423
feat: 添加异步demo
irisSong Feb 12, 2025
fe66362
fix: update doc
irisSong Feb 12, 2025
aa5f2ea
fix: 同步pickerview变更
irisSong Feb 12, 2025
b5987b9
fix: 解决小程序控制条样式问题+demo7取消不还原问题
irisSong Feb 12, 2025
0ae1a26
fix: datepicker类型同步更新
irisSong Feb 12, 2025
ce3b37b
fix: 合并主分支
irisSong Feb 12, 2025
26f9319
fix: update test
irisSong Feb 12, 2025
d5118f6
fix: 修改标签
irisSong Feb 13, 2025
a787f7d
feat: add test
irisSong Feb 13, 2025
c10fcc7
fix: update doc and test
irisSong Feb 13, 2025
9e32bcd
fix: adjust the dependency package location
irisSong Feb 13, 2025
ae272de
Merge remote-tracking branch 'upstream/feat_v3.x' into feat_v3.x_pick…
irisSong Feb 13, 2025
f539b83
fix: adjust the dependency package path
irisSong Feb 13, 2025
f06ec00
fix: adjust the dependency package path
irisSong Feb 13, 2025
b67dfca
fix: adjust the dependency package path
irisSong Feb 13, 2025
9905564
fix: update doc props type
irisSong Feb 13, 2025
0c448c8
fix: adjust note
irisSong Feb 13, 2025
cc30cb0
chore: merge v3.x
irisSong Feb 13, 2025
b699d60
Merge branch 'feat_v3.x_picker' of https://github.com/irisSong/nutui-…
irisSong Feb 13, 2025
7760169
fix: adjust the dependency package path
irisSong Feb 13, 2025
86855f0
fix: 合并最新的pickerview
irisSong Feb 13, 2025
88d4f80
fix: optimize details
irisSong Feb 13, 2025
654d1e0
fix: update test
irisSong Feb 13, 2025
507f18c
fix: merge pickerview
irisSong Feb 13, 2025
d9628e7
fix: path not compilable
irisSong Feb 13, 2025
38296d3
fix: key error
irisSong Feb 13, 2025
dc14741
Merge branch 'feat_v3.x_pickerview' into feat_v3.x_picker
irisSong Feb 14, 2025
65238d3
fix: update datepicker test
irisSong Feb 14, 2025
15630d6
Merge remote-tracking branch 'upstream/feat_v3.x' into feat_v3.x_picker
irisSong Feb 14, 2025
369fec3
fix: hidden entry
irisSong Feb 14, 2025
eb899ee
Merge remote-tracking branch 'upstream/feat_v3.x' into feat_v3.x_picker
irisSong Feb 17, 2025
b458e92
fix: modify config
irisSong Feb 17, 2025
ffba77f
fix: remove repeat config
irisSong Feb 17, 2025
f6edf91
fix: 修改组件引入路径
irisSong Feb 25, 2025
9688104
fix: ts类型和单测修正
irisSong Feb 25, 2025
f81ef99
fix: 弹窗动效还原
irisSong Feb 25, 2025
f278479
fix: remove console
irisSong Feb 25, 2025
3fbf988
Merge remote-tracking branch 'upstream/feat_v3.x' into feat_v3.x_picker
irisSong Feb 26, 2025
7b5fd5e
chore: update migrate (#3021)
oasis-cloud Feb 27, 2025
2f0a40e
Merge branch 'feat_v3.x_datepickerview' into refactor_datepicker
irisSong Feb 27, 2025
3a7f51c
fix: 合并picker版本
irisSong Feb 27, 2025
e6a6337
fix: 修改pickerprops路径
irisSong Feb 27, 2025
95dc4b8
refactor: picker (#2990)
irisSong Feb 27, 2025
593e727
fix: 移除console
irisSong Feb 27, 2025
6392141
fix: 修改类型
irisSong Feb 27, 2025
b854693
fix: demo修正同步
irisSong Feb 27, 2025
7497787
fix: pickerprops导出路径修改
irisSong Feb 27, 2025
70abe4f
fix: popover demo修改
irisSong Feb 27, 2025
2db1df1
fix: picker的onchange修改popover demo同步更新 (#3025)
irisSong Feb 27, 2025
b082b51
Merge remote-tracking branch 'upstream/feat_v3.x' into refactor_datep…
irisSong Feb 27, 2025
438950a
fix: taro导出文件修改+demo ts类型修改
irisSong Feb 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
797 changes: 104 additions & 693 deletions migrate-from-v2.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -688,8 +688,8 @@
"sort": 10,
"show": true,
"taro": true,
"author": "dsj",
"dd": false
"dd": false,
"author": "songsong"
},
{
"version": "3.0.0",
Expand Down Expand Up @@ -1456,4 +1456,4 @@
]
}
]
}
}
2 changes: 1 addition & 1 deletion src/packages/backtop/doc.taro.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import { BackTop } from '@nutui/nutui-react-taro'
| threshold | 页面垂直滚动多高后出现 | `number` | `200` |
| zIndex | 设置组件页面层级 | `number` | `900` |
| duration | 设置动画持续时间,为 0 时表示无动画 | `number` | `1000` |
| scrollRes | 被监听容器滚动时的回调参数,主要用于 rn、鸿蒙端 | `PageScrollObejct` | `-` |
| scrollRes | 被监听容器滚动时的回调参数 | `PageScrollObejct` | `-` |
| onClick | 按钮点击时触发事件 | `(event: MouseEvent<HTMLDivElement>) => void` | `-` |

## 主题定制
Expand Down
19 changes: 15 additions & 4 deletions src/packages/calendar/demos/h5/demo6.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import React, { useRef, useState } from 'react'
import { Cell, Calendar, DatePicker, CalendarDay } from '@nutui/nutui-react'
import {
Cell,
Calendar,
DatePicker,
CalendarDay,
PickerValue,
PickerOptions,
} from '@nutui/nutui-react'

const padZero = (num: number | string, targetLength = 2) => {
let str = `${num}`
Expand Down Expand Up @@ -32,14 +39,18 @@ const Demo6 = () => {
const dateArr = [...[chooseData[0][3], chooseData[1][3]]]
setDate([...dateArr])
}
const confirm = (values: (string | number)[], options: any[]) => {
const confirm = (values: PickerValue[], options: PickerOptions) => {
if (desc.current === 1) {
setDesc1(
options.map((option) => padZero(parseInt(option.text))).join(':')
options
.map((option) => padZero(parseInt(option.label as string)))
.join(':')
)
} else {
setDesc2(
options.map((option) => padZero(parseInt(option.text))).join(':')
options
.map((option) => padZero(parseInt(option.label as string)))
.join(':')
)
}
}
Expand Down
12 changes: 9 additions & 3 deletions src/packages/calendar/demos/taro/demo6.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
Calendar,
DatePicker,
CalendarDay,
PickerValue,
PickerOptions,
} from '@nutui/nutui-react-taro'
import { View } from '@tarojs/components'

Expand Down Expand Up @@ -33,14 +35,18 @@ const Demo6 = () => {
const dateArr = [...[chooseData[0][3], chooseData[1][3]]]
setDate([...dateArr])
}
const confirm = (values: (string | number)[], options: any[]) => {
const confirm = (values: PickerValue[], options: PickerOptions) => {
if (desc.current === 1) {
setDesc1(
options.map((option) => padZero(parseInt(option.text))).join(':')
options
.map((option) => padZero(parseInt(option.label as string)))
.join(':')
)
} else {
setDesc2(
options.map((option) => padZero(parseInt(option.text))).join(':')
options
.map((option) => padZero(parseInt(option.label as string)))
.join(':')
)
}
}
Expand Down
32 changes: 14 additions & 18 deletions src/packages/datepicker/__test__/datepicker.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test('Show Chinese', async () => {
fireEvent.click(confirmBtn)
await waitFor(() => {
expect(
confirm.mock.calls[0][0].map((option: any) => option.text).join('')
confirm.mock.calls[0][0].map((option: any) => option.label).join('')
).toEqual(`${currentYear - 10}年01月01日`)
})
})
Expand All @@ -40,13 +40,9 @@ test('Min date & Max date', async () => {
/>
)

const columns = container.querySelectorAll('.nut-picker-list')[0]
const lists = columns.querySelectorAll('.nut-picker-roller-item-title')
const years = ['2020', '2021', '2022']
const columns = container.querySelectorAll('.nut-pickerview-list')
const lists = columns[0].querySelectorAll('.nut-pickerview-roller-item-tiled')
expect(lists.length).toBe(3)
lists.forEach((list, i) => {
expect(list.textContent).toEqual(years[i])
})
rerender(
<DatePicker
title="日期选择"
Expand Down Expand Up @@ -98,22 +94,22 @@ test('Min date & Max date', async () => {
const formatter = (type: string, option: any) => {
switch (type) {
case 'year':
option.text += ''
option.label += ''
break
case 'month':
option.text += 'M'
option.label += 'M'
break
case 'day':
option.text += 'D'
option.label += 'D'
break
case 'hour':
option.text += 'H'
option.label += 'H'
break
case 'minute':
option.text += 'M'
option.label += 'M'
break
default:
option.text += ''
option.label += ''
}
return option
}
Expand Down Expand Up @@ -148,7 +144,7 @@ test('should pick defaultValue', async () => {
fireEvent.click(confirmBtn)
await waitFor(() =>
expect(
confirm.mock.calls[0][0].map((option: any) => option.text).join('')
confirm.mock.calls[0][0].map((option: any) => option.label).join('')
).toEqual('20210301')
)
})
Expand All @@ -166,8 +162,8 @@ test('Increment step setting', async () => {
/>
)

const columns = container.querySelectorAll('.nut-picker-list')[1]
const lists = columns.querySelectorAll('.nut-picker-roller-item')
const columns = container.querySelectorAll('.nut-pickerview-list')
const lists = columns[1].querySelectorAll('.nut-pickerview-roller-item')
expect(lists.length).toBe(12)
})

Expand All @@ -189,7 +185,7 @@ test('Filter Time', async () => {
/>
)

const columns = container.querySelectorAll('.nut-picker-list')[3]
const lists = columns.querySelectorAll('.nut-picker-roller-item')
const columns = container.querySelectorAll('.nut-pickerview-list')
const lists = columns[3].querySelectorAll('.nut-pickerview-roller-item')
expect(lists.length).toBe(4)
})
30 changes: 13 additions & 17 deletions src/packages/datepicker/datepicker.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, {
useImperativeHandle,
} from 'react'
import { View } from '@tarojs/components'
import Picker, { PickerOption } from '@/packages/picker/index.taro'
import Picker from '@/packages/picker/index.taro'
import { useConfig } from '@/packages/configprovider/index.taro'
import { usePropsValue } from '@/hooks/use-props-value'
import { ComponentDefaults } from '@/utils/typings'
Expand All @@ -17,8 +17,9 @@ import {
getDatePartValue,
handlePickerValueChange,
} from './utils'
import { DatePickerActions, DatePickerRef } from './types'
import { DatePickerProps } from './types.taro'
import { DatePickerActions, DatePickerRef } from './types'
import { PickerOptions, PickerValue } from '@/packages/pickerview/types'

const currentYear = new Date().getFullYear()

Expand Down Expand Up @@ -76,8 +77,8 @@ const InternalPicker: ForwardRefRenderFunction<
seconds: lang.seconds,
}

const [pickerValue, setPickerValue] = useState<(string | number)[]>([])
const [pickerOptions, setPickerOptions] = useState<PickerOption[][]>([])
const [pickerValue, setPickerValue] = useState<PickerValue[]>([])
const [pickerOptions, setPickerOptions] = useState<PickerOptions[]>([])

const [selectedDate, setSelectedDate] = usePropsValue<number>({
value: props.value && formatValue(props.value, startDate, endDate),
Expand Down Expand Up @@ -107,7 +108,7 @@ const InternalPicker: ForwardRefRenderFunction<

const handleDateComparison = (
newDate: Date | null,
selectedOptions: PickerOption[],
selectedOptions: PickerOptions,
index: number
) => {
const isEqual = new Date(innerDate)?.getTime() === newDate?.getTime()
Expand Down Expand Up @@ -146,10 +147,7 @@ const InternalPicker: ForwardRefRenderFunction<
onClose?.()
}

const handleConfirm = (
options: PickerOption[],
value: (string | number)[]
) => {
const handleConfirm = (options: PickerOptions, value: PickerValue[]) => {
handlePickerValueChange(
options,
value,
Expand All @@ -162,8 +160,8 @@ const InternalPicker: ForwardRefRenderFunction<
}

const handleChange = (
selectedOptions: PickerOption[],
selectedValue: (string | number)[],
selectedOptions: PickerOptions,
selectedValue: PickerValue[],
index: number
) => {
innerVisible &&
Expand All @@ -177,7 +175,7 @@ const InternalPicker: ForwardRefRenderFunction<
)
}

const generatePickerColumns = (): PickerOption[][] => {
const generatePickerColumns = (): PickerOptions[] => {
const dateRanges = generateDatePickerRanges(
type,
innerDate,
Expand Down Expand Up @@ -236,11 +234,9 @@ const InternalPicker: ForwardRefRenderFunction<
onClose={handleClose}
onCancel={handleCancel}
onConfirm={handleConfirm}
onChange={(
options: PickerOption[],
value: (string | number)[],
index: number
) => handleChange(options, value, index)}
onChange={({ value, index, selectedOptions }) => {
handleChange(selectedOptions, value, index)
}}
threeDimensional={threeDimensional}
/>
)}
Expand Down
28 changes: 12 additions & 16 deletions src/packages/datepicker/datepicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, {
ForwardRefRenderFunction,
useImperativeHandle,
} from 'react'
import Picker, { PickerOption } from '@/packages/picker'
import Picker from '@/packages/picker'
import { useConfig } from '@/packages/configprovider'
import { usePropsValue } from '@/hooks/use-props-value'
import { ComponentDefaults } from '@/utils/typings'
Expand All @@ -17,6 +17,7 @@ import {
handlePickerValueChange,
} from './utils'
import { DatePickerActions, DatePickerProps, DatePickerRef } from './types'
import { PickerOptions, PickerValue } from '@/packages/pickerview/types'

const currentYear = new Date().getFullYear()

Expand Down Expand Up @@ -74,8 +75,8 @@ const InternalPicker: ForwardRefRenderFunction<
seconds: lang.seconds,
}

const [pickerValue, setPickerValue] = useState<(string | number)[]>([])
const [pickerOptions, setPickerOptions] = useState<PickerOption[][]>([])
const [pickerValue, setPickerValue] = useState<PickerValue[]>([])
const [pickerOptions, setPickerOptions] = useState<PickerOptions[]>([])

const [selectedDate, setSelectedDate] = usePropsValue<number>({
value: props.value && formatValue(props.value, startDate, endDate),
Expand Down Expand Up @@ -105,7 +106,7 @@ const InternalPicker: ForwardRefRenderFunction<

const handleDateComparison = (
newDate: Date | null,
selectedOptions: PickerOption[],
selectedOptions: PickerOptions,
index: number
) => {
const isEqual = new Date(innerDate)?.getTime() === newDate?.getTime()
Expand Down Expand Up @@ -144,10 +145,7 @@ const InternalPicker: ForwardRefRenderFunction<
onClose?.()
}

const handleConfirm = (
options: PickerOption[],
value: (string | number)[]
) => {
const handleConfirm = (options: PickerOptions, value: PickerValue[]) => {
handlePickerValueChange(
options,
value,
Expand All @@ -160,8 +158,8 @@ const InternalPicker: ForwardRefRenderFunction<
}

const handleChange = (
selectedOptions: PickerOption[],
selectedValue: (string | number)[],
selectedOptions: PickerOptions,
selectedValue: PickerValue[],
index: number
) => {
innerVisible &&
Expand All @@ -175,7 +173,7 @@ const InternalPicker: ForwardRefRenderFunction<
)
}

const generatePickerColumns = (): PickerOption[][] => {
const generatePickerColumns = (): PickerOptions[] => {
const dateRanges = generateDatePickerRanges(
type,
innerDate,
Expand Down Expand Up @@ -234,11 +232,9 @@ const InternalPicker: ForwardRefRenderFunction<
onClose={handleClose}
onCancel={handleCancel}
onConfirm={handleConfirm}
onChange={(
options: PickerOption[],
value: (string | number)[],
index: number
) => handleChange(options, value, index)}
onChange={({ value, index, selectedOptions }) => {
handleChange(selectedOptions, value, index)
}}
threeDimensional={threeDimensional}
/>
)}
Expand Down
13 changes: 9 additions & 4 deletions src/packages/datepicker/demos/h5/demo1.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import React, { useState } from 'react'
import { DatePicker, Cell, type PickerOption } from '@nutui/nutui-react'
import {
DatePicker,
Cell,
PickerValue,
PickerOptions,
} from '@nutui/nutui-react'
import isEqual from 'react-fast-compare'

const useDatePicker = (initialDate: Date) => {
Expand Down Expand Up @@ -31,17 +36,17 @@ const Demo1 = () => {

const handleConfirm =
(setDesc: (desc: string) => void, setValue?: (value: string) => void) =>
(options: PickerOption[], values: (string | number)[]) => {
(options: PickerOptions, values: PickerValue[]) => {
if (setValue) {
if (isEqual(values, ['2026', '02', '21'])) {
setValue('2026/03/22')
setDesc('2026年03月22日')
} else {
setValue(values.join('/'))
setDesc(options.map((option) => option.text).join(''))
setDesc(options.map((option) => option.label).join(''))
}
} else {
setDesc(options.map((option) => option.text).join(''))
setDesc(options.map((option) => option.label).join(''))
}
}

Expand Down
Loading
Loading