@deque/cauldron-react 4.0.0-canary.78d6a743 → 4.0.0-canary.9538a958
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/lib/components/Checkbox/index.d.ts +1 -0
- package/lib/index.js +17 -7
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import React, { InputHTMLAttributes, Ref } from 'react';
|
|
|
2
2
|
export interface CheckboxProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
3
3
|
id: string;
|
|
4
4
|
label: React.ReactNode;
|
|
5
|
+
labelDescription?: string;
|
|
5
6
|
error?: React.ReactNode;
|
|
6
7
|
customIcon?: React.ReactNode;
|
|
7
8
|
checkboxRef?: Ref<HTMLInputElement>;
|
package/lib/index.js
CHANGED
|
@@ -2381,7 +2381,7 @@ RadioGroup.propTypes = {
|
|
|
2381
2381
|
RadioGroup.displayName = 'RadioGroup';
|
|
2382
2382
|
|
|
2383
2383
|
var Checkbox = React.forwardRef(function (_a, ref) {
|
|
2384
|
-
var id = _a.id, label = _a.label, error = _a.error, checkboxRef = _a.checkboxRef, className = _a.className, onChange = _a.onChange, ariaDescribedby = _a["aria-describedby"], _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.checked, checked = _c === void 0 ? false : _c, other = tslib.__rest(_a, ["id", "label", "error", "checkboxRef", "className", "onChange", 'aria-describedby', "disabled", "checked"]);
|
|
2384
|
+
var id = _a.id, label = _a.label, labelDescription = _a.labelDescription, error = _a.error, checkboxRef = _a.checkboxRef, className = _a.className, onChange = _a.onChange, ariaDescribedby = _a["aria-describedby"], _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.checked, checked = _c === void 0 ? false : _c, other = tslib.__rest(_a, ["id", "label", "labelDescription", "error", "checkboxRef", "className", "onChange", 'aria-describedby', "disabled", "checked"]);
|
|
2385
2385
|
var _d = tslib.__read(React.useState(checked), 2), isChecked = _d[0], setIsChecked = _d[1];
|
|
2386
2386
|
var _e = tslib.__read(React.useState(false), 2), focused = _e[0], setFocused = _e[1];
|
|
2387
2387
|
var checkRef = React.useRef(null);
|
|
@@ -2392,10 +2392,19 @@ var Checkbox = React.forwardRef(function (_a, ref) {
|
|
|
2392
2392
|
if (typeof refProp === 'function') {
|
|
2393
2393
|
refProp(checkRef.current);
|
|
2394
2394
|
}
|
|
2395
|
-
var
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2395
|
+
var _f = React.useMemo(function () {
|
|
2396
|
+
return {
|
|
2397
|
+
labelDescriptionId: nextId__default(),
|
|
2398
|
+
errorId: nextId__default()
|
|
2399
|
+
};
|
|
2400
|
+
}, []), errorId = _f.errorId, labelDescriptionId = _f.labelDescriptionId;
|
|
2401
|
+
var ariaDescribedbyId = ariaDescribedby;
|
|
2402
|
+
if (error) {
|
|
2403
|
+
ariaDescribedbyId = tokenList(errorId, ariaDescribedbyId);
|
|
2404
|
+
}
|
|
2405
|
+
if (labelDescription) {
|
|
2406
|
+
ariaDescribedbyId = tokenList(labelDescriptionId, ariaDescribedbyId);
|
|
2407
|
+
}
|
|
2399
2408
|
return (React__default.createElement(React__default.Fragment, null,
|
|
2400
2409
|
React__default.createElement("div", { className: classNames('Checkbox is--flex-row', className) },
|
|
2401
2410
|
React__default.createElement("input", tslib.__assign({ id: id, ref: typeof refProp === 'function' || !refProp ? checkRef : refProp, type: "checkbox", checked: isChecked, disabled: disabled, onFocus: function () { return setFocused(true); }, onBlur: function () { return setFocused(false); }, "aria-describedby": ariaDescribedbyId, onChange: function (e) {
|
|
@@ -2419,8 +2428,9 @@ var Checkbox = React.forwardRef(function (_a, ref) {
|
|
|
2419
2428
|
else {
|
|
2420
2429
|
(_b = checkRef.current) === null || _b === void 0 ? void 0 : _b.click();
|
|
2421
2430
|
}
|
|
2422
|
-
} })
|
|
2423
|
-
|
|
2431
|
+
} }),
|
|
2432
|
+
labelDescription && (React__default.createElement("span", { id: labelDescriptionId, className: "Field__labelDescription" }, labelDescription)),
|
|
2433
|
+
error && (React__default.createElement("div", { id: errorId, className: "Error" }, error)))));
|
|
2424
2434
|
});
|
|
2425
2435
|
Checkbox.displayName = 'Checkbox';
|
|
2426
2436
|
|