From fe388431584ca53a7fead7dd06fcc0535ece03af Mon Sep 17 00:00:00 2001 From: Navin Moorthy Date: Tue, 24 May 2022 13:51:36 +0530 Subject: [PATCH] =?UTF-8?q?refactor(slider):=20=E2=99=BB=EF=B8=8F=20add=20?= =?UTF-8?q?base=20states=20to=20props=20states?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/meter/index.ts | 1 + src/slider/slider-state.ts | 7 ++++++- src/slider/slider-thumb-state.ts | 7 ++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/meter/index.ts b/src/meter/index.ts index 78e7e50de..6e6e53e30 100644 --- a/src/meter/index.ts +++ b/src/meter/index.ts @@ -1,2 +1,3 @@ +export * from "./__utils"; export * from "./meter-base"; export * from "./meter-state"; diff --git a/src/slider/slider-state.ts b/src/slider/slider-state.ts index 1e8085f4d..3fc62876e 100644 --- a/src/slider/slider-state.ts +++ b/src/slider/slider-state.ts @@ -9,7 +9,7 @@ export function useSliderState(props: SliderStateProps): SliderState { const trackRef = React.useRef(null); const sliderProps = useSlider(rest, state, trackRef); - return { ...sliderProps, trackRef }; + return { ...sliderProps, trackRef, baseState: state }; } export type SliderState = { @@ -32,6 +32,11 @@ export type SliderState = { /** Props for the output element, displaying the value of the slider thumbs. */ outputProps: React.OutputHTMLAttributes; + + /** + * Object returned by the `useSliderBaseState` hook. + */ + baseState: SliderBaseState; }; export type SliderStateProps = AriaSliderProps & { diff --git a/src/slider/slider-thumb-state.ts b/src/slider/slider-thumb-state.ts index 4de58c8a5..164cb757a 100644 --- a/src/slider/slider-thumb-state.ts +++ b/src/slider/slider-thumb-state.ts @@ -18,12 +18,17 @@ export function useSliderThumbState( state, ); - return { ...sliderThumbProps, inputRef }; + return { ...sliderThumbProps, inputRef, baseState: state }; } export type SliderThumbState = SliderThumbAria & { /** A ref to the thumb input element. */ inputRef: React.RefObject; + + /** + * Object returned by the `useSliderBaseState` hook. + */ + baseState: SliderBaseState; }; export type SliderThumbStateProps = AriaSliderThumbProps & {