@popmenu/table 0.20.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 +121 -56
- package/build/index.es.js.map +1 -1
- package/build/index.js +120 -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
|
}
|
|
@@ -720,6 +721,34 @@ var Tooltip = React.forwardRef(function (props, ref) {
|
|
|
720
721
|
});
|
|
721
722
|
Tooltip.displayName = 'Tooltip';
|
|
722
723
|
|
|
724
|
+
core.makeStyles(function () { return ({
|
|
725
|
+
root: {
|
|
726
|
+
height: 56,
|
|
727
|
+
},
|
|
728
|
+
}); });
|
|
729
|
+
core.makeStyles(function (theme) { return ({
|
|
730
|
+
root: {
|
|
731
|
+
height: '100%',
|
|
732
|
+
width: 'min-content',
|
|
733
|
+
borderRadius: theme.spacing(1),
|
|
734
|
+
},
|
|
735
|
+
input: {
|
|
736
|
+
'&::-webkit-clear-button, &::-webkit-outer-spin-button, &::-webkit-inner-spin-button': {
|
|
737
|
+
display: 'none',
|
|
738
|
+
},
|
|
739
|
+
'-moz-appearance': 'textfield',
|
|
740
|
+
minWidth: 40,
|
|
741
|
+
padding: 0,
|
|
742
|
+
textAlign: 'center',
|
|
743
|
+
},
|
|
744
|
+
adornedStart: {
|
|
745
|
+
padding: 0,
|
|
746
|
+
},
|
|
747
|
+
adornedEnd: {
|
|
748
|
+
padding: 0,
|
|
749
|
+
},
|
|
750
|
+
}); });
|
|
751
|
+
|
|
723
752
|
var TableFooter = function (props) {
|
|
724
753
|
return (React__default['default'].createElement(core.Box, { display: "flex", justifyContent: "center", alignItems: "end", paddingTop: 3, paddingBottom: 4, flexGrow: 1 }, props.children));
|
|
725
754
|
};
|
|
@@ -729,57 +758,75 @@ var TableHeader = function (props) {
|
|
|
729
758
|
return React__default['default'].createElement("thead", __assign$1({}, restProps), children);
|
|
730
759
|
};
|
|
731
760
|
|
|
732
|
-
var _path$
|
|
761
|
+
var _path$4w;
|
|
733
762
|
|
|
734
|
-
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); }
|
|
735
764
|
|
|
736
|
-
function
|
|
737
|
-
return /*#__PURE__*/React__namespace.createElement("svg", _extends$
|
|
765
|
+
function SvgChevronDown(props) {
|
|
766
|
+
return /*#__PURE__*/React__namespace.createElement("svg", _extends$4M({
|
|
738
767
|
viewBox: "0 0 16 16",
|
|
739
768
|
strokeLinecap: "round",
|
|
740
769
|
strokeLinejoin: "round",
|
|
741
770
|
stroke: "currentColor",
|
|
771
|
+
fill: "none",
|
|
742
772
|
width: "1em",
|
|
743
|
-
height: "1em"
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
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"
|
|
747
776
|
})));
|
|
748
777
|
}
|
|
749
778
|
|
|
750
|
-
var _path$
|
|
779
|
+
var _path$4v;
|
|
751
780
|
|
|
752
|
-
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); }
|
|
753
782
|
|
|
754
|
-
function
|
|
755
|
-
return /*#__PURE__*/React__namespace.createElement("svg", _extends$
|
|
783
|
+
function SvgChevronUp(props) {
|
|
784
|
+
return /*#__PURE__*/React__namespace.createElement("svg", _extends$4L({
|
|
756
785
|
viewBox: "0 0 16 16",
|
|
757
786
|
strokeLinecap: "round",
|
|
758
787
|
strokeLinejoin: "round",
|
|
759
788
|
stroke: "currentColor",
|
|
789
|
+
fill: "none",
|
|
760
790
|
width: "1em",
|
|
761
|
-
height: "1em"
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
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"
|
|
765
794
|
})));
|
|
766
795
|
}
|
|
767
796
|
|
|
768
|
-
var _path$
|
|
797
|
+
var _path$3c;
|
|
769
798
|
|
|
770
|
-
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); }
|
|
771
800
|
|
|
772
|
-
function
|
|
773
|
-
return /*#__PURE__*/React__namespace.createElement("svg", _extends$
|
|
801
|
+
function SvgMore(props) {
|
|
802
|
+
return /*#__PURE__*/React__namespace.createElement("svg", _extends$3s({
|
|
774
803
|
viewBox: "0 0 16 16",
|
|
775
804
|
strokeLinecap: "round",
|
|
776
805
|
strokeLinejoin: "round",
|
|
777
806
|
stroke: "currentColor",
|
|
807
|
+
fill: "none",
|
|
778
808
|
width: "1em",
|
|
779
|
-
height: "1em"
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
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"
|
|
783
830
|
})));
|
|
784
831
|
}
|
|
785
832
|
|
|
@@ -870,28 +917,6 @@ var TableCell = function (props) {
|
|
|
870
917
|
return (React__default['default'].createElement("td", __assign$1({ className: root }, restProps), children));
|
|
871
918
|
};
|
|
872
919
|
|
|
873
|
-
var useTableStyles = core.makeStyles(function (_a) {
|
|
874
|
-
var typography = _a.typography;
|
|
875
|
-
return ({
|
|
876
|
-
root: function (_a) {
|
|
877
|
-
var fullWidth = _a.fullWidth;
|
|
878
|
-
return ({
|
|
879
|
-
display: fullWidth ? 'flex' : 'inline-flex',
|
|
880
|
-
flexDirection: 'column',
|
|
881
|
-
});
|
|
882
|
-
},
|
|
883
|
-
table: function (_a) {
|
|
884
|
-
var fullWidth = _a.fullWidth;
|
|
885
|
-
return (__assign$1(__assign$1({ borderCollapse: 'collapse' }, (fullWidth && { width: '100%' })), typography[tableConstants.tableTypography]));
|
|
886
|
-
},
|
|
887
|
-
tableWrap: function () { return ({
|
|
888
|
-
maxWidth: '100%',
|
|
889
|
-
overflowX: 'auto',
|
|
890
|
-
overflowY: 'hidden',
|
|
891
|
-
}); },
|
|
892
|
-
});
|
|
893
|
-
});
|
|
894
|
-
|
|
895
920
|
var filterProps = function (props) {
|
|
896
921
|
props.icon; props.action; var filteredProps = __rest$1(props, ["icon", "action"]);
|
|
897
922
|
return filteredProps;
|
|
@@ -945,17 +970,54 @@ var makeColumns = function (config) {
|
|
|
945
970
|
return memoizedColumns;
|
|
946
971
|
};
|
|
947
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
|
+
|
|
948
1008
|
/* eslint-disable react/jsx-key */
|
|
949
1009
|
var Table = function (props) {
|
|
1010
|
+
// Setup
|
|
950
1011
|
var actionColumnId = 'table-actions-column';
|
|
951
|
-
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;
|
|
952
1013
|
var theme = core.useTheme();
|
|
953
1014
|
var classes = useTableStyles(props);
|
|
954
1015
|
var columns = React.useMemo(function () { return makeColumns({ columns: rawColumns, actions: actions, actionColumnId: actionColumnId }); }, [rawColumns, actions]);
|
|
955
1016
|
var initialPaginationState = paginationOptions.initialState, restPaginationOptions = __rest$1(paginationOptions, ["initialState"]);
|
|
956
1017
|
var initialState = __assign$1({}, initialPaginationState);
|
|
957
|
-
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);
|
|
958
|
-
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
|
|
959
1021
|
var isPaginated = pageCount > 1;
|
|
960
1022
|
var isEmpty = rows.length === 0;
|
|
961
1023
|
var lineHeightRem = parseFloat(theme.typography[tableConstants.tableTypography].lineHeight);
|
|
@@ -966,6 +1028,7 @@ var Table = function (props) {
|
|
|
966
1028
|
var bodyHeight = instance.state.pageSize * cellHeight;
|
|
967
1029
|
var footerHeight = 88;
|
|
968
1030
|
var minHeight = headerHeight + bodyHeight + footerHeight;
|
|
1031
|
+
// Handlers
|
|
969
1032
|
var handlePagination = function (_e, pageNumber) {
|
|
970
1033
|
var pageIndex = pageNumber - 1;
|
|
971
1034
|
if (onPaginate) {
|
|
@@ -976,6 +1039,8 @@ var Table = function (props) {
|
|
|
976
1039
|
}
|
|
977
1040
|
};
|
|
978
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)))),
|
|
979
1044
|
React__default['default'].createElement(core.Box, { className: classes.tableWrap },
|
|
980
1045
|
React__default['default'].createElement("table", __assign$1({ className: classes.table }, getTableProps()),
|
|
981
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'))); }))); })),
|