@equinor/apollo-components 1.7.1 → 1.8.1
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/dist/index.d.ts +16 -3
- package/dist/index.js +65 -56
- package/dist/index.mjs +39 -30
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IconData } from '@equinor/eds-icons';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { ReactNode, ComponentProps } from 'react';
|
|
3
|
+
import { ReactNode, ReactElement, ComponentProps } from 'react';
|
|
4
4
|
import { Cell, CellContext, Table, Row, ColumnDef, RowSelectionState, SortingState, HeaderContext } from '@tanstack/react-table';
|
|
5
5
|
import { ColumnDef as ColumnDef$1 } from '@tanstack/table-core';
|
|
6
6
|
import * as styled_components from 'styled-components';
|
|
@@ -47,7 +47,18 @@ interface FilterConfig {
|
|
|
47
47
|
filterFromLeafRows?: boolean;
|
|
48
48
|
filterActions?: <T>(table: Table<T>) => ReactNode;
|
|
49
49
|
}
|
|
50
|
+
interface TableRowWrapper<T> {
|
|
51
|
+
(props: TableRowWrapperProps<T>): ReactElement;
|
|
52
|
+
}
|
|
53
|
+
interface TableRowWrapperProps<T> {
|
|
54
|
+
row: Row<T>;
|
|
55
|
+
children: ReactNode;
|
|
56
|
+
}
|
|
50
57
|
interface RowConfig<T> {
|
|
58
|
+
/**
|
|
59
|
+
* ! Unstable - Row Wrapper has not been tested for compatibility with virtualization. Use with caution.
|
|
60
|
+
*/
|
|
61
|
+
rowWrapper?: TableRowWrapper<T>;
|
|
51
62
|
getRowBackground?: (row: Row<T>) => string | undefined;
|
|
52
63
|
onClick?: (row: Row<T>) => void;
|
|
53
64
|
onMouseEnter?: (row: Row<T>) => void;
|
|
@@ -55,10 +66,12 @@ interface RowConfig<T> {
|
|
|
55
66
|
}
|
|
56
67
|
interface CellConfig<T> {
|
|
57
68
|
getStickyCellColor?: (cell: Cell<T, unknown>) => string;
|
|
69
|
+
getShouldHighlight?: (cell: Cell<T, unknown>) => boolean;
|
|
58
70
|
}
|
|
59
71
|
declare type RowSelectionMode = 'single' | 'multiple';
|
|
60
72
|
declare type DataTableConfig<T> = {
|
|
61
73
|
height?: string;
|
|
74
|
+
tableLayout?: 'auto' | 'fixed';
|
|
62
75
|
sortable?: boolean;
|
|
63
76
|
virtual?: boolean;
|
|
64
77
|
rowSelectionMode?: RowSelectionMode;
|
|
@@ -83,7 +96,7 @@ interface DataTableProps<T> {
|
|
|
83
96
|
filters?: FilterConfig;
|
|
84
97
|
header?: HeaderConfig;
|
|
85
98
|
}
|
|
86
|
-
declare function DataTable$1<T>({ columns, data, isLoading, header, filters, config, rowConfig, }: DataTableProps<T>): JSX.Element;
|
|
99
|
+
declare function DataTable$1<T>({ columns, data, isLoading, header, filters, config, cellConfig, rowConfig, }: DataTableProps<T>): JSX.Element;
|
|
87
100
|
|
|
88
101
|
declare type DataTableProviderProps = ComponentProps<typeof Provider>;
|
|
89
102
|
declare function DataTableProvider({ children, ...props }: DataTableProviderProps): JSX.Element;
|
|
@@ -140,4 +153,4 @@ declare type TypographyProps = {
|
|
|
140
153
|
*/
|
|
141
154
|
declare const TypographyCustom: (props: TypographyProps) => JSX.Element;
|
|
142
155
|
|
|
143
|
-
export { AppShell, AppSidebar, CellConfig, ChipsCell, ColumnSelect, DataTable, DataTableConfig, DynamicCell, FilterConfig, HeaderConfig, HierarchyCell, RowConfig, RowSelectionMode, SelectColumnDef, StickyCell, TableHeader, TypographyCustom, capitalizeHeader, globalFilterAtom, prependSelectColumn, rowSelectionAtom, tableSortingAtom };
|
|
156
|
+
export { AppShell, AppSidebar, CellConfig, ChipsCell, ColumnSelect, DataTable, DataTableConfig, DynamicCell, FilterConfig, HeaderConfig, HierarchyCell, RowConfig, RowSelectionMode, SelectColumnDef, StickyCell, TableHeader, TableRowWrapper, TableRowWrapperProps, TypographyCustom, capitalizeHeader, globalFilterAtom, prependSelectColumn, rowSelectionAtom, tableSortingAtom };
|
package/dist/index.js
CHANGED
|
@@ -195,24 +195,12 @@ var ChipsCell = (props) => {
|
|
|
195
195
|
// src/cells/DynamicCell.tsx
|
|
196
196
|
var import_eds_core_react4 = require("@equinor/eds-core-react");
|
|
197
197
|
var import_react_table = require("@tanstack/react-table");
|
|
198
|
-
var
|
|
198
|
+
var import_styled_components5 = __toESM(require("styled-components"));
|
|
199
199
|
|
|
200
200
|
// src/cells/StickyCell.tsx
|
|
201
201
|
var import_eds_core_react3 = require("@equinor/eds-core-react");
|
|
202
202
|
var import_styled_components4 = __toESM(require("styled-components"));
|
|
203
|
-
var
|
|
204
|
-
position: sticky;
|
|
205
|
-
right: 0;
|
|
206
|
-
top: 0;
|
|
207
|
-
z-index: 4;
|
|
208
|
-
`;
|
|
209
|
-
var StickyHeaderCell = (0, import_styled_components4.default)(StickyCell)`
|
|
210
|
-
z-index: 5;
|
|
211
|
-
`;
|
|
212
|
-
|
|
213
|
-
// src/cells/styles.ts
|
|
214
|
-
var import_styled_components5 = require("styled-components");
|
|
215
|
-
var leftCellShadow = import_styled_components5.css`
|
|
203
|
+
var leftCellShadow = import_styled_components4.css`
|
|
216
204
|
&:before {
|
|
217
205
|
box-shadow: -1px 0 1px -1px inset;
|
|
218
206
|
content: ' ';
|
|
@@ -223,15 +211,24 @@ var leftCellShadow = import_styled_components5.css`
|
|
|
223
211
|
width: 1px;
|
|
224
212
|
}
|
|
225
213
|
`;
|
|
214
|
+
var StickyCell = (0, import_styled_components4.default)(import_eds_core_react3.Table.Cell)`
|
|
215
|
+
position: sticky;
|
|
216
|
+
right: 0;
|
|
217
|
+
top: 0;
|
|
218
|
+
z-index: 4;
|
|
219
|
+
background-clip: padding-box;
|
|
220
|
+
${leftCellShadow}
|
|
221
|
+
`;
|
|
222
|
+
var StickyHeaderCell = (0, import_styled_components4.default)(StickyCell)`
|
|
223
|
+
z-index: 5;
|
|
224
|
+
`;
|
|
226
225
|
|
|
227
226
|
// src/cells/DynamicCell.tsx
|
|
228
227
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
229
|
-
var StyledStickyCell = (0,
|
|
230
|
-
background-clip: padding-box;
|
|
231
|
-
${leftCellShadow}
|
|
228
|
+
var StyledStickyCell = (0, import_styled_components5.default)(StickyCell)`
|
|
232
229
|
${(props) => props.backgroundColor ? `background-color: ${props.backgroundColor} !important;` : ``}
|
|
233
230
|
`;
|
|
234
|
-
var StyledCell = (0,
|
|
231
|
+
var StyledCell = (0, import_styled_components5.default)(import_eds_core_react4.Table.Cell)`
|
|
235
232
|
${(props) => props.backgroundColor ? `background-color: ${props.backgroundColor} !important;` : ``}
|
|
236
233
|
`;
|
|
237
234
|
function DynamicCell({ cell, highlight, getStickyCellColor }) {
|
|
@@ -253,12 +250,12 @@ function DynamicCell({ cell, highlight, getStickyCellColor }) {
|
|
|
253
250
|
|
|
254
251
|
// src/cells/HierarchyCell.tsx
|
|
255
252
|
var import_eds_tokens4 = require("@equinor/eds-tokens");
|
|
256
|
-
var
|
|
253
|
+
var import_styled_components7 = __toESM(require("styled-components"));
|
|
257
254
|
|
|
258
255
|
// src/cells/TypographyCustom.tsx
|
|
259
256
|
var import_eds_core_react5 = require("@equinor/eds-core-react");
|
|
260
257
|
var import_eds_tokens3 = require("@equinor/eds-tokens");
|
|
261
|
-
var
|
|
258
|
+
var import_styled_components6 = __toESM(require("styled-components"));
|
|
262
259
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
263
260
|
var truncateStyle = {
|
|
264
261
|
overflow: "hidden",
|
|
@@ -294,7 +291,7 @@ var TypographyCustom = (props) => {
|
|
|
294
291
|
style: { ...styleFromProps, ...noWrap ? truncateStyle : {} }
|
|
295
292
|
});
|
|
296
293
|
};
|
|
297
|
-
var HoverCapture =
|
|
294
|
+
var HoverCapture = import_styled_components6.default.div`
|
|
298
295
|
position: relative;
|
|
299
296
|
z-index: 0;
|
|
300
297
|
|
|
@@ -305,7 +302,7 @@ var HoverCapture = import_styled_components7.default.div`
|
|
|
305
302
|
opacity: 1;
|
|
306
303
|
}
|
|
307
304
|
`;
|
|
308
|
-
var ShowAllWrapperWrapper =
|
|
305
|
+
var ShowAllWrapperWrapper = import_styled_components6.default.div`
|
|
309
306
|
position: absolute;
|
|
310
307
|
z-index: 1;
|
|
311
308
|
pointer-events: none;
|
|
@@ -317,14 +314,14 @@ var ShowAllWrapperWrapper = import_styled_components7.default.div`
|
|
|
317
314
|
|
|
318
315
|
// src/cells/HierarchyCell.tsx
|
|
319
316
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
320
|
-
var CellWrapper = (0,
|
|
317
|
+
var CellWrapper = (0, import_styled_components7.default)(TypographyCustom)`
|
|
321
318
|
height: 100%;
|
|
322
319
|
display: flex;
|
|
323
320
|
align-items: center;
|
|
324
321
|
|
|
325
322
|
${({ depth, expanded }) => expanded && depth === 0 && "font-weight: bold;"}
|
|
326
323
|
|
|
327
|
-
${({ depth }) => depth > 0 &&
|
|
324
|
+
${({ depth }) => depth > 0 && import_styled_components7.css`
|
|
328
325
|
border-left: 3px solid ${import_eds_tokens4.tokens.colors.infographic.primary__moss_green_34.hex};
|
|
329
326
|
gap: 0.5rem;
|
|
330
327
|
.--divider {
|
|
@@ -352,9 +349,9 @@ function HierarchyCell(cell, options = {}) {
|
|
|
352
349
|
// src/cells/SelectColumnDef.tsx
|
|
353
350
|
var import_eds_core_react6 = require("@equinor/eds-core-react");
|
|
354
351
|
var import_eds_icons3 = require("@equinor/eds-icons");
|
|
355
|
-
var
|
|
352
|
+
var import_styled_components8 = __toESM(require("styled-components"));
|
|
356
353
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
357
|
-
var CellWrapper2 =
|
|
354
|
+
var CellWrapper2 = import_styled_components8.default.div`
|
|
358
355
|
display: flex;
|
|
359
356
|
align-items: center;
|
|
360
357
|
width: 48px;
|
|
@@ -410,7 +407,7 @@ function SelectColumnDef(selectionMode) {
|
|
|
410
407
|
var import_react_table3 = require("@tanstack/react-table");
|
|
411
408
|
var import_jotai3 = require("jotai");
|
|
412
409
|
var import_react4 = require("react");
|
|
413
|
-
var
|
|
410
|
+
var import_styled_components14 = __toESM(require("styled-components"));
|
|
414
411
|
|
|
415
412
|
// src/DataTable/atoms.ts
|
|
416
413
|
var import_jotai = require("jotai");
|
|
@@ -425,9 +422,9 @@ var import_eds_core_react11 = require("@equinor/eds-core-react");
|
|
|
425
422
|
|
|
426
423
|
// src/DataTable/components/PlaceholderRow.tsx
|
|
427
424
|
var import_eds_core_react7 = require("@equinor/eds-core-react");
|
|
428
|
-
var
|
|
425
|
+
var import_styled_components9 = __toESM(require("styled-components"));
|
|
429
426
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
430
|
-
var PlaceholderTextWrapper =
|
|
427
|
+
var PlaceholderTextWrapper = import_styled_components9.default.div`
|
|
431
428
|
display: flex;
|
|
432
429
|
justify-content: center;
|
|
433
430
|
`;
|
|
@@ -453,17 +450,14 @@ var import_eds_core_react9 = require("@equinor/eds-core-react");
|
|
|
453
450
|
var import_eds_core_react8 = require("@equinor/eds-core-react");
|
|
454
451
|
var import_eds_icons4 = require("@equinor/eds-icons");
|
|
455
452
|
var import_react_table2 = require("@tanstack/react-table");
|
|
456
|
-
var
|
|
453
|
+
var import_styled_components10 = __toESM(require("styled-components"));
|
|
457
454
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
458
|
-
var HeaderDiv =
|
|
455
|
+
var HeaderDiv = import_styled_components10.default.div`
|
|
459
456
|
display: flex;
|
|
460
457
|
align-items: center;
|
|
461
458
|
gap: 0.25rem;
|
|
462
459
|
z-index: 5;
|
|
463
460
|
`;
|
|
464
|
-
var StyledStickyCell2 = (0, import_styled_components11.default)(StickyCell)`
|
|
465
|
-
${leftCellShadow}
|
|
466
|
-
`;
|
|
467
461
|
var HeaderCell = ({ header }) => {
|
|
468
462
|
var _a;
|
|
469
463
|
const style = {
|
|
@@ -476,7 +470,7 @@ var HeaderCell = ({ header }) => {
|
|
|
476
470
|
colSpan: header.colSpan
|
|
477
471
|
};
|
|
478
472
|
if ((_a = header.column.columnDef.meta) == null ? void 0 : _a.sticky)
|
|
479
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
473
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StickyHeaderCell, {
|
|
480
474
|
...cellProps,
|
|
481
475
|
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HeaderContent, {
|
|
482
476
|
header
|
|
@@ -539,20 +533,30 @@ function TableHeader({ table, sticky }) {
|
|
|
539
533
|
var import_eds_core_react10 = require("@equinor/eds-core-react");
|
|
540
534
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
541
535
|
function TableRow({ row, rowConfig, cellConfig }) {
|
|
542
|
-
|
|
536
|
+
var _a;
|
|
537
|
+
const rowWrapper = rowConfig == null ? void 0 : rowConfig.rowWrapper;
|
|
538
|
+
const tableRowContent = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_eds_core_react10.Table.Row, {
|
|
543
539
|
active: row.getIsSelected(),
|
|
544
|
-
style: {
|
|
540
|
+
style: {
|
|
541
|
+
cursor: (rowConfig == null ? void 0 : rowConfig.onClick) ? "pointer" : "initial",
|
|
542
|
+
backgroundColor: (_a = rowConfig == null ? void 0 : rowConfig.getRowBackground) == null ? void 0 : _a.call(rowConfig, row)
|
|
543
|
+
},
|
|
545
544
|
onClick: () => {
|
|
546
|
-
var
|
|
547
|
-
return (
|
|
545
|
+
var _a2;
|
|
546
|
+
return (_a2 = rowConfig == null ? void 0 : rowConfig.onClick) == null ? void 0 : _a2.call(rowConfig, row);
|
|
548
547
|
},
|
|
549
548
|
onMouseEnter: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseEnter),
|
|
550
549
|
onMouseLeave: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseLeave),
|
|
551
|
-
children: row.getVisibleCells().map((cell) =>
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
550
|
+
children: row.getVisibleCells().map((cell) => {
|
|
551
|
+
var _a2;
|
|
552
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DynamicCell, {
|
|
553
|
+
cell,
|
|
554
|
+
getStickyCellColor: cellConfig == null ? void 0 : cellConfig.getStickyCellColor,
|
|
555
|
+
highlight: (_a2 = cellConfig == null ? void 0 : cellConfig.getShouldHighlight) == null ? void 0 : _a2.call(cellConfig, cell)
|
|
556
|
+
}, cell.id);
|
|
557
|
+
})
|
|
555
558
|
});
|
|
559
|
+
return rowWrapper ? rowWrapper({ row, children: tableRowContent }) : tableRowContent;
|
|
556
560
|
}
|
|
557
561
|
function handleRowEvent(row, handler) {
|
|
558
562
|
if (!handler)
|
|
@@ -595,18 +599,18 @@ function BasicTable({
|
|
|
595
599
|
var import_eds_core_react14 = require("@equinor/eds-core-react");
|
|
596
600
|
var import_eds_icons7 = require("@equinor/eds-icons");
|
|
597
601
|
var import_jotai2 = require("jotai");
|
|
598
|
-
var
|
|
602
|
+
var import_styled_components13 = __toESM(require("styled-components"));
|
|
599
603
|
|
|
600
604
|
// src/DataTable/filters/DebouncedInput.tsx
|
|
601
605
|
var import_eds_core_react12 = require("@equinor/eds-core-react");
|
|
602
606
|
var import_eds_icons5 = require("@equinor/eds-icons");
|
|
603
607
|
var import_react2 = require("react");
|
|
604
|
-
var
|
|
608
|
+
var import_styled_components11 = __toESM(require("styled-components"));
|
|
605
609
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
606
|
-
var Wrapper3 =
|
|
610
|
+
var Wrapper3 = import_styled_components11.default.div`
|
|
607
611
|
width: 200px;
|
|
608
612
|
`;
|
|
609
|
-
var CloseButton = (0,
|
|
613
|
+
var CloseButton = (0, import_styled_components11.default)(import_eds_core_react12.Button)`
|
|
610
614
|
width: 24px;
|
|
611
615
|
height: 24px;
|
|
612
616
|
`;
|
|
@@ -667,7 +671,7 @@ var fuzzyFilter = (row, columnId, value, addMeta) => {
|
|
|
667
671
|
var import_eds_core_react13 = require("@equinor/eds-core-react");
|
|
668
672
|
var import_eds_icons6 = require("@equinor/eds-icons");
|
|
669
673
|
var import_react3 = require("react");
|
|
670
|
-
var
|
|
674
|
+
var import_styled_components12 = __toESM(require("styled-components"));
|
|
671
675
|
|
|
672
676
|
// src/DataTable/utils.tsx
|
|
673
677
|
function capitalizeHeader(context) {
|
|
@@ -693,12 +697,12 @@ function prependSelectColumn(columns, config) {
|
|
|
693
697
|
|
|
694
698
|
// src/DataTable/components/ColumnSelect.tsx
|
|
695
699
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
696
|
-
var ColumnSelectContent =
|
|
700
|
+
var ColumnSelectContent = import_styled_components12.default.div`
|
|
697
701
|
display: grid;
|
|
698
702
|
grid-template-columns: repeat(2, 1fr);
|
|
699
703
|
grid-gap: 0.5rem;
|
|
700
704
|
`;
|
|
701
|
-
var ActionsWrapper =
|
|
705
|
+
var ActionsWrapper = import_styled_components12.default.div`
|
|
702
706
|
display: flex;
|
|
703
707
|
align-items: center;
|
|
704
708
|
justify-content: flex-end;
|
|
@@ -780,14 +784,14 @@ function ColumnSelect({ table }) {
|
|
|
780
784
|
|
|
781
785
|
// src/DataTable/components/DataTableHeader.tsx
|
|
782
786
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
783
|
-
var DataTableHeaderWrapper =
|
|
787
|
+
var DataTableHeaderWrapper = import_styled_components13.default.div`
|
|
784
788
|
display: flex;
|
|
785
789
|
align-items: center;
|
|
786
790
|
justify-content: space-between;
|
|
787
791
|
gap: 0.5rem;
|
|
788
792
|
padding: ${(props) => props.captionPadding ?? "1rem"};
|
|
789
793
|
`;
|
|
790
|
-
var FilterContainer =
|
|
794
|
+
var FilterContainer = import_styled_components13.default.div`
|
|
791
795
|
display: flex;
|
|
792
796
|
align-items: center;
|
|
793
797
|
gap: 1rem;
|
|
@@ -893,7 +897,7 @@ function VirtualTable({
|
|
|
893
897
|
|
|
894
898
|
// src/DataTable/DataTable.tsx
|
|
895
899
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
896
|
-
var DataTableWrapper =
|
|
900
|
+
var DataTableWrapper = import_styled_components14.default.div`
|
|
897
901
|
width: ${(props) => props.width ?? "100%"};
|
|
898
902
|
|
|
899
903
|
.--table-container {
|
|
@@ -902,8 +906,10 @@ var DataTableWrapper = import_styled_components15.default.div`
|
|
|
902
906
|
overflow: auto;
|
|
903
907
|
|
|
904
908
|
table {
|
|
905
|
-
width: 100
|
|
906
|
-
|
|
909
|
+
width: ${(props) => props.width ?? "100%"};
|
|
910
|
+
height: ${(props) => props.height ?? "100%"};
|
|
911
|
+
table-layout: ${(props) => props.tableLayout ?? "fixed"};
|
|
912
|
+
border-collapse: collapse;
|
|
907
913
|
}
|
|
908
914
|
}
|
|
909
915
|
`;
|
|
@@ -914,6 +920,7 @@ function DataTable({
|
|
|
914
920
|
header,
|
|
915
921
|
filters,
|
|
916
922
|
config,
|
|
923
|
+
cellConfig,
|
|
917
924
|
rowConfig
|
|
918
925
|
}) {
|
|
919
926
|
const [columnVisibility, setColumnVisibility] = (0, import_jotai3.useAtom)(columnVisibilityAtom);
|
|
@@ -965,9 +972,9 @@ function DataTable({
|
|
|
965
972
|
}, [table, config == null ? void 0 : config.expandAllByDefault]);
|
|
966
973
|
const tableContainerRef = (0, import_react4.useRef)(null);
|
|
967
974
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DataTableWrapper, {
|
|
968
|
-
captionPadding: header == null ? void 0 : header.captionPadding,
|
|
969
975
|
height: config == null ? void 0 : config.height,
|
|
970
976
|
width: config == null ? void 0 : config.width,
|
|
977
|
+
tableLayout: config == null ? void 0 : config.tableLayout,
|
|
971
978
|
children: [
|
|
972
979
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DataTableHeader, {
|
|
973
980
|
tableCaption: header == null ? void 0 : header.tableCaption,
|
|
@@ -982,11 +989,13 @@ function DataTable({
|
|
|
982
989
|
containerRef: tableContainerRef,
|
|
983
990
|
table,
|
|
984
991
|
rowConfig,
|
|
992
|
+
cellConfig,
|
|
985
993
|
isLoading,
|
|
986
994
|
stickyHeader: header == null ? void 0 : header.stickyHeader
|
|
987
995
|
}) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(BasicTable, {
|
|
988
996
|
table,
|
|
989
997
|
rowConfig,
|
|
998
|
+
cellConfig,
|
|
990
999
|
isLoading,
|
|
991
1000
|
stickyHeader: header == null ? void 0 : header.stickyHeader
|
|
992
1001
|
})
|
package/dist/index.mjs
CHANGED
|
@@ -152,19 +152,7 @@ import styled5 from "styled-components";
|
|
|
152
152
|
|
|
153
153
|
// src/cells/StickyCell.tsx
|
|
154
154
|
import { Table } from "@equinor/eds-core-react";
|
|
155
|
-
import styled4 from "styled-components";
|
|
156
|
-
var StickyCell = styled4(Table.Cell)`
|
|
157
|
-
position: sticky;
|
|
158
|
-
right: 0;
|
|
159
|
-
top: 0;
|
|
160
|
-
z-index: 4;
|
|
161
|
-
`;
|
|
162
|
-
var StickyHeaderCell = styled4(StickyCell)`
|
|
163
|
-
z-index: 5;
|
|
164
|
-
`;
|
|
165
|
-
|
|
166
|
-
// src/cells/styles.ts
|
|
167
|
-
import { css as css2 } from "styled-components";
|
|
155
|
+
import styled4, { css as css2 } from "styled-components";
|
|
168
156
|
var leftCellShadow = css2`
|
|
169
157
|
&:before {
|
|
170
158
|
box-shadow: -1px 0 1px -1px inset;
|
|
@@ -176,12 +164,21 @@ var leftCellShadow = css2`
|
|
|
176
164
|
width: 1px;
|
|
177
165
|
}
|
|
178
166
|
`;
|
|
167
|
+
var StickyCell = styled4(Table.Cell)`
|
|
168
|
+
position: sticky;
|
|
169
|
+
right: 0;
|
|
170
|
+
top: 0;
|
|
171
|
+
z-index: 4;
|
|
172
|
+
background-clip: padding-box;
|
|
173
|
+
${leftCellShadow}
|
|
174
|
+
`;
|
|
175
|
+
var StickyHeaderCell = styled4(StickyCell)`
|
|
176
|
+
z-index: 5;
|
|
177
|
+
`;
|
|
179
178
|
|
|
180
179
|
// src/cells/DynamicCell.tsx
|
|
181
180
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
182
181
|
var StyledStickyCell = styled5(StickyCell)`
|
|
183
|
-
background-clip: padding-box;
|
|
184
|
-
${leftCellShadow}
|
|
185
182
|
${(props) => props.backgroundColor ? `background-color: ${props.backgroundColor} !important;` : ``}
|
|
186
183
|
`;
|
|
187
184
|
var StyledCell = styled5(Table2.Cell)`
|
|
@@ -422,9 +419,6 @@ var HeaderDiv = styled10.div`
|
|
|
422
419
|
gap: 0.25rem;
|
|
423
420
|
z-index: 5;
|
|
424
421
|
`;
|
|
425
|
-
var StyledStickyCell2 = styled10(StickyCell)`
|
|
426
|
-
${leftCellShadow}
|
|
427
|
-
`;
|
|
428
422
|
var HeaderCell = ({ header }) => {
|
|
429
423
|
var _a;
|
|
430
424
|
const style = {
|
|
@@ -437,7 +431,7 @@ var HeaderCell = ({ header }) => {
|
|
|
437
431
|
colSpan: header.colSpan
|
|
438
432
|
};
|
|
439
433
|
if ((_a = header.column.columnDef.meta) == null ? void 0 : _a.sticky)
|
|
440
|
-
return /* @__PURE__ */ jsx9(
|
|
434
|
+
return /* @__PURE__ */ jsx9(StickyHeaderCell, {
|
|
441
435
|
...cellProps,
|
|
442
436
|
children: /* @__PURE__ */ jsx9(HeaderContent, {
|
|
443
437
|
header
|
|
@@ -500,20 +494,30 @@ function TableHeader({ table, sticky }) {
|
|
|
500
494
|
import { Table as Table6 } from "@equinor/eds-core-react";
|
|
501
495
|
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
502
496
|
function TableRow({ row, rowConfig, cellConfig }) {
|
|
503
|
-
|
|
497
|
+
var _a;
|
|
498
|
+
const rowWrapper = rowConfig == null ? void 0 : rowConfig.rowWrapper;
|
|
499
|
+
const tableRowContent = /* @__PURE__ */ jsx11(Table6.Row, {
|
|
504
500
|
active: row.getIsSelected(),
|
|
505
|
-
style: {
|
|
501
|
+
style: {
|
|
502
|
+
cursor: (rowConfig == null ? void 0 : rowConfig.onClick) ? "pointer" : "initial",
|
|
503
|
+
backgroundColor: (_a = rowConfig == null ? void 0 : rowConfig.getRowBackground) == null ? void 0 : _a.call(rowConfig, row)
|
|
504
|
+
},
|
|
506
505
|
onClick: () => {
|
|
507
|
-
var
|
|
508
|
-
return (
|
|
506
|
+
var _a2;
|
|
507
|
+
return (_a2 = rowConfig == null ? void 0 : rowConfig.onClick) == null ? void 0 : _a2.call(rowConfig, row);
|
|
509
508
|
},
|
|
510
509
|
onMouseEnter: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseEnter),
|
|
511
510
|
onMouseLeave: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseLeave),
|
|
512
|
-
children: row.getVisibleCells().map((cell) =>
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
511
|
+
children: row.getVisibleCells().map((cell) => {
|
|
512
|
+
var _a2;
|
|
513
|
+
return /* @__PURE__ */ jsx11(DynamicCell, {
|
|
514
|
+
cell,
|
|
515
|
+
getStickyCellColor: cellConfig == null ? void 0 : cellConfig.getStickyCellColor,
|
|
516
|
+
highlight: (_a2 = cellConfig == null ? void 0 : cellConfig.getShouldHighlight) == null ? void 0 : _a2.call(cellConfig, cell)
|
|
517
|
+
}, cell.id);
|
|
518
|
+
})
|
|
516
519
|
});
|
|
520
|
+
return rowWrapper ? rowWrapper({ row, children: tableRowContent }) : tableRowContent;
|
|
517
521
|
}
|
|
518
522
|
function handleRowEvent(row, handler) {
|
|
519
523
|
if (!handler)
|
|
@@ -863,8 +867,10 @@ var DataTableWrapper = styled14.div`
|
|
|
863
867
|
overflow: auto;
|
|
864
868
|
|
|
865
869
|
table {
|
|
866
|
-
width: 100
|
|
867
|
-
|
|
870
|
+
width: ${(props) => props.width ?? "100%"};
|
|
871
|
+
height: ${(props) => props.height ?? "100%"};
|
|
872
|
+
table-layout: ${(props) => props.tableLayout ?? "fixed"};
|
|
873
|
+
border-collapse: collapse;
|
|
868
874
|
}
|
|
869
875
|
}
|
|
870
876
|
`;
|
|
@@ -875,6 +881,7 @@ function DataTable({
|
|
|
875
881
|
header,
|
|
876
882
|
filters,
|
|
877
883
|
config,
|
|
884
|
+
cellConfig,
|
|
878
885
|
rowConfig
|
|
879
886
|
}) {
|
|
880
887
|
const [columnVisibility, setColumnVisibility] = useAtom2(columnVisibilityAtom);
|
|
@@ -926,9 +933,9 @@ function DataTable({
|
|
|
926
933
|
}, [table, config == null ? void 0 : config.expandAllByDefault]);
|
|
927
934
|
const tableContainerRef = useRef2(null);
|
|
928
935
|
return /* @__PURE__ */ jsxs11(DataTableWrapper, {
|
|
929
|
-
captionPadding: header == null ? void 0 : header.captionPadding,
|
|
930
936
|
height: config == null ? void 0 : config.height,
|
|
931
937
|
width: config == null ? void 0 : config.width,
|
|
938
|
+
tableLayout: config == null ? void 0 : config.tableLayout,
|
|
932
939
|
children: [
|
|
933
940
|
/* @__PURE__ */ jsx18(DataTableHeader, {
|
|
934
941
|
tableCaption: header == null ? void 0 : header.tableCaption,
|
|
@@ -943,11 +950,13 @@ function DataTable({
|
|
|
943
950
|
containerRef: tableContainerRef,
|
|
944
951
|
table,
|
|
945
952
|
rowConfig,
|
|
953
|
+
cellConfig,
|
|
946
954
|
isLoading,
|
|
947
955
|
stickyHeader: header == null ? void 0 : header.stickyHeader
|
|
948
956
|
}) : /* @__PURE__ */ jsx18(BasicTable, {
|
|
949
957
|
table,
|
|
950
958
|
rowConfig,
|
|
959
|
+
cellConfig,
|
|
951
960
|
isLoading,
|
|
952
961
|
stickyHeader: header == null ? void 0 : header.stickyHeader
|
|
953
962
|
})
|