@equinor/apollo-components 1.8.1 → 1.10.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
@@ -69,9 +69,18 @@ interface CellConfig<T> {
69
69
  getShouldHighlight?: (cell: Cell<T, unknown>) => boolean;
70
70
  }
71
71
  declare type RowSelectionMode = 'single' | 'multiple';
72
+ declare type TableLayout = 'auto' | 'fixed';
72
73
  declare type DataTableConfig<T> = {
73
74
  height?: string;
74
- tableLayout?: 'auto' | 'fixed';
75
+ /**
76
+ * Defaults to `'auto'`.
77
+ *
78
+ * `'auto'` determines column width based on cell content.
79
+ *
80
+ * `'fixed'` uses fixed column width. Specify width (`size` property) in ColumnDef.
81
+ * Default size is 150px.
82
+ */
83
+ tableLayout?: TableLayout;
75
84
  sortable?: boolean;
76
85
  virtual?: boolean;
77
86
  rowSelectionMode?: RowSelectionMode;
@@ -84,10 +93,7 @@ interface ExpansionConfig {
84
93
  expandAllByDefault?: boolean;
85
94
  hideExpandControls?: boolean;
86
95
  }
87
-
88
- interface DataTableProps<T> {
89
- data: T[];
90
- columns: ColumnDef<T, any>[];
96
+ interface DataTableCommonProps<T> {
91
97
  isLoading?: boolean;
92
98
  className?: string;
93
99
  config?: DataTableConfig<T>;
@@ -96,7 +102,15 @@ interface DataTableProps<T> {
96
102
  filters?: FilterConfig;
97
103
  header?: HeaderConfig;
98
104
  }
99
- declare function DataTable$1<T>({ columns, data, isLoading, header, filters, config, cellConfig, rowConfig, }: DataTableProps<T>): JSX.Element;
105
+ interface DataTableProps<T> extends DataTableCommonProps<T> {
106
+ data: T[];
107
+ columns: ColumnDef<T, any>[];
108
+ }
109
+ interface DataTableRawProps<T> extends DataTableCommonProps<T> {
110
+ table: Table<T>;
111
+ }
112
+
113
+ declare function DataTable$1<T>(props: DataTableProps<T>): JSX.Element;
100
114
 
101
115
  declare type DataTableProviderProps = ComponentProps<typeof Provider>;
102
116
  declare function DataTableProvider({ children, ...props }: DataTableProviderProps): JSX.Element;
@@ -138,7 +152,7 @@ declare type DataTableCompoundProps = typeof DataTable$1 & {
138
152
  };
139
153
  declare const DataTable: DataTableCompoundProps;
140
154
 
141
- declare function SelectColumnDef<T>(selectionMode?: RowSelectionMode): ColumnDef$1<T, any>;
155
+ declare function SelectColumnDef<T>(props?: DataTableConfig<T>): ColumnDef$1<T, any>;
142
156
 
143
157
  declare const StickyCell: styled_components.StyledComponent<react.ForwardRefExoticComponent<CellProps & react.RefAttributes<HTMLTableCellElement>>, any, {} & CellProps, never>;
144
158
 
@@ -153,4 +167,4 @@ declare type TypographyProps = {
153
167
  */
154
168
  declare const TypographyCustom: (props: TypographyProps) => JSX.Element;
155
169
 
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 };
170
+ export { AppShell, AppSidebar, CellConfig, ChipsCell, ColumnSelect, DataTable, DataTableCommonProps, DataTableConfig, DataTableProps, DataTableRawProps, DynamicCell, FilterConfig, HeaderConfig, HierarchyCell, RowConfig, RowSelectionMode, SelectColumnDef, StickyCell, TableHeader, TableLayout, TableRowWrapper, TableRowWrapperProps, TypographyCustom, capitalizeHeader, globalFilterAtom, prependSelectColumn, rowSelectionAtom, tableSortingAtom };
package/dist/index.js CHANGED
@@ -61,6 +61,7 @@ var Wrapper = import_styled_components.default.div`
61
61
  }
62
62
  .--content-outlet {
63
63
  flex: 1;
64
+ max-width: 100%;
64
65
  }
65
66
  `;
66
67
  var AppShell = ({ children, icon, title, sidebar }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Wrapper, {
@@ -172,7 +173,10 @@ var import_jsx_runtime3 = require("react/jsx-runtime");
172
173
  var ChipsWrapper = import_styled_components3.default.div`
173
174
  display: flex;
174
175
  align-items: center;
176
+ flex-wrap: wrap;
175
177
  gap: 0.25rem;
178
+ padding-top: 0.25rem;
179
+ padding-bottom: 0.25rem;
176
180
  `;
177
181
  var Chip = import_styled_components3.default.div`
178
182
  border-radius: 25px;
@@ -226,10 +230,10 @@ var StickyHeaderCell = (0, import_styled_components4.default)(StickyCell)`
226
230
  // src/cells/DynamicCell.tsx
227
231
  var import_jsx_runtime4 = require("react/jsx-runtime");
228
232
  var StyledStickyCell = (0, import_styled_components5.default)(StickyCell)`
229
- ${(props) => props.backgroundColor ? `background-color: ${props.backgroundColor} !important;` : ``}
233
+ background-color: ${({ backgroundColor: bg }) => bg ? `${bg} !important` : `inherit`};
230
234
  `;
231
235
  var StyledCell = (0, import_styled_components5.default)(import_eds_core_react4.Table.Cell)`
232
- ${(props) => props.backgroundColor ? `background-color: ${props.backgroundColor} !important;` : ``}
236
+ ${({ backgroundColor: bg }) => bg ? `background-color: ${bg} !important;` : ``};
233
237
  `;
234
238
  function DynamicCell({ cell, highlight, getStickyCellColor }) {
235
239
  var _a;
@@ -358,9 +362,12 @@ var CellWrapper2 = import_styled_components8.default.div`
358
362
  margin-left: -16px;
359
363
  z-index: 2;
360
364
  `;
361
- function SelectColumnDef(selectionMode) {
365
+ function SelectColumnDef(props = {}) {
366
+ const selectionMode = props.rowSelectionMode;
367
+ const showBothSelectAndSubRowsToggle = props.hideExpandControls === false;
362
368
  return {
363
369
  id: "select",
370
+ size: showBothSelectAndSubRowsToggle ? 96 : 48,
364
371
  header: ({ table }) => selectionMode !== "single" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CellWrapper2, {
365
372
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Checkbox, {
366
373
  checked: table.getIsAllRowsSelected(),
@@ -403,22 +410,12 @@ function SelectColumnDef(selectionMode) {
403
410
  };
404
411
  }
405
412
 
406
- // src/DataTable/DataTable.tsx
407
- var import_react_table3 = require("@tanstack/react-table");
408
- var import_jotai3 = require("jotai");
413
+ // src/DataTable/DataTableRaw.tsx
409
414
  var import_react4 = require("react");
410
- var import_styled_components14 = __toESM(require("styled-components"));
411
-
412
- // src/DataTable/atoms.ts
413
- var import_jotai = require("jotai");
414
- var columnVisibilityAtom = (0, import_jotai.atom)({});
415
- var globalFilterAtom = (0, import_jotai.atom)("");
416
- var rowSelectionAtom = (0, import_jotai.atom)({});
417
- var tableSortingAtom = (0, import_jotai.atom)([]);
418
- var expandedRowsAtom = (0, import_jotai.atom)({});
415
+ var import_styled_components16 = __toESM(require("styled-components"));
419
416
 
420
417
  // src/DataTable/components/BasicTable.tsx
421
- var import_eds_core_react11 = require("@equinor/eds-core-react");
418
+ var import_eds_core_react12 = require("@equinor/eds-core-react");
422
419
 
423
420
  // src/DataTable/components/PlaceholderRow.tsx
424
421
  var import_eds_core_react7 = require("@equinor/eds-core-react");
@@ -443,16 +440,25 @@ function PlaceholderRow({ isLoading }) {
443
440
  });
444
441
  }
445
442
 
443
+ // src/DataTable/components/TableBody.tsx
444
+ var import_eds_core_react8 = require("@equinor/eds-core-react");
445
+ var import_styled_components10 = __toESM(require("styled-components"));
446
+ var TableBody = (0, import_styled_components10.default)(import_eds_core_react8.Table.Body)`
447
+ // The following attribute are important for fixed column width
448
+ // CHANGE THES WITH CAUTION
449
+ background: inherit;
450
+ `;
451
+
446
452
  // src/DataTable/components/TableHeader.tsx
447
- var import_eds_core_react9 = require("@equinor/eds-core-react");
453
+ var import_eds_core_react10 = require("@equinor/eds-core-react");
448
454
 
449
455
  // src/cells/HeaderCell.tsx
450
- var import_eds_core_react8 = require("@equinor/eds-core-react");
456
+ var import_eds_core_react9 = require("@equinor/eds-core-react");
451
457
  var import_eds_icons4 = require("@equinor/eds-icons");
452
458
  var import_react_table2 = require("@tanstack/react-table");
453
- var import_styled_components10 = __toESM(require("styled-components"));
459
+ var import_styled_components11 = __toESM(require("styled-components"));
454
460
  var import_jsx_runtime9 = require("react/jsx-runtime");
455
- var HeaderDiv = import_styled_components10.default.div`
461
+ var HeaderDiv = import_styled_components11.default.div`
456
462
  display: flex;
457
463
  align-items: center;
458
464
  gap: 0.25rem;
@@ -461,7 +467,7 @@ var HeaderDiv = import_styled_components10.default.div`
461
467
  var HeaderCell = ({ header }) => {
462
468
  var _a;
463
469
  const style = {
464
- width: header.column.getSize() === -1 ? "auto" : header.column.getSize()
470
+ width: header.column.getSize()
465
471
  };
466
472
  const cellProps = {
467
473
  style,
@@ -469,14 +475,15 @@ var HeaderCell = ({ header }) => {
469
475
  onClick: header.column.getToggleSortingHandler(),
470
476
  colSpan: header.colSpan
471
477
  };
472
- if ((_a = header.column.columnDef.meta) == null ? void 0 : _a.sticky)
478
+ if ((_a = header.column.columnDef.meta) == null ? void 0 : _a.sticky) {
473
479
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StickyHeaderCell, {
474
480
  ...cellProps,
475
481
  children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HeaderContent, {
476
482
  header
477
483
  })
478
484
  }, header.id);
479
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Table.Cell, {
485
+ }
486
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react9.Table.Cell, {
480
487
  ...cellProps,
481
488
  children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HeaderContent, {
482
489
  header
@@ -490,13 +497,13 @@ function HeaderContent({ header }) {
490
497
  children: [
491
498
  (0, import_react_table2.flexRender)(header.column.columnDef.header, header.getContext()),
492
499
  {
493
- asc: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Icon, {
500
+ asc: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react9.Icon, {
494
501
  data: import_eds_icons4.arrow_drop_up
495
502
  }),
496
- desc: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Icon, {
503
+ desc: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react9.Icon, {
497
504
  data: import_eds_icons4.arrow_drop_down
498
505
  }),
499
- none: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Icon, {
506
+ none: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react9.Icon, {
500
507
  data: import_eds_icons4.arrow_drop_down
501
508
  })
502
509
  }[header.column.getIsSorted()] ?? null
@@ -519,9 +526,9 @@ function getSort({ column }) {
519
526
  // src/DataTable/components/TableHeader.tsx
520
527
  var import_jsx_runtime10 = require("react/jsx-runtime");
521
528
  function TableHeader({ table, sticky }) {
522
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_eds_core_react9.Table.Head, {
529
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_eds_core_react10.Table.Head, {
523
530
  sticky,
524
- children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_eds_core_react9.Table.Row, {
531
+ children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_eds_core_react10.Table.Row, {
525
532
  children: headerGroup.headers.map((header) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(HeaderCell, {
526
533
  header
527
534
  }, header.id))
@@ -530,12 +537,13 @@ function TableHeader({ table, sticky }) {
530
537
  }
531
538
 
532
539
  // src/DataTable/components/TableRow.tsx
533
- var import_eds_core_react10 = require("@equinor/eds-core-react");
540
+ var import_eds_core_react11 = require("@equinor/eds-core-react");
541
+ var import_styled_components12 = __toESM(require("styled-components"));
534
542
  var import_jsx_runtime11 = require("react/jsx-runtime");
535
543
  function TableRow({ row, rowConfig, cellConfig }) {
536
544
  var _a;
537
545
  const rowWrapper = rowConfig == null ? void 0 : rowConfig.rowWrapper;
538
- const tableRowContent = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_eds_core_react10.Table.Row, {
546
+ const tableRowContent = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(StyledTableRow, {
539
547
  active: row.getIsSelected(),
540
548
  style: {
541
549
  cursor: (rowConfig == null ? void 0 : rowConfig.onClick) ? "pointer" : "initial",
@@ -558,6 +566,10 @@ function TableRow({ row, rowConfig, cellConfig }) {
558
566
  });
559
567
  return rowWrapper ? rowWrapper({ row, children: tableRowContent }) : tableRowContent;
560
568
  }
569
+ var StyledTableRow = (0, import_styled_components12.default)(import_eds_core_react11.Table.Row)`
570
+ /* Background color must be inherited here. Does not work with inline styling */
571
+ background-color: inherit;
572
+ `;
561
573
  function handleRowEvent(row, handler) {
562
574
  if (!handler)
563
575
  return void 0;
@@ -576,13 +588,13 @@ function BasicTable({
576
588
  isLoading
577
589
  }) {
578
590
  const tableRows = table.getRowModel().rows;
579
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_eds_core_react11.Table, {
591
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_eds_core_react12.Table, {
580
592
  children: [
581
593
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TableHeader, {
582
594
  sticky: stickyHeader,
583
595
  table
584
596
  }),
585
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Table.Body, {
597
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TableBody, {
586
598
  children: tableRows.length ? tableRows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TableRow, {
587
599
  row,
588
600
  rowConfig,
@@ -596,21 +608,29 @@ function BasicTable({
596
608
  }
597
609
 
598
610
  // src/DataTable/components/DataTableHeader.tsx
599
- var import_eds_core_react14 = require("@equinor/eds-core-react");
611
+ var import_eds_core_react15 = require("@equinor/eds-core-react");
600
612
  var import_eds_icons7 = require("@equinor/eds-icons");
601
613
  var import_jotai2 = require("jotai");
602
- var import_styled_components13 = __toESM(require("styled-components"));
614
+ var import_styled_components15 = __toESM(require("styled-components"));
615
+
616
+ // src/DataTable/atoms.ts
617
+ var import_jotai = require("jotai");
618
+ var columnVisibilityAtom = (0, import_jotai.atom)({});
619
+ var globalFilterAtom = (0, import_jotai.atom)("");
620
+ var rowSelectionAtom = (0, import_jotai.atom)({});
621
+ var tableSortingAtom = (0, import_jotai.atom)([]);
622
+ var expandedRowsAtom = (0, import_jotai.atom)({});
603
623
 
604
624
  // src/DataTable/filters/DebouncedInput.tsx
605
- var import_eds_core_react12 = require("@equinor/eds-core-react");
625
+ var import_eds_core_react13 = require("@equinor/eds-core-react");
606
626
  var import_eds_icons5 = require("@equinor/eds-icons");
607
627
  var import_react2 = require("react");
608
- var import_styled_components11 = __toESM(require("styled-components"));
628
+ var import_styled_components13 = __toESM(require("styled-components"));
609
629
  var import_jsx_runtime13 = require("react/jsx-runtime");
610
- var Wrapper3 = import_styled_components11.default.div`
630
+ var Wrapper3 = import_styled_components13.default.div`
611
631
  width: 200px;
612
632
  `;
613
- var CloseButton = (0, import_styled_components11.default)(import_eds_core_react12.Button)`
633
+ var CloseButton = (0, import_styled_components13.default)(import_eds_core_react13.Button)`
614
634
  width: 24px;
615
635
  height: 24px;
616
636
  `;
@@ -632,20 +652,20 @@ function DebouncedInput({
632
652
  return () => clearTimeout(timeout);
633
653
  }, [value]);
634
654
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Wrapper3, {
635
- children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Input, {
655
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react13.Input, {
636
656
  ...props,
637
657
  value,
638
- leftAdornments: icon && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Icon, {
658
+ leftAdornments: icon && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react13.Icon, {
639
659
  name: icon.name,
640
660
  data: icon,
641
661
  size: 18
642
662
  }),
643
- rightAdornments: !!value && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Tooltip, {
663
+ rightAdornments: !!value && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react13.Tooltip, {
644
664
  title: "Clear input",
645
665
  children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CloseButton, {
646
666
  variant: "ghost_icon",
647
667
  onClick: () => setValue(""),
648
- children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Icon, {
668
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react13.Icon, {
649
669
  name: import_eds_icons5.close.name,
650
670
  data: import_eds_icons5.close,
651
671
  size: 18
@@ -668,10 +688,10 @@ var fuzzyFilter = (row, columnId, value, addMeta) => {
668
688
  };
669
689
 
670
690
  // src/DataTable/components/ColumnSelect.tsx
671
- var import_eds_core_react13 = require("@equinor/eds-core-react");
691
+ var import_eds_core_react14 = require("@equinor/eds-core-react");
672
692
  var import_eds_icons6 = require("@equinor/eds-icons");
673
693
  var import_react3 = require("react");
674
- var import_styled_components12 = __toESM(require("styled-components"));
694
+ var import_styled_components14 = __toESM(require("styled-components"));
675
695
 
676
696
  // src/DataTable/utils.tsx
677
697
  function capitalizeHeader(context) {
@@ -691,18 +711,18 @@ function prependSelectColumn(columns, config) {
691
711
  if (!(config == null ? void 0 : config.selectColumn))
692
712
  return columns;
693
713
  if (config.selectColumn === "default")
694
- return [SelectColumnDef(config == null ? void 0 : config.rowSelectionMode), ...columns];
714
+ return [SelectColumnDef(config), ...columns];
695
715
  return [config.selectColumn(), ...columns];
696
716
  }
697
717
 
698
718
  // src/DataTable/components/ColumnSelect.tsx
699
719
  var import_jsx_runtime14 = require("react/jsx-runtime");
700
- var ColumnSelectContent = import_styled_components12.default.div`
720
+ var ColumnSelectContent = import_styled_components14.default.div`
701
721
  display: grid;
702
722
  grid-template-columns: repeat(2, 1fr);
703
723
  grid-gap: 0.5rem;
704
724
  `;
705
- var ActionsWrapper = import_styled_components12.default.div`
725
+ var ActionsWrapper = import_styled_components14.default.div`
706
726
  display: flex;
707
727
  align-items: center;
708
728
  justify-content: flex-end;
@@ -714,7 +734,7 @@ function ColumnSelect({ table }) {
714
734
  const selectableColumns = table.getAllLeafColumns().filter((column) => column.id !== "select");
715
735
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, {
716
736
  children: [
717
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Button, {
737
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react14.Button, {
718
738
  "aria-haspopup": true,
719
739
  id: "column-select-anchor",
720
740
  "aria-controls": "column-select-popover",
@@ -722,28 +742,28 @@ function ColumnSelect({ table }) {
722
742
  ref: referenceElement,
723
743
  variant: "ghost_icon",
724
744
  onClick: () => setIsOpen(true),
725
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Icon, {
745
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react14.Icon, {
726
746
  name: "view_column",
727
747
  data: import_eds_icons6.view_column
728
748
  })
729
749
  }),
730
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_eds_core_react13.Popover, {
750
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_eds_core_react14.Popover, {
731
751
  open: isOpen,
732
752
  id: "column-select-popover",
733
753
  anchorEl: referenceElement.current,
734
754
  placement: "bottom-end",
735
755
  onClose: () => setIsOpen(false),
736
756
  children: [
737
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_eds_core_react13.Popover.Header, {
757
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_eds_core_react14.Popover.Header, {
738
758
  children: [
739
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Popover.Title, {
759
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react14.Popover.Title, {
740
760
  children: "Column settings"
741
761
  }),
742
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Button, {
762
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react14.Button, {
743
763
  variant: "ghost_icon",
744
764
  "aria-label": "Close column select",
745
765
  onClick: () => setIsOpen(false),
746
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Icon, {
766
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react14.Icon, {
747
767
  name: "close",
748
768
  data: import_eds_icons6.close,
749
769
  size: 24
@@ -751,22 +771,22 @@ function ColumnSelect({ table }) {
751
771
  })
752
772
  ]
753
773
  }),
754
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_eds_core_react13.Popover.Content, {
774
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_eds_core_react14.Popover.Content, {
755
775
  children: [
756
776
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ColumnSelectContent, {
757
777
  children: selectableColumns.map((column) => {
758
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Checkbox, {
778
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react14.Checkbox, {
759
779
  checked: column.getIsVisible(),
760
780
  label: getColumnHeader(column),
761
781
  onChange: column.getToggleVisibilityHandler()
762
782
  }, column.id);
763
783
  })
764
784
  }),
765
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Divider, {
785
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react14.Divider, {
766
786
  variant: "small"
767
787
  }),
768
788
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ActionsWrapper, {
769
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react13.Button, {
789
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_eds_core_react14.Button, {
770
790
  color: "secondary",
771
791
  variant: "ghost",
772
792
  disabled: table.getIsAllColumnsVisible(),
@@ -784,14 +804,14 @@ function ColumnSelect({ table }) {
784
804
 
785
805
  // src/DataTable/components/DataTableHeader.tsx
786
806
  var import_jsx_runtime15 = require("react/jsx-runtime");
787
- var DataTableHeaderWrapper = import_styled_components13.default.div`
807
+ var DataTableHeaderWrapper = import_styled_components15.default.div`
788
808
  display: flex;
789
809
  align-items: center;
790
810
  justify-content: space-between;
791
811
  gap: 0.5rem;
792
812
  padding: ${(props) => props.captionPadding ?? "1rem"};
793
813
  `;
794
- var FilterContainer = import_styled_components13.default.div`
814
+ var FilterContainer = import_styled_components15.default.div`
795
815
  display: flex;
796
816
  align-items: center;
797
817
  gap: 1rem;
@@ -804,7 +824,7 @@ function DataTableHeader({ config, table, ...props }) {
804
824
  className: "--table-caption",
805
825
  captionPadding: props.captionPadding,
806
826
  children: [
807
- (props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_eds_core_react14.Typography, {
827
+ (props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_eds_core_react15.Typography, {
808
828
  variant: "h3",
809
829
  children: props == null ? void 0 : props.tableCaption
810
830
  }),
@@ -830,17 +850,17 @@ function DataTableHeader({ config, table, ...props }) {
830
850
  }
831
851
 
832
852
  // src/DataTable/components/VirtualTable.tsx
833
- var import_eds_core_react16 = require("@equinor/eds-core-react");
853
+ var import_eds_core_react17 = require("@equinor/eds-core-react");
834
854
  var import_react_virtual = require("@tanstack/react-virtual");
835
855
 
836
856
  // src/DataTable/components/PaddingRow.tsx
837
- var import_eds_core_react15 = require("@equinor/eds-core-react");
857
+ var import_eds_core_react16 = require("@equinor/eds-core-react");
838
858
  var import_jsx_runtime16 = require("react/jsx-runtime");
839
859
  var PaddingRow = (props) => {
840
860
  if (!props.height)
841
861
  return null;
842
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_eds_core_react15.Table.Row, {
843
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_eds_core_react15.Table.Cell, {
862
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_eds_core_react16.Table.Row, {
863
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_eds_core_react16.Table.Cell, {
844
864
  style: { height: `${props.height}px` }
845
865
  })
846
866
  });
@@ -865,13 +885,13 @@ function VirtualTable({
865
885
  const virtualRows = rowVirtualizer.getVirtualItems();
866
886
  const paddingTop = virtualRows.length > 0 ? ((_a = virtualRows == null ? void 0 : virtualRows[0]) == null ? void 0 : _a.start) || 0 : 0;
867
887
  const paddingBottom = virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (((_b = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b.end) || 0) : 0;
868
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_eds_core_react16.Table, {
888
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_eds_core_react17.Table, {
869
889
  children: [
870
890
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TableHeader, {
871
891
  sticky: props.stickyHeader,
872
892
  table
873
893
  }),
874
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_eds_core_react16.Table.Body, {
894
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(TableBody, {
875
895
  children: [
876
896
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PaddingRow, {
877
897
  height: paddingTop
@@ -895,9 +915,9 @@ function VirtualTable({
895
915
  });
896
916
  }
897
917
 
898
- // src/DataTable/DataTable.tsx
918
+ // src/DataTable/DataTableRaw.tsx
899
919
  var import_jsx_runtime18 = require("react/jsx-runtime");
900
- var DataTableWrapper = import_styled_components14.default.div`
920
+ var DataTableWrapper = import_styled_components16.default.div`
901
921
  width: ${(props) => props.width ?? "100%"};
902
922
 
903
923
  .--table-container {
@@ -906,23 +926,57 @@ var DataTableWrapper = import_styled_components14.default.div`
906
926
  overflow: auto;
907
927
 
908
928
  table {
909
- width: ${(props) => props.width ?? "100%"};
910
- height: ${(props) => props.height ?? "100%"};
911
- table-layout: ${(props) => props.tableLayout ?? "fixed"};
912
- border-collapse: collapse;
929
+ width: 100%;
930
+
931
+ // The following attributes are important for fixed column width
932
+ // CHANGE THES WITH CAUTION
933
+ overflow: auto;
934
+ table-layout: ${(props) => props.tableLayout ?? "auto"};
913
935
  }
914
936
  }
915
937
  `;
916
- function DataTable({
917
- columns,
918
- data,
919
- isLoading,
920
- header,
921
- filters,
922
- config,
923
- cellConfig,
924
- rowConfig
925
- }) {
938
+ function DataTableRaw(props) {
939
+ const { isLoading, header, filters, config, rowConfig, table } = props;
940
+ const tableContainerRef = (0, import_react4.useRef)(null);
941
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DataTableWrapper, {
942
+ captionPadding: header == null ? void 0 : header.captionPadding,
943
+ height: config == null ? void 0 : config.height,
944
+ width: config == null ? void 0 : config.width,
945
+ tableLayout: config == null ? void 0 : config.tableLayout,
946
+ children: [
947
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DataTableHeader, {
948
+ tableCaption: header == null ? void 0 : header.tableCaption,
949
+ captionPadding: header == null ? void 0 : header.captionPadding,
950
+ table,
951
+ config: filters
952
+ }),
953
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", {
954
+ ref: tableContainerRef,
955
+ className: "--table-container",
956
+ children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(VirtualTable, {
957
+ containerRef: tableContainerRef,
958
+ table,
959
+ rowConfig,
960
+ isLoading,
961
+ stickyHeader: header == null ? void 0 : header.stickyHeader
962
+ }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(BasicTable, {
963
+ table,
964
+ rowConfig,
965
+ isLoading,
966
+ stickyHeader: header == null ? void 0 : header.stickyHeader
967
+ })
968
+ })
969
+ ]
970
+ });
971
+ }
972
+
973
+ // src/DataTable/useDataTable.tsx
974
+ var import_react_table3 = require("@tanstack/react-table");
975
+ var import_jotai3 = require("jotai");
976
+ var import_react5 = require("react");
977
+ var import_jsx_runtime19 = require("react/jsx-runtime");
978
+ function useDataTable(props) {
979
+ const { columns, data, filters, config, meta } = props;
926
980
  const [columnVisibility, setColumnVisibility] = (0, import_jotai3.useAtom)(columnVisibilityAtom);
927
981
  const [globalFilter, setGlobalFilter] = (0, import_jotai3.useAtom)(globalFilterAtom);
928
982
  const [sorting, setSorting] = (0, import_jotai3.useAtom)(tableSortingAtom);
@@ -943,11 +997,12 @@ function DataTable({
943
997
  columnVisibility
944
998
  },
945
999
  defaultColumn: {
946
- cell: (cell) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TypographyCustom, {
1000
+ cell: (cell) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TypographyCustom, {
947
1001
  noWrap: true,
948
1002
  children: cell.getValue()
949
1003
  })
950
1004
  },
1005
+ meta,
951
1006
  enableSorting: config == null ? void 0 : config.sortable,
952
1007
  enableExpanding: !(config == null ? void 0 : config.hideExpandControls),
953
1008
  enableMultiRowSelection: (config == null ? void 0 : config.rowSelectionMode) === "multiple",
@@ -965,50 +1020,29 @@ function DataTable({
965
1020
  getSubRows: config == null ? void 0 : config.getSubRows,
966
1021
  getRowId: config == null ? void 0 : config.getRowId
967
1022
  });
968
- (0, import_react4.useEffect)(() => {
1023
+ (0, import_react5.useEffect)(() => {
969
1024
  if (config && config.expandAllByDefault) {
970
1025
  table.toggleAllRowsExpanded();
971
1026
  }
972
1027
  }, [table, config == null ? void 0 : config.expandAllByDefault]);
973
- const tableContainerRef = (0, import_react4.useRef)(null);
974
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DataTableWrapper, {
975
- height: config == null ? void 0 : config.height,
976
- width: config == null ? void 0 : config.width,
977
- tableLayout: config == null ? void 0 : config.tableLayout,
978
- children: [
979
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DataTableHeader, {
980
- tableCaption: header == null ? void 0 : header.tableCaption,
981
- captionPadding: header == null ? void 0 : header.captionPadding,
982
- table,
983
- config: filters
984
- }),
985
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", {
986
- ref: tableContainerRef,
987
- className: "--table-container",
988
- children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(VirtualTable, {
989
- containerRef: tableContainerRef,
990
- table,
991
- rowConfig,
992
- cellConfig,
993
- isLoading,
994
- stickyHeader: header == null ? void 0 : header.stickyHeader
995
- }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(BasicTable, {
996
- table,
997
- rowConfig,
998
- cellConfig,
999
- isLoading,
1000
- stickyHeader: header == null ? void 0 : header.stickyHeader
1001
- })
1002
- })
1003
- ]
1028
+ return table;
1029
+ }
1030
+
1031
+ // src/DataTable/DataTable.tsx
1032
+ var import_jsx_runtime20 = require("react/jsx-runtime");
1033
+ function DataTable(props) {
1034
+ const table = useDataTable(props);
1035
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(DataTableRaw, {
1036
+ table,
1037
+ ...props
1004
1038
  });
1005
1039
  }
1006
1040
 
1007
1041
  // src/DataTable/Provider.tsx
1008
1042
  var import_jotai4 = require("jotai");
1009
- var import_jsx_runtime19 = require("react/jsx-runtime");
1043
+ var import_jsx_runtime21 = require("react/jsx-runtime");
1010
1044
  function DataTableProvider({ children, ...props }) {
1011
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jotai4.Provider, {
1045
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jotai4.Provider, {
1012
1046
  ...props,
1013
1047
  children
1014
1048
  });
package/dist/index.mjs CHANGED
@@ -14,6 +14,7 @@ var Wrapper = styled.div`
14
14
  }
15
15
  .--content-outlet {
16
16
  flex: 1;
17
+ max-width: 100%;
17
18
  }
18
19
  `;
19
20
  var AppShell = ({ children, icon, title, sidebar }) => /* @__PURE__ */ jsxs(Wrapper, {
@@ -125,7 +126,10 @@ import { jsx as jsx3 } from "react/jsx-runtime";
125
126
  var ChipsWrapper = styled3.div`
126
127
  display: flex;
127
128
  align-items: center;
129
+ flex-wrap: wrap;
128
130
  gap: 0.25rem;
131
+ padding-top: 0.25rem;
132
+ padding-bottom: 0.25rem;
129
133
  `;
130
134
  var Chip = styled3.div`
131
135
  border-radius: 25px;
@@ -179,10 +183,10 @@ var StickyHeaderCell = styled4(StickyCell)`
179
183
  // src/cells/DynamicCell.tsx
180
184
  import { jsx as jsx4 } from "react/jsx-runtime";
181
185
  var StyledStickyCell = styled5(StickyCell)`
182
- ${(props) => props.backgroundColor ? `background-color: ${props.backgroundColor} !important;` : ``}
186
+ background-color: ${({ backgroundColor: bg }) => bg ? `${bg} !important` : `inherit`};
183
187
  `;
184
188
  var StyledCell = styled5(Table2.Cell)`
185
- ${(props) => props.backgroundColor ? `background-color: ${props.backgroundColor} !important;` : ``}
189
+ ${({ backgroundColor: bg }) => bg ? `background-color: ${bg} !important;` : ``};
186
190
  `;
187
191
  function DynamicCell({ cell, highlight, getStickyCellColor }) {
188
192
  var _a;
@@ -313,9 +317,12 @@ var CellWrapper2 = styled8.div`
313
317
  margin-left: -16px;
314
318
  z-index: 2;
315
319
  `;
316
- function SelectColumnDef(selectionMode) {
320
+ function SelectColumnDef(props = {}) {
321
+ const selectionMode = props.rowSelectionMode;
322
+ const showBothSelectAndSubRowsToggle = props.hideExpandControls === false;
317
323
  return {
318
324
  id: "select",
325
+ size: showBothSelectAndSubRowsToggle ? 96 : 48,
319
326
  header: ({ table }) => selectionMode !== "single" ? /* @__PURE__ */ jsx7(CellWrapper2, {
320
327
  children: /* @__PURE__ */ jsx7(Checkbox, {
321
328
  checked: table.getIsAllRowsSelected(),
@@ -358,25 +365,9 @@ function SelectColumnDef(selectionMode) {
358
365
  };
359
366
  }
360
367
 
361
- // src/DataTable/DataTable.tsx
362
- import {
363
- getCoreRowModel,
364
- getExpandedRowModel,
365
- getFilteredRowModel,
366
- getSortedRowModel,
367
- useReactTable
368
- } from "@tanstack/react-table";
369
- import { useAtom as useAtom2 } from "jotai";
370
- import { useEffect as useEffect2, useRef as useRef2 } from "react";
371
- import styled14 from "styled-components";
372
-
373
- // src/DataTable/atoms.ts
374
- import { atom } from "jotai";
375
- var columnVisibilityAtom = atom({});
376
- var globalFilterAtom = atom("");
377
- var rowSelectionAtom = atom({});
378
- var tableSortingAtom = atom([]);
379
- var expandedRowsAtom = atom({});
368
+ // src/DataTable/DataTableRaw.tsx
369
+ import { useRef as useRef2 } from "react";
370
+ import styled16 from "styled-components";
380
371
 
381
372
  // src/DataTable/components/BasicTable.tsx
382
373
  import { Table as EdsTable } from "@equinor/eds-core-react";
@@ -404,16 +395,25 @@ function PlaceholderRow({ isLoading }) {
404
395
  });
405
396
  }
406
397
 
398
+ // src/DataTable/components/TableBody.tsx
399
+ import { Table as Table4 } from "@equinor/eds-core-react";
400
+ import styled10 from "styled-components";
401
+ var TableBody = styled10(Table4.Body)`
402
+ // The following attribute are important for fixed column width
403
+ // CHANGE THES WITH CAUTION
404
+ background: inherit;
405
+ `;
406
+
407
407
  // src/DataTable/components/TableHeader.tsx
408
- import { Table as Table5 } from "@equinor/eds-core-react";
408
+ import { Table as Table6 } from "@equinor/eds-core-react";
409
409
 
410
410
  // src/cells/HeaderCell.tsx
411
- import { Icon as Icon4, Table as Table4 } from "@equinor/eds-core-react";
411
+ import { Icon as Icon4, Table as Table5 } from "@equinor/eds-core-react";
412
412
  import { arrow_drop_down, arrow_drop_up } from "@equinor/eds-icons";
413
413
  import { flexRender as flexRender2 } from "@tanstack/react-table";
414
- import styled10 from "styled-components";
414
+ import styled11 from "styled-components";
415
415
  import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
416
- var HeaderDiv = styled10.div`
416
+ var HeaderDiv = styled11.div`
417
417
  display: flex;
418
418
  align-items: center;
419
419
  gap: 0.25rem;
@@ -422,7 +422,7 @@ var HeaderDiv = styled10.div`
422
422
  var HeaderCell = ({ header }) => {
423
423
  var _a;
424
424
  const style = {
425
- width: header.column.getSize() === -1 ? "auto" : header.column.getSize()
425
+ width: header.column.getSize()
426
426
  };
427
427
  const cellProps = {
428
428
  style,
@@ -430,14 +430,15 @@ var HeaderCell = ({ header }) => {
430
430
  onClick: header.column.getToggleSortingHandler(),
431
431
  colSpan: header.colSpan
432
432
  };
433
- if ((_a = header.column.columnDef.meta) == null ? void 0 : _a.sticky)
433
+ if ((_a = header.column.columnDef.meta) == null ? void 0 : _a.sticky) {
434
434
  return /* @__PURE__ */ jsx9(StickyHeaderCell, {
435
435
  ...cellProps,
436
436
  children: /* @__PURE__ */ jsx9(HeaderContent, {
437
437
  header
438
438
  })
439
439
  }, header.id);
440
- return /* @__PURE__ */ jsx9(Table4.Cell, {
440
+ }
441
+ return /* @__PURE__ */ jsx9(Table5.Cell, {
441
442
  ...cellProps,
442
443
  children: /* @__PURE__ */ jsx9(HeaderContent, {
443
444
  header
@@ -480,9 +481,9 @@ function getSort({ column }) {
480
481
  // src/DataTable/components/TableHeader.tsx
481
482
  import { jsx as jsx10 } from "react/jsx-runtime";
482
483
  function TableHeader({ table, sticky }) {
483
- return /* @__PURE__ */ jsx10(Table5.Head, {
484
+ return /* @__PURE__ */ jsx10(Table6.Head, {
484
485
  sticky,
485
- children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx10(Table5.Row, {
486
+ children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx10(Table6.Row, {
486
487
  children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx10(HeaderCell, {
487
488
  header
488
489
  }, header.id))
@@ -491,12 +492,13 @@ function TableHeader({ table, sticky }) {
491
492
  }
492
493
 
493
494
  // src/DataTable/components/TableRow.tsx
494
- import { Table as Table6 } from "@equinor/eds-core-react";
495
+ import { Table as Table7 } from "@equinor/eds-core-react";
496
+ import styled12 from "styled-components";
495
497
  import { jsx as jsx11 } from "react/jsx-runtime";
496
498
  function TableRow({ row, rowConfig, cellConfig }) {
497
499
  var _a;
498
500
  const rowWrapper = rowConfig == null ? void 0 : rowConfig.rowWrapper;
499
- const tableRowContent = /* @__PURE__ */ jsx11(Table6.Row, {
501
+ const tableRowContent = /* @__PURE__ */ jsx11(StyledTableRow, {
500
502
  active: row.getIsSelected(),
501
503
  style: {
502
504
  cursor: (rowConfig == null ? void 0 : rowConfig.onClick) ? "pointer" : "initial",
@@ -519,6 +521,10 @@ function TableRow({ row, rowConfig, cellConfig }) {
519
521
  });
520
522
  return rowWrapper ? rowWrapper({ row, children: tableRowContent }) : tableRowContent;
521
523
  }
524
+ var StyledTableRow = styled12(Table7.Row)`
525
+ /* Background color must be inherited here. Does not work with inline styling */
526
+ background-color: inherit;
527
+ `;
522
528
  function handleRowEvent(row, handler) {
523
529
  if (!handler)
524
530
  return void 0;
@@ -543,7 +549,7 @@ function BasicTable({
543
549
  sticky: stickyHeader,
544
550
  table
545
551
  }),
546
- /* @__PURE__ */ jsx12(EdsTable.Body, {
552
+ /* @__PURE__ */ jsx12(TableBody, {
547
553
  children: tableRows.length ? tableRows.map((row) => /* @__PURE__ */ jsx12(TableRow, {
548
554
  row,
549
555
  rowConfig,
@@ -560,18 +566,26 @@ function BasicTable({
560
566
  import { Typography as Typography2 } from "@equinor/eds-core-react";
561
567
  import { search } from "@equinor/eds-icons";
562
568
  import { useAtom } from "jotai";
563
- import styled13 from "styled-components";
569
+ import styled15 from "styled-components";
570
+
571
+ // src/DataTable/atoms.ts
572
+ import { atom } from "jotai";
573
+ var columnVisibilityAtom = atom({});
574
+ var globalFilterAtom = atom("");
575
+ var rowSelectionAtom = atom({});
576
+ var tableSortingAtom = atom([]);
577
+ var expandedRowsAtom = atom({});
564
578
 
565
579
  // src/DataTable/filters/DebouncedInput.tsx
566
580
  import { Button as Button3, Icon as Icon5, Input, Tooltip } from "@equinor/eds-core-react";
567
581
  import { close } from "@equinor/eds-icons";
568
582
  import { useEffect, useState as useState2 } from "react";
569
- import styled11 from "styled-components";
583
+ import styled13 from "styled-components";
570
584
  import { jsx as jsx13 } from "react/jsx-runtime";
571
- var Wrapper3 = styled11.div`
585
+ var Wrapper3 = styled13.div`
572
586
  width: 200px;
573
587
  `;
574
- var CloseButton = styled11(Button3)`
588
+ var CloseButton = styled13(Button3)`
575
589
  width: 24px;
576
590
  height: 24px;
577
591
  `;
@@ -632,7 +646,7 @@ var fuzzyFilter = (row, columnId, value, addMeta) => {
632
646
  import { Button as Button4, Checkbox as Checkbox2, Divider, Icon as Icon6, Popover } from "@equinor/eds-core-react";
633
647
  import { close as close2, view_column } from "@equinor/eds-icons";
634
648
  import { useRef, useState as useState3 } from "react";
635
- import styled12 from "styled-components";
649
+ import styled14 from "styled-components";
636
650
 
637
651
  // src/DataTable/utils.tsx
638
652
  function capitalizeHeader(context) {
@@ -652,18 +666,18 @@ function prependSelectColumn(columns, config) {
652
666
  if (!(config == null ? void 0 : config.selectColumn))
653
667
  return columns;
654
668
  if (config.selectColumn === "default")
655
- return [SelectColumnDef(config == null ? void 0 : config.rowSelectionMode), ...columns];
669
+ return [SelectColumnDef(config), ...columns];
656
670
  return [config.selectColumn(), ...columns];
657
671
  }
658
672
 
659
673
  // src/DataTable/components/ColumnSelect.tsx
660
674
  import { Fragment as Fragment2, jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
661
- var ColumnSelectContent = styled12.div`
675
+ var ColumnSelectContent = styled14.div`
662
676
  display: grid;
663
677
  grid-template-columns: repeat(2, 1fr);
664
678
  grid-gap: 0.5rem;
665
679
  `;
666
- var ActionsWrapper = styled12.div`
680
+ var ActionsWrapper = styled14.div`
667
681
  display: flex;
668
682
  align-items: center;
669
683
  justify-content: flex-end;
@@ -745,14 +759,14 @@ function ColumnSelect({ table }) {
745
759
 
746
760
  // src/DataTable/components/DataTableHeader.tsx
747
761
  import { Fragment as Fragment3, jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
748
- var DataTableHeaderWrapper = styled13.div`
762
+ var DataTableHeaderWrapper = styled15.div`
749
763
  display: flex;
750
764
  align-items: center;
751
765
  justify-content: space-between;
752
766
  gap: 0.5rem;
753
767
  padding: ${(props) => props.captionPadding ?? "1rem"};
754
768
  `;
755
- var FilterContainer = styled13.div`
769
+ var FilterContainer = styled15.div`
756
770
  display: flex;
757
771
  align-items: center;
758
772
  gap: 1rem;
@@ -791,17 +805,17 @@ function DataTableHeader({ config, table, ...props }) {
791
805
  }
792
806
 
793
807
  // src/DataTable/components/VirtualTable.tsx
794
- import { Table as Table8 } from "@equinor/eds-core-react";
808
+ import { Table as Table9 } from "@equinor/eds-core-react";
795
809
  import { useVirtualizer } from "@tanstack/react-virtual";
796
810
 
797
811
  // src/DataTable/components/PaddingRow.tsx
798
- import { Table as Table7 } from "@equinor/eds-core-react";
812
+ import { Table as Table8 } from "@equinor/eds-core-react";
799
813
  import { jsx as jsx16 } from "react/jsx-runtime";
800
814
  var PaddingRow = (props) => {
801
815
  if (!props.height)
802
816
  return null;
803
- return /* @__PURE__ */ jsx16(Table7.Row, {
804
- children: /* @__PURE__ */ jsx16(Table7.Cell, {
817
+ return /* @__PURE__ */ jsx16(Table8.Row, {
818
+ children: /* @__PURE__ */ jsx16(Table8.Cell, {
805
819
  style: { height: `${props.height}px` }
806
820
  })
807
821
  });
@@ -826,13 +840,13 @@ function VirtualTable({
826
840
  const virtualRows = rowVirtualizer.getVirtualItems();
827
841
  const paddingTop = virtualRows.length > 0 ? ((_a = virtualRows == null ? void 0 : virtualRows[0]) == null ? void 0 : _a.start) || 0 : 0;
828
842
  const paddingBottom = virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (((_b = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b.end) || 0) : 0;
829
- return /* @__PURE__ */ jsxs10(Table8, {
843
+ return /* @__PURE__ */ jsxs10(Table9, {
830
844
  children: [
831
845
  /* @__PURE__ */ jsx17(TableHeader, {
832
846
  sticky: props.stickyHeader,
833
847
  table
834
848
  }),
835
- /* @__PURE__ */ jsxs10(Table8.Body, {
849
+ /* @__PURE__ */ jsxs10(TableBody, {
836
850
  children: [
837
851
  /* @__PURE__ */ jsx17(PaddingRow, {
838
852
  height: paddingTop
@@ -856,9 +870,9 @@ function VirtualTable({
856
870
  });
857
871
  }
858
872
 
859
- // src/DataTable/DataTable.tsx
873
+ // src/DataTable/DataTableRaw.tsx
860
874
  import { jsx as jsx18, jsxs as jsxs11 } from "react/jsx-runtime";
861
- var DataTableWrapper = styled14.div`
875
+ var DataTableWrapper = styled16.div`
862
876
  width: ${(props) => props.width ?? "100%"};
863
877
 
864
878
  .--table-container {
@@ -867,23 +881,63 @@ var DataTableWrapper = styled14.div`
867
881
  overflow: auto;
868
882
 
869
883
  table {
870
- width: ${(props) => props.width ?? "100%"};
871
- height: ${(props) => props.height ?? "100%"};
872
- table-layout: ${(props) => props.tableLayout ?? "fixed"};
873
- border-collapse: collapse;
884
+ width: 100%;
885
+
886
+ // The following attributes are important for fixed column width
887
+ // CHANGE THES WITH CAUTION
888
+ overflow: auto;
889
+ table-layout: ${(props) => props.tableLayout ?? "auto"};
874
890
  }
875
891
  }
876
892
  `;
877
- function DataTable({
878
- columns,
879
- data,
880
- isLoading,
881
- header,
882
- filters,
883
- config,
884
- cellConfig,
885
- rowConfig
886
- }) {
893
+ function DataTableRaw(props) {
894
+ const { isLoading, header, filters, config, rowConfig, table } = props;
895
+ const tableContainerRef = useRef2(null);
896
+ return /* @__PURE__ */ jsxs11(DataTableWrapper, {
897
+ captionPadding: header == null ? void 0 : header.captionPadding,
898
+ height: config == null ? void 0 : config.height,
899
+ width: config == null ? void 0 : config.width,
900
+ tableLayout: config == null ? void 0 : config.tableLayout,
901
+ children: [
902
+ /* @__PURE__ */ jsx18(DataTableHeader, {
903
+ tableCaption: header == null ? void 0 : header.tableCaption,
904
+ captionPadding: header == null ? void 0 : header.captionPadding,
905
+ table,
906
+ config: filters
907
+ }),
908
+ /* @__PURE__ */ jsx18("div", {
909
+ ref: tableContainerRef,
910
+ className: "--table-container",
911
+ children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ jsx18(VirtualTable, {
912
+ containerRef: tableContainerRef,
913
+ table,
914
+ rowConfig,
915
+ isLoading,
916
+ stickyHeader: header == null ? void 0 : header.stickyHeader
917
+ }) : /* @__PURE__ */ jsx18(BasicTable, {
918
+ table,
919
+ rowConfig,
920
+ isLoading,
921
+ stickyHeader: header == null ? void 0 : header.stickyHeader
922
+ })
923
+ })
924
+ ]
925
+ });
926
+ }
927
+
928
+ // src/DataTable/useDataTable.tsx
929
+ import {
930
+ getCoreRowModel,
931
+ getExpandedRowModel,
932
+ getFilteredRowModel,
933
+ getSortedRowModel,
934
+ useReactTable
935
+ } from "@tanstack/react-table";
936
+ import { useAtom as useAtom2 } from "jotai";
937
+ import { useEffect as useEffect2 } from "react";
938
+ import { jsx as jsx19 } from "react/jsx-runtime";
939
+ function useDataTable(props) {
940
+ const { columns, data, filters, config, meta } = props;
887
941
  const [columnVisibility, setColumnVisibility] = useAtom2(columnVisibilityAtom);
888
942
  const [globalFilter, setGlobalFilter] = useAtom2(globalFilterAtom);
889
943
  const [sorting, setSorting] = useAtom2(tableSortingAtom);
@@ -904,11 +958,12 @@ function DataTable({
904
958
  columnVisibility
905
959
  },
906
960
  defaultColumn: {
907
- cell: (cell) => /* @__PURE__ */ jsx18(TypographyCustom, {
961
+ cell: (cell) => /* @__PURE__ */ jsx19(TypographyCustom, {
908
962
  noWrap: true,
909
963
  children: cell.getValue()
910
964
  })
911
965
  },
966
+ meta,
912
967
  enableSorting: config == null ? void 0 : config.sortable,
913
968
  enableExpanding: !(config == null ? void 0 : config.hideExpandControls),
914
969
  enableMultiRowSelection: (config == null ? void 0 : config.rowSelectionMode) === "multiple",
@@ -931,45 +986,24 @@ function DataTable({
931
986
  table.toggleAllRowsExpanded();
932
987
  }
933
988
  }, [table, config == null ? void 0 : config.expandAllByDefault]);
934
- const tableContainerRef = useRef2(null);
935
- return /* @__PURE__ */ jsxs11(DataTableWrapper, {
936
- height: config == null ? void 0 : config.height,
937
- width: config == null ? void 0 : config.width,
938
- tableLayout: config == null ? void 0 : config.tableLayout,
939
- children: [
940
- /* @__PURE__ */ jsx18(DataTableHeader, {
941
- tableCaption: header == null ? void 0 : header.tableCaption,
942
- captionPadding: header == null ? void 0 : header.captionPadding,
943
- table,
944
- config: filters
945
- }),
946
- /* @__PURE__ */ jsx18("div", {
947
- ref: tableContainerRef,
948
- className: "--table-container",
949
- children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ jsx18(VirtualTable, {
950
- containerRef: tableContainerRef,
951
- table,
952
- rowConfig,
953
- cellConfig,
954
- isLoading,
955
- stickyHeader: header == null ? void 0 : header.stickyHeader
956
- }) : /* @__PURE__ */ jsx18(BasicTable, {
957
- table,
958
- rowConfig,
959
- cellConfig,
960
- isLoading,
961
- stickyHeader: header == null ? void 0 : header.stickyHeader
962
- })
963
- })
964
- ]
989
+ return table;
990
+ }
991
+
992
+ // src/DataTable/DataTable.tsx
993
+ import { jsx as jsx20 } from "react/jsx-runtime";
994
+ function DataTable(props) {
995
+ const table = useDataTable(props);
996
+ return /* @__PURE__ */ jsx20(DataTableRaw, {
997
+ table,
998
+ ...props
965
999
  });
966
1000
  }
967
1001
 
968
1002
  // src/DataTable/Provider.tsx
969
1003
  import { Provider } from "jotai";
970
- import { jsx as jsx19 } from "react/jsx-runtime";
1004
+ import { jsx as jsx21 } from "react/jsx-runtime";
971
1005
  function DataTableProvider({ children, ...props }) {
972
- return /* @__PURE__ */ jsx19(Provider, {
1006
+ return /* @__PURE__ */ jsx21(Provider, {
973
1007
  ...props,
974
1008
  children
975
1009
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/apollo-components",
3
- "version": "1.8.1",
3
+ "version": "1.10.0",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",