Fix review comments added single slider

Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com>
This commit is contained in:
AmbrishRamachandiran
2026-03-10 13:03:06 +05:30
parent 41ec1e20e2
commit 37b7ca137c
3 changed files with 23 additions and 22 deletions
+9 -21
View File
@@ -32,17 +32,14 @@ function SliderImpl<T extends number | number[]>(
props: SliderProps<T>,
ref: React.ForwardedRef<HTMLDivElement>,
) {
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<T extends number | number[]>(
}
}, [label, ariaLabel, ariaLabelledBy]);
const {
ownProps,
restProps: definitionRest,
dataAttributes,
} = useDefinition(SliderDefinition, restProps);
const { classes, className } = ownProps;
const secondaryLabelText = secondaryLabel || (isRequired ? 'Required' : null);
return (
<AriaSlider
className={clsx(classes.root, className)}
{...dataAttributes}
aria-label={ariaLabel}
aria-labelledby={ariaLabelledBy}
defaultValue={defaultValue}
value={value}
isRequired={isRequired}
{...definitionRest}
{...restProps}
ref={ref}
>
{label && (
@@ -34,5 +34,9 @@ export const SliderDefinition = defineComponent<SliderOwnProps>()({
},
propDefs: {
className: {},
label: {},
secondaryLabel: {},
description: {},
isRequired: {},
},
});
+10 -1
View File
@@ -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<T extends number | number[]>
| 'onChange'
| 'slot'
| 'style'
> {}
| 'label'
| 'secondaryLabel'
| 'description'
| 'isRequired'
>,
SliderOwnProps {}