diff --git a/packages/ui/src/components/Slider/Slider.tsx b/packages/ui/src/components/Slider/Slider.tsx index d3156ee3f5..a417dfecb0 100644 --- a/packages/ui/src/components/Slider/Slider.tsx +++ b/packages/ui/src/components/Slider/Slider.tsx @@ -32,17 +32,14 @@ function SliderImpl( props: SliderProps, ref: React.ForwardedRef, ) { - const { - label, - 'aria-label': ariaLabel, - 'aria-labelledby': ariaLabelledBy, - description, - secondaryLabel, - defaultValue, - value, - isRequired, - ...restProps - } = props; + const { ownProps, restProps } = useDefinition(SliderDefinition, props); + const { classes, className, label, secondaryLabel, description, isRequired } = + ownProps; + + const ariaLabel = restProps['aria-label']; + const ariaLabelledBy = restProps['aria-labelledby']; + const defaultValue = restProps.defaultValue; + const value = restProps.value; useEffect(() => { if (!label && !ariaLabel && !ariaLabelledBy) { @@ -52,25 +49,16 @@ function SliderImpl( } }, [label, ariaLabel, ariaLabelledBy]); - const { - ownProps, - restProps: definitionRest, - dataAttributes, - } = useDefinition(SliderDefinition, restProps); - const { classes, className } = ownProps; - const secondaryLabelText = secondaryLabel || (isRequired ? 'Required' : null); return ( {label && ( diff --git a/packages/ui/src/components/Slider/definition.ts b/packages/ui/src/components/Slider/definition.ts index ab460c93ba..fdfd19939f 100644 --- a/packages/ui/src/components/Slider/definition.ts +++ b/packages/ui/src/components/Slider/definition.ts @@ -34,5 +34,9 @@ export const SliderDefinition = defineComponent()({ }, propDefs: { className: {}, + label: {}, + secondaryLabel: {}, + description: {}, + isRequired: {}, }, }); diff --git a/packages/ui/src/components/Slider/types.ts b/packages/ui/src/components/Slider/types.ts index ce58fef748..55ab3e1448 100644 --- a/packages/ui/src/components/Slider/types.ts +++ b/packages/ui/src/components/Slider/types.ts @@ -20,6 +20,10 @@ import type { FieldLabelProps } from '../FieldLabel/types'; /** @public */ export interface SliderOwnProps { className?: string; + label?: FieldLabelProps['label']; + secondaryLabel?: FieldLabelProps['secondaryLabel']; + description?: FieldLabelProps['description']; + isRequired?: boolean; } /** @public */ @@ -34,4 +38,9 @@ export interface SliderProps | 'onChange' | 'slot' | 'style' - > {} + | 'label' + | 'secondaryLabel' + | 'description' + | 'isRequired' + >, + SliderOwnProps {}