@equinor/apollo-components 1.6.1 → 1.7.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  import { IconData } from '@equinor/eds-icons';
2
2
  import * as react from 'react';
3
3
  import { ReactNode, ComponentProps } from 'react';
4
- import { Cell, CellContext, ColumnDef, Row, RowSelectionState, SortingState, Table, HeaderContext } from '@tanstack/react-table';
4
+ import { Cell, CellContext, Row, ColumnDef, RowSelectionState, SortingState, Table, 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';
7
7
  import { CellProps, TypographyProps as TypographyProps$1 } from '@equinor/eds-core-react';
@@ -45,6 +45,15 @@ interface FilterConfig {
45
45
  globalFilterPlaceholder?: string;
46
46
  filterFromLeafRows?: boolean;
47
47
  }
48
+ interface RowConfig<T> {
49
+ getRowBackground?: (row: Row<T>) => string | undefined;
50
+ onClick?: (row: Row<T>) => void;
51
+ onMouseEnter?: (row: Row<T>) => void;
52
+ onMouseLeave?: (row: Row<T>) => void;
53
+ }
54
+ interface CellConfig<T> {
55
+ getStickyCellColor?: (cell: Cell<T, unknown>) => string;
56
+ }
48
57
  declare type RowSelectionMode = 'single' | 'multiple';
49
58
  declare type DataTableConfig<T> = {
50
59
  height?: string;
@@ -55,7 +64,6 @@ declare type DataTableConfig<T> = {
55
64
  selectColumn?: 'default' | ((options?: Record<string, any>) => ColumnDef<T, any>);
56
65
  getSubRows?: (originalRow: T) => T[] | undefined;
57
66
  getRowId?: (originalRow: T, index: number, parent: Row<T> | undefined) => string;
58
- onRowClick?: (row: Row<T>) => void;
59
67
  } & ExpansionConfig;
60
68
  interface ExpansionConfig {
61
69
  expandAllByDefault?: boolean;
@@ -68,10 +76,12 @@ interface DataTableProps<T> {
68
76
  isLoading?: boolean;
69
77
  className?: string;
70
78
  config?: DataTableConfig<T>;
79
+ cellConfig?: CellConfig<T>;
80
+ rowConfig?: RowConfig<T>;
71
81
  filters?: FilterConfig;
72
82
  header?: HeaderConfig;
73
83
  }
74
- declare function DataTable$1<T>({ columns, data, isLoading, header, filters, config, }: DataTableProps<T>): JSX.Element;
84
+ declare function DataTable$1<T>({ columns, data, isLoading, header, filters, config, rowConfig, }: DataTableProps<T>): JSX.Element;
75
85
 
76
86
  declare type DataTableProviderProps = ComponentProps<typeof Provider>;
77
87
  declare function DataTableProvider({ children, ...props }: DataTableProviderProps): JSX.Element;
@@ -123,4 +133,4 @@ declare type TypographyProps = {
123
133
  */
124
134
  declare const TypographyCustom: (props: TypographyProps) => JSX.Element;
125
135
 
126
- export { AppShell, AppSidebar, ChipsCell, DataTable, DataTableConfig, DynamicCell, FilterConfig, HeaderConfig, HierarchyCell, RowSelectionMode, SelectColumnDef, StickyCell, TableHeader, TypographyCustom, capitalizeHeader, globalFilterAtom, prependSelectColumn, rowSelectionAtom, tableSortingAtom };
136
+ export { AppShell, AppSidebar, CellConfig, ChipsCell, DataTable, DataTableConfig, DynamicCell, FilterConfig, HeaderConfig, HierarchyCell, RowConfig, RowSelectionMode, SelectColumnDef, StickyCell, TableHeader, TypographyCustom, capitalizeHeader, globalFilterAtom, prependSelectColumn, rowSelectionAtom, tableSortingAtom };
package/dist/index.js CHANGED
@@ -159,6 +159,12 @@ function stringToHslColor(str, s = 80, l = 85) {
159
159
  const h = hash % 360;
160
160
  return "hsl(" + h + ", " + s + "%, " + l + "%)";
161
161
  }
162
+ function stopPropagation(handler) {
163
+ return (e) => {
164
+ e.stopPropagation();
165
+ handler(e);
166
+ };
167
+ }
162
168
 
163
169
  // src/cells/ChipsCell.tsx
164
170
  var import_jsx_runtime3 = require("react/jsx-runtime");
@@ -222,6 +228,7 @@ var import_jsx_runtime4 = require("react/jsx-runtime");
222
228
  var StyledStickyCell = (0, import_styled_components6.default)(StickyCell)`
223
229
  background-clip: padding-box;
224
230
  ${leftCellShadow}
231
+ ${(props) => props.backgroundColor ? `background-color: ${props.backgroundColor} !important;` : ``}
225
232
  `;
226
233
  var StyledCell = (0, import_styled_components6.default)(import_eds_core_react4.Table.Cell)`
227
234
  ${(props) => props.backgroundColor ? `background-color: ${props.backgroundColor} !important;` : ``}
@@ -374,27 +381,18 @@ function SelectColumnDef(selectionMode) {
374
381
  selectionMode === "single" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Radio, {
375
382
  checked: row.getIsSelected(),
376
383
  "aria-label": `Select row ${row.id}`,
377
- onChange: (e) => {
378
- e.stopPropagation();
379
- row.getToggleSelectedHandler()(e);
380
- }
384
+ onChange: stopPropagation(row.getToggleSelectedHandler())
381
385
  }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Checkbox, {
382
386
  checked: row.getIsSelected(),
383
387
  indeterminate: row.getIsSomeSelected(),
384
388
  "aria-label": `Select row ${row.id}`,
385
- onChange: (e) => {
386
- e.stopPropagation();
387
- row.getToggleSelectedHandler()(e);
388
- }
389
+ onChange: stopPropagation(row.getToggleSelectedHandler())
389
390
  }),
390
391
  row.getCanExpand() && table.options.enableExpanding && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Button, {
391
392
  variant: "ghost_icon",
392
393
  color: "secondary",
393
394
  "aria-label": row.getIsExpanded() ? "Close group" : "Expand group",
394
- onClick: (e) => {
395
- e.stopPropagation();
396
- row.getToggleExpandedHandler()();
397
- },
395
+ onClick: stopPropagation(row.getToggleExpandedHandler()),
398
396
  style: { cursor: "pointer" },
399
397
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Icon, {
400
398
  data: row.getIsExpanded() ? import_eds_icons3.chevron_up : import_eds_icons3.chevron_down
@@ -408,7 +406,7 @@ function SelectColumnDef(selectionMode) {
408
406
  }
409
407
 
410
408
  // src/DataTable/DataTable.tsx
411
- var import_react_table5 = require("@tanstack/react-table");
409
+ var import_react_table3 = require("@tanstack/react-table");
412
410
  var import_jotai3 = require("jotai");
413
411
  var import_react4 = require("react");
414
412
  var import_styled_components15 = __toESM(require("styled-components"));
@@ -422,8 +420,7 @@ var tableSortingAtom = (0, import_jotai.atom)([]);
422
420
  var expandedRowsAtom = (0, import_jotai.atom)({});
423
421
 
424
422
  // src/DataTable/components/BasicTable.tsx
425
- var import_eds_core_react10 = require("@equinor/eds-core-react");
426
- var import_react_table3 = require("@tanstack/react-table");
423
+ var import_eds_core_react11 = require("@equinor/eds-core-react");
427
424
 
428
425
  // src/DataTable/components/PlaceholderRow.tsx
429
426
  var import_eds_core_react7 = require("@equinor/eds-core-react");
@@ -537,28 +534,55 @@ function TableHeader({ table, sticky }) {
537
534
  });
538
535
  }
539
536
 
540
- // src/DataTable/components/BasicTable.tsx
537
+ // src/DataTable/components/TableRow.tsx
538
+ var import_eds_core_react10 = require("@equinor/eds-core-react");
541
539
  var import_jsx_runtime11 = require("react/jsx-runtime");
542
- function BasicTable({ table, config, stickyHeader, isLoading }) {
540
+ function TableRow({ row, rowConfig, cellConfig }) {
541
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_eds_core_react10.Table.Row, {
542
+ active: row.getIsSelected(),
543
+ style: { cursor: (rowConfig == null ? void 0 : rowConfig.onClick) ? "pointer" : "initial" },
544
+ onClick: () => {
545
+ var _a;
546
+ return (_a = rowConfig == null ? void 0 : rowConfig.onClick) == null ? void 0 : _a.call(rowConfig, row);
547
+ },
548
+ onMouseEnter: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseEnter),
549
+ onMouseLeave: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseLeave),
550
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DynamicCell, {
551
+ cell,
552
+ getStickyCellColor: cellConfig == null ? void 0 : cellConfig.getStickyCellColor
553
+ }, cell.id))
554
+ });
555
+ }
556
+ function handleRowEvent(row, handler) {
557
+ if (!handler)
558
+ return void 0;
559
+ return () => {
560
+ handler(row);
561
+ };
562
+ }
563
+
564
+ // src/DataTable/components/BasicTable.tsx
565
+ var import_jsx_runtime12 = require("react/jsx-runtime");
566
+ function BasicTable({
567
+ table,
568
+ rowConfig,
569
+ cellConfig,
570
+ stickyHeader,
571
+ isLoading
572
+ }) {
543
573
  const tableRows = table.getRowModel().rows;
544
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_eds_core_react10.Table, {
574
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_eds_core_react11.Table, {
545
575
  children: [
546
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TableHeader, {
576
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TableHeader, {
547
577
  sticky: stickyHeader,
548
578
  table
549
579
  }),
550
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_eds_core_react10.Table.Body, {
551
- children: tableRows.length ? tableRows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_eds_core_react10.Table.Row, {
552
- active: row.getIsSelected(),
553
- style: { cursor: (config == null ? void 0 : config.onRowClick) ? "pointer" : "initial" },
554
- onClick: () => {
555
- var _a;
556
- return (_a = config == null ? void 0 : config.onRowClick) == null ? void 0 : _a.call(config, row);
557
- },
558
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_eds_core_react10.Table.Cell, {
559
- children: (0, import_react_table3.flexRender)(cell.column.columnDef.cell, cell.getContext())
560
- }, cell.id))
561
- }, row.id)) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PlaceholderRow, {
580
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Table.Body, {
581
+ children: tableRows.length ? tableRows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TableRow, {
582
+ row,
583
+ rowConfig,
584
+ cellConfig
585
+ }, row.id)) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(PlaceholderRow, {
562
586
  isLoading
563
587
  })
564
588
  })
@@ -567,7 +591,7 @@ function BasicTable({ table, config, stickyHeader, isLoading }) {
567
591
  }
568
592
 
569
593
  // src/DataTable/components/ColumnSelect.tsx
570
- var import_eds_core_react11 = require("@equinor/eds-core-react");
594
+ var import_eds_core_react12 = require("@equinor/eds-core-react");
571
595
  var import_eds_icons5 = require("@equinor/eds-icons");
572
596
  var import_react2 = require("react");
573
597
  var import_styled_components12 = __toESM(require("styled-components"));
@@ -595,7 +619,7 @@ function prependSelectColumn(columns, config) {
595
619
  }
596
620
 
597
621
  // src/DataTable/components/ColumnSelect.tsx
598
- var import_jsx_runtime12 = require("react/jsx-runtime");
622
+ var import_jsx_runtime13 = require("react/jsx-runtime");
599
623
  var ColumnSelectContent = import_styled_components12.default.div`
600
624
  display: grid;
601
625
  grid-template-columns: repeat(2, 1fr);
@@ -611,9 +635,9 @@ function ColumnSelect({ table }) {
611
635
  const [isOpen, setIsOpen] = (0, import_react2.useState)(false);
612
636
  const referenceElement = (0, import_react2.useRef)(null);
613
637
  const selectableColumns = table.getAllLeafColumns().filter((column) => column.id !== "select");
614
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, {
638
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, {
615
639
  children: [
616
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Button, {
640
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Button, {
617
641
  "aria-haspopup": true,
618
642
  id: "column-select-anchor",
619
643
  "aria-controls": "column-select-popover",
@@ -621,28 +645,28 @@ function ColumnSelect({ table }) {
621
645
  ref: referenceElement,
622
646
  variant: "ghost_icon",
623
647
  onClick: () => setIsOpen(true),
624
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Icon, {
648
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Icon, {
625
649
  name: "view_column",
626
650
  data: import_eds_icons5.view_column
627
651
  })
628
652
  }),
629
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_eds_core_react11.Popover, {
653
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_eds_core_react12.Popover, {
630
654
  open: isOpen,
631
655
  id: "column-select-popover",
632
656
  anchorEl: referenceElement.current,
633
657
  placement: "bottom-end",
634
658
  onClose: () => setIsOpen(false),
635
659
  children: [
636
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_eds_core_react11.Popover.Header, {
660
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_eds_core_react12.Popover.Header, {
637
661
  children: [
638
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Popover.Title, {
662
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Popover.Title, {
639
663
  children: "Column settings"
640
664
  }),
641
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Button, {
665
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Button, {
642
666
  variant: "ghost_icon",
643
667
  "aria-label": "Close column select",
644
668
  onClick: () => setIsOpen(false),
645
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Icon, {
669
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Icon, {
646
670
  name: "close",
647
671
  data: import_eds_icons5.close,
648
672
  size: 24
@@ -650,22 +674,22 @@ function ColumnSelect({ table }) {
650
674
  })
651
675
  ]
652
676
  }),
653
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_eds_core_react11.Popover.Content, {
677
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_eds_core_react12.Popover.Content, {
654
678
  children: [
655
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ColumnSelectContent, {
679
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ColumnSelectContent, {
656
680
  children: selectableColumns.map((column) => {
657
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Checkbox, {
681
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Checkbox, {
658
682
  checked: column.getIsVisible(),
659
683
  label: getColumnHeader(column),
660
684
  onChange: column.getToggleVisibilityHandler()
661
685
  }, column.id);
662
686
  })
663
687
  }),
664
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Divider, {
688
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Divider, {
665
689
  variant: "small"
666
690
  }),
667
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ActionsWrapper, {
668
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Button, {
691
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ActionsWrapper, {
692
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Button, {
669
693
  color: "secondary",
670
694
  variant: "ghost",
671
695
  disabled: table.getIsAllColumnsVisible(),
@@ -682,21 +706,21 @@ function ColumnSelect({ table }) {
682
706
  }
683
707
 
684
708
  // src/DataTable/components/DataTableHeader.tsx
685
- var import_eds_core_react13 = require("@equinor/eds-core-react");
709
+ var import_eds_core_react14 = require("@equinor/eds-core-react");
686
710
  var import_eds_icons7 = require("@equinor/eds-icons");
687
711
  var import_jotai2 = require("jotai");
688
712
  var import_styled_components14 = __toESM(require("styled-components"));
689
713
 
690
714
  // src/DataTable/filters/DebouncedInput.tsx
691
- var import_eds_core_react12 = require("@equinor/eds-core-react");
715
+ var import_eds_core_react13 = require("@equinor/eds-core-react");
692
716
  var import_eds_icons6 = require("@equinor/eds-icons");
693
717
  var import_react3 = require("react");
694
718
  var import_styled_components13 = __toESM(require("styled-components"));
695
- var import_jsx_runtime13 = require("react/jsx-runtime");
719
+ var import_jsx_runtime14 = require("react/jsx-runtime");
696
720
  var Wrapper3 = import_styled_components13.default.div`
697
721
  width: 200px;
698
722
  `;
699
- var CloseButton = (0, import_styled_components13.default)(import_eds_core_react12.Button)`
723
+ var CloseButton = (0, import_styled_components13.default)(import_eds_core_react13.Button)`
700
724
  width: 24px;
701
725
  height: 24px;
702
726
  `;
@@ -717,21 +741,21 @@ function DebouncedInput({
717
741
  }, debounce);
718
742
  return () => clearTimeout(timeout);
719
743
  }, [value]);
720
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Wrapper3, {
721
- children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Input, {
744
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Wrapper3, {
745
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Input, {
722
746
  ...props,
723
747
  value,
724
- leftAdornments: icon && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Icon, {
748
+ leftAdornments: icon && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Icon, {
725
749
  name: icon.name,
726
750
  data: icon,
727
751
  size: 18
728
752
  }),
729
- rightAdornments: !!value && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Tooltip, {
753
+ rightAdornments: !!value && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Tooltip, {
730
754
  title: "Clear input",
731
- children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CloseButton, {
755
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CloseButton, {
732
756
  variant: "ghost_icon",
733
757
  onClick: () => setValue(""),
734
- children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Icon, {
758
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Icon, {
735
759
  name: import_eds_icons6.close.name,
736
760
  data: import_eds_icons6.close,
737
761
  size: 18
@@ -754,7 +778,7 @@ var fuzzyFilter = (row, columnId, value, addMeta) => {
754
778
  };
755
779
 
756
780
  // src/DataTable/components/DataTableHeader.tsx
757
- var import_jsx_runtime14 = require("react/jsx-runtime");
781
+ var import_jsx_runtime15 = require("react/jsx-runtime");
758
782
  var DataTableHeaderWrapper = import_styled_components14.default.div`
759
783
  display: flex;
760
784
  align-items: center;
@@ -770,18 +794,18 @@ var FilterContainer = import_styled_components14.default.div`
770
794
  `;
771
795
  var DataTableHeader = (props) => {
772
796
  const [globalFilter, setGlobalFilter] = (0, import_jotai2.useAtom)(globalFilterAtom);
773
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(DataTableHeaderWrapper, {
797
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(DataTableHeaderWrapper, {
774
798
  className: "--table-caption",
775
799
  captionPadding: props.captionPadding,
776
800
  children: [
777
- (props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Typography, {
801
+ (props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_eds_core_react14.Typography, {
778
802
  variant: "h3",
779
803
  children: props == null ? void 0 : props.tableCaption
780
804
  }),
781
- (props == null ? void 0 : props.enableGlobalFilter) && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(FilterContainer, {
805
+ (props == null ? void 0 : props.enableGlobalFilter) && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(FilterContainer, {
782
806
  className: "--filter-container",
783
807
  children: [
784
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DebouncedInput, {
808
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(DebouncedInput, {
785
809
  value: globalFilter,
786
810
  icon: import_eds_icons7.search,
787
811
  placeholder: (props == null ? void 0 : props.globalFilterPlaceholder) ?? "Search all columns",
@@ -795,26 +819,31 @@ var DataTableHeader = (props) => {
795
819
  };
796
820
 
797
821
  // src/DataTable/components/VirtualTable.tsx
798
- var import_eds_core_react15 = require("@equinor/eds-core-react");
799
- var import_react_table4 = require("@tanstack/react-table");
822
+ var import_eds_core_react16 = require("@equinor/eds-core-react");
800
823
  var import_react_virtual = require("@tanstack/react-virtual");
801
824
 
802
825
  // src/DataTable/components/PaddingRow.tsx
803
- var import_eds_core_react14 = require("@equinor/eds-core-react");
804
- var import_jsx_runtime15 = require("react/jsx-runtime");
826
+ var import_eds_core_react15 = require("@equinor/eds-core-react");
827
+ var import_jsx_runtime16 = require("react/jsx-runtime");
805
828
  var PaddingRow = (props) => {
806
829
  if (!props.height)
807
830
  return null;
808
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_eds_core_react14.Table.Row, {
809
- children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_eds_core_react14.Table.Cell, {
831
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_eds_core_react15.Table.Row, {
832
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_eds_core_react15.Table.Cell, {
810
833
  style: { height: `${props.height}px` }
811
834
  })
812
835
  });
813
836
  };
814
837
 
815
838
  // src/DataTable/components/VirtualTable.tsx
816
- var import_jsx_runtime16 = require("react/jsx-runtime");
817
- function VirtualTable({ table, config, containerRef, ...props }) {
839
+ var import_jsx_runtime17 = require("react/jsx-runtime");
840
+ function VirtualTable({
841
+ table,
842
+ rowConfig,
843
+ cellConfig,
844
+ containerRef,
845
+ ...props
846
+ }) {
818
847
  var _a, _b;
819
848
  const { rows } = table.getRowModel();
820
849
  const rowVirtualizer = (0, import_react_virtual.useVirtualizer)({
@@ -825,34 +854,28 @@ function VirtualTable({ table, config, containerRef, ...props }) {
825
854
  const virtualRows = rowVirtualizer.getVirtualItems();
826
855
  const paddingTop = virtualRows.length > 0 ? ((_a = virtualRows == null ? void 0 : virtualRows[0]) == null ? void 0 : _a.start) || 0 : 0;
827
856
  const paddingBottom = virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (((_b = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b.end) || 0) : 0;
828
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_eds_core_react15.Table, {
857
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_eds_core_react16.Table, {
829
858
  children: [
830
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TableHeader, {
859
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TableHeader, {
831
860
  sticky: props.stickyHeader,
832
861
  table
833
862
  }),
834
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_eds_core_react15.Table.Body, {
863
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_eds_core_react16.Table.Body, {
835
864
  children: [
836
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(PaddingRow, {
865
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PaddingRow, {
837
866
  height: paddingTop
838
867
  }),
839
868
  rows.length ? virtualRows.map((virtualRow) => {
840
869
  const row = rows[virtualRow.index];
841
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_eds_core_react15.Table.Row, {
842
- active: row.getIsSelected(),
843
- style: { cursor: (config == null ? void 0 : config.onRowClick) ? "pointer" : "initial" },
844
- onClick: () => {
845
- var _a2;
846
- return (_a2 = config == null ? void 0 : config.onRowClick) == null ? void 0 : _a2.call(config, row);
847
- },
848
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_eds_core_react15.Table.Cell, {
849
- children: (0, import_react_table4.flexRender)(cell.column.columnDef.cell, cell.getContext())
850
- }, cell.id))
870
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TableRow, {
871
+ row,
872
+ rowConfig,
873
+ cellConfig
851
874
  }, row.id);
852
- }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(PlaceholderRow, {
875
+ }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PlaceholderRow, {
853
876
  isLoading: props.isLoading
854
877
  }),
855
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(PaddingRow, {
878
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PaddingRow, {
856
879
  height: paddingBottom
857
880
  })
858
881
  ]
@@ -862,7 +885,7 @@ function VirtualTable({ table, config, containerRef, ...props }) {
862
885
  }
863
886
 
864
887
  // src/DataTable/DataTable.tsx
865
- var import_jsx_runtime17 = require("react/jsx-runtime");
888
+ var import_jsx_runtime18 = require("react/jsx-runtime");
866
889
  var DataTableWrapper = import_styled_components15.default.div`
867
890
  width: ${(props) => props.width ?? "100%"};
868
891
 
@@ -883,7 +906,8 @@ function DataTable({
883
906
  isLoading,
884
907
  header,
885
908
  filters,
886
- config
909
+ config,
910
+ rowConfig
887
911
  }) {
888
912
  const [columnVisibility, setColumnVisibility] = (0, import_jotai3.useAtom)(columnVisibilityAtom);
889
913
  const [globalFilter, setGlobalFilter] = (0, import_jotai3.useAtom)(globalFilterAtom);
@@ -893,7 +917,7 @@ function DataTable({
893
917
  function enableGlobalFilter(value) {
894
918
  return enableOrUndefined(filters == null ? void 0 : filters.globalFilter, value);
895
919
  }
896
- const table = (0, import_react_table5.useReactTable)({
920
+ const table = (0, import_react_table3.useReactTable)({
897
921
  columns: prependSelectColumn(columns, config),
898
922
  data,
899
923
  globalFilterFn: enableGlobalFilter(fuzzyFilter),
@@ -905,7 +929,7 @@ function DataTable({
905
929
  columnVisibility
906
930
  },
907
931
  defaultColumn: {
908
- cell: (cell) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TypographyCustom, {
932
+ cell: (cell) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TypographyCustom, {
909
933
  noWrap: true,
910
934
  children: cell.getValue()
911
935
  })
@@ -915,10 +939,10 @@ function DataTable({
915
939
  enableMultiRowSelection: (config == null ? void 0 : config.rowSelectionMode) === "multiple",
916
940
  enableSubRowSelection: (config == null ? void 0 : config.rowSelectionMode) !== "single",
917
941
  filterFromLeafRows: filters == null ? void 0 : filters.filterFromLeafRows,
918
- getFilteredRowModel: enableGlobalFilter((0, import_react_table5.getFilteredRowModel)()),
919
- getCoreRowModel: (0, import_react_table5.getCoreRowModel)(),
920
- getExpandedRowModel: (0, import_react_table5.getExpandedRowModel)(),
921
- getSortedRowModel: (0, import_react_table5.getSortedRowModel)(),
942
+ getFilteredRowModel: enableGlobalFilter((0, import_react_table3.getFilteredRowModel)()),
943
+ getCoreRowModel: (0, import_react_table3.getCoreRowModel)(),
944
+ getExpandedRowModel: (0, import_react_table3.getExpandedRowModel)(),
945
+ getSortedRowModel: (0, import_react_table3.getSortedRowModel)(),
922
946
  onExpandedChange: setExpanded,
923
947
  onRowSelectionChange: setRowSelectionState,
924
948
  onSortingChange: enableOrUndefined(config == null ? void 0 : config.sortable, setSorting),
@@ -933,32 +957,32 @@ function DataTable({
933
957
  }
934
958
  }, [table, config == null ? void 0 : config.expandAllByDefault]);
935
959
  const tableContainerRef = (0, import_react4.useRef)(null);
936
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(DataTableWrapper, {
960
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DataTableWrapper, {
937
961
  captionPadding: header == null ? void 0 : header.captionPadding,
938
962
  height: config == null ? void 0 : config.height,
939
963
  width: config == null ? void 0 : config.width,
940
964
  children: [
941
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(DataTableHeader, {
965
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DataTableHeader, {
942
966
  tableCaption: header == null ? void 0 : header.tableCaption,
943
967
  enableGlobalFilter: filters == null ? void 0 : filters.globalFilter,
944
968
  globalFilterPlaceholder: filters == null ? void 0 : filters.globalFilterPlaceholder,
945
969
  captionPadding: header == null ? void 0 : header.captionPadding,
946
- filterActions: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ColumnSelect, {
970
+ filterActions: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ColumnSelect, {
947
971
  table
948
972
  })
949
973
  }),
950
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", {
974
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", {
951
975
  ref: tableContainerRef,
952
976
  className: "--table-container",
953
- children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(VirtualTable, {
977
+ children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(VirtualTable, {
954
978
  containerRef: tableContainerRef,
955
979
  table,
956
- config,
980
+ rowConfig,
957
981
  isLoading,
958
982
  stickyHeader: header == null ? void 0 : header.stickyHeader
959
- }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(BasicTable, {
983
+ }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(BasicTable, {
960
984
  table,
961
- config,
985
+ rowConfig,
962
986
  isLoading,
963
987
  stickyHeader: header == null ? void 0 : header.stickyHeader
964
988
  })
@@ -969,9 +993,9 @@ function DataTable({
969
993
 
970
994
  // src/DataTable/Provider.tsx
971
995
  var import_jotai4 = require("jotai");
972
- var import_jsx_runtime18 = require("react/jsx-runtime");
996
+ var import_jsx_runtime19 = require("react/jsx-runtime");
973
997
  function DataTableProvider({ children, ...props }) {
974
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jotai4.Provider, {
998
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jotai4.Provider, {
975
999
  ...props,
976
1000
  children
977
1001
  });
package/dist/index.mjs CHANGED
@@ -113,6 +113,12 @@ function stringToHslColor(str, s = 80, l = 85) {
113
113
  const h = hash % 360;
114
114
  return "hsl(" + h + ", " + s + "%, " + l + "%)";
115
115
  }
116
+ function stopPropagation(handler) {
117
+ return (e) => {
118
+ e.stopPropagation();
119
+ handler(e);
120
+ };
121
+ }
116
122
 
117
123
  // src/cells/ChipsCell.tsx
118
124
  import { jsx as jsx3 } from "react/jsx-runtime";
@@ -176,6 +182,7 @@ import { jsx as jsx4 } from "react/jsx-runtime";
176
182
  var StyledStickyCell = styled5(StickyCell)`
177
183
  background-clip: padding-box;
178
184
  ${leftCellShadow}
185
+ ${(props) => props.backgroundColor ? `background-color: ${props.backgroundColor} !important;` : ``}
179
186
  `;
180
187
  var StyledCell = styled5(Table2.Cell)`
181
188
  ${(props) => props.backgroundColor ? `background-color: ${props.backgroundColor} !important;` : ``}
@@ -330,27 +337,18 @@ function SelectColumnDef(selectionMode) {
330
337
  selectionMode === "single" ? /* @__PURE__ */ jsx7(Radio, {
331
338
  checked: row.getIsSelected(),
332
339
  "aria-label": `Select row ${row.id}`,
333
- onChange: (e) => {
334
- e.stopPropagation();
335
- row.getToggleSelectedHandler()(e);
336
- }
340
+ onChange: stopPropagation(row.getToggleSelectedHandler())
337
341
  }) : /* @__PURE__ */ jsx7(Checkbox, {
338
342
  checked: row.getIsSelected(),
339
343
  indeterminate: row.getIsSomeSelected(),
340
344
  "aria-label": `Select row ${row.id}`,
341
- onChange: (e) => {
342
- e.stopPropagation();
343
- row.getToggleSelectedHandler()(e);
344
- }
345
+ onChange: stopPropagation(row.getToggleSelectedHandler())
345
346
  }),
346
347
  row.getCanExpand() && table.options.enableExpanding && /* @__PURE__ */ jsx7(Button2, {
347
348
  variant: "ghost_icon",
348
349
  color: "secondary",
349
350
  "aria-label": row.getIsExpanded() ? "Close group" : "Expand group",
350
- onClick: (e) => {
351
- e.stopPropagation();
352
- row.getToggleExpandedHandler()();
353
- },
351
+ onClick: stopPropagation(row.getToggleExpandedHandler()),
354
352
  style: { cursor: "pointer" },
355
353
  children: /* @__PURE__ */ jsx7(Icon3, {
356
354
  data: row.getIsExpanded() ? chevron_up : chevron_down
@@ -385,7 +383,6 @@ var expandedRowsAtom = atom({});
385
383
 
386
384
  // src/DataTable/components/BasicTable.tsx
387
385
  import { Table as EdsTable } from "@equinor/eds-core-react";
388
- import { flexRender as flexRender3 } from "@tanstack/react-table";
389
386
 
390
387
  // src/DataTable/components/PlaceholderRow.tsx
391
388
  import { DotProgress, Table as Table3, Typography } from "@equinor/eds-core-react";
@@ -499,28 +496,55 @@ function TableHeader({ table, sticky }) {
499
496
  });
500
497
  }
501
498
 
499
+ // src/DataTable/components/TableRow.tsx
500
+ import { Table as Table6 } from "@equinor/eds-core-react";
501
+ import { jsx as jsx11 } from "react/jsx-runtime";
502
+ function TableRow({ row, rowConfig, cellConfig }) {
503
+ return /* @__PURE__ */ jsx11(Table6.Row, {
504
+ active: row.getIsSelected(),
505
+ style: { cursor: (rowConfig == null ? void 0 : rowConfig.onClick) ? "pointer" : "initial" },
506
+ onClick: () => {
507
+ var _a;
508
+ return (_a = rowConfig == null ? void 0 : rowConfig.onClick) == null ? void 0 : _a.call(rowConfig, row);
509
+ },
510
+ onMouseEnter: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseEnter),
511
+ onMouseLeave: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseLeave),
512
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx11(DynamicCell, {
513
+ cell,
514
+ getStickyCellColor: cellConfig == null ? void 0 : cellConfig.getStickyCellColor
515
+ }, cell.id))
516
+ });
517
+ }
518
+ function handleRowEvent(row, handler) {
519
+ if (!handler)
520
+ return void 0;
521
+ return () => {
522
+ handler(row);
523
+ };
524
+ }
525
+
502
526
  // src/DataTable/components/BasicTable.tsx
503
- import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
504
- function BasicTable({ table, config, stickyHeader, isLoading }) {
527
+ import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
528
+ function BasicTable({
529
+ table,
530
+ rowConfig,
531
+ cellConfig,
532
+ stickyHeader,
533
+ isLoading
534
+ }) {
505
535
  const tableRows = table.getRowModel().rows;
506
536
  return /* @__PURE__ */ jsxs7(EdsTable, {
507
537
  children: [
508
- /* @__PURE__ */ jsx11(TableHeader, {
538
+ /* @__PURE__ */ jsx12(TableHeader, {
509
539
  sticky: stickyHeader,
510
540
  table
511
541
  }),
512
- /* @__PURE__ */ jsx11(EdsTable.Body, {
513
- children: tableRows.length ? tableRows.map((row) => /* @__PURE__ */ jsx11(EdsTable.Row, {
514
- active: row.getIsSelected(),
515
- style: { cursor: (config == null ? void 0 : config.onRowClick) ? "pointer" : "initial" },
516
- onClick: () => {
517
- var _a;
518
- return (_a = config == null ? void 0 : config.onRowClick) == null ? void 0 : _a.call(config, row);
519
- },
520
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx11(EdsTable.Cell, {
521
- children: flexRender3(cell.column.columnDef.cell, cell.getContext())
522
- }, cell.id))
523
- }, row.id)) : /* @__PURE__ */ jsx11(PlaceholderRow, {
542
+ /* @__PURE__ */ jsx12(EdsTable.Body, {
543
+ children: tableRows.length ? tableRows.map((row) => /* @__PURE__ */ jsx12(TableRow, {
544
+ row,
545
+ rowConfig,
546
+ cellConfig
547
+ }, row.id)) : /* @__PURE__ */ jsx12(PlaceholderRow, {
524
548
  isLoading
525
549
  })
526
550
  })
@@ -557,7 +581,7 @@ function prependSelectColumn(columns, config) {
557
581
  }
558
582
 
559
583
  // src/DataTable/components/ColumnSelect.tsx
560
- import { Fragment as Fragment2, jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
584
+ import { Fragment as Fragment2, jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
561
585
  var ColumnSelectContent = styled11.div`
562
586
  display: grid;
563
587
  grid-template-columns: repeat(2, 1fr);
@@ -575,7 +599,7 @@ function ColumnSelect({ table }) {
575
599
  const selectableColumns = table.getAllLeafColumns().filter((column) => column.id !== "select");
576
600
  return /* @__PURE__ */ jsxs8(Fragment2, {
577
601
  children: [
578
- /* @__PURE__ */ jsx12(Button3, {
602
+ /* @__PURE__ */ jsx13(Button3, {
579
603
  "aria-haspopup": true,
580
604
  id: "column-select-anchor",
581
605
  "aria-controls": "column-select-popover",
@@ -583,7 +607,7 @@ function ColumnSelect({ table }) {
583
607
  ref: referenceElement,
584
608
  variant: "ghost_icon",
585
609
  onClick: () => setIsOpen(true),
586
- children: /* @__PURE__ */ jsx12(Icon5, {
610
+ children: /* @__PURE__ */ jsx13(Icon5, {
587
611
  name: "view_column",
588
612
  data: view_column
589
613
  })
@@ -597,14 +621,14 @@ function ColumnSelect({ table }) {
597
621
  children: [
598
622
  /* @__PURE__ */ jsxs8(Popover.Header, {
599
623
  children: [
600
- /* @__PURE__ */ jsx12(Popover.Title, {
624
+ /* @__PURE__ */ jsx13(Popover.Title, {
601
625
  children: "Column settings"
602
626
  }),
603
- /* @__PURE__ */ jsx12(Button3, {
627
+ /* @__PURE__ */ jsx13(Button3, {
604
628
  variant: "ghost_icon",
605
629
  "aria-label": "Close column select",
606
630
  onClick: () => setIsOpen(false),
607
- children: /* @__PURE__ */ jsx12(Icon5, {
631
+ children: /* @__PURE__ */ jsx13(Icon5, {
608
632
  name: "close",
609
633
  data: close,
610
634
  size: 24
@@ -614,20 +638,20 @@ function ColumnSelect({ table }) {
614
638
  }),
615
639
  /* @__PURE__ */ jsxs8(Popover.Content, {
616
640
  children: [
617
- /* @__PURE__ */ jsx12(ColumnSelectContent, {
641
+ /* @__PURE__ */ jsx13(ColumnSelectContent, {
618
642
  children: selectableColumns.map((column) => {
619
- return /* @__PURE__ */ jsx12(Checkbox2, {
643
+ return /* @__PURE__ */ jsx13(Checkbox2, {
620
644
  checked: column.getIsVisible(),
621
645
  label: getColumnHeader(column),
622
646
  onChange: column.getToggleVisibilityHandler()
623
647
  }, column.id);
624
648
  })
625
649
  }),
626
- /* @__PURE__ */ jsx12(Divider, {
650
+ /* @__PURE__ */ jsx13(Divider, {
627
651
  variant: "small"
628
652
  }),
629
- /* @__PURE__ */ jsx12(ActionsWrapper, {
630
- children: /* @__PURE__ */ jsx12(Button3, {
653
+ /* @__PURE__ */ jsx13(ActionsWrapper, {
654
+ children: /* @__PURE__ */ jsx13(Button3, {
631
655
  color: "secondary",
632
656
  variant: "ghost",
633
657
  disabled: table.getIsAllColumnsVisible(),
@@ -654,7 +678,7 @@ import { Button as Button4, Icon as Icon6, Input, Tooltip } from "@equinor/eds-c
654
678
  import { close as close2 } from "@equinor/eds-icons";
655
679
  import { useEffect, useState as useState3 } from "react";
656
680
  import styled12 from "styled-components";
657
- import { jsx as jsx13 } from "react/jsx-runtime";
681
+ import { jsx as jsx14 } from "react/jsx-runtime";
658
682
  var Wrapper3 = styled12.div`
659
683
  width: 200px;
660
684
  `;
@@ -679,21 +703,21 @@ function DebouncedInput({
679
703
  }, debounce);
680
704
  return () => clearTimeout(timeout);
681
705
  }, [value]);
682
- return /* @__PURE__ */ jsx13(Wrapper3, {
683
- children: /* @__PURE__ */ jsx13(Input, {
706
+ return /* @__PURE__ */ jsx14(Wrapper3, {
707
+ children: /* @__PURE__ */ jsx14(Input, {
684
708
  ...props,
685
709
  value,
686
- leftAdornments: icon && /* @__PURE__ */ jsx13(Icon6, {
710
+ leftAdornments: icon && /* @__PURE__ */ jsx14(Icon6, {
687
711
  name: icon.name,
688
712
  data: icon,
689
713
  size: 18
690
714
  }),
691
- rightAdornments: !!value && /* @__PURE__ */ jsx13(Tooltip, {
715
+ rightAdornments: !!value && /* @__PURE__ */ jsx14(Tooltip, {
692
716
  title: "Clear input",
693
- children: /* @__PURE__ */ jsx13(CloseButton, {
717
+ children: /* @__PURE__ */ jsx14(CloseButton, {
694
718
  variant: "ghost_icon",
695
719
  onClick: () => setValue(""),
696
- children: /* @__PURE__ */ jsx13(Icon6, {
720
+ children: /* @__PURE__ */ jsx14(Icon6, {
697
721
  name: close2.name,
698
722
  data: close2,
699
723
  size: 18
@@ -716,7 +740,7 @@ var fuzzyFilter = (row, columnId, value, addMeta) => {
716
740
  };
717
741
 
718
742
  // src/DataTable/components/DataTableHeader.tsx
719
- import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
743
+ import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
720
744
  var DataTableHeaderWrapper = styled13.div`
721
745
  display: flex;
722
746
  align-items: center;
@@ -736,14 +760,14 @@ var DataTableHeader = (props) => {
736
760
  className: "--table-caption",
737
761
  captionPadding: props.captionPadding,
738
762
  children: [
739
- (props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ jsx14(Typography2, {
763
+ (props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ jsx15(Typography2, {
740
764
  variant: "h3",
741
765
  children: props == null ? void 0 : props.tableCaption
742
766
  }),
743
767
  (props == null ? void 0 : props.enableGlobalFilter) && /* @__PURE__ */ jsxs9(FilterContainer, {
744
768
  className: "--filter-container",
745
769
  children: [
746
- /* @__PURE__ */ jsx14(DebouncedInput, {
770
+ /* @__PURE__ */ jsx15(DebouncedInput, {
747
771
  value: globalFilter,
748
772
  icon: search,
749
773
  placeholder: (props == null ? void 0 : props.globalFilterPlaceholder) ?? "Search all columns",
@@ -758,25 +782,30 @@ var DataTableHeader = (props) => {
758
782
 
759
783
  // src/DataTable/components/VirtualTable.tsx
760
784
  import { Table as Table8 } from "@equinor/eds-core-react";
761
- import { flexRender as flexRender4 } from "@tanstack/react-table";
762
785
  import { useVirtualizer } from "@tanstack/react-virtual";
763
786
 
764
787
  // src/DataTable/components/PaddingRow.tsx
765
788
  import { Table as Table7 } from "@equinor/eds-core-react";
766
- import { jsx as jsx15 } from "react/jsx-runtime";
789
+ import { jsx as jsx16 } from "react/jsx-runtime";
767
790
  var PaddingRow = (props) => {
768
791
  if (!props.height)
769
792
  return null;
770
- return /* @__PURE__ */ jsx15(Table7.Row, {
771
- children: /* @__PURE__ */ jsx15(Table7.Cell, {
793
+ return /* @__PURE__ */ jsx16(Table7.Row, {
794
+ children: /* @__PURE__ */ jsx16(Table7.Cell, {
772
795
  style: { height: `${props.height}px` }
773
796
  })
774
797
  });
775
798
  };
776
799
 
777
800
  // src/DataTable/components/VirtualTable.tsx
778
- import { jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
779
- function VirtualTable({ table, config, containerRef, ...props }) {
801
+ import { jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
802
+ function VirtualTable({
803
+ table,
804
+ rowConfig,
805
+ cellConfig,
806
+ containerRef,
807
+ ...props
808
+ }) {
780
809
  var _a, _b;
781
810
  const { rows } = table.getRowModel();
782
811
  const rowVirtualizer = useVirtualizer({
@@ -789,32 +818,26 @@ function VirtualTable({ table, config, containerRef, ...props }) {
789
818
  const paddingBottom = virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (((_b = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b.end) || 0) : 0;
790
819
  return /* @__PURE__ */ jsxs10(Table8, {
791
820
  children: [
792
- /* @__PURE__ */ jsx16(TableHeader, {
821
+ /* @__PURE__ */ jsx17(TableHeader, {
793
822
  sticky: props.stickyHeader,
794
823
  table
795
824
  }),
796
825
  /* @__PURE__ */ jsxs10(Table8.Body, {
797
826
  children: [
798
- /* @__PURE__ */ jsx16(PaddingRow, {
827
+ /* @__PURE__ */ jsx17(PaddingRow, {
799
828
  height: paddingTop
800
829
  }),
801
830
  rows.length ? virtualRows.map((virtualRow) => {
802
831
  const row = rows[virtualRow.index];
803
- return /* @__PURE__ */ jsx16(Table8.Row, {
804
- active: row.getIsSelected(),
805
- style: { cursor: (config == null ? void 0 : config.onRowClick) ? "pointer" : "initial" },
806
- onClick: () => {
807
- var _a2;
808
- return (_a2 = config == null ? void 0 : config.onRowClick) == null ? void 0 : _a2.call(config, row);
809
- },
810
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx16(Table8.Cell, {
811
- children: flexRender4(cell.column.columnDef.cell, cell.getContext())
812
- }, cell.id))
832
+ return /* @__PURE__ */ jsx17(TableRow, {
833
+ row,
834
+ rowConfig,
835
+ cellConfig
813
836
  }, row.id);
814
- }) : /* @__PURE__ */ jsx16(PlaceholderRow, {
837
+ }) : /* @__PURE__ */ jsx17(PlaceholderRow, {
815
838
  isLoading: props.isLoading
816
839
  }),
817
- /* @__PURE__ */ jsx16(PaddingRow, {
840
+ /* @__PURE__ */ jsx17(PaddingRow, {
818
841
  height: paddingBottom
819
842
  })
820
843
  ]
@@ -824,7 +847,7 @@ function VirtualTable({ table, config, containerRef, ...props }) {
824
847
  }
825
848
 
826
849
  // src/DataTable/DataTable.tsx
827
- import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
850
+ import { jsx as jsx18, jsxs as jsxs11 } from "react/jsx-runtime";
828
851
  var DataTableWrapper = styled14.div`
829
852
  width: ${(props) => props.width ?? "100%"};
830
853
 
@@ -845,7 +868,8 @@ function DataTable({
845
868
  isLoading,
846
869
  header,
847
870
  filters,
848
- config
871
+ config,
872
+ rowConfig
849
873
  }) {
850
874
  const [columnVisibility, setColumnVisibility] = useAtom2(columnVisibilityAtom);
851
875
  const [globalFilter, setGlobalFilter] = useAtom2(globalFilterAtom);
@@ -867,7 +891,7 @@ function DataTable({
867
891
  columnVisibility
868
892
  },
869
893
  defaultColumn: {
870
- cell: (cell) => /* @__PURE__ */ jsx17(TypographyCustom, {
894
+ cell: (cell) => /* @__PURE__ */ jsx18(TypographyCustom, {
871
895
  noWrap: true,
872
896
  children: cell.getValue()
873
897
  })
@@ -900,27 +924,27 @@ function DataTable({
900
924
  height: config == null ? void 0 : config.height,
901
925
  width: config == null ? void 0 : config.width,
902
926
  children: [
903
- /* @__PURE__ */ jsx17(DataTableHeader, {
927
+ /* @__PURE__ */ jsx18(DataTableHeader, {
904
928
  tableCaption: header == null ? void 0 : header.tableCaption,
905
929
  enableGlobalFilter: filters == null ? void 0 : filters.globalFilter,
906
930
  globalFilterPlaceholder: filters == null ? void 0 : filters.globalFilterPlaceholder,
907
931
  captionPadding: header == null ? void 0 : header.captionPadding,
908
- filterActions: /* @__PURE__ */ jsx17(ColumnSelect, {
932
+ filterActions: /* @__PURE__ */ jsx18(ColumnSelect, {
909
933
  table
910
934
  })
911
935
  }),
912
- /* @__PURE__ */ jsx17("div", {
936
+ /* @__PURE__ */ jsx18("div", {
913
937
  ref: tableContainerRef,
914
938
  className: "--table-container",
915
- children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ jsx17(VirtualTable, {
939
+ children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ jsx18(VirtualTable, {
916
940
  containerRef: tableContainerRef,
917
941
  table,
918
- config,
942
+ rowConfig,
919
943
  isLoading,
920
944
  stickyHeader: header == null ? void 0 : header.stickyHeader
921
- }) : /* @__PURE__ */ jsx17(BasicTable, {
945
+ }) : /* @__PURE__ */ jsx18(BasicTable, {
922
946
  table,
923
- config,
947
+ rowConfig,
924
948
  isLoading,
925
949
  stickyHeader: header == null ? void 0 : header.stickyHeader
926
950
  })
@@ -931,9 +955,9 @@ function DataTable({
931
955
 
932
956
  // src/DataTable/Provider.tsx
933
957
  import { Provider } from "jotai";
934
- import { jsx as jsx18 } from "react/jsx-runtime";
958
+ import { jsx as jsx19 } from "react/jsx-runtime";
935
959
  function DataTableProvider({ children, ...props }) {
936
- return /* @__PURE__ */ jsx18(Provider, {
960
+ return /* @__PURE__ */ jsx19(Provider, {
937
961
  ...props,
938
962
  children
939
963
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/apollo-components",
3
- "version": "1.6.1",
3
+ "version": "1.7.0",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",