Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/packages/animatingnumbers/countup.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,5 @@ export const CountUp: FunctionComponent<Partial<CountUpProps>> = (props) => {
)
}

CountUp.defaultProps = defaultProps
CountUp.defaultProps = defaultProps // 不可删除
CountUp.displayName = 'NutCountUp'
2 changes: 1 addition & 1 deletion src/packages/animatingnumbers/countup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,5 @@ export const CountUp: FunctionComponent<Partial<CountUpProps>> = (props) => {
)
}

CountUp.defaultProps = defaultProps
CountUp.defaultProps = defaultProps // 不可删除
CountUp.displayName = 'NutCountUp'
15 changes: 7 additions & 8 deletions src/packages/audio/audio.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,20 @@ export const Audio: FunctionComponent<
audioCtx.autoplay = autoplay || false
audioCtx.loop = loop || false
audioCtx.onPause(() => {
props.onPause && props.onPause(audioCtx)
onPause?.(audioCtx)
})
audioCtx.onEnded(() => {
if (props.loop) {
if (loop) {
console.warn(locale.audio.tips || 'onPlayEnd事件在loop=false时才会触发')
} else {
props.onPlayEnd && props.onPlayEnd(audioCtx)
onPlayEnd?.(audioCtx)
}
})

audioCtx.onPlay(() => {
const { duration } = audioCtx
setTotalSeconds(Math.floor(duration))
props.onPlay && props.onPlay(audioCtx)
onPlay?.(audioCtx)
})
audioCtx.onCanplay(() => {
const intervalID = setInterval(function () {
Expand All @@ -111,7 +111,7 @@ export const Audio: FunctionComponent<
}
}, 500)
setIsCanPlay(true)
props.onCanPlay && props.onCanPlay(audioCtx)
onCanPlay?.(audioCtx)
})
audioCtx.onTimeUpdate(() => {
const time = parseInt(`${audioCtx.currentTime}`)
Expand Down Expand Up @@ -146,15 +146,15 @@ export const Audio: FunctionComponent<
statusRef.current.currentTime = Math.max(currentTime - 1, 0)
setCurrentDuration(formatSeconds(statusRef.current.currentTime.toString()))
audioCtx.seek(statusRef.current.currentTime)
props.onFastBack && props.onFastBack(audioCtx)
onFastBack?.(audioCtx)
}

const handleForward = () => {
const currentTime = Math.floor(audioCtx.currentTime)
statusRef.current.currentTime = Math.min(currentTime + 1, audioCtx.duration)
setCurrentDuration(formatSeconds(statusRef.current.currentTime.toString()))
audioCtx.seek(statusRef.current.currentTime)
props.onForward && props.onForward(audioCtx)
onForward?.(audioCtx)
}

const handleStatusChange = () => {
Expand Down Expand Up @@ -267,5 +267,4 @@ export const Audio: FunctionComponent<
)
}

Audio.defaultProps = defaultProps
Audio.displayName = 'NutAudio'
21 changes: 10 additions & 11 deletions src/packages/audio/audio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ export const Audio: FunctionComponent<
percent: 0,
duration: '00:00:00',
second: 0,
hanMuted: props.muted,
playing: props.autoPlay,
hanMuted: muted,
playing: autoPlay,
handPlaying: false,
})
const classPrefix = 'nut-audio'
const handleEnded = (e: SyntheticEvent<HTMLAudioElement>) => {
if (props.loop) {
if (loop) {
console.warn(locale.audio.tips || 'onPlayEnd事件在loop=false时才会触发')
} else {
props.onEnd && props.onEnd(e)
onEnd?.(e)
}
}

Expand Down Expand Up @@ -130,25 +130,25 @@ export const Audio: FunctionComponent<
if (statusRef.current.currentTime > 0 && AudioRef.current) {
statusRef.current.currentTime--
AudioRef.current.currentTime = statusRef.current.currentTime
props.onBack && props.onBack(AudioRef.current)
onBack?.(AudioRef.current)
}
}
const handleForward = () => {
if (AudioRef.current) {
statusRef.current.currentTime++
AudioRef.current.currentTime = statusRef.current.currentTime
props.onForward && props.onForward(AudioRef.current)
onForward?.(AudioRef.current)
}
}
const handleMute = () => {
if (AudioRef.current) {
AudioRef.current.muted = !AudioRef.current.muted
props.onMute && props.onMute(AudioRef.current)
onMute?.(AudioRef.current)
}
}
const handlePause = (e: SyntheticEvent<HTMLAudioElement>) => {
setPlaying(false)
props.onPause && props.onPause(e)
onPause?.(e)
}

const formatSeconds = (value: string) => {
Expand Down Expand Up @@ -252,12 +252,12 @@ export const Audio: FunctionComponent<

const handleCanplay = (e: SyntheticEvent<HTMLAudioElement>) => {
setIsCanPlay(true)
if (props.autoPlay && !playing) {
if (autoPlay && !playing) {
AudioRef && AudioRef.current && AudioRef.current.play()
}
if (AudioRef.current) {
statusRef.current.second = AudioRef.current.duration || 0
props.onCanPlay && props.onCanPlay(e)
onCanPlay?.(e)
}
}
const onTimeupdate = (e: SyntheticEvent<HTMLAudioElement>) => {
Expand Down Expand Up @@ -290,5 +290,4 @@ export const Audio: FunctionComponent<
)
}

Audio.defaultProps = defaultProps
Audio.displayName = 'NutAudio'
11 changes: 5 additions & 6 deletions src/packages/checkboxgroup/checkboxgroup.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ export const CheckboxGroup = React.forwardRef(
className,
disabled,
list,
onChange,
value,
defaultValue,
max,
min,
onLimit,
labelPosition,
direction,
options,
onChange,
onLimit,
...rest
} = { ...defaultProps, ...props }

Expand Down Expand Up @@ -86,8 +86,8 @@ export const CheckboxGroup = React.forwardRef(
}))

const [_value, setValue] = usePropsValue<string[]>({
value: props.value,
defaultValue: props.defaultValue,
value,
defaultValue,
finalValue: [] as string[],
onChange,
})
Expand Down Expand Up @@ -137,7 +137,7 @@ export const CheckboxGroup = React.forwardRef(
className={classNames(
classPrefix,
{
[`nut-checkboxgroup-${props.direction}`]: props.direction,
[`nut-checkboxgroup-${direction}`]: direction,
[`nut-checkboxgroup-list`]: list,
},
className
Expand All @@ -151,5 +151,4 @@ export const CheckboxGroup = React.forwardRef(
}
)

CheckboxGroup.defaultProps = defaultProps
CheckboxGroup.displayName = 'NutCheckboxGroup'
11 changes: 5 additions & 6 deletions src/packages/checkboxgroup/checkboxgroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ export const CheckboxGroup = React.forwardRef(
className,
disabled,
list,
onChange,
value,
defaultValue,
max,
min,
onLimit,
labelPosition,
direction,
options,
onChange,
onLimit,
...rest
} = { ...defaultProps, ...props }

Expand Down Expand Up @@ -86,8 +86,8 @@ export const CheckboxGroup = React.forwardRef(
}))

const [_value, setValue] = usePropsValue<string[]>({
value: props.value,
defaultValue: props.defaultValue,
value,
defaultValue,
finalValue: [] as string[],
onChange,
})
Expand Down Expand Up @@ -137,7 +137,7 @@ export const CheckboxGroup = React.forwardRef(
className={classNames(
classPrefix,
{
[`nut-checkboxgroup-${props.direction}`]: props.direction,
[`nut-checkboxgroup-${direction}`]: direction,
[`nut-checkboxgroup-list`]: list,
},
className
Expand All @@ -151,5 +151,4 @@ export const CheckboxGroup = React.forwardRef(
}
)

CheckboxGroup.defaultProps = defaultProps
CheckboxGroup.displayName = 'NutCheckboxGroup'
24 changes: 11 additions & 13 deletions src/packages/datepicker/datepicker.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,15 @@ export const DatePicker: FunctionComponent<
if (!isEqual) {
setSelectedDate(formatValue(newDate as Date))
}
props.onChange &&
props.onChange(
selectedOptions,
[
String(newDate.getFullYear()),
String(newDate.getMonth() + 1),
String(newDate.getDate()),
],
index
)
onChange?.(
selectedOptions,
[
String(newDate.getFullYear()),
String(newDate.getMonth() + 1),
String(newDate.getDate()),
],
index
)
}
}
const handlePickerChange = (
Expand Down Expand Up @@ -350,8 +349,8 @@ export const DatePicker: FunctionComponent<
pickerValue[columnIndex] = arr[index]?.value
setPickerValue([...pickerValue])

if (props.filter && props.filter(type, arr)) {
return props.filter(type, arr)
if (filter?.(type, arr)) {
return filter?.(type, arr)
}
return arr
}
Expand Down Expand Up @@ -428,5 +427,4 @@ export const DatePicker: FunctionComponent<
)
}

DatePicker.defaultProps = defaultProps
DatePicker.displayName = 'NutDatePicker'
24 changes: 11 additions & 13 deletions src/packages/datepicker/datepicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,15 @@ export const DatePicker: FunctionComponent<
if (!isEqual) {
setSelectedDate(formatValue(newDate as Date))
}
props.onChange &&
props.onChange(
selectedOptions,
[
String(newDate.getFullYear()),
String(newDate.getMonth() + 1),
String(newDate.getDate()),
],
index
)
onChange?.(
selectedOptions,
[
String(newDate.getFullYear()),
String(newDate.getMonth() + 1),
String(newDate.getDate()),
],
index
)
}
}
const handlePickerChange = (
Expand Down Expand Up @@ -350,8 +349,8 @@ export const DatePicker: FunctionComponent<
pickerValue[columnIndex] = arr[index]?.value
setPickerValue([...pickerValue])

if (props.filter && props.filter(type, arr)) {
return props.filter(type, arr)
if (filter?.(type, arr)) {
return filter?.(type, arr)
}
return arr
}
Expand Down Expand Up @@ -423,5 +422,4 @@ export const DatePicker: FunctionComponent<
)
}

DatePicker.defaultProps = defaultProps
DatePicker.displayName = 'NutDatePicker'
2 changes: 1 addition & 1 deletion src/packages/dialog/dialog.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export function close(selector: string) {
customEvents.trigger(path, { status: false })
}

BaseDialog.defaultProps = defaultProps
BaseDialog.defaultProps = defaultProps // 不可删除
BaseDialog.displayName = 'NutDialog'
BaseDialog.open = open
BaseDialog.close = close
2 changes: 1 addition & 1 deletion src/packages/dialog/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,5 @@ Dialog.confirm = (props: DialogConfirmProps): DialogReturnProps => {
}
})

Dialog.defaultProps = defaultProps
Dialog.defaultProps = defaultProps // 不可删除
Dialog.displayName = 'NutDialog'
1 change: 0 additions & 1 deletion src/packages/dialog/dialogwrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,4 @@ export const DialogWrap: FunctionComponent<
)
}

DialogWrap.defaultProps = defaultDialogProps
DialogWrap.displayName = 'NutDialogWrap'
2 changes: 1 addition & 1 deletion src/packages/notify/notify.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export function close(selector: string) {
customEvents.trigger(path, false)
}

Notify.defaultProps = defaultProps
Notify.defaultProps = defaultProps // 不可删除
Notify.displayName = 'NutNotify'
Notify.open = open
Notify.close = close
1 change: 0 additions & 1 deletion src/packages/pulltorefresh/pulltorefresh.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,4 @@ export const PullToRefresh: FunctionComponent<Partial<PullToRefreshProps>> = (
)
}

PullToRefresh.defaultProps = defaultProps
PullToRefresh.displayName = 'NutPullToRefresh'
1 change: 0 additions & 1 deletion src/packages/pulltorefresh/pulltorefresh.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,5 +226,4 @@ export const PullToRefresh: FunctionComponent<Partial<PullToRefreshProps>> = (
)
}

PullToRefresh.defaultProps = defaultProps
PullToRefresh.displayName = 'NutPullToRefresh'
1 change: 0 additions & 1 deletion src/packages/radio/radio.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,5 @@ export const Radio: FunctionComponent<
)
}

Radio.defaultProps = defaultProps
Radio.displayName = 'NutRadio'
Radio.Group = RadioGroup
1 change: 0 additions & 1 deletion src/packages/radio/radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,5 @@ export const Radio: FunctionComponent<
)
}

Radio.defaultProps = defaultProps
Radio.displayName = 'NutRadio'
Radio.Group = RadioGroup
1 change: 0 additions & 1 deletion src/packages/radiogroup/radiogroup.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,4 @@ export const RadioGroup = React.forwardRef(
}
)

RadioGroup.defaultProps = defaultProps
RadioGroup.displayName = 'NutRadioGroup'
1 change: 0 additions & 1 deletion src/packages/radiogroup/radiogroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,4 @@ export const RadioGroup = React.forwardRef(
}
)

RadioGroup.defaultProps = defaultProps
RadioGroup.displayName = 'NutRadioGroup'
Loading