| 1 |
"use strict"; |
| 2 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 3 |
exports.SelectColumn = exports.RowSelectVariant = void 0; |
| 4 |
const tslib_1 = require("tslib"); |
| 5 |
const jsx_runtime_1 = require("react/jsx-runtime"); |
| 6 |
const react_1 = require("react"); |
| 7 |
const Tooltip_1 = require('@patternfly/react-core/dist/js/components/Tooltip'); |
| 8 |
const Checkbox_1 = require('@patternfly/react-core/dist/js/components/Checkbox'); |
| 9 |
const Radio_1 = require('@patternfly/react-core/dist/js/components/Radio'); |
| 10 |
var RowSelectVariant; |
| 11 |
(function (RowSelectVariant) { |
| 12 |
RowSelectVariant["radio"] = "radio"; |
| 13 |
RowSelectVariant["checkbox"] = "checkbox"; |
| 14 |
})(RowSelectVariant || (exports.RowSelectVariant = RowSelectVariant = {})); |
| 15 |
const SelectColumn = (_a) => { |
| 16 |
var { children = null, |
| 17 |
// eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 18 |
className, onSelect = null, selectVariant, tooltip, tooltipProps, id, name, isIndeterminate } = _a, props = tslib_1.__rest(_a, ["children", "className", "onSelect", "selectVariant", "tooltip", "tooltipProps", "id", "name", "isIndeterminate"]); |
| 19 |
const inputRef = (0, react_1.createRef)(); |
| 20 |
const handleChange = (event, _checked) => { |
| 21 |
onSelect && onSelect(event); |
| 22 |
}; |
| 23 |
const commonProps = Object.assign(Object.assign({}, props), { id, ref: inputRef, onChange: handleChange }); |
| 24 |
const checkboxProps = Object.assign(Object.assign({}, commonProps), (isIndeterminate && { isChecked: null })); |
| 25 |
const content = ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [selectVariant === RowSelectVariant.checkbox ? ((0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, Object.assign({}, checkboxProps))) : ((0, jsx_runtime_1.jsx)(Radio_1.Radio, Object.assign({}, commonProps, { name: name }))), children] })); |
| 26 |
return tooltip ? ((0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, Object.assign({ triggerRef: inputRef, content: tooltip }, tooltipProps, { children: content }))) : (content); |
| 27 |
}; |
| 28 |
exports.SelectColumn = SelectColumn; |
| 29 |
exports.SelectColumn.displayName = 'SelectColumn'; |
| 30 |
//# sourceMappingURL=SelectColumn.js.map |