react-tablize
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -30,8 +30,6 @@ import * as React from 'react'; | ||
export declare class TableRowProps<T> { | ||
key?: React.Key; | ||
className?: string; | ||
style?: React.CSSProperties; | ||
children: RowContent<T>; | ||
export interface TableRowProps<T> extends React.DivProps { | ||
children?: RowContent<T>; | ||
} | ||
export declare class TableRow<T> extends React.PureComponent<TableRowProps<T>> { } | ||
@@ -47,9 +45,5 @@ | ||
export declare class TableCellProps<T> { | ||
export interface TableCellProps<T> extends React.DivProps { | ||
children?: CellContent; | ||
className?: string; | ||
style?: React.CSSProperties; | ||
title?: string; | ||
visible?: boolean; | ||
onClick?: VoidFunction; | ||
} | ||
@@ -130,2 +124,4 @@ | ||
type DivProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>; | ||
type Constructor<T> = new (...args: any[]) => T; | ||
@@ -132,0 +128,0 @@ |
@@ -103,3 +103,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
\***********************************/ | ||
/*! exports provided: GridViewProps, GridView, ColumnBodyProps, ColumnBody, ColumnHeadProps, ColumnHead, TableBodyProps, TableBody, TableCellProps, TableCell, TableColumnProps, TableColumn, TableHeadProps, TableHead, TableRowProps, TableRow, TableViewProps, TableView */ | ||
/*! exports provided: GridViewProps, GridView, ColumnBodyProps, ColumnBody, ColumnHeadProps, ColumnHead, TableBodyProps, TableBody, TableCell, TableColumnProps, TableColumn, TableHeadProps, TableHead, TableRow, TableViewProps, TableView */ | ||
/*! ModuleConcatenation bailout: Cannot concat with external "@emotion/styled" (<- Module is not an ECMAScript module) */ | ||
@@ -276,2 +276,4 @@ /*! ModuleConcatenation bailout: Cannot concat with external "emotion-theming" (<- Module is not an ECMAScript module) */ | ||
function TableCell_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function TableCell_possibleConstructorReturn(self, call) { if (call && (TableCell_typeof(call) === "object" || typeof call === "function")) { return call; } return TableCell_assertThisInitialized(self); } | ||
@@ -287,24 +289,3 @@ | ||
function TableCell_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function TableCell_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var TableCellProps = function TableCellProps(initial) { | ||
TableCell_classCallCheck(this, TableCellProps); | ||
TableCell_defineProperty(this, "children", void 0); | ||
TableCell_defineProperty(this, "className", void 0); | ||
TableCell_defineProperty(this, "style", void 0); | ||
TableCell_defineProperty(this, "title", void 0); | ||
TableCell_defineProperty(this, "visible", true); | ||
TableCell_defineProperty(this, "onClick", void 0); | ||
Object.assign(this, initial); | ||
}; | ||
var TableCell = | ||
@@ -400,2 +381,4 @@ /*#__PURE__*/ | ||
function TableRow_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function TableRow_possibleConstructorReturn(self, call) { if (call && (TableRow_typeof(call) === "object" || typeof call === "function")) { return call; } return TableRow_assertThisInitialized(self); } | ||
@@ -411,18 +394,3 @@ | ||
function TableRow_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function TableRow_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var TableRowProps = function TableRowProps() { | ||
TableRow_classCallCheck(this, TableRowProps); | ||
TableRow_defineProperty(this, "key", void 0); | ||
TableRow_defineProperty(this, "className", void 0); | ||
TableRow_defineProperty(this, "style", void 0); | ||
TableRow_defineProperty(this, "children", void 0); | ||
}; | ||
var TableRow = | ||
@@ -534,6 +502,14 @@ /*#__PURE__*/ | ||
reactUtils_createClass(ReactUtils, null, [{ | ||
key: "elementInstanceOf", | ||
key: "getProps", | ||
// | ||
// props | ||
// | ||
value: function getProps(elem) { | ||
return elem && elem.props || {}; | ||
} // | ||
// react element | ||
// | ||
}, { | ||
key: "elementInstanceOf", | ||
value: function elementInstanceOf(elem, type) { | ||
@@ -624,2 +600,6 @@ if (!elem) return false; | ||
} | ||
function cssSizeString(size) { | ||
if (Number.isFinite(size)) return size + 'px'; | ||
return size; | ||
} | ||
// EXTERNAL MODULE: external "@emotion/styled" | ||
@@ -733,2 +713,8 @@ var styled_ = __webpack_require__("@emotion/styled"); | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
function TableView_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
@@ -859,10 +845,9 @@ | ||
if (!cellProps.visible) return null; | ||
if (cellProps.visible === false) return null; | ||
var cellContent = _this2.getHeadCellContent(headCell); | ||
return external_react_["createElement"](StyledTableHeadCell, { | ||
key: index, | ||
style: cellProps.style | ||
}, external_react_["createElement"](ErrorBoundary_ErrorBoundary, null, cellContent)); | ||
return external_react_["createElement"](StyledTableHeadCell, _extends({ | ||
key: index | ||
}, cellProps), external_react_["createElement"](ErrorBoundary_ErrorBoundary, null, cellContent)); | ||
})))); | ||
@@ -919,3 +904,5 @@ } | ||
var rowProps = _this3.getRowProps(row); | ||
var _this3$getRowProps = _this3.getRowProps(row), | ||
rowStyle = _this3$getRowProps.style, | ||
rowProps = _objectWithoutProperties(_this3$getRowProps, ["style"]); | ||
@@ -926,17 +913,12 @@ var rowKey = _this3.getRowKey(rowProps, item, index); | ||
return external_react_["createElement"](StyledTableBodyRow, { | ||
className: rowProps.className, | ||
style: Object.assign({}, style, rowProps.style || {}), | ||
return external_react_["createElement"](StyledTableBodyRow, _extends({ | ||
style: Object.assign({}, style, rowStyle || {}), | ||
key: rowKey | ||
}, external_react_["createElement"](ErrorBoundary_ErrorBoundary, null, asArray(rowContent).map(function (cell, columnIndex) { | ||
}, rowProps), external_react_["createElement"](ErrorBoundary_ErrorBoundary, null, asArray(rowContent).map(function (cell, columnIndex) { | ||
var cellProps = _this3.getCellProps(cell); | ||
if (!cellProps.visible) return null; | ||
return external_react_["createElement"](StyledTableBodyCell, { | ||
key: columnIndex, | ||
className: cellProps.className, | ||
style: cellProps.style, | ||
title: cellProps.title, | ||
onClick: cellProps.onClick | ||
}, external_react_["createElement"](ErrorBoundary_ErrorBoundary, null, _this3.getCellContent(cell))); | ||
if (cellProps.visible === false) return null; | ||
return external_react_["createElement"](StyledTableBodyCell, _extends({ | ||
key: columnIndex | ||
}, cellProps), external_react_["createElement"](ErrorBoundary_ErrorBoundary, null, _this3.getCellContent(cell))); | ||
}))); | ||
@@ -973,2 +955,5 @@ }); | ||
height = cssSizeString(height); | ||
minHeight = cssSizeString(minHeight); | ||
maxHeight = cssSizeString(maxHeight); | ||
return { | ||
@@ -1027,7 +1012,6 @@ height: height, | ||
value: function getHeadCellProps(cell) { | ||
if (reactUtils_ReactUtils.elementInstanceOf(cell, TableCell)) { | ||
return new TableCellProps(cell.props); | ||
} | ||
// cell element | ||
if (reactUtils_ReactUtils.elementInstanceOf(cell, TableCell)) return cell.props || {}; // default props | ||
return new TableCellProps(); | ||
return {}; | ||
} | ||
@@ -1056,5 +1040,5 @@ }, { | ||
value: function getRowProps(row) { | ||
if (reactUtils_ReactUtils.elementInstanceOf(row, TableRow)) return row.props; // default props | ||
if (reactUtils_ReactUtils.elementInstanceOf(row, TableRow)) return row.props || {}; // default props | ||
return new TableRowProps(); | ||
return {}; | ||
} | ||
@@ -1094,5 +1078,5 @@ }, { | ||
// cell element | ||
if (reactUtils_ReactUtils.elementInstanceOf(cell, TableCell)) return new TableCellProps(cell.props); // default props | ||
if (reactUtils_ReactUtils.elementInstanceOf(cell, TableCell)) return cell.props || {}; // default props | ||
return new TableCellProps(); | ||
return {}; | ||
} | ||
@@ -1147,3 +1131,2 @@ }, { | ||
/* concated harmony reexport TableBody */__webpack_require__.d(__webpack_exports__, "TableBody", function() { return TableBody; }); | ||
/* concated harmony reexport TableCellProps */__webpack_require__.d(__webpack_exports__, "TableCellProps", function() { return TableCellProps; }); | ||
/* concated harmony reexport TableCell */__webpack_require__.d(__webpack_exports__, "TableCell", function() { return TableCell; }); | ||
@@ -1154,3 +1137,2 @@ /* concated harmony reexport TableColumnProps */__webpack_require__.d(__webpack_exports__, "TableColumnProps", function() { return TableColumnProps; }); | ||
/* concated harmony reexport TableHead */__webpack_require__.d(__webpack_exports__, "TableHead", function() { return TableHead; }); | ||
/* concated harmony reexport TableRowProps */__webpack_require__.d(__webpack_exports__, "TableRowProps", function() { return TableRowProps; }); | ||
/* concated harmony reexport TableRow */__webpack_require__.d(__webpack_exports__, "TableRow", function() { return TableRow; }); | ||
@@ -1157,0 +1139,0 @@ /* concated harmony reexport TableViewProps */__webpack_require__.d(__webpack_exports__, "TableViewProps", function() { return TableViewProps; }); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("react-tablize",[],t):"object"==typeof exports?exports["react-tablize"]=t():e["react-tablize"]=t()}(this,function(){return function(n){var r={};function o(e){if(r[e])return r[e].exports;var t=r[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}return o.m=n,o.c=r,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=5)}([function(e,t){e.exports=require("react")},function(e,t){e.exports=require("emotion-theming")},function(e,t){e.exports=require("react-virtualized-auto-sizer")},function(e,t){e.exports=require("react-window")},function(e,t){e.exports=require("@emotion/styled")},function(e,t,n){e.exports=n(7)},function(e,t){e.exports=require("lodash.flattendeep")},function(e,t,n){"use strict";n.r(t);var s=n(0);function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var f=function e(){l(this,e)},a=function(e){function t(){return l(this,t),i(this,u(t).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(t,s["PureComponent"]),function(e,t,n){t&&o(e.prototype,t),n&&o(e,n)}(t,[{key:"render",value:function(){return s.createElement("h1",null,"Hi!")}}]),t}();function p(e){return(p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function y(e,t){return!t||"object"!==p(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function b(e,t){return(b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var m=function e(){d(this,e),function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(this,"children",void 0)},v=function(e){function t(){return d(this,t),y(this,h(t).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&b(e,t)}(t,s["PureComponent"]),t}();function g(e){return(g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function w(e,t){return!t||"object"!==g(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function O(e){return(O=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function j(e,t){return(j=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function P(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var C=function e(){P(this,e),_(this,"height","40px"),_(this,"children",void 0)},S=function(e){function t(){return P(this,t),w(this,O(t).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&j(e,t)}(t,s["PureComponent"]),t}();function E(e){return(E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function x(e,t){return!t||"object"!==E(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function T(e){return(T=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function k(e,t){return(k=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function H(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var R=function e(){H(this,e),function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(this,"children",void 0)},I=function(e){function t(){return H(this,t),x(this,T(t).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&k(e,t)}(t,s["PureComponent"]),t}();function A(e){return(A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function B(e,t){return!t||"object"!==A(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function F(e){return(F=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function N(e,t){return(N=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function z(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function q(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var M=function e(t){z(this,e),q(this,"children",void 0),q(this,"className",void 0),q(this,"style",void 0),q(this,"title",void 0),q(this,"visible",!0),q(this,"onClick",void 0),Object.assign(this,t)},V=function(e){function t(){return z(this,t),B(this,F(t).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&N(e,t)}(t,s["PureComponent"]),t}();function D(e){return(D="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function G(e,t){return!t||"object"!==D(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function K(e){return(K=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function L(e,t){return(L=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function X(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var J=function e(){X(this,e),function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(this,"children",void 0)},Q=function(e){function t(){return X(this,t),G(this,K(t).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&L(e,t)}(t,s["PureComponent"]),t}();function U(e){return(U="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function W(e,t){return!t||"object"!==U(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function Y(e){return(Y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Z(e,t){return(Z=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function $(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ee(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var te=function e(){$(this,e),ee(this,"height","40px"),ee(this,"children",void 0)},ne=function(e){function t(){return $(this,t),W(this,Y(t).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Z(e,t)}(t,s["PureComponent"]),t}();function re(e){return(re="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function oe(e,t){return!t||"object"!==re(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function ie(e){return(ie=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ue(e,t){return(ue=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ce(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function le(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var fe=function e(){ce(this,e),le(this,"key",void 0),le(this,"className",void 0),le(this,"style",void 0),le(this,"children",void 0)},ae=function(e){function t(){return ce(this,t),oe(this,ie(t).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ue(e,t)}(t,s["PureComponent"]),t}(),se=n(1),pe=n(2),ye=n.n(pe),he=n(3);function be(e){return(be="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function de(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function me(e,t){return!t||"object"!==be(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function ve(e){return(ve=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ge(e,t){return(ge=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function we(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var Oe=function(e){function n(e){var t;return we(this,n),(t=me(this,ve(n).call(this,e))).state={hasError:!1},t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ge(e,t)}(n,s["Component"]),function(e,t,n){t&&de(e.prototype,t),n&&de(e,n)}(n,[{key:"componentDidCatch",value:function(e,t){this.setState({hasError:!0}),console.error(e)}},{key:"render",value:function(){return this.state.hasError?s.createElement("span",null,"X"):void 0!==this.props.children?this.props.children:null}}]),n}();function je(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var Pe=function(){function r(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r)}return function(e,t,n){t&&je(e.prototype,t),n&&je(e,n)}(r,null,[{key:"elementInstanceOf",value:function(e,t){return!!e&&(!!e.type&&(e.type===t||e.type.prototype instanceof t||t.isPrototypeOf(e.type)))}},{key:"isReactFragment",value:function(e){return s.isValidElement(e)&&e.type===s.Fragment}},{key:"addPropsToChildren",value:function(e,r){return s.Children.map(e,function(e,t){var n=r(e,t);return s.cloneElement(e,n)})}},{key:"childrenArray",value:function(e){if(!e)return null;if(!e.props)return null;var t=e.props.children;return Array.isArray(t)?t:s.Children.map(t,function(e){return e})}},{key:"childrenOfType",value:function(e,t){var n=r.childrenArray(e);return n?n.filter(function(e){return r.elementInstanceOf(e,t)}):null}},{key:"singleChildOfType",value:function(e,t){var n=r.childrenOfType(e,t);if(!n||!n.length)return null;if(1<n.length)throw new Error("Only one ".concat(t.name," child element is allowed."));return n[0]}},{key:"singleFunctionChild",value:function(e){if(!e)return null;if(!e.props)return null;var t=e.props.children;return"function"!=typeof e.props.children?null:t}}]),r}();function _e(e){return null==e}var Ce=n(4),Se=n.n(Ce).a;function Ee(){var e=Ae(["\n flex: 1;\n padding: 8px;\n overflow: hidden;\n text-overflow: ellipsis;\n"]);return Ee=function(){return e},e}function xe(){var e=Ae(["\n flex: 1;\n display: flex;\n justify-content: stretch;\n\n border-top: ",";\n\n &:first-of-type {\n border-top: none;\n }\n"]);return xe=function(){return e},e}function Te(){var e=Ae(["\n display: flex;\n flex-flow: column;\n\n vertical-align: middle;\n"]);return Te=function(){return e},e}function ke(){var e=Ae(["\n flex: 1;\n display: flex;\n padding: 8px;\n overflow: hidden;\n text-overflow: ellipsis;\n align-items: flex-end;\n vertical-align: bottom;\n"]);return ke=function(){return e},e}function He(){var e=Ae(["\n flex: 1;\n display: flex;\n justify-content: stretch;\n\n ",": ",";\n\n border-bottom: ",";\n"]);return He=function(){return e},e}function Re(){var e=Ae(["\n display: flex;\n flex-flow: column;\n\n overflow-y: hidden;\n\n font-weight: bold;\n vertical-align: middle;\n"]);return Re=function(){return e},e}function Ie(){var e=Ae(["\n background-color: #fff;\n width: 100%;\n overflow-y: hidden;\n"]);return Ie=function(){return e},e}function Ae(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var Be="1px solid #ddd",Fe=Se.div(Ie()),Ne=Se.div(Re()),ze=Se.div(He(),function(e){return"rtl"===e.theme.dir?"padding-left":"padding-dir"},"17px",Be),qe=Se.div(ke()),Me=Se.div(Te()),Ve=Se.div(xe(),Be),De=Se.div(Ee());function Ge(e){return(Ge="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ke(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Le(e,t){return!t||"object"!==Ge(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function Xe(e){return(Xe=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Je(e,t){return(Je=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Qe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ue(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var We=n(6),Ye=function e(){Qe(this,e),Ue(this,"items",void 0),Ue(this,"itemId",void 0),Ue(this,"children",void 0),Ue(this,"dir","ltr"),Ue(this,"className",void 0),Ue(this,"style",void 0),Ue(this,"rowHeight",50),Ue(this,"emptyMessage","No Items to Display"),Ue(this,"overscanCount",20)},Ze=function e(){Qe(this,e),Ue(this,"selectedItems",{})},$e=function(e){function r(e){var t;return Qe(this,r),(t=Le(this,Xe(r).call(this,e))).state=new Ze,t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Je(e,t)}(r,s["PureComponent"]),function(e,t,n){t&&Ke(e.prototype,t),n&&Ke(e,n)}(r,[{key:"render",value:function(){var e=Pe.singleChildOfType(this,ne),t=Pe.singleChildOfType(this,I),n=Pe.childrenOfType(this,Q);if(n&&n.length){if(e||t)throw new Error("Can not specify head and/or body when specifying table columns.");e=this.createHeadFromColumns(n),t=this.createBodyFromColumns(n)}return s.createElement(Oe,null,s.createElement(se.ThemeProvider,{theme:this.getTheme()},s.createElement(Fe,{className:this.props.className,style:Object.assign({},this.props.style,this.getHeights())},this.renderTableHead(e),this.renderTableBody(e,t))))}},{key:"renderTableHead",value:function(e){var i=this;return e?s.createElement(Ne,{style:{height:e.props.height}},s.createElement(ze,null,s.createElement(Oe,null,s.Children.map(e.props.children,function(e,t){var n=e,r=i.getHeadCellProps(n);if(!r.visible)return null;var o=i.getHeadCellContent(n);return s.createElement(qe,{key:t,style:r.style},s.createElement(Oe,null,o))})))):null}},{key:"renderTableBody",value:function(e,t){var n=this.getHeadProps(e),r=this.getHeights(),o="calc(".concat(r.height," - ").concat(n.height,")"),i="calc(".concat(r.minHeight," - ").concat(n.height,")"),u="calc(".concat(r.maxHeight," - ").concat(n.height,")");return s.createElement(Me,{style:{direction:this.props.dir,height:o,minHeight:i,maxHeight:u}},s.createElement(Oe,null,this.renderTableRows(t)))}},{key:"renderTableRows",value:function(f){var a=this;return 0!==this.props.items.length&&this.hasBody(f)?s.createElement(ye.a,null,function(e){var t=e.width,n=e.height;return s.createElement(he.FixedSizeList,{style:{outline:"none"},direction:a.props.dir,layout:"vertical",height:n,width:t,itemCount:a.props.items.length,itemSize:a.props.rowHeight},function(e){var t=e.index,n=e.style,r=f.props.children;if(!r)return null;var o=a.props.items[t],i=r(o,t),u=a.getRowProps(i),c=a.getRowKey(u,o,t),l=a.getRowContent(i);return s.createElement(Ve,{className:u.className,style:Object.assign({},n,u.style||{}),key:c},s.createElement(Oe,null,function(e){return Array.isArray(e)?e:[e]}(l).map(function(e,t){var n=a.getCellProps(e);return n.visible?s.createElement(De,{key:t,className:n.className,style:n.style,title:n.title,onClick:n.onClick},s.createElement(Oe,null,a.getCellContent(e))):null})))})}):this.renderItemsPlaceHolder()}},{key:"renderItemsPlaceHolder",value:function(){return s.createElement("div",null,s.createElement("div",{style:{textAlign:"center"}},this.props.emptyMessage))}},{key:"getTheme",value:function(){return{dir:this.props.dir}}},{key:"getHeights",value:function(){var e=(this.props.style||{}).height,t=(this.props.style||{}).minHeight,n=(this.props.style||{}).maxHeight;return void 0===e&&void 0===t&&(e=r.defaultHeight),{height:e,minHeight:t,maxHeight:n}}},{key:"getItemId",value:function(e,t){return"function"==typeof this.props.itemId?this.props.itemId(e,t):e.id}},{key:"createHeadFromColumns",value:function(e){return s.createElement(ne,null,e.map(function(e){return Pe.singleChildOfType(e,S).props.children}))}},{key:"createBodyFromColumns",value:function(e){return s.createElement(I,null,function(r,o){return e.map(function(e,t){var n=Pe.singleChildOfType(e,v).props.children;return n?n(r,o,t):null})})}},{key:"getHeadProps",value:function(e){return Pe.elementInstanceOf(e,ae)?e.props:new te}},{key:"getHeadCellProps",value:function(e){return Pe.elementInstanceOf(e,V)?new M(e.props):new M}},{key:"getHeadCellContent",value:function(e){return Pe.elementInstanceOf(e,V)?e.props.children:e}},{key:"hasBody",value:function(e){return!!e&&(!_e(e.props.children)&&("function"==typeof e.props.children||(Array.isArray(e.props.children)?0<e.props.children.length:0<s.Children.count(e.props.children))))}},{key:"getRowProps",value:function(e){return Pe.elementInstanceOf(e,ae)?e.props:new fe}},{key:"getRowContent",value:function(e){var t=e;if(Pe.isReactFragment(t))throw new Error("Can not use React.Fragment as row content. Consider wrapping your content with a row element.");return Pe.elementInstanceOf(t,ae)&&(t=t.props.children),Array.isArray(t)&&(t=We(t)),t}},{key:"getRowKey",value:function(e,t,n){if(!_e(e.key))return e.key;var r=this.getItemId(t,n);return _e(r)?n:r}},{key:"getCellProps",value:function(e){return Pe.elementInstanceOf(e,V)?new M(e.props):new M}},{key:"getCellContent",value:function(e){var t=e;return Pe.elementInstanceOf(t,V)&&(t=t.props.children),t||null}}]),r}();Ue($e,"defaultHeight","35vh"),Ue($e,"Head",ne),Ue($e,"Body",I),Ue($e,"Row",ae),Ue($e,"Cell",V),Ue($e,"Column",Q),Ue($e,"defaultProps",new Ye),n.d(t,"GridViewProps",function(){return f}),n.d(t,"GridView",function(){return a}),n.d(t,"ColumnBodyProps",function(){return m}),n.d(t,"ColumnBody",function(){return v}),n.d(t,"ColumnHeadProps",function(){return C}),n.d(t,"ColumnHead",function(){return S}),n.d(t,"TableBodyProps",function(){return R}),n.d(t,"TableBody",function(){return I}),n.d(t,"TableCellProps",function(){return M}),n.d(t,"TableCell",function(){return V}),n.d(t,"TableColumnProps",function(){return J}),n.d(t,"TableColumn",function(){return Q}),n.d(t,"TableHeadProps",function(){return te}),n.d(t,"TableHead",function(){return ne}),n.d(t,"TableRowProps",function(){return fe}),n.d(t,"TableRow",function(){return ae}),n.d(t,"TableViewProps",function(){return Ye}),n.d(t,"TableView",function(){return $e})}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("react-tablize",[],t):"object"==typeof exports?exports["react-tablize"]=t():e["react-tablize"]=t()}(this,function(){return function(n){var r={};function o(e){if(r[e])return r[e].exports;var t=r[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}return o.m=n,o.c=r,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=5)}([function(e,t){e.exports=require("react")},function(e,t){e.exports=require("emotion-theming")},function(e,t){e.exports=require("react-virtualized-auto-sizer")},function(e,t){e.exports=require("react-window")},function(e,t){e.exports=require("@emotion/styled")},function(e,t,n){e.exports=n(7)},function(e,t){e.exports=require("lodash.flattendeep")},function(e,t,n){"use strict";n.r(t);var y=n(0);function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var f=function e(){l(this,e)},a=function(e){function t(){return l(this,t),i(this,u(t).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(t,y["PureComponent"]),function(e,t,n){t&&o(e.prototype,t),n&&o(e,n)}(t,[{key:"render",value:function(){return y.createElement("h1",null,"Hi!")}}]),t}();function p(e){return(p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function s(e,t){return!t||"object"!==p(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function b(e,t){return(b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var m=function e(){d(this,e),function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(this,"children",void 0)},v=function(e){function t(){return d(this,t),s(this,h(t).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&b(e,t)}(t,y["PureComponent"]),t}();function g(e){return(g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function O(e,t){return!t||"object"!==g(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function w(e){return(w=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function j(e,t){return(j=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function P(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var S=function e(){P(this,e),_(this,"height","40px"),_(this,"children",void 0)},C=function(e){function t(){return P(this,t),O(this,w(t).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&j(e,t)}(t,y["PureComponent"]),t}();function E(e){return(E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function x(e,t){return!t||"object"!==E(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function T(e){return(T=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function k(e,t){return(k=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function H(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var R=function e(){H(this,e),function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(this,"children",void 0)},I=function(e){function t(){return H(this,t),x(this,T(t).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&k(e,t)}(t,y["PureComponent"]),t}();function A(e){return(A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function B(e,t){return!t||"object"!==A(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function F(e){return(F=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function z(e,t){return(z=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var q=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),B(this,F(t).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&z(e,t)}(t,y["PureComponent"]),t}();function M(e){return(M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function N(e,t){return!t||"object"!==M(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function V(e){return(V=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function D(e,t){return(D=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function G(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var K=function e(){G(this,e),function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(this,"children",void 0)},L=function(e){function t(){return G(this,t),N(this,V(t).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&D(e,t)}(t,y["PureComponent"]),t}();function X(e){return(X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function J(e,t){return!t||"object"!==X(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function Q(e){return(Q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function U(e,t){return(U=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function W(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Z=function e(){W(this,e),Y(this,"height","40px"),Y(this,"children",void 0)},$=function(e){function t(){return W(this,t),J(this,Q(t).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&U(e,t)}(t,y["PureComponent"]),t}();function ee(e){return(ee="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function te(e,t){return!t||"object"!==ee(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function ne(e){return(ne=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function re(e,t){return(re=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var oe=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),te(this,ne(t).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&re(e,t)}(t,y["PureComponent"]),t}(),ie=n(1),ue=n(2),ce=n.n(ue),le=n(3);function fe(e){return(fe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ae(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function pe(e,t){return!t||"object"!==fe(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function se(e){return(se=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ye(e,t){return(ye=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function he(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var be=function(e){function n(e){var t;return he(this,n),(t=pe(this,se(n).call(this,e))).state={hasError:!1},t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ye(e,t)}(n,y["Component"]),function(e,t,n){t&&ae(e.prototype,t),n&&ae(e,n)}(n,[{key:"componentDidCatch",value:function(e,t){this.setState({hasError:!0}),console.error(e)}},{key:"render",value:function(){return this.state.hasError?y.createElement("span",null,"X"):void 0!==this.props.children?this.props.children:null}}]),n}();function de(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var me=function(){function r(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r)}return function(e,t,n){t&&de(e.prototype,t),n&&de(e,n)}(r,null,[{key:"getProps",value:function(e){return e&&e.props||{}}},{key:"elementInstanceOf",value:function(e,t){return!!e&&(!!e.type&&(e.type===t||e.type.prototype instanceof t||t.isPrototypeOf(e.type)))}},{key:"isReactFragment",value:function(e){return y.isValidElement(e)&&e.type===y.Fragment}},{key:"addPropsToChildren",value:function(e,r){return y.Children.map(e,function(e,t){var n=r(e,t);return y.cloneElement(e,n)})}},{key:"childrenArray",value:function(e){if(!e)return null;if(!e.props)return null;var t=e.props.children;return Array.isArray(t)?t:y.Children.map(t,function(e){return e})}},{key:"childrenOfType",value:function(e,t){var n=r.childrenArray(e);return n?n.filter(function(e){return r.elementInstanceOf(e,t)}):null}},{key:"singleChildOfType",value:function(e,t){var n=r.childrenOfType(e,t);if(!n||!n.length)return null;if(1<n.length)throw new Error("Only one ".concat(t.name," child element is allowed."));return n[0]}},{key:"singleFunctionChild",value:function(e){if(!e)return null;if(!e.props)return null;var t=e.props.children;return"function"!=typeof e.props.children?null:t}}]),r}();function ve(e){return null==e}function ge(e){return Number.isFinite(e)?e+"px":e}var Oe=n(4),we=n.n(Oe).a;function je(){var e=Te(["\n flex: 1;\n padding: 8px;\n overflow: hidden;\n text-overflow: ellipsis;\n"]);return je=function(){return e},e}function Pe(){var e=Te(["\n flex: 1;\n display: flex;\n justify-content: stretch;\n\n border-top: ",";\n\n &:first-of-type {\n border-top: none;\n }\n"]);return Pe=function(){return e},e}function _e(){var e=Te(["\n display: flex;\n flex-flow: column;\n\n vertical-align: middle;\n"]);return _e=function(){return e},e}function Se(){var e=Te(["\n flex: 1;\n display: flex;\n padding: 8px;\n overflow: hidden;\n text-overflow: ellipsis;\n align-items: flex-end;\n vertical-align: bottom;\n"]);return Se=function(){return e},e}function Ce(){var e=Te(["\n flex: 1;\n display: flex;\n justify-content: stretch;\n\n ",": ",";\n\n border-bottom: ",";\n"]);return Ce=function(){return e},e}function Ee(){var e=Te(["\n display: flex;\n flex-flow: column;\n\n overflow-y: hidden;\n\n font-weight: bold;\n vertical-align: middle;\n"]);return Ee=function(){return e},e}function xe(){var e=Te(["\n background-color: #fff;\n width: 100%;\n overflow-y: hidden;\n"]);return xe=function(){return e},e}function Te(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var ke="1px solid #ddd",He=we.div(xe()),Re=we.div(Ee()),Ie=we.div(Ce(),function(e){return"rtl"===e.theme.dir?"padding-left":"padding-dir"},"17px",ke),Ae=we.div(Se()),Be=we.div(_e()),Fe=we.div(Pe(),ke),ze=we.div(je());function qe(e){return(qe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Me(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],0<=t.indexOf(n)||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],0<=t.indexOf(n)||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function Ne(){return(Ne=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function Ve(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function De(e,t){return!t||"object"!==qe(t)&&"function"!=typeof t?function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}function Ge(e){return(Ge=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Ke(e,t){return(Ke=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Le(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Xe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Je=n(6),Qe=function e(){Le(this,e),Xe(this,"items",void 0),Xe(this,"itemId",void 0),Xe(this,"children",void 0),Xe(this,"dir","ltr"),Xe(this,"className",void 0),Xe(this,"style",void 0),Xe(this,"rowHeight",50),Xe(this,"emptyMessage","No Items to Display"),Xe(this,"overscanCount",20)},Ue=function e(){Le(this,e),Xe(this,"selectedItems",{})},We=function(e){function r(e){var t;return Le(this,r),(t=De(this,Ge(r).call(this,e))).state=new Ue,t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Ke(e,t)}(r,y["PureComponent"]),function(e,t,n){t&&Ve(e.prototype,t),n&&Ve(e,n)}(r,[{key:"render",value:function(){var e=me.singleChildOfType(this,$),t=me.singleChildOfType(this,I),n=me.childrenOfType(this,L);if(n&&n.length){if(e||t)throw new Error("Can not specify head and/or body when specifying table columns.");e=this.createHeadFromColumns(n),t=this.createBodyFromColumns(n)}return y.createElement(be,null,y.createElement(ie.ThemeProvider,{theme:this.getTheme()},y.createElement(He,{className:this.props.className,style:Object.assign({},this.props.style,this.getHeights())},this.renderTableHead(e),this.renderTableBody(e,t))))}},{key:"renderTableHead",value:function(e){var i=this;return e?y.createElement(Re,{style:{height:e.props.height}},y.createElement(Ie,null,y.createElement(be,null,y.Children.map(e.props.children,function(e,t){var n=e,r=i.getHeadCellProps(n);if(!1===r.visible)return null;var o=i.getHeadCellContent(n);return y.createElement(Ae,Ne({key:t},r),y.createElement(be,null,o))})))):null}},{key:"renderTableBody",value:function(e,t){var n=this.getHeadProps(e),r=this.getHeights(),o="calc(".concat(r.height," - ").concat(n.height,")"),i="calc(".concat(r.minHeight," - ").concat(n.height,")"),u="calc(".concat(r.maxHeight," - ").concat(n.height,")");return y.createElement(Be,{style:{direction:this.props.dir,height:o,minHeight:i,maxHeight:u}},y.createElement(be,null,this.renderTableRows(t)))}},{key:"renderTableRows",value:function(p){var s=this;return 0!==this.props.items.length&&this.hasBody(p)?y.createElement(ce.a,null,function(e){var t=e.width,n=e.height;return y.createElement(le.FixedSizeList,{style:{outline:"none"},direction:s.props.dir,layout:"vertical",height:n,width:t,itemCount:s.props.items.length,itemSize:s.props.rowHeight},function(e){var t=e.index,n=e.style,r=p.props.children;if(!r)return null;var o=s.props.items[t],i=r(o,t),u=s.getRowProps(i),c=u.style,l=Me(u,["style"]),f=s.getRowKey(l,o,t),a=s.getRowContent(i);return y.createElement(Fe,Ne({style:Object.assign({},n,c||{}),key:f},l),y.createElement(be,null,function(e){return Array.isArray(e)?e:[e]}(a).map(function(e,t){var n=s.getCellProps(e);return!1===n.visible?null:y.createElement(ze,Ne({key:t},n),y.createElement(be,null,s.getCellContent(e)))})))})}):this.renderItemsPlaceHolder()}},{key:"renderItemsPlaceHolder",value:function(){return y.createElement("div",null,y.createElement("div",{style:{textAlign:"center"}},this.props.emptyMessage))}},{key:"getTheme",value:function(){return{dir:this.props.dir}}},{key:"getHeights",value:function(){var e=(this.props.style||{}).height,t=(this.props.style||{}).minHeight,n=(this.props.style||{}).maxHeight;return void 0===e&&void 0===t&&(e=r.defaultHeight),{height:e=ge(e),minHeight:t=ge(t),maxHeight:n=ge(n)}}},{key:"getItemId",value:function(e,t){return"function"==typeof this.props.itemId?this.props.itemId(e,t):e.id}},{key:"createHeadFromColumns",value:function(e){return y.createElement($,null,e.map(function(e){return me.singleChildOfType(e,C).props.children}))}},{key:"createBodyFromColumns",value:function(e){return y.createElement(I,null,function(r,o){return e.map(function(e,t){var n=me.singleChildOfType(e,v).props.children;return n?n(r,o,t):null})})}},{key:"getHeadProps",value:function(e){return me.elementInstanceOf(e,oe)?e.props:new Z}},{key:"getHeadCellProps",value:function(e){return me.elementInstanceOf(e,q)&&e.props||{}}},{key:"getHeadCellContent",value:function(e){return me.elementInstanceOf(e,q)?e.props.children:e}},{key:"hasBody",value:function(e){return!!e&&(!ve(e.props.children)&&("function"==typeof e.props.children||(Array.isArray(e.props.children)?0<e.props.children.length:0<y.Children.count(e.props.children))))}},{key:"getRowProps",value:function(e){return me.elementInstanceOf(e,oe)&&e.props||{}}},{key:"getRowContent",value:function(e){var t=e;if(me.isReactFragment(t))throw new Error("Can not use React.Fragment as row content. Consider wrapping your content with a row element.");return me.elementInstanceOf(t,oe)&&(t=t.props.children),Array.isArray(t)&&(t=Je(t)),t}},{key:"getRowKey",value:function(e,t,n){if(!ve(e.key))return e.key;var r=this.getItemId(t,n);return ve(r)?n:r}},{key:"getCellProps",value:function(e){return me.elementInstanceOf(e,q)&&e.props||{}}},{key:"getCellContent",value:function(e){var t=e;return me.elementInstanceOf(t,q)&&(t=t.props.children),t||null}}]),r}();Xe(We,"defaultHeight","35vh"),Xe(We,"Head",$),Xe(We,"Body",I),Xe(We,"Row",oe),Xe(We,"Cell",q),Xe(We,"Column",L),Xe(We,"defaultProps",new Qe),n.d(t,"GridViewProps",function(){return f}),n.d(t,"GridView",function(){return a}),n.d(t,"ColumnBodyProps",function(){return m}),n.d(t,"ColumnBody",function(){return v}),n.d(t,"ColumnHeadProps",function(){return S}),n.d(t,"ColumnHead",function(){return C}),n.d(t,"TableBodyProps",function(){return R}),n.d(t,"TableBody",function(){return I}),n.d(t,"TableCell",function(){return q}),n.d(t,"TableColumnProps",function(){return K}),n.d(t,"TableColumn",function(){return L}),n.d(t,"TableHeadProps",function(){return Z}),n.d(t,"TableHead",function(){return $}),n.d(t,"TableRow",function(){return oe}),n.d(t,"TableViewProps",function(){return Qe}),n.d(t,"TableView",function(){return We})}])}); |
{ | ||
"name": "react-tablize", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "React virtual table component", | ||
"author": "Alon Bar", | ||
"license": "MIT", | ||
"homepage": "https://github.com/alonrbar/react-tablize", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/alonrbar/react-tablize.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/alonrbar/react-tablize/issues" | ||
}, | ||
"main": "dist/react-tablize.js", | ||
@@ -8,0 +16,0 @@ "typings": "dist/index.d.ts", |
101
README.md
# react-tablize | ||
React virtual table component. | ||
React virtual table component. | ||
[![npm version](https://img.shields.io/npm/v/react-tablize.svg)](https://www.npmjs.com/package/react-tablize) | ||
[![npm license](https://img.shields.io/npm/l/react-tablize.svg)](https://www.npmjs.com/package/react-tablize) | ||
[![dependencies](https://david-dm.org/alonrbar/react-tablize.svg)](https://github.com/alonrbar/react-tablize) | ||
[![dependencies](https://david-dm.org/alonrbar/react-tablize/dev-status.svg)](https://github.com/alonrbar/react-tablize) | ||
## Examples | ||
### Terse syntax | ||
```jsx | ||
<TableView items={people}> | ||
<TableHead> | ||
{['Name', 'Age']} | ||
</TableHead> | ||
<TableBody> | ||
{(person: Person) => ([ | ||
person.name, | ||
person.age | ||
])} | ||
</TableBody> | ||
</TableView> | ||
``` | ||
### Rows and cells syntax | ||
```jsx | ||
<TableView items={people}> | ||
<TableHead> | ||
<TableCell> | ||
Name | ||
</TableCell> | ||
<TableCell> | ||
Age | ||
</TableCell> | ||
</TableHead> | ||
<TableBody> | ||
{(person: Person) => ( | ||
<TableRow> | ||
<TableCell> | ||
{person.name} | ||
</TableCell> | ||
<TableCell> | ||
{person.age} | ||
</TableCell> | ||
</TableRow> | ||
)} | ||
</TableBody> | ||
</TableView> | ||
``` | ||
### Mixed syntax | ||
```jsx | ||
<TableView items={people}> | ||
<TableHead> | ||
{[ | ||
<TableCell key="name"> | ||
Name | ||
</TableCell>, | ||
'Age' | ||
]} | ||
</TableHead> | ||
<TableBody> | ||
{(person: Person) => ( | ||
<TableRow> | ||
{[ | ||
<TableCell key="name"> | ||
{person.name} | ||
</TableCell>, | ||
person.age | ||
]} | ||
</TableRow> | ||
)} | ||
</TableBody> | ||
</TableView> | ||
``` | ||
### Columns syntax | ||
```jsx | ||
<TableView items={people}> | ||
<TableColumn> | ||
<ColumnHead>Name</ColumnHead> | ||
<ColumnBody> | ||
{(person: Person) => person.name} | ||
</ColumnBody> | ||
</TableColumn> | ||
<TableColumn> | ||
<ColumnHead>Age</ColumnHead> | ||
<ColumnBody> | ||
{(person: Person) => person.age} | ||
</ColumnBody> | ||
</TableColumn> | ||
</TableView> | ||
``` |
import * as React from 'react'; | ||
declare module 'react' { | ||
type SubComp<T> = T extends React.Component<infer P> ? React.ReactElement<P, any> : never; | ||
type DivProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>; | ||
} |
@@ -6,2 +6,10 @@ import * as React from 'react'; | ||
// | ||
// props | ||
// | ||
public static getProps<T>(elem: any): T { | ||
return (elem && (elem as any).props) || {}; | ||
} | ||
// | ||
// react element | ||
@@ -8,0 +16,0 @@ // |
@@ -11,2 +11,8 @@ | ||
return [val]; | ||
} | ||
export function cssSizeString(size: any): string { | ||
if (Number.isFinite(size)) | ||
return size + 'px'; | ||
return size; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
162917
29
0
2
102
0
1671