1- import React , { ChangeEventHandler , forwardRef , InputHTMLAttributes } from 'react'
2- import PropTypes from 'prop-types'
1+ import React , { ChangeEventHandler , forwardRef , InputHTMLAttributes , ReactNode } from 'react'
2+
33import classNames from 'classnames'
4+ import PropTypes from 'prop-types'
45
6+ import { CFormLabel } from './CFormLabel'
57export interface CFormRangeProps extends InputHTMLAttributes < HTMLInputElement > {
68 /**
79 * A string of all className you want applied to the component.
@@ -11,6 +13,12 @@ export interface CFormRangeProps extends InputHTMLAttributes<HTMLInputElement> {
1113 * Toggle the disabled state for the component.
1214 */
1315 disabled ?: boolean
16+ /**
17+ * Add a caption for a component.
18+ *
19+ * @since 4.2.0
20+ */
21+ label ?: ReactNode | string
1422 /**
1523 * Specifies the maximum value for the component.
1624 */
@@ -40,14 +48,20 @@ export interface CFormRangeProps extends InputHTMLAttributes<HTMLInputElement> {
4048}
4149
4250export const CFormRange = forwardRef < HTMLInputElement , CFormRangeProps > (
43- ( { className, ...rest } , ref ) => {
51+ ( { className, label , ...rest } , ref ) => {
4452 const _className = classNames ( 'form-range' , className )
45- return < input type = "range" className = { _className } { ...rest } ref = { ref } />
53+ return (
54+ < >
55+ { label && < CFormLabel htmlFor = { rest . id } > { label } </ CFormLabel > }
56+ < input type = "range" className = { _className } { ...rest } ref = { ref } />
57+ </ >
58+ )
4659 } ,
4760)
4861
4962CFormRange . propTypes = {
5063 className : PropTypes . string ,
64+ label : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . string ] ) ,
5165}
5266
5367CFormRange . displayName = 'CFormRange'
0 commit comments