@equinor/apollo-components 1.1.1 → 1.2.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,6 +1,8 @@
1
1
  import { IconData } from '@equinor/eds-icons';
2
- import { ReactNode } from 'react';
3
- import { ColumnDef } from '@tanstack/react-table';
2
+ import { ReactNode, ComponentProps } from 'react';
3
+ import { ColumnDef, RowSelectionState, SortingState } from '@tanstack/react-table';
4
+ import * as jotai from 'jotai';
5
+ import { Provider } from 'jotai';
4
6
 
5
7
  interface AppShellProps {
6
8
  children?: ReactNode;
@@ -29,6 +31,7 @@ interface DataTableConfig {
29
31
  height?: string;
30
32
  sortable?: boolean;
31
33
  virtual?: boolean;
34
+ enableRowSelection?: boolean;
32
35
  width?: string;
33
36
  }
34
37
 
@@ -40,6 +43,24 @@ interface DataTableProps<T> {
40
43
  filters?: FilterConfig;
41
44
  header?: HeaderConfig;
42
45
  }
43
- declare function DataTable<T>({ columns, data, header, filters, config }: DataTableProps<T>): JSX.Element;
46
+ declare function DataTable$1<T>({ columns, data, header, filters, config }: DataTableProps<T>): JSX.Element;
44
47
 
45
- export { AppShell, AppSidebar, ChipsCell, DataTable, DataTableConfig, FilterConfig, HeaderConfig };
48
+ declare type DataTableProviderProps = ComponentProps<typeof Provider>;
49
+ declare function DataTableProvider({ children, ...props }: DataTableProviderProps): JSX.Element;
50
+
51
+ declare const globalFilterAtom: jotai.PrimitiveAtom<string> & {
52
+ init: string;
53
+ };
54
+ declare const rowSelectionAtom: jotai.PrimitiveAtom<RowSelectionState> & {
55
+ init: RowSelectionState;
56
+ };
57
+ declare const tableSortingAtom: jotai.PrimitiveAtom<SortingState> & {
58
+ init: SortingState;
59
+ };
60
+
61
+ declare type DataTableCompoundProps = typeof DataTable$1 & {
62
+ Provider: typeof DataTableProvider;
63
+ };
64
+ declare const DataTable: DataTableCompoundProps;
65
+
66
+ export { AppShell, AppSidebar, ChipsCell, DataTable, DataTableConfig, FilterConfig, HeaderConfig, globalFilterAtom, rowSelectionAtom, tableSortingAtom };
package/dist/index.js CHANGED
@@ -29,7 +29,10 @@ __export(src_exports, {
29
29
  AppShell: () => AppShell,
30
30
  AppSidebar: () => AppSidebar,
31
31
  ChipsCell: () => ChipsCell,
32
- DataTable: () => DataTable
32
+ DataTable: () => DataTable2,
33
+ globalFilterAtom: () => globalFilterAtom,
34
+ rowSelectionAtom: () => rowSelectionAtom,
35
+ tableSortingAtom: () => tableSortingAtom
33
36
  });
34
37
  module.exports = __toCommonJS(src_exports);
35
38
 
@@ -176,8 +179,16 @@ var ChipsCell = (props) => {
176
179
 
177
180
  // src/DataTable/DataTable.tsx
178
181
  var import_react_table4 = require("@tanstack/react-table");
179
- var import_react3 = require("react");
180
- var import_styled_components7 = __toESM(require("styled-components"));
182
+ var import_jotai3 = require("jotai");
183
+ var import_react4 = require("react");
184
+ var import_styled_components8 = __toESM(require("styled-components"));
185
+
186
+ // src/DataTable/atoms.ts
187
+ var import_jotai = require("jotai");
188
+ var columnVisibilityAtom = (0, import_jotai.atom)({});
189
+ var globalFilterAtom = (0, import_jotai.atom)("");
190
+ var rowSelectionAtom = (0, import_jotai.atom)({});
191
+ var tableSortingAtom = (0, import_jotai.atom)([]);
181
192
 
182
193
  // src/DataTable/components/BasicTable.tsx
183
194
  var import_eds_core_react5 = require("@equinor/eds-core-react");
@@ -248,38 +259,154 @@ function BasicTable({ table, stickyHeader }) {
248
259
  });
249
260
  }
250
261
 
251
- // src/DataTable/components/DataTableHeader.tsx
252
- var import_eds_core_react7 = require("@equinor/eds-core-react");
253
- var import_styled_components6 = __toESM(require("styled-components"));
254
-
255
- // src/DataTable/filters/DebouncedInput.tsx
262
+ // src/DataTable/components/ColumnSelect.tsx
256
263
  var import_eds_core_react6 = require("@equinor/eds-core-react");
264
+ var import_eds_icons4 = require("@equinor/eds-icons");
257
265
  var import_react2 = require("react");
258
266
  var import_styled_components5 = __toESM(require("styled-components"));
259
267
  var import_jsx_runtime7 = require("react/jsx-runtime");
260
- var Wrapper3 = import_styled_components5.default.div`
261
- width: 300px;
268
+ var ColumnSelectContent = import_styled_components5.default.div`
269
+ display: grid;
270
+ grid-template-columns: repeat(2, 1fr);
271
+ grid-gap: 0.5rem;
272
+ `;
273
+ var ActionsWrapper = import_styled_components5.default.div`
274
+ display: flex;
275
+ align-items: center;
276
+ justify-content: flex-end;
277
+ gap: 0.5rem;
278
+ `;
279
+ function ColumnSelect({ table }) {
280
+ const [isOpen, setIsOpen] = (0, import_react2.useState)(false);
281
+ const referenceElement = (0, import_react2.useRef)(null);
282
+ const selectableColumns = table.getAllLeafColumns().filter((column) => column.id !== "select");
283
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, {
284
+ children: [
285
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Button, {
286
+ "aria-haspopup": true,
287
+ id: "column-select-anchor",
288
+ "aria-controls": "column-select-popover",
289
+ "aria-expanded": isOpen,
290
+ ref: referenceElement,
291
+ variant: "ghost_icon",
292
+ onClick: () => setIsOpen(true),
293
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Icon, {
294
+ name: "view_column",
295
+ data: import_eds_icons4.view_column
296
+ })
297
+ }),
298
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_eds_core_react6.Popover, {
299
+ open: isOpen,
300
+ id: "column-select-popover",
301
+ anchorEl: referenceElement.current,
302
+ placement: "bottom-end",
303
+ onClose: () => setIsOpen(false),
304
+ children: [
305
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_eds_core_react6.Popover.Header, {
306
+ children: [
307
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Popover.Title, {
308
+ children: "Column settings"
309
+ }),
310
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Button, {
311
+ variant: "ghost_icon",
312
+ "aria-label": "Close column select",
313
+ onClick: () => setIsOpen(false),
314
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Icon, {
315
+ name: "close",
316
+ data: import_eds_icons4.close,
317
+ size: 24
318
+ })
319
+ })
320
+ ]
321
+ }),
322
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_eds_core_react6.Popover.Content, {
323
+ children: [
324
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ColumnSelectContent, {
325
+ children: selectableColumns.map((column) => {
326
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Checkbox, {
327
+ checked: column.getIsVisible(),
328
+ label: column.id,
329
+ onChange: column.getToggleVisibilityHandler()
330
+ }, column.id);
331
+ })
332
+ }),
333
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Divider, {
334
+ variant: "small"
335
+ }),
336
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ActionsWrapper, {
337
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Button, {
338
+ color: "secondary",
339
+ variant: "ghost",
340
+ disabled: table.getIsAllColumnsVisible(),
341
+ onClick: () => table.toggleAllColumnsVisible(true),
342
+ children: "Reset to default"
343
+ })
344
+ })
345
+ ]
346
+ })
347
+ ]
348
+ })
349
+ ]
350
+ });
351
+ }
352
+
353
+ // src/DataTable/components/DataTableHeader.tsx
354
+ var import_eds_core_react8 = require("@equinor/eds-core-react");
355
+ var import_eds_icons6 = require("@equinor/eds-icons");
356
+ var import_jotai2 = require("jotai");
357
+ var import_styled_components7 = __toESM(require("styled-components"));
358
+
359
+ // src/DataTable/filters/DebouncedInput.tsx
360
+ var import_eds_core_react7 = require("@equinor/eds-core-react");
361
+ var import_eds_icons5 = require("@equinor/eds-icons");
362
+ var import_react3 = require("react");
363
+ var import_styled_components6 = __toESM(require("styled-components"));
364
+ var import_jsx_runtime8 = require("react/jsx-runtime");
365
+ var Wrapper3 = import_styled_components6.default.div`
366
+ width: 200px;
367
+ `;
368
+ var CloseButton = (0, import_styled_components6.default)(import_eds_core_react7.Button)`
369
+ width: 24px;
370
+ height: 24px;
262
371
  `;
263
372
  function DebouncedInput({
264
373
  value: initialValue,
265
374
  onChange,
375
+ icon,
266
376
  debounce = 500,
267
377
  ...props
268
378
  }) {
269
- const [value, setValue] = (0, import_react2.useState)(initialValue);
270
- (0, import_react2.useEffect)(() => {
379
+ const [value, setValue] = (0, import_react3.useState)(initialValue);
380
+ (0, import_react3.useEffect)(() => {
271
381
  setValue(initialValue);
272
382
  }, [initialValue]);
273
- (0, import_react2.useEffect)(() => {
383
+ (0, import_react3.useEffect)(() => {
274
384
  const timeout = setTimeout(() => {
275
385
  onChange(value);
276
386
  }, debounce);
277
387
  return () => clearTimeout(timeout);
278
388
  }, [value]);
279
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Wrapper3, {
280
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Input, {
389
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Wrapper3, {
390
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Input, {
281
391
  ...props,
282
392
  value,
393
+ leftAdornments: icon && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Icon, {
394
+ name: icon.name,
395
+ data: icon,
396
+ size: 18
397
+ }),
398
+ rightAdornments: !!value && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Tooltip, {
399
+ title: "Clear input",
400
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CloseButton, {
401
+ variant: "ghost_icon",
402
+ onClick: () => setValue(""),
403
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Icon, {
404
+ name: import_eds_icons5.close.name,
405
+ data: import_eds_icons5.close,
406
+ size: 18
407
+ })
408
+ })
409
+ }),
283
410
  onChange: (event) => setValue(event.target.value)
284
411
  })
285
412
  });
@@ -296,94 +423,98 @@ var fuzzyFilter = (row, columnId, value, addMeta) => {
296
423
  };
297
424
 
298
425
  // src/DataTable/components/DataTableHeader.tsx
299
- var import_jsx_runtime8 = require("react/jsx-runtime");
300
- var DataTableHeaderWrapper = import_styled_components6.default.div`
301
- & > * + * {
302
- margin-top: 0.5rem;
303
- }
426
+ var import_jsx_runtime9 = require("react/jsx-runtime");
427
+ var DataTableHeaderWrapper = import_styled_components7.default.div`
428
+ display: flex;
429
+ align-items: center;
430
+ justify-content: space-between;
304
431
  gap: 0.5rem;
305
432
  padding: ${(props) => props.captionPadding ?? "1rem"};
306
433
  `;
307
- var FilterContainer = import_styled_components6.default.div`
434
+ var FilterContainer = import_styled_components7.default.div`
308
435
  display: flex;
309
436
  align-items: center;
310
- gap: 0.5rem;
437
+ gap: 1rem;
438
+ justify-content: flex-end;
311
439
  `;
312
440
  var DataTableHeader = (props) => {
313
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(DataTableHeaderWrapper, {
441
+ const [globalFilter, setGlobalFilter] = (0, import_jotai2.useAtom)(globalFilterAtom);
442
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(DataTableHeaderWrapper, {
314
443
  className: "--table-caption",
315
444
  captionPadding: props.captionPadding,
316
445
  children: [
317
- (props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Typography, {
318
- variant: "h2",
446
+ (props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Typography, {
447
+ variant: "h3",
319
448
  children: props == null ? void 0 : props.tableCaption
320
449
  }),
321
- (props == null ? void 0 : props.enableGlobalFilter) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FilterContainer, {
450
+ (props == null ? void 0 : props.enableGlobalFilter) && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(FilterContainer, {
322
451
  className: "--filter-container",
323
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DebouncedInput, {
324
- value: props.globalFilter ?? "",
325
- placeholder: (props == null ? void 0 : props.globalFilterPlaceholder) ?? "Search all columns",
326
- onChange: (value) => {
327
- var _a;
328
- return (_a = props.setGlobalFilter) == null ? void 0 : _a.call(props, String(value));
329
- }
330
- })
452
+ children: [
453
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DebouncedInput, {
454
+ value: globalFilter,
455
+ icon: import_eds_icons6.search,
456
+ placeholder: (props == null ? void 0 : props.globalFilterPlaceholder) ?? "Search all columns",
457
+ onChange: (value) => setGlobalFilter(String(value))
458
+ }),
459
+ props.filterActions
460
+ ]
331
461
  })
332
462
  ]
333
463
  });
334
464
  };
335
465
 
336
466
  // src/DataTable/components/VirtualTable.tsx
337
- var import_eds_core_react9 = require("@equinor/eds-core-react");
467
+ var import_eds_core_react10 = require("@equinor/eds-core-react");
338
468
  var import_react_table3 = require("@tanstack/react-table");
339
469
  var import_react_virtual = require("@tanstack/react-virtual");
340
470
 
341
471
  // src/DataTable/components/PaddingRow.tsx
342
- var import_eds_core_react8 = require("@equinor/eds-core-react");
343
- var import_jsx_runtime9 = require("react/jsx-runtime");
472
+ var import_eds_core_react9 = require("@equinor/eds-core-react");
473
+ var import_jsx_runtime10 = require("react/jsx-runtime");
344
474
  var PaddingRow = (props) => {
345
475
  if (!props.height)
346
476
  return null;
347
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Table.Row, {
348
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Table.Cell, {
477
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_eds_core_react9.Table.Row, {
478
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_eds_core_react9.Table.Cell, {
349
479
  style: { height: `${props.height}px` }
350
480
  })
351
481
  });
352
482
  };
353
483
 
354
484
  // src/DataTable/components/VirtualTable.tsx
355
- var import_jsx_runtime10 = require("react/jsx-runtime");
485
+ var import_jsx_runtime11 = require("react/jsx-runtime");
356
486
  function VirtualTable({ table, containerRef, ...props }) {
357
487
  var _a, _b;
358
488
  const { rows } = table.getRowModel();
359
- const rowVirtualizer = (0, import_react_virtual.useVirtual)({
360
- overscan: 10,
361
- size: rows.length,
362
- parentRef: containerRef
489
+ const rowVirtualizer = (0, import_react_virtual.useVirtualizer)({
490
+ count: rows.length,
491
+ estimateSize: () => 35,
492
+ getScrollElement: () => containerRef.current
363
493
  });
364
- const { virtualItems: virtualRows, totalSize } = rowVirtualizer;
494
+ const virtualRows = rowVirtualizer.getVirtualItems();
365
495
  const paddingTop = virtualRows.length > 0 ? ((_a = virtualRows == null ? void 0 : virtualRows[0]) == null ? void 0 : _a.start) || 0 : 0;
366
- const paddingBottom = virtualRows.length > 0 ? totalSize - (((_b = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b.end) || 0) : 0;
367
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_eds_core_react9.Table, {
496
+ const paddingBottom = virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (((_b = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b.end) || 0) : 0;
497
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_eds_core_react10.Table, {
368
498
  children: [
369
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TableHeader, {
499
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TableHeader, {
370
500
  sticky: props.stickyHeader,
371
501
  table
372
502
  }),
373
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_eds_core_react9.Table.Body, {
503
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_eds_core_react10.Table.Body, {
374
504
  children: [
375
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PaddingRow, {
505
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PaddingRow, {
376
506
  height: paddingTop
377
507
  }),
378
508
  virtualRows.map((virtualRow) => {
379
509
  const row = rows[virtualRow.index];
380
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_eds_core_react9.Table.Row, {
381
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_eds_core_react9.Table.Cell, {
510
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_eds_core_react10.Table.Row, {
511
+ active: row.getIsSelected(),
512
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_eds_core_react10.Table.Cell, {
382
513
  children: (0, import_react_table3.flexRender)(cell.column.columnDef.cell, cell.getContext())
383
514
  }, cell.id))
384
515
  }, row.id);
385
516
  }),
386
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PaddingRow, {
517
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PaddingRow, {
387
518
  height: paddingBottom
388
519
  })
389
520
  ]
@@ -392,14 +523,42 @@ function VirtualTable({ table, containerRef, ...props }) {
392
523
  });
393
524
  }
394
525
 
395
- // src/DataTable/utils.ts
526
+ // src/DataTable/utils.tsx
527
+ var import_eds_core_react11 = require("@equinor/eds-core-react");
528
+ var import_jsx_runtime12 = require("react/jsx-runtime");
396
529
  function enableOrUndefined(enabled, value) {
397
530
  return Boolean(enabled) ? value : void 0;
398
531
  }
532
+ function prependSelectColumnIfEnabled(columns, config) {
533
+ if (!(config == null ? void 0 : config.enableRowSelection))
534
+ return columns;
535
+ const selectColumn = {
536
+ id: "select",
537
+ header: ({ table }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", {
538
+ style: { width: "48px" },
539
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Checkbox, {
540
+ checked: table.getIsAllRowsSelected(),
541
+ indeterminate: table.getIsSomeRowsSelected(),
542
+ "aria-label": table.getIsAllRowsSelected() ? "Deselect all rows" : "Select all rows",
543
+ onChange: table.getToggleAllRowsSelectedHandler()
544
+ })
545
+ }),
546
+ cell: ({ row }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", {
547
+ style: { width: "48px" },
548
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Checkbox, {
549
+ checked: row.getIsSelected(),
550
+ indeterminate: row.getIsSomeSelected(),
551
+ "aria-label": `Select ${row.getValue("name")}`,
552
+ onChange: row.getToggleSelectedHandler()
553
+ })
554
+ })
555
+ };
556
+ return [selectColumn, ...columns];
557
+ }
399
558
 
400
559
  // src/DataTable/DataTable.tsx
401
- var import_jsx_runtime11 = require("react/jsx-runtime");
402
- var DataTableWrapper = import_styled_components7.default.div`
560
+ var import_jsx_runtime13 = require("react/jsx-runtime");
561
+ var DataTableWrapper = import_styled_components8.default.div`
403
562
  width: ${(props) => props.width ?? "100%"};
404
563
 
405
564
  .--table-container {
@@ -413,48 +572,55 @@ var DataTableWrapper = import_styled_components7.default.div`
413
572
  }
414
573
  `;
415
574
  function DataTable({ columns, data, header, filters, config }) {
416
- const [globalFilter, setGlobalFilter] = (0, import_react3.useState)("");
575
+ const [columnVisibility, setColumnVisibility] = (0, import_jotai3.useAtom)(columnVisibilityAtom);
576
+ const [globalFilter, setGlobalFilter] = (0, import_jotai3.useAtom)(globalFilterAtom);
577
+ const [sorting, setSorting] = (0, import_jotai3.useAtom)(tableSortingAtom);
578
+ const [rowSelectionState, setRowSelectionState] = (0, import_jotai3.useAtom)(rowSelectionAtom);
417
579
  function enableGlobalFilter(value) {
418
580
  return enableOrUndefined(filters == null ? void 0 : filters.globalFilter, value);
419
581
  }
420
- const [sorting, setSorting] = (0, import_react3.useState)([]);
421
582
  const table = (0, import_react_table4.useReactTable)({
422
- columns,
583
+ columns: prependSelectColumnIfEnabled(columns, config),
423
584
  data,
424
585
  getCoreRowModel: (0, import_react_table4.getCoreRowModel)(),
425
586
  getFilteredRowModel: enableGlobalFilter((0, import_react_table4.getFilteredRowModel)()),
426
587
  globalFilterFn: enableGlobalFilter(fuzzyFilter),
427
588
  state: {
428
589
  globalFilter: enableGlobalFilter(globalFilter),
429
- sorting
590
+ sorting: enableOrUndefined(config == null ? void 0 : config.sortable, sorting),
591
+ rowSelection: rowSelectionState,
592
+ columnVisibility
430
593
  },
594
+ onRowSelectionChange: setRowSelectionState,
431
595
  enableSorting: config == null ? void 0 : config.sortable,
432
- onSortingChange: setSorting,
596
+ onSortingChange: enableOrUndefined(config == null ? void 0 : config.sortable, setSorting),
433
597
  getSortedRowModel: (0, import_react_table4.getSortedRowModel)(),
598
+ onColumnVisibilityChange: setColumnVisibility,
434
599
  onGlobalFilterChange: enableGlobalFilter(setGlobalFilter)
435
600
  });
436
- const tableContainerRef = (0, import_react3.useRef)(null);
437
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(DataTableWrapper, {
601
+ const tableContainerRef = (0, import_react4.useRef)(null);
602
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(DataTableWrapper, {
438
603
  captionPadding: header == null ? void 0 : header.captionPadding,
439
604
  height: config == null ? void 0 : config.height,
440
605
  width: config == null ? void 0 : config.width,
441
606
  children: [
442
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DataTableHeader, {
607
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DataTableHeader, {
443
608
  tableCaption: header == null ? void 0 : header.tableCaption,
444
609
  enableGlobalFilter: filters == null ? void 0 : filters.globalFilter,
445
- globalFilter,
446
- setGlobalFilter,
447
610
  globalFilterPlaceholder: filters == null ? void 0 : filters.globalFilterPlaceholder,
448
- captionPadding: header == null ? void 0 : header.captionPadding
611
+ captionPadding: header == null ? void 0 : header.captionPadding,
612
+ filterActions: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ColumnSelect, {
613
+ table
614
+ })
449
615
  }),
450
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", {
616
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", {
451
617
  ref: tableContainerRef,
452
618
  className: "--table-container",
453
- children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(VirtualTable, {
619
+ children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(VirtualTable, {
454
620
  containerRef: tableContainerRef,
455
621
  table,
456
622
  stickyHeader: header == null ? void 0 : header.stickyHeader
457
- }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(BasicTable, {
623
+ }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(BasicTable, {
458
624
  table,
459
625
  stickyHeader: header == null ? void 0 : header.stickyHeader
460
626
  })
@@ -462,10 +628,27 @@ function DataTable({ columns, data, header, filters, config }) {
462
628
  ]
463
629
  });
464
630
  }
631
+
632
+ // src/DataTable/Provider.tsx
633
+ var import_jotai4 = require("jotai");
634
+ var import_jsx_runtime14 = require("react/jsx-runtime");
635
+ function DataTableProvider({ children, ...props }) {
636
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jotai4.Provider, {
637
+ ...props,
638
+ children
639
+ });
640
+ }
641
+
642
+ // src/DataTable/index.ts
643
+ var DataTable2 = DataTable;
644
+ DataTable2.Provider = DataTableProvider;
465
645
  // Annotate the CommonJS export names for ESM import in node:
466
646
  0 && (module.exports = {
467
647
  AppShell,
468
648
  AppSidebar,
469
649
  ChipsCell,
470
- DataTable
650
+ DataTable,
651
+ globalFilterAtom,
652
+ rowSelectionAtom,
653
+ tableSortingAtom
471
654
  });
package/dist/index.mjs CHANGED
@@ -146,8 +146,16 @@ import {
146
146
  getSortedRowModel,
147
147
  useReactTable
148
148
  } from "@tanstack/react-table";
149
- import { useRef, useState as useState3 } from "react";
150
- import styled7 from "styled-components";
149
+ import { useAtom as useAtom2 } from "jotai";
150
+ import { useRef as useRef2 } from "react";
151
+ import styled8 from "styled-components";
152
+
153
+ // src/DataTable/atoms.ts
154
+ import { atom } from "jotai";
155
+ var columnVisibilityAtom = atom({});
156
+ var globalFilterAtom = atom("");
157
+ var rowSelectionAtom = atom({});
158
+ var tableSortingAtom = atom([]);
151
159
 
152
160
  // src/DataTable/components/BasicTable.tsx
153
161
  import { Table as EdsTable } from "@equinor/eds-core-react";
@@ -218,25 +226,124 @@ function BasicTable({ table, stickyHeader }) {
218
226
  });
219
227
  }
220
228
 
229
+ // src/DataTable/components/ColumnSelect.tsx
230
+ import { Button as Button2, Checkbox, Divider, Icon as Icon4, Popover } from "@equinor/eds-core-react";
231
+ import { close, view_column } from "@equinor/eds-icons";
232
+ import { useRef, useState as useState2 } from "react";
233
+ import styled5 from "styled-components";
234
+ import { Fragment, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
235
+ var ColumnSelectContent = styled5.div`
236
+ display: grid;
237
+ grid-template-columns: repeat(2, 1fr);
238
+ grid-gap: 0.5rem;
239
+ `;
240
+ var ActionsWrapper = styled5.div`
241
+ display: flex;
242
+ align-items: center;
243
+ justify-content: flex-end;
244
+ gap: 0.5rem;
245
+ `;
246
+ function ColumnSelect({ table }) {
247
+ const [isOpen, setIsOpen] = useState2(false);
248
+ const referenceElement = useRef(null);
249
+ const selectableColumns = table.getAllLeafColumns().filter((column) => column.id !== "select");
250
+ return /* @__PURE__ */ jsxs5(Fragment, {
251
+ children: [
252
+ /* @__PURE__ */ jsx7(Button2, {
253
+ "aria-haspopup": true,
254
+ id: "column-select-anchor",
255
+ "aria-controls": "column-select-popover",
256
+ "aria-expanded": isOpen,
257
+ ref: referenceElement,
258
+ variant: "ghost_icon",
259
+ onClick: () => setIsOpen(true),
260
+ children: /* @__PURE__ */ jsx7(Icon4, {
261
+ name: "view_column",
262
+ data: view_column
263
+ })
264
+ }),
265
+ /* @__PURE__ */ jsxs5(Popover, {
266
+ open: isOpen,
267
+ id: "column-select-popover",
268
+ anchorEl: referenceElement.current,
269
+ placement: "bottom-end",
270
+ onClose: () => setIsOpen(false),
271
+ children: [
272
+ /* @__PURE__ */ jsxs5(Popover.Header, {
273
+ children: [
274
+ /* @__PURE__ */ jsx7(Popover.Title, {
275
+ children: "Column settings"
276
+ }),
277
+ /* @__PURE__ */ jsx7(Button2, {
278
+ variant: "ghost_icon",
279
+ "aria-label": "Close column select",
280
+ onClick: () => setIsOpen(false),
281
+ children: /* @__PURE__ */ jsx7(Icon4, {
282
+ name: "close",
283
+ data: close,
284
+ size: 24
285
+ })
286
+ })
287
+ ]
288
+ }),
289
+ /* @__PURE__ */ jsxs5(Popover.Content, {
290
+ children: [
291
+ /* @__PURE__ */ jsx7(ColumnSelectContent, {
292
+ children: selectableColumns.map((column) => {
293
+ return /* @__PURE__ */ jsx7(Checkbox, {
294
+ checked: column.getIsVisible(),
295
+ label: column.id,
296
+ onChange: column.getToggleVisibilityHandler()
297
+ }, column.id);
298
+ })
299
+ }),
300
+ /* @__PURE__ */ jsx7(Divider, {
301
+ variant: "small"
302
+ }),
303
+ /* @__PURE__ */ jsx7(ActionsWrapper, {
304
+ children: /* @__PURE__ */ jsx7(Button2, {
305
+ color: "secondary",
306
+ variant: "ghost",
307
+ disabled: table.getIsAllColumnsVisible(),
308
+ onClick: () => table.toggleAllColumnsVisible(true),
309
+ children: "Reset to default"
310
+ })
311
+ })
312
+ ]
313
+ })
314
+ ]
315
+ })
316
+ ]
317
+ });
318
+ }
319
+
221
320
  // src/DataTable/components/DataTableHeader.tsx
222
321
  import { Typography } from "@equinor/eds-core-react";
223
- import styled6 from "styled-components";
322
+ import { search } from "@equinor/eds-icons";
323
+ import { useAtom } from "jotai";
324
+ import styled7 from "styled-components";
224
325
 
225
326
  // src/DataTable/filters/DebouncedInput.tsx
226
- import { Input } from "@equinor/eds-core-react";
227
- import { useEffect, useState as useState2 } from "react";
228
- import styled5 from "styled-components";
229
- import { jsx as jsx7 } from "react/jsx-runtime";
230
- var Wrapper3 = styled5.div`
231
- width: 300px;
327
+ import { Button as Button3, Icon as Icon5, Input, Tooltip } from "@equinor/eds-core-react";
328
+ import { close as close2 } from "@equinor/eds-icons";
329
+ import { useEffect, useState as useState3 } from "react";
330
+ import styled6 from "styled-components";
331
+ import { jsx as jsx8 } from "react/jsx-runtime";
332
+ var Wrapper3 = styled6.div`
333
+ width: 200px;
334
+ `;
335
+ var CloseButton = styled6(Button3)`
336
+ width: 24px;
337
+ height: 24px;
232
338
  `;
233
339
  function DebouncedInput({
234
340
  value: initialValue,
235
341
  onChange,
342
+ icon,
236
343
  debounce = 500,
237
344
  ...props
238
345
  }) {
239
- const [value, setValue] = useState2(initialValue);
346
+ const [value, setValue] = useState3(initialValue);
240
347
  useEffect(() => {
241
348
  setValue(initialValue);
242
349
  }, [initialValue]);
@@ -246,10 +353,27 @@ function DebouncedInput({
246
353
  }, debounce);
247
354
  return () => clearTimeout(timeout);
248
355
  }, [value]);
249
- return /* @__PURE__ */ jsx7(Wrapper3, {
250
- children: /* @__PURE__ */ jsx7(Input, {
356
+ return /* @__PURE__ */ jsx8(Wrapper3, {
357
+ children: /* @__PURE__ */ jsx8(Input, {
251
358
  ...props,
252
359
  value,
360
+ leftAdornments: icon && /* @__PURE__ */ jsx8(Icon5, {
361
+ name: icon.name,
362
+ data: icon,
363
+ size: 18
364
+ }),
365
+ rightAdornments: !!value && /* @__PURE__ */ jsx8(Tooltip, {
366
+ title: "Clear input",
367
+ children: /* @__PURE__ */ jsx8(CloseButton, {
368
+ variant: "ghost_icon",
369
+ onClick: () => setValue(""),
370
+ children: /* @__PURE__ */ jsx8(Icon5, {
371
+ name: close2.name,
372
+ data: close2,
373
+ size: 18
374
+ })
375
+ })
376
+ }),
253
377
  onChange: (event) => setValue(event.target.value)
254
378
  })
255
379
  });
@@ -266,38 +390,41 @@ var fuzzyFilter = (row, columnId, value, addMeta) => {
266
390
  };
267
391
 
268
392
  // src/DataTable/components/DataTableHeader.tsx
269
- import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
270
- var DataTableHeaderWrapper = styled6.div`
271
- & > * + * {
272
- margin-top: 0.5rem;
273
- }
393
+ import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
394
+ var DataTableHeaderWrapper = styled7.div`
395
+ display: flex;
396
+ align-items: center;
397
+ justify-content: space-between;
274
398
  gap: 0.5rem;
275
399
  padding: ${(props) => props.captionPadding ?? "1rem"};
276
400
  `;
277
- var FilterContainer = styled6.div`
401
+ var FilterContainer = styled7.div`
278
402
  display: flex;
279
403
  align-items: center;
280
- gap: 0.5rem;
404
+ gap: 1rem;
405
+ justify-content: flex-end;
281
406
  `;
282
407
  var DataTableHeader = (props) => {
283
- return /* @__PURE__ */ jsxs5(DataTableHeaderWrapper, {
408
+ const [globalFilter, setGlobalFilter] = useAtom(globalFilterAtom);
409
+ return /* @__PURE__ */ jsxs6(DataTableHeaderWrapper, {
284
410
  className: "--table-caption",
285
411
  captionPadding: props.captionPadding,
286
412
  children: [
287
- (props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ jsx8(Typography, {
288
- variant: "h2",
413
+ (props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ jsx9(Typography, {
414
+ variant: "h3",
289
415
  children: props == null ? void 0 : props.tableCaption
290
416
  }),
291
- (props == null ? void 0 : props.enableGlobalFilter) && /* @__PURE__ */ jsx8(FilterContainer, {
417
+ (props == null ? void 0 : props.enableGlobalFilter) && /* @__PURE__ */ jsxs6(FilterContainer, {
292
418
  className: "--filter-container",
293
- children: /* @__PURE__ */ jsx8(DebouncedInput, {
294
- value: props.globalFilter ?? "",
295
- placeholder: (props == null ? void 0 : props.globalFilterPlaceholder) ?? "Search all columns",
296
- onChange: (value) => {
297
- var _a;
298
- return (_a = props.setGlobalFilter) == null ? void 0 : _a.call(props, String(value));
299
- }
300
- })
419
+ children: [
420
+ /* @__PURE__ */ jsx9(DebouncedInput, {
421
+ value: globalFilter,
422
+ icon: search,
423
+ placeholder: (props == null ? void 0 : props.globalFilterPlaceholder) ?? "Search all columns",
424
+ onChange: (value) => setGlobalFilter(String(value))
425
+ }),
426
+ props.filterActions
427
+ ]
301
428
  })
302
429
  ]
303
430
  });
@@ -306,54 +433,55 @@ var DataTableHeader = (props) => {
306
433
  // src/DataTable/components/VirtualTable.tsx
307
434
  import { Table as Table5 } from "@equinor/eds-core-react";
308
435
  import { flexRender as flexRender3 } from "@tanstack/react-table";
309
- import { useVirtual } from "@tanstack/react-virtual";
436
+ import { useVirtualizer } from "@tanstack/react-virtual";
310
437
 
311
438
  // src/DataTable/components/PaddingRow.tsx
312
439
  import { Table as Table4 } from "@equinor/eds-core-react";
313
- import { jsx as jsx9 } from "react/jsx-runtime";
440
+ import { jsx as jsx10 } from "react/jsx-runtime";
314
441
  var PaddingRow = (props) => {
315
442
  if (!props.height)
316
443
  return null;
317
- return /* @__PURE__ */ jsx9(Table4.Row, {
318
- children: /* @__PURE__ */ jsx9(Table4.Cell, {
444
+ return /* @__PURE__ */ jsx10(Table4.Row, {
445
+ children: /* @__PURE__ */ jsx10(Table4.Cell, {
319
446
  style: { height: `${props.height}px` }
320
447
  })
321
448
  });
322
449
  };
323
450
 
324
451
  // src/DataTable/components/VirtualTable.tsx
325
- import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
452
+ import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
326
453
  function VirtualTable({ table, containerRef, ...props }) {
327
454
  var _a, _b;
328
455
  const { rows } = table.getRowModel();
329
- const rowVirtualizer = useVirtual({
330
- overscan: 10,
331
- size: rows.length,
332
- parentRef: containerRef
456
+ const rowVirtualizer = useVirtualizer({
457
+ count: rows.length,
458
+ estimateSize: () => 35,
459
+ getScrollElement: () => containerRef.current
333
460
  });
334
- const { virtualItems: virtualRows, totalSize } = rowVirtualizer;
461
+ const virtualRows = rowVirtualizer.getVirtualItems();
335
462
  const paddingTop = virtualRows.length > 0 ? ((_a = virtualRows == null ? void 0 : virtualRows[0]) == null ? void 0 : _a.start) || 0 : 0;
336
- const paddingBottom = virtualRows.length > 0 ? totalSize - (((_b = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b.end) || 0) : 0;
337
- return /* @__PURE__ */ jsxs6(Table5, {
463
+ const paddingBottom = virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (((_b = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b.end) || 0) : 0;
464
+ return /* @__PURE__ */ jsxs7(Table5, {
338
465
  children: [
339
- /* @__PURE__ */ jsx10(TableHeader, {
466
+ /* @__PURE__ */ jsx11(TableHeader, {
340
467
  sticky: props.stickyHeader,
341
468
  table
342
469
  }),
343
- /* @__PURE__ */ jsxs6(Table5.Body, {
470
+ /* @__PURE__ */ jsxs7(Table5.Body, {
344
471
  children: [
345
- /* @__PURE__ */ jsx10(PaddingRow, {
472
+ /* @__PURE__ */ jsx11(PaddingRow, {
346
473
  height: paddingTop
347
474
  }),
348
475
  virtualRows.map((virtualRow) => {
349
476
  const row = rows[virtualRow.index];
350
- return /* @__PURE__ */ jsx10(Table5.Row, {
351
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx10(Table5.Cell, {
477
+ return /* @__PURE__ */ jsx11(Table5.Row, {
478
+ active: row.getIsSelected(),
479
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx11(Table5.Cell, {
352
480
  children: flexRender3(cell.column.columnDef.cell, cell.getContext())
353
481
  }, cell.id))
354
482
  }, row.id);
355
483
  }),
356
- /* @__PURE__ */ jsx10(PaddingRow, {
484
+ /* @__PURE__ */ jsx11(PaddingRow, {
357
485
  height: paddingBottom
358
486
  })
359
487
  ]
@@ -362,14 +490,42 @@ function VirtualTable({ table, containerRef, ...props }) {
362
490
  });
363
491
  }
364
492
 
365
- // src/DataTable/utils.ts
493
+ // src/DataTable/utils.tsx
494
+ import { Checkbox as Checkbox2 } from "@equinor/eds-core-react";
495
+ import { jsx as jsx12 } from "react/jsx-runtime";
366
496
  function enableOrUndefined(enabled, value) {
367
497
  return Boolean(enabled) ? value : void 0;
368
498
  }
499
+ function prependSelectColumnIfEnabled(columns, config) {
500
+ if (!(config == null ? void 0 : config.enableRowSelection))
501
+ return columns;
502
+ const selectColumn = {
503
+ id: "select",
504
+ header: ({ table }) => /* @__PURE__ */ jsx12("div", {
505
+ style: { width: "48px" },
506
+ children: /* @__PURE__ */ jsx12(Checkbox2, {
507
+ checked: table.getIsAllRowsSelected(),
508
+ indeterminate: table.getIsSomeRowsSelected(),
509
+ "aria-label": table.getIsAllRowsSelected() ? "Deselect all rows" : "Select all rows",
510
+ onChange: table.getToggleAllRowsSelectedHandler()
511
+ })
512
+ }),
513
+ cell: ({ row }) => /* @__PURE__ */ jsx12("div", {
514
+ style: { width: "48px" },
515
+ children: /* @__PURE__ */ jsx12(Checkbox2, {
516
+ checked: row.getIsSelected(),
517
+ indeterminate: row.getIsSomeSelected(),
518
+ "aria-label": `Select ${row.getValue("name")}`,
519
+ onChange: row.getToggleSelectedHandler()
520
+ })
521
+ })
522
+ };
523
+ return [selectColumn, ...columns];
524
+ }
369
525
 
370
526
  // src/DataTable/DataTable.tsx
371
- import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
372
- var DataTableWrapper = styled7.div`
527
+ import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
528
+ var DataTableWrapper = styled8.div`
373
529
  width: ${(props) => props.width ?? "100%"};
374
530
 
375
531
  .--table-container {
@@ -383,48 +539,55 @@ var DataTableWrapper = styled7.div`
383
539
  }
384
540
  `;
385
541
  function DataTable({ columns, data, header, filters, config }) {
386
- const [globalFilter, setGlobalFilter] = useState3("");
542
+ const [columnVisibility, setColumnVisibility] = useAtom2(columnVisibilityAtom);
543
+ const [globalFilter, setGlobalFilter] = useAtom2(globalFilterAtom);
544
+ const [sorting, setSorting] = useAtom2(tableSortingAtom);
545
+ const [rowSelectionState, setRowSelectionState] = useAtom2(rowSelectionAtom);
387
546
  function enableGlobalFilter(value) {
388
547
  return enableOrUndefined(filters == null ? void 0 : filters.globalFilter, value);
389
548
  }
390
- const [sorting, setSorting] = useState3([]);
391
549
  const table = useReactTable({
392
- columns,
550
+ columns: prependSelectColumnIfEnabled(columns, config),
393
551
  data,
394
552
  getCoreRowModel: getCoreRowModel(),
395
553
  getFilteredRowModel: enableGlobalFilter(getFilteredRowModel()),
396
554
  globalFilterFn: enableGlobalFilter(fuzzyFilter),
397
555
  state: {
398
556
  globalFilter: enableGlobalFilter(globalFilter),
399
- sorting
557
+ sorting: enableOrUndefined(config == null ? void 0 : config.sortable, sorting),
558
+ rowSelection: rowSelectionState,
559
+ columnVisibility
400
560
  },
561
+ onRowSelectionChange: setRowSelectionState,
401
562
  enableSorting: config == null ? void 0 : config.sortable,
402
- onSortingChange: setSorting,
563
+ onSortingChange: enableOrUndefined(config == null ? void 0 : config.sortable, setSorting),
403
564
  getSortedRowModel: getSortedRowModel(),
565
+ onColumnVisibilityChange: setColumnVisibility,
404
566
  onGlobalFilterChange: enableGlobalFilter(setGlobalFilter)
405
567
  });
406
- const tableContainerRef = useRef(null);
407
- return /* @__PURE__ */ jsxs7(DataTableWrapper, {
568
+ const tableContainerRef = useRef2(null);
569
+ return /* @__PURE__ */ jsxs8(DataTableWrapper, {
408
570
  captionPadding: header == null ? void 0 : header.captionPadding,
409
571
  height: config == null ? void 0 : config.height,
410
572
  width: config == null ? void 0 : config.width,
411
573
  children: [
412
- /* @__PURE__ */ jsx11(DataTableHeader, {
574
+ /* @__PURE__ */ jsx13(DataTableHeader, {
413
575
  tableCaption: header == null ? void 0 : header.tableCaption,
414
576
  enableGlobalFilter: filters == null ? void 0 : filters.globalFilter,
415
- globalFilter,
416
- setGlobalFilter,
417
577
  globalFilterPlaceholder: filters == null ? void 0 : filters.globalFilterPlaceholder,
418
- captionPadding: header == null ? void 0 : header.captionPadding
578
+ captionPadding: header == null ? void 0 : header.captionPadding,
579
+ filterActions: /* @__PURE__ */ jsx13(ColumnSelect, {
580
+ table
581
+ })
419
582
  }),
420
- /* @__PURE__ */ jsx11("div", {
583
+ /* @__PURE__ */ jsx13("div", {
421
584
  ref: tableContainerRef,
422
585
  className: "--table-container",
423
- children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ jsx11(VirtualTable, {
586
+ children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ jsx13(VirtualTable, {
424
587
  containerRef: tableContainerRef,
425
588
  table,
426
589
  stickyHeader: header == null ? void 0 : header.stickyHeader
427
- }) : /* @__PURE__ */ jsx11(BasicTable, {
590
+ }) : /* @__PURE__ */ jsx13(BasicTable, {
428
591
  table,
429
592
  stickyHeader: header == null ? void 0 : header.stickyHeader
430
593
  })
@@ -432,9 +595,26 @@ function DataTable({ columns, data, header, filters, config }) {
432
595
  ]
433
596
  });
434
597
  }
598
+
599
+ // src/DataTable/Provider.tsx
600
+ import { Provider } from "jotai";
601
+ import { jsx as jsx14 } from "react/jsx-runtime";
602
+ function DataTableProvider({ children, ...props }) {
603
+ return /* @__PURE__ */ jsx14(Provider, {
604
+ ...props,
605
+ children
606
+ });
607
+ }
608
+
609
+ // src/DataTable/index.ts
610
+ var DataTable2 = DataTable;
611
+ DataTable2.Provider = DataTableProvider;
435
612
  export {
436
613
  AppShell,
437
614
  AppSidebar,
438
615
  ChipsCell,
439
- DataTable
616
+ DataTable2 as DataTable,
617
+ globalFilterAtom,
618
+ rowSelectionAtom,
619
+ tableSortingAtom
440
620
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/apollo-components",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -17,12 +17,13 @@
17
17
  "storybook": "storybook dev"
18
18
  },
19
19
  "dependencies": {
20
- "@equinor/eds-core-react": "^0.24.0",
20
+ "@equinor/eds-core-react": "^0.27.0",
21
21
  "@equinor/eds-icons": "^0.15.0",
22
22
  "@equinor/eds-tokens": "^0.9.0",
23
23
  "@tanstack/match-sorter-utils": "^8.5.14",
24
24
  "@tanstack/react-table": "^8.5.15",
25
25
  "@tanstack/react-virtual": "^3.0.0-beta.23",
26
+ "jotai": "^1.10.0",
26
27
  "styled-components": "^5.3.6",
27
28
  "tsup": "^6.3.0"
28
29
  },