@react-md/table
Version:
Create responsive data tables and accessible fixed tables
46 lines • 3.7 kB
JavaScript
;
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TableCheckbox = void 0;
var jsx_runtime_1 = require("react/jsx-runtime");
var react_1 = require("react");
var classnames_1 = __importDefault(require("classnames"));
var form_1 = require("@react-md/form");
var TableCell_1 = require("./TableCell");
var DEFAULT_ARIA_LABEL = "Toggle Row Selection";
/**
* This is a simple wrapper for the `Checkbox` component that allows you to
* render a nicely styled `Checkbox` within a `TableCell` element. This will
* mostly just remove the additional padding applied and default an `aria-label`
* since you normally don't want a checkbox with a label within a table since
* it's more for selection.
*/
exports.TableCheckbox = (0, react_1.forwardRef)(function TableCheckbox(_a, ref) {
var cellId = _a.cellId, className = _a.className, id = _a.id, ariaLabel = _a["aria-label"], ariaLabelledBy = _a["aria-labelledby"], ariaChecked = _a["aria-checked"], ariaControls = _a["aria-controls"], checkboxRef = _a.checkboxRef, checkboxStyle = _a.checkboxStyle, checkboxClassName = _a.checkboxClassName, icon = _a.icon, iconStyle = _a.iconStyle, iconClassName = _a.iconClassName, toggleStyle = _a.toggleStyle, toggleClassName = _a.toggleClassName, disableIconOverlay = _a.disableIconOverlay, name = _a.name, value = _a.value, checked = _a.checked, onChange = _a.onChange, defaultChecked = _a.defaultChecked, indeterminate = _a.indeterminate, props = __rest(_a, ["cellId", "className", "id", "aria-label", "aria-labelledby", "aria-checked", "aria-controls", "checkboxRef", "checkboxStyle", "checkboxClassName", "icon", "iconStyle", "iconClassName", "toggleStyle", "toggleClassName", "disableIconOverlay", "name", "value", "checked", "onChange", "defaultChecked", "indeterminate"]);
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCell, __assign({}, props, { ref: ref, id: cellId, header: false, className: (0, classnames_1.default)("rmd-table-cell--checkbox", className) }, { children: (0, jsx_runtime_1.jsx)(form_1.Checkbox, { id: id, "aria-label": (ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : ariaLabelledBy) ? undefined : DEFAULT_ARIA_LABEL, "aria-labelledby": ariaLabelledBy, "aria-checked": ariaChecked, "aria-controls": ariaControls, ref: checkboxRef, style: checkboxStyle, indeterminate: indeterminate, className: checkboxClassName, icon: icon, iconStyle: iconStyle, iconClassName: iconClassName, toggleStyle: toggleStyle, toggleClassName: toggleClassName, disableIconOverlay: disableIconOverlay, name: name, value: value, checked: checked, onChange: onChange, defaultChecked: defaultChecked }) })));
});
//# sourceMappingURL=TableCheckbox.js.map