@dvrd/dvr-controls 1.0.60 → 1.0.61
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
|
@@ -16,7 +16,7 @@ interface Props {
|
|
|
16
16
|
onCheck: MouseEventHandler;
|
|
17
17
|
onMouseEnter: MouseEventHandler;
|
|
18
18
|
onMouseLeave: MouseEventHandler;
|
|
19
|
-
checked: boolean;
|
|
19
|
+
checked: boolean | 'partial';
|
|
20
20
|
disabled: boolean;
|
|
21
21
|
isHovered: boolean;
|
|
22
22
|
label?: string;
|
|
@@ -117,6 +117,7 @@ export default function DvrdCheckbox(props: Props) {
|
|
|
117
117
|
let checkName: IconName = 'check';
|
|
118
118
|
if(typeof checkIcon === 'string') checkName = checkIcon as IconName;
|
|
119
119
|
else if (asRadio) checkName = 'circle';
|
|
120
|
+
else if (checked === 'partial') checkName = 'minus';
|
|
120
121
|
return <AwesomeIcon name={checkName} className={checkClassName} style={checkStyle}/>;
|
|
121
122
|
}
|
|
122
123
|
|
|
@@ -10,7 +10,7 @@ interface Props {
|
|
|
10
10
|
onCheck: Function;
|
|
11
11
|
onMouseEnter?: MouseEventHandler;
|
|
12
12
|
onMouseLeave?: MouseEventHandler;
|
|
13
|
-
checked: boolean;
|
|
13
|
+
checked: boolean | 'partial';
|
|
14
14
|
disabled?: boolean;
|
|
15
15
|
label?: string;
|
|
16
16
|
labelPosition?: 'left' | 'right';
|
|
@@ -42,13 +42,14 @@ export default function CheckboxController(props: Props) {
|
|
|
42
42
|
|
|
43
43
|
function _onCheck(evt: React.MouseEvent<Element, Event>) {
|
|
44
44
|
if (disabled) return;
|
|
45
|
+
const trueValues = [false, 'partial'];
|
|
46
|
+
const value = unControlled ? trueValues.includes(internalValue) : trueValues.includes(checked);
|
|
45
47
|
if (unControlled) {
|
|
46
48
|
evt.stopPropagation();
|
|
47
49
|
evt.persist();
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
} else onCheck(!checked, evt);
|
|
50
|
+
setInternalValue(value);
|
|
51
|
+
onCheck(value, evt);
|
|
52
|
+
} else onCheck(value, evt);
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
function onMouseEnter(evt: React.MouseEvent) {
|
|
@@ -107,109 +108,4 @@ export default function CheckboxController(props: Props) {
|
|
|
107
108
|
baseColor={baseColor} contrastColor={contrastColor} useDarkestColor={useDarkestColor ?? true}
|
|
108
109
|
asRadio={asRadio}/>
|
|
109
110
|
)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// interface CheckboxState {
|
|
113
|
-
// isHovered: boolean;
|
|
114
|
-
// internalValue: boolean;
|
|
115
|
-
// }
|
|
116
|
-
//
|
|
117
|
-
// class _CheckboxController extends React.Component<Props, CheckboxState> {
|
|
118
|
-
// static contextType = ControlContext;
|
|
119
|
-
//
|
|
120
|
-
// static defaultProps = {
|
|
121
|
-
// disabled: false,
|
|
122
|
-
// label: '',
|
|
123
|
-
// labelPosition: 'right',
|
|
124
|
-
// containerClass: '',
|
|
125
|
-
// labelClass: '',
|
|
126
|
-
// checkboxClass: '',
|
|
127
|
-
// checkClass: '',
|
|
128
|
-
// errorClass: '',
|
|
129
|
-
// checkIcon: null,
|
|
130
|
-
// error: null,
|
|
131
|
-
// unControlled: false,
|
|
132
|
-
// useDarkestColor: true,
|
|
133
|
-
// };
|
|
134
|
-
//
|
|
135
|
-
// private getContainer = (): HTMLElement | null => {
|
|
136
|
-
// return document.getElementById(this.id);
|
|
137
|
-
// };
|
|
138
|
-
//
|
|
139
|
-
// private getRipple = (): HTMLElement | null => {
|
|
140
|
-
// const container = this.getContainer();
|
|
141
|
-
// if (container === null) return null;
|
|
142
|
-
// return container.querySelector('div.ripple');
|
|
143
|
-
// };
|
|
144
|
-
//
|
|
145
|
-
// private id: string = generateComponentId(this.props.id);
|
|
146
|
-
//
|
|
147
|
-
// state = {isHovered: false, internalValue: this.props.checked};
|
|
148
|
-
//
|
|
149
|
-
// onCheck = (evt: React.MouseEvent<Element, Event>) => {
|
|
150
|
-
// const {checked, onCheck, disabled, unControlled} = this.props;
|
|
151
|
-
// if (disabled) return;
|
|
152
|
-
// if (unControlled) {
|
|
153
|
-
// evt.stopPropagation();
|
|
154
|
-
// evt.persist();
|
|
155
|
-
// this.setState({internalValue: !this.state.internalValue}, () => {
|
|
156
|
-
// onCheck(this.state.internalValue, evt);
|
|
157
|
-
// });
|
|
158
|
-
// } else onCheck(!checked, evt);
|
|
159
|
-
// this.addRipple();
|
|
160
|
-
// };
|
|
161
|
-
//
|
|
162
|
-
// onMouseEnter = () => {
|
|
163
|
-
// if (this.props.disabled) return;
|
|
164
|
-
// this.setState({isHovered: true});
|
|
165
|
-
// };
|
|
166
|
-
//
|
|
167
|
-
// onMouseLeave = () => {
|
|
168
|
-
// if (this.props.disabled) return;
|
|
169
|
-
// this.setState({isHovered: false});
|
|
170
|
-
// };
|
|
171
|
-
//
|
|
172
|
-
// addRipple = () => {
|
|
173
|
-
// const container = this.getContainer();
|
|
174
|
-
// if (container !== null) {
|
|
175
|
-
// const ripple = this.getRipple();
|
|
176
|
-
// if (ripple !== null) {
|
|
177
|
-
// if (container.classList.contains('rippling'))
|
|
178
|
-
// container.classList.remove('rippling');
|
|
179
|
-
// ripple.addEventListener('transitionend', this.removeRipple);
|
|
180
|
-
// container.classList.add('rippling');
|
|
181
|
-
// }
|
|
182
|
-
// }
|
|
183
|
-
// };
|
|
184
|
-
//
|
|
185
|
-
// removeRipple = () => {
|
|
186
|
-
// const ripple = this.getRipple();
|
|
187
|
-
// const container = this.getContainer();
|
|
188
|
-
// if (ripple !== null && container !== null) {
|
|
189
|
-
// ripple.removeEventListener('transitionend', this.removeRipple);
|
|
190
|
-
// container.classList.remove('rippling');
|
|
191
|
-
// }
|
|
192
|
-
// };
|
|
193
|
-
//
|
|
194
|
-
// componentDidUpdate = (prevProps: Props, prevState: CheckboxState) => {
|
|
195
|
-
// if (prevState.internalValue !== this.state.internalValue && this.state.internalValue) this.addRipple();
|
|
196
|
-
// else if (prevProps.checked !== this.props.checked && this.props.checked) this.addRipple();
|
|
197
|
-
// };
|
|
198
|
-
//
|
|
199
|
-
// componentWillUnmount = () => {
|
|
200
|
-
// this.removeRipple();
|
|
201
|
-
// };
|
|
202
|
-
//
|
|
203
|
-
// render = () => {
|
|
204
|
-
// const {
|
|
205
|
-
// checked, disabled, label, labelPosition, containerClass, labelClass, checkboxClass, checkClass, checkIcon,
|
|
206
|
-
// error, errorClass, unControlled, title, baseColor, contrastColor, useDarkestColor,
|
|
207
|
-
// } = this.props, {isHovered, internalValue} = this.state, isChecked = unControlled ? internalValue : checked;
|
|
208
|
-
// return <Checkbox onCheck={this.onCheck} onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}
|
|
209
|
-
// checked={isChecked} disabled={disabled} isHovered={isHovered} label={label}
|
|
210
|
-
// labelPosition={labelPosition} containerClass={containerClass} labelClass={labelClass}
|
|
211
|
-
// checkboxClass={checkboxClass} checkClass={checkClass} id={this.id} checkIcon={checkIcon}
|
|
212
|
-
// error={error} errorClass={errorClass} title={title} baseColor={baseColor}
|
|
213
|
-
// contrastColor={contrastColor} useDarkestColor={useDarkestColor}/>
|
|
214
|
-
// }
|
|
215
|
-
// }
|
|
111
|
+
}
|