diff --git a/CHANGELOG.en-US.md b/CHANGELOG.en-US.md index 7846219c..9f0f2a6a 100644 --- a/CHANGELOG.en-US.md +++ b/CHANGELOG.en-US.md @@ -14,6 +14,14 @@ toc: false --- +### 5.3.2 +`2024-12-11` + - **Tooltip** + - feat: Add offset settings to tooltip [#1398](https://github.com/ant-design/ant-design-mobile-rn/pull/1398) + - fix: Tooltip flash style [#1391](https://github.com/ant-design/ant-design-mobile-rn/issues/1391) + - feat: Slider ref + - fix: new Date not adhering to ISO 8601 [#1401](https://github.com/ant-design/ant-design-mobile-rn/pull/1401) + ### 5.3.1 `2024-11-20` - **Carousel** diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index 6730520c..17ca3746 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -14,6 +14,14 @@ toc: false --- +### 5.3.2 +`2024-12-11` + - **Tooltip** + - feat: Add offset settings to tooltip [#1398](https://github.com/ant-design/ant-design-mobile-rn/pull/1398) + - fix: Tooltip flash style [#1391](https://github.com/ant-design/ant-design-mobile-rn/issues/1391) + - feat: Slider ref + - fix: new Date not adhering to ISO 8601 [#1401](https://github.com/ant-design/ant-design-mobile-rn/pull/1401) + ### 5.3.1 `2024-11-20` - **Carousel** diff --git a/components/date-picker-view/date-picker-view.tsx b/components/date-picker-view/date-picker-view.tsx index 1835b687..b3698d51 100644 --- a/components/date-picker-view/date-picker-view.tsx +++ b/components/date-picker-view/date-picker-view.tsx @@ -17,14 +17,15 @@ import { PickerViewStyle } from '../picker-view/style' import { WithThemeStyles } from '../style' import { DatePickerViewPropsType } from './PropsType' import useRenderLabel from './useRenderLabel' +import dayjs from 'dayjs' export interface DatePickerViewProps extends DatePickerViewPropsType, WithThemeStyles {} const defaultProps = { - minDate: new Date('2000-1-1'), - maxDate: new Date('2030-1-1'), + minDate: dayjs('2000-1-1').toDate(), + maxDate: dayjs('2030-1-1').toDate(), mode: 'date', } diff --git a/components/date-picker/date-picker.tsx b/components/date-picker/date-picker.tsx index fdaaf474..1526548c 100644 --- a/components/date-picker/date-picker.tsx +++ b/components/date-picker/date-picker.tsx @@ -26,8 +26,8 @@ export type DatePickerRef = any export interface DatePickerProps extends DatePickerPropsType {} const defaultProps = { - minDate: new Date('2000-1-1'), - maxDate: new Date('2030-1-1'), + minDate: dayjs('2000-1-1').toDate(), + maxDate: dayjs('2030-1-1').toDate(), precision: 'day', } diff --git a/components/slider/PropsType.tsx b/components/slider/PropsType.tsx index 34e0101b..7b5d7689 100644 --- a/components/slider/PropsType.tsx +++ b/components/slider/PropsType.tsx @@ -8,6 +8,10 @@ export type SliderMarks = { } export type SliderValueType = number | [number, number] +export interface SliderRef { + onSlide: (changeX: number) => void +} + export type BaseSliderProps = { min?: number max?: number diff --git a/components/slider/index.tsx b/components/slider/index.tsx index 2de397f7..c8eb8208 100644 --- a/components/slider/index.tsx +++ b/components/slider/index.tsx @@ -1,4 +1,4 @@ -import { Slider } from './slider' +import Slider from './slider' export type { SliderProps } from './PropsType' diff --git a/components/slider/slider.tsx b/components/slider/slider.tsx index d0fd3759..718cc7e7 100644 --- a/components/slider/slider.tsx +++ b/components/slider/slider.tsx @@ -1,8 +1,10 @@ import getMiniDecimal from '@rc-component/mini-decimal' import React, { + ForwardedRef, useCallback, useContext, useEffect, + useImperativeHandle, useMemo, useRef, useState, @@ -18,7 +20,12 @@ import Animated, { import HapticsContext from '../provider/HapticsContext' import { useTheme } from '../style' import Marks from './marks' -import { BaseSliderProps, SliderProps, SliderValueType } from './PropsType' +import { + BaseSliderProps, + SliderProps, + SliderRef, + SliderValueType, +} from './PropsType' import SliderStyles from './style' import Thumb from './thumb' import Ticks from './ticks' @@ -33,8 +40,9 @@ function nearest(arr: number[], target: number) { }) } -export function Slider( +function InternalSlider( props: SliderProps, + ref: ForwardedRef, ) { const { value: propsValue, @@ -359,6 +367,15 @@ export function Slider( ) } + // ================== Actions Ref ================== + const actions = React.useMemo( + () => ({ + onSlide, + }), + [onSlide], + ) + useImperativeHandle(ref, () => actions) + return ( @@ -384,3 +401,12 @@ export function Slider( ) } + +const Slider = React.forwardRef(InternalSlider) as (( + props: React.PropsWithChildren & React.RefAttributes, +) => React.ReactElement) & + Pick + +Slider.displayName = 'Slider' + +export default React.memo(Slider) diff --git a/components/tooltip/Tooltip.tsx b/components/tooltip/Tooltip.tsx index 1a0e0e47..853cedf7 100644 --- a/components/tooltip/Tooltip.tsx +++ b/components/tooltip/Tooltip.tsx @@ -153,6 +153,9 @@ const InternalTooltip: React.ForwardRefRenderFunction< }) const safeFloatingStyles = useMemo(() => { + if (floatingStyles.left === 0 && floatingStyles.top === 0) { + return { display: 'none' } as const + } if (isNaN(floatingStyles.left) || isNaN(floatingStyles.top)) { return { display: 'none' } as const } @@ -175,7 +178,8 @@ const InternalTooltip: React.ForwardRefRenderFunction< style={{ marginTop: crossOffset.top, marginLeft: crossOffset.left, - }}> + }} + collapsable={false}>