@gpa-gemstone/react-table 1.2.56 → 1.2.58

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.
Files changed (47) hide show
  1. package/lib/AdjustableTable/Column.d.ts +6 -45
  2. package/lib/AdjustableTable/Column.js +32 -53
  3. package/lib/AdjustableTable/Table.d.ts +2 -116
  4. package/lib/AdjustableTable/Table.js +329 -347
  5. package/lib/AdjustableTable/Types.d.ts +148 -0
  6. package/lib/AdjustableTable/Types.js +24 -0
  7. package/lib/ConfigurableTable/ConfigurableColumn.d.ts +11 -0
  8. package/lib/ConfigurableTable/ConfigurableColumn.js +31 -0
  9. package/lib/ConfigurableTable/ConfigurableTable.d.ts +25 -0
  10. package/lib/ConfigurableTable/ConfigurableTable.js +189 -0
  11. package/lib/FilterableTable/BooleanFilter.d.ts +26 -0
  12. package/lib/FilterableTable/BooleanFilter.js +68 -0
  13. package/lib/FilterableTable/DateTimeFilters.d.ts +10 -0
  14. package/lib/FilterableTable/DateTimeFilters.js +321 -0
  15. package/lib/FilterableTable/EnumFilter.d.ts +37 -0
  16. package/lib/FilterableTable/EnumFilter.js +89 -0
  17. package/lib/FilterableTable/FilterableColumn.d.ts +20 -0
  18. package/lib/FilterableTable/FilterableColumn.js +34 -0
  19. package/lib/FilterableTable/FilterableTable.d.ts +12 -0
  20. package/lib/FilterableTable/FilterableTable.js +95 -0
  21. package/lib/FilterableTable/NumberFilter.d.ts +19 -0
  22. package/lib/FilterableTable/NumberFilter.js +160 -0
  23. package/lib/FilterableTable/TextFilter.d.ts +14 -0
  24. package/lib/FilterableTable/TextFilter.js +78 -0
  25. package/lib/Filters/BooleanFilter.d.ts +26 -0
  26. package/lib/Filters/BooleanFilter.js +68 -0
  27. package/lib/Filters/DateTimeFilters.d.ts +10 -0
  28. package/lib/Filters/DateTimeFilters.js +321 -0
  29. package/lib/Filters/EnumFilter.d.ts +37 -0
  30. package/lib/Filters/EnumFilter.js +89 -0
  31. package/lib/Filters/NumberFilter.d.ts +19 -0
  32. package/lib/Filters/NumberFilter.js +160 -0
  33. package/lib/Filters/TextFilter.d.ts +14 -0
  34. package/lib/Filters/TextFilter.js +78 -0
  35. package/lib/Table/Column.d.ts +19 -0
  36. package/lib/Table/Column.js +73 -0
  37. package/lib/Table/FilterableColumn.d.ts +20 -0
  38. package/lib/Table/FilterableColumn.js +74 -0
  39. package/lib/Table/Table.d.ts +3 -0
  40. package/lib/Table/Table.js +498 -0
  41. package/lib/Table/Types.d.ts +185 -0
  42. package/lib/Table/Types.js +24 -0
  43. package/lib/index.d.ts +7 -14
  44. package/lib/index.js +13 -19
  45. package/package.json +56 -52
  46. package/lib/AdjustableTable/AdjustableColumn.d.ts +0 -18
  47. package/lib/AdjustableTable/AdjustableColumn.js +0 -187
@@ -1,59 +1,20 @@
1
1
  import * as React from 'react';
2
- export interface IColumnProps<T> {
3
- /**
4
- * a unique Key for this Collumn
5
- */
6
- Key: string;
7
- /**
8
- * Flag indicating whether sorting by this Collumn is allowed
9
- */
10
- AllowSort?: boolean;
11
- /**
12
- * Optional - the Field to be used
13
- */
14
- Field?: keyof T;
15
- /**
16
- * The Default style for the th element
17
- */
18
- HeaderStyle?: React.CSSProperties;
19
- /**
20
- * The Default style for the td element
21
- */
22
- RowStyle?: React.CSSProperties;
23
- /**
24
- * Determines the Content to be displayed
25
- * @param d the data to be turned into content
26
- * @returns the content displayed
27
- */
28
- Content?: (d: {
29
- item: T;
30
- key: string;
31
- field: keyof T | undefined;
32
- index: number;
33
- style?: React.CSSProperties;
34
- }) => React.ReactNode;
35
- }
36
- export default function Column<T>(props: React.PropsWithChildren<IColumnProps<T>>): JSX.Element;
2
+ import * as ReactTableProps from './Types';
3
+ export declare function AdjustableColumn<T>(props: React.PropsWithChildren<ReactTableProps.IColumn<T>>): JSX.Element;
4
+ export declare function Column<T>(props: React.PropsWithChildren<ReactTableProps.IColumn<T>>): JSX.Element;
37
5
  export interface IHeaderWrapperProps {
38
- setWidth: (w: number, a: boolean, u: boolean) => void;
39
6
  onSort: React.MouseEventHandler<HTMLTableCellElement>;
7
+ startAdjustment?: React.MouseEventHandler<HTMLDivElement>;
40
8
  sorted: boolean;
41
9
  asc: boolean;
42
10
  style: React.CSSProperties;
43
11
  allowSort?: boolean;
44
12
  colKey: string;
45
- width?: number;
46
- enabled: boolean;
47
- extraWidth: number;
48
13
  }
49
- export declare function ColumnHeaderWrapper(props: React.PropsWithChildren<IHeaderWrapperProps>): JSX.Element | null;
14
+ export declare function ColumnHeaderWrapper(props: React.PropsWithChildren<IHeaderWrapperProps>): JSX.Element;
50
15
  export interface IDataWrapperProps {
51
- setWidth: (w: number, a: boolean, u: boolean) => void;
52
- width?: number;
53
- enabled: boolean;
54
16
  dragStart?: (e: React.DragEvent) => void;
55
17
  onClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
56
18
  style: React.CSSProperties;
57
- extraWidth: number;
58
19
  }
59
- export declare function ColumnDataWrapper(props: React.PropsWithChildren<IDataWrapperProps>): JSX.Element | null;
20
+ export declare function ColumnDataWrapper(props: React.PropsWithChildren<IDataWrapperProps>): JSX.Element;
@@ -21,78 +21,57 @@
21
21
  // Generated original version of source code.
22
22
  // 05/31/2024 - C. Lackner
23
23
  // Refactored to fix sizing issues.
24
+ // 12/04/2024 - G. Santos
25
+ // Refactored to fix performance issues.
24
26
  //
25
27
  // ******************************************************************************************************
26
28
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.default = Column;
29
+ exports.AdjustableColumn = AdjustableColumn;
30
+ exports.Column = Column;
28
31
  exports.ColumnHeaderWrapper = ColumnHeaderWrapper;
29
32
  exports.ColumnDataWrapper = ColumnDataWrapper;
30
33
  const gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
31
34
  const React = require("react");
35
+ function AdjustableColumn(props) {
36
+ return React.createElement(React.Fragment, null, props.children);
37
+ }
32
38
  function Column(props) {
33
39
  return React.createElement(React.Fragment, null, props.children);
34
40
  }
35
41
  function ColumnHeaderWrapper(props) {
36
- var _a, _b, _c, _d, _e, _f;
37
- const thref = React.useRef(null);
38
- const style = (props.style !== undefined) ? Object.assign({}, props.style) : {};
39
- style.overflowX = (_a = style.overflowX) !== null && _a !== void 0 ? _a : 'hidden';
40
- style.display = (_b = style.display) !== null && _b !== void 0 ? _b : 'inline-block';
41
- style.position = (_c = style.position) !== null && _c !== void 0 ? _c : 'relative';
42
- style.borderTop = (_d = style.borderTop) !== null && _d !== void 0 ? _d : 'none';
43
- const isAuto = style.width == 'auto';
44
- const isUndefined = style.width === undefined;
45
- if ((style.width == undefined || style.width == 'auto') && props.width !== undefined) {
46
- style.width = (props.width) + props.extraWidth;
47
- }
48
- if (style.cursor === undefined && ((_e = props.allowSort) !== null && _e !== void 0 ? _e : true)) {
49
- style.cursor = 'pointer';
50
- }
51
- React.useLayoutEffect(() => {
52
- var _a;
53
- if (thref.current == null)
54
- return;
55
- const w = (_a = thref.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width;
56
- if (props.width !== undefined && (w === undefined || w == (props.width + props.extraWidth)))
57
- return;
58
- props.setWidth(w, isAuto, isUndefined);
59
- });
42
+ var _a;
43
+ const [showBorder, setShowBorder] = React.useState(false);
44
+ const onHover = React.useCallback(() => { setShowBorder(true); }, []);
45
+ const onLeave = React.useCallback(() => { setShowBorder(false); }, []);
46
+ const onClickBorder = React.useCallback((e) => {
47
+ if (props.startAdjustment != null)
48
+ props.startAdjustment(e);
49
+ }, [props.startAdjustment]);
60
50
  const onClick = React.useCallback((e) => {
61
51
  var _a;
62
52
  if ((_a = props.allowSort) !== null && _a !== void 0 ? _a : true)
63
53
  props.onSort(e);
64
54
  }, [props.onSort, props.allowSort]);
65
- if (props.width != undefined && !props.enabled)
66
- return null;
67
- return React.createElement("th", { ref: thref, style: style, onClick: onClick, onDrag: (e) => { e.stopPropagation(); } },
55
+ const preventPropagation = React.useCallback((e) => {
56
+ e.stopPropagation();
57
+ }, []);
58
+ return React.createElement("th", { style: props.style, onClick: onClick, onDrag: (e) => { e.stopPropagation(); }, id: props.colKey },
59
+ props.startAdjustment == null ? React.createElement(React.Fragment, null) :
60
+ React.createElement("div", { style: {
61
+ width: 5,
62
+ height: '100%',
63
+ position: 'absolute',
64
+ top: 0,
65
+ left: 0,
66
+ opacity: showBorder ? 1 : 0,
67
+ background: '#e9ecef',
68
+ cursor: 'col-resize',
69
+ }, onMouseEnter: onHover, onMouseLeave: onLeave, onMouseDown: onClickBorder, onClick: preventPropagation }),
68
70
  props.sorted ? React.createElement("div", { style: { position: 'absolute', width: 25 } }, props.asc ? React.createElement(gpa_symbols_1.ReactIcons.ArrowDropUp, null) : React.createElement(gpa_symbols_1.ReactIcons.ArrowDropDown, null)) : null,
69
71
  React.createElement("div", { style: {
70
72
  marginLeft: (props.sorted ? 25 : 0),
71
- } }, (_f = props.children) !== null && _f !== void 0 ? _f : props.colKey));
73
+ } }, (_a = props.children) !== null && _a !== void 0 ? _a : props.colKey));
72
74
  }
73
75
  function ColumnDataWrapper(props) {
74
- var _a, _b;
75
- const tdref = React.useRef(null);
76
- const style = (props.style !== undefined) ? Object.assign({}, props.style) : {};
77
- style.overflowX = (_a = style.overflowX) !== null && _a !== void 0 ? _a : 'hidden';
78
- style.display = (_b = style.display) !== null && _b !== void 0 ? _b : 'inline-block';
79
- const isAuto = style.width == 'auto';
80
- const isUndefined = style.width === undefined;
81
- if ((style.width == undefined || style.width == 'auto') && props.width !== undefined) {
82
- style.width = (props.width) + props.extraWidth;
83
- }
84
- if (props.dragStart !== undefined)
85
- style.cursor = "grab";
86
- React.useLayoutEffect(() => {
87
- var _a;
88
- if (tdref.current == null)
89
- return;
90
- const w = (_a = tdref.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width;
91
- if (props.width !== undefined && (w === undefined || w == (props.width + props.extraWidth)))
92
- return;
93
- props.setWidth(w, isAuto, isUndefined);
94
- });
95
- if (props.width != undefined && !props.enabled)
96
- return null;
97
- return (React.createElement("td", { ref: tdref, style: style, onClick: props.onClick, draggable: props.dragStart !== undefined, onDragStart: props.dragStart }, props.children));
76
+ return (React.createElement("td", { style: props.style, onClick: props.onClick, draggable: props.dragStart !== undefined, onDragStart: props.dragStart }, props.children));
98
77
  }
@@ -1,117 +1,3 @@
1
1
  import * as React from 'react';
2
- interface TableProps<T> {
3
- /**
4
- * List of T objects used to generate rows
5
- */
6
- Data: T[];
7
- /**
8
- * Callback when the user clicks on a data entry
9
- * @param data contains the data including the columnKey
10
- * @param event the onClick Event to allow propagation as needed
11
- * @returns
12
- */
13
- OnClick?: (data: {
14
- colKey?: string;
15
- colField?: keyof T;
16
- row: T;
17
- data: T[keyof T] | null;
18
- index: number;
19
- }, event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
20
- /**
21
- * Key of the collumn to sort by
22
- */
23
- SortKey: string;
24
- /**
25
- * Boolen to indicate whether the sort is ascending or descending
26
- */
27
- Ascending: boolean;
28
- /**
29
- * Callback when the data should be sorted
30
- * @param data the information of the collumn including the Key of the collumn
31
- * @param event The onCLick event to allow Propagation as needed
32
- */
33
- OnSort(data: {
34
- colKey: string;
35
- colField?: keyof T;
36
- ascending: boolean;
37
- }, event: React.MouseEvent<HTMLElement, MouseEvent>): void;
38
- /**
39
- * Class of the table component
40
- */
41
- TableClass?: string;
42
- /**
43
- * style of the table component
44
- */
45
- TableStyle?: React.CSSProperties;
46
- /**
47
- * style of the thead component
48
- */
49
- TheadStyle?: React.CSSProperties;
50
- /**
51
- * Class of the thead component
52
- */
53
- TheadClass?: string;
54
- /**
55
- * style of the tbody component
56
- * Note: Display style overwritten to "block"
57
- */
58
- TbodyStyle?: React.CSSProperties;
59
- /**
60
- * Class of the tbody component
61
- */
62
- TbodyClass?: string;
63
- /**
64
- * style of the tfoot component
65
- */
66
- TfootStyle?: React.CSSProperties;
67
- /**
68
- * Class of the tfoot component
69
- */
70
- TfootClass?: string;
71
- /**
72
- * determines if a row should be styled as selected
73
- * @param data the item to be checked
74
- * @returns true if the row should be styled as selected
75
- */
76
- Selected?: (data: T, index: number) => boolean;
77
- /**
78
- *
79
- * @param data the information of the row including the item of the row
80
- * @param e the event triggering this
81
- * @returns
82
- */
83
- OnDragStart?: (data: {
84
- colKey?: string;
85
- colField?: keyof T;
86
- row: T;
87
- data: T[keyof T] | null;
88
- index: number;
89
- }, e: React.DragEvent<Element>) => void;
90
- /**
91
- * The default style for the tr element
92
- */
93
- RowStyle?: React.CSSProperties;
94
- /**
95
- * a Function that retrieves a unique key used for React key properties
96
- * @param data the item to be turned into a key
97
- * @returns a unique Key
98
- */
99
- KeySelector: (data: T, index?: number) => string | number;
100
- /**
101
- * Optional Element to display in the last row of the Table
102
- * use this for displaying warnings when the Table content gets cut off.
103
- * Data appears in the tfoot element
104
- */
105
- LastRow?: string | React.ReactNode;
106
- /**
107
- * Optional Element to display on upper Right corner
108
- */
109
- LastColumn?: string | React.ReactNode;
110
- /**
111
- * Optional Callback that gets called when there is not enough space to display columns
112
- * @param disabled takes in string of disabled keys
113
- */
114
- ReduceWidthCallback?: (disabled: string[]) => void;
115
- }
116
- export default function AdjustableTable<T>(props: React.PropsWithChildren<TableProps<T>>): JSX.Element;
117
- export {};
2
+ import * as ReactTableProps from './Types';
3
+ export declare function AdjustableTable<T>(props: React.PropsWithChildren<ReactTableProps.ITable<T>>): JSX.Element;