@tableus/ui-bootstrap5
Version:
A Bootstrap 5 UI for tableus.
61 lines • 2.84 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.initTableComponents = void 0;
require("./styles.css");
const react_1 = __importDefault(require("react"));
const react_bootstrap_icons_1 = require("react-bootstrap-icons");
const react_bootstrap_1 = require("react-bootstrap");
const pagination_1 = require("./pagination");
const filtering_1 = require("./filtering");
const DEFAULT_EMPTY_VALUE = "-";
function initTableComponents(configArg) {
const config = Object.assign({
tableProps: {},
emptyValue: DEFAULT_EMPTY_VALUE,
}, configArg);
return {
Table: (props) => {
const className = props.fetcherState.isLoading ? "bs5-filter-blur" : "";
return (react_1.default.createElement(react_bootstrap_1.Table, Object.assign({}, config.tableProps, { className: className }), props.children));
},
TableHead: (props) => {
return react_1.default.createElement("thead", null, props.children);
},
TableHeadRow: (props) => {
return react_1.default.createElement("tr", null, props.children);
},
TableHeadCell: ({ getCanSort, getToggleSortingHandler, getIsSorted, tableConfig, children, }) => {
const canSort = tableConfig.sorting === true && getCanSort();
let sortIcon = null;
if (canSort && getIsSorted()) {
sortIcon =
getIsSorted() === "asc" ? (react_1.default.createElement(react_bootstrap_icons_1.SortUp, { size: 16 })) : (react_1.default.createElement(react_bootstrap_icons_1.SortDown, { size: 16 }));
}
const thProps = canSort
? { role: "button", onClick: getToggleSortingHandler() }
: {};
return (react_1.default.createElement("th", Object.assign({}, thProps),
react_1.default.createElement("div", { className: "d-flex justify-content-between align-items-center" },
children,
sortIcon)));
},
TableBody: (props) => {
return react_1.default.createElement("tbody", null, props.children);
},
TableRow: (props) => {
return react_1.default.createElement("tr", null, props.children);
},
TableCell: (props) => {
return react_1.default.createElement("td", null, props.children);
},
TablePagination: pagination_1.Pagination,
SelectFilter: filtering_1.SelectFilter,
SearchFilter: filtering_1.SearchFilter,
CheckFilter: filtering_1.CheckFilter,
};
}
exports.initTableComponents = initTableComponents;
//# sourceMappingURL=index.js.map
;