| 1 |
import { __rest } from "tslib"; |
| 2 |
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; |
| 3 |
import { useState } from 'react'; |
| 4 |
import LongArrowAltUpIcon from '@patternfly/react-icons/dist/esm/icons/long-arrow-alt-up-icon'; |
| 5 |
import LongArrowAltDownIcon from '@patternfly/react-icons/dist/esm/icons/long-arrow-alt-down-icon'; |
| 6 |
import ArrowsAltVIcon from '@patternfly/react-icons/dist/esm/icons/arrows-alt-v-icon'; |
| 7 |
import { css } from '@patternfly/react-styles'; |
| 8 |
import styles from '@patternfly/react-styles/css/components/Table/table.mjs'; |
| 9 |
import { TableText } from './TableText'; |
| 10 |
import { ActionList, ActionListItem } from '@patternfly/react-core/dist/esm/components/ActionList'; |
| 11 |
import { Button } from '@patternfly/react-core/dist/esm/components/Button'; |
| 12 |
export var SortByDirection; |
| 13 |
(function (SortByDirection) { |
| 14 |
SortByDirection["asc"] = "asc"; |
| 15 |
SortByDirection["desc"] = "desc"; |
| 16 |
})(SortByDirection || (SortByDirection = {})); |
| 17 |
export const SortColumn = (_a) => { |
| 18 |
var { children = null, className = '', isSortedBy = false, onSort = null, sortDirection = '', type = 'button', tooltip, tooltipProps, tooltipHasDefaultBehavior, favoriteButtonProps } = _a, props = __rest(_a, ["children", "className", "isSortedBy", "onSort", "sortDirection", "type", "tooltip", "tooltipProps", "tooltipHasDefaultBehavior", "favoriteButtonProps"]); |
| 19 |
let SortedByIcon; |
| 20 |
const [focused, setFocused] = useState(false); |
| 21 |
if (isSortedBy) { |
| 22 |
SortedByIcon = sortDirection === SortByDirection.asc ? LongArrowAltUpIcon : LongArrowAltDownIcon; |
| 23 |
} |
| 24 |
else { |
| 25 |
SortedByIcon = ArrowsAltVIcon; |
| 26 |
} |
| 27 |
if (favoriteButtonProps) { |
| 28 |
const { favorited } = favoriteButtonProps, rest = __rest(favoriteButtonProps, ["favorited"]); |
| 29 |
return (_jsxs(ActionList, { isIconList: true, children: [_jsx(ActionListItem, { children: _jsx(Button, Object.assign({ variant: "plain", isFavorite: true, isFavorited: favorited }, rest)) }), _jsx(ActionListItem, { children: _jsx(Button, Object.assign({ variant: "plain", icon: _jsx("span", { className: css(styles.tableSortIndicator), children: _jsx(SortedByIcon, {}) }), onClick: (event) => onSort && onSort(event) }, props)) })] })); |
| 30 |
} |
| 31 |
return (_jsx("button", Object.assign({}, props, { type: type, className: css(className, styles.tableButton), onClick: (event) => onSort && onSort(event), onFocus: () => setFocused(true), onBlur: () => setFocused(false), children: _jsxs("div", { className: css(className, styles.tableButtonContent), children: [_jsx(TableText, { tooltip: tooltip, tooltipProps: tooltipProps, tooltipHasDefaultBehavior: tooltipHasDefaultBehavior, focused: focused, children: children }), _jsx("span", { className: css(styles.tableSortIndicator), children: _jsx(SortedByIcon, {}) })] }) }))); |
| 32 |
}; |
| 33 |
SortColumn.displayName = 'SortColumn'; |
| 34 |
//# sourceMappingURL=SortColumn.js.map |