From d4c00495db5d077c90e8bee265ec0826facf08b8 Mon Sep 17 00:00:00 2001 From: Eiinu Date: Thu, 16 May 2024 10:22:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4=20defaultProps(2)=20(?= =?UTF-8?q?#2254)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 移除 defaultProps * fix: remove defaultProps --- scripts/demo.js | 1 - src/packages/actionsheet/actionsheet.taro.tsx | 1 - src/packages/actionsheet/actionsheet.tsx | 1 - src/packages/address/address.taro.tsx | 1 - src/packages/address/address.tsx | 1 - src/packages/animate/animate.taro.tsx | 1 - src/packages/animate/animate.tsx | 1 - src/packages/avatar/avatar.taro.tsx | 5 ++--- src/packages/avatar/avatar.tsx | 5 ++--- src/packages/avatarcropper/avatarcropper.taro.tsx | 1 - src/packages/avatarcropper/avatarcropper.tsx | 1 - src/packages/avatargroup/avatargroup.taro.tsx | 1 - src/packages/avatargroup/avatargroup.tsx | 1 - src/packages/badge/badge.taro.tsx | 1 - src/packages/badge/badge.tsx | 1 - src/packages/barrage/barrage.taro.tsx | 1 - src/packages/barrage/barrage.tsx | 1 - src/packages/calendar/calendar.taro.tsx | 1 - src/packages/calendar/calendar.tsx | 1 - src/packages/calendarcard/calendarcard.taro.tsx | 1 - src/packages/calendarcard/calendarcard.tsx | 1 - src/packages/calendaritem/calendaritem.taro.tsx | 6 +++--- src/packages/calendaritem/calendaritem.tsx | 6 +++--- src/packages/card/card.taro.tsx | 1 - src/packages/card/card.tsx | 1 - src/packages/cascader/cascader.taro.tsx | 9 +++++---- src/packages/cascader/cascader.tsx | 9 +++++---- src/packages/checkbox/checkbox.taro.tsx | 5 ++--- src/packages/checkbox/checkbox.tsx | 5 ++--- .../circleprogress/circleprogress.taro.tsx | 14 ++++++-------- src/packages/circleprogress/circleprogress.tsx | 4 +--- src/packages/collapse/collapse.taro.tsx | 1 - src/packages/collapse/collapse.tsx | 1 - src/packages/collapseitem/collapseitem.taro.tsx | 1 - src/packages/collapseitem/collapseitem.tsx | 1 - src/packages/countdown/countdown.taro.tsx | 1 - src/packages/countdown/countdown.tsx | 1 - src/packages/drag/drag.taro.tsx | 9 ++++----- src/packages/drag/drag.tsx | 3 +-- src/packages/ellipsis/ellipsis.taro.tsx | 1 - src/packages/ellipsis/ellipsis.tsx | 1 - src/packages/empty/empty.taro.tsx | 1 - src/packages/empty/empty.tsx | 1 - src/packages/form/form.taro.tsx | 1 - src/packages/form/form.tsx | 1 - src/packages/imagepreview/imagepreview.taro.tsx | 11 ++++++----- src/packages/imagepreview/imagepreview.tsx | 11 ++++++----- src/packages/indicator/indicator.taro.tsx | 1 - src/packages/indicator/indicator.tsx | 1 - .../infiniteloading/infiniteloading.taro.tsx | 1 - src/packages/infiniteloading/infiniteloading.tsx | 1 - src/packages/input/input.taro.tsx | 5 ++--- src/packages/input/input.tsx | 11 ++++++----- src/packages/inputnumber/inputnumber.taro.tsx | 1 - src/packages/inputnumber/inputnumber.tsx | 1 - src/packages/layout/layout.taro.tsx | 1 - src/packages/layout/layout.tsx | 1 - src/packages/loading/loading.taro.tsx | 1 - src/packages/loading/loading.tsx | 1 - src/packages/menu/menu.taro.tsx | 1 - src/packages/menu/menu.tsx | 1 - src/packages/menuitem/menuitem.taro.tsx | 1 - src/packages/menuitem/menuitem.tsx | 1 - src/packages/noticebar/noticebar.taro.tsx | 1 - src/packages/noticebar/noticebar.tsx | 1 - .../numberkeyboard/numberkeyboard.taro.tsx | 1 - src/packages/numberkeyboard/numberkeyboard.tsx | 1 - src/packages/pagination/pagination.taro.tsx | 1 - src/packages/pagination/pagination.tsx | 1 - src/packages/popover/popover.taro.tsx | 7 +++---- src/packages/popover/popover.tsx | 9 ++++----- src/packages/popup/popup.taro.tsx | 1 - src/packages/popup/popup.tsx | 1 - src/packages/price/price.taro.tsx | 1 - src/packages/price/price.tsx | 1 - src/packages/progress/progress.taro.tsx | 1 - src/packages/progress/progress.tsx | 1 - src/packages/range/range.taro.tsx | 1 - src/packages/range/range.tsx | 1 - src/packages/rate/rate.taro.tsx | 1 - src/packages/rate/rate.tsx | 1 - src/packages/searchbar/searchbar.taro.tsx | 14 ++++++++------ src/packages/searchbar/searchbar.tsx | 14 ++++++++------ src/packages/shortpassword/shortpassword.taro.tsx | 4 ++-- src/packages/shortpassword/shortpassword.tsx | 4 ++-- src/packages/signature/signature.taro.tsx | 3 +-- src/packages/signature/signature.tsx | 1 - src/packages/skeleton/skeleton.taro.tsx | 1 - src/packages/skeleton/skeleton.tsx | 1 - src/packages/step/step.taro.tsx | 1 - src/packages/step/step.tsx | 1 - src/packages/steps/steps.taro.tsx | 3 +-- src/packages/steps/steps.tsx | 3 +-- src/packages/switch/switch.taro.tsx | 1 - src/packages/switch/switch.tsx | 1 - src/packages/table/table.taro.tsx | 3 +-- src/packages/table/table.tsx | 3 +-- src/packages/tag/tag.taro.tsx | 1 - src/packages/tag/tag.tsx | 1 - src/packages/textarea/textarea.taro.tsx | 1 - src/packages/textarea/textarea.tsx | 1 - src/packages/timedetail/timedetail.taro.tsx | 1 - src/packages/timedetail/timedetail.tsx | 1 - src/packages/timeselect/timeselect.taro.tsx | 1 - src/packages/timeselect/timeselect.tsx | 1 - src/packages/tour/tour.taro.tsx | 1 - src/packages/tour/tour.tsx | 1 - src/packages/trendarrow/trendarrow.taro.tsx | 1 - src/packages/trendarrow/trendarrow.tsx | 1 - src/packages/uploader/uploader.taro.tsx | 7 +++---- src/packages/uploader/uploader.tsx | 5 ++--- src/packages/video/video.taro.tsx | 1 - src/packages/video/video.tsx | 1 - src/packages/virtuallist/virtuallist.taro.tsx | 1 - src/packages/virtuallist/virtuallist.tsx | 1 - src/packages/watermark/watermark.taro.tsx | 1 - src/packages/watermark/watermark.tsx | 1 - 117 files changed, 93 insertions(+), 192 deletions(-) diff --git a/scripts/demo.js b/scripts/demo.js index 145b52ed2b..71f79c7909 100644 --- a/scripts/demo.js +++ b/scripts/demo.js @@ -56,7 +56,6 @@ export const ${name}: FunctionComponent & React.HTMLAttrib return
${name}
} -${name}.defaultProps = defaultProps ${name}.displayName = 'Nut${name}' `, doc: `# ${name}组件 diff --git a/src/packages/actionsheet/actionsheet.taro.tsx b/src/packages/actionsheet/actionsheet.taro.tsx index 569b4c29c1..73bdf83a3a 100644 --- a/src/packages/actionsheet/actionsheet.taro.tsx +++ b/src/packages/actionsheet/actionsheet.taro.tsx @@ -106,5 +106,4 @@ export const ActionSheet: FunctionComponent< ) } -ActionSheet.defaultProps = defaultProps ActionSheet.displayName = 'NutActionSheet' diff --git a/src/packages/actionsheet/actionsheet.tsx b/src/packages/actionsheet/actionsheet.tsx index 005b171af5..27d0561bc5 100644 --- a/src/packages/actionsheet/actionsheet.tsx +++ b/src/packages/actionsheet/actionsheet.tsx @@ -106,5 +106,4 @@ export const ActionSheet: FunctionComponent< ) } -ActionSheet.defaultProps = defaultProps ActionSheet.displayName = 'NutActionSheet' diff --git a/src/packages/address/address.taro.tsx b/src/packages/address/address.taro.tsx index 52b4c862b4..146bb660d9 100644 --- a/src/packages/address/address.taro.tsx +++ b/src/packages/address/address.taro.tsx @@ -206,5 +206,4 @@ const InternalAddress: ForwardRefRenderFunction< export const Address = forwardRef(InternalAddress) -Address.defaultProps = defaultProps Address.displayName = 'NutAddress' diff --git a/src/packages/address/address.tsx b/src/packages/address/address.tsx index ca0a3a0ddc..fc810fa05f 100644 --- a/src/packages/address/address.tsx +++ b/src/packages/address/address.tsx @@ -206,5 +206,4 @@ export const InternalAddress: ForwardRefRenderFunction< export const Address = forwardRef(InternalAddress) -Address.defaultProps = defaultProps Address.displayName = 'NutAddress' diff --git a/src/packages/animate/animate.taro.tsx b/src/packages/animate/animate.taro.tsx index 4065743457..401934c35a 100644 --- a/src/packages/animate/animate.taro.tsx +++ b/src/packages/animate/animate.taro.tsx @@ -56,5 +56,4 @@ export const Animate: FunctionComponent< ) } -Animate.defaultProps = defaultProps Animate.displayName = 'NutAnimate' diff --git a/src/packages/animate/animate.tsx b/src/packages/animate/animate.tsx index 4065743457..401934c35a 100644 --- a/src/packages/animate/animate.tsx +++ b/src/packages/animate/animate.tsx @@ -56,5 +56,4 @@ export const Animate: FunctionComponent< ) } -Animate.defaultProps = defaultProps Animate.displayName = 'NutAnimate' diff --git a/src/packages/avatar/avatar.taro.tsx b/src/packages/avatar/avatar.taro.tsx index a1d606b35b..a0ce6e2546 100644 --- a/src/packages/avatar/avatar.taro.tsx +++ b/src/packages/avatar/avatar.taro.tsx @@ -144,8 +144,8 @@ export const Avatar: FunctionComponent< } const errorEvent = () => { - if (props.onError) { - props.onError() + if (onError) { + onError() } } @@ -202,6 +202,5 @@ export const Avatar: FunctionComponent< ) } -Avatar.defaultProps = defaultProps Avatar.displayName = 'NutAvatar' Avatar.Group = AvatarGroup diff --git a/src/packages/avatar/avatar.tsx b/src/packages/avatar/avatar.tsx index 00dfc57d7f..c20bf285e8 100644 --- a/src/packages/avatar/avatar.tsx +++ b/src/packages/avatar/avatar.tsx @@ -129,8 +129,8 @@ export const Avatar: FunctionComponent< } const errorEvent = () => { - if (props.onError) { - props.onError() + if (onError) { + onError() } } @@ -188,6 +188,5 @@ export const Avatar: FunctionComponent< ) } -Avatar.defaultProps = defaultProps Avatar.displayName = 'NutAvatar' Avatar.Group = AvatarGroup diff --git a/src/packages/avatarcropper/avatarcropper.taro.tsx b/src/packages/avatarcropper/avatarcropper.taro.tsx index a5bad569ab..7730883a33 100644 --- a/src/packages/avatarcropper/avatarcropper.taro.tsx +++ b/src/packages/avatarcropper/avatarcropper.taro.tsx @@ -719,5 +719,4 @@ export const AvatarCropper: FunctionComponent> = ( ) } -AvatarCropper.defaultProps = defaultProps AvatarCropper.displayName = 'NutAvatarCropper' diff --git a/src/packages/avatarcropper/avatarcropper.tsx b/src/packages/avatarcropper/avatarcropper.tsx index 6ca2af7c8c..e7db92f32c 100644 --- a/src/packages/avatarcropper/avatarcropper.tsx +++ b/src/packages/avatarcropper/avatarcropper.tsx @@ -483,5 +483,4 @@ export const AvatarCropper: FunctionComponent> = ( ) } -AvatarCropper.defaultProps = defaultProps AvatarCropper.displayName = 'NutAvatarCropper' diff --git a/src/packages/avatargroup/avatargroup.taro.tsx b/src/packages/avatargroup/avatargroup.taro.tsx index 58cc47eba5..d922a0a06b 100644 --- a/src/packages/avatargroup/avatargroup.taro.tsx +++ b/src/packages/avatargroup/avatargroup.taro.tsx @@ -47,5 +47,4 @@ export const AvatarGroup: FunctionComponent< ) } -AvatarGroup.defaultProps = defaultProps AvatarGroup.displayName = 'NutAvatarGroup' diff --git a/src/packages/avatargroup/avatargroup.tsx b/src/packages/avatargroup/avatargroup.tsx index 58cc47eba5..d922a0a06b 100644 --- a/src/packages/avatargroup/avatargroup.tsx +++ b/src/packages/avatargroup/avatargroup.tsx @@ -47,5 +47,4 @@ export const AvatarGroup: FunctionComponent< ) } -AvatarGroup.defaultProps = defaultProps AvatarGroup.displayName = 'NutAvatarGroup' diff --git a/src/packages/badge/badge.taro.tsx b/src/packages/badge/badge.taro.tsx index a0bf0c2cb7..17a35b9ae3 100644 --- a/src/packages/badge/badge.taro.tsx +++ b/src/packages/badge/badge.taro.tsx @@ -107,5 +107,4 @@ export const Badge: FunctionComponent> = (props) => { ) } -Badge.defaultProps = defaultProps Badge.displayName = 'NutBadge' diff --git a/src/packages/badge/badge.tsx b/src/packages/badge/badge.tsx index be30f25a39..5cb4acf0ae 100644 --- a/src/packages/badge/badge.tsx +++ b/src/packages/badge/badge.tsx @@ -108,5 +108,4 @@ export const Badge: FunctionComponent> = (props) => { ) } -Badge.defaultProps = defaultProps Badge.displayName = 'NutBadge' diff --git a/src/packages/barrage/barrage.taro.tsx b/src/packages/barrage/barrage.taro.tsx index c541c3af2a..ed4ceb9b73 100644 --- a/src/packages/barrage/barrage.taro.tsx +++ b/src/packages/barrage/barrage.taro.tsx @@ -165,5 +165,4 @@ export const Barrage = React.forwardRef>( InternalBarrage ) -Barrage.defaultProps = defaultProps Barrage.displayName = 'NutBarrage' diff --git a/src/packages/barrage/barrage.tsx b/src/packages/barrage/barrage.tsx index 53fc07b59e..a565719174 100644 --- a/src/packages/barrage/barrage.tsx +++ b/src/packages/barrage/barrage.tsx @@ -147,5 +147,4 @@ export const Barrage = React.forwardRef>( InternalBarrage ) -Barrage.defaultProps = defaultProps Barrage.displayName = 'NutBarrage' diff --git a/src/packages/calendar/calendar.taro.tsx b/src/packages/calendar/calendar.taro.tsx index f4fd74bd35..5e38fbc5d7 100644 --- a/src/packages/calendar/calendar.taro.tsx +++ b/src/packages/calendar/calendar.taro.tsx @@ -186,5 +186,4 @@ export const Calendar = React.forwardRef< ) }) -Calendar.defaultProps = defaultProps Calendar.displayName = 'NutCalendar' diff --git a/src/packages/calendar/calendar.tsx b/src/packages/calendar/calendar.tsx index f17ed9ad5c..57a9330f36 100644 --- a/src/packages/calendar/calendar.tsx +++ b/src/packages/calendar/calendar.tsx @@ -186,5 +186,4 @@ export const Calendar = React.forwardRef< ) }) -Calendar.defaultProps = defaultProps Calendar.displayName = 'NutCalendar' diff --git a/src/packages/calendarcard/calendarcard.taro.tsx b/src/packages/calendarcard/calendarcard.taro.tsx index e5a3bc6aee..9322b25d3e 100644 --- a/src/packages/calendarcard/calendarcard.taro.tsx +++ b/src/packages/calendarcard/calendarcard.taro.tsx @@ -468,5 +468,4 @@ export const CalendarCard = React.forwardRef< ) : null }) -CalendarCard.defaultProps = defaultProps as CalendarCardProps CalendarCard.displayName = 'NutCalendarCard' diff --git a/src/packages/calendarcard/calendarcard.tsx b/src/packages/calendarcard/calendarcard.tsx index c8d78ea0e6..2afcb0cc8b 100644 --- a/src/packages/calendarcard/calendarcard.tsx +++ b/src/packages/calendarcard/calendarcard.tsx @@ -468,5 +468,4 @@ export const CalendarCard = React.forwardRef< ) : null }) -CalendarCard.defaultProps = defaultProps as CalendarCardProps CalendarCard.displayName = 'NutCalendarCard' diff --git a/src/packages/calendaritem/calendaritem.taro.tsx b/src/packages/calendaritem/calendaritem.taro.tsx index da42eb52f7..1339d90858 100644 --- a/src/packages/calendaritem/calendaritem.taro.tsx +++ b/src/packages/calendaritem/calendaritem.taro.tsx @@ -121,6 +121,7 @@ export const CalendarItem = React.forwardRef< renderDay, renderDayTop, renderDayBottom, + value, onConfirm, onUpdate, onDayClick, @@ -172,7 +173,7 @@ export const CalendarItem = React.forwardRef< } const [currentDate, setCurrentDate] = usePropsValue({ - value: props.value, + value, defaultValue: resetDefaultValue(), finalValue: [], onChange: (val) => {}, @@ -412,7 +413,7 @@ export const CalendarItem = React.forwardRef< monthsData[current.lastCurrent], true ) - } else if (props.type === 'week') { + } else if (type === 'week') { chooseDay( { day: defaultData[2], type: 'curr' }, monthsData[current.current], @@ -890,5 +891,4 @@ export const CalendarItem = React.forwardRef< ) }) -CalendarItem.defaultProps = defaultProps CalendarItem.displayName = 'NutCalendarItem' diff --git a/src/packages/calendaritem/calendaritem.tsx b/src/packages/calendaritem/calendaritem.tsx index a1f322f2b1..0ed672985e 100644 --- a/src/packages/calendaritem/calendaritem.tsx +++ b/src/packages/calendaritem/calendaritem.tsx @@ -119,6 +119,7 @@ export const CalendarItem = React.forwardRef< renderDay, renderDayTop, renderDayBottom, + value, onConfirm, onUpdate, onDayClick, @@ -170,7 +171,7 @@ export const CalendarItem = React.forwardRef< } const [currentDate, setCurrentDate] = usePropsValue({ - value: props.value, + value, defaultValue: resetDefaultValue(), finalValue: [], onChange: (val) => {}, @@ -412,7 +413,7 @@ export const CalendarItem = React.forwardRef< monthsData[current.lastCurrent], true ) - } else if (props.type === 'week') { + } else if (type === 'week') { chooseDay( { day: defaultData[2], type: 'curr' }, monthsData[current.current], @@ -888,5 +889,4 @@ export const CalendarItem = React.forwardRef< ) }) -CalendarItem.defaultProps = defaultProps CalendarItem.displayName = 'NutCalendarItem' diff --git a/src/packages/card/card.taro.tsx b/src/packages/card/card.taro.tsx index ac4e4736ad..51d94d10a1 100644 --- a/src/packages/card/card.taro.tsx +++ b/src/packages/card/card.taro.tsx @@ -89,5 +89,4 @@ export const Card: FunctionComponent< ) } -Card.defaultProps = defaultProps Card.displayName = 'NutCard' diff --git a/src/packages/card/card.tsx b/src/packages/card/card.tsx index 8c42905c8e..0b9b32ca94 100644 --- a/src/packages/card/card.tsx +++ b/src/packages/card/card.tsx @@ -89,5 +89,4 @@ export const Card: FunctionComponent< ) } -Card.defaultProps = defaultProps Card.displayName = 'NutCard' diff --git a/src/packages/cascader/cascader.taro.tsx b/src/packages/cascader/cascader.taro.tsx index babba6dc85..e5bf5ed0e6 100644 --- a/src/packages/cascader/cascader.taro.tsx +++ b/src/packages/cascader/cascader.taro.tsx @@ -108,6 +108,8 @@ const InternalCascader: ForwardRefRenderFunction< closeIconPosition, closeIcon, lazy, + title, + left, onLoad, onClose, onChange, @@ -124,7 +126,7 @@ const InternalCascader: ForwardRefRenderFunction< finalValue: defaultValue, }) const [innerVisible, setInnerVisible] = usePropsValue({ - value: props.visible, + value: visible, defaultValue: undefined, finalValue: false, }) @@ -481,8 +483,8 @@ const InternalCascader: ForwardRefRenderFunction< closeIcon={closeIcon} closeable={closeable} closeIconPosition={closeIconPosition} - title={popup && (props.title as ReactNode)} - left={props.left} + title={popup && (title as ReactNode)} + left={left} // todo 只关闭,不处理逻辑。和popup的逻辑不一致。关闭时需要增加是否要处理回调 onOverlayClick={closePopup} onCloseIconClick={closePopup} @@ -498,5 +500,4 @@ const InternalCascader: ForwardRefRenderFunction< export const Cascader = React.forwardRef(InternalCascader) -Cascader.defaultProps = defaultProps Cascader.displayName = 'NutCascader' diff --git a/src/packages/cascader/cascader.tsx b/src/packages/cascader/cascader.tsx index 3d3196ee81..6ada53b1d5 100644 --- a/src/packages/cascader/cascader.tsx +++ b/src/packages/cascader/cascader.tsx @@ -107,6 +107,8 @@ const InternalCascader: ForwardRefRenderFunction< closeIconPosition, closeIcon, lazy, + title, + left, onLoad, onClose, onChange, @@ -123,7 +125,7 @@ const InternalCascader: ForwardRefRenderFunction< finalValue: defaultValue, }) const [innerVisible, setInnerVisible] = usePropsValue({ - value: props.visible, + value: visible, defaultValue: undefined, finalValue: false, }) @@ -479,8 +481,8 @@ const InternalCascader: ForwardRefRenderFunction< closeIcon={closeIcon} closeable={closeable} closeIconPosition={closeIconPosition} - title={popup && (props.title as ReactNode)} - left={props.left} + title={popup && (title as ReactNode)} + left={left} // todo 只关闭,不处理逻辑。和popup的逻辑不一致。关闭时需要增加是否要处理回调 onOverlayClick={closePopup} onCloseIconClick={closePopup} @@ -496,5 +498,4 @@ const InternalCascader: ForwardRefRenderFunction< export const Cascader = React.forwardRef(InternalCascader) -Cascader.defaultProps = defaultProps Cascader.displayName = 'NutCascader' diff --git a/src/packages/checkbox/checkbox.taro.tsx b/src/packages/checkbox/checkbox.taro.tsx index 3e1c55e176..acd6b2251a 100644 --- a/src/packages/checkbox/checkbox.taro.tsx +++ b/src/packages/checkbox/checkbox.taro.tsx @@ -71,8 +71,8 @@ export const Checkbox: FunctionComponent< const ctx = useContext(Context) let [innerChecked, setChecked] = usePropsValue({ - value: props.checked, - defaultValue: props.defaultChecked, + value: checked, + defaultValue: defaultChecked, finalValue: defaultChecked, onChange, }) @@ -230,6 +230,5 @@ export const Checkbox: FunctionComponent< ) } -Checkbox.defaultProps = defaultProps Checkbox.displayName = 'NutCheckBox' Checkbox.Group = CheckboxGroup diff --git a/src/packages/checkbox/checkbox.tsx b/src/packages/checkbox/checkbox.tsx index 7f6ba0ac7c..df7833a9a6 100644 --- a/src/packages/checkbox/checkbox.tsx +++ b/src/packages/checkbox/checkbox.tsx @@ -70,8 +70,8 @@ export const Checkbox: FunctionComponent< const ctx = useContext(Context) let [innerChecked, setChecked] = usePropsValue({ - value: props.checked, - defaultValue: props.defaultChecked, + value: checked, + defaultValue: defaultChecked, finalValue: defaultChecked, onChange, }) @@ -229,6 +229,5 @@ export const Checkbox: FunctionComponent< ) } -Checkbox.defaultProps = defaultProps Checkbox.displayName = 'NutCheckBox' Checkbox.Group = CheckboxGroup diff --git a/src/packages/circleprogress/circleprogress.taro.tsx b/src/packages/circleprogress/circleprogress.taro.tsx index e1e504e8ca..148f616a59 100644 --- a/src/packages/circleprogress/circleprogress.taro.tsx +++ b/src/packages/circleprogress/circleprogress.taro.tsx @@ -84,10 +84,9 @@ export const CircleProgress: FunctionComponent< }, [percent]) const stop = () => { - if (!isObject(props.color)) { + if (!isObject(color)) { return [] } - const color = props.color as Color const colorArr = Object.keys(color).sort( (a, b) => parseFloat(a) - parseFloat(b) ) @@ -126,17 +125,17 @@ export const CircleProgress: FunctionComponent< const progress = +oldValue.current const offset = (perimeter * Number(format(parseFloat(progress.toFixed(1))))) / 100 - const isWise = props.clockwise ? 1 : 0 - const color = isObject(props.color) + const isWise = clockwise ? 1 : 0 + const realColor = isObject(color) ? `url(%23${refRandomId})` - : transColor(props.color) + : transColor(color) const d = `M 50 50 m 0 -45 a 45 45 0 1 ${isWise} 0 90 a 45 45 0 1, ${isWise} 0 -90` const pa = `%3Cdefs%3E%3ClinearGradient id='${refRandomId}' x1='100%25' y1='0%25' x2='0%25' y2='0%25'%3E${stopDom}%3C/linearGradient%3E%3C/defs%3E` const path = `%3Cpath d='${d}' stroke-width='${strokeWidth}' stroke='${transColor( - props.background + background )}' fill='none'/%3E` const path1 = `%3Cpath d='${d}' stroke-width='${strokeWidth}' stroke-dasharray='${offset},${perimeter}' stroke-linecap='round' stroke='${transColor( - color + realColor )}' fill='none'/%3E` return { background: `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E${pa}${path}${path1}%3C/svg%3E")`, @@ -153,5 +152,4 @@ export const CircleProgress: FunctionComponent< ) } -CircleProgress.defaultProps = defaultProps CircleProgress.displayName = 'NutCircleProgress' diff --git a/src/packages/circleprogress/circleprogress.tsx b/src/packages/circleprogress/circleprogress.tsx index 873b2b870d..1deea405ae 100644 --- a/src/packages/circleprogress/circleprogress.tsx +++ b/src/packages/circleprogress/circleprogress.tsx @@ -75,10 +75,9 @@ export const CircleProgress: FunctionComponent< } const stop = () => { - if (!isObject(props.color)) { + if (!isObject(color)) { return } - const color = props.color as Color const colorArr = Object.keys(color).sort( (a, b) => parseFloat(a) - parseFloat(b) ) @@ -129,5 +128,4 @@ export const CircleProgress: FunctionComponent< ) } -CircleProgress.defaultProps = defaultProps CircleProgress.displayName = 'NutCircleProgress' diff --git a/src/packages/collapse/collapse.taro.tsx b/src/packages/collapse/collapse.taro.tsx index e5f36ba07a..791ce9db71 100644 --- a/src/packages/collapse/collapse.taro.tsx +++ b/src/packages/collapse/collapse.taro.tsx @@ -110,6 +110,5 @@ export const Collapse: FunctionComponent> & { ) } -Collapse.defaultProps = defaultProps Collapse.displayName = 'NutCollapse' Collapse.Item = CollapseItem diff --git a/src/packages/collapse/collapse.tsx b/src/packages/collapse/collapse.tsx index a4a5515052..95ef0c0dfa 100644 --- a/src/packages/collapse/collapse.tsx +++ b/src/packages/collapse/collapse.tsx @@ -110,6 +110,5 @@ export const Collapse: FunctionComponent> & { ) } -Collapse.defaultProps = defaultProps Collapse.displayName = 'NutCollapse' Collapse.Item = CollapseItem diff --git a/src/packages/collapseitem/collapseitem.taro.tsx b/src/packages/collapseitem/collapseitem.taro.tsx index 5152c81545..fd9af4ec9c 100644 --- a/src/packages/collapseitem/collapseitem.taro.tsx +++ b/src/packages/collapseitem/collapseitem.taro.tsx @@ -180,5 +180,4 @@ export const CollapseItem: FunctionComponent< ) } -CollapseItem.defaultProps = defaultProps CollapseItem.displayName = 'NutCollapseItem' diff --git a/src/packages/collapseitem/collapseitem.tsx b/src/packages/collapseitem/collapseitem.tsx index 5153aac4bb..386af9a854 100644 --- a/src/packages/collapseitem/collapseitem.tsx +++ b/src/packages/collapseitem/collapseitem.tsx @@ -139,5 +139,4 @@ export const CollapseItem: FunctionComponent< ) } -CollapseItem.defaultProps = defaultProps CollapseItem.displayName = 'NutCollapseItem' diff --git a/src/packages/countdown/countdown.taro.tsx b/src/packages/countdown/countdown.taro.tsx index 2f50f32991..0704ab9fb0 100644 --- a/src/packages/countdown/countdown.taro.tsx +++ b/src/packages/countdown/countdown.taro.tsx @@ -305,5 +305,4 @@ export const CountDown = React.forwardRef>( InternalCountDown ) -CountDown.defaultProps = defaultProps CountDown.displayName = 'NutCountDown' diff --git a/src/packages/countdown/countdown.tsx b/src/packages/countdown/countdown.tsx index 7006eca97c..c9a4184fa0 100644 --- a/src/packages/countdown/countdown.tsx +++ b/src/packages/countdown/countdown.tsx @@ -306,5 +306,4 @@ export const CountDown = React.forwardRef>( InternalCountDown ) -CountDown.defaultProps = defaultProps CountDown.displayName = 'NutCountDown' diff --git a/src/packages/drag/drag.taro.tsx b/src/packages/drag/drag.taro.tsx index 669eefdc23..2242714b11 100644 --- a/src/packages/drag/drag.taro.tsx +++ b/src/packages/drag/drag.taro.tsx @@ -96,22 +96,22 @@ export const Drag: FunctionComponent< } const transform = `translate3d(${ - props.direction !== 'y' ? translateX.current : 0 - }px, ${props.direction !== 'x' ? translateY.current : 0}px, 0px)` + direction !== 'y' ? translateX.current : 0 + }px, ${direction !== 'x' ? translateY.current : 0}px, 0px)` setCurrStyle({ transform }) } } const touchEnd = (e: React.TouchEvent) => { - if (props.direction !== 'y' && props.attract && dragRef.current) { + if (direction !== 'y' && attract && dragRef.current) { if (translateX.current < middleLine.current) { translateX.current = boundaryState.left } else { translateX.current = boundaryState.right } const transform = `translate3d(${translateX.current}px, ${ - props.direction !== 'x' ? translateY.current : 0 + direction !== 'x' ? translateY.current : 0 }px, 0px)` setCurrStyle({ transform }) } @@ -148,5 +148,4 @@ export const Drag: FunctionComponent< ) } -Drag.defaultProps = defaultProps Drag.displayName = 'NutDrag' diff --git a/src/packages/drag/drag.tsx b/src/packages/drag/drag.tsx index a7e9eb848a..fc2155fa49 100644 --- a/src/packages/drag/drag.tsx +++ b/src/packages/drag/drag.tsx @@ -63,7 +63,7 @@ export const Drag: FunctionComponent< ({ down, last, offset: [x, y] }) => { api.start({ x, y, immediate: down }) if (last) { - if (props.direction !== 'y' && props.attract) { + if (direction !== 'y' && attract) { if (x < middleLine.current) { api.start({ x: boundaryState.left, y, immediate: down }) } else { @@ -101,5 +101,4 @@ export const Drag: FunctionComponent< ) } -Drag.defaultProps = defaultProps Drag.displayName = 'NutDrag' diff --git a/src/packages/ellipsis/ellipsis.taro.tsx b/src/packages/ellipsis/ellipsis.taro.tsx index cb0f741631..1cc6217f40 100644 --- a/src/packages/ellipsis/ellipsis.taro.tsx +++ b/src/packages/ellipsis/ellipsis.taro.tsx @@ -403,5 +403,4 @@ export const Ellipsis: FunctionComponent< ) } -Ellipsis.defaultProps = defaultProps Ellipsis.displayName = 'NutEllipsis' diff --git a/src/packages/ellipsis/ellipsis.tsx b/src/packages/ellipsis/ellipsis.tsx index ea50f220ca..c5c118a85f 100644 --- a/src/packages/ellipsis/ellipsis.tsx +++ b/src/packages/ellipsis/ellipsis.tsx @@ -253,5 +253,4 @@ export const Ellipsis: FunctionComponent< ) } -Ellipsis.defaultProps = defaultProps Ellipsis.displayName = 'NutEllipsis' diff --git a/src/packages/empty/empty.taro.tsx b/src/packages/empty/empty.taro.tsx index cd8a64ebf7..cb1d7d3284 100644 --- a/src/packages/empty/empty.taro.tsx +++ b/src/packages/empty/empty.taro.tsx @@ -133,5 +133,4 @@ export const Empty: FunctionComponent< ) } -Empty.defaultProps = defaultProps Empty.displayName = 'NutEmpty' diff --git a/src/packages/empty/empty.tsx b/src/packages/empty/empty.tsx index 63ff1a10b8..5100f7e091 100644 --- a/src/packages/empty/empty.tsx +++ b/src/packages/empty/empty.tsx @@ -134,5 +134,4 @@ export const Empty: FunctionComponent< ) } -Empty.defaultProps = defaultProps Empty.displayName = 'NutEmpty' diff --git a/src/packages/form/form.taro.tsx b/src/packages/form/form.taro.tsx index 071cf2bb16..c2389c8a6b 100644 --- a/src/packages/form/form.taro.tsx +++ b/src/packages/form/form.taro.tsx @@ -104,5 +104,4 @@ export const Form = React.forwardRef>( } ) -Form.defaultProps = defaultProps Form.displayName = 'NutForm' diff --git a/src/packages/form/form.tsx b/src/packages/form/form.tsx index ce5784d4a6..86beb7199a 100644 --- a/src/packages/form/form.tsx +++ b/src/packages/form/form.tsx @@ -104,5 +104,4 @@ export const Form = React.forwardRef>( } ) -Form.defaultProps = defaultProps Form.displayName = 'NutForm' diff --git a/src/packages/imagepreview/imagepreview.taro.tsx b/src/packages/imagepreview/imagepreview.taro.tsx index 744101c667..72b017840b 100644 --- a/src/packages/imagepreview/imagepreview.taro.tsx +++ b/src/packages/imagepreview/imagepreview.taro.tsx @@ -75,6 +75,7 @@ export const ImagePreview: FunctionComponent> = ( props ) => { const { + value, className, style, images, @@ -89,15 +90,16 @@ export const ImagePreview: FunctionComponent> = ( closeIconPosition, showMenuByLongpress, onClose, - } = props + onChange, + } = { ...defaultProps, ...props } const classPrefix = 'nut-imagepreview' const ref = useRef(null) const [innerNo, setInnerNo] = usePropsValue({ - value: props.value, + value, defaultValue, finalValue: defaultValue, onChange: (val: number) => { - props.onChange?.(val) + onChange?.(val) }, }) @@ -239,7 +241,7 @@ export const ImagePreview: FunctionComponent> = ( const slideChangeEnd = (page: number) => { setActive(page + 1) - props.onChange?.(page + 1) + onChange?.(page + 1) } const onCloseInner = (e: ITouchEvent | React.MouseEvent) => { e.stopPropagation() @@ -346,5 +348,4 @@ export const ImagePreview: FunctionComponent> = ( ) } -ImagePreview.defaultProps = defaultProps ImagePreview.displayName = 'NutImagePreview' diff --git a/src/packages/imagepreview/imagepreview.tsx b/src/packages/imagepreview/imagepreview.tsx index 8a9d061cd0..9b1b97277d 100644 --- a/src/packages/imagepreview/imagepreview.tsx +++ b/src/packages/imagepreview/imagepreview.tsx @@ -71,6 +71,7 @@ export const ImagePreview: FunctionComponent> = ( props ) => { const { + value, className, style, images, @@ -84,15 +85,16 @@ export const ImagePreview: FunctionComponent> = ( closeIcon, closeIconPosition, onClose, - } = props + onChange, + } = { ...defaultProps, ...props } const classPrefix = 'nut-imagepreview' const ref = useRef(null) const [innerNo, setInnerNo] = usePropsValue({ - value: props.value, + value, defaultValue, finalValue: defaultValue, onChange: (val: number) => { - props.onChange?.(val) + onChange?.(val) }, }) @@ -236,7 +238,7 @@ export const ImagePreview: FunctionComponent> = ( const slideChangeEnd = (page: number) => { setActive(page + 1) - props.onChange?.(page + 1) + onChange?.(page + 1) } const onCloseInner = (e: React.MouseEvent) => { @@ -326,5 +328,4 @@ export const ImagePreview: FunctionComponent> = ( ) } -ImagePreview.defaultProps = defaultProps ImagePreview.displayName = 'NutImagePreview' diff --git a/src/packages/indicator/indicator.taro.tsx b/src/packages/indicator/indicator.taro.tsx index 6c679ee32d..08413b10de 100644 --- a/src/packages/indicator/indicator.taro.tsx +++ b/src/packages/indicator/indicator.taro.tsx @@ -47,5 +47,4 @@ export const Indicator: FunctionComponent< ) } -Indicator.defaultProps = defaultProps Indicator.displayName = 'NutIndicator' diff --git a/src/packages/indicator/indicator.tsx b/src/packages/indicator/indicator.tsx index f0679743ec..d64929f5a2 100644 --- a/src/packages/indicator/indicator.tsx +++ b/src/packages/indicator/indicator.tsx @@ -49,5 +49,4 @@ export const Indicator: FunctionComponent< ) } -Indicator.defaultProps = defaultProps Indicator.displayName = 'NutIndicator' diff --git a/src/packages/infiniteloading/infiniteloading.taro.tsx b/src/packages/infiniteloading/infiniteloading.taro.tsx index bf33b35bf8..56765aa75e 100644 --- a/src/packages/infiniteloading/infiniteloading.taro.tsx +++ b/src/packages/infiniteloading/infiniteloading.taro.tsx @@ -198,5 +198,4 @@ export const InfiniteLoading: FunctionComponent< ) } -InfiniteLoading.defaultProps = defaultProps InfiniteLoading.displayName = 'NutInfiniteLoading' diff --git a/src/packages/infiniteloading/infiniteloading.tsx b/src/packages/infiniteloading/infiniteloading.tsx index f2d27eefd3..80186213e4 100644 --- a/src/packages/infiniteloading/infiniteloading.tsx +++ b/src/packages/infiniteloading/infiniteloading.tsx @@ -245,5 +245,4 @@ export const InfiniteLoading: FunctionComponent< ) } -InfiniteLoading.defaultProps = defaultProps InfiniteLoading.displayName = 'NutInfiniteLoading' diff --git a/src/packages/input/input.taro.tsx b/src/packages/input/input.taro.tsx index 9b4bcd8c24..187aeb7ed2 100644 --- a/src/packages/input/input.taro.tsx +++ b/src/packages/input/input.taro.tsx @@ -105,8 +105,8 @@ export const Input = forwardRef( ...props, } const [value, setValue] = usePropsValue({ - value: props.value, - defaultValue: props.defaultValue, + value: _value, + defaultValue, finalValue: '', onChange, }) @@ -267,5 +267,4 @@ export const Input = forwardRef( } ) -Input.defaultProps = defaultProps Input.displayName = 'NutInput' diff --git a/src/packages/input/input.tsx b/src/packages/input/input.tsx index 7cdb28df80..92674b66eb 100644 --- a/src/packages/input/input.tsx +++ b/src/packages/input/input.tsx @@ -91,14 +91,16 @@ export const Input = forwardRef( confirmType, defaultValue, value: _value, + onCompositionStart, + onCompositionEnd, ...rest } = { ...defaultProps, ...props, } const [value, setValue] = usePropsValue({ - value: props.value, - defaultValue: props.defaultValue, + value: _value, + defaultValue, finalValue: '', onChange, }) @@ -228,11 +230,11 @@ export const Input = forwardRef( }} onCompositionStart={(e) => { composingRef.current = true - props.onCompositionStart?.(e) + onCompositionStart?.(e) }} onCompositionEnd={(e) => { composingRef.current = false - props.onCompositionEnd?.(e) + onCompositionEnd?.(e) }} /> {clearable && !readOnly && active && value.length > 0 ? ( @@ -253,5 +255,4 @@ export const Input = forwardRef( } ) -Input.defaultProps = defaultProps Input.displayName = 'NutInput' diff --git a/src/packages/inputnumber/inputnumber.taro.tsx b/src/packages/inputnumber/inputnumber.taro.tsx index f7e8c5cc47..2f223d7dbc 100644 --- a/src/packages/inputnumber/inputnumber.taro.tsx +++ b/src/packages/inputnumber/inputnumber.taro.tsx @@ -252,5 +252,4 @@ export const InputNumber: FunctionComponent< ) } -InputNumber.defaultProps = defaultProps InputNumber.displayName = 'NutInputNumber' diff --git a/src/packages/inputnumber/inputnumber.tsx b/src/packages/inputnumber/inputnumber.tsx index 5120c394b5..f8ce2e1f23 100644 --- a/src/packages/inputnumber/inputnumber.tsx +++ b/src/packages/inputnumber/inputnumber.tsx @@ -246,5 +246,4 @@ export const InputNumber: FunctionComponent< ) } -InputNumber.defaultProps = defaultProps InputNumber.displayName = 'NutInputNumber' diff --git a/src/packages/layout/layout.taro.tsx b/src/packages/layout/layout.taro.tsx index 7387582910..7844dbc17a 100644 --- a/src/packages/layout/layout.taro.tsx +++ b/src/packages/layout/layout.taro.tsx @@ -9,5 +9,4 @@ export const Layout: FunctionComponent< return
Layout
} -Layout.defaultProps = defaultProps Layout.displayName = 'NutLayout' diff --git a/src/packages/layout/layout.tsx b/src/packages/layout/layout.tsx index 7387582910..7844dbc17a 100644 --- a/src/packages/layout/layout.tsx +++ b/src/packages/layout/layout.tsx @@ -9,5 +9,4 @@ export const Layout: FunctionComponent< return
Layout
} -Layout.defaultProps = defaultProps Layout.displayName = 'NutLayout' diff --git a/src/packages/loading/loading.taro.tsx b/src/packages/loading/loading.taro.tsx index fa77483d17..48113beb98 100644 --- a/src/packages/loading/loading.taro.tsx +++ b/src/packages/loading/loading.taro.tsx @@ -55,5 +55,4 @@ export const Loading: FunctionComponent< ) } -Loading.defaultProps = defaultProps Loading.displayName = 'NutLoading' diff --git a/src/packages/loading/loading.tsx b/src/packages/loading/loading.tsx index 21b7f30ac0..5ec760258a 100644 --- a/src/packages/loading/loading.tsx +++ b/src/packages/loading/loading.tsx @@ -55,5 +55,4 @@ export const Loading: FunctionComponent< ) } -Loading.defaultProps = defaultProps Loading.displayName = 'NutLoading' diff --git a/src/packages/menu/menu.taro.tsx b/src/packages/menu/menu.taro.tsx index c0d8cef76f..78f591e006 100644 --- a/src/packages/menu/menu.taro.tsx +++ b/src/packages/menu/menu.taro.tsx @@ -183,6 +183,5 @@ export const Menu: FunctionComponent> & { ) } -Menu.defaultProps = defaultProps Menu.displayName = 'NutMenu' Menu.Item = MenuItem diff --git a/src/packages/menu/menu.tsx b/src/packages/menu/menu.tsx index 13977e9c3c..7974fab1f2 100644 --- a/src/packages/menu/menu.tsx +++ b/src/packages/menu/menu.tsx @@ -192,6 +192,5 @@ export const Menu: FunctionComponent> & { ) } -Menu.defaultProps = defaultProps Menu.displayName = 'NutMenu' Menu.Item = MenuItem diff --git a/src/packages/menuitem/menuitem.taro.tsx b/src/packages/menuitem/menuitem.taro.tsx index 72913b36b4..64704a0473 100644 --- a/src/packages/menuitem/menuitem.taro.tsx +++ b/src/packages/menuitem/menuitem.taro.tsx @@ -265,5 +265,4 @@ export const MenuItem = forwardRef((props: Partial, ref) => { ) }) -MenuItem.defaultProps = defaultProps MenuItem.displayName = 'NutMenuItem' diff --git a/src/packages/menuitem/menuitem.tsx b/src/packages/menuitem/menuitem.tsx index 49385e135a..abead80e7d 100644 --- a/src/packages/menuitem/menuitem.tsx +++ b/src/packages/menuitem/menuitem.tsx @@ -257,5 +257,4 @@ export const MenuItem = forwardRef((props: Partial, ref) => { ) }) -MenuItem.defaultProps = defaultProps MenuItem.displayName = 'NutMenuItem' diff --git a/src/packages/noticebar/noticebar.taro.tsx b/src/packages/noticebar/noticebar.taro.tsx index 6c62450d8e..f41c3fcb9a 100644 --- a/src/packages/noticebar/noticebar.taro.tsx +++ b/src/packages/noticebar/noticebar.taro.tsx @@ -539,5 +539,4 @@ export const NoticeBar: FunctionComponent< ) } -NoticeBar.defaultProps = defaultProps NoticeBar.displayName = 'NutNoticeBar' diff --git a/src/packages/noticebar/noticebar.tsx b/src/packages/noticebar/noticebar.tsx index a834594821..4130f6cd9b 100644 --- a/src/packages/noticebar/noticebar.tsx +++ b/src/packages/noticebar/noticebar.tsx @@ -531,5 +531,4 @@ export const NoticeBar: FunctionComponent< ) } -NoticeBar.defaultProps = defaultProps NoticeBar.displayName = 'NutNoticeBar' diff --git a/src/packages/numberkeyboard/numberkeyboard.taro.tsx b/src/packages/numberkeyboard/numberkeyboard.taro.tsx index 8cc9b0cb5c..6b892ef90a 100644 --- a/src/packages/numberkeyboard/numberkeyboard.taro.tsx +++ b/src/packages/numberkeyboard/numberkeyboard.taro.tsx @@ -192,5 +192,4 @@ export const NumberKeyboard: FunctionComponent< ) } -NumberKeyboard.defaultProps = defaultProps NumberKeyboard.displayName = 'NutNumberKeyboard' diff --git a/src/packages/numberkeyboard/numberkeyboard.tsx b/src/packages/numberkeyboard/numberkeyboard.tsx index 2edb273c6f..fb7a274b3e 100644 --- a/src/packages/numberkeyboard/numberkeyboard.tsx +++ b/src/packages/numberkeyboard/numberkeyboard.tsx @@ -196,5 +196,4 @@ export const NumberKeyboard: FunctionComponent< ) } -NumberKeyboard.defaultProps = defaultProps NumberKeyboard.displayName = 'NutNumberKeyboard' diff --git a/src/packages/pagination/pagination.taro.tsx b/src/packages/pagination/pagination.taro.tsx index 38ecf7e39a..b1906cca8f 100644 --- a/src/packages/pagination/pagination.taro.tsx +++ b/src/packages/pagination/pagination.taro.tsx @@ -168,5 +168,4 @@ export const Pagination: FunctionComponent< ) } -Pagination.defaultProps = defaultProps Pagination.displayName = 'NutPagination' diff --git a/src/packages/pagination/pagination.tsx b/src/packages/pagination/pagination.tsx index 929d34d4fa..39683c5814 100644 --- a/src/packages/pagination/pagination.tsx +++ b/src/packages/pagination/pagination.tsx @@ -168,5 +168,4 @@ export const Pagination: FunctionComponent< ) } -Pagination.defaultProps = defaultProps Pagination.displayName = 'NutPagination' diff --git a/src/packages/popover/popover.taro.tsx b/src/packages/popover/popover.taro.tsx index cdbec609d1..7e6ffa60bf 100644 --- a/src/packages/popover/popover.taro.tsx +++ b/src/packages/popover/popover.taro.tsx @@ -154,7 +154,7 @@ export const Popover: FunctionComponent< const clickAway = () => { if (closeOnOutsideClick) { - props.onClick && props.onClick() + onClick && onClick() onClose && onClose() } } @@ -243,7 +243,7 @@ export const Popover: FunctionComponent< const skew = location.split('-')[1] const base = 16 - if (props.arrowOffset !== 0) { + if (arrowOffset !== 0) { const dir = rtl ? 'right' : 'left' const dir2 = rtl ? 'left' : 'right' if (['bottom', 'top'].includes(direction)) { @@ -278,7 +278,7 @@ export const Popover: FunctionComponent< onSelect?.(item, index) } if (closeOnActionClick) { - props.onClick?.() + onClick?.() onClose?.() } } @@ -358,5 +358,4 @@ export const Popover: FunctionComponent< ) } -Popover.defaultProps = defaultProps Popover.displayName = 'NutPopover' diff --git a/src/packages/popover/popover.tsx b/src/packages/popover/popover.tsx index 8ace62d0cc..9d6c6f3acb 100644 --- a/src/packages/popover/popover.tsx +++ b/src/packages/popover/popover.tsx @@ -130,7 +130,7 @@ export const Popover: FunctionComponent< } useClickAway( () => { - props.onClick?.() + onClick?.() onClose?.() }, targetSet as Element[], @@ -235,7 +235,7 @@ export const Popover: FunctionComponent< const skew = location.split('-')[1] const base = 16 - if (props.arrowOffset !== 0) { + if (arrowOffset !== 0) { const dir = rtl ? 'right' : 'left' const dir2 = rtl ? 'left' : 'right' if (['bottom', 'top'].includes(direction)) { @@ -270,7 +270,7 @@ export const Popover: FunctionComponent< onSelect?.(item, index) } if (closeOnActionClick) { - props.onClick?.() + onClick?.() onClose?.() } } @@ -281,7 +281,7 @@ export const Popover: FunctionComponent< className="nut-popover-wrapper" ref={popoverRef} onClick={() => { - props.onClick?.() + onClick?.() if (!visible) { onOpen?.() } else { @@ -354,5 +354,4 @@ export const Popover: FunctionComponent< ) } -Popover.defaultProps = defaultProps Popover.displayName = 'NutPopover' diff --git a/src/packages/popup/popup.taro.tsx b/src/packages/popup/popup.taro.tsx index b39c1b448c..5921b26de0 100644 --- a/src/packages/popup/popup.taro.tsx +++ b/src/packages/popup/popup.taro.tsx @@ -303,5 +303,4 @@ export const Popup: FunctionComponent< return <>{renderToContainer(portal as Teleport, renderNode())} } -Popup.defaultProps = defaultProps Popup.displayName = 'NutPopup' diff --git a/src/packages/popup/popup.tsx b/src/packages/popup/popup.tsx index 2ef165f9f7..a5f7fff117 100644 --- a/src/packages/popup/popup.tsx +++ b/src/packages/popup/popup.tsx @@ -303,5 +303,4 @@ export const Popup: FunctionComponent< return <>{renderToContainer(portal as Teleport, renderNode())} } -Popup.defaultProps = defaultProps Popup.displayName = 'NutPopup' diff --git a/src/packages/price/price.taro.tsx b/src/packages/price/price.taro.tsx index d35ca1f8c0..3ade80360c 100644 --- a/src/packages/price/price.taro.tsx +++ b/src/packages/price/price.taro.tsx @@ -129,5 +129,4 @@ export const Price: FunctionComponent> = (props) => { ) } -Price.defaultProps = defaultProps Price.displayName = 'NutPrice' diff --git a/src/packages/price/price.tsx b/src/packages/price/price.tsx index ab0e99402e..37b0497eec 100644 --- a/src/packages/price/price.tsx +++ b/src/packages/price/price.tsx @@ -120,5 +120,4 @@ export const Price: FunctionComponent> = (props) => { ) } -Price.defaultProps = defaultProps Price.displayName = 'NutPrice' diff --git a/src/packages/progress/progress.taro.tsx b/src/packages/progress/progress.taro.tsx index 43d520073b..ff529046c0 100644 --- a/src/packages/progress/progress.taro.tsx +++ b/src/packages/progress/progress.taro.tsx @@ -188,5 +188,4 @@ export const Progress: FunctionComponent< ) } -Progress.defaultProps = defaultProps Progress.displayName = 'NutProgress' diff --git a/src/packages/progress/progress.tsx b/src/packages/progress/progress.tsx index b3e4101e7f..a47ec44fbd 100644 --- a/src/packages/progress/progress.tsx +++ b/src/packages/progress/progress.tsx @@ -153,5 +153,4 @@ export const Progress: FunctionComponent< ) } -Progress.defaultProps = defaultProps Progress.displayName = 'NutProgress' diff --git a/src/packages/range/range.taro.tsx b/src/packages/range/range.taro.tsx index b8a2f94775..f5186f4ad0 100644 --- a/src/packages/range/range.taro.tsx +++ b/src/packages/range/range.taro.tsx @@ -424,5 +424,4 @@ export const Range: FunctionComponent< ) } -Range.defaultProps = defaultProps Range.displayName = 'NutRange' diff --git a/src/packages/range/range.tsx b/src/packages/range/range.tsx index 0c3a122e8a..328a2d6dc6 100644 --- a/src/packages/range/range.tsx +++ b/src/packages/range/range.tsx @@ -419,5 +419,4 @@ export const Range: FunctionComponent< ) } -Range.defaultProps = defaultProps Range.displayName = 'NutRange' diff --git a/src/packages/rate/rate.taro.tsx b/src/packages/rate/rate.taro.tsx index bfdc00630e..addc335fb9 100644 --- a/src/packages/rate/rate.taro.tsx +++ b/src/packages/rate/rate.taro.tsx @@ -241,5 +241,4 @@ export const Rate: FunctionComponent> = (props) => { ) } -Rate.defaultProps = defaultProps Rate.displayName = 'NutRate' diff --git a/src/packages/rate/rate.tsx b/src/packages/rate/rate.tsx index 0092f67afb..a461f4e99f 100644 --- a/src/packages/rate/rate.tsx +++ b/src/packages/rate/rate.tsx @@ -250,5 +250,4 @@ export const Rate: FunctionComponent> = (props) => { ) } -Rate.defaultProps = defaultProps Rate.displayName = 'NutRate' diff --git a/src/packages/searchbar/searchbar.taro.tsx b/src/packages/searchbar/searchbar.taro.tsx index 3693d13dd7..cf17c37284 100644 --- a/src/packages/searchbar/searchbar.taro.tsx +++ b/src/packages/searchbar/searchbar.taro.tsx @@ -66,9 +66,10 @@ export const SearchBar: FunctionComponent< const { locale } = useConfig() const searchRef = useRef(null) - const [value, setValue] = useState(() => props.value) const { + value: outerValue, + style, placeholder, shape, className, @@ -93,6 +94,8 @@ export const SearchBar: FunctionComponent< ...props, } + const [value, setValue] = useState(() => outerValue) + const forceFocus = () => { const searchSelf: HTMLInputElement | null = searchRef.current searchSelf && searchSelf.focus() @@ -114,8 +117,8 @@ export const SearchBar: FunctionComponent< onBlur && onBlur?.(value, event) } useEffect(() => { - setValue(props.value || '') - }, [props.value]) + setValue(outerValue || '') + }, [outerValue]) useEffect(() => { autoFocus && forceFocus() }, [autoFocus]) @@ -126,7 +129,7 @@ export const SearchBar: FunctionComponent< clearable ? `${classPrefix}-input-clear` : '' }`} ref={searchRef} - style={{ ...props.style }} + style={style} value={value || ''} placeholder={placeholder || locale.placeholder} disabled={disabled} @@ -202,7 +205,7 @@ export const SearchBar: FunctionComponent< className={`${classPrefix} ${ disabled ? `${classPrefix}-disabled` : '' } ${className || ''}`} - style={{ ...props.style }} + style={style} > {renderLeft()}
(null) - const [value, setValue] = useState(() => props.value) const { + value: outerValue, + style, placeholder, shape, className, @@ -93,6 +94,8 @@ export const SearchBar: FunctionComponent< ...props, } + const [value, setValue] = useState(() => outerValue) + const forceFocus = () => { const searchSelf: HTMLInputElement | null = searchRef.current searchSelf && searchSelf.focus() @@ -113,8 +116,8 @@ export const SearchBar: FunctionComponent< onBlur && onBlur?.(value, event) } useEffect(() => { - setValue(props.value) - }, [props.value]) + setValue(outerValue) + }, [outerValue]) useEffect(() => { autoFocus && forceFocus() }, [autoFocus]) @@ -125,7 +128,7 @@ export const SearchBar: FunctionComponent< clearable ? `${classPrefix}-input-clear` : '' }`} ref={searchRef} - style={{ ...props.style }} + style={style} value={value || ''} placeholder={placeholder || locale.placeholder} disabled={disabled} @@ -209,7 +212,7 @@ export const SearchBar: FunctionComponent< className={`${classPrefix} ${ disabled ? `${classPrefix}-disabled` : '' } ${className || ''}`} - style={{ ...props.style }} + style={style} > {renderLeft()}
{ canvasToTempFilePath({ canvas: res[0].node, - fileType: props.type, + fileType: type, canvasId: `${canvasId}`, success: (res) => { onConfirm && onConfirm(res.tempFilePath) @@ -223,5 +223,4 @@ const InternalSignature: ForwardRefRenderFunction< export const Signature = React.forwardRef>( InternalSignature ) -Signature.defaultProps = defaultProps Signature.displayName = 'NutSignature' diff --git a/src/packages/signature/signature.tsx b/src/packages/signature/signature.tsx index e7e81d481a..b875d5a975 100644 --- a/src/packages/signature/signature.tsx +++ b/src/packages/signature/signature.tsx @@ -178,5 +178,4 @@ const InternalSignature: ForwardRefRenderFunction< export const Signature = React.forwardRef>( InternalSignature ) -Signature.defaultProps = defaultProps Signature.displayName = 'NutSignature' diff --git a/src/packages/skeleton/skeleton.taro.tsx b/src/packages/skeleton/skeleton.taro.tsx index e7e054ef25..fd69c374d5 100644 --- a/src/packages/skeleton/skeleton.taro.tsx +++ b/src/packages/skeleton/skeleton.taro.tsx @@ -100,5 +100,4 @@ export const Skeleton: FunctionComponent> = (props) => { ) } -Skeleton.defaultProps = defaultProps Skeleton.displayName = 'NutSkeleton' diff --git a/src/packages/skeleton/skeleton.tsx b/src/packages/skeleton/skeleton.tsx index f838833b3c..03dc00b257 100644 --- a/src/packages/skeleton/skeleton.tsx +++ b/src/packages/skeleton/skeleton.tsx @@ -99,5 +99,4 @@ export const Skeleton: FunctionComponent> = (props) => { ) } -Skeleton.defaultProps = defaultProps Skeleton.displayName = 'NutSkeleton' diff --git a/src/packages/step/step.taro.tsx b/src/packages/step/step.taro.tsx index 46db8f3689..5a3f0ec238 100644 --- a/src/packages/step/step.taro.tsx +++ b/src/packages/step/step.taro.tsx @@ -76,5 +76,4 @@ export const Step: FunctionComponent< ) } -Step.defaultProps = defaultProps Step.displayName = 'NutStep' diff --git a/src/packages/step/step.tsx b/src/packages/step/step.tsx index 0a37df9825..ea8aabcbe3 100644 --- a/src/packages/step/step.tsx +++ b/src/packages/step/step.tsx @@ -75,5 +75,4 @@ export const Step: FunctionComponent< ) } -Step.defaultProps = defaultProps Step.displayName = 'NutStep' diff --git a/src/packages/steps/steps.taro.tsx b/src/packages/steps/steps.taro.tsx index d7e221de2f..e57debb2ca 100644 --- a/src/packages/steps/steps.taro.tsx +++ b/src/packages/steps/steps.taro.tsx @@ -40,7 +40,7 @@ export const Steps: FunctionComponent< classPrefix, { [`${classPrefix}-${direction}`]: true, - [`${classPrefix}-dot`]: !!props.dot, + [`${classPrefix}-dot`]: !!dot, }, className ) @@ -53,5 +53,4 @@ export const Steps: FunctionComponent< ) } -Steps.defaultProps = defaultProps Steps.displayName = 'NutSteps' diff --git a/src/packages/steps/steps.tsx b/src/packages/steps/steps.tsx index d7e221de2f..e57debb2ca 100644 --- a/src/packages/steps/steps.tsx +++ b/src/packages/steps/steps.tsx @@ -40,7 +40,7 @@ export const Steps: FunctionComponent< classPrefix, { [`${classPrefix}-${direction}`]: true, - [`${classPrefix}-dot`]: !!props.dot, + [`${classPrefix}-dot`]: !!dot, }, className ) @@ -53,5 +53,4 @@ export const Steps: FunctionComponent< ) } -Steps.defaultProps = defaultProps Steps.displayName = 'NutSteps' diff --git a/src/packages/switch/switch.taro.tsx b/src/packages/switch/switch.taro.tsx index 9b406cbee0..bfb6b00b54 100644 --- a/src/packages/switch/switch.taro.tsx +++ b/src/packages/switch/switch.taro.tsx @@ -73,5 +73,4 @@ export const Switch: FunctionComponent> = (props) => { ) } -Switch.defaultProps = defaultProps Switch.displayName = 'NutSwitch' diff --git a/src/packages/switch/switch.tsx b/src/packages/switch/switch.tsx index 9b406cbee0..bfb6b00b54 100644 --- a/src/packages/switch/switch.tsx +++ b/src/packages/switch/switch.tsx @@ -73,5 +73,4 @@ export const Switch: FunctionComponent> = (props) => { ) } -Switch.defaultProps = defaultProps Switch.displayName = 'NutSwitch' diff --git a/src/packages/table/table.taro.tsx b/src/packages/table/table.taro.tsx index d829761682..9152ce4398 100644 --- a/src/packages/table/table.taro.tsx +++ b/src/packages/table/table.taro.tsx @@ -88,7 +88,7 @@ export const Table: FunctionComponent< const cellClasses = (item: TableColumnProps) => { return { - [`${headerClassPrefix}-border`]: props.bordered, + [`${headerClassPrefix}-border`]: bordered, [`${headerClassPrefix}-align${item.align ? item.align : ''}`]: true, } } @@ -198,5 +198,4 @@ export const Table: FunctionComponent< ) } -Table.defaultProps = defaultProps Table.displayName = 'NutTable' diff --git a/src/packages/table/table.tsx b/src/packages/table/table.tsx index f9a4f71747..562980e1fe 100644 --- a/src/packages/table/table.tsx +++ b/src/packages/table/table.tsx @@ -85,7 +85,7 @@ export const Table: FunctionComponent< const cellClasses = (item: TableColumnProps) => { return { - [`${headerClassPrefix}-border`]: props.bordered, + [`${headerClassPrefix}-border`]: bordered, [`${headerClassPrefix}-align${item.align ? item.align : ''}`]: true, } } @@ -195,5 +195,4 @@ export const Table: FunctionComponent< ) } -Table.defaultProps = defaultProps Table.displayName = 'NutTable' diff --git a/src/packages/tag/tag.taro.tsx b/src/packages/tag/tag.taro.tsx index 5160957421..1d4099d69e 100644 --- a/src/packages/tag/tag.taro.tsx +++ b/src/packages/tag/tag.taro.tsx @@ -144,5 +144,4 @@ export const Tag: FunctionComponent> = (props) => { ) } -Tag.defaultProps = defaultProps Tag.displayName = 'NutTag' diff --git a/src/packages/tag/tag.tsx b/src/packages/tag/tag.tsx index 8ce948cabe..756f5fb8df 100644 --- a/src/packages/tag/tag.tsx +++ b/src/packages/tag/tag.tsx @@ -144,5 +144,4 @@ export const Tag: FunctionComponent> = (props) => { ) } -Tag.defaultProps = defaultProps Tag.displayName = 'NutTag' diff --git a/src/packages/textarea/textarea.taro.tsx b/src/packages/textarea/textarea.taro.tsx index 663fd214ab..85b5c119c5 100644 --- a/src/packages/textarea/textarea.taro.tsx +++ b/src/packages/textarea/textarea.taro.tsx @@ -136,5 +136,4 @@ export const TextArea: FunctionComponent> = (props) => { ) } -TextArea.defaultProps = defaultProps TextArea.displayName = 'NutTextArea' diff --git a/src/packages/textarea/textarea.tsx b/src/packages/textarea/textarea.tsx index a640575e98..c09f34e1ec 100644 --- a/src/packages/textarea/textarea.tsx +++ b/src/packages/textarea/textarea.tsx @@ -150,5 +150,4 @@ export const TextArea: FunctionComponent< ) } -TextArea.defaultProps = defaultProps TextArea.displayName = 'NutTextArea' diff --git a/src/packages/timedetail/timedetail.taro.tsx b/src/packages/timedetail/timedetail.taro.tsx index 4943fe26fe..af8be2f105 100644 --- a/src/packages/timedetail/timedetail.taro.tsx +++ b/src/packages/timedetail/timedetail.taro.tsx @@ -76,5 +76,4 @@ export const TimeDetail: FunctionComponent< ) } -TimeDetail.defaultProps = defaultProps TimeDetail.displayName = 'NutTimeDetail' diff --git a/src/packages/timedetail/timedetail.tsx b/src/packages/timedetail/timedetail.tsx index b81dc3fa84..8b89ebc3ee 100644 --- a/src/packages/timedetail/timedetail.tsx +++ b/src/packages/timedetail/timedetail.tsx @@ -72,5 +72,4 @@ export const TimeDetail: FunctionComponent< ) } -TimeDetail.defaultProps = defaultProps TimeDetail.displayName = 'NutTimeDetail' diff --git a/src/packages/timeselect/timeselect.taro.tsx b/src/packages/timeselect/timeselect.taro.tsx index 2336257876..f3bfe88d37 100644 --- a/src/packages/timeselect/timeselect.taro.tsx +++ b/src/packages/timeselect/timeselect.taro.tsx @@ -180,5 +180,4 @@ export const TimeSelect: FunctionComponent> = ( ) } -TimeSelect.defaultProps = defaultProps TimeSelect.displayName = 'NutTimeSelect' diff --git a/src/packages/timeselect/timeselect.tsx b/src/packages/timeselect/timeselect.tsx index e5dacfca99..835a4bfd7d 100644 --- a/src/packages/timeselect/timeselect.tsx +++ b/src/packages/timeselect/timeselect.tsx @@ -180,5 +180,4 @@ export const TimeSelect: FunctionComponent> = ( ) } -TimeSelect.defaultProps = defaultProps TimeSelect.displayName = 'NutTimeSelect' diff --git a/src/packages/tour/tour.taro.tsx b/src/packages/tour/tour.taro.tsx index 4cccc34e9e..2e7aaec021 100644 --- a/src/packages/tour/tour.taro.tsx +++ b/src/packages/tour/tour.taro.tsx @@ -266,5 +266,4 @@ export const Tour: FunctionComponent< ) } -Tour.defaultProps = defaultProps Tour.displayName = 'NutTour' diff --git a/src/packages/tour/tour.tsx b/src/packages/tour/tour.tsx index 49b928ecf1..27e29fbc04 100644 --- a/src/packages/tour/tour.tsx +++ b/src/packages/tour/tour.tsx @@ -259,5 +259,4 @@ export const Tour: FunctionComponent< ) } -Tour.defaultProps = defaultProps Tour.displayName = 'NutTour' diff --git a/src/packages/trendarrow/trendarrow.taro.tsx b/src/packages/trendarrow/trendarrow.taro.tsx index 7247ef6ffe..5367083266 100644 --- a/src/packages/trendarrow/trendarrow.taro.tsx +++ b/src/packages/trendarrow/trendarrow.taro.tsx @@ -121,5 +121,4 @@ export const TrendArrow: FunctionComponent< ) } -TrendArrow.defaultProps = defaultProps TrendArrow.displayName = 'NutTrendArrow' diff --git a/src/packages/trendarrow/trendarrow.tsx b/src/packages/trendarrow/trendarrow.tsx index 615bdc4037..ca4cb7bae8 100644 --- a/src/packages/trendarrow/trendarrow.tsx +++ b/src/packages/trendarrow/trendarrow.tsx @@ -121,5 +121,4 @@ export const TrendArrow: FunctionComponent< ) } -TrendArrow.defaultProps = defaultProps TrendArrow.displayName = 'NutTrendArrow' diff --git a/src/packages/uploader/uploader.taro.tsx b/src/packages/uploader/uploader.taro.tsx index fa01721bc8..1af9ae7f2f 100644 --- a/src/packages/uploader/uploader.taro.tsx +++ b/src/packages/uploader/uploader.taro.tsx @@ -372,7 +372,7 @@ const InternalUploader: ForwardRefRenderFunction< } const task = new UploaderTaro(uploadOption) - if (props.autoUpload) { + if (autoUpload) { task.uploadTaro(uploadFile, getEnv()) } else { uploadQueue.push( @@ -432,8 +432,8 @@ const InternalUploader: ForwardRefRenderFunction< } const filterFiles = (files: T[]) => { - const maximum = (props.maxCount as number) * 1 - const maximize = (props.maxFileSize as number) * 1 + const maximum = (maxCount as number) * 1 + const maximize = (maxFileSize as number) * 1 const oversizes = new Array() const filterFile = files.filter((file: T) => { if (file.size > maximize) { @@ -535,5 +535,4 @@ const InternalUploader: ForwardRefRenderFunction< export const Uploader = React.forwardRef(InternalUploader) -Uploader.defaultProps = defaultProps Uploader.displayName = 'NutUploader' diff --git a/src/packages/uploader/uploader.tsx b/src/packages/uploader/uploader.tsx index cd9987334b..3f4a04ce3a 100644 --- a/src/packages/uploader/uploader.tsx +++ b/src/packages/uploader/uploader.tsx @@ -269,7 +269,7 @@ const InternalUploader: ForwardRefRenderFunction< }) } const task = new Upload(uploadOption) - if (props.autoUpload) { + if (autoUpload) { task.upload() } else { uploadQueue.push( @@ -313,7 +313,7 @@ const InternalUploader: ForwardRefRenderFunction< } const filterFiles = (files: File[]) => { - const maximum = (props.maxCount as number) * 1 + const maximum = (maxCount as number) * 1 const oversizes = new Array() const filterFile = files.filter((file: File) => { if (file.size > maxFileSize) { @@ -448,5 +448,4 @@ const InternalUploader: ForwardRefRenderFunction< export const Uploader = React.forwardRef(InternalUploader) -Uploader.defaultProps = defaultProps Uploader.displayName = 'NutUploader' diff --git a/src/packages/video/video.taro.tsx b/src/packages/video/video.taro.tsx index d9f6b25d2b..ff623ba15a 100644 --- a/src/packages/video/video.taro.tsx +++ b/src/packages/video/video.taro.tsx @@ -77,5 +77,4 @@ export const Video: FunctionComponent> = (props) => { ) } -Video.defaultProps = defaultProps Video.displayName = 'NutVideo' diff --git a/src/packages/video/video.tsx b/src/packages/video/video.tsx index 33b42618b3..6c5dda0762 100644 --- a/src/packages/video/video.tsx +++ b/src/packages/video/video.tsx @@ -107,5 +107,4 @@ export const Video: FunctionComponent< ) } -Video.defaultProps = defaultProps Video.displayName = 'NutVideo' diff --git a/src/packages/virtuallist/virtuallist.taro.tsx b/src/packages/virtuallist/virtuallist.taro.tsx index 23c5abc314..c42d9592d0 100644 --- a/src/packages/virtuallist/virtuallist.taro.tsx +++ b/src/packages/virtuallist/virtuallist.taro.tsx @@ -207,5 +207,4 @@ export const VirtualList: FunctionComponent> = ( ) } -VirtualList.defaultProps = defaultProps VirtualList.displayName = 'NutVirtualList' diff --git a/src/packages/virtuallist/virtuallist.tsx b/src/packages/virtuallist/virtuallist.tsx index 433d57b520..9b5d0fe9a9 100644 --- a/src/packages/virtuallist/virtuallist.tsx +++ b/src/packages/virtuallist/virtuallist.tsx @@ -235,5 +235,4 @@ export const VirtualList: FunctionComponent> = ( ) } -VirtualList.defaultProps = defaultProps VirtualList.displayName = 'NutVirtualList' diff --git a/src/packages/watermark/watermark.taro.tsx b/src/packages/watermark/watermark.taro.tsx index 515e0fd941..c99394c208 100644 --- a/src/packages/watermark/watermark.taro.tsx +++ b/src/packages/watermark/watermark.taro.tsx @@ -160,5 +160,4 @@ export const WaterMark: FunctionComponent< ) } -WaterMark.defaultProps = defaultProps WaterMark.displayName = 'NutWaterMark' diff --git a/src/packages/watermark/watermark.tsx b/src/packages/watermark/watermark.tsx index 30adc3252f..b94a64a79f 100644 --- a/src/packages/watermark/watermark.tsx +++ b/src/packages/watermark/watermark.tsx @@ -140,5 +140,4 @@ export const WaterMark: FunctionComponent< ) } -WaterMark.defaultProps = defaultProps WaterMark.displayName = 'NutWaterMark'