@gpa-gemstone/react-table 1.2.43 → 1.2.45

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.
@@ -1,20 +1,20 @@
1
- import * as React from 'react';
2
- import { IColumnProps } from './Column';
3
- interface IAdjustableColProps<T> extends IColumnProps<T> {
4
- /**
5
- * The minimum Width used for this Collumn - default is 100px
6
- */
7
- MinWidth?: number;
8
- }
9
- export default function AdjustableCol<T>(props: React.PropsWithChildren<IAdjustableColProps<T>>): JSX.Element;
10
- interface IHeaderWrapperProps<T> extends IAdjustableColProps<T> {
11
- setWidth: (w: number, m: number) => void;
12
- width?: number;
13
- onSort: (key: string, event: any, field?: keyof T) => void;
14
- sorted: boolean;
15
- asc: boolean;
16
- startAdjustment: (e: any) => void;
17
- fixedLayout: boolean;
18
- }
19
- export declare function AdjColumnHeaderWrapper<T>(props: React.PropsWithChildren<IHeaderWrapperProps<T>>): JSX.Element;
20
- export {};
1
+ import * as React from 'react';
2
+ import { IColumnProps } from './Column';
3
+ interface IAdjustableColProps<T> extends IColumnProps<T> {
4
+ /**
5
+ * The minimum Width used for this Collumn - default is 100px
6
+ */
7
+ MinWidth?: number;
8
+ }
9
+ export default function AdjustableCol<T>(props: React.PropsWithChildren<IAdjustableColProps<T>>): JSX.Element;
10
+ interface IHeaderWrapperProps<T> extends IAdjustableColProps<T> {
11
+ setWidth: (w: number, m: number) => void;
12
+ width?: number;
13
+ onSort: (key: string, event: any, field?: keyof T) => void;
14
+ sorted: boolean;
15
+ asc: boolean;
16
+ startAdjustment: (e: any) => void;
17
+ fixedLayout: boolean;
18
+ }
19
+ export declare function AdjColumnHeaderWrapper<T>(props: React.PropsWithChildren<IHeaderWrapperProps<T>>): JSX.Element;
20
+ export {};
@@ -1,100 +1,99 @@
1
- "use strict";
2
- // ******************************************************************************************************
3
- // AdjustableColumn.tsx - Gbtc
4
- //
5
- // Copyright © 2023, Grid Protection Alliance. All Rights Reserved.
6
- //
7
- // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
8
- // the NOTICE file distributed with this work for additional information regarding copyright ownership.
9
- // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
10
- // file except in compliance with the License. You may obtain a copy of the License at:
11
- //
12
- // http://opensource.org/licenses/MIT
13
- //
14
- // Unless agreed to in writing, the subject software distributed under the License is distributed on an
15
- // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
16
- // License for the specific language governing permissions and limitations.
17
- //
18
- // Code Modification History:
19
- // ----------------------------------------------------------------------------------------------------
20
- // 11/19/2023 - C. Lackner
21
- // Generated original version of source code.
22
- //
23
- // ******************************************************************************************************
24
- var __assign = (this && this.__assign) || function () {
25
- __assign = Object.assign || function(t) {
26
- for (var s, i = 1, n = arguments.length; i < n; i++) {
27
- s = arguments[i];
28
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
29
- t[p] = s[p];
30
- }
31
- return t;
32
- };
33
- return __assign.apply(this, arguments);
34
- };
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.AdjColumnHeaderWrapper = void 0;
37
- var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
38
- var helper_functions_1 = require("@gpa-gemstone/helper-functions");
39
- var React = require("react");
40
- function AdjustableCol(props) {
41
- return React.createElement(React.Fragment, null, props.children);
42
- }
43
- exports.default = AdjustableCol;
44
- function AdjColumnHeaderWrapper(props) {
45
- var _a, _b;
46
- var thref = React.useRef(null);
47
- var _c = React.useState(false), showBorder = _c[0], setShowBorder = _c[1];
48
- var onHover = React.useCallback(function () { setShowBorder(true); }, []);
49
- var onLeave = React.useCallback(function () { setShowBorder(false); }, []);
50
- var style = (props.RowStyle !== undefined) ? __assign({}, props.HeaderStyle) : {};
51
- if (props.width !== undefined && props.fixedLayout) {
52
- style.width = props.width;
53
- style.minWidth = props.width;
54
- style.maxWidth = props.width;
55
- }
56
- if (style.cursor === undefined && ((_a = props.AllowSort) !== null && _a !== void 0 ? _a : true)) {
57
- style.cursor = 'pointer';
58
- }
59
- if (style.position === undefined) {
60
- style.position = 'relative';
61
- }
62
- if (style.borderTop === undefined) {
63
- style.borderTop = 'none';
64
- }
65
- React.useLayoutEffect(function () {
66
- var _a, _b;
67
- if (thref.current == null || props.width !== undefined)
68
- return;
69
- var w = (_a = (0, helper_functions_1.GetNodeSize)(thref.current)) === null || _a === void 0 ? void 0 : _a.width;
70
- if (w === undefined)
71
- return;
72
- props.setWidth(w, (_b = props.MinWidth) !== null && _b !== void 0 ? _b : 100);
73
- });
74
- var onClick = React.useCallback(function (e) {
75
- var _a;
76
- if ((_a = props.AllowSort) !== null && _a !== void 0 ? _a : true)
77
- props.onSort(props.Key, e, props.Field);
78
- e.stopPropagation();
79
- }, [props.onSort]);
80
- var onClickBorder = React.useCallback(function (e) {
81
- props.startAdjustment(e);
82
- }, [props.startAdjustment]);
83
- return React.createElement("th", { ref: thref, style: style, onClick: onClick, onDrag: function (e) { e.stopPropagation(); } },
84
- React.createElement("div", { style: {
85
- width: 5,
86
- height: '100%',
87
- position: 'absolute',
88
- top: 0,
89
- left: 0,
90
- opacity: showBorder ? 1 : 0,
91
- background: '#e9ecef',
92
- cursor: 'col-resize'
93
- }, onMouseEnter: onHover, onMouseLeave: onLeave, onMouseDown: onClickBorder }),
94
- props.sorted && props.asc ? React.createElement("div", { style: { position: 'absolute', width: 25 } }, gpa_symbols_1.SVGIcons.ArrowDropDown) : null,
95
- props.sorted && !props.asc ? React.createElement("div", { style: { position: 'absolute', width: 25 } }, gpa_symbols_1.SVGIcons.ArrowDropUp) : null,
96
- React.createElement("div", { style: {
97
- marginLeft: (props.sorted ? 25 : 0),
98
- } }, (_b = props.children) !== null && _b !== void 0 ? _b : props.Key));
99
- }
100
- exports.AdjColumnHeaderWrapper = AdjColumnHeaderWrapper;
1
+ "use strict";
2
+ // ******************************************************************************************************
3
+ // AdjustableColumn.tsx - Gbtc
4
+ //
5
+ // Copyright © 2023, Grid Protection Alliance. All Rights Reserved.
6
+ //
7
+ // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
8
+ // the NOTICE file distributed with this work for additional information regarding copyright ownership.
9
+ // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
10
+ // file except in compliance with the License. You may obtain a copy of the License at:
11
+ //
12
+ // http://opensource.org/licenses/MIT
13
+ //
14
+ // Unless agreed to in writing, the subject software distributed under the License is distributed on an
15
+ // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
16
+ // License for the specific language governing permissions and limitations.
17
+ //
18
+ // Code Modification History:
19
+ // ----------------------------------------------------------------------------------------------------
20
+ // 11/19/2023 - C. Lackner
21
+ // Generated original version of source code.
22
+ //
23
+ // ******************************************************************************************************
24
+ var __assign = (this && this.__assign) || function () {
25
+ __assign = Object.assign || function(t) {
26
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
27
+ s = arguments[i];
28
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
29
+ t[p] = s[p];
30
+ }
31
+ return t;
32
+ };
33
+ return __assign.apply(this, arguments);
34
+ };
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.default = AdjustableCol;
37
+ exports.AdjColumnHeaderWrapper = AdjColumnHeaderWrapper;
38
+ var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
39
+ var helper_functions_1 = require("@gpa-gemstone/helper-functions");
40
+ var React = require("react");
41
+ function AdjustableCol(props) {
42
+ return React.createElement(React.Fragment, null, props.children);
43
+ }
44
+ function AdjColumnHeaderWrapper(props) {
45
+ var _a, _b;
46
+ var thref = React.useRef(null);
47
+ var _c = React.useState(false), showBorder = _c[0], setShowBorder = _c[1];
48
+ var onHover = React.useCallback(function () { setShowBorder(true); }, []);
49
+ var onLeave = React.useCallback(function () { setShowBorder(false); }, []);
50
+ var style = (props.RowStyle !== undefined) ? __assign({}, props.HeaderStyle) : {};
51
+ if (props.width !== undefined && props.fixedLayout) {
52
+ style.width = props.width;
53
+ style.minWidth = props.width;
54
+ style.maxWidth = props.width;
55
+ }
56
+ if (style.cursor === undefined && ((_a = props.AllowSort) !== null && _a !== void 0 ? _a : true)) {
57
+ style.cursor = 'pointer';
58
+ }
59
+ if (style.position === undefined) {
60
+ style.position = 'relative';
61
+ }
62
+ if (style.borderTop === undefined) {
63
+ style.borderTop = 'none';
64
+ }
65
+ React.useLayoutEffect(function () {
66
+ var _a, _b;
67
+ if (thref.current == null || props.width !== undefined)
68
+ return;
69
+ var w = (_a = (0, helper_functions_1.GetNodeSize)(thref.current)) === null || _a === void 0 ? void 0 : _a.width;
70
+ if (w === undefined)
71
+ return;
72
+ props.setWidth(w, (_b = props.MinWidth) !== null && _b !== void 0 ? _b : 100);
73
+ });
74
+ var onClick = React.useCallback(function (e) {
75
+ var _a;
76
+ if ((_a = props.AllowSort) !== null && _a !== void 0 ? _a : true)
77
+ props.onSort(props.Key, e, props.Field);
78
+ e.stopPropagation();
79
+ }, [props.onSort]);
80
+ var onClickBorder = React.useCallback(function (e) {
81
+ props.startAdjustment(e);
82
+ }, [props.startAdjustment]);
83
+ return React.createElement("th", { ref: thref, style: style, onClick: onClick, onDrag: function (e) { e.stopPropagation(); } },
84
+ React.createElement("div", { style: {
85
+ width: 5,
86
+ height: '100%',
87
+ position: 'absolute',
88
+ top: 0,
89
+ left: 0,
90
+ opacity: showBorder ? 1 : 0,
91
+ background: '#e9ecef',
92
+ cursor: 'col-resize'
93
+ }, onMouseEnter: onHover, onMouseLeave: onLeave, onMouseDown: onClickBorder }),
94
+ props.sorted && props.asc ? React.createElement("div", { style: { position: 'absolute', width: 25 } }, gpa_symbols_1.SVGIcons.ArrowDropDown) : null,
95
+ props.sorted && !props.asc ? React.createElement("div", { style: { position: 'absolute', width: 25 } }, gpa_symbols_1.SVGIcons.ArrowDropUp) : null,
96
+ React.createElement("div", { style: {
97
+ marginLeft: (props.sorted ? 25 : 0),
98
+ } }, (_b = props.children) !== null && _b !== void 0 ? _b : props.Key));
99
+ }
@@ -1,102 +1,102 @@
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: any) => 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: any): 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
- */
57
- TbodyStyle?: React.CSSProperties;
58
- /**
59
- * Class of the tbody component
60
- */
61
- TbodyClass?: string;
62
- /**
63
- * determines if a row should be styled as selected
64
- * @param data the item to be checked
65
- * @returns true if the row should be styled as selected
66
- */
67
- Selected?: (data: T, index: number) => boolean;
68
- /**
69
- *
70
- * @param data he information of the row including the item of the row
71
- * @param e the event triggering this
72
- * @returns
73
- */
74
- OnDragStart?: (data: {
75
- colKey: string;
76
- colField?: keyof T;
77
- row: T;
78
- data: T[keyof T] | null;
79
- index: number;
80
- }, e: any) => void;
81
- /**
82
- * The default style for the tr element
83
- */
84
- RowStyle?: React.CSSProperties;
85
- /**
86
- * a Function that retrieves a unique key used for React key properties
87
- * @param data the item to be turned into a key
88
- * @returns a unique Key
89
- */
90
- KeySelector: (data: T, index?: number) => string | number;
91
- /**
92
- * Optional Element to display in the last row of the Table
93
- * use this for displaying warnings when the Table content gets cut off
94
- */
95
- LastRow?: string | React.ReactNode;
96
- /**
97
- * Optional Element to display on upper Right corner
98
- */
99
- LastColumn?: string | React.ReactNode;
100
- }
101
- export default function AdjustableTable<T>(props: React.PropsWithChildren<TableProps<T>>): JSX.Element;
102
- export {};
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: any) => 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: any): 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
+ */
57
+ TbodyStyle?: React.CSSProperties;
58
+ /**
59
+ * Class of the tbody component
60
+ */
61
+ TbodyClass?: string;
62
+ /**
63
+ * determines if a row should be styled as selected
64
+ * @param data the item to be checked
65
+ * @returns true if the row should be styled as selected
66
+ */
67
+ Selected?: (data: T, index: number) => boolean;
68
+ /**
69
+ *
70
+ * @param data he information of the row including the item of the row
71
+ * @param e the event triggering this
72
+ * @returns
73
+ */
74
+ OnDragStart?: (data: {
75
+ colKey: string;
76
+ colField?: keyof T;
77
+ row: T;
78
+ data: T[keyof T] | null;
79
+ index: number;
80
+ }, e: any) => void;
81
+ /**
82
+ * The default style for the tr element
83
+ */
84
+ RowStyle?: React.CSSProperties;
85
+ /**
86
+ * a Function that retrieves a unique key used for React key properties
87
+ * @param data the item to be turned into a key
88
+ * @returns a unique Key
89
+ */
90
+ KeySelector: (data: T, index?: number) => string | number;
91
+ /**
92
+ * Optional Element to display in the last row of the Table
93
+ * use this for displaying warnings when the Table content gets cut off
94
+ */
95
+ LastRow?: string | React.ReactNode;
96
+ /**
97
+ * Optional Element to display on upper Right corner
98
+ */
99
+ LastColumn?: string | React.ReactNode;
100
+ }
101
+ export default function AdjustableTable<T>(props: React.PropsWithChildren<TableProps<T>>): JSX.Element;
102
+ export {};