| 1 |
import { __rest } from "tslib"; |
| 2 |
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; |
| 3 |
import { createRef, Fragment } from 'react'; |
| 4 |
import { Tooltip } from '@patternfly/react-core/dist/esm/components/Tooltip'; |
| 5 |
import { Checkbox } from '@patternfly/react-core/dist/esm/components/Checkbox'; |
| 6 |
import { Radio } from '@patternfly/react-core/dist/esm/components/Radio'; |
| 7 |
export var RowSelectVariant; |
| 8 |
(function (RowSelectVariant) { |
| 9 |
RowSelectVariant["radio"] = "radio"; |
| 10 |
RowSelectVariant["checkbox"] = "checkbox"; |
| 11 |
})(RowSelectVariant || (RowSelectVariant = {})); |
| 12 |
export const SelectColumn = (_a) => { |
| 13 |
var { children = null, |
| 14 |
// eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 15 |
className, onSelect = null, selectVariant, tooltip, tooltipProps, id, name, isIndeterminate } = _a, props = __rest(_a, ["children", "className", "onSelect", "selectVariant", "tooltip", "tooltipProps", "id", "name", "isIndeterminate"]); |
| 16 |
const inputRef = createRef(); |
| 17 |
const handleChange = (event, _checked) => { |
| 18 |
onSelect && onSelect(event); |
| 19 |
}; |
| 20 |
const commonProps = Object.assign(Object.assign({}, props), { id, ref: inputRef, onChange: handleChange }); |
| 21 |
const checkboxProps = Object.assign(Object.assign({}, commonProps), (isIndeterminate && { isChecked: null })); |
| 22 |
const content = (_jsxs(Fragment, { children: [selectVariant === RowSelectVariant.checkbox ? (_jsx(Checkbox, Object.assign({}, checkboxProps))) : (_jsx(Radio, Object.assign({}, commonProps, { name: name }))), children] })); |
| 23 |
return tooltip ? (_jsx(Tooltip, Object.assign({ triggerRef: inputRef, content: tooltip }, tooltipProps, { children: content }))) : (content); |
| 24 |
}; |
| 25 |
SelectColumn.displayName = 'SelectColumn'; |
| 26 |
//# sourceMappingURL=SelectColumn.js.map |