@gpa-gemstone/react-table 1.2.22 → 1.2.24
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/lib/Table.d.ts +14 -0
- package/lib/Table.js +6 -3
- package/package.json +3 -3
package/lib/Table.d.ts
CHANGED
|
@@ -43,6 +43,13 @@ export interface TableProps<T> {
|
|
|
43
43
|
tbodyStyle?: React.CSSProperties;
|
|
44
44
|
tbodyClass?: string;
|
|
45
45
|
selected?(data: T): boolean;
|
|
46
|
+
onDragStart?: ((data: {
|
|
47
|
+
colKey: string;
|
|
48
|
+
colField?: keyof T;
|
|
49
|
+
row: T;
|
|
50
|
+
data: T[keyof T] | null;
|
|
51
|
+
index: number;
|
|
52
|
+
}, e: any) => void);
|
|
46
53
|
rowStyle?: React.CSSProperties;
|
|
47
54
|
keySelector?: (data: T) => string;
|
|
48
55
|
/**
|
|
@@ -65,6 +72,13 @@ interface IRowProps<T> {
|
|
|
65
72
|
data: T[keyof T] | null;
|
|
66
73
|
index: number;
|
|
67
74
|
}, e: React.MouseEvent<HTMLTableHeaderCellElement, MouseEvent>) => void;
|
|
75
|
+
DragStart?: ((data: {
|
|
76
|
+
colKey: string;
|
|
77
|
+
colField?: keyof T;
|
|
78
|
+
row: T;
|
|
79
|
+
data: T[keyof T] | null;
|
|
80
|
+
index: number;
|
|
81
|
+
}, e: any) => void);
|
|
68
82
|
Selected?: ((data: T) => boolean);
|
|
69
83
|
KeySelector?: (data: T) => string;
|
|
70
84
|
}
|
package/lib/Table.js
CHANGED
|
@@ -39,7 +39,7 @@ var React = require("react");
|
|
|
39
39
|
function Table(props) {
|
|
40
40
|
return (React.createElement("table", { className: props.tableClass !== undefined ? props.tableClass : '', style: props.tableStyle },
|
|
41
41
|
React.createElement(Header, { Class: props.theadClass, Style: props.theadStyle, Cols: props.cols, SortKey: props.sortKey, Ascending: props.ascending, Click: function (d, e) { return handleSort(d, e); } }),
|
|
42
|
-
React.createElement(Rows, { Data: props.data, Cols: props.cols, RowStyle: props.rowStyle, BodyStyle: props.tbodyStyle, BodyClass: props.tbodyClass, Click: function (data, e) { return (props.onClick === undefined ? null : props.onClick(data, e)); }, Selected: props.selected, KeySelector: props.keySelector }),
|
|
42
|
+
React.createElement(Rows, { DragStart: props.onDragStart, Data: props.data, Cols: props.cols, RowStyle: props.rowStyle, BodyStyle: props.tbodyStyle, BodyClass: props.tbodyClass, Click: function (data, e) { return (props.onClick === undefined ? null : props.onClick(data, e)); }, Selected: props.selected, KeySelector: props.keySelector }),
|
|
43
43
|
props.lastRow !== undefined ? React.createElement("tr", { style: (props.rowStyle !== undefined) ? __assign({}, props.rowStyle) : {}, key: -1 }, props.lastRow) : null));
|
|
44
44
|
function handleSort(data, event) {
|
|
45
45
|
if (data.colKey !== null)
|
|
@@ -52,7 +52,7 @@ function Rows(props) {
|
|
|
52
52
|
return null;
|
|
53
53
|
var rows = props.Data.map(function (item, rowIndex) {
|
|
54
54
|
var cells = props.Cols.map(function (colData) {
|
|
55
|
-
return React.createElement(Cell, { key: colData.key, Style: colData.rowStyle, DataKey: colData.key, DataField: colData.field, Object: item, RowIndex: rowIndex, Content: colData.content, Click: function (data, e) { return props.Click(data, e); } });
|
|
55
|
+
return React.createElement(Cell, { key: colData.key, Style: colData.rowStyle, DataKey: colData.key, DataField: colData.field, Object: item, RowIndex: rowIndex, Content: colData.content, Click: function (data, e) { return props.Click(data, e); }, DragStart: props.DragStart });
|
|
56
56
|
});
|
|
57
57
|
var style = (props.RowStyle !== undefined) ? __assign({}, props.RowStyle) : {};
|
|
58
58
|
if (style.cursor === undefined)
|
|
@@ -71,9 +71,12 @@ function Rows(props) {
|
|
|
71
71
|
exports.Rows = Rows;
|
|
72
72
|
function Cell(props) {
|
|
73
73
|
var css = (props.Style !== undefined) ? __assign({}, props.Style) : {};
|
|
74
|
+
if (props.DragStart !== undefined)
|
|
75
|
+
css.cursor = "grab";
|
|
74
76
|
var getFieldValue = function () { return props.DataField !== undefined ? props.Object[props.DataField] : null; };
|
|
75
77
|
var getFieldContent = function () { return props.Content !== undefined ? props.Content(props.Object, props.DataKey, props.DataField, css, props.RowIndex) : getFieldValue(); };
|
|
76
|
-
return (React.createElement("td", { style: css, onClick: function (e) { return props.Click({ colKey: props.DataKey, colField: props.DataField, row: props.Object, data: getFieldValue(), index: props.RowIndex }, e); }
|
|
78
|
+
return (React.createElement("td", { style: css, onClick: function (e) { return props.Click({ colKey: props.DataKey, colField: props.DataField, row: props.Object, data: getFieldValue(), index: props.RowIndex }, e); }, draggable: props.DragStart !== undefined, onDragStart: function (e) { if (props.DragStart !== undefined)
|
|
79
|
+
props.DragStart({ colKey: props.DataKey, colField: props.DataField, row: props.Object, data: getFieldValue(), index: props.RowIndex }, e); } }, getFieldContent()));
|
|
77
80
|
}
|
|
78
81
|
function Header(props) {
|
|
79
82
|
return (React.createElement("thead", { className: props.Class, style: props.Style },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gpa-gemstone/react-table",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.24",
|
|
4
4
|
"description": "Table for GPA web applications",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"typescript": "4.4.4"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@gpa-gemstone/gpa-symbols": "0.0.
|
|
45
|
-
"@gpa-gemstone/helper-functions": "0.0.
|
|
44
|
+
"@gpa-gemstone/gpa-symbols": "0.0.26",
|
|
45
|
+
"@gpa-gemstone/helper-functions": "0.0.20",
|
|
46
46
|
"@types/lodash": "^4.14.171",
|
|
47
47
|
"@types/react": "^17.0.14",
|
|
48
48
|
"lodash": "^4.17.21",
|