Skip to content

Commit 395219f

Browse files
update
1 parent 3fa92f6 commit 395219f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/DTableSwitch/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { generatorBase64Code } from 'dtable-utils';
55

66
import './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

4748
export default DTableSwitch;

0 commit comments

Comments
 (0)