UNPKG

@react-md/table

Version:

Create responsive data tables and accessible fixed tables

40 lines 3.34 kB
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; }; import { jsx as _jsx } from "react/jsx-runtime"; import { forwardRef } from "react"; import cn from "classnames"; import { Checkbox } from "@react-md/form"; import { TableCell } from "./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. */ export var TableCheckbox = 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 (_jsx(TableCell, __assign({}, props, { ref: ref, id: cellId, header: false, className: cn("rmd-table-cell--checkbox", className) }, { children: _jsx(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