| 1 |
"use strict"; |
| 2 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 3 |
exports.SortColumn = exports.SortByDirection = 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 long_arrow_alt_up_icon_1 = tslib_1.__importDefault(require('@patternfly/react-icons/dist/js/icons/long-arrow-alt-up-icon')); |
| 8 |
const long_arrow_alt_down_icon_1 = tslib_1.__importDefault(require('@patternfly/react-icons/dist/js/icons/long-arrow-alt-down-icon')); |
| 9 |
const arrows_alt_v_icon_1 = tslib_1.__importDefault(require('@patternfly/react-icons/dist/js/icons/arrows-alt-v-icon')); |
| 10 |
const react_styles_1 = require("@patternfly/react-styles"); |
| 11 |
const table_1 = tslib_1.__importDefault(require("@patternfly/react-styles/css/components/Table/table")); |
| 12 |
const TableText_1 = require("./TableText"); |
| 13 |
const ActionList_1 = require('@patternfly/react-core/dist/js/components/ActionList'); |
| 14 |
const Button_1 = require('@patternfly/react-core/dist/js/components/Button'); |
| 15 |
var SortByDirection; |
| 16 |
(function (SortByDirection) { |
| 17 |
SortByDirection["asc"] = "asc"; |
| 18 |
SortByDirection["desc"] = "desc"; |
| 19 |
})(SortByDirection || (exports.SortByDirection = SortByDirection = {})); |
| 20 |
const SortColumn = (_a) => { |
| 21 |
var { children = null, className = '', isSortedBy = false, onSort = null, sortDirection = '', type = 'button', tooltip, tooltipProps, tooltipHasDefaultBehavior, favoriteButtonProps } = _a, props = tslib_1.__rest(_a, ["children", "className", "isSortedBy", "onSort", "sortDirection", "type", "tooltip", "tooltipProps", "tooltipHasDefaultBehavior", "favoriteButtonProps"]); |
| 22 |
let SortedByIcon; |
| 23 |
const [focused, setFocused] = (0, react_1.useState)(false); |
| 24 |
if (isSortedBy) { |
| 25 |
SortedByIcon = sortDirection === SortByDirection.asc ? long_arrow_alt_up_icon_1.default : long_arrow_alt_down_icon_1.default; |
| 26 |
} |
| 27 |
else { |
| 28 |
SortedByIcon = arrows_alt_v_icon_1.default; |
| 29 |
} |
| 30 |
if (favoriteButtonProps) { |
| 31 |
const { favorited } = favoriteButtonProps, rest = tslib_1.__rest(favoriteButtonProps, ["favorited"]); |
| 32 |
return ((0, jsx_runtime_1.jsxs)(ActionList_1.ActionList, { isIconList: true, children: [(0, jsx_runtime_1.jsx)(ActionList_1.ActionListItem, { children: (0, jsx_runtime_1.jsx)(Button_1.Button, Object.assign({ variant: "plain", isFavorite: true, isFavorited: favorited }, rest)) }), (0, jsx_runtime_1.jsx)(ActionList_1.ActionListItem, { children: (0, jsx_runtime_1.jsx)(Button_1.Button, Object.assign({ variant: "plain", icon: (0, jsx_runtime_1.jsx)("span", { className: (0, react_styles_1.css)(table_1.default.tableSortIndicator), children: (0, jsx_runtime_1.jsx)(SortedByIcon, {}) }), onClick: (event) => onSort && onSort(event) }, props)) })] })); |
| 33 |
} |
| 34 |
return ((0, jsx_runtime_1.jsx)("button", Object.assign({}, props, { type: type, className: (0, react_styles_1.css)(className, table_1.default.tableButton), onClick: (event) => onSort && onSort(event), onFocus: () => setFocused(true), onBlur: () => setFocused(false), children: (0, jsx_runtime_1.jsxs)("div", { className: (0, react_styles_1.css)(className, table_1.default.tableButtonContent), children: [(0, jsx_runtime_1.jsx)(TableText_1.TableText, { tooltip: tooltip, tooltipProps: tooltipProps, tooltipHasDefaultBehavior: tooltipHasDefaultBehavior, focused: focused, children: children }), (0, jsx_runtime_1.jsx)("span", { className: (0, react_styles_1.css)(table_1.default.tableSortIndicator), children: (0, jsx_runtime_1.jsx)(SortedByIcon, {}) })] }) }))); |
| 35 |
}; |
| 36 |
exports.SortColumn = SortColumn; |
| 37 |
exports.SortColumn.displayName = 'SortColumn'; |
| 38 |
//# sourceMappingURL=SortColumn.js.map |