@carbon/react
Version:
React components for the Carbon Design System
92 lines (84 loc) • 2.94 kB
JavaScript
/**
* Copyright IBM Corp. 2016, 2023
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var PropTypes = require('prop-types');
var React = require('react');
var InlineCheckbox = require('../InlineCheckbox/InlineCheckbox.js');
var cx = require('classnames');
var usePrefix = require('../../internal/usePrefix.js');
var deprecate = require('../../prop-types/deprecate.js');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
const TableSelectAll = ({
ariaLabel: deprecatedAriaLabel = 'Select all rows in the table',
['aria-label']: ariaLabel,
checked,
id,
indeterminate,
name,
onSelect,
disabled,
className
}) => {
const prefix = usePrefix.usePrefix();
return /*#__PURE__*/React__default["default"].createElement("th", {
"aria-live": "off",
scope: "col",
className: cx__default["default"](`${prefix}--table-column-checkbox`, className)
}, /*#__PURE__*/React__default["default"].createElement(InlineCheckbox["default"], {
"aria-label": ariaLabel || deprecatedAriaLabel,
checked: checked,
id: id,
indeterminate: indeterminate,
name: name,
onClick: onSelect,
disabled: disabled
}));
};
TableSelectAll.propTypes = {
/**
* Specify the aria label for the underlying input control
*/
['aria-label']: PropTypes__default["default"].string,
/**
* Deprecated, please use `aria-label` instead.
* Specify the aria label for the underlying input control
*/
ariaLabel: deprecate["default"](PropTypes__default["default"].string, 'This prop syntax has been deprecated. Please use the new `aria-label`.'),
/**
* Specify whether all items are selected, or not
*/
checked: PropTypes__default["default"].bool,
/**
* The CSS class names of the cell that wraps the underlying input control
*/
className: PropTypes__default["default"].string,
/**
* Specify whether the checkbox input should be disabled
*/
disabled: PropTypes__default["default"].bool,
/**
* Provide an `id` for the underlying input control
*/
id: PropTypes__default["default"].string.isRequired,
/**
* Specify whether the selection only has a subset of all items
*/
indeterminate: PropTypes__default["default"].bool,
/**
* Provide a `name` for the underlying input control
*/
name: PropTypes__default["default"].string.isRequired,
/**
* Provide a handler to listen to when a user initiates a selection request
*/
onSelect: PropTypes__default["default"].func.isRequired
};
exports["default"] = TableSelectAll;