@ltht-react/table 1.0.100 → 1.0.101

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 (41) hide show
  1. package/lib/index.d.ts +6 -6
  2. package/lib/index.js +12 -12
  3. package/lib/molecules/table-cell.d.ts +14 -14
  4. package/lib/molecules/table-cell.js +61 -61
  5. package/lib/molecules/table-component.d.ts +22 -22
  6. package/lib/molecules/table-component.js +71 -71
  7. package/lib/molecules/table-methods.d.ts +12 -12
  8. package/lib/molecules/table-methods.js +198 -198
  9. package/lib/molecules/table-styled-components.d.ts +86 -86
  10. package/lib/molecules/table-styled-components.js +86 -86
  11. package/lib/molecules/table.d.ts +37 -37
  12. package/lib/molecules/table.js +98 -98
  13. package/lib/molecules/useDimensionRef.d.ts +5 -5
  14. package/lib/molecules/useDimensionRef.js +30 -30
  15. package/lib/molecules/useScrollRef.d.ts +8 -8
  16. package/lib/molecules/useScrollRef.js +27 -27
  17. package/lib/organisms/generic-table.d.ts +11 -11
  18. package/lib/organisms/generic-table.js +35 -35
  19. package/lib/organisms/questionnaire-table-methods.d.ts +9 -9
  20. package/lib/organisms/questionnaire-table-methods.js +208 -208
  21. package/lib/organisms/questionnaire-table.d.ts +13 -13
  22. package/lib/organisms/questionnaire-table.js +44 -44
  23. package/package.json +8 -8
  24. package/lib/atoms/horizontal.d.ts +0 -8
  25. package/lib/atoms/horizontal.js +0 -130
  26. package/lib/atoms/horizontal.js.map +0 -1
  27. package/lib/atoms/table.d.ts +0 -36
  28. package/lib/atoms/table.js +0 -106
  29. package/lib/atoms/table.js.map +0 -1
  30. package/lib/atoms/vertical.d.ts +0 -8
  31. package/lib/atoms/vertical.js +0 -89
  32. package/lib/atoms/vertical.js.map +0 -1
  33. package/lib/molecules/generic-table.d.ts +0 -11
  34. package/lib/molecules/generic-table.js +0 -36
  35. package/lib/molecules/generic-table.js.map +0 -1
  36. package/lib/molecules/questionnaire-table.d.ts +0 -12
  37. package/lib/molecules/questionnaire-table.js +0 -131
  38. package/lib/molecules/questionnaire-table.js.map +0 -1
  39. package/lib/types.d.ts +0 -3
  40. package/lib/types.js +0 -3
  41. package/lib/types.js.map +0 -1
package/lib/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import Table, { Header, DataEntity, TableData, CellProps } from './molecules/table';
2
- import GenericTable from './organisms/generic-table';
3
- import QuestionnaireTable from './organisms/questionnaire-table';
4
- import { AdminActionsForQuestionnaire } from './organisms/questionnaire-table-methods';
5
- export default Table;
6
- export { Header, TableData, DataEntity, CellProps, GenericTable, QuestionnaireTable, AdminActionsForQuestionnaire };
1
+ import Table, { Header, DataEntity, TableData, CellProps } from './molecules/table';
2
+ import GenericTable from './organisms/generic-table';
3
+ import QuestionnaireTable from './organisms/questionnaire-table';
4
+ import { AdminActionsForQuestionnaire } from './organisms/questionnaire-table-methods';
5
+ export default Table;
6
+ export { Header, TableData, DataEntity, CellProps, GenericTable, QuestionnaireTable, AdminActionsForQuestionnaire };
package/lib/index.js CHANGED
@@ -1,13 +1,13 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.QuestionnaireTable = exports.GenericTable = void 0;
7
- var table_1 = __importDefault(require("./molecules/table"));
8
- var generic_table_1 = __importDefault(require("./organisms/generic-table"));
9
- exports.GenericTable = generic_table_1.default;
10
- var questionnaire_table_1 = __importDefault(require("./organisms/questionnaire-table"));
11
- exports.QuestionnaireTable = questionnaire_table_1.default;
12
- exports.default = table_1.default;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.QuestionnaireTable = exports.GenericTable = void 0;
7
+ var table_1 = __importDefault(require("./molecules/table"));
8
+ var generic_table_1 = __importDefault(require("./organisms/generic-table"));
9
+ exports.GenericTable = generic_table_1.default;
10
+ var questionnaire_table_1 = __importDefault(require("./organisms/questionnaire-table"));
11
+ exports.QuestionnaireTable = questionnaire_table_1.default;
12
+ exports.default = table_1.default;
13
13
  //# sourceMappingURL=index.js.map
@@ -1,14 +1,14 @@
1
- import { FC } from 'react';
2
- import { IconProps } from '@ltht-react/icon';
3
- import { ActionMenuOption } from '@ltht-react/menu';
4
- declare const TableCell: FC<CellProps>;
5
- export interface CellProps {
6
- adminActions?: ActionMenuOption[];
7
- isButton?: boolean;
8
- text?: string;
9
- iconProps?: IconProps;
10
- clickHandler?: React.MouseEventHandler<HTMLButtonElement>;
11
- customComponentOverride?: JSX.Element;
12
- parentStyle?: React.CSSProperties;
13
- }
14
- export default TableCell;
1
+ import { FC } from 'react';
2
+ import { IconProps } from '@ltht-react/icon';
3
+ import { ActionMenuOption } from '@ltht-react/menu';
4
+ declare const TableCell: FC<CellProps>;
5
+ export interface CellProps {
6
+ adminActions?: ActionMenuOption[];
7
+ isButton?: boolean;
8
+ text?: string;
9
+ iconProps?: IconProps;
10
+ clickHandler?: React.MouseEventHandler<HTMLButtonElement>;
11
+ customComponentOverride?: JSX.Element;
12
+ parentStyle?: React.CSSProperties;
13
+ }
14
+ export default TableCell;
@@ -1,62 +1,62 @@
1
- "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
- var __assign = (this && this.__assign) || function () {
7
- __assign = Object.assign || function(t) {
8
- for (var s, i = 1, n = arguments.length; i < n; i++) {
9
- s = arguments[i];
10
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
- t[p] = s[p];
12
- }
13
- return t;
14
- };
15
- return __assign.apply(this, arguments);
16
- };
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- var jsx_runtime_1 = require("react/jsx-runtime");
22
- var button_1 = require("@ltht-react/button");
23
- var styled_1 = __importDefault(require("@emotion/styled"));
24
- var icon_1 = require("@ltht-react/icon");
25
- var menu_1 = __importDefault(require("@ltht-react/menu"));
26
- var styles_1 = require("@ltht-react/styles");
27
- var StyledText = styled_1.default.span(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n margin-left: 0.4rem;\n"], ["\n margin-left: 0.4rem;\n"
28
- // TODO: This component is still a WIP and will be re-factored soon!
29
- // May be best to split it out into different components, the important part is unifying Type used by React-Table so the mapping can be simplified
30
- // It will need to facilitate the Actions list capability Jonny Dyson has requested
31
- // Betters ways of handling the customComponentOverride will be considered too
32
- ])));
33
- // TODO: This component is still a WIP and will be re-factored soon!
34
- // May be best to split it out into different components, the important part is unifying Type used by React-Table so the mapping can be simplified
35
- // It will need to facilitate the Actions list capability Jonny Dyson has requested
36
- // Betters ways of handling the customComponentOverride will be considered too
37
- var TableCell = function (_a) {
38
- var adminActions = _a.adminActions, _b = _a.isButton, isButton = _b === void 0 ? false : _b, text = _a.text, iconProps = _a.iconProps, clickHandler = _a.clickHandler, customComponentOverride = _a.customComponentOverride;
39
- if (customComponentOverride) {
40
- return customComponentOverride;
41
- }
42
- if (adminActions) {
43
- return jsx_runtime_1.jsx(menu_1.default, { actions: adminActions, popupStyle: { zIndex: styles_1.getZIndex(styles_1.PopUp) } }, void 0);
44
- }
45
- if (isButton) {
46
- return jsx_runtime_1.jsx(button_1.Button, { type: "button", value: text, icon: iconProps && jsx_runtime_1.jsx(icon_1.Icon, __assign({}, iconProps), void 0), onClick: clickHandler }, void 0);
47
- }
48
- if (clickHandler && iconProps) {
49
- return jsx_runtime_1.jsx(icon_1.IconButton, { iconProps: iconProps, text: text, onClick: clickHandler }, void 0);
50
- }
51
- if (iconProps) {
52
- return (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [jsx_runtime_1.jsx(icon_1.Icon, __assign({}, iconProps), void 0),
53
- text && jsx_runtime_1.jsx(StyledText, { children: text }, void 0)] }, void 0));
54
- }
55
- if (text) {
56
- return jsx_runtime_1.jsx("div", { children: text !== null && text !== void 0 ? text : '' }, void 0);
57
- }
58
- return jsx_runtime_1.jsx(jsx_runtime_1.Fragment, {}, void 0);
59
- };
60
- exports.default = TableCell;
61
- var templateObject_1;
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __assign = (this && this.__assign) || function () {
7
+ __assign = Object.assign || function(t) {
8
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9
+ s = arguments[i];
10
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
+ t[p] = s[p];
12
+ }
13
+ return t;
14
+ };
15
+ return __assign.apply(this, arguments);
16
+ };
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ var jsx_runtime_1 = require("react/jsx-runtime");
22
+ var button_1 = require("@ltht-react/button");
23
+ var styled_1 = __importDefault(require("@emotion/styled"));
24
+ var icon_1 = require("@ltht-react/icon");
25
+ var menu_1 = __importDefault(require("@ltht-react/menu"));
26
+ var styles_1 = require("@ltht-react/styles");
27
+ var StyledText = styled_1.default.span(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n margin-left: 0.4rem;\n"], ["\n margin-left: 0.4rem;\n"
28
+ // TODO: This component is still a WIP and will be re-factored soon!
29
+ // May be best to split it out into different components, the important part is unifying Type used by React-Table so the mapping can be simplified
30
+ // It will need to facilitate the Actions list capability Jonny Dyson has requested
31
+ // Betters ways of handling the customComponentOverride will be considered too
32
+ ])));
33
+ // TODO: This component is still a WIP and will be re-factored soon!
34
+ // May be best to split it out into different components, the important part is unifying Type used by React-Table so the mapping can be simplified
35
+ // It will need to facilitate the Actions list capability Jonny Dyson has requested
36
+ // Betters ways of handling the customComponentOverride will be considered too
37
+ var TableCell = function (_a) {
38
+ var adminActions = _a.adminActions, _b = _a.isButton, isButton = _b === void 0 ? false : _b, text = _a.text, iconProps = _a.iconProps, clickHandler = _a.clickHandler, customComponentOverride = _a.customComponentOverride;
39
+ if (customComponentOverride) {
40
+ return customComponentOverride;
41
+ }
42
+ if (adminActions) {
43
+ return jsx_runtime_1.jsx(menu_1.default, { actions: adminActions, popupStyle: { zIndex: styles_1.getZIndex(styles_1.PopUp) } }, void 0);
44
+ }
45
+ if (isButton) {
46
+ return jsx_runtime_1.jsx(button_1.Button, { type: "button", value: text, icon: iconProps && jsx_runtime_1.jsx(icon_1.Icon, __assign({}, iconProps), void 0), onClick: clickHandler }, void 0);
47
+ }
48
+ if (clickHandler && iconProps) {
49
+ return jsx_runtime_1.jsx(icon_1.IconButton, { iconProps: iconProps, text: text, onClick: clickHandler }, void 0);
50
+ }
51
+ if (iconProps) {
52
+ return (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [jsx_runtime_1.jsx(icon_1.Icon, __assign({}, iconProps), void 0),
53
+ text && jsx_runtime_1.jsx(StyledText, { children: text }, void 0)] }, void 0));
54
+ }
55
+ if (text) {
56
+ return jsx_runtime_1.jsx("div", { children: text !== null && text !== void 0 ? text : '' }, void 0);
57
+ }
58
+ return jsx_runtime_1.jsx(jsx_runtime_1.Fragment, {}, void 0);
59
+ };
60
+ exports.default = TableCell;
61
+ var templateObject_1;
62
62
  //# sourceMappingURL=table-cell.js.map
@@ -1,22 +1,22 @@
1
- /// <reference types="react" />
2
- import { Table } from '@tanstack/react-table';
3
- import { Axis } from '@ltht-react/types';
4
- declare const TableComponent: <T>({ table, staticColumns, headerAxis }: ITableHeadProps<T>) => JSX.Element;
5
- declare const TableNavigationButton: ({ position, hidden, clickHandler }: ITableNavButtonProps) => JSX.Element;
6
- declare const TableSpinner: ({ position, hidden }: ITableSpinnerProps) => JSX.Element;
7
- interface ITableNavButtonProps {
8
- position: 'bottom' | 'right';
9
- hidden: boolean;
10
- clickHandler: () => void;
11
- }
12
- interface ITableSpinnerProps {
13
- position: 'bottom' | 'right';
14
- hidden: boolean;
15
- }
16
- interface ITableHeadProps<T> {
17
- table: Table<T>;
18
- headerAxis: Axis;
19
- staticColumns: 0 | 1 | 2;
20
- }
21
- export default TableComponent;
22
- export { TableNavigationButton, TableSpinner };
1
+ /// <reference types="react" />
2
+ import { Table } from '@tanstack/react-table';
3
+ import { Axis } from '@ltht-react/types';
4
+ declare const TableComponent: <T>({ table, staticColumns, headerAxis }: ITableHeadProps<T>) => JSX.Element;
5
+ declare const TableNavigationButton: ({ position, hidden, clickHandler }: ITableNavButtonProps) => JSX.Element;
6
+ declare const TableSpinner: ({ position, hidden }: ITableSpinnerProps) => JSX.Element;
7
+ interface ITableNavButtonProps {
8
+ position: 'bottom' | 'right';
9
+ hidden: boolean;
10
+ clickHandler: () => void;
11
+ }
12
+ interface ITableSpinnerProps {
13
+ position: 'bottom' | 'right';
14
+ hidden: boolean;
15
+ }
16
+ interface ITableHeadProps<T> {
17
+ table: Table<T>;
18
+ headerAxis: Axis;
19
+ staticColumns: 0 | 1 | 2;
20
+ }
21
+ export default TableComponent;
22
+ export { TableNavigationButton, TableSpinner };
@@ -1,72 +1,72 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.TableSpinner = exports.TableNavigationButton = void 0;
18
- var jsx_runtime_1 = require("react/jsx-runtime");
19
- var icon_1 = require("@ltht-react/icon");
20
- var react_table_1 = require("@tanstack/react-table");
21
- var react_1 = require("react");
22
- var table_methods_1 = require("./table-methods");
23
- var table_styled_components_1 = require("./table-styled-components");
24
- var useDimensionRef_1 = __importDefault(require("./useDimensionRef"));
25
- var TableComponent = function (_a) {
26
- var table = _a.table, staticColumns = _a.staticColumns, headerAxis = _a.headerAxis;
27
- var firstColumn = react_1.useRef(null);
28
- var secondColumn = react_1.useRef(null);
29
- var tableElement = react_1.useRef(null);
30
- var firstColumnWidth = useDimensionRef_1.default(firstColumn, tableElement).width;
31
- var secondColumnWidth = useDimensionRef_1.default(secondColumn, tableElement).width;
32
- var usingExpanderColumn = table.getHeaderGroups().some(function (x) { return x.headers.some(function (h) { return h.column.id === 'expander'; }); });
33
- var totalStaticColumns = react_1.useMemo(function () { return (usingExpanderColumn ? staticColumns + 1 : staticColumns); }, [
34
- usingExpanderColumn,
35
- staticColumns,
36
- ]);
37
- var getHeaderColumn = function (header, headerIndex) {
38
- switch (headerIndex) {
39
- case 0:
40
- return getHeaderElement(header, table_methods_1.calculateStaticColumnOffset(headerIndex, totalStaticColumns, firstColumnWidth, secondColumnWidth), firstColumn);
41
- case 1:
42
- return getHeaderElement(header, table_methods_1.calculateStaticColumnOffset(headerIndex, totalStaticColumns, firstColumnWidth, secondColumnWidth), secondColumn);
43
- default:
44
- return getHeaderElement(header, table_methods_1.calculateStaticColumnOffset(headerIndex, totalStaticColumns, firstColumnWidth, secondColumnWidth));
45
- }
46
- };
47
- var getHeaderElement = function (header, stickyWidth, elementRef) { return (jsx_runtime_1.jsx(table_styled_components_1.StyledTableHeader, __assign({ stickyWidth: stickyWidth, colSpan: header.colSpan, ref: elementRef, role: "columnheader" }, (header.column.id !== 'expander'
48
- ? {
49
- style: {
50
- cursor: header.column.getCanSort() ? 'pointer' : '',
51
- },
52
- onClick: header.column.getToggleSortingHandler(),
53
- }
54
- : {}), { children: header.isPlaceholder ? null : react_table_1.flexRender(header.column.columnDef.header, header.getContext()) }), header.id)); };
55
- return (jsx_runtime_1.jsxs(table_styled_components_1.StyledTable, __assign({ ref: tableElement }, { children: [jsx_runtime_1.jsx(table_styled_components_1.StyledTHead, { children: table.getHeaderGroups().map(function (headerGroup) { return (jsx_runtime_1.jsx("tr", __assign({ role: "row" }, { children: headerGroup.headers.map(function (header, headerIndex) { return getHeaderColumn(header, headerIndex); }) }), headerGroup.id)); }) }, void 0),
56
- jsx_runtime_1.jsx("tbody", { children: table.getRowModel().rows.map(function (row) { return (jsx_runtime_1.jsx(table_styled_components_1.StyledTableRow, __assign({ tableHeaderAxis: headerAxis, role: "row" }, { children: row.getVisibleCells().map(function (cell, cellIdx) {
57
- var _a;
58
- return (jsx_runtime_1.jsx(table_styled_components_1.StyledTableData, __assign({ tableHeaderAxis: headerAxis, stickyWidth: table_methods_1.calculateStaticColumnOffset(cellIdx, totalStaticColumns, firstColumnWidth, secondColumnWidth), role: "cell", style: (_a = cell.getValue()) === null || _a === void 0 ? void 0 : _a.parentStyle }, { children: react_table_1.flexRender(cell.column.columnDef.cell, cell.getContext()) }), cell.id));
59
- }) }), row.id)); }) }, void 0)] }), void 0));
60
- };
61
- var TableNavigationButton = function (_a) {
62
- var position = _a.position, hidden = _a.hidden, clickHandler = _a.clickHandler;
63
- return (jsx_runtime_1.jsx(table_styled_components_1.StyledNextPageButtonContainer, __assign({ role: "button", elementPosition: position, onClick: function () { return clickHandler(); }, hidden: hidden }, { children: jsx_runtime_1.jsx(icon_1.Icon, { type: "chevron", direction: position === 'bottom' ? 'down' : 'right', size: "medium" }, void 0) }), void 0));
64
- };
65
- exports.TableNavigationButton = TableNavigationButton;
66
- var TableSpinner = function (_a) {
67
- var position = _a.position, hidden = _a.hidden;
68
- return (jsx_runtime_1.jsx(table_styled_components_1.StyledSpinnerContainer, __assign({ elementPosition: position, hidden: hidden }, { children: jsx_runtime_1.jsx(icon_1.Icon, { type: "spinner", size: "medium", title: "Loading..." }, void 0) }), void 0));
69
- };
70
- exports.TableSpinner = TableSpinner;
71
- exports.default = TableComponent;
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.TableSpinner = exports.TableNavigationButton = void 0;
18
+ var jsx_runtime_1 = require("react/jsx-runtime");
19
+ var icon_1 = require("@ltht-react/icon");
20
+ var react_table_1 = require("@tanstack/react-table");
21
+ var react_1 = require("react");
22
+ var table_methods_1 = require("./table-methods");
23
+ var table_styled_components_1 = require("./table-styled-components");
24
+ var useDimensionRef_1 = __importDefault(require("./useDimensionRef"));
25
+ var TableComponent = function (_a) {
26
+ var table = _a.table, staticColumns = _a.staticColumns, headerAxis = _a.headerAxis;
27
+ var firstColumn = react_1.useRef(null);
28
+ var secondColumn = react_1.useRef(null);
29
+ var tableElement = react_1.useRef(null);
30
+ var firstColumnWidth = useDimensionRef_1.default(firstColumn, tableElement).width;
31
+ var secondColumnWidth = useDimensionRef_1.default(secondColumn, tableElement).width;
32
+ var usingExpanderColumn = table.getHeaderGroups().some(function (x) { return x.headers.some(function (h) { return h.column.id === 'expander'; }); });
33
+ var totalStaticColumns = react_1.useMemo(function () { return (usingExpanderColumn ? staticColumns + 1 : staticColumns); }, [
34
+ usingExpanderColumn,
35
+ staticColumns,
36
+ ]);
37
+ var getHeaderColumn = function (header, headerIndex) {
38
+ switch (headerIndex) {
39
+ case 0:
40
+ return getHeaderElement(header, table_methods_1.calculateStaticColumnOffset(headerIndex, totalStaticColumns, firstColumnWidth, secondColumnWidth), firstColumn);
41
+ case 1:
42
+ return getHeaderElement(header, table_methods_1.calculateStaticColumnOffset(headerIndex, totalStaticColumns, firstColumnWidth, secondColumnWidth), secondColumn);
43
+ default:
44
+ return getHeaderElement(header, table_methods_1.calculateStaticColumnOffset(headerIndex, totalStaticColumns, firstColumnWidth, secondColumnWidth));
45
+ }
46
+ };
47
+ var getHeaderElement = function (header, stickyWidth, elementRef) { return (jsx_runtime_1.jsx(table_styled_components_1.StyledTableHeader, __assign({ stickyWidth: stickyWidth, colSpan: header.colSpan, ref: elementRef, role: "columnheader" }, (header.column.id !== 'expander'
48
+ ? {
49
+ style: {
50
+ cursor: header.column.getCanSort() ? 'pointer' : '',
51
+ },
52
+ onClick: header.column.getToggleSortingHandler(),
53
+ }
54
+ : {}), { children: header.isPlaceholder ? null : react_table_1.flexRender(header.column.columnDef.header, header.getContext()) }), header.id)); };
55
+ return (jsx_runtime_1.jsxs(table_styled_components_1.StyledTable, __assign({ ref: tableElement }, { children: [jsx_runtime_1.jsx(table_styled_components_1.StyledTHead, { children: table.getHeaderGroups().map(function (headerGroup) { return (jsx_runtime_1.jsx("tr", __assign({ role: "row" }, { children: headerGroup.headers.map(function (header, headerIndex) { return getHeaderColumn(header, headerIndex); }) }), headerGroup.id)); }) }, void 0),
56
+ jsx_runtime_1.jsx("tbody", { children: table.getRowModel().rows.map(function (row) { return (jsx_runtime_1.jsx(table_styled_components_1.StyledTableRow, __assign({ tableHeaderAxis: headerAxis, role: "row" }, { children: row.getVisibleCells().map(function (cell, cellIdx) {
57
+ var _a;
58
+ return (jsx_runtime_1.jsx(table_styled_components_1.StyledTableData, __assign({ tableHeaderAxis: headerAxis, stickyWidth: table_methods_1.calculateStaticColumnOffset(cellIdx, totalStaticColumns, firstColumnWidth, secondColumnWidth), role: "cell", style: (_a = cell.getValue()) === null || _a === void 0 ? void 0 : _a.parentStyle }, { children: react_table_1.flexRender(cell.column.columnDef.cell, cell.getContext()) }), cell.id));
59
+ }) }), row.id)); }) }, void 0)] }), void 0));
60
+ };
61
+ var TableNavigationButton = function (_a) {
62
+ var position = _a.position, hidden = _a.hidden, clickHandler = _a.clickHandler;
63
+ return (jsx_runtime_1.jsx(table_styled_components_1.StyledNextPageButtonContainer, __assign({ role: "button", elementPosition: position, onClick: function () { return clickHandler(); }, hidden: hidden }, { children: jsx_runtime_1.jsx(icon_1.Icon, { type: "chevron", direction: position === 'bottom' ? 'down' : 'right', size: "medium" }, void 0) }), void 0));
64
+ };
65
+ exports.TableNavigationButton = TableNavigationButton;
66
+ var TableSpinner = function (_a) {
67
+ var position = _a.position, hidden = _a.hidden;
68
+ return (jsx_runtime_1.jsx(table_styled_components_1.StyledSpinnerContainer, __assign({ elementPosition: position, hidden: hidden }, { children: jsx_runtime_1.jsx(icon_1.Icon, { type: "spinner", size: "medium", title: "Loading..." }, void 0) }), void 0));
69
+ };
70
+ exports.TableSpinner = TableSpinner;
71
+ exports.default = TableComponent;
72
72
  //# sourceMappingURL=table-component.js.map
@@ -1,12 +1,12 @@
1
- import { ColumnDef, Table } from '@tanstack/react-table';
2
- import { Axis } from '@ltht-react/types';
3
- import React from 'react';
4
- import { TableData, DataEntity } from './table';
5
- import { ScrollState } from './useScrollRef';
6
- declare const createColumns: (tableData: TableData) => ColumnDef<DataEntity>[];
7
- declare const calculateStaticColumnOffset: (cellIdx: number, staticColumns: number, firstColumnWidth: number, secondColumnWidth: number) => number | undefined;
8
- declare const handleScrollEvent: (table: Table<DataEntity>, headerAxis: Axis, scrollState: ScrollState) => void;
9
- declare const handleScrollEventManual: (getCanNextPage: () => boolean, nextPage: () => void, headerAxis: Axis, scrollState: ScrollState) => void;
10
- declare const handleDataUpdate: (tableData: TableData, pageIndex: number, pageSize: number, headerAxis: Axis, setColumns: (value: React.SetStateAction<ColumnDef<DataEntity>[]>) => void, setData: (value: React.SetStateAction<DataEntity[]>) => void, setPageCount: (value: React.SetStateAction<number>) => void) => void;
11
- declare const handleDataUpdateForManualPagination: (tableData: TableData, headerAxis: Axis, keepPreviousData: boolean, setColumns: (value: React.SetStateAction<ColumnDef<DataEntity>[]>) => void, setData: (value: React.SetStateAction<DataEntity[]>) => void) => void;
12
- export { createColumns, calculateStaticColumnOffset, handleScrollEvent, handleScrollEventManual, handleDataUpdate, handleDataUpdateForManualPagination, };
1
+ import { ColumnDef, Table } from '@tanstack/react-table';
2
+ import { Axis } from '@ltht-react/types';
3
+ import React from 'react';
4
+ import { TableData, DataEntity } from './table';
5
+ import { ScrollState } from './useScrollRef';
6
+ declare const createColumns: (tableData: TableData) => ColumnDef<DataEntity>[];
7
+ declare const calculateStaticColumnOffset: (cellIdx: number, staticColumns: number, firstColumnWidth: number, secondColumnWidth: number) => number | undefined;
8
+ declare const handleScrollEvent: (table: Table<DataEntity>, headerAxis: Axis, scrollState: ScrollState) => void;
9
+ declare const handleScrollEventManual: (getCanNextPage: () => boolean, nextPage: () => void, headerAxis: Axis, scrollState: ScrollState) => void;
10
+ declare const handleDataUpdate: (tableData: TableData, pageIndex: number, pageSize: number, headerAxis: Axis, setColumns: (value: React.SetStateAction<ColumnDef<DataEntity>[]>) => void, setData: (value: React.SetStateAction<DataEntity[]>) => void, setPageCount: (value: React.SetStateAction<number>) => void) => void;
11
+ declare const handleDataUpdateForManualPagination: (tableData: TableData, headerAxis: Axis, keepPreviousData: boolean, setColumns: (value: React.SetStateAction<ColumnDef<DataEntity>[]>) => void, setData: (value: React.SetStateAction<DataEntity[]>) => void) => void;
12
+ export { createColumns, calculateStaticColumnOffset, handleScrollEvent, handleScrollEventManual, handleDataUpdate, handleDataUpdateForManualPagination, };