@insticc/react-datagrid-2 1.0.5 → 1.0.7
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/index.js +17 -115
- package/build/utils/filters.js +6 -4
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports["default"] = void 0;
|
|
8
4
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
5
|
var _propTypes = _interopRequireWildcard(require("prop-types"));
|
|
10
6
|
var _materialReactTable = require("material-react-table");
|
|
@@ -83,6 +79,16 @@ var DataGrid = function DataGrid(_ref) {
|
|
|
83
79
|
_useState2 = _slicedToArray(_useState, 2),
|
|
84
80
|
rowSelection = _useState2[0],
|
|
85
81
|
setRowSelection = _useState2[1];
|
|
82
|
+
var _useState3 = (0, _react.useState)(true),
|
|
83
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
84
|
+
isLoading = _useState4[0],
|
|
85
|
+
setIsLoading = _useState4[1];
|
|
86
|
+
var _useState5 = (0, _react.useState)([]),
|
|
87
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
88
|
+
sorting = _useState6[0],
|
|
89
|
+
setSorting = _useState6[1];
|
|
90
|
+
//optionally access the underlying virtualizer instance
|
|
91
|
+
var rowVirtualizerInstanceRef = (0, _react.useRef)(null);
|
|
86
92
|
|
|
87
93
|
// get the selected rows (if is a int that means that the row is selected if is a double that means that is a subrow)
|
|
88
94
|
// so if is a subrow we need to go to the parent row and get the id that is on the position after the .
|
|
@@ -122,17 +128,6 @@ var DataGrid = function DataGrid(_ref) {
|
|
|
122
128
|
}));
|
|
123
129
|
}
|
|
124
130
|
}, [rowSelection]);
|
|
125
|
-
|
|
126
|
-
//optionally access the underlying virtualizer instance
|
|
127
|
-
var rowVirtualizerInstanceRef = (0, _react.useRef)(null);
|
|
128
|
-
var _useState3 = (0, _react.useState)(true),
|
|
129
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
130
|
-
isLoading = _useState4[0],
|
|
131
|
-
setIsLoading = _useState4[1];
|
|
132
|
-
var _useState5 = (0, _react.useState)([]),
|
|
133
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
134
|
-
sorting = _useState6[0],
|
|
135
|
-
setSorting = _useState6[1];
|
|
136
131
|
(0, _react.useEffect)(function () {
|
|
137
132
|
if (typeof window !== 'undefined') {
|
|
138
133
|
setIsLoading(false);
|
|
@@ -553,6 +548,12 @@ DataGrid.propTypes = {
|
|
|
553
548
|
enableGlobalFilter: _propTypes["default"].bool,
|
|
554
549
|
enableVirtualization: _propTypes["default"].bool
|
|
555
550
|
};
|
|
551
|
+
|
|
552
|
+
// export default DataGrid;
|
|
553
|
+
module.exports = {
|
|
554
|
+
DataGrid: DataGrid
|
|
555
|
+
};
|
|
556
|
+
|
|
556
557
|
// DataGrid.defaultProps = {
|
|
557
558
|
// hasExcelExport: false,
|
|
558
559
|
// hasPdfExport: false,
|
|
@@ -565,103 +566,4 @@ DataGrid.propTypes = {
|
|
|
565
566
|
// pagination: 'both',
|
|
566
567
|
// itemsPerPage: [10, 15, 20, 25],
|
|
567
568
|
// rowHeight: 60,
|
|
568
|
-
// };
|
|
569
|
-
var _default = exports["default"] = DataGrid;
|
|
570
|
-
/**
|
|
571
|
-
* [ DataGrid Example ]
|
|
572
|
-
import React from "react";
|
|
573
|
-
import { Icon } from "semantic-ui-react";
|
|
574
|
-
import DataGrid from "../../Components/DataGrid";
|
|
575
|
-
class DataGridExample extends React.Component {
|
|
576
|
-
constructor(props) {
|
|
577
|
-
super(props);
|
|
578
|
-
this.state = {};
|
|
579
|
-
}
|
|
580
|
-
// ... Omited code related to the data fetching
|
|
581
|
-
getActions = () => {
|
|
582
|
-
return [
|
|
583
|
-
{
|
|
584
|
-
name: "Edit",
|
|
585
|
-
onClick: this.editRow,
|
|
586
|
-
icon: <Icon name="edit"/>,
|
|
587
|
-
selectionMode: "multi",
|
|
588
|
-
},
|
|
589
|
-
{
|
|
590
|
-
name: "Delete",
|
|
591
|
-
onClick: this.deleteRow,
|
|
592
|
-
icon: require("../../images/trash.png"),
|
|
593
|
-
color: "red",
|
|
594
|
-
selectionMode: "single",
|
|
595
|
-
confirmMessage: "Are you sure you want to delete this row?",
|
|
596
|
-
},
|
|
597
|
-
]
|
|
598
|
-
}
|
|
599
|
-
createColumns = () => {
|
|
600
|
-
return [
|
|
601
|
-
{
|
|
602
|
-
accessorKey: 'id',
|
|
603
|
-
header: 'ID',
|
|
604
|
-
size: 350,
|
|
605
|
-
enableClickToCopy: true,
|
|
606
|
-
Cell: ({ renderedCellValue }) => (
|
|
607
|
-
<span>
|
|
608
|
-
<Icon name="copy outline"/> {renderedCellValue}
|
|
609
|
-
</span>
|
|
610
|
-
),
|
|
611
|
-
},
|
|
612
|
-
{
|
|
613
|
-
accessorKey: 'name',
|
|
614
|
-
header: 'Name',
|
|
615
|
-
size: 400,
|
|
616
|
-
filterFn: 'regex',
|
|
617
|
-
},
|
|
618
|
-
{
|
|
619
|
-
accessorKey: 'description',
|
|
620
|
-
header: 'Description',
|
|
621
|
-
enableResizing: false,
|
|
622
|
-
},
|
|
623
|
-
{
|
|
624
|
-
accessorKey: 'type',
|
|
625
|
-
header: 'Type',
|
|
626
|
-
enableColumnFilterModes: false,
|
|
627
|
-
},
|
|
628
|
-
{
|
|
629
|
-
accessorFn: (row) => `${row.senderContext} ${row.role} (${row.contextType})`,
|
|
630
|
-
header: 'Sender',
|
|
631
|
-
size: 300,
|
|
632
|
-
},
|
|
633
|
-
]
|
|
634
|
-
}
|
|
635
|
-
getRows = () => {
|
|
636
|
-
const rows = this.props.data.map((rule) => {
|
|
637
|
-
return {
|
|
638
|
-
id: rule.idRule,
|
|
639
|
-
name: rule.name,
|
|
640
|
-
description: rule.description || 'N/A',
|
|
641
|
-
type: rule.RuleType.name,
|
|
642
|
-
senderContext: rule.Sender.context || '',
|
|
643
|
-
role: rule.Sender.role,
|
|
644
|
-
contextType: rule.ContextType.name,
|
|
645
|
-
context: rule.context,
|
|
646
|
-
conditions: rule.Conditions || [],
|
|
647
|
-
addressee: rule.addressee || '',
|
|
648
|
-
contact: rule.contactProperty || '',
|
|
649
|
-
createdAt: rule.createdAt || '',
|
|
650
|
-
}
|
|
651
|
-
})
|
|
652
|
-
return rows;
|
|
653
|
-
}
|
|
654
|
-
render() {
|
|
655
|
-
return (
|
|
656
|
-
<DataGrid
|
|
657
|
-
createRows={this.getRows()}
|
|
658
|
-
columns={this.createColumns()}
|
|
659
|
-
actions={this.getActions()}
|
|
660
|
-
rowHeight=90
|
|
661
|
-
hasExcelExport={true}
|
|
662
|
-
excelOption="all"
|
|
663
|
-
/>
|
|
664
|
-
);
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
*/
|
|
569
|
+
// };
|
package/build/utils/filters.js
CHANGED
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.regexFilterTooltip = exports.logicalFilterTooltip = exports.logicalFilter = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
7
8
|
var _semanticUiReact = require("semantic-ui-react");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
8
10
|
var logicalFilter = exports.logicalFilter = function logicalFilter(row, id, filterValue) {
|
|
9
11
|
var rowValue = row.getValue(id).toLowerCase();
|
|
10
12
|
var contains = function contains(value, term) {
|
|
@@ -45,17 +47,17 @@ var logicalFilter = exports.logicalFilter = function logicalFilter(row, id, filt
|
|
|
45
47
|
if (!parts) return false;
|
|
46
48
|
return analyseParts(parts);
|
|
47
49
|
};
|
|
48
|
-
var logicalFilterTooltip = exports.logicalFilterTooltip = /*#__PURE__*/
|
|
50
|
+
var logicalFilterTooltip = exports.logicalFilterTooltip = /*#__PURE__*/_react["default"].createElement("div", {
|
|
49
51
|
style: {
|
|
50
52
|
display: 'flex',
|
|
51
53
|
flexDirection: 'column',
|
|
52
54
|
textAlign: 'start'
|
|
53
55
|
}
|
|
54
|
-
}, "This filter admits logical operators such as:", /*#__PURE__*/
|
|
55
|
-
var regexFilterTooltip = exports.regexFilterTooltip = /*#__PURE__*/
|
|
56
|
+
}, "This filter admits logical operators such as:", /*#__PURE__*/_react["default"].createElement("ul", null, /*#__PURE__*/_react["default"].createElement("li", null, "'&&' (AND) "), /*#__PURE__*/_react["default"].createElement("li", null, "'||' (OR) "), /*#__PURE__*/_react["default"].createElement("li", null, "'~' (NOT) ")), /*#__PURE__*/_react["default"].createElement("br", null), "These operators can be combined.", /*#__PURE__*/_react["default"].createElement("br", null), "For example, 'John Doe && Smith || James' will return rows that have both 'John Doe' and 'Smith', or 'James'.");
|
|
57
|
+
var regexFilterTooltip = exports.regexFilterTooltip = /*#__PURE__*/_react["default"].createElement("div", {
|
|
56
58
|
style: {
|
|
57
59
|
display: 'flex',
|
|
58
60
|
flexDirection: 'column',
|
|
59
61
|
textAlign: 'start'
|
|
60
62
|
}
|
|
61
|
-
}, "This filter enables the use of regular expression to search for patterns in the row data.", /*#__PURE__*/
|
|
63
|
+
}, "This filter enables the use of regular expression to search for patterns in the row data.", /*#__PURE__*/_react["default"].createElement("br", null), "For example, '^[A-Z]' will find entries that start with a capital letter.");
|