@equinor/apollo-components 1.8.0 → 1.9.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
@@ -71,6 +71,7 @@ interface CellConfig<T> {
71
71
  declare type RowSelectionMode = 'single' | 'multiple';
72
72
  declare type DataTableConfig<T> = {
73
73
  height?: string;
74
+ tableLayout?: 'auto' | 'fixed';
74
75
  sortable?: boolean;
75
76
  virtual?: boolean;
76
77
  rowSelectionMode?: RowSelectionMode;
@@ -83,10 +84,7 @@ interface ExpansionConfig {
83
84
  expandAllByDefault?: boolean;
84
85
  hideExpandControls?: boolean;
85
86
  }
86
-
87
- interface DataTableProps<T> {
88
- data: T[];
89
- columns: ColumnDef<T, any>[];
87
+ interface DataTableCommonProps<T> {
90
88
  isLoading?: boolean;
91
89
  className?: string;
92
90
  config?: DataTableConfig<T>;
@@ -95,7 +93,15 @@ interface DataTableProps<T> {
95
93
  filters?: FilterConfig;
96
94
  header?: HeaderConfig;
97
95
  }
98
- declare function DataTable$1<T>({ columns, data, isLoading, header, filters, config, cellConfig, rowConfig, }: DataTableProps<T>): JSX.Element;
96
+ interface DataTableProps<T> extends DataTableCommonProps<T> {
97
+ data: T[];
98
+ columns: ColumnDef<T, any>[];
99
+ }
100
+ interface DataTableRawProps<T> extends DataTableCommonProps<T> {
101
+ table: Table<T>;
102
+ }
103
+
104
+ declare function DataTable$1<T>(props: DataTableProps<T>): JSX.Element;
99
105
 
100
106
  declare type DataTableProviderProps = ComponentProps<typeof Provider>;
101
107
  declare function DataTableProvider({ children, ...props }: DataTableProviderProps): JSX.Element;
@@ -152,4 +158,4 @@ declare type TypographyProps = {
152
158
  */
153
159
  declare const TypographyCustom: (props: TypographyProps) => JSX.Element;
154
160
 
155
- 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 };
161
+ export { AppShell, AppSidebar, CellConfig, ChipsCell, ColumnSelect, DataTable, DataTableCommonProps, DataTableConfig, DataTableProps, DataTableRawProps, DynamicCell, FilterConfig, HeaderConfig, HierarchyCell, RowConfig, RowSelectionMode, SelectColumnDef, StickyCell, TableHeader, TableRowWrapper, TableRowWrapperProps, TypographyCustom, capitalizeHeader, globalFilterAtom, prependSelectColumn, rowSelectionAtom, tableSortingAtom };
package/dist/index.js CHANGED
@@ -195,24 +195,12 @@ var ChipsCell = (props) => {
195
195
  // src/cells/DynamicCell.tsx
196
196
  var import_eds_core_react4 = require("@equinor/eds-core-react");
197
197
  var import_react_table = require("@tanstack/react-table");
198
- var import_styled_components6 = __toESM(require("styled-components"));
198
+ var import_styled_components5 = __toESM(require("styled-components"));
199
199
 
200
200
  // src/cells/StickyCell.tsx
201
201
  var import_eds_core_react3 = require("@equinor/eds-core-react");
202
202
  var import_styled_components4 = __toESM(require("styled-components"));
203
- var StickyCell = (0, import_styled_components4.default)(import_eds_core_react3.Table.Cell)`
204
- position: sticky;
205
- right: 0;
206
- top: 0;
207
- z-index: 4;
208
- `;
209
- var StickyHeaderCell = (0, import_styled_components4.default)(StickyCell)`
210
- z-index: 5;
211
- `;
212
-
213
- // src/cells/styles.ts
214
- var import_styled_components5 = require("styled-components");
215
- var leftCellShadow = import_styled_components5.css`
203
+ var leftCellShadow = import_styled_components4.css`
216
204
  &:before {
217
205
  box-shadow: -1px 0 1px -1px inset;
218
206
  content: ' ';
@@ -223,15 +211,24 @@ var leftCellShadow = import_styled_components5.css`
223
211
  width: 1px;
224
212
  }
225
213
  `;
214
+ var StickyCell = (0, import_styled_components4.default)(import_eds_core_react3.Table.Cell)`
215
+ position: sticky;
216
+ right: 0;
217
+ top: 0;
218
+ z-index: 4;
219
+ background-clip: padding-box;
220
+ ${leftCellShadow}
221
+ `;
222
+ var StickyHeaderCell = (0, import_styled_components4.default)(StickyCell)`
223
+ z-index: 5;
224
+ `;
226
225
 
227
226
  // src/cells/DynamicCell.tsx
228
227
  var import_jsx_runtime4 = require("react/jsx-runtime");
229
- var StyledStickyCell = (0, import_styled_components6.default)(StickyCell)`
230
- background-clip: padding-box;
231
- ${leftCellShadow}
228
+ var StyledStickyCell = (0, import_styled_components5.default)(StickyCell)`
232
229
  ${(props) => props.backgroundColor ? `background-color: ${props.backgroundColor} !important;` : ``}
233
230
  `;
234
- var StyledCell = (0, import_styled_components6.default)(import_eds_core_react4.Table.Cell)`
231
+ var StyledCell = (0, import_styled_components5.default)(import_eds_core_react4.Table.Cell)`
235
232
  ${(props) => props.backgroundColor ? `background-color: ${props.backgroundColor} !important;` : ``}
236
233
  `;
237
234
  function DynamicCell({ cell, highlight, getStickyCellColor }) {
@@ -253,12 +250,12 @@ function DynamicCell({ cell, highlight, getStickyCellColor }) {
253
250
 
254
251
  // src/cells/HierarchyCell.tsx
255
252
  var import_eds_tokens4 = require("@equinor/eds-tokens");
256
- var import_styled_components8 = __toESM(require("styled-components"));
253
+ var import_styled_components7 = __toESM(require("styled-components"));
257
254
 
258
255
  // src/cells/TypographyCustom.tsx
259
256
  var import_eds_core_react5 = require("@equinor/eds-core-react");
260
257
  var import_eds_tokens3 = require("@equinor/eds-tokens");
261
- var import_styled_components7 = __toESM(require("styled-components"));
258
+ var import_styled_components6 = __toESM(require("styled-components"));
262
259
  var import_jsx_runtime5 = require("react/jsx-runtime");
263
260
  var truncateStyle = {
264
261
  overflow: "hidden",
@@ -294,7 +291,7 @@ var TypographyCustom = (props) => {
294
291
  style: { ...styleFromProps, ...noWrap ? truncateStyle : {} }
295
292
  });
296
293
  };
297
- var HoverCapture = import_styled_components7.default.div`
294
+ var HoverCapture = import_styled_components6.default.div`
298
295
  position: relative;
299
296
  z-index: 0;
300
297
 
@@ -305,7 +302,7 @@ var HoverCapture = import_styled_components7.default.div`
305
302
  opacity: 1;
306
303
  }
307
304
  `;
308
- var ShowAllWrapperWrapper = import_styled_components7.default.div`
305
+ var ShowAllWrapperWrapper = import_styled_components6.default.div`
309
306
  position: absolute;
310
307
  z-index: 1;
311
308
  pointer-events: none;
@@ -317,14 +314,14 @@ var ShowAllWrapperWrapper = import_styled_components7.default.div`
317
314
 
318
315
  // src/cells/HierarchyCell.tsx
319
316
  var import_jsx_runtime6 = require("react/jsx-runtime");
320
- var CellWrapper = (0, import_styled_components8.default)(TypographyCustom)`
317
+ var CellWrapper = (0, import_styled_components7.default)(TypographyCustom)`
321
318
  height: 100%;
322
319
  display: flex;
323
320
  align-items: center;
324
321
 
325
322
  ${({ depth, expanded }) => expanded && depth === 0 && "font-weight: bold;"}
326
323
 
327
- ${({ depth }) => depth > 0 && import_styled_components8.css`
324
+ ${({ depth }) => depth > 0 && import_styled_components7.css`
328
325
  border-left: 3px solid ${import_eds_tokens4.tokens.colors.infographic.primary__moss_green_34.hex};
329
326
  gap: 0.5rem;
330
327
  .--divider {
@@ -352,9 +349,9 @@ function HierarchyCell(cell, options = {}) {
352
349
  // src/cells/SelectColumnDef.tsx
353
350
  var import_eds_core_react6 = require("@equinor/eds-core-react");
354
351
  var import_eds_icons3 = require("@equinor/eds-icons");
355
- var import_styled_components9 = __toESM(require("styled-components"));
352
+ var import_styled_components8 = __toESM(require("styled-components"));
356
353
  var import_jsx_runtime7 = require("react/jsx-runtime");
357
- var CellWrapper2 = import_styled_components9.default.div`
354
+ var CellWrapper2 = import_styled_components8.default.div`
358
355
  display: flex;
359
356
  align-items: center;
360
357
  width: 48px;
@@ -406,28 +403,18 @@ function SelectColumnDef(selectionMode) {
406
403
  };
407
404
  }
408
405
 
409
- // src/DataTable/DataTable.tsx
410
- var import_react_table3 = require("@tanstack/react-table");
411
- var import_jotai3 = require("jotai");
406
+ // src/DataTable/DataTableRaw.tsx
412
407
  var import_react4 = require("react");
413
- var import_styled_components15 = __toESM(require("styled-components"));
414
-
415
- // src/DataTable/atoms.ts
416
- var import_jotai = require("jotai");
417
- var columnVisibilityAtom = (0, import_jotai.atom)({});
418
- var globalFilterAtom = (0, import_jotai.atom)("");
419
- var rowSelectionAtom = (0, import_jotai.atom)({});
420
- var tableSortingAtom = (0, import_jotai.atom)([]);
421
- var expandedRowsAtom = (0, import_jotai.atom)({});
408
+ var import_styled_components14 = __toESM(require("styled-components"));
422
409
 
423
410
  // src/DataTable/components/BasicTable.tsx
424
411
  var import_eds_core_react11 = require("@equinor/eds-core-react");
425
412
 
426
413
  // src/DataTable/components/PlaceholderRow.tsx
427
414
  var import_eds_core_react7 = require("@equinor/eds-core-react");
428
- var import_styled_components10 = __toESM(require("styled-components"));
415
+ var import_styled_components9 = __toESM(require("styled-components"));
429
416
  var import_jsx_runtime8 = require("react/jsx-runtime");
430
- var PlaceholderTextWrapper = import_styled_components10.default.div`
417
+ var PlaceholderTextWrapper = import_styled_components9.default.div`
431
418
  display: flex;
432
419
  justify-content: center;
433
420
  `;
@@ -453,17 +440,14 @@ var import_eds_core_react9 = require("@equinor/eds-core-react");
453
440
  var import_eds_core_react8 = require("@equinor/eds-core-react");
454
441
  var import_eds_icons4 = require("@equinor/eds-icons");
455
442
  var import_react_table2 = require("@tanstack/react-table");
456
- var import_styled_components11 = __toESM(require("styled-components"));
443
+ var import_styled_components10 = __toESM(require("styled-components"));
457
444
  var import_jsx_runtime9 = require("react/jsx-runtime");
458
- var HeaderDiv = import_styled_components11.default.div`
445
+ var HeaderDiv = import_styled_components10.default.div`
459
446
  display: flex;
460
447
  align-items: center;
461
448
  gap: 0.25rem;
462
449
  z-index: 5;
463
450
  `;
464
- var StyledStickyCell2 = (0, import_styled_components11.default)(StickyCell)`
465
- ${leftCellShadow}
466
- `;
467
451
  var HeaderCell = ({ header }) => {
468
452
  var _a;
469
453
  const style = {
@@ -475,13 +459,14 @@ var HeaderCell = ({ header }) => {
475
459
  onClick: header.column.getToggleSortingHandler(),
476
460
  colSpan: header.colSpan
477
461
  };
478
- if ((_a = header.column.columnDef.meta) == null ? void 0 : _a.sticky)
479
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StyledStickyCell2, {
462
+ if ((_a = header.column.columnDef.meta) == null ? void 0 : _a.sticky) {
463
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StickyHeaderCell, {
480
464
  ...cellProps,
481
465
  children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HeaderContent, {
482
466
  header
483
467
  })
484
468
  }, header.id);
469
+ }
485
470
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Table.Cell, {
486
471
  ...cellProps,
487
472
  children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HeaderContent, {
@@ -605,18 +590,26 @@ function BasicTable({
605
590
  var import_eds_core_react14 = require("@equinor/eds-core-react");
606
591
  var import_eds_icons7 = require("@equinor/eds-icons");
607
592
  var import_jotai2 = require("jotai");
608
- var import_styled_components14 = __toESM(require("styled-components"));
593
+ var import_styled_components13 = __toESM(require("styled-components"));
594
+
595
+ // src/DataTable/atoms.ts
596
+ var import_jotai = require("jotai");
597
+ var columnVisibilityAtom = (0, import_jotai.atom)({});
598
+ var globalFilterAtom = (0, import_jotai.atom)("");
599
+ var rowSelectionAtom = (0, import_jotai.atom)({});
600
+ var tableSortingAtom = (0, import_jotai.atom)([]);
601
+ var expandedRowsAtom = (0, import_jotai.atom)({});
609
602
 
610
603
  // src/DataTable/filters/DebouncedInput.tsx
611
604
  var import_eds_core_react12 = require("@equinor/eds-core-react");
612
605
  var import_eds_icons5 = require("@equinor/eds-icons");
613
606
  var import_react2 = require("react");
614
- var import_styled_components12 = __toESM(require("styled-components"));
607
+ var import_styled_components11 = __toESM(require("styled-components"));
615
608
  var import_jsx_runtime13 = require("react/jsx-runtime");
616
- var Wrapper3 = import_styled_components12.default.div`
609
+ var Wrapper3 = import_styled_components11.default.div`
617
610
  width: 200px;
618
611
  `;
619
- var CloseButton = (0, import_styled_components12.default)(import_eds_core_react12.Button)`
612
+ var CloseButton = (0, import_styled_components11.default)(import_eds_core_react12.Button)`
620
613
  width: 24px;
621
614
  height: 24px;
622
615
  `;
@@ -677,7 +670,7 @@ var fuzzyFilter = (row, columnId, value, addMeta) => {
677
670
  var import_eds_core_react13 = require("@equinor/eds-core-react");
678
671
  var import_eds_icons6 = require("@equinor/eds-icons");
679
672
  var import_react3 = require("react");
680
- var import_styled_components13 = __toESM(require("styled-components"));
673
+ var import_styled_components12 = __toESM(require("styled-components"));
681
674
 
682
675
  // src/DataTable/utils.tsx
683
676
  function capitalizeHeader(context) {
@@ -703,12 +696,12 @@ function prependSelectColumn(columns, config) {
703
696
 
704
697
  // src/DataTable/components/ColumnSelect.tsx
705
698
  var import_jsx_runtime14 = require("react/jsx-runtime");
706
- var ColumnSelectContent = import_styled_components13.default.div`
699
+ var ColumnSelectContent = import_styled_components12.default.div`
707
700
  display: grid;
708
701
  grid-template-columns: repeat(2, 1fr);
709
702
  grid-gap: 0.5rem;
710
703
  `;
711
- var ActionsWrapper = import_styled_components13.default.div`
704
+ var ActionsWrapper = import_styled_components12.default.div`
712
705
  display: flex;
713
706
  align-items: center;
714
707
  justify-content: flex-end;
@@ -790,14 +783,14 @@ function ColumnSelect({ table }) {
790
783
 
791
784
  // src/DataTable/components/DataTableHeader.tsx
792
785
  var import_jsx_runtime15 = require("react/jsx-runtime");
793
- var DataTableHeaderWrapper = import_styled_components14.default.div`
786
+ var DataTableHeaderWrapper = import_styled_components13.default.div`
794
787
  display: flex;
795
788
  align-items: center;
796
789
  justify-content: space-between;
797
790
  gap: 0.5rem;
798
791
  padding: ${(props) => props.captionPadding ?? "1rem"};
799
792
  `;
800
- var FilterContainer = import_styled_components14.default.div`
793
+ var FilterContainer = import_styled_components13.default.div`
801
794
  display: flex;
802
795
  align-items: center;
803
796
  gap: 1rem;
@@ -901,9 +894,9 @@ function VirtualTable({
901
894
  });
902
895
  }
903
896
 
904
- // src/DataTable/DataTable.tsx
897
+ // src/DataTable/DataTableRaw.tsx
905
898
  var import_jsx_runtime18 = require("react/jsx-runtime");
906
- var DataTableWrapper = import_styled_components15.default.div`
899
+ var DataTableWrapper = import_styled_components14.default.div`
907
900
  width: ${(props) => props.width ?? "100%"};
908
901
 
909
902
  .--table-container {
@@ -917,16 +910,47 @@ var DataTableWrapper = import_styled_components15.default.div`
917
910
  }
918
911
  }
919
912
  `;
920
- function DataTable({
921
- columns,
922
- data,
923
- isLoading,
924
- header,
925
- filters,
926
- config,
927
- cellConfig,
928
- rowConfig
929
- }) {
913
+ function DataTableRaw(props) {
914
+ const { isLoading, header, filters, config, rowConfig, table } = props;
915
+ const tableContainerRef = (0, import_react4.useRef)(null);
916
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DataTableWrapper, {
917
+ captionPadding: header == null ? void 0 : header.captionPadding,
918
+ height: config == null ? void 0 : config.height,
919
+ width: config == null ? void 0 : config.width,
920
+ children: [
921
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DataTableHeader, {
922
+ tableCaption: header == null ? void 0 : header.tableCaption,
923
+ captionPadding: header == null ? void 0 : header.captionPadding,
924
+ table,
925
+ config: filters
926
+ }),
927
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", {
928
+ ref: tableContainerRef,
929
+ className: "--table-container",
930
+ children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(VirtualTable, {
931
+ containerRef: tableContainerRef,
932
+ table,
933
+ rowConfig,
934
+ isLoading,
935
+ stickyHeader: header == null ? void 0 : header.stickyHeader
936
+ }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(BasicTable, {
937
+ table,
938
+ rowConfig,
939
+ isLoading,
940
+ stickyHeader: header == null ? void 0 : header.stickyHeader
941
+ })
942
+ })
943
+ ]
944
+ });
945
+ }
946
+
947
+ // src/DataTable/useDataTable.tsx
948
+ var import_react_table3 = require("@tanstack/react-table");
949
+ var import_jotai3 = require("jotai");
950
+ var import_react5 = require("react");
951
+ var import_jsx_runtime19 = require("react/jsx-runtime");
952
+ function useDataTable(props) {
953
+ const { columns, data, filters, config, meta } = props;
930
954
  const [columnVisibility, setColumnVisibility] = (0, import_jotai3.useAtom)(columnVisibilityAtom);
931
955
  const [globalFilter, setGlobalFilter] = (0, import_jotai3.useAtom)(globalFilterAtom);
932
956
  const [sorting, setSorting] = (0, import_jotai3.useAtom)(tableSortingAtom);
@@ -947,11 +971,12 @@ function DataTable({
947
971
  columnVisibility
948
972
  },
949
973
  defaultColumn: {
950
- cell: (cell) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TypographyCustom, {
974
+ cell: (cell) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TypographyCustom, {
951
975
  noWrap: true,
952
976
  children: cell.getValue()
953
977
  })
954
978
  },
979
+ meta,
955
980
  enableSorting: config == null ? void 0 : config.sortable,
956
981
  enableExpanding: !(config == null ? void 0 : config.hideExpandControls),
957
982
  enableMultiRowSelection: (config == null ? void 0 : config.rowSelectionMode) === "multiple",
@@ -969,50 +994,29 @@ function DataTable({
969
994
  getSubRows: config == null ? void 0 : config.getSubRows,
970
995
  getRowId: config == null ? void 0 : config.getRowId
971
996
  });
972
- (0, import_react4.useEffect)(() => {
997
+ (0, import_react5.useEffect)(() => {
973
998
  if (config && config.expandAllByDefault) {
974
999
  table.toggleAllRowsExpanded();
975
1000
  }
976
1001
  }, [table, config == null ? void 0 : config.expandAllByDefault]);
977
- const tableContainerRef = (0, import_react4.useRef)(null);
978
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DataTableWrapper, {
979
- captionPadding: header == null ? void 0 : header.captionPadding,
980
- height: config == null ? void 0 : config.height,
981
- width: config == null ? void 0 : config.width,
982
- children: [
983
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DataTableHeader, {
984
- tableCaption: header == null ? void 0 : header.tableCaption,
985
- captionPadding: header == null ? void 0 : header.captionPadding,
986
- table,
987
- config: filters
988
- }),
989
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", {
990
- ref: tableContainerRef,
991
- className: "--table-container",
992
- children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(VirtualTable, {
993
- containerRef: tableContainerRef,
994
- table,
995
- rowConfig,
996
- cellConfig,
997
- isLoading,
998
- stickyHeader: header == null ? void 0 : header.stickyHeader
999
- }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(BasicTable, {
1000
- table,
1001
- rowConfig,
1002
- cellConfig,
1003
- isLoading,
1004
- stickyHeader: header == null ? void 0 : header.stickyHeader
1005
- })
1006
- })
1007
- ]
1002
+ return table;
1003
+ }
1004
+
1005
+ // src/DataTable/DataTable.tsx
1006
+ var import_jsx_runtime20 = require("react/jsx-runtime");
1007
+ function DataTable(props) {
1008
+ const table = useDataTable(props);
1009
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(DataTableRaw, {
1010
+ table,
1011
+ ...props
1008
1012
  });
1009
1013
  }
1010
1014
 
1011
1015
  // src/DataTable/Provider.tsx
1012
1016
  var import_jotai4 = require("jotai");
1013
- var import_jsx_runtime19 = require("react/jsx-runtime");
1017
+ var import_jsx_runtime21 = require("react/jsx-runtime");
1014
1018
  function DataTableProvider({ children, ...props }) {
1015
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jotai4.Provider, {
1019
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jotai4.Provider, {
1016
1020
  ...props,
1017
1021
  children
1018
1022
  });
package/dist/index.mjs CHANGED
@@ -152,19 +152,7 @@ import styled5 from "styled-components";
152
152
 
153
153
  // src/cells/StickyCell.tsx
154
154
  import { Table } from "@equinor/eds-core-react";
155
- import styled4 from "styled-components";
156
- var StickyCell = styled4(Table.Cell)`
157
- position: sticky;
158
- right: 0;
159
- top: 0;
160
- z-index: 4;
161
- `;
162
- var StickyHeaderCell = styled4(StickyCell)`
163
- z-index: 5;
164
- `;
165
-
166
- // src/cells/styles.ts
167
- import { css as css2 } from "styled-components";
155
+ import styled4, { css as css2 } from "styled-components";
168
156
  var leftCellShadow = css2`
169
157
  &:before {
170
158
  box-shadow: -1px 0 1px -1px inset;
@@ -176,12 +164,21 @@ var leftCellShadow = css2`
176
164
  width: 1px;
177
165
  }
178
166
  `;
167
+ var StickyCell = styled4(Table.Cell)`
168
+ position: sticky;
169
+ right: 0;
170
+ top: 0;
171
+ z-index: 4;
172
+ background-clip: padding-box;
173
+ ${leftCellShadow}
174
+ `;
175
+ var StickyHeaderCell = styled4(StickyCell)`
176
+ z-index: 5;
177
+ `;
179
178
 
180
179
  // src/cells/DynamicCell.tsx
181
180
  import { jsx as jsx4 } from "react/jsx-runtime";
182
181
  var StyledStickyCell = styled5(StickyCell)`
183
- background-clip: padding-box;
184
- ${leftCellShadow}
185
182
  ${(props) => props.backgroundColor ? `background-color: ${props.backgroundColor} !important;` : ``}
186
183
  `;
187
184
  var StyledCell = styled5(Table2.Cell)`
@@ -361,26 +358,10 @@ function SelectColumnDef(selectionMode) {
361
358
  };
362
359
  }
363
360
 
364
- // src/DataTable/DataTable.tsx
365
- import {
366
- getCoreRowModel,
367
- getExpandedRowModel,
368
- getFilteredRowModel,
369
- getSortedRowModel,
370
- useReactTable
371
- } from "@tanstack/react-table";
372
- import { useAtom as useAtom2 } from "jotai";
373
- import { useEffect as useEffect2, useRef as useRef2 } from "react";
361
+ // src/DataTable/DataTableRaw.tsx
362
+ import { useRef as useRef2 } from "react";
374
363
  import styled14 from "styled-components";
375
364
 
376
- // src/DataTable/atoms.ts
377
- import { atom } from "jotai";
378
- var columnVisibilityAtom = atom({});
379
- var globalFilterAtom = atom("");
380
- var rowSelectionAtom = atom({});
381
- var tableSortingAtom = atom([]);
382
- var expandedRowsAtom = atom({});
383
-
384
365
  // src/DataTable/components/BasicTable.tsx
385
366
  import { Table as EdsTable } from "@equinor/eds-core-react";
386
367
 
@@ -422,9 +403,6 @@ var HeaderDiv = styled10.div`
422
403
  gap: 0.25rem;
423
404
  z-index: 5;
424
405
  `;
425
- var StyledStickyCell2 = styled10(StickyCell)`
426
- ${leftCellShadow}
427
- `;
428
406
  var HeaderCell = ({ header }) => {
429
407
  var _a;
430
408
  const style = {
@@ -436,13 +414,14 @@ var HeaderCell = ({ header }) => {
436
414
  onClick: header.column.getToggleSortingHandler(),
437
415
  colSpan: header.colSpan
438
416
  };
439
- if ((_a = header.column.columnDef.meta) == null ? void 0 : _a.sticky)
440
- return /* @__PURE__ */ jsx9(StyledStickyCell2, {
417
+ if ((_a = header.column.columnDef.meta) == null ? void 0 : _a.sticky) {
418
+ return /* @__PURE__ */ jsx9(StickyHeaderCell, {
441
419
  ...cellProps,
442
420
  children: /* @__PURE__ */ jsx9(HeaderContent, {
443
421
  header
444
422
  })
445
423
  }, header.id);
424
+ }
446
425
  return /* @__PURE__ */ jsx9(Table4.Cell, {
447
426
  ...cellProps,
448
427
  children: /* @__PURE__ */ jsx9(HeaderContent, {
@@ -568,6 +547,14 @@ import { search } from "@equinor/eds-icons";
568
547
  import { useAtom } from "jotai";
569
548
  import styled13 from "styled-components";
570
549
 
550
+ // src/DataTable/atoms.ts
551
+ import { atom } from "jotai";
552
+ var columnVisibilityAtom = atom({});
553
+ var globalFilterAtom = atom("");
554
+ var rowSelectionAtom = atom({});
555
+ var tableSortingAtom = atom([]);
556
+ var expandedRowsAtom = atom({});
557
+
571
558
  // src/DataTable/filters/DebouncedInput.tsx
572
559
  import { Button as Button3, Icon as Icon5, Input, Tooltip } from "@equinor/eds-core-react";
573
560
  import { close } from "@equinor/eds-icons";
@@ -862,7 +849,7 @@ function VirtualTable({
862
849
  });
863
850
  }
864
851
 
865
- // src/DataTable/DataTable.tsx
852
+ // src/DataTable/DataTableRaw.tsx
866
853
  import { jsx as jsx18, jsxs as jsxs11 } from "react/jsx-runtime";
867
854
  var DataTableWrapper = styled14.div`
868
855
  width: ${(props) => props.width ?? "100%"};
@@ -878,16 +865,53 @@ var DataTableWrapper = styled14.div`
878
865
  }
879
866
  }
880
867
  `;
881
- function DataTable({
882
- columns,
883
- data,
884
- isLoading,
885
- header,
886
- filters,
887
- config,
888
- cellConfig,
889
- rowConfig
890
- }) {
868
+ function DataTableRaw(props) {
869
+ const { isLoading, header, filters, config, rowConfig, table } = props;
870
+ const tableContainerRef = useRef2(null);
871
+ return /* @__PURE__ */ jsxs11(DataTableWrapper, {
872
+ captionPadding: header == null ? void 0 : header.captionPadding,
873
+ height: config == null ? void 0 : config.height,
874
+ width: config == null ? void 0 : config.width,
875
+ children: [
876
+ /* @__PURE__ */ jsx18(DataTableHeader, {
877
+ tableCaption: header == null ? void 0 : header.tableCaption,
878
+ captionPadding: header == null ? void 0 : header.captionPadding,
879
+ table,
880
+ config: filters
881
+ }),
882
+ /* @__PURE__ */ jsx18("div", {
883
+ ref: tableContainerRef,
884
+ className: "--table-container",
885
+ children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ jsx18(VirtualTable, {
886
+ containerRef: tableContainerRef,
887
+ table,
888
+ rowConfig,
889
+ isLoading,
890
+ stickyHeader: header == null ? void 0 : header.stickyHeader
891
+ }) : /* @__PURE__ */ jsx18(BasicTable, {
892
+ table,
893
+ rowConfig,
894
+ isLoading,
895
+ stickyHeader: header == null ? void 0 : header.stickyHeader
896
+ })
897
+ })
898
+ ]
899
+ });
900
+ }
901
+
902
+ // src/DataTable/useDataTable.tsx
903
+ import {
904
+ getCoreRowModel,
905
+ getExpandedRowModel,
906
+ getFilteredRowModel,
907
+ getSortedRowModel,
908
+ useReactTable
909
+ } from "@tanstack/react-table";
910
+ import { useAtom as useAtom2 } from "jotai";
911
+ import { useEffect as useEffect2 } from "react";
912
+ import { jsx as jsx19 } from "react/jsx-runtime";
913
+ function useDataTable(props) {
914
+ const { columns, data, filters, config, meta } = props;
891
915
  const [columnVisibility, setColumnVisibility] = useAtom2(columnVisibilityAtom);
892
916
  const [globalFilter, setGlobalFilter] = useAtom2(globalFilterAtom);
893
917
  const [sorting, setSorting] = useAtom2(tableSortingAtom);
@@ -908,11 +932,12 @@ function DataTable({
908
932
  columnVisibility
909
933
  },
910
934
  defaultColumn: {
911
- cell: (cell) => /* @__PURE__ */ jsx18(TypographyCustom, {
935
+ cell: (cell) => /* @__PURE__ */ jsx19(TypographyCustom, {
912
936
  noWrap: true,
913
937
  children: cell.getValue()
914
938
  })
915
939
  },
940
+ meta,
916
941
  enableSorting: config == null ? void 0 : config.sortable,
917
942
  enableExpanding: !(config == null ? void 0 : config.hideExpandControls),
918
943
  enableMultiRowSelection: (config == null ? void 0 : config.rowSelectionMode) === "multiple",
@@ -935,45 +960,24 @@ function DataTable({
935
960
  table.toggleAllRowsExpanded();
936
961
  }
937
962
  }, [table, config == null ? void 0 : config.expandAllByDefault]);
938
- const tableContainerRef = useRef2(null);
939
- return /* @__PURE__ */ jsxs11(DataTableWrapper, {
940
- captionPadding: header == null ? void 0 : header.captionPadding,
941
- height: config == null ? void 0 : config.height,
942
- width: config == null ? void 0 : config.width,
943
- children: [
944
- /* @__PURE__ */ jsx18(DataTableHeader, {
945
- tableCaption: header == null ? void 0 : header.tableCaption,
946
- captionPadding: header == null ? void 0 : header.captionPadding,
947
- table,
948
- config: filters
949
- }),
950
- /* @__PURE__ */ jsx18("div", {
951
- ref: tableContainerRef,
952
- className: "--table-container",
953
- children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ jsx18(VirtualTable, {
954
- containerRef: tableContainerRef,
955
- table,
956
- rowConfig,
957
- cellConfig,
958
- isLoading,
959
- stickyHeader: header == null ? void 0 : header.stickyHeader
960
- }) : /* @__PURE__ */ jsx18(BasicTable, {
961
- table,
962
- rowConfig,
963
- cellConfig,
964
- isLoading,
965
- stickyHeader: header == null ? void 0 : header.stickyHeader
966
- })
967
- })
968
- ]
963
+ return table;
964
+ }
965
+
966
+ // src/DataTable/DataTable.tsx
967
+ import { jsx as jsx20 } from "react/jsx-runtime";
968
+ function DataTable(props) {
969
+ const table = useDataTable(props);
970
+ return /* @__PURE__ */ jsx20(DataTableRaw, {
971
+ table,
972
+ ...props
969
973
  });
970
974
  }
971
975
 
972
976
  // src/DataTable/Provider.tsx
973
977
  import { Provider } from "jotai";
974
- import { jsx as jsx19 } from "react/jsx-runtime";
978
+ import { jsx as jsx21 } from "react/jsx-runtime";
975
979
  function DataTableProvider({ children, ...props }) {
976
- return /* @__PURE__ */ jsx19(Provider, {
980
+ return /* @__PURE__ */ jsx21(Provider, {
977
981
  ...props,
978
982
  children
979
983
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/apollo-components",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",