@equinor/apollo-components 1.0.1 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -16,20 +16,30 @@ declare const ChipsCell: (props: {
16
16
  values?: string[];
17
17
  }) => JSX.Element;
18
18
 
19
- interface DataTableProps<T> {
20
- className?: string;
21
- columns: ColumnDef<T, any>[];
22
- data: T[];
23
- tableCaption?: string;
19
+ interface HeaderConfig {
24
20
  captionPadding?: string;
21
+ stickyHeader?: boolean;
22
+ tableCaption?: string;
23
+ }
24
+ interface FilterConfig {
25
25
  globalFilter?: boolean;
26
26
  globalFilterPlaceholder?: string;
27
- stickyHeader?: boolean;
28
- tableWidth?: string;
27
+ }
28
+ interface DataTableConfig {
29
+ height?: string;
29
30
  sortable?: boolean;
30
31
  virtual?: boolean;
31
- height?: string;
32
+ width?: string;
33
+ }
34
+
35
+ interface DataTableProps<T> {
36
+ className?: string;
37
+ columns: ColumnDef<T, any>[];
38
+ config?: DataTableConfig;
39
+ data: T[];
40
+ filters?: FilterConfig;
41
+ header?: HeaderConfig;
32
42
  }
33
- declare function DataTable<T>({ columns, data, ...props }: DataTableProps<T>): JSX.Element;
43
+ declare function DataTable<T>({ columns, data, header, filters, config }: DataTableProps<T>): JSX.Element;
34
44
 
35
- export { AppShell, AppSidebar, ChipsCell, DataTable };
45
+ export { AppShell, AppSidebar, ChipsCell, DataTable, DataTableConfig, FilterConfig, HeaderConfig };
package/dist/index.js CHANGED
@@ -412,10 +412,10 @@ var DataTableWrapper = import_styled_components7.default.div`
412
412
  }
413
413
  }
414
414
  `;
415
- function DataTable({ columns, data, ...props }) {
415
+ function DataTable({ columns, data, header, filters, config }) {
416
416
  const [globalFilter, setGlobalFilter] = (0, import_react3.useState)("");
417
417
  function enableGlobalFilter(value) {
418
- return enableOrUndefined(props.globalFilter, value);
418
+ return enableOrUndefined(filters == null ? void 0 : filters.globalFilter, value);
419
419
  }
420
420
  const [sorting, setSorting] = (0, import_react3.useState)([]);
421
421
  const table = (0, import_react_table4.useReactTable)({
@@ -428,35 +428,35 @@ function DataTable({ columns, data, ...props }) {
428
428
  globalFilter: enableGlobalFilter(globalFilter),
429
429
  sorting
430
430
  },
431
- enableSorting: props.sortable,
431
+ enableSorting: config == null ? void 0 : config.sortable,
432
432
  onSortingChange: setSorting,
433
433
  getSortedRowModel: (0, import_react_table4.getSortedRowModel)(),
434
434
  onGlobalFilterChange: enableGlobalFilter(setGlobalFilter)
435
435
  });
436
436
  const tableContainerRef = (0, import_react3.useRef)(null);
437
437
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(DataTableWrapper, {
438
- captionPadding: props.captionPadding,
439
- height: props.height,
440
- width: props.tableWidth,
438
+ captionPadding: header == null ? void 0 : header.captionPadding,
439
+ height: config == null ? void 0 : config.height,
440
+ width: config == null ? void 0 : config.width,
441
441
  children: [
442
442
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DataTableHeader, {
443
- tableCaption: props.tableCaption,
444
- enableGlobalFilter: props.globalFilter,
443
+ tableCaption: header == null ? void 0 : header.tableCaption,
444
+ enableGlobalFilter: filters == null ? void 0 : filters.globalFilter,
445
445
  globalFilter,
446
446
  setGlobalFilter,
447
- globalFilterPlaceholder: props.globalFilterPlaceholder,
448
- captionPadding: props.captionPadding
447
+ globalFilterPlaceholder: filters == null ? void 0 : filters.globalFilterPlaceholder,
448
+ captionPadding: header == null ? void 0 : header.captionPadding
449
449
  }),
450
450
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", {
451
451
  ref: tableContainerRef,
452
452
  className: "--table-container",
453
- children: props.virtual ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(VirtualTable, {
453
+ children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(VirtualTable, {
454
454
  containerRef: tableContainerRef,
455
455
  table,
456
- stickyHeader: props.stickyHeader
456
+ stickyHeader: header == null ? void 0 : header.stickyHeader
457
457
  }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(BasicTable, {
458
458
  table,
459
- stickyHeader: props.stickyHeader
459
+ stickyHeader: header == null ? void 0 : header.stickyHeader
460
460
  })
461
461
  })
462
462
  ]
package/dist/index.mjs CHANGED
@@ -382,10 +382,10 @@ var DataTableWrapper = styled7.div`
382
382
  }
383
383
  }
384
384
  `;
385
- function DataTable({ columns, data, ...props }) {
385
+ function DataTable({ columns, data, header, filters, config }) {
386
386
  const [globalFilter, setGlobalFilter] = useState3("");
387
387
  function enableGlobalFilter(value) {
388
- return enableOrUndefined(props.globalFilter, value);
388
+ return enableOrUndefined(filters == null ? void 0 : filters.globalFilter, value);
389
389
  }
390
390
  const [sorting, setSorting] = useState3([]);
391
391
  const table = useReactTable({
@@ -398,35 +398,35 @@ function DataTable({ columns, data, ...props }) {
398
398
  globalFilter: enableGlobalFilter(globalFilter),
399
399
  sorting
400
400
  },
401
- enableSorting: props.sortable,
401
+ enableSorting: config == null ? void 0 : config.sortable,
402
402
  onSortingChange: setSorting,
403
403
  getSortedRowModel: getSortedRowModel(),
404
404
  onGlobalFilterChange: enableGlobalFilter(setGlobalFilter)
405
405
  });
406
406
  const tableContainerRef = useRef(null);
407
407
  return /* @__PURE__ */ jsxs7(DataTableWrapper, {
408
- captionPadding: props.captionPadding,
409
- height: props.height,
410
- width: props.tableWidth,
408
+ captionPadding: header == null ? void 0 : header.captionPadding,
409
+ height: config == null ? void 0 : config.height,
410
+ width: config == null ? void 0 : config.width,
411
411
  children: [
412
412
  /* @__PURE__ */ jsx11(DataTableHeader, {
413
- tableCaption: props.tableCaption,
414
- enableGlobalFilter: props.globalFilter,
413
+ tableCaption: header == null ? void 0 : header.tableCaption,
414
+ enableGlobalFilter: filters == null ? void 0 : filters.globalFilter,
415
415
  globalFilter,
416
416
  setGlobalFilter,
417
- globalFilterPlaceholder: props.globalFilterPlaceholder,
418
- captionPadding: props.captionPadding
417
+ globalFilterPlaceholder: filters == null ? void 0 : filters.globalFilterPlaceholder,
418
+ captionPadding: header == null ? void 0 : header.captionPadding
419
419
  }),
420
420
  /* @__PURE__ */ jsx11("div", {
421
421
  ref: tableContainerRef,
422
422
  className: "--table-container",
423
- children: props.virtual ? /* @__PURE__ */ jsx11(VirtualTable, {
423
+ children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ jsx11(VirtualTable, {
424
424
  containerRef: tableContainerRef,
425
425
  table,
426
- stickyHeader: props.stickyHeader
426
+ stickyHeader: header == null ? void 0 : header.stickyHeader
427
427
  }) : /* @__PURE__ */ jsx11(BasicTable, {
428
428
  table,
429
- stickyHeader: props.stickyHeader
429
+ stickyHeader: header == null ? void 0 : header.stickyHeader
430
430
  })
431
431
  })
432
432
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/apollo-components",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -22,7 +22,7 @@
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
- "@tanstack/react-virtual": "^3.0.0-alpha.0",
25
+ "@tanstack/react-virtual": "^3.0.0-beta.23",
26
26
  "styled-components": "^5.3.6",
27
27
  "tsup": "^6.3.0"
28
28
  },