@gpa-gemstone/react-table 1.2.10 → 1.2.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  export interface Column<T> {
3
3
  key: string;
4
- label: string;
4
+ label: string | React.ReactNode;
5
5
  field?: keyof T;
6
6
  headerStyle?: React.CSSProperties;
7
7
  rowStyle?: React.CSSProperties;
@@ -16,7 +16,7 @@ export interface TableProps<T> {
16
16
  * List of T objects used to generate rows
17
17
  */
18
18
  data: T[];
19
- onClick: (data: {
19
+ onClick?: (data: {
20
20
  colKey: string;
21
21
  colField?: keyof T;
22
22
  row: T;
@@ -35,7 +35,7 @@ export interface TableProps<T> {
35
35
  colKey: string;
36
36
  colField?: keyof T;
37
37
  ascending: boolean;
38
- }): void;
38
+ }, event: any): void;
39
39
  tableClass?: string;
40
40
  tableStyle?: React.CSSProperties;
41
41
  theadStyle?: React.CSSProperties;
package/lib/Table.js CHANGED
@@ -34,14 +34,15 @@ var __assign = (this && this.__assign) || function () {
34
34
  };
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.Header = exports.Rows = void 0;
37
+ var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
37
38
  var React = require("react");
38
39
  function Table(props) {
39
40
  return (React.createElement("table", { className: props.tableClass !== undefined ? props.tableClass : '', style: props.tableStyle },
40
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); } }),
41
- 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(data, e); }, Selected: props.selected, KeySelector: props.keySelector })));
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
43
  function handleSort(data, event) {
43
44
  if (data.colKey !== null)
44
- props.onSort(data);
45
+ props.onSort(data, event);
45
46
  }
46
47
  }
47
48
  exports.default = Table;
@@ -87,11 +88,12 @@ function HeaderCell(props) {
87
88
  style.position = 'relative';
88
89
  }
89
90
  return (React.createElement("th", { style: style, onClick: function (e) { return props.Click(e); } },
90
- React.createElement(RenderAngleIcon, { SortKey: props.SortKey, Key: props.DataKey, Ascending: props.Ascending }),
91
- React.createElement("div", { style: { marginLeft: 10 } }, props.Label)));
91
+ React.createElement("div", { style: { position: 'absolute', width: 25 } },
92
+ React.createElement(RenderAngleIcon, { SortKey: props.SortKey, Key: props.DataKey, Ascending: props.Ascending })),
93
+ React.createElement("div", { style: { marginLeft: 25 } }, props.Label)));
92
94
  }
93
95
  function RenderAngleIcon(props) {
94
- var AngleIcon = function () { return (React.createElement("div", { style: { position: 'absolute', top: 10, transform: (props.Ascending ? 'rotate(0deg)' : 'rotate(180deg)') } }, '^')); };
96
+ var AngleIcon = function (a) { return a.ascending ? gpa_symbols_1.SVGIcons.ArrowDropUp : gpa_symbols_1.SVGIcons.ArrowDropDown; };
95
97
  if (props.SortKey === null)
96
98
  return null;
97
99
  if (props.SortKey !== props.Key)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gpa-gemstone/react-table",
3
- "version": "1.2.10",
3
+ "version": "1.2.13",
4
4
  "description": "Table for GPA web applications",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -45,6 +45,7 @@
45
45
  "typescript": "4.4.4"
46
46
  },
47
47
  "dependencies": {
48
+ "@gpa-gemstone/gpa-symbols": "0.0.20",
48
49
  "@gpa-gemstone/helper-functions": "0.0.14",
49
50
  "@types/lodash": "^4.14.171",
50
51
  "@types/react": "^17.0.14",