@@ -5,7 +5,7 @@ import { generatorBase64Code } from 'dtable-utils';
55
66import './index.css' ;
77
8- function DTableSwitch ( { onChange, checked = false , placeholder, disabled, size = 'sm' , switchPosition = 'right' , switchClassName } ) {
8+ function DTableSwitch ( { onChange, checked = false , placeholder, disabled, size = 'sm' , switchPosition = 'right' , switchClassName, inputId } ) {
99 const switchNode = < span className = "custom-switch-indicator" > </ span > ;
1010 const textNode = < span className = "custom-switch-description text-truncate" > { placeholder } </ span > ;
1111 return (
@@ -25,7 +25,7 @@ function DTableSwitch({ onChange, checked = false, placeholder, disabled, size =
2525 name = "custom-switch-checkbox"
2626 disabled = { disabled }
2727 aria-label = { placeholder }
28- id = { 'dtable-switch-' + generatorBase64Code ( 12 ) }
28+ id = { inputId || 'dtable-switch-' + generatorBase64Code ( 12 ) }
2929 />
3030 { switchPosition === 'left' && < > { switchNode } { textNode } </ > }
3131 { switchPosition === 'right' && < > { textNode } { switchNode } </ > }
@@ -41,7 +41,8 @@ DTableSwitch.propTypes = {
4141 placeholder : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . node ] ) . isRequired ,
4242 onChange : PropTypes . func . isRequired ,
4343 disabled : PropTypes . bool ,
44- switchClassName : PropTypes . string
44+ switchClassName : PropTypes . string ,
45+ inputId : PropTypes . string
4546} ;
4647
4748export default DTableSwitch ;
0 commit comments