@popmenu/table 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/GlobalFilter/GlobalFilter.d.ts +3 -0
- package/build/components/GlobalFilter/GlobalFilterProps.d.ts +7 -0
- package/build/components/GlobalFilter/index.d.ts +2 -0
- package/build/components/Table/TableProps.d.ts +5 -0
- package/build/index.es.js +93 -56
- package/build/index.es.js.map +1 -1
- package/build/index.js +92 -55
- package/build/index.js.map +1 -1
- package/package.json +2 -2
package/build/index.js
CHANGED
|
@@ -6,6 +6,7 @@ var React = require('react');
|
|
|
6
6
|
var useTable_js = require('react-table/src/hooks/useTable.js');
|
|
7
7
|
var usePagination_js = require('react-table/src/plugin-hooks/usePagination.js');
|
|
8
8
|
var useSortBy_js = require('react-table/src/plugin-hooks/useSortBy.js');
|
|
9
|
+
var useGlobalFilter_js = require('react-table/src/plugin-hooks/useGlobalFilter.js');
|
|
9
10
|
var lab = require('@material-ui/lab');
|
|
10
11
|
require('@material-ui/lab/Alert');
|
|
11
12
|
var core = require('@material-ui/core');
|
|
@@ -179,20 +180,20 @@ function __rest(s, e) {
|
|
|
179
180
|
return t;
|
|
180
181
|
}
|
|
181
182
|
|
|
182
|
-
var _path$
|
|
183
|
+
var _path$2O;
|
|
183
184
|
|
|
184
|
-
function _extends$
|
|
185
|
+
function _extends$32() { _extends$32 = 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$32.apply(this, arguments); }
|
|
185
186
|
|
|
186
187
|
function SvgUser(props) {
|
|
187
|
-
return /*#__PURE__*/React__namespace.createElement("svg", _extends$
|
|
188
|
+
return /*#__PURE__*/React__namespace.createElement("svg", _extends$32({
|
|
188
189
|
viewBox: "0 0 16 16",
|
|
189
190
|
strokeLinecap: "round",
|
|
190
191
|
strokeLinejoin: "round",
|
|
191
192
|
stroke: "currentColor",
|
|
193
|
+
fill: "none",
|
|
192
194
|
width: "1em",
|
|
193
|
-
height: "1em"
|
|
194
|
-
|
|
195
|
-
}, props), _path$3k || (_path$3k = /*#__PURE__*/React__namespace.createElement("path", {
|
|
195
|
+
height: "1em"
|
|
196
|
+
}, props), _path$2O || (_path$2O = /*#__PURE__*/React__namespace.createElement("path", {
|
|
196
197
|
d: "M13.333 14v-1.333A2.667 2.667 0 0010.667 10H5.333a2.667 2.667 0 00-2.666 2.667V14M8 7.333A2.667 2.667 0 108 2a2.667 2.667 0 000 5.333z"
|
|
197
198
|
})));
|
|
198
199
|
}
|
|
@@ -757,57 +758,75 @@ var TableHeader = function (props) {
|
|
|
757
758
|
return React__default['default'].createElement("thead", __assign$1({}, restProps), children);
|
|
758
759
|
};
|
|
759
760
|
|
|
760
|
-
var _path$
|
|
761
|
+
var _path$4w;
|
|
761
762
|
|
|
762
|
-
function _extends$
|
|
763
|
+
function _extends$4M() { _extends$4M = 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$4M.apply(this, arguments); }
|
|
763
764
|
|
|
764
|
-
function
|
|
765
|
-
return /*#__PURE__*/React__namespace.createElement("svg", _extends$
|
|
765
|
+
function SvgChevronDown(props) {
|
|
766
|
+
return /*#__PURE__*/React__namespace.createElement("svg", _extends$4M({
|
|
766
767
|
viewBox: "0 0 16 16",
|
|
767
768
|
strokeLinecap: "round",
|
|
768
769
|
strokeLinejoin: "round",
|
|
769
770
|
stroke: "currentColor",
|
|
771
|
+
fill: "none",
|
|
770
772
|
width: "1em",
|
|
771
|
-
height: "1em"
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
d: "M8 8.667a.667.667 0 100-1.334.667.667 0 000 1.334zM8 4a.667.667 0 100-1.333A.667.667 0 008 4zm0 9.333A.667.667 0 108 12a.667.667 0 000 1.333z"
|
|
773
|
+
height: "1em"
|
|
774
|
+
}, props), _path$4w || (_path$4w = /*#__PURE__*/React__namespace.createElement("path", {
|
|
775
|
+
d: "M4 6l4 4 4-4"
|
|
775
776
|
})));
|
|
776
777
|
}
|
|
777
778
|
|
|
778
|
-
var _path$
|
|
779
|
+
var _path$4v;
|
|
779
780
|
|
|
780
|
-
function _extends$
|
|
781
|
+
function _extends$4L() { _extends$4L = 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$4L.apply(this, arguments); }
|
|
781
782
|
|
|
782
|
-
function
|
|
783
|
-
return /*#__PURE__*/React__namespace.createElement("svg", _extends$
|
|
783
|
+
function SvgChevronUp(props) {
|
|
784
|
+
return /*#__PURE__*/React__namespace.createElement("svg", _extends$4L({
|
|
784
785
|
viewBox: "0 0 16 16",
|
|
785
786
|
strokeLinecap: "round",
|
|
786
787
|
strokeLinejoin: "round",
|
|
787
788
|
stroke: "currentColor",
|
|
789
|
+
fill: "none",
|
|
788
790
|
width: "1em",
|
|
789
|
-
height: "1em"
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
d: "M4 6l4 4 4-4"
|
|
791
|
+
height: "1em"
|
|
792
|
+
}, props), _path$4v || (_path$4v = /*#__PURE__*/React__namespace.createElement("path", {
|
|
793
|
+
d: "M12 10L8 6l-4 4"
|
|
793
794
|
})));
|
|
794
795
|
}
|
|
795
796
|
|
|
796
|
-
var _path$
|
|
797
|
+
var _path$3c;
|
|
797
798
|
|
|
798
|
-
function _extends$
|
|
799
|
+
function _extends$3s() { _extends$3s = 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$3s.apply(this, arguments); }
|
|
799
800
|
|
|
800
|
-
function
|
|
801
|
-
return /*#__PURE__*/React__namespace.createElement("svg", _extends$
|
|
801
|
+
function SvgMore(props) {
|
|
802
|
+
return /*#__PURE__*/React__namespace.createElement("svg", _extends$3s({
|
|
802
803
|
viewBox: "0 0 16 16",
|
|
803
804
|
strokeLinecap: "round",
|
|
804
805
|
strokeLinejoin: "round",
|
|
805
806
|
stroke: "currentColor",
|
|
807
|
+
fill: "none",
|
|
806
808
|
width: "1em",
|
|
807
|
-
height: "1em"
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
809
|
+
height: "1em"
|
|
810
|
+
}, props), _path$3c || (_path$3c = /*#__PURE__*/React__namespace.createElement("path", {
|
|
811
|
+
d: "M8 8.667a.667.667 0 100-1.334.667.667 0 000 1.334zM8 4a.667.667 0 100-1.334A.667.667 0 008 4zm0 9.333A.667.667 0 108 12a.667.667 0 000 1.333z"
|
|
812
|
+
})));
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
var _path$32;
|
|
816
|
+
|
|
817
|
+
function _extends$3i() { _extends$3i = 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$3i.apply(this, arguments); }
|
|
818
|
+
|
|
819
|
+
function SvgSearch(props) {
|
|
820
|
+
return /*#__PURE__*/React__namespace.createElement("svg", _extends$3i({
|
|
821
|
+
viewBox: "0 0 16 16",
|
|
822
|
+
strokeLinecap: "round",
|
|
823
|
+
strokeLinejoin: "round",
|
|
824
|
+
stroke: "currentColor",
|
|
825
|
+
fill: "none",
|
|
826
|
+
width: "1em",
|
|
827
|
+
height: "1em"
|
|
828
|
+
}, props), _path$32 || (_path$32 = /*#__PURE__*/React__namespace.createElement("path", {
|
|
829
|
+
d: "M7.333 12.667A5.333 5.333 0 107.333 2a5.333 5.333 0 000 10.667zM14 14l-2.9-2.9"
|
|
811
830
|
})));
|
|
812
831
|
}
|
|
813
832
|
|
|
@@ -898,28 +917,6 @@ var TableCell = function (props) {
|
|
|
898
917
|
return (React__default['default'].createElement("td", __assign$1({ className: root }, restProps), children));
|
|
899
918
|
};
|
|
900
919
|
|
|
901
|
-
var useTableStyles = core.makeStyles(function (_a) {
|
|
902
|
-
var typography = _a.typography;
|
|
903
|
-
return ({
|
|
904
|
-
root: function (_a) {
|
|
905
|
-
var fullWidth = _a.fullWidth;
|
|
906
|
-
return ({
|
|
907
|
-
display: fullWidth ? 'flex' : 'inline-flex',
|
|
908
|
-
flexDirection: 'column',
|
|
909
|
-
});
|
|
910
|
-
},
|
|
911
|
-
table: function (_a) {
|
|
912
|
-
var fullWidth = _a.fullWidth;
|
|
913
|
-
return (__assign$1(__assign$1({ borderCollapse: 'collapse' }, (fullWidth && { width: '100%' })), typography[tableConstants.tableTypography]));
|
|
914
|
-
},
|
|
915
|
-
tableWrap: function () { return ({
|
|
916
|
-
maxWidth: '100%',
|
|
917
|
-
overflowX: 'auto',
|
|
918
|
-
overflowY: 'hidden',
|
|
919
|
-
}); },
|
|
920
|
-
});
|
|
921
|
-
});
|
|
922
|
-
|
|
923
920
|
var filterProps = function (props) {
|
|
924
921
|
props.icon; props.action; var filteredProps = __rest$1(props, ["icon", "action"]);
|
|
925
922
|
return filteredProps;
|
|
@@ -973,17 +970,54 @@ var makeColumns = function (config) {
|
|
|
973
970
|
return memoizedColumns;
|
|
974
971
|
};
|
|
975
972
|
|
|
973
|
+
var GlobalFilter = function (props) {
|
|
974
|
+
var value = props.value, setValue = props.setValue, restProps = __rest$1(props, ["value", "setValue"]);
|
|
975
|
+
var onChange = restProps.onChange, InputProps = restProps.InputProps, cleanRestProps = __rest$1(restProps, ["onChange", "InputProps"]);
|
|
976
|
+
var handleChange = function (e) {
|
|
977
|
+
setValue(e.target.value);
|
|
978
|
+
if (onChange) {
|
|
979
|
+
onChange(e);
|
|
980
|
+
}
|
|
981
|
+
};
|
|
982
|
+
return (React__default['default'].createElement(core.TextField, __assign$1({ variant: "outlined", value: value, onChange: handleChange, InputProps: __assign$1({ startAdornment: (React__default['default'].createElement(core.InputAdornment, { position: "start" },
|
|
983
|
+
React__default['default'].createElement(Icon, { icon: SvgSearch }))) }, InputProps) }, cleanRestProps)));
|
|
984
|
+
};
|
|
985
|
+
|
|
986
|
+
var useTableStyles = core.makeStyles(function (_a) {
|
|
987
|
+
var typography = _a.typography;
|
|
988
|
+
return ({
|
|
989
|
+
root: function (_a) {
|
|
990
|
+
var fullWidth = _a.fullWidth;
|
|
991
|
+
return ({
|
|
992
|
+
display: fullWidth ? 'flex' : 'inline-flex',
|
|
993
|
+
flexDirection: 'column',
|
|
994
|
+
});
|
|
995
|
+
},
|
|
996
|
+
table: function (_a) {
|
|
997
|
+
var fullWidth = _a.fullWidth;
|
|
998
|
+
return (__assign$1(__assign$1({ borderCollapse: 'collapse' }, (fullWidth && { width: '100%' })), typography[tableConstants.tableTypography]));
|
|
999
|
+
},
|
|
1000
|
+
tableWrap: function () { return ({
|
|
1001
|
+
maxWidth: '100%',
|
|
1002
|
+
overflowX: 'auto',
|
|
1003
|
+
overflowY: 'hidden',
|
|
1004
|
+
}); },
|
|
1005
|
+
});
|
|
1006
|
+
});
|
|
1007
|
+
|
|
976
1008
|
/* eslint-disable react/jsx-key */
|
|
977
1009
|
var Table = function (props) {
|
|
1010
|
+
// Setup
|
|
978
1011
|
var actionColumnId = 'table-actions-column';
|
|
979
|
-
var rawColumns = props.columns, data = props.data, actions = props.actions, sortable = props.sortable, emptyMessage = props.emptyMessage, EmptyImage = props.EmptyImage, isLoading = props.loading, fullHeight = props.fullHeight, _a = props.paginationOptions, paginationOptions = _a === void 0 ? {} : _a, _b = props.tableOptions, tableOptions = _b === void 0 ? {} : _b, onPaginate = props.onPaginate;
|
|
1012
|
+
var rawColumns = props.columns, data = props.data, actions = props.actions, sortable = props.sortable, emptyMessage = props.emptyMessage, EmptyImage = props.EmptyImage, isLoading = props.loading, fullHeight = props.fullHeight, GlobalFilterProps = props.GlobalFilterProps, _a = props.paginationOptions, paginationOptions = _a === void 0 ? {} : _a, _b = props.tableOptions, tableOptions = _b === void 0 ? {} : _b, searchable = props.searchable, onPaginate = props.onPaginate;
|
|
980
1013
|
var theme = core.useTheme();
|
|
981
1014
|
var classes = useTableStyles(props);
|
|
982
1015
|
var columns = React.useMemo(function () { return makeColumns({ columns: rawColumns, actions: actions, actionColumnId: actionColumnId }); }, [rawColumns, actions]);
|
|
983
1016
|
var initialPaginationState = paginationOptions.initialState, restPaginationOptions = __rest$1(paginationOptions, ["initialState"]);
|
|
984
1017
|
var initialState = __assign$1({}, initialPaginationState);
|
|
985
|
-
var instance = useTable_js.useTable(__assign$1(__assign$1({ columns: columns, data: data, disableSortBy: !sortable, initialState: initialState }, restPaginationOptions), tableOptions), useSortBy_js.useSortBy, usePagination_js.usePagination);
|
|
986
|
-
var getTableProps = instance.getTableProps, getTableBodyProps = instance.getTableBodyProps, headerGroups = instance.headerGroups, page = instance.page, prepareRow = instance.prepareRow, pageCount = instance.pageCount, gotoPage = instance.gotoPage, rows = instance.rows;
|
|
1018
|
+
var instance = useTable_js.useTable(__assign$1(__assign$1({ columns: columns, data: data, disableSortBy: !sortable, initialState: initialState }, restPaginationOptions), tableOptions), useGlobalFilter_js.useGlobalFilter, useSortBy_js.useSortBy, usePagination_js.usePagination);
|
|
1019
|
+
var getTableProps = instance.getTableProps, getTableBodyProps = instance.getTableBodyProps, headerGroups = instance.headerGroups, page = instance.page, prepareRow = instance.prepareRow, pageCount = instance.pageCount, gotoPage = instance.gotoPage, rows = instance.rows, state = instance.state, setGlobalFilter = instance.setGlobalFilter;
|
|
1020
|
+
// Aliases
|
|
987
1021
|
var isPaginated = pageCount > 1;
|
|
988
1022
|
var isEmpty = rows.length === 0;
|
|
989
1023
|
var lineHeightRem = parseFloat(theme.typography[tableConstants.tableTypography].lineHeight);
|
|
@@ -994,6 +1028,7 @@ var Table = function (props) {
|
|
|
994
1028
|
var bodyHeight = instance.state.pageSize * cellHeight;
|
|
995
1029
|
var footerHeight = 88;
|
|
996
1030
|
var minHeight = headerHeight + bodyHeight + footerHeight;
|
|
1031
|
+
// Handlers
|
|
997
1032
|
var handlePagination = function (_e, pageNumber) {
|
|
998
1033
|
var pageIndex = pageNumber - 1;
|
|
999
1034
|
if (onPaginate) {
|
|
@@ -1004,6 +1039,8 @@ var Table = function (props) {
|
|
|
1004
1039
|
}
|
|
1005
1040
|
};
|
|
1006
1041
|
return (React__default['default'].createElement(core.Box, { className: classes.root, minHeight: fullHeight ? minHeight : 'unset' },
|
|
1042
|
+
searchable && (React__default['default'].createElement(core.Box, null,
|
|
1043
|
+
React__default['default'].createElement(GlobalFilter, __assign$1({ value: state.globalFilter, setValue: setGlobalFilter }, GlobalFilterProps)))),
|
|
1007
1044
|
React__default['default'].createElement(core.Box, { className: classes.tableWrap },
|
|
1008
1045
|
React__default['default'].createElement("table", __assign$1({ className: classes.table }, getTableProps()),
|
|
1009
1046
|
React__default['default'].createElement(TableHeader, null, headerGroups.map(function (headerGroup) { return (React__default['default'].createElement(TableHeaderRow, __assign$1({}, headerGroup.getHeaderGroupProps()), headerGroup.headers.map(function (column) { return (React__default['default'].createElement(TableHeaderCell, __assign$1({}, column.getHeaderProps(column.getSortByToggleProps()), { column: __assign$1(__assign$1({}, column), { isActionColumn: column.id === actionColumnId }), tableProps: props }), column.render('Header'))); }))); })),
|