@equinor/apollo-components 1.2.2 → 1.3.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
@@ -31,19 +31,20 @@ interface DataTableConfig {
31
31
  height?: string;
32
32
  sortable?: boolean;
33
33
  virtual?: boolean;
34
- enableRowSelection?: boolean;
34
+ rowSelection?: 'multiple' | 'single';
35
35
  width?: string;
36
36
  }
37
37
 
38
38
  interface DataTableProps<T> {
39
- className?: string;
39
+ data: T[];
40
40
  columns: ColumnDef<T, any>[];
41
+ isLoading?: boolean;
42
+ className?: string;
41
43
  config?: DataTableConfig;
42
- data: T[];
43
44
  filters?: FilterConfig;
44
45
  header?: HeaderConfig;
45
46
  }
46
- declare function DataTable$1<T>({ columns, data, header, filters, config }: DataTableProps<T>): JSX.Element;
47
+ declare function DataTable$1<T>({ columns, data, isLoading, header, filters, config, }: DataTableProps<T>): JSX.Element;
47
48
 
48
49
  declare type DataTableProviderProps = ComponentProps<typeof Provider>;
49
50
  declare function DataTableProvider({ children, ...props }: DataTableProviderProps): JSX.Element;
package/dist/index.js CHANGED
@@ -181,7 +181,7 @@ var ChipsCell = (props) => {
181
181
  var import_react_table4 = require("@tanstack/react-table");
182
182
  var import_jotai3 = require("jotai");
183
183
  var import_react4 = require("react");
184
- var import_styled_components8 = __toESM(require("styled-components"));
184
+ var import_styled_components9 = __toESM(require("styled-components"));
185
185
 
186
186
  // src/DataTable/atoms.ts
187
187
  var import_jotai = require("jotai");
@@ -191,35 +191,58 @@ var rowSelectionAtom = (0, import_jotai.atom)({});
191
191
  var tableSortingAtom = (0, import_jotai.atom)([]);
192
192
 
193
193
  // src/DataTable/components/BasicTable.tsx
194
- var import_eds_core_react5 = require("@equinor/eds-core-react");
194
+ var import_eds_core_react6 = require("@equinor/eds-core-react");
195
195
  var import_react_table2 = require("@tanstack/react-table");
196
196
 
197
+ // src/DataTable/components/PlaceholderRow.tsx
198
+ var import_eds_core_react3 = require("@equinor/eds-core-react");
199
+ var import_styled_components4 = __toESM(require("styled-components"));
200
+ var import_jsx_runtime4 = require("react/jsx-runtime");
201
+ var PlaceholderTextWrapper = import_styled_components4.default.div`
202
+ display: flex;
203
+ justify-content: center;
204
+ `;
205
+ function PlaceholderRow({ isLoading }) {
206
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_eds_core_react3.Table.Row, {
207
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_eds_core_react3.Table.Cell, {
208
+ colSpan: 100,
209
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PlaceholderTextWrapper, {
210
+ children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_eds_core_react3.DotProgress, {
211
+ color: "primary"
212
+ }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_eds_core_react3.Typography, {
213
+ children: "No data available"
214
+ })
215
+ })
216
+ })
217
+ });
218
+ }
219
+
197
220
  // src/DataTable/components/TableHeader.tsx
198
- var import_eds_core_react4 = require("@equinor/eds-core-react");
221
+ var import_eds_core_react5 = require("@equinor/eds-core-react");
199
222
 
200
223
  // src/DataTable/components/HeaderCell.tsx
201
- var import_eds_core_react3 = require("@equinor/eds-core-react");
224
+ var import_eds_core_react4 = require("@equinor/eds-core-react");
202
225
  var import_eds_icons3 = require("@equinor/eds-icons");
203
226
  var import_react_table = require("@tanstack/react-table");
204
- var import_styled_components4 = __toESM(require("styled-components"));
205
- var import_jsx_runtime4 = require("react/jsx-runtime");
206
- var HeaderDiv = import_styled_components4.default.div`
227
+ var import_styled_components5 = __toESM(require("styled-components"));
228
+ var import_jsx_runtime5 = require("react/jsx-runtime");
229
+ var HeaderDiv = import_styled_components5.default.div`
207
230
  display: flex;
208
231
  align-items: center;
209
232
  gap: 0.25rem;
210
233
  `;
211
234
  var HeaderCell = ({ header }) => {
212
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_eds_core_react3.Table.Cell, {
235
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_eds_core_react4.Table.Cell, {
213
236
  colSpan: header.colSpan,
214
- children: header.isPlaceholder ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(HeaderDiv, {
237
+ children: header.isPlaceholder ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(HeaderDiv, {
215
238
  onClick: header.column.getToggleSortingHandler(),
216
239
  children: [
217
240
  (0, import_react_table.flexRender)(header.column.columnDef.header, header.getContext()),
218
241
  {
219
- asc: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_eds_core_react3.Icon, {
242
+ asc: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_eds_core_react4.Icon, {
220
243
  data: import_eds_icons3.arrow_down
221
244
  }),
222
- desc: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_eds_core_react3.Icon, {
245
+ desc: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_eds_core_react4.Icon, {
223
246
  data: import_eds_icons3.arrow_up
224
247
  })
225
248
  }[header.column.getIsSorted()] ?? null
@@ -229,45 +252,48 @@ var HeaderCell = ({ header }) => {
229
252
  };
230
253
 
231
254
  // src/DataTable/components/TableHeader.tsx
232
- var import_jsx_runtime5 = require("react/jsx-runtime");
233
- var TableHeader = ({ table, sticky }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_eds_core_react4.Table.Head, {
255
+ var import_jsx_runtime6 = require("react/jsx-runtime");
256
+ var TableHeader = ({ table, sticky }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_eds_core_react5.Table.Head, {
234
257
  sticky,
235
- children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_eds_core_react4.Table.Row, {
236
- children: headerGroup.headers.map((header) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(HeaderCell, {
258
+ children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_eds_core_react5.Table.Row, {
259
+ children: headerGroup.headers.map((header) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(HeaderCell, {
237
260
  header
238
261
  }, header.id))
239
262
  }, headerGroup.id))
240
263
  });
241
264
 
242
265
  // src/DataTable/components/BasicTable.tsx
243
- var import_jsx_runtime6 = require("react/jsx-runtime");
244
- function BasicTable({ table, stickyHeader }) {
245
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_eds_core_react5.Table, {
266
+ var import_jsx_runtime7 = require("react/jsx-runtime");
267
+ function BasicTable({ table, stickyHeader, isLoading }) {
268
+ const tableRows = table.getRowModel().rows;
269
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_eds_core_react6.Table, {
246
270
  children: [
247
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TableHeader, {
271
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TableHeader, {
248
272
  sticky: stickyHeader,
249
273
  table
250
274
  }),
251
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_eds_core_react5.Table.Body, {
252
- children: table.getRowModel().rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_eds_core_react5.Table.Row, {
253
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_eds_core_react5.Table.Cell, {
275
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Table.Body, {
276
+ children: tableRows.length ? tableRows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Table.Row, {
277
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Table.Cell, {
254
278
  children: (0, import_react_table2.flexRender)(cell.column.columnDef.cell, cell.getContext())
255
279
  }, cell.id))
256
- }, row.id))
280
+ }, row.id)) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PlaceholderRow, {
281
+ isLoading
282
+ })
257
283
  })
258
284
  ]
259
285
  });
260
286
  }
261
287
 
262
288
  // src/DataTable/components/ColumnSelect.tsx
263
- var import_eds_core_react7 = require("@equinor/eds-core-react");
289
+ var import_eds_core_react8 = require("@equinor/eds-core-react");
264
290
  var import_eds_icons4 = require("@equinor/eds-icons");
265
291
  var import_react2 = require("react");
266
- var import_styled_components5 = __toESM(require("styled-components"));
292
+ var import_styled_components6 = __toESM(require("styled-components"));
267
293
 
268
294
  // src/DataTable/utils.tsx
269
- var import_eds_core_react6 = require("@equinor/eds-core-react");
270
- var import_jsx_runtime7 = require("react/jsx-runtime");
295
+ var import_eds_core_react7 = require("@equinor/eds-core-react");
296
+ var import_jsx_runtime8 = require("react/jsx-runtime");
271
297
  function enableOrUndefined(enabled, value) {
272
298
  return Boolean(enabled) ? value : void 0;
273
299
  }
@@ -278,22 +304,22 @@ function getColumnHeader(column) {
278
304
  return typeof columnHeader === "string" ? columnHeader : column.id;
279
305
  }
280
306
  function prependSelectColumnIfEnabled(columns, config) {
281
- if (!(config == null ? void 0 : config.enableRowSelection))
307
+ if (!Boolean(config == null ? void 0 : config.rowSelection))
282
308
  return columns;
283
309
  const selectColumn = {
284
310
  id: "select",
285
- header: ({ table }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", {
311
+ header: ({ table }) => (config == null ? void 0 : config.rowSelection) === "multiple" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", {
286
312
  style: { width: "48px" },
287
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Checkbox, {
313
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Checkbox, {
288
314
  checked: table.getIsAllRowsSelected(),
289
315
  indeterminate: table.getIsSomeRowsSelected(),
290
316
  "aria-label": table.getIsAllRowsSelected() ? "Deselect all rows" : "Select all rows",
291
317
  onChange: table.getToggleAllRowsSelectedHandler()
292
318
  })
293
- }),
294
- cell: ({ row }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", {
319
+ }) : null,
320
+ cell: ({ row }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", {
295
321
  style: { width: "48px" },
296
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Checkbox, {
322
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Checkbox, {
297
323
  checked: row.getIsSelected(),
298
324
  indeterminate: row.getIsSomeSelected(),
299
325
  "aria-label": `Select row ${row.id}`,
@@ -305,13 +331,13 @@ function prependSelectColumnIfEnabled(columns, config) {
305
331
  }
306
332
 
307
333
  // src/DataTable/components/ColumnSelect.tsx
308
- var import_jsx_runtime8 = require("react/jsx-runtime");
309
- var ColumnSelectContent = import_styled_components5.default.div`
334
+ var import_jsx_runtime9 = require("react/jsx-runtime");
335
+ var ColumnSelectContent = import_styled_components6.default.div`
310
336
  display: grid;
311
337
  grid-template-columns: repeat(2, 1fr);
312
338
  grid-gap: 0.5rem;
313
339
  `;
314
- var ActionsWrapper = import_styled_components5.default.div`
340
+ var ActionsWrapper = import_styled_components6.default.div`
315
341
  display: flex;
316
342
  align-items: center;
317
343
  justify-content: flex-end;
@@ -321,9 +347,9 @@ function ColumnSelect({ table }) {
321
347
  const [isOpen, setIsOpen] = (0, import_react2.useState)(false);
322
348
  const referenceElement = (0, import_react2.useRef)(null);
323
349
  const selectableColumns = table.getAllLeafColumns().filter((column) => column.id !== "select");
324
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, {
350
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, {
325
351
  children: [
326
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Button, {
352
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Button, {
327
353
  "aria-haspopup": true,
328
354
  id: "column-select-anchor",
329
355
  "aria-controls": "column-select-popover",
@@ -331,28 +357,28 @@ function ColumnSelect({ table }) {
331
357
  ref: referenceElement,
332
358
  variant: "ghost_icon",
333
359
  onClick: () => setIsOpen(true),
334
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Icon, {
360
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Icon, {
335
361
  name: "view_column",
336
362
  data: import_eds_icons4.view_column
337
363
  })
338
364
  }),
339
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_eds_core_react7.Popover, {
365
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_eds_core_react8.Popover, {
340
366
  open: isOpen,
341
367
  id: "column-select-popover",
342
368
  anchorEl: referenceElement.current,
343
369
  placement: "bottom-end",
344
370
  onClose: () => setIsOpen(false),
345
371
  children: [
346
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_eds_core_react7.Popover.Header, {
372
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_eds_core_react8.Popover.Header, {
347
373
  children: [
348
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Popover.Title, {
374
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Popover.Title, {
349
375
  children: "Column settings"
350
376
  }),
351
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Button, {
377
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Button, {
352
378
  variant: "ghost_icon",
353
379
  "aria-label": "Close column select",
354
380
  onClick: () => setIsOpen(false),
355
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Icon, {
381
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Icon, {
356
382
  name: "close",
357
383
  data: import_eds_icons4.close,
358
384
  size: 24
@@ -360,22 +386,22 @@ function ColumnSelect({ table }) {
360
386
  })
361
387
  ]
362
388
  }),
363
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_eds_core_react7.Popover.Content, {
389
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_eds_core_react8.Popover.Content, {
364
390
  children: [
365
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ColumnSelectContent, {
391
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ColumnSelectContent, {
366
392
  children: selectableColumns.map((column) => {
367
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Checkbox, {
393
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Checkbox, {
368
394
  checked: column.getIsVisible(),
369
395
  label: getColumnHeader(column),
370
396
  onChange: column.getToggleVisibilityHandler()
371
397
  }, column.id);
372
398
  })
373
399
  }),
374
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Divider, {
400
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Divider, {
375
401
  variant: "small"
376
402
  }),
377
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ActionsWrapper, {
378
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_eds_core_react7.Button, {
403
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ActionsWrapper, {
404
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Button, {
379
405
  color: "secondary",
380
406
  variant: "ghost",
381
407
  disabled: table.getIsAllColumnsVisible(),
@@ -392,21 +418,21 @@ function ColumnSelect({ table }) {
392
418
  }
393
419
 
394
420
  // src/DataTable/components/DataTableHeader.tsx
395
- var import_eds_core_react9 = require("@equinor/eds-core-react");
421
+ var import_eds_core_react10 = require("@equinor/eds-core-react");
396
422
  var import_eds_icons6 = require("@equinor/eds-icons");
397
423
  var import_jotai2 = require("jotai");
398
- var import_styled_components7 = __toESM(require("styled-components"));
424
+ var import_styled_components8 = __toESM(require("styled-components"));
399
425
 
400
426
  // src/DataTable/filters/DebouncedInput.tsx
401
- var import_eds_core_react8 = require("@equinor/eds-core-react");
427
+ var import_eds_core_react9 = require("@equinor/eds-core-react");
402
428
  var import_eds_icons5 = require("@equinor/eds-icons");
403
429
  var import_react3 = require("react");
404
- var import_styled_components6 = __toESM(require("styled-components"));
405
- var import_jsx_runtime9 = require("react/jsx-runtime");
406
- var Wrapper3 = import_styled_components6.default.div`
430
+ var import_styled_components7 = __toESM(require("styled-components"));
431
+ var import_jsx_runtime10 = require("react/jsx-runtime");
432
+ var Wrapper3 = import_styled_components7.default.div`
407
433
  width: 200px;
408
434
  `;
409
- var CloseButton = (0, import_styled_components6.default)(import_eds_core_react8.Button)`
435
+ var CloseButton = (0, import_styled_components7.default)(import_eds_core_react9.Button)`
410
436
  width: 24px;
411
437
  height: 24px;
412
438
  `;
@@ -427,21 +453,21 @@ function DebouncedInput({
427
453
  }, debounce);
428
454
  return () => clearTimeout(timeout);
429
455
  }, [value]);
430
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Wrapper3, {
431
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Input, {
456
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Wrapper3, {
457
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_eds_core_react9.Input, {
432
458
  ...props,
433
459
  value,
434
- leftAdornments: icon && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Icon, {
460
+ leftAdornments: icon && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_eds_core_react9.Icon, {
435
461
  name: icon.name,
436
462
  data: icon,
437
463
  size: 18
438
464
  }),
439
- rightAdornments: !!value && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Tooltip, {
465
+ rightAdornments: !!value && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_eds_core_react9.Tooltip, {
440
466
  title: "Clear input",
441
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CloseButton, {
467
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CloseButton, {
442
468
  variant: "ghost_icon",
443
469
  onClick: () => setValue(""),
444
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_eds_core_react8.Icon, {
470
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_eds_core_react9.Icon, {
445
471
  name: import_eds_icons5.close.name,
446
472
  data: import_eds_icons5.close,
447
473
  size: 18
@@ -464,15 +490,15 @@ var fuzzyFilter = (row, columnId, value, addMeta) => {
464
490
  };
465
491
 
466
492
  // src/DataTable/components/DataTableHeader.tsx
467
- var import_jsx_runtime10 = require("react/jsx-runtime");
468
- var DataTableHeaderWrapper = import_styled_components7.default.div`
493
+ var import_jsx_runtime11 = require("react/jsx-runtime");
494
+ var DataTableHeaderWrapper = import_styled_components8.default.div`
469
495
  display: flex;
470
496
  align-items: center;
471
497
  justify-content: space-between;
472
498
  gap: 0.5rem;
473
499
  padding: ${(props) => props.captionPadding ?? "1rem"};
474
500
  `;
475
- var FilterContainer = import_styled_components7.default.div`
501
+ var FilterContainer = import_styled_components8.default.div`
476
502
  display: flex;
477
503
  align-items: center;
478
504
  gap: 1rem;
@@ -480,18 +506,18 @@ var FilterContainer = import_styled_components7.default.div`
480
506
  `;
481
507
  var DataTableHeader = (props) => {
482
508
  const [globalFilter, setGlobalFilter] = (0, import_jotai2.useAtom)(globalFilterAtom);
483
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(DataTableHeaderWrapper, {
509
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(DataTableHeaderWrapper, {
484
510
  className: "--table-caption",
485
511
  captionPadding: props.captionPadding,
486
512
  children: [
487
- (props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_eds_core_react9.Typography, {
513
+ (props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_eds_core_react10.Typography, {
488
514
  variant: "h3",
489
515
  children: props == null ? void 0 : props.tableCaption
490
516
  }),
491
- (props == null ? void 0 : props.enableGlobalFilter) && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(FilterContainer, {
517
+ (props == null ? void 0 : props.enableGlobalFilter) && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(FilterContainer, {
492
518
  className: "--filter-container",
493
519
  children: [
494
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(DebouncedInput, {
520
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DebouncedInput, {
495
521
  value: globalFilter,
496
522
  icon: import_eds_icons6.search,
497
523
  placeholder: (props == null ? void 0 : props.globalFilterPlaceholder) ?? "Search all columns",
@@ -505,25 +531,25 @@ var DataTableHeader = (props) => {
505
531
  };
506
532
 
507
533
  // src/DataTable/components/VirtualTable.tsx
508
- var import_eds_core_react11 = require("@equinor/eds-core-react");
534
+ var import_eds_core_react12 = require("@equinor/eds-core-react");
509
535
  var import_react_table3 = require("@tanstack/react-table");
510
536
  var import_react_virtual = require("@tanstack/react-virtual");
511
537
 
512
538
  // src/DataTable/components/PaddingRow.tsx
513
- var import_eds_core_react10 = require("@equinor/eds-core-react");
514
- var import_jsx_runtime11 = require("react/jsx-runtime");
539
+ var import_eds_core_react11 = require("@equinor/eds-core-react");
540
+ var import_jsx_runtime12 = require("react/jsx-runtime");
515
541
  var PaddingRow = (props) => {
516
542
  if (!props.height)
517
543
  return null;
518
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_eds_core_react10.Table.Row, {
519
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_eds_core_react10.Table.Cell, {
544
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Table.Row, {
545
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Table.Cell, {
520
546
  style: { height: `${props.height}px` }
521
547
  })
522
548
  });
523
549
  };
524
550
 
525
551
  // src/DataTable/components/VirtualTable.tsx
526
- var import_jsx_runtime12 = require("react/jsx-runtime");
552
+ var import_jsx_runtime13 = require("react/jsx-runtime");
527
553
  function VirtualTable({ table, containerRef, ...props }) {
528
554
  var _a, _b;
529
555
  const { rows } = table.getRowModel();
@@ -535,27 +561,29 @@ function VirtualTable({ table, containerRef, ...props }) {
535
561
  const virtualRows = rowVirtualizer.getVirtualItems();
536
562
  const paddingTop = virtualRows.length > 0 ? ((_a = virtualRows == null ? void 0 : virtualRows[0]) == null ? void 0 : _a.start) || 0 : 0;
537
563
  const paddingBottom = virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (((_b = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b.end) || 0) : 0;
538
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_eds_core_react11.Table, {
564
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_eds_core_react12.Table, {
539
565
  children: [
540
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TableHeader, {
566
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TableHeader, {
541
567
  sticky: props.stickyHeader,
542
568
  table
543
569
  }),
544
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_eds_core_react11.Table.Body, {
570
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_eds_core_react12.Table.Body, {
545
571
  children: [
546
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(PaddingRow, {
572
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(PaddingRow, {
547
573
  height: paddingTop
548
574
  }),
549
- virtualRows.map((virtualRow) => {
575
+ rows.length ? virtualRows.map((virtualRow) => {
550
576
  const row = rows[virtualRow.index];
551
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Table.Row, {
577
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Table.Row, {
552
578
  active: row.getIsSelected(),
553
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_eds_core_react11.Table.Cell, {
579
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Table.Cell, {
554
580
  children: (0, import_react_table3.flexRender)(cell.column.columnDef.cell, cell.getContext())
555
581
  }, cell.id))
556
582
  }, row.id);
583
+ }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(PlaceholderRow, {
584
+ isLoading: props.isLoading
557
585
  }),
558
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(PaddingRow, {
586
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(PaddingRow, {
559
587
  height: paddingBottom
560
588
  })
561
589
  ]
@@ -565,8 +593,8 @@ function VirtualTable({ table, containerRef, ...props }) {
565
593
  }
566
594
 
567
595
  // src/DataTable/DataTable.tsx
568
- var import_jsx_runtime13 = require("react/jsx-runtime");
569
- var DataTableWrapper = import_styled_components8.default.div`
596
+ var import_jsx_runtime14 = require("react/jsx-runtime");
597
+ var DataTableWrapper = import_styled_components9.default.div`
570
598
  width: ${(props) => props.width ?? "100%"};
571
599
 
572
600
  .--table-container {
@@ -579,7 +607,14 @@ var DataTableWrapper = import_styled_components8.default.div`
579
607
  }
580
608
  }
581
609
  `;
582
- function DataTable({ columns, data, header, filters, config }) {
610
+ function DataTable({
611
+ columns,
612
+ data,
613
+ isLoading,
614
+ header,
615
+ filters,
616
+ config
617
+ }) {
583
618
  const [columnVisibility, setColumnVisibility] = (0, import_jotai3.useAtom)(columnVisibilityAtom);
584
619
  const [globalFilter, setGlobalFilter] = (0, import_jotai3.useAtom)(globalFilterAtom);
585
620
  const [sorting, setSorting] = (0, import_jotai3.useAtom)(tableSortingAtom);
@@ -600,6 +635,7 @@ function DataTable({ columns, data, header, filters, config }) {
600
635
  columnVisibility
601
636
  },
602
637
  onRowSelectionChange: setRowSelectionState,
638
+ enableMultiRowSelection: (config == null ? void 0 : config.rowSelection) === "multiple",
603
639
  enableSorting: config == null ? void 0 : config.sortable,
604
640
  onSortingChange: enableOrUndefined(config == null ? void 0 : config.sortable, setSorting),
605
641
  getSortedRowModel: (0, import_react_table4.getSortedRowModel)(),
@@ -607,29 +643,31 @@ function DataTable({ columns, data, header, filters, config }) {
607
643
  onGlobalFilterChange: enableGlobalFilter(setGlobalFilter)
608
644
  });
609
645
  const tableContainerRef = (0, import_react4.useRef)(null);
610
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(DataTableWrapper, {
646
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(DataTableWrapper, {
611
647
  captionPadding: header == null ? void 0 : header.captionPadding,
612
648
  height: config == null ? void 0 : config.height,
613
649
  width: config == null ? void 0 : config.width,
614
650
  children: [
615
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DataTableHeader, {
651
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DataTableHeader, {
616
652
  tableCaption: header == null ? void 0 : header.tableCaption,
617
653
  enableGlobalFilter: filters == null ? void 0 : filters.globalFilter,
618
654
  globalFilterPlaceholder: filters == null ? void 0 : filters.globalFilterPlaceholder,
619
655
  captionPadding: header == null ? void 0 : header.captionPadding,
620
- filterActions: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ColumnSelect, {
656
+ filterActions: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ColumnSelect, {
621
657
  table
622
658
  })
623
659
  }),
624
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", {
660
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", {
625
661
  ref: tableContainerRef,
626
662
  className: "--table-container",
627
- children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(VirtualTable, {
663
+ children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(VirtualTable, {
628
664
  containerRef: tableContainerRef,
629
665
  table,
666
+ isLoading,
630
667
  stickyHeader: header == null ? void 0 : header.stickyHeader
631
- }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(BasicTable, {
668
+ }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(BasicTable, {
632
669
  table,
670
+ isLoading,
633
671
  stickyHeader: header == null ? void 0 : header.stickyHeader
634
672
  })
635
673
  })
@@ -639,9 +677,9 @@ function DataTable({ columns, data, header, filters, config }) {
639
677
 
640
678
  // src/DataTable/Provider.tsx
641
679
  var import_jotai4 = require("jotai");
642
- var import_jsx_runtime14 = require("react/jsx-runtime");
680
+ var import_jsx_runtime15 = require("react/jsx-runtime");
643
681
  function DataTableProvider({ children, ...props }) {
644
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jotai4.Provider, {
682
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jotai4.Provider, {
645
683
  ...props,
646
684
  children
647
685
  });
package/dist/index.mjs CHANGED
@@ -148,7 +148,7 @@ import {
148
148
  } from "@tanstack/react-table";
149
149
  import { useAtom as useAtom2 } from "jotai";
150
150
  import { useRef as useRef2 } from "react";
151
- import styled8 from "styled-components";
151
+ import styled9 from "styled-components";
152
152
 
153
153
  // src/DataTable/atoms.ts
154
154
  import { atom } from "jotai";
@@ -161,32 +161,55 @@ var tableSortingAtom = atom([]);
161
161
  import { Table as EdsTable } from "@equinor/eds-core-react";
162
162
  import { flexRender as flexRender2 } from "@tanstack/react-table";
163
163
 
164
+ // src/DataTable/components/PlaceholderRow.tsx
165
+ import { DotProgress, Table, Typography } from "@equinor/eds-core-react";
166
+ import styled4 from "styled-components";
167
+ import { jsx as jsx4 } from "react/jsx-runtime";
168
+ var PlaceholderTextWrapper = styled4.div`
169
+ display: flex;
170
+ justify-content: center;
171
+ `;
172
+ function PlaceholderRow({ isLoading }) {
173
+ return /* @__PURE__ */ jsx4(Table.Row, {
174
+ children: /* @__PURE__ */ jsx4(Table.Cell, {
175
+ colSpan: 100,
176
+ children: /* @__PURE__ */ jsx4(PlaceholderTextWrapper, {
177
+ children: isLoading ? /* @__PURE__ */ jsx4(DotProgress, {
178
+ color: "primary"
179
+ }) : /* @__PURE__ */ jsx4(Typography, {
180
+ children: "No data available"
181
+ })
182
+ })
183
+ })
184
+ });
185
+ }
186
+
164
187
  // src/DataTable/components/TableHeader.tsx
165
- import { Table as Table2 } from "@equinor/eds-core-react";
188
+ import { Table as Table3 } from "@equinor/eds-core-react";
166
189
 
167
190
  // src/DataTable/components/HeaderCell.tsx
168
- import { Icon as Icon3, Table } from "@equinor/eds-core-react";
191
+ import { Icon as Icon3, Table as Table2 } from "@equinor/eds-core-react";
169
192
  import { arrow_down, arrow_up } from "@equinor/eds-icons";
170
193
  import { flexRender } from "@tanstack/react-table";
171
- import styled4 from "styled-components";
172
- import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
173
- var HeaderDiv = styled4.div`
194
+ import styled5 from "styled-components";
195
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
196
+ var HeaderDiv = styled5.div`
174
197
  display: flex;
175
198
  align-items: center;
176
199
  gap: 0.25rem;
177
200
  `;
178
201
  var HeaderCell = ({ header }) => {
179
- return /* @__PURE__ */ jsx4(Table.Cell, {
202
+ return /* @__PURE__ */ jsx5(Table2.Cell, {
180
203
  colSpan: header.colSpan,
181
204
  children: header.isPlaceholder ? null : /* @__PURE__ */ jsxs3(HeaderDiv, {
182
205
  onClick: header.column.getToggleSortingHandler(),
183
206
  children: [
184
207
  flexRender(header.column.columnDef.header, header.getContext()),
185
208
  {
186
- asc: /* @__PURE__ */ jsx4(Icon3, {
209
+ asc: /* @__PURE__ */ jsx5(Icon3, {
187
210
  data: arrow_down
188
211
  }),
189
- desc: /* @__PURE__ */ jsx4(Icon3, {
212
+ desc: /* @__PURE__ */ jsx5(Icon3, {
190
213
  data: arrow_up
191
214
  })
192
215
  }[header.column.getIsSorted()] ?? null
@@ -196,31 +219,34 @@ var HeaderCell = ({ header }) => {
196
219
  };
197
220
 
198
221
  // src/DataTable/components/TableHeader.tsx
199
- import { jsx as jsx5 } from "react/jsx-runtime";
200
- var TableHeader = ({ table, sticky }) => /* @__PURE__ */ jsx5(Table2.Head, {
222
+ import { jsx as jsx6 } from "react/jsx-runtime";
223
+ var TableHeader = ({ table, sticky }) => /* @__PURE__ */ jsx6(Table3.Head, {
201
224
  sticky,
202
- children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx5(Table2.Row, {
203
- children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx5(HeaderCell, {
225
+ children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx6(Table3.Row, {
226
+ children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx6(HeaderCell, {
204
227
  header
205
228
  }, header.id))
206
229
  }, headerGroup.id))
207
230
  });
208
231
 
209
232
  // src/DataTable/components/BasicTable.tsx
210
- import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
211
- function BasicTable({ table, stickyHeader }) {
233
+ import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
234
+ function BasicTable({ table, stickyHeader, isLoading }) {
235
+ const tableRows = table.getRowModel().rows;
212
236
  return /* @__PURE__ */ jsxs4(EdsTable, {
213
237
  children: [
214
- /* @__PURE__ */ jsx6(TableHeader, {
238
+ /* @__PURE__ */ jsx7(TableHeader, {
215
239
  sticky: stickyHeader,
216
240
  table
217
241
  }),
218
- /* @__PURE__ */ jsx6(EdsTable.Body, {
219
- children: table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx6(EdsTable.Row, {
220
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx6(EdsTable.Cell, {
242
+ /* @__PURE__ */ jsx7(EdsTable.Body, {
243
+ children: tableRows.length ? tableRows.map((row) => /* @__PURE__ */ jsx7(EdsTable.Row, {
244
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx7(EdsTable.Cell, {
221
245
  children: flexRender2(cell.column.columnDef.cell, cell.getContext())
222
246
  }, cell.id))
223
- }, row.id))
247
+ }, row.id)) : /* @__PURE__ */ jsx7(PlaceholderRow, {
248
+ isLoading
249
+ })
224
250
  })
225
251
  ]
226
252
  });
@@ -230,11 +256,11 @@ function BasicTable({ table, stickyHeader }) {
230
256
  import { Button as Button2, Checkbox as Checkbox2, Divider, Icon as Icon4, Popover } from "@equinor/eds-core-react";
231
257
  import { close, view_column } from "@equinor/eds-icons";
232
258
  import { useRef, useState as useState2 } from "react";
233
- import styled5 from "styled-components";
259
+ import styled6 from "styled-components";
234
260
 
235
261
  // src/DataTable/utils.tsx
236
262
  import { Checkbox } from "@equinor/eds-core-react";
237
- import { jsx as jsx7 } from "react/jsx-runtime";
263
+ import { jsx as jsx8 } from "react/jsx-runtime";
238
264
  function enableOrUndefined(enabled, value) {
239
265
  return Boolean(enabled) ? value : void 0;
240
266
  }
@@ -245,22 +271,22 @@ function getColumnHeader(column) {
245
271
  return typeof columnHeader === "string" ? columnHeader : column.id;
246
272
  }
247
273
  function prependSelectColumnIfEnabled(columns, config) {
248
- if (!(config == null ? void 0 : config.enableRowSelection))
274
+ if (!Boolean(config == null ? void 0 : config.rowSelection))
249
275
  return columns;
250
276
  const selectColumn = {
251
277
  id: "select",
252
- header: ({ table }) => /* @__PURE__ */ jsx7("div", {
278
+ header: ({ table }) => (config == null ? void 0 : config.rowSelection) === "multiple" ? /* @__PURE__ */ jsx8("div", {
253
279
  style: { width: "48px" },
254
- children: /* @__PURE__ */ jsx7(Checkbox, {
280
+ children: /* @__PURE__ */ jsx8(Checkbox, {
255
281
  checked: table.getIsAllRowsSelected(),
256
282
  indeterminate: table.getIsSomeRowsSelected(),
257
283
  "aria-label": table.getIsAllRowsSelected() ? "Deselect all rows" : "Select all rows",
258
284
  onChange: table.getToggleAllRowsSelectedHandler()
259
285
  })
260
- }),
261
- cell: ({ row }) => /* @__PURE__ */ jsx7("div", {
286
+ }) : null,
287
+ cell: ({ row }) => /* @__PURE__ */ jsx8("div", {
262
288
  style: { width: "48px" },
263
- children: /* @__PURE__ */ jsx7(Checkbox, {
289
+ children: /* @__PURE__ */ jsx8(Checkbox, {
264
290
  checked: row.getIsSelected(),
265
291
  indeterminate: row.getIsSomeSelected(),
266
292
  "aria-label": `Select row ${row.id}`,
@@ -272,13 +298,13 @@ function prependSelectColumnIfEnabled(columns, config) {
272
298
  }
273
299
 
274
300
  // src/DataTable/components/ColumnSelect.tsx
275
- import { Fragment, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
276
- var ColumnSelectContent = styled5.div`
301
+ import { Fragment, jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
302
+ var ColumnSelectContent = styled6.div`
277
303
  display: grid;
278
304
  grid-template-columns: repeat(2, 1fr);
279
305
  grid-gap: 0.5rem;
280
306
  `;
281
- var ActionsWrapper = styled5.div`
307
+ var ActionsWrapper = styled6.div`
282
308
  display: flex;
283
309
  align-items: center;
284
310
  justify-content: flex-end;
@@ -290,7 +316,7 @@ function ColumnSelect({ table }) {
290
316
  const selectableColumns = table.getAllLeafColumns().filter((column) => column.id !== "select");
291
317
  return /* @__PURE__ */ jsxs5(Fragment, {
292
318
  children: [
293
- /* @__PURE__ */ jsx8(Button2, {
319
+ /* @__PURE__ */ jsx9(Button2, {
294
320
  "aria-haspopup": true,
295
321
  id: "column-select-anchor",
296
322
  "aria-controls": "column-select-popover",
@@ -298,7 +324,7 @@ function ColumnSelect({ table }) {
298
324
  ref: referenceElement,
299
325
  variant: "ghost_icon",
300
326
  onClick: () => setIsOpen(true),
301
- children: /* @__PURE__ */ jsx8(Icon4, {
327
+ children: /* @__PURE__ */ jsx9(Icon4, {
302
328
  name: "view_column",
303
329
  data: view_column
304
330
  })
@@ -312,14 +338,14 @@ function ColumnSelect({ table }) {
312
338
  children: [
313
339
  /* @__PURE__ */ jsxs5(Popover.Header, {
314
340
  children: [
315
- /* @__PURE__ */ jsx8(Popover.Title, {
341
+ /* @__PURE__ */ jsx9(Popover.Title, {
316
342
  children: "Column settings"
317
343
  }),
318
- /* @__PURE__ */ jsx8(Button2, {
344
+ /* @__PURE__ */ jsx9(Button2, {
319
345
  variant: "ghost_icon",
320
346
  "aria-label": "Close column select",
321
347
  onClick: () => setIsOpen(false),
322
- children: /* @__PURE__ */ jsx8(Icon4, {
348
+ children: /* @__PURE__ */ jsx9(Icon4, {
323
349
  name: "close",
324
350
  data: close,
325
351
  size: 24
@@ -329,20 +355,20 @@ function ColumnSelect({ table }) {
329
355
  }),
330
356
  /* @__PURE__ */ jsxs5(Popover.Content, {
331
357
  children: [
332
- /* @__PURE__ */ jsx8(ColumnSelectContent, {
358
+ /* @__PURE__ */ jsx9(ColumnSelectContent, {
333
359
  children: selectableColumns.map((column) => {
334
- return /* @__PURE__ */ jsx8(Checkbox2, {
360
+ return /* @__PURE__ */ jsx9(Checkbox2, {
335
361
  checked: column.getIsVisible(),
336
362
  label: getColumnHeader(column),
337
363
  onChange: column.getToggleVisibilityHandler()
338
364
  }, column.id);
339
365
  })
340
366
  }),
341
- /* @__PURE__ */ jsx8(Divider, {
367
+ /* @__PURE__ */ jsx9(Divider, {
342
368
  variant: "small"
343
369
  }),
344
- /* @__PURE__ */ jsx8(ActionsWrapper, {
345
- children: /* @__PURE__ */ jsx8(Button2, {
370
+ /* @__PURE__ */ jsx9(ActionsWrapper, {
371
+ children: /* @__PURE__ */ jsx9(Button2, {
346
372
  color: "secondary",
347
373
  variant: "ghost",
348
374
  disabled: table.getIsAllColumnsVisible(),
@@ -359,21 +385,21 @@ function ColumnSelect({ table }) {
359
385
  }
360
386
 
361
387
  // src/DataTable/components/DataTableHeader.tsx
362
- import { Typography } from "@equinor/eds-core-react";
388
+ import { Typography as Typography2 } from "@equinor/eds-core-react";
363
389
  import { search } from "@equinor/eds-icons";
364
390
  import { useAtom } from "jotai";
365
- import styled7 from "styled-components";
391
+ import styled8 from "styled-components";
366
392
 
367
393
  // src/DataTable/filters/DebouncedInput.tsx
368
394
  import { Button as Button3, Icon as Icon5, Input, Tooltip } from "@equinor/eds-core-react";
369
395
  import { close as close2 } from "@equinor/eds-icons";
370
396
  import { useEffect, useState as useState3 } from "react";
371
- import styled6 from "styled-components";
372
- import { jsx as jsx9 } from "react/jsx-runtime";
373
- var Wrapper3 = styled6.div`
397
+ import styled7 from "styled-components";
398
+ import { jsx as jsx10 } from "react/jsx-runtime";
399
+ var Wrapper3 = styled7.div`
374
400
  width: 200px;
375
401
  `;
376
- var CloseButton = styled6(Button3)`
402
+ var CloseButton = styled7(Button3)`
377
403
  width: 24px;
378
404
  height: 24px;
379
405
  `;
@@ -394,21 +420,21 @@ function DebouncedInput({
394
420
  }, debounce);
395
421
  return () => clearTimeout(timeout);
396
422
  }, [value]);
397
- return /* @__PURE__ */ jsx9(Wrapper3, {
398
- children: /* @__PURE__ */ jsx9(Input, {
423
+ return /* @__PURE__ */ jsx10(Wrapper3, {
424
+ children: /* @__PURE__ */ jsx10(Input, {
399
425
  ...props,
400
426
  value,
401
- leftAdornments: icon && /* @__PURE__ */ jsx9(Icon5, {
427
+ leftAdornments: icon && /* @__PURE__ */ jsx10(Icon5, {
402
428
  name: icon.name,
403
429
  data: icon,
404
430
  size: 18
405
431
  }),
406
- rightAdornments: !!value && /* @__PURE__ */ jsx9(Tooltip, {
432
+ rightAdornments: !!value && /* @__PURE__ */ jsx10(Tooltip, {
407
433
  title: "Clear input",
408
- children: /* @__PURE__ */ jsx9(CloseButton, {
434
+ children: /* @__PURE__ */ jsx10(CloseButton, {
409
435
  variant: "ghost_icon",
410
436
  onClick: () => setValue(""),
411
- children: /* @__PURE__ */ jsx9(Icon5, {
437
+ children: /* @__PURE__ */ jsx10(Icon5, {
412
438
  name: close2.name,
413
439
  data: close2,
414
440
  size: 18
@@ -431,15 +457,15 @@ var fuzzyFilter = (row, columnId, value, addMeta) => {
431
457
  };
432
458
 
433
459
  // src/DataTable/components/DataTableHeader.tsx
434
- import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
435
- var DataTableHeaderWrapper = styled7.div`
460
+ import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
461
+ var DataTableHeaderWrapper = styled8.div`
436
462
  display: flex;
437
463
  align-items: center;
438
464
  justify-content: space-between;
439
465
  gap: 0.5rem;
440
466
  padding: ${(props) => props.captionPadding ?? "1rem"};
441
467
  `;
442
- var FilterContainer = styled7.div`
468
+ var FilterContainer = styled8.div`
443
469
  display: flex;
444
470
  align-items: center;
445
471
  gap: 1rem;
@@ -451,14 +477,14 @@ var DataTableHeader = (props) => {
451
477
  className: "--table-caption",
452
478
  captionPadding: props.captionPadding,
453
479
  children: [
454
- (props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ jsx10(Typography, {
480
+ (props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ jsx11(Typography2, {
455
481
  variant: "h3",
456
482
  children: props == null ? void 0 : props.tableCaption
457
483
  }),
458
484
  (props == null ? void 0 : props.enableGlobalFilter) && /* @__PURE__ */ jsxs6(FilterContainer, {
459
485
  className: "--filter-container",
460
486
  children: [
461
- /* @__PURE__ */ jsx10(DebouncedInput, {
487
+ /* @__PURE__ */ jsx11(DebouncedInput, {
462
488
  value: globalFilter,
463
489
  icon: search,
464
490
  placeholder: (props == null ? void 0 : props.globalFilterPlaceholder) ?? "Search all columns",
@@ -472,25 +498,25 @@ var DataTableHeader = (props) => {
472
498
  };
473
499
 
474
500
  // src/DataTable/components/VirtualTable.tsx
475
- import { Table as Table5 } from "@equinor/eds-core-react";
501
+ import { Table as Table6 } from "@equinor/eds-core-react";
476
502
  import { flexRender as flexRender3 } from "@tanstack/react-table";
477
503
  import { useVirtualizer } from "@tanstack/react-virtual";
478
504
 
479
505
  // src/DataTable/components/PaddingRow.tsx
480
- import { Table as Table4 } from "@equinor/eds-core-react";
481
- import { jsx as jsx11 } from "react/jsx-runtime";
506
+ import { Table as Table5 } from "@equinor/eds-core-react";
507
+ import { jsx as jsx12 } from "react/jsx-runtime";
482
508
  var PaddingRow = (props) => {
483
509
  if (!props.height)
484
510
  return null;
485
- return /* @__PURE__ */ jsx11(Table4.Row, {
486
- children: /* @__PURE__ */ jsx11(Table4.Cell, {
511
+ return /* @__PURE__ */ jsx12(Table5.Row, {
512
+ children: /* @__PURE__ */ jsx12(Table5.Cell, {
487
513
  style: { height: `${props.height}px` }
488
514
  })
489
515
  });
490
516
  };
491
517
 
492
518
  // src/DataTable/components/VirtualTable.tsx
493
- import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
519
+ import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
494
520
  function VirtualTable({ table, containerRef, ...props }) {
495
521
  var _a, _b;
496
522
  const { rows } = table.getRowModel();
@@ -502,27 +528,29 @@ function VirtualTable({ table, containerRef, ...props }) {
502
528
  const virtualRows = rowVirtualizer.getVirtualItems();
503
529
  const paddingTop = virtualRows.length > 0 ? ((_a = virtualRows == null ? void 0 : virtualRows[0]) == null ? void 0 : _a.start) || 0 : 0;
504
530
  const paddingBottom = virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (((_b = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b.end) || 0) : 0;
505
- return /* @__PURE__ */ jsxs7(Table5, {
531
+ return /* @__PURE__ */ jsxs7(Table6, {
506
532
  children: [
507
- /* @__PURE__ */ jsx12(TableHeader, {
533
+ /* @__PURE__ */ jsx13(TableHeader, {
508
534
  sticky: props.stickyHeader,
509
535
  table
510
536
  }),
511
- /* @__PURE__ */ jsxs7(Table5.Body, {
537
+ /* @__PURE__ */ jsxs7(Table6.Body, {
512
538
  children: [
513
- /* @__PURE__ */ jsx12(PaddingRow, {
539
+ /* @__PURE__ */ jsx13(PaddingRow, {
514
540
  height: paddingTop
515
541
  }),
516
- virtualRows.map((virtualRow) => {
542
+ rows.length ? virtualRows.map((virtualRow) => {
517
543
  const row = rows[virtualRow.index];
518
- return /* @__PURE__ */ jsx12(Table5.Row, {
544
+ return /* @__PURE__ */ jsx13(Table6.Row, {
519
545
  active: row.getIsSelected(),
520
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx12(Table5.Cell, {
546
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx13(Table6.Cell, {
521
547
  children: flexRender3(cell.column.columnDef.cell, cell.getContext())
522
548
  }, cell.id))
523
549
  }, row.id);
550
+ }) : /* @__PURE__ */ jsx13(PlaceholderRow, {
551
+ isLoading: props.isLoading
524
552
  }),
525
- /* @__PURE__ */ jsx12(PaddingRow, {
553
+ /* @__PURE__ */ jsx13(PaddingRow, {
526
554
  height: paddingBottom
527
555
  })
528
556
  ]
@@ -532,8 +560,8 @@ function VirtualTable({ table, containerRef, ...props }) {
532
560
  }
533
561
 
534
562
  // src/DataTable/DataTable.tsx
535
- import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
536
- var DataTableWrapper = styled8.div`
563
+ import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
564
+ var DataTableWrapper = styled9.div`
537
565
  width: ${(props) => props.width ?? "100%"};
538
566
 
539
567
  .--table-container {
@@ -546,7 +574,14 @@ var DataTableWrapper = styled8.div`
546
574
  }
547
575
  }
548
576
  `;
549
- function DataTable({ columns, data, header, filters, config }) {
577
+ function DataTable({
578
+ columns,
579
+ data,
580
+ isLoading,
581
+ header,
582
+ filters,
583
+ config
584
+ }) {
550
585
  const [columnVisibility, setColumnVisibility] = useAtom2(columnVisibilityAtom);
551
586
  const [globalFilter, setGlobalFilter] = useAtom2(globalFilterAtom);
552
587
  const [sorting, setSorting] = useAtom2(tableSortingAtom);
@@ -567,6 +602,7 @@ function DataTable({ columns, data, header, filters, config }) {
567
602
  columnVisibility
568
603
  },
569
604
  onRowSelectionChange: setRowSelectionState,
605
+ enableMultiRowSelection: (config == null ? void 0 : config.rowSelection) === "multiple",
570
606
  enableSorting: config == null ? void 0 : config.sortable,
571
607
  onSortingChange: enableOrUndefined(config == null ? void 0 : config.sortable, setSorting),
572
608
  getSortedRowModel: getSortedRowModel(),
@@ -579,24 +615,26 @@ function DataTable({ columns, data, header, filters, config }) {
579
615
  height: config == null ? void 0 : config.height,
580
616
  width: config == null ? void 0 : config.width,
581
617
  children: [
582
- /* @__PURE__ */ jsx13(DataTableHeader, {
618
+ /* @__PURE__ */ jsx14(DataTableHeader, {
583
619
  tableCaption: header == null ? void 0 : header.tableCaption,
584
620
  enableGlobalFilter: filters == null ? void 0 : filters.globalFilter,
585
621
  globalFilterPlaceholder: filters == null ? void 0 : filters.globalFilterPlaceholder,
586
622
  captionPadding: header == null ? void 0 : header.captionPadding,
587
- filterActions: /* @__PURE__ */ jsx13(ColumnSelect, {
623
+ filterActions: /* @__PURE__ */ jsx14(ColumnSelect, {
588
624
  table
589
625
  })
590
626
  }),
591
- /* @__PURE__ */ jsx13("div", {
627
+ /* @__PURE__ */ jsx14("div", {
592
628
  ref: tableContainerRef,
593
629
  className: "--table-container",
594
- children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ jsx13(VirtualTable, {
630
+ children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ jsx14(VirtualTable, {
595
631
  containerRef: tableContainerRef,
596
632
  table,
633
+ isLoading,
597
634
  stickyHeader: header == null ? void 0 : header.stickyHeader
598
- }) : /* @__PURE__ */ jsx13(BasicTable, {
635
+ }) : /* @__PURE__ */ jsx14(BasicTable, {
599
636
  table,
637
+ isLoading,
600
638
  stickyHeader: header == null ? void 0 : header.stickyHeader
601
639
  })
602
640
  })
@@ -606,9 +644,9 @@ function DataTable({ columns, data, header, filters, config }) {
606
644
 
607
645
  // src/DataTable/Provider.tsx
608
646
  import { Provider } from "jotai";
609
- import { jsx as jsx14 } from "react/jsx-runtime";
647
+ import { jsx as jsx15 } from "react/jsx-runtime";
610
648
  function DataTableProvider({ children, ...props }) {
611
- return /* @__PURE__ */ jsx14(Provider, {
649
+ return /* @__PURE__ */ jsx15(Provider, {
612
650
  ...props,
613
651
  children
614
652
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/apollo-components",
3
- "version": "1.2.2",
3
+ "version": "1.3.1",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",