@dvrd/dvr-controls 1.1.15 → 1.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import React, {MouseEventHandler, useEffect, useRef, useState} from 'react';
|
|
6
|
-
import DvrdCheckbox from
|
|
6
|
+
import DvrdCheckbox from './checkbox';
|
|
7
7
|
import {generateComponentId} from '../../..';
|
|
8
8
|
|
|
9
9
|
interface Props {
|
|
@@ -29,12 +29,14 @@ interface Props {
|
|
|
29
29
|
useDarkestColor?: boolean;
|
|
30
30
|
ref?: any;
|
|
31
31
|
asRadio?: boolean;
|
|
32
|
+
noRipple?: boolean;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
export default function CheckboxController(props: Props) {
|
|
35
36
|
const {
|
|
36
37
|
disabled, unControlled, checked, onCheck, label, labelPosition, className, labelClassName, checkboxClassName,
|
|
37
|
-
checkClassName, error, checkIcon, errorClassName, title, useDarkestColor, baseColor, contrastColor, asRadio
|
|
38
|
+
checkClassName, error, checkIcon, errorClassName, title, useDarkestColor, baseColor, contrastColor, asRadio,
|
|
39
|
+
noRipple
|
|
38
40
|
} = props;
|
|
39
41
|
const [isHovered, setIsHovered] = useState(false);
|
|
40
42
|
const [internalValue, setInternalValue] = useState(props.checked);
|
|
@@ -64,6 +66,7 @@ export default function CheckboxController(props: Props) {
|
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
function addRipple() {
|
|
69
|
+
if (noRipple) return;
|
|
67
70
|
const container = getContainer();
|
|
68
71
|
if (!container) return;
|
|
69
72
|
const ripple = getRipple();
|
|
@@ -95,10 +98,10 @@ export default function CheckboxController(props: Props) {
|
|
|
95
98
|
else if (!unControlled && checked) addRipple();
|
|
96
99
|
return function () {
|
|
97
100
|
removeRipple();
|
|
98
|
-
}
|
|
101
|
+
};
|
|
99
102
|
}, [internalValue, checked]);
|
|
100
103
|
|
|
101
|
-
const isChecked = unControlled ? internalValue : checked
|
|
104
|
+
const isChecked = unControlled ? internalValue : checked;
|
|
102
105
|
return (
|
|
103
106
|
<DvrdCheckbox onCheck={_onCheck} onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave} checked={isChecked}
|
|
104
107
|
disabled={disabled ?? false} isHovered={isHovered} label={label}
|
|
@@ -107,5 +110,5 @@ export default function CheckboxController(props: Props) {
|
|
|
107
110
|
checkIcon={checkIcon} error={error ?? null} errorClassName={errorClassName} title={title}
|
|
108
111
|
baseColor={baseColor} contrastColor={contrastColor} useDarkestColor={useDarkestColor ?? true}
|
|
109
112
|
asRadio={asRadio}/>
|
|
110
|
-
)
|
|
113
|
+
);
|
|
111
114
|
}
|