UNPKG

@carbon/react

Version:

React components for the Carbon Design System

82 lines (78 loc) 2.27 kB
/** * 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. */ import PropTypes from 'prop-types'; import React from 'react'; import InlineCheckbox from '../InlineCheckbox/InlineCheckbox.js'; import cx from 'classnames'; import { usePrefix } from '../../internal/usePrefix.js'; import { deprecate } from '../../prop-types/deprecate.js'; const TableSelectAll = ({ ariaLabel: deprecatedAriaLabel = 'Select all rows in the table', ['aria-label']: ariaLabel, checked, id, indeterminate, name, onSelect, disabled, className }) => { const prefix = usePrefix(); return /*#__PURE__*/React.createElement("th", { "aria-live": "off", scope: "col", className: cx(`${prefix}--table-column-checkbox`, className) }, /*#__PURE__*/React.createElement(InlineCheckbox, { "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.string, /** * Deprecated, please use `aria-label` instead. * Specify the aria label for the underlying input control */ ariaLabel: deprecate(PropTypes.string, 'This prop syntax has been deprecated. Please use the new `aria-label`.'), /** * Specify whether all items are selected, or not */ checked: PropTypes.bool, /** * The CSS class names of the cell that wraps the underlying input control */ className: PropTypes.string, /** * Specify whether the checkbox input should be disabled */ disabled: PropTypes.bool, /** * Provide an `id` for the underlying input control */ id: PropTypes.string.isRequired, /** * Specify whether the selection only has a subset of all items */ indeterminate: PropTypes.bool, /** * Provide a `name` for the underlying input control */ name: PropTypes.string.isRequired, /** * Provide a handler to listen to when a user initiates a selection request */ onSelect: PropTypes.func.isRequired }; export { TableSelectAll as default };