lucid-ui
Version:
A UI component library from AppNexus.
320 lines • 30.9 kB
JavaScript
"use strict";
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataTable = void 0;
/* eslint-disable react/prop-types */
var lodash_1 = __importDefault(require("lodash"));
var react_1 = __importStar(require("react"));
var prop_types_1 = __importDefault(require("react-peek/prop-types"));
var style_helpers_1 = require("../../util/style-helpers");
var component_types_1 = require("../../util/component-types");
var Checkbox_1 = __importDefault(require("../Checkbox/Checkbox"));
var EmptyStateWrapper_1 = __importDefault(require("../EmptyStateWrapper/EmptyStateWrapper"));
var ScrollTable_1 = __importDefault(require("../ScrollTable/ScrollTable"));
var Table_1 = __importDefault(require("../Table/Table"));
var Thead = ScrollTable_1.default.Thead, Tbody = ScrollTable_1.default.Tbody, Tr = ScrollTable_1.default.Tr, Th = ScrollTable_1.default.Th, Td = ScrollTable_1.default.Td;
var cx = style_helpers_1.lucidClassNames.bind('&-DataTable');
var cxe = style_helpers_1.lucidClassNames.bind('&-DataTable-EmptyStateWrapper');
var SELECTOR_COLUMN_WIDTH = 41;
var any = prop_types_1.default.any, func = prop_types_1.default.func, number = prop_types_1.default.number, object = prop_types_1.default.object, stringProps = prop_types_1.default.string, bool = prop_types_1.default.bool, arrayOf = prop_types_1.default.arrayOf;
var defaultProps = {
emptyCellText: '--',
isActionable: false,
isSelectable: false,
onRowClick: lodash_1.default.noop,
onSelect: lodash_1.default.noop,
onSelectAll: lodash_1.default.noop,
onSort: lodash_1.default.noop,
minRows: 10,
hasFixedHeader: false,
fixedColumnCount: 0,
};
var defaultState = {
// Represents the actively changing width as the cell is resized.
activeWidth: {},
};
var DataTable = function (props) {
var _a = react_1.useState(defaultState), state = _a[0], setState = _a[1];
var fixedHeaderUnfixedColumnsRef;
var fixedBodyFixedColumnsRef;
var handleSelect = function (rowIndex, _a) {
var event = _a.event;
var data = props.data, onSelect = props.onSelect;
onSelect(data[rowIndex], rowIndex, { props: props, event: event });
};
var handleSelectAll = function (_a) {
var event = _a.event;
var onSelectAll = props.onSelectAll;
onSelectAll({ props: props, event: event });
};
var handleRowClick = function (rowIndex, event) {
var data = props.data, onRowClick = props.onRowClick;
var targetTagName = event.target.tagName.toLowerCase();
if (targetTagName === 'td' || targetTagName === 'tr') {
onRowClick(data[rowIndex], rowIndex, { props: props, event: event });
}
};
var handleSort = function (field, event) {
var onSort = props.onSort;
event.stopPropagation();
event.preventDefault();
event.bubbles = false;
onSort(field, { props: props, event: event });
};
var handleFixedBodyUnfixedColumnsScroll = function (event) {
fixedHeaderUnfixedColumnsRef &&
(fixedHeaderUnfixedColumnsRef.scrollLeft = event.target.scrollLeft);
fixedBodyFixedColumnsRef &&
(fixedBodyFixedColumnsRef.scrollTop = event.target.scrollTop);
};
var handleResize = function (columnWidth, _a) {
var field = _a.props.field;
// setting latest column width to Tbody
setState(function (state) {
var _a;
return ({
activeWidth: __assign(__assign({}, state.activeWidth), (_a = {}, _a[field] = columnWidth, _a)),
});
});
};
var renderHeader = function (startColumn, endColumn, childComponentElements, flattenedColumns) {
var isSelectable = props.isSelectable, data = props.data, truncateContent = props.truncateContent;
var hasGroupedColumns = lodash_1.default.some(childComponentElements, function (childComponentElement) {
return childComponentElement.type === exports.DataTable.ColumnGroup;
});
var columnSlicer = lodash_1.default.flow(lodash_1.default.compact, function (columns) {
return lodash_1.default.slice(columns, startColumn, endColumn);
});
var allSelected = lodash_1.default.every(data, 'isSelected');
return (react_1.default.createElement(Thead, null,
react_1.default.createElement(Tr, null, columnSlicer([
isSelectable ? (react_1.default.createElement(Th, { key: cx('&-row-selector'), rowSpan: hasGroupedColumns ? 2 : null, width: SELECTOR_COLUMN_WIDTH },
react_1.default.createElement(Checkbox_1.default, { isDisabled: !data || !data.length, isSelected: !!data && data.length > 0 && allSelected, isIndeterminate: !allSelected && !!data.find(function (d) { return d.isSelected; }), onSelect: handleSelectAll }))) : null,
].concat(lodash_1.default.map(childComponentElements, function (_a, index) {
var props = _a.props, type = _a.type;
return type === exports.DataTable.Column ? (react_1.default.createElement(Th, __assign({ onResize: props.isResizable ? handleResize : null }, lodash_1.default.omit(props, ['children', 'title']), { onClick: exports.DataTable.shouldColumnHandleSort(props)
? lodash_1.default.partial(handleSort, props.field)
: null, rowSpan: hasGroupedColumns ? 2 : null, field: props.field || index, key: lodash_1.default.get(props, 'field', index), truncateContent: truncateContent }), props.title || props.children)) : (react_1.default.createElement(Th, __assign({ colSpan: lodash_1.default.size(component_types_1.filterTypes(props.children, exports.DataTable.Column)) }, lodash_1.default.omit(props, ['field', 'children', 'width', 'title']), { key: lodash_1.default.get(props, 'field', index) }), props.title || props.children));
})))),
hasGroupedColumns ? (react_1.default.createElement(Tr, null, lodash_1.default.reduce(flattenedColumns, function (acc, _a, index) {
var columnProps = _a.props, columnGroupProps = _a.columnGroupProps;
return acc.concat(lodash_1.default.isNull(columnGroupProps)
? []
: [
react_1.default.createElement(Th, __assign({}, component_types_1.omitProps(columnProps, undefined, lodash_1.default.keys(exports.DataTable.Column.propTypes), false), { onClick: exports.DataTable.shouldColumnHandleSort(columnProps)
? lodash_1.default.partial(handleSort, columnProps.field)
: null, style: {
width: columnProps.width,
}, key: lodash_1.default.get(columnProps, 'field', index) }), columnProps.title || columnProps.children),
]);
}, []))) : null));
};
var renderBody = function (startColumn, endColumn, flattenedColumns) {
var data = props.data, isSelectable = props.isSelectable, isActionable = props.isActionable, minRows = props.minRows, emptyCellText = props.emptyCellText, fixedRowHeight = props.fixedRowHeight, truncateContent = props.truncateContent;
var fillerRowCount = lodash_1.default.clamp(minRows - lodash_1.default.size(data), 0, Infinity);
var isFixedColumn = endColumn < Infinity;
var columnSlicer = lodash_1.default.flow(lodash_1.default.compact, function (columns) {
return lodash_1.default.slice(columns, startColumn, endColumn);
});
return (react_1.default.createElement(Tbody, null,
lodash_1.default.map(data, function (row, index) { return (react_1.default.createElement(Tr, __assign({}, lodash_1.default.pick(row, ['isDisabled', 'isActive', 'isSelected']), { isActionable: isActionable, onClick: lodash_1.default.partial(handleRowClick, index), key: 'row' + index, style: lodash_1.default.assign(row.style, fixedRowHeight ? { height: fixedRowHeight } : {}) }), columnSlicer([
isSelectable ? (react_1.default.createElement(Td, { key: cx('&-row-selector'), width: SELECTOR_COLUMN_WIDTH, hasBorderRight: isFixedColumn && flattenedColumns.length === 0 },
react_1.default.createElement(Checkbox_1.default, { isSelected: row.isSelected, onSelect: lodash_1.default.partial(handleSelect, index) }))) : null,
].concat(lodash_1.default.map(flattenedColumns, function (_a, columnIndex) {
var columnProps = _a.props;
var cellValue = lodash_1.default.get(row, columnProps.field);
var isEmpty = lodash_1.default.isEmpty(lodash_1.default.toString(cellValue));
var currentWidth = state.activeWidth[columnProps.field || columnIndex] ||
columnProps.width;
return (react_1.default.createElement(Td, __assign({}, lodash_1.default.omit(columnProps, [
'field',
'children',
'width',
'title',
'isSortable',
'isSorted',
'isResizable',
]), { hasBorderRight: !lodash_1.default.isNil(columnProps.hasBorderRight)
? columnProps.hasBorderRight
: isFixedColumn &&
columnIndex + 1 + (isSelectable ? 1 : 0) ===
endColumn, style: { width: currentWidth }, key: 'row' +
index +
lodash_1.default.get(columnProps, 'field', columnIndex), truncateContent: truncateContent }), isEmpty
? emptyCellText
: lodash_1.default.isFunction(cellValue)
? cellValue(currentWidth)
: cellValue));
}))))); }),
lodash_1.default.times(fillerRowCount, function (index) { return (react_1.default.createElement(Tr, { isDisabled: true, key: 'row' + index, style: { height: fixedRowHeight || '32px' } }, columnSlicer([isSelectable ? react_1.default.createElement(Td, { key: cx('&-row-selector') }) : null].concat(lodash_1.default.map(flattenedColumns, function (_a, columnIndex) {
var columnProps = _a.props;
return (react_1.default.createElement(Td, __assign({}, lodash_1.default.omit(columnProps, [
'field',
'children',
'width',
'title',
'isSortable',
'isSorted',
'isResizable',
]), { style: {
width: columnProps.width,
}, key: 'row' + index + lodash_1.default.get(columnProps, 'field', columnIndex) })));
}))))); })));
};
var className = props.className, data = props.data, isFullWidth = props.isFullWidth, isLoading = props.isLoading, style = props.style, hasFixedHeader = props.hasFixedHeader, fixedColumnCount = props.fixedColumnCount, anchorMessage = props.anchorMessage, passThroughs = __rest(props, ["className", "data", "isFullWidth", "isLoading", "style", "hasFixedHeader", "fixedColumnCount", "anchorMessage"]);
var childComponentElements = component_types_1.findTypes(props, [
exports.DataTable.Column,
exports.DataTable.ColumnGroup,
]);
var flattenedColumns = lodash_1.default.reduce(childComponentElements, function (acc, childComponentElement) {
if (childComponentElement.type === exports.DataTable.Column) {
return acc.concat([
{ props: childComponentElement.props, columnGroupProps: null },
]);
}
if (childComponentElement.type === exports.DataTable.ColumnGroup) {
return acc.concat(lodash_1.default.map(component_types_1.findTypes(childComponentElement.props, exports.DataTable.Column), function (columnChildComponent) { return ({
props: columnChildComponent.props,
columnGroupProps: childComponentElement.props,
}); }));
}
}, []);
var emptyStateWrapper = component_types_1.getFirst(props, exports.DataTable.EmptyStateWrapper) || (react_1.default.createElement(exports.DataTable.EmptyStateWrapper, { Title: 'No items found.', Body: 'Try creating a new object or removing a filter.' }));
var emptyStateWrapperClassName = cxe({
'&-has-fixed-header': hasFixedHeader,
}, emptyStateWrapper.props.className);
return (react_1.default.createElement(EmptyStateWrapper_1.default, __assign({}, emptyStateWrapper.props, { isEmpty: lodash_1.default.isEmpty(data), isLoading: isLoading, className: emptyStateWrapperClassName, anchorMessage: anchorMessage }),
emptyStateWrapper.props.children,
hasFixedHeader ? (react_1.default.createElement("div", { className: cx('&-fixed') },
react_1.default.createElement("div", { className: cx('&-fixed-header') },
react_1.default.createElement("div", { className: cx('&-fixed-header-fixed-columns') }, fixedColumnCount > 0 ? (react_1.default.createElement(Table_1.default, __assign({}, component_types_1.omitProps(passThroughs, undefined, lodash_1.default.keys(exports.DataTable.propTypes), false), { style: style, className: cx('&-fixed-header-fixed-columns-Table') }), renderHeader(0, fixedColumnCount, childComponentElements, flattenedColumns))) : null),
react_1.default.createElement("div", { className: cx('&-fixed-header-unfixed-columns'), ref: function (ref) { return (fixedHeaderUnfixedColumnsRef = ref); } },
react_1.default.createElement(Table_1.default, __assign({}, component_types_1.omitProps(passThroughs, undefined, lodash_1.default.keys(exports.DataTable.propTypes), false), { style: style, className: cx('&-fixed-header-unfixed-columns-Table') }), renderHeader(fixedColumnCount, Infinity, childComponentElements, flattenedColumns)))),
react_1.default.createElement("div", { className: cx('&-fixed-body') },
react_1.default.createElement("div", { className: cx('&-fixed-body-fixed-columns'), ref: function (ref) { return (fixedBodyFixedColumnsRef = ref); } }, fixedColumnCount > 0 ? (react_1.default.createElement(Table_1.default, __assign({}, component_types_1.omitProps(passThroughs, undefined, lodash_1.default.keys(exports.DataTable.propTypes), false), { style: style, className: cx('&-fixed-body-fixed-columns-Table'), hasWordWrap: false /* try to protect against vertical overflow */ }), renderBody(0, fixedColumnCount, flattenedColumns))) : null),
react_1.default.createElement("div", { onScroll: handleFixedBodyUnfixedColumnsScroll, className: cx('&-fixed-body-unfixed-columns') },
react_1.default.createElement("span", { className: cx('&-fixed-body-unfixed-columns-shadow') }),
react_1.default.createElement(Table_1.default, __assign({}, component_types_1.omitProps(passThroughs, undefined, lodash_1.default.keys(exports.DataTable.propTypes), false), { style: style, className: cx('&-fixed-body-unfixed-columns-Table'), hasWordWrap: false /* try to protect against vertical overflow */ }), renderBody(fixedColumnCount, Infinity, flattenedColumns)))))) : (react_1.default.createElement(ScrollTable_1.default, __assign({ style: style, tableWidth: isFullWidth ? '100%' : undefined }, component_types_1.omitProps(passThroughs, undefined, lodash_1.default.keys(exports.DataTable.propTypes), false), { className: cx('&', {
'&-full-width': isFullWidth,
}, className) }),
renderHeader(0, Infinity, childComponentElements, flattenedColumns),
renderBody(0, Infinity, flattenedColumns)))));
};
exports.DataTable = DataTable;
exports.DataTable.displayName = 'DataTable';
exports.DataTable.propTypes = {
className: stringProps(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\t\tClass names that are appended to the defaults.\n\t"], ["\n\t\tClass names that are appended to the defaults.\n\t"]))),
data: arrayOf(object)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n\t\tArray of objects to be rendered in the table. Object keys match the\n\t\t`field` of each defined `DataTable.Column`.\n\t"], ["\n\t\tArray of objects to be rendered in the table. Object keys match the\n\t\t\\`field\\` of each defined \\`DataTable.Column\\`.\n\t"]))),
emptyCellText: stringProps(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n\t\tThe text to display in cells which have no data.\n\t"], ["\n\t\tThe text to display in cells which have no data.\n\t"]))),
isActionable: bool(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n\t\tRender each row item to be navigable, allowing `onRowClick` to be\n\t\ttriggered.\n\t"], ["\n\t\tRender each row item to be navigable, allowing \\`onRowClick\\` to be\n\t\ttriggered.\n\t"]))),
isFullWidth: bool(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n\t\tIf `true`, the table will be set to fill the width of its parent\n\t\tcontainer.\n\t"], ["\n\t\tIf \\`true\\`, the table will be set to fill the width of its parent\n\t\tcontainer.\n\t"]))),
isLoading: bool(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n\t\tControls the visibility of the `LoadingMessage`.\n\t"], ["\n\t\tControls the visibility of the \\`LoadingMessage\\`.\n\t"]))),
isSelectable: bool(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n\t\tRender a checkbox in the first column allowing `onSelect` and\n\t\t`onSelectAll` to be triggered.\n\t"], ["\n\t\tRender a checkbox in the first column allowing \\`onSelect\\` and\n\t\t\\`onSelectAll\\` to be triggered.\n\t"]))),
anchorMessage: bool(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n\t\tPosition the `EmptyMessage` and `LoadingMessage` near the top of the container. \n\t\tBy default, they are vertically aligned to the middle of the table. Useful\n\t\tfor tables with many rows that extend past the viewport.\n\t"], ["\n\t\tPosition the \\`EmptyMessage\\` and \\`LoadingMessage\\` near the top of the container. \n\t\tBy default, they are vertically aligned to the middle of the table. Useful\n\t\tfor tables with many rows that extend past the viewport.\n\t"]))),
style: object(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n\t\tStyles that are passed through to the root container.\n\t"], ["\n\t\tStyles that are passed through to the root container.\n\t"]))),
minRows: number(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n\t\tThe minimum number of rows to rendered. If not enough data is provided,\n\t\tthe remainder will be shown as empty rows.\n\t"], ["\n\t\tThe minimum number of rows to rendered. If not enough data is provided,\n\t\tthe remainder will be shown as empty rows.\n\t"]))),
onRowClick: func(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n\t\tHandler for row click. Signature is\n\t\t`(object, index, { props, event }) => {...}`\n\t"], ["\n\t\tHandler for row click. Signature is\n\t\t\\`(object, index, { props, event }) => {...}\\`\n\t"]))),
onSelect: func(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n\t\tHandler for checkbox selection. Signature is\n\t\t`(object, index, { props, event }) => {...}`\n\t"], ["\n\t\tHandler for checkbox selection. Signature is\n\t\t\\`(object, index, { props, event }) => {...}\\`\n\t"]))),
onSelectAll: func(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n\t\tHandler for checkbox selection in the table header. Signature is\n\t\t`({ props, event }) => {...}`\n\t"], ["\n\t\tHandler for checkbox selection in the table header. Signature is\n\t\t\\`({ props, event }) => {...}\\`\n\t"]))),
onSort: func(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n\t\tHandler for column header click (for sorting). Signature is\n\t\t`(field, { props, event }) => {...}`\n\t"], ["\n\t\tHandler for column header click (for sorting). Signature is\n\t\t\\`(field, { props, event }) => {...}\\`\n\t"]))),
hasFixedHeader: bool(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n\t\tIf `true` the table will have a fixed header set. *Note* this feature\n\t\timposes some limitations with respect to the styling and usage of your\n\t\ttable. Here are those caveats:\n\n\t\t- Each `DataTable.Column` *must* have an explicit pixel width defined\n\t\t\ton it. If the combined width of all the columns is greater than the\n\t\t\tparent container, the user will be able to horizontally scroll.\n\t\t- The outermost wrapper element emitted by this component will be set to\n\t\t\t100% height. It's your responsibility to put this component inside\n\t\t\tanother container that limits its height so that the resulting table can\n\t\t\tscroll vertically and keep the fixed headers.\n\t\t- Scroll bars will always be present. This is prevent misalignment of the\n\t\t\theader and the table body that can occur when scroll bars show up and\n\t\t\ttake width. MacOS browsers depend on OS level settings to determine how\n\t\t\tscrollbars show up. Having them always present saves us from writing a\n\t\t\tbunch of terrible code to detect scroll bars and account for their width.\n\t\t- Using fixed headers means multiple tables will be rendered under the\n\t\t\thood. We use `table-layout: fixed` behavior to make sure we can sync\n\t\t\tcolumns widths between the header and the body.\n\t\t- Does not support `DataTable.ColumnGroup`s at this time. It's possible\n\t\t\twe could support them at some point but its not a priority at the moment.\n\t\t- You have to be careful about table cell height overflow. There are\n\t\t\tcases where this can break the alignment of fixed columns.\n\t"], ["\n\t\tIf \\`true\\` the table will have a fixed header set. *Note* this feature\n\t\timposes some limitations with respect to the styling and usage of your\n\t\ttable. Here are those caveats:\n\n\t\t- Each \\`DataTable.Column\\` *must* have an explicit pixel width defined\n\t\t\ton it. If the combined width of all the columns is greater than the\n\t\t\tparent container, the user will be able to horizontally scroll.\n\t\t- The outermost wrapper element emitted by this component will be set to\n\t\t\t100% height. It's your responsibility to put this component inside\n\t\t\tanother container that limits its height so that the resulting table can\n\t\t\tscroll vertically and keep the fixed headers.\n\t\t- Scroll bars will always be present. This is prevent misalignment of the\n\t\t\theader and the table body that can occur when scroll bars show up and\n\t\t\ttake width. MacOS browsers depend on OS level settings to determine how\n\t\t\tscrollbars show up. Having them always present saves us from writing a\n\t\t\tbunch of terrible code to detect scroll bars and account for their width.\n\t\t- Using fixed headers means multiple tables will be rendered under the\n\t\t\thood. We use \\`table-layout: fixed\\` behavior to make sure we can sync\n\t\t\tcolumns widths between the header and the body.\n\t\t- Does not support \\`DataTable.ColumnGroup\\`s at this time. It's possible\n\t\t\twe could support them at some point but its not a priority at the moment.\n\t\t- You have to be careful about table cell height overflow. There are\n\t\t\tcases where this can break the alignment of fixed columns.\n\t"]))),
fixedColumnCount: number(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n\t\tSets the number of columns you want to have fixed. You must specify\n\t\t`fixedRowHeight` and enable `hasFixedHeader`when setting this prop.\n\t"], ["\n\t\tSets the number of columns you want to have fixed. You must specify\n\t\t\\`fixedRowHeight\\` and enable \\`hasFixedHeader\\`when setting this prop.\n\t"]))),
fixedRowHeight: number(templateObject_17 || (templateObject_17 = __makeTemplateObject(["\n\t\tDetermines the height of every row in the DataTable. It's required when\n\t\tusing the `fixedColumnCount` prop.\n\t"], ["\n\t\tDetermines the height of every row in the DataTable. It's required when\n\t\tusing the \\`fixedColumnCount\\` prop.\n\t"]))),
truncateContent: bool(templateObject_18 || (templateObject_18 = __makeTemplateObject(["\n\t\tTruncates `Table.Td` content with ellipses, must be used with `hasFixedHeader`\n\t"], ["\n\t\tTruncates \\`Table.Td\\` content with ellipses, must be used with \\`hasFixedHeader\\`\n\t"]))),
Column: any(templateObject_19 || (templateObject_19 = __makeTemplateObject(["\n\t\t*Child Element*\n\n\t\tUsed to define a column of the table. It accepts the same props as\n\t\t`Table.Th` in addition to:\n\n\t\t- the required prop `field`\n\t\t- the optional prop `title`\n\t"], ["\n\t\t*Child Element*\n\n\t\tUsed to define a column of the table. It accepts the same props as\n\t\t\\`Table.Th\\` in addition to:\n\n\t\t- the required prop \\`field\\`\n\t\t- the optional prop \\`title\\`\n\t"]))),
ColumnGroup: any(templateObject_20 || (templateObject_20 = __makeTemplateObject(["\n\t\t*Child Element*\n\n\t\t_Note_: column groups are *not* compatible with `hasFixedHeader`.\n\n\t\tUsed to Group defined `Column`s in the table. It accepts the same props\n\t\tas `Table.Th` in addition to:\n\n\t\t- the optional prop `title`\n\t"], ["\n\t\t*Child Element*\n\n\t\t_Note_: column groups are *not* compatible with \\`hasFixedHeader\\`.\n\n\t\tUsed to Group defined \\`Column\\`s in the table. It accepts the same props\n\t\tas \\`Table.Th\\` in addition to:\n\n\t\t- the optional prop \\`title\\`\n\t"]))),
};
exports.DataTable.defaultProps = defaultProps;
exports.DataTable.peek = {
description: "\n\t\t`DataTable` provides a simple abstraction over the `Table`\n\t\tcomponent to make it easier to define data-driven tables and render an\n\t\tarray of objects.\n\t",
notes: {
overview: "\n\t\t\t`DataTable` provides a simple abstraction over the `Table`\n\t\t\tcomponent to make it easier to define data-driven tables and render an\n\t\t\tarray of objects.\n\t\t",
intendedUse: "\n\t\t\t`DataTable` is optimized for our two main uses, full page and in-line tables.\n\n\t\t\t**Full page table**\n\t\t\t\n\t\t\tTables that cover the entire page, or are the main focus on the page. Generally used for managing and monitoring objects.\n\t\t\t\n\t\t\t**In-line tables**\n\t\t\t\n\t\t\tTables insides containers such as `Dialog` or `Panel`. Generally used for details panels and actions dialogs.\n\t\t\t\t\t\t\t\t\n\t\t\t**Styling notes**\n\t\t\t\n\t\t\t- Preferred column alignment shown in `basic` example, column header alignment should match column content\n\t\t\t\t- strings left-aligned\n\t\t\t\t- currency right-aligned\n\t\t\t\t- icons/buttons centered\n\t\t\t- Use grey footer for full page tables, `hasLightFooter={false}`\n\t\t\t- Use white footer for in-line tables, `hasLightFooter={true}`\n\t\t",
technicalRecommendations: "\n\t\t\t- There is a pre-styled state for tables with no data, see the `empty` example\n\t\t\t- There should be no row hover state if the rows are not clickable, see example (?)\n\t\t",
},
categories: ['table'],
madeFrom: ['Checkbox', 'EmptyStateWrapper', 'ScrollTable'],
};
exports.DataTable.EmptyStateWrapper = EmptyStateWrapper_1.default;
// type IColumnProps = Overwrite<typeof Th, IColumnPropsRaw>;
var Column = function (props) {
return null;
};
Column.displayName = 'DataTable.Column';
Column.peek = {
description: "\n\t\tRenders a `Th` for the table. It accepts all the props of `Table.Th`\n\t",
};
Column.propTypes = {
field: stringProps.isRequired,
title: stringProps,
isResizable: bool,
};
exports.DataTable.Column = Column;
var ColumnGroup = function (_a) {
var children = _a.children;
return children;
};
ColumnGroup.displayName = 'DataTable.ColumnGroup';
ColumnGroup.peek = {
description: "\n\t\tRenders a group of `Th`s. It accepts all the props of Table.Th\n\t",
};
ColumnGroup.propTypes = {
title: stringProps,
};
ColumnGroup.defaultProps = {
align: 'center',
};
exports.DataTable.ColumnGroup = ColumnGroup;
exports.DataTable.shouldColumnHandleSort = function (column) {
return lodash_1.default.isNil(column.isSortable) ? column.isSorted : column.isSortable;
};
exports.default = exports.DataTable;
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16, templateObject_17, templateObject_18, templateObject_19, templateObject_20;
//# sourceMappingURL=DataTable.js.map