@equinor/apollo-components 1.3.0 → 1.4.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.mjs CHANGED
@@ -139,16 +139,229 @@ var ChipsCell = (props) => {
139
139
  });
140
140
  };
141
141
 
142
+ // src/cells/DynamicCell.tsx
143
+ import { Table as Table2 } from "@equinor/eds-core-react";
144
+ import { flexRender } from "@tanstack/react-table";
145
+ import styled5 from "styled-components";
146
+
147
+ // src/cells/StickyCell.tsx
148
+ import { Table } from "@equinor/eds-core-react";
149
+ import styled4 from "styled-components";
150
+ var StickyCell = styled4(Table.Cell)`
151
+ position: sticky;
152
+ right: 0;
153
+ top: 0;
154
+ z-index: 4;
155
+ `;
156
+ var StickyHeaderCell = styled4(StickyCell)`
157
+ z-index: 5;
158
+ `;
159
+
160
+ // src/cells/styles.ts
161
+ import { css as css2 } from "styled-components";
162
+ var leftCellShadow = css2`
163
+ &:before {
164
+ box-shadow: -1px 0 1px -1px inset;
165
+ content: ' ';
166
+ height: 100%;
167
+ top: 0;
168
+ left: -1px;
169
+ position: absolute;
170
+ width: 1px;
171
+ }
172
+ `;
173
+
174
+ // src/cells/DynamicCell.tsx
175
+ import { jsx as jsx4 } from "react/jsx-runtime";
176
+ var StyledStickyCell = styled5(StickyCell)`
177
+ background-clip: padding-box;
178
+ ${leftCellShadow}
179
+ `;
180
+ var StyledCell = styled5(Table2.Cell)`
181
+ background-color: ${(props) => props.backgroundColor ? props.backgroundColor + " !important" : void 0};
182
+ `;
183
+ function DynamicCell({ cell, highlight }) {
184
+ var _a;
185
+ const cellContent = flexRender(cell.column.columnDef.cell, cell.getContext());
186
+ if ((_a = cell.column.columnDef.meta) == null ? void 0 : _a.sticky) {
187
+ return /* @__PURE__ */ jsx4(StyledStickyCell, {
188
+ "data-column": cell.column.id,
189
+ children: cellContent
190
+ });
191
+ }
192
+ return /* @__PURE__ */ jsx4(StyledCell, {
193
+ "data-column": cell.column.id,
194
+ backgroundColor: highlight ? "#d5eaf4" : void 0,
195
+ children: cellContent
196
+ });
197
+ }
198
+
199
+ // src/cells/HierarchyCell.tsx
200
+ import { tokens as tokens4 } from "@equinor/eds-tokens";
201
+ import styled7, { css as css3 } from "styled-components";
202
+
203
+ // src/cells/TypographyCustom.tsx
204
+ import {
205
+ Typography as EdsTypography
206
+ } from "@equinor/eds-core-react";
207
+ import { tokens as tokens3 } from "@equinor/eds-tokens";
208
+ import styled6 from "styled-components";
209
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
210
+ var truncateStyle = {
211
+ overflow: "hidden",
212
+ whiteSpace: "nowrap",
213
+ textOverflow: "ellipsis"
214
+ };
215
+ var TypographyCustom = (props) => {
216
+ const { noWrap, showAllOnHover, style: styleFromProps, ...edsTypographyProps } = props;
217
+ if (noWrap && showAllOnHover)
218
+ return /* @__PURE__ */ jsxs3(HoverCapture, {
219
+ children: [
220
+ /* @__PURE__ */ jsx5(ShowAllWrapperWrapper, {
221
+ children: /* @__PURE__ */ jsx5(EdsTypography, {
222
+ ...edsTypographyProps,
223
+ ref: void 0,
224
+ style: {
225
+ ...styleFromProps,
226
+ whiteSpace: "nowrap"
227
+ }
228
+ })
229
+ }),
230
+ /* @__PURE__ */ jsx5(EdsTypography, {
231
+ ...edsTypographyProps,
232
+ style: {
233
+ ...styleFromProps,
234
+ ...truncateStyle
235
+ }
236
+ })
237
+ ]
238
+ });
239
+ return /* @__PURE__ */ jsx5(EdsTypography, {
240
+ ...edsTypographyProps,
241
+ style: { ...styleFromProps, ...noWrap ? truncateStyle : {} }
242
+ });
243
+ };
244
+ var HoverCapture = styled6.div`
245
+ position: relative;
246
+ z-index: 0;
247
+
248
+ padding: 0.5em;
249
+ margin: -0.5em;
250
+
251
+ &:hover > * {
252
+ opacity: 1;
253
+ }
254
+ `;
255
+ var ShowAllWrapperWrapper = styled6.div`
256
+ position: absolute;
257
+ z-index: 1;
258
+ pointer-events: none;
259
+
260
+ opacity: 0;
261
+ padding-right: 1em;
262
+ background-color: ${tokens3.colors.interactive.table__cell__fill_hover.hex};
263
+ `;
264
+
265
+ // src/cells/HierarchyCell.tsx
266
+ import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
267
+ var CellWrapper = styled7(TypographyCustom)`
268
+ height: 100%;
269
+ display: flex;
270
+ align-items: center;
271
+
272
+ ${({ depth, expanded }) => expanded && depth === 0 && "font-weight: bold;"}
273
+
274
+ ${({ depth }) => depth > 0 && css3`
275
+ border-left: 3px solid ${tokens4.colors.infographic.primary__moss_green_34.hex};
276
+ gap: 0.5rem;
277
+ .--divider {
278
+ width: ${depth * 32}px;
279
+ background-color: ${tokens4.colors.infographic.primary__moss_green_34.hex};
280
+ height: 3px;
281
+ border-radius: 0 5px 5px 0;
282
+ }
283
+ `}
284
+ `;
285
+ function HierarchyCell(cell) {
286
+ return /* @__PURE__ */ jsxs4(CellWrapper, {
287
+ depth: cell.row.depth,
288
+ expanded: cell.row.getIsExpanded(),
289
+ children: [
290
+ /* @__PURE__ */ jsx6("span", {
291
+ className: "--divider"
292
+ }),
293
+ cell.getValue()
294
+ ]
295
+ });
296
+ }
297
+
298
+ // src/cells/SelectColumnDef.tsx
299
+ import { Button as Button2, Checkbox, Icon as Icon3, Radio } from "@equinor/eds-core-react";
300
+ import { chevron_down, chevron_up } from "@equinor/eds-icons";
301
+ import styled8 from "styled-components";
302
+ import { Fragment, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
303
+ var CellWrapper2 = styled8.div`
304
+ display: flex;
305
+ align-items: center;
306
+ width: 48px;
307
+ margin-left: -16px;
308
+ `;
309
+ function SelectColumnDef(selectionMode) {
310
+ return {
311
+ id: "select",
312
+ header: ({ table }) => selectionMode !== "single" ? /* @__PURE__ */ jsx7(CellWrapper2, {
313
+ children: /* @__PURE__ */ jsx7(Checkbox, {
314
+ checked: table.getIsAllRowsSelected(),
315
+ indeterminate: table.getIsSomeRowsSelected(),
316
+ "aria-label": table.getIsAllRowsSelected() ? "Deselect all rows" : "Select all rows",
317
+ onChange: table.getToggleAllRowsSelectedHandler()
318
+ })
319
+ }) : null,
320
+ cell: ({ table, row }) => {
321
+ const paddingLeft = "0px";
322
+ return /* @__PURE__ */ jsx7(CellWrapper2, {
323
+ paddingLeft,
324
+ rowDepth: row.depth,
325
+ children: /* @__PURE__ */ jsxs5(Fragment, {
326
+ children: [
327
+ selectionMode === "single" ? /* @__PURE__ */ jsx7(Radio, {
328
+ checked: row.getIsSelected(),
329
+ "aria-label": `Select row ${row.id}`,
330
+ onChange: row.getToggleSelectedHandler()
331
+ }) : /* @__PURE__ */ jsx7(Checkbox, {
332
+ checked: row.getIsSelected(),
333
+ indeterminate: row.getIsSomeSelected(),
334
+ "aria-label": `Select row ${row.id}`,
335
+ onChange: row.getToggleSelectedHandler()
336
+ }),
337
+ row.getCanExpand() && table.options.enableExpanding && /* @__PURE__ */ jsx7(Button2, {
338
+ variant: "ghost_icon",
339
+ color: "secondary",
340
+ "aria-label": row.getIsExpanded() ? "Close group" : "Expand group",
341
+ onClick: row.getToggleExpandedHandler(),
342
+ style: { cursor: "pointer" },
343
+ children: /* @__PURE__ */ jsx7(Icon3, {
344
+ data: row.getIsExpanded() ? chevron_up : chevron_down
345
+ })
346
+ })
347
+ ]
348
+ })
349
+ });
350
+ }
351
+ };
352
+ }
353
+
142
354
  // src/DataTable/DataTable.tsx
143
355
  import {
144
356
  getCoreRowModel,
357
+ getExpandedRowModel,
145
358
  getFilteredRowModel,
146
359
  getSortedRowModel,
147
360
  useReactTable
148
361
  } from "@tanstack/react-table";
149
362
  import { useAtom as useAtom2 } from "jotai";
150
- import { useRef as useRef2 } from "react";
151
- import styled8 from "styled-components";
363
+ import { useEffect as useEffect2, useRef as useRef2 } from "react";
364
+ import styled14 from "styled-components";
152
365
 
153
366
  // src/DataTable/atoms.ts
154
367
  import { atom } from "jotai";
@@ -156,85 +369,129 @@ var columnVisibilityAtom = atom({});
156
369
  var globalFilterAtom = atom("");
157
370
  var rowSelectionAtom = atom({});
158
371
  var tableSortingAtom = atom([]);
372
+ var expandedRowsAtom = atom({});
159
373
 
160
374
  // src/DataTable/components/BasicTable.tsx
161
375
  import { Table as EdsTable } from "@equinor/eds-core-react";
162
- import { flexRender as flexRender2 } from "@tanstack/react-table";
376
+ import { flexRender as flexRender3 } from "@tanstack/react-table";
377
+
378
+ // src/DataTable/components/PlaceholderRow.tsx
379
+ import { DotProgress, Table as Table3, Typography } from "@equinor/eds-core-react";
380
+ import styled9 from "styled-components";
381
+ import { jsx as jsx8 } from "react/jsx-runtime";
382
+ var PlaceholderTextWrapper = styled9.div`
383
+ display: flex;
384
+ justify-content: center;
385
+ `;
386
+ function PlaceholderRow({ isLoading }) {
387
+ return /* @__PURE__ */ jsx8(Table3.Row, {
388
+ children: /* @__PURE__ */ jsx8(Table3.Cell, {
389
+ colSpan: 100,
390
+ children: /* @__PURE__ */ jsx8(PlaceholderTextWrapper, {
391
+ children: isLoading ? /* @__PURE__ */ jsx8(DotProgress, {
392
+ color: "primary"
393
+ }) : /* @__PURE__ */ jsx8(Typography, {
394
+ children: "No data available"
395
+ })
396
+ })
397
+ })
398
+ });
399
+ }
163
400
 
164
401
  // src/DataTable/components/TableHeader.tsx
165
- import { Table as Table2 } from "@equinor/eds-core-react";
402
+ import { Table as Table5 } from "@equinor/eds-core-react";
166
403
 
167
- // src/DataTable/components/HeaderCell.tsx
168
- import { Icon as Icon3, Table } from "@equinor/eds-core-react";
169
- import { arrow_down, arrow_up } from "@equinor/eds-icons";
170
- 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`
404
+ // src/cells/HeaderCell.tsx
405
+ import { Icon as Icon4, Table as Table4 } from "@equinor/eds-core-react";
406
+ import { arrow_drop_down, arrow_drop_up } from "@equinor/eds-icons";
407
+ import { flexRender as flexRender2 } from "@tanstack/react-table";
408
+ import styled10 from "styled-components";
409
+ import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
410
+ var HeaderDiv = styled10.div`
174
411
  display: flex;
175
412
  align-items: center;
176
413
  gap: 0.25rem;
177
414
  `;
415
+ var StyledStickyCell2 = styled10(StickyCell)`
416
+ z-index: 5;
417
+ ${leftCellShadow}
418
+ `;
178
419
  var HeaderCell = ({ header }) => {
179
- return /* @__PURE__ */ jsx4(Table.Cell, {
420
+ var _a;
421
+ if ((_a = header.column.columnDef.meta) == null ? void 0 : _a.sticky)
422
+ return /* @__PURE__ */ jsx9(StyledStickyCell2, {
423
+ colSpan: header.colSpan,
424
+ children: /* @__PURE__ */ jsx9(HeaderContent, {
425
+ header
426
+ })
427
+ }, header.id);
428
+ return /* @__PURE__ */ jsx9(Table4.Cell, {
180
429
  colSpan: header.colSpan,
181
- children: header.isPlaceholder ? null : /* @__PURE__ */ jsxs3(HeaderDiv, {
182
- onClick: header.column.getToggleSortingHandler(),
183
- children: [
184
- flexRender(header.column.columnDef.header, header.getContext()),
185
- {
186
- asc: /* @__PURE__ */ jsx4(Icon3, {
187
- data: arrow_down
188
- }),
189
- desc: /* @__PURE__ */ jsx4(Icon3, {
190
- data: arrow_up
191
- })
192
- }[header.column.getIsSorted()] ?? null
193
- ]
430
+ children: /* @__PURE__ */ jsx9(HeaderContent, {
431
+ header
194
432
  })
195
433
  }, header.id);
196
434
  };
435
+ function HeaderContent({ header }) {
436
+ if (header.isPlaceholder)
437
+ return null;
438
+ return /* @__PURE__ */ jsxs6(HeaderDiv, {
439
+ onClick: header.column.getToggleSortingHandler(),
440
+ children: [
441
+ flexRender2(header.column.columnDef.header, header.getContext()),
442
+ {
443
+ asc: /* @__PURE__ */ jsx9(Icon4, {
444
+ data: arrow_drop_down
445
+ }),
446
+ desc: /* @__PURE__ */ jsx9(Icon4, {
447
+ data: arrow_drop_up
448
+ })
449
+ }[header.column.getIsSorted()] ?? null
450
+ ]
451
+ });
452
+ }
197
453
 
198
454
  // src/DataTable/components/TableHeader.tsx
199
- import { jsx as jsx5 } from "react/jsx-runtime";
200
- var TableHeader = ({ table, sticky }) => /* @__PURE__ */ jsx5(Table2.Head, {
455
+ import { jsx as jsx10 } from "react/jsx-runtime";
456
+ var TableHeader = ({ table, sticky }) => /* @__PURE__ */ jsx10(Table5.Head, {
201
457
  sticky,
202
- children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx5(Table2.Row, {
203
- children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx5(HeaderCell, {
458
+ children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx10(Table5.Row, {
459
+ children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx10(HeaderCell, {
204
460
  header
205
461
  }, header.id))
206
462
  }, headerGroup.id))
207
463
  });
208
464
 
209
465
  // src/DataTable/components/BasicTable.tsx
210
- import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
211
- function BasicTable({ table, stickyHeader }) {
212
- return /* @__PURE__ */ jsxs4(EdsTable, {
466
+ import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
467
+ function BasicTable({ table, stickyHeader, isLoading }) {
468
+ const tableRows = table.getRowModel().rows;
469
+ return /* @__PURE__ */ jsxs7(EdsTable, {
213
470
  children: [
214
- /* @__PURE__ */ jsx6(TableHeader, {
471
+ /* @__PURE__ */ jsx11(TableHeader, {
215
472
  sticky: stickyHeader,
216
473
  table
217
474
  }),
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, {
221
- children: flexRender2(cell.column.columnDef.cell, cell.getContext())
475
+ /* @__PURE__ */ jsx11(EdsTable.Body, {
476
+ children: tableRows.length ? tableRows.map((row) => /* @__PURE__ */ jsx11(EdsTable.Row, {
477
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx11(EdsTable.Cell, {
478
+ children: flexRender3(cell.column.columnDef.cell, cell.getContext())
222
479
  }, cell.id))
223
- }, row.id))
480
+ }, row.id)) : /* @__PURE__ */ jsx11(PlaceholderRow, {
481
+ isLoading
482
+ })
224
483
  })
225
484
  ]
226
485
  });
227
486
  }
228
487
 
229
488
  // src/DataTable/components/ColumnSelect.tsx
230
- import { Button as Button2, Checkbox as Checkbox2, Divider, Icon as Icon4, Popover } from "@equinor/eds-core-react";
489
+ import { Button as Button3, Checkbox as Checkbox2, Divider, Icon as Icon5, Popover } from "@equinor/eds-core-react";
231
490
  import { close, view_column } from "@equinor/eds-icons";
232
491
  import { useRef, useState as useState2 } from "react";
233
- import styled5 from "styled-components";
492
+ import styled11 from "styled-components";
234
493
 
235
494
  // src/DataTable/utils.tsx
236
- import { Checkbox } from "@equinor/eds-core-react";
237
- import { jsx as jsx7 } from "react/jsx-runtime";
238
495
  function enableOrUndefined(enabled, value) {
239
496
  return Boolean(enabled) ? value : void 0;
240
497
  }
@@ -244,41 +501,22 @@ function getColumnHeader(column) {
244
501
  return column.id;
245
502
  return typeof columnHeader === "string" ? columnHeader : column.id;
246
503
  }
247
- function prependSelectColumnIfEnabled(columns, config) {
248
- if (!Boolean(config == null ? void 0 : config.rowSelection))
504
+ function prependSelectColumn(columns, config) {
505
+ if (!(config == null ? void 0 : config.selectColumn))
249
506
  return columns;
250
- const selectColumn = {
251
- id: "select",
252
- header: ({ table }) => (config == null ? void 0 : config.rowSelection) === "multiple" ? /* @__PURE__ */ jsx7("div", {
253
- style: { width: "48px" },
254
- children: /* @__PURE__ */ jsx7(Checkbox, {
255
- checked: table.getIsAllRowsSelected(),
256
- indeterminate: table.getIsSomeRowsSelected(),
257
- "aria-label": table.getIsAllRowsSelected() ? "Deselect all rows" : "Select all rows",
258
- onChange: table.getToggleAllRowsSelectedHandler()
259
- })
260
- }) : null,
261
- cell: ({ row }) => /* @__PURE__ */ jsx7("div", {
262
- style: { width: "48px" },
263
- children: /* @__PURE__ */ jsx7(Checkbox, {
264
- checked: row.getIsSelected(),
265
- indeterminate: row.getIsSomeSelected(),
266
- "aria-label": `Select row ${row.id}`,
267
- onChange: row.getToggleSelectedHandler()
268
- })
269
- })
270
- };
271
- return [selectColumn, ...columns];
507
+ if (config.selectColumn === "default")
508
+ return [SelectColumnDef(config == null ? void 0 : config.rowSelectionMode), ...columns];
509
+ return [config.selectColumn(), ...columns];
272
510
  }
273
511
 
274
512
  // src/DataTable/components/ColumnSelect.tsx
275
- import { Fragment, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
276
- var ColumnSelectContent = styled5.div`
513
+ import { Fragment as Fragment2, jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
514
+ var ColumnSelectContent = styled11.div`
277
515
  display: grid;
278
516
  grid-template-columns: repeat(2, 1fr);
279
517
  grid-gap: 0.5rem;
280
518
  `;
281
- var ActionsWrapper = styled5.div`
519
+ var ActionsWrapper = styled11.div`
282
520
  display: flex;
283
521
  align-items: center;
284
522
  justify-content: flex-end;
@@ -288,9 +526,9 @@ function ColumnSelect({ table }) {
288
526
  const [isOpen, setIsOpen] = useState2(false);
289
527
  const referenceElement = useRef(null);
290
528
  const selectableColumns = table.getAllLeafColumns().filter((column) => column.id !== "select");
291
- return /* @__PURE__ */ jsxs5(Fragment, {
529
+ return /* @__PURE__ */ jsxs8(Fragment2, {
292
530
  children: [
293
- /* @__PURE__ */ jsx8(Button2, {
531
+ /* @__PURE__ */ jsx12(Button3, {
294
532
  "aria-haspopup": true,
295
533
  id: "column-select-anchor",
296
534
  "aria-controls": "column-select-popover",
@@ -298,28 +536,28 @@ function ColumnSelect({ table }) {
298
536
  ref: referenceElement,
299
537
  variant: "ghost_icon",
300
538
  onClick: () => setIsOpen(true),
301
- children: /* @__PURE__ */ jsx8(Icon4, {
539
+ children: /* @__PURE__ */ jsx12(Icon5, {
302
540
  name: "view_column",
303
541
  data: view_column
304
542
  })
305
543
  }),
306
- /* @__PURE__ */ jsxs5(Popover, {
544
+ /* @__PURE__ */ jsxs8(Popover, {
307
545
  open: isOpen,
308
546
  id: "column-select-popover",
309
547
  anchorEl: referenceElement.current,
310
548
  placement: "bottom-end",
311
549
  onClose: () => setIsOpen(false),
312
550
  children: [
313
- /* @__PURE__ */ jsxs5(Popover.Header, {
551
+ /* @__PURE__ */ jsxs8(Popover.Header, {
314
552
  children: [
315
- /* @__PURE__ */ jsx8(Popover.Title, {
553
+ /* @__PURE__ */ jsx12(Popover.Title, {
316
554
  children: "Column settings"
317
555
  }),
318
- /* @__PURE__ */ jsx8(Button2, {
556
+ /* @__PURE__ */ jsx12(Button3, {
319
557
  variant: "ghost_icon",
320
558
  "aria-label": "Close column select",
321
559
  onClick: () => setIsOpen(false),
322
- children: /* @__PURE__ */ jsx8(Icon4, {
560
+ children: /* @__PURE__ */ jsx12(Icon5, {
323
561
  name: "close",
324
562
  data: close,
325
563
  size: 24
@@ -327,22 +565,22 @@ function ColumnSelect({ table }) {
327
565
  })
328
566
  ]
329
567
  }),
330
- /* @__PURE__ */ jsxs5(Popover.Content, {
568
+ /* @__PURE__ */ jsxs8(Popover.Content, {
331
569
  children: [
332
- /* @__PURE__ */ jsx8(ColumnSelectContent, {
570
+ /* @__PURE__ */ jsx12(ColumnSelectContent, {
333
571
  children: selectableColumns.map((column) => {
334
- return /* @__PURE__ */ jsx8(Checkbox2, {
572
+ return /* @__PURE__ */ jsx12(Checkbox2, {
335
573
  checked: column.getIsVisible(),
336
574
  label: getColumnHeader(column),
337
575
  onChange: column.getToggleVisibilityHandler()
338
576
  }, column.id);
339
577
  })
340
578
  }),
341
- /* @__PURE__ */ jsx8(Divider, {
579
+ /* @__PURE__ */ jsx12(Divider, {
342
580
  variant: "small"
343
581
  }),
344
- /* @__PURE__ */ jsx8(ActionsWrapper, {
345
- children: /* @__PURE__ */ jsx8(Button2, {
582
+ /* @__PURE__ */ jsx12(ActionsWrapper, {
583
+ children: /* @__PURE__ */ jsx12(Button3, {
346
584
  color: "secondary",
347
585
  variant: "ghost",
348
586
  disabled: table.getIsAllColumnsVisible(),
@@ -359,21 +597,21 @@ function ColumnSelect({ table }) {
359
597
  }
360
598
 
361
599
  // src/DataTable/components/DataTableHeader.tsx
362
- import { Typography } from "@equinor/eds-core-react";
600
+ import { Typography as Typography2 } from "@equinor/eds-core-react";
363
601
  import { search } from "@equinor/eds-icons";
364
602
  import { useAtom } from "jotai";
365
- import styled7 from "styled-components";
603
+ import styled13 from "styled-components";
366
604
 
367
605
  // src/DataTable/filters/DebouncedInput.tsx
368
- import { Button as Button3, Icon as Icon5, Input, Tooltip } from "@equinor/eds-core-react";
606
+ import { Button as Button4, Icon as Icon6, Input, Tooltip } from "@equinor/eds-core-react";
369
607
  import { close as close2 } from "@equinor/eds-icons";
370
608
  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`
609
+ import styled12 from "styled-components";
610
+ import { jsx as jsx13 } from "react/jsx-runtime";
611
+ var Wrapper3 = styled12.div`
374
612
  width: 200px;
375
613
  `;
376
- var CloseButton = styled6(Button3)`
614
+ var CloseButton = styled12(Button4)`
377
615
  width: 24px;
378
616
  height: 24px;
379
617
  `;
@@ -394,21 +632,21 @@ function DebouncedInput({
394
632
  }, debounce);
395
633
  return () => clearTimeout(timeout);
396
634
  }, [value]);
397
- return /* @__PURE__ */ jsx9(Wrapper3, {
398
- children: /* @__PURE__ */ jsx9(Input, {
635
+ return /* @__PURE__ */ jsx13(Wrapper3, {
636
+ children: /* @__PURE__ */ jsx13(Input, {
399
637
  ...props,
400
638
  value,
401
- leftAdornments: icon && /* @__PURE__ */ jsx9(Icon5, {
639
+ leftAdornments: icon && /* @__PURE__ */ jsx13(Icon6, {
402
640
  name: icon.name,
403
641
  data: icon,
404
642
  size: 18
405
643
  }),
406
- rightAdornments: !!value && /* @__PURE__ */ jsx9(Tooltip, {
644
+ rightAdornments: !!value && /* @__PURE__ */ jsx13(Tooltip, {
407
645
  title: "Clear input",
408
- children: /* @__PURE__ */ jsx9(CloseButton, {
646
+ children: /* @__PURE__ */ jsx13(CloseButton, {
409
647
  variant: "ghost_icon",
410
648
  onClick: () => setValue(""),
411
- children: /* @__PURE__ */ jsx9(Icon5, {
649
+ children: /* @__PURE__ */ jsx13(Icon6, {
412
650
  name: close2.name,
413
651
  data: close2,
414
652
  size: 18
@@ -431,15 +669,15 @@ var fuzzyFilter = (row, columnId, value, addMeta) => {
431
669
  };
432
670
 
433
671
  // src/DataTable/components/DataTableHeader.tsx
434
- import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
435
- var DataTableHeaderWrapper = styled7.div`
672
+ import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
673
+ var DataTableHeaderWrapper = styled13.div`
436
674
  display: flex;
437
675
  align-items: center;
438
676
  justify-content: space-between;
439
677
  gap: 0.5rem;
440
678
  padding: ${(props) => props.captionPadding ?? "1rem"};
441
679
  `;
442
- var FilterContainer = styled7.div`
680
+ var FilterContainer = styled13.div`
443
681
  display: flex;
444
682
  align-items: center;
445
683
  gap: 1rem;
@@ -447,18 +685,18 @@ var FilterContainer = styled7.div`
447
685
  `;
448
686
  var DataTableHeader = (props) => {
449
687
  const [globalFilter, setGlobalFilter] = useAtom(globalFilterAtom);
450
- return /* @__PURE__ */ jsxs6(DataTableHeaderWrapper, {
688
+ return /* @__PURE__ */ jsxs9(DataTableHeaderWrapper, {
451
689
  className: "--table-caption",
452
690
  captionPadding: props.captionPadding,
453
691
  children: [
454
- (props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ jsx10(Typography, {
692
+ (props == null ? void 0 : props.tableCaption) && /* @__PURE__ */ jsx14(Typography2, {
455
693
  variant: "h3",
456
694
  children: props == null ? void 0 : props.tableCaption
457
695
  }),
458
- (props == null ? void 0 : props.enableGlobalFilter) && /* @__PURE__ */ jsxs6(FilterContainer, {
696
+ (props == null ? void 0 : props.enableGlobalFilter) && /* @__PURE__ */ jsxs9(FilterContainer, {
459
697
  className: "--filter-container",
460
698
  children: [
461
- /* @__PURE__ */ jsx10(DebouncedInput, {
699
+ /* @__PURE__ */ jsx14(DebouncedInput, {
462
700
  value: globalFilter,
463
701
  icon: search,
464
702
  placeholder: (props == null ? void 0 : props.globalFilterPlaceholder) ?? "Search all columns",
@@ -472,25 +710,25 @@ var DataTableHeader = (props) => {
472
710
  };
473
711
 
474
712
  // src/DataTable/components/VirtualTable.tsx
475
- import { Table as Table5 } from "@equinor/eds-core-react";
476
- import { flexRender as flexRender3 } from "@tanstack/react-table";
713
+ import { Table as Table8 } from "@equinor/eds-core-react";
714
+ import { flexRender as flexRender4 } from "@tanstack/react-table";
477
715
  import { useVirtualizer } from "@tanstack/react-virtual";
478
716
 
479
717
  // src/DataTable/components/PaddingRow.tsx
480
- import { Table as Table4 } from "@equinor/eds-core-react";
481
- import { jsx as jsx11 } from "react/jsx-runtime";
718
+ import { Table as Table7 } from "@equinor/eds-core-react";
719
+ import { jsx as jsx15 } from "react/jsx-runtime";
482
720
  var PaddingRow = (props) => {
483
721
  if (!props.height)
484
722
  return null;
485
- return /* @__PURE__ */ jsx11(Table4.Row, {
486
- children: /* @__PURE__ */ jsx11(Table4.Cell, {
723
+ return /* @__PURE__ */ jsx15(Table7.Row, {
724
+ children: /* @__PURE__ */ jsx15(Table7.Cell, {
487
725
  style: { height: `${props.height}px` }
488
726
  })
489
727
  });
490
728
  };
491
729
 
492
730
  // src/DataTable/components/VirtualTable.tsx
493
- import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
731
+ import { jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
494
732
  function VirtualTable({ table, containerRef, ...props }) {
495
733
  var _a, _b;
496
734
  const { rows } = table.getRowModel();
@@ -502,27 +740,29 @@ function VirtualTable({ table, containerRef, ...props }) {
502
740
  const virtualRows = rowVirtualizer.getVirtualItems();
503
741
  const paddingTop = virtualRows.length > 0 ? ((_a = virtualRows == null ? void 0 : virtualRows[0]) == null ? void 0 : _a.start) || 0 : 0;
504
742
  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, {
743
+ return /* @__PURE__ */ jsxs10(Table8, {
506
744
  children: [
507
- /* @__PURE__ */ jsx12(TableHeader, {
745
+ /* @__PURE__ */ jsx16(TableHeader, {
508
746
  sticky: props.stickyHeader,
509
747
  table
510
748
  }),
511
- /* @__PURE__ */ jsxs7(Table5.Body, {
749
+ /* @__PURE__ */ jsxs10(Table8.Body, {
512
750
  children: [
513
- /* @__PURE__ */ jsx12(PaddingRow, {
751
+ /* @__PURE__ */ jsx16(PaddingRow, {
514
752
  height: paddingTop
515
753
  }),
516
- virtualRows.map((virtualRow) => {
754
+ rows.length ? virtualRows.map((virtualRow) => {
517
755
  const row = rows[virtualRow.index];
518
- return /* @__PURE__ */ jsx12(Table5.Row, {
756
+ return /* @__PURE__ */ jsx16(Table8.Row, {
519
757
  active: row.getIsSelected(),
520
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx12(Table5.Cell, {
521
- children: flexRender3(cell.column.columnDef.cell, cell.getContext())
758
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx16(Table8.Cell, {
759
+ children: flexRender4(cell.column.columnDef.cell, cell.getContext())
522
760
  }, cell.id))
523
761
  }, row.id);
762
+ }) : /* @__PURE__ */ jsx16(PlaceholderRow, {
763
+ isLoading: props.isLoading
524
764
  }),
525
- /* @__PURE__ */ jsx12(PaddingRow, {
765
+ /* @__PURE__ */ jsx16(PaddingRow, {
526
766
  height: paddingBottom
527
767
  })
528
768
  ]
@@ -532,8 +772,8 @@ function VirtualTable({ table, containerRef, ...props }) {
532
772
  }
533
773
 
534
774
  // src/DataTable/DataTable.tsx
535
- import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
536
- var DataTableWrapper = styled8.div`
775
+ import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
776
+ var DataTableWrapper = styled14.div`
537
777
  width: ${(props) => props.width ?? "100%"};
538
778
 
539
779
  .--table-container {
@@ -543,61 +783,89 @@ var DataTableWrapper = styled8.div`
543
783
 
544
784
  table {
545
785
  width: 100%;
786
+ table-layout: auto;
546
787
  }
547
788
  }
548
789
  `;
549
- function DataTable({ columns, data, header, filters, config }) {
790
+ function DataTable({
791
+ columns,
792
+ data,
793
+ isLoading,
794
+ header,
795
+ filters,
796
+ config
797
+ }) {
550
798
  const [columnVisibility, setColumnVisibility] = useAtom2(columnVisibilityAtom);
551
799
  const [globalFilter, setGlobalFilter] = useAtom2(globalFilterAtom);
552
800
  const [sorting, setSorting] = useAtom2(tableSortingAtom);
553
801
  const [rowSelectionState, setRowSelectionState] = useAtom2(rowSelectionAtom);
802
+ const [expanded, setExpanded] = useAtom2(expandedRowsAtom);
554
803
  function enableGlobalFilter(value) {
555
804
  return enableOrUndefined(filters == null ? void 0 : filters.globalFilter, value);
556
805
  }
557
806
  const table = useReactTable({
558
- columns: prependSelectColumnIfEnabled(columns, config),
807
+ columns: prependSelectColumn(columns, config),
559
808
  data,
560
- getCoreRowModel: getCoreRowModel(),
561
- getFilteredRowModel: enableGlobalFilter(getFilteredRowModel()),
562
809
  globalFilterFn: enableGlobalFilter(fuzzyFilter),
563
810
  state: {
811
+ expanded,
564
812
  globalFilter: enableGlobalFilter(globalFilter),
565
813
  sorting: enableOrUndefined(config == null ? void 0 : config.sortable, sorting),
566
814
  rowSelection: rowSelectionState,
567
815
  columnVisibility
568
816
  },
569
- onRowSelectionChange: setRowSelectionState,
570
- enableMultiRowSelection: (config == null ? void 0 : config.rowSelection) === "multiple",
817
+ defaultColumn: {
818
+ cell: (cell) => /* @__PURE__ */ jsx17(TypographyCustom, {
819
+ noWrap: true,
820
+ children: cell.getValue()
821
+ })
822
+ },
571
823
  enableSorting: config == null ? void 0 : config.sortable,
572
- onSortingChange: enableOrUndefined(config == null ? void 0 : config.sortable, setSorting),
824
+ enableExpanding: !(config == null ? void 0 : config.hideExpandControls),
825
+ enableMultiRowSelection: (config == null ? void 0 : config.rowSelectionMode) === "multiple",
826
+ enableSubRowSelection: (config == null ? void 0 : config.rowSelectionMode) !== "single",
827
+ getFilteredRowModel: enableGlobalFilter(getFilteredRowModel()),
828
+ getCoreRowModel: getCoreRowModel(),
829
+ getExpandedRowModel: getExpandedRowModel(),
573
830
  getSortedRowModel: getSortedRowModel(),
831
+ onExpandedChange: setExpanded,
832
+ onRowSelectionChange: setRowSelectionState,
833
+ onSortingChange: enableOrUndefined(config == null ? void 0 : config.sortable, setSorting),
574
834
  onColumnVisibilityChange: setColumnVisibility,
575
- onGlobalFilterChange: enableGlobalFilter(setGlobalFilter)
835
+ onGlobalFilterChange: enableGlobalFilter(setGlobalFilter),
836
+ getSubRows: config == null ? void 0 : config.getSubRows
576
837
  });
838
+ useEffect2(() => {
839
+ if (config && config.expandAllByDefault) {
840
+ table.toggleAllRowsExpanded();
841
+ }
842
+ }, [table, config == null ? void 0 : config.expandAllByDefault]);
577
843
  const tableContainerRef = useRef2(null);
578
- return /* @__PURE__ */ jsxs8(DataTableWrapper, {
844
+ return /* @__PURE__ */ jsxs11(DataTableWrapper, {
579
845
  captionPadding: header == null ? void 0 : header.captionPadding,
580
846
  height: config == null ? void 0 : config.height,
581
847
  width: config == null ? void 0 : config.width,
582
848
  children: [
583
- /* @__PURE__ */ jsx13(DataTableHeader, {
849
+ /* @__PURE__ */ jsx17(DataTableHeader, {
584
850
  tableCaption: header == null ? void 0 : header.tableCaption,
585
851
  enableGlobalFilter: filters == null ? void 0 : filters.globalFilter,
586
852
  globalFilterPlaceholder: filters == null ? void 0 : filters.globalFilterPlaceholder,
587
853
  captionPadding: header == null ? void 0 : header.captionPadding,
588
- filterActions: /* @__PURE__ */ jsx13(ColumnSelect, {
854
+ filterActions: /* @__PURE__ */ jsx17(ColumnSelect, {
589
855
  table
590
856
  })
591
857
  }),
592
- /* @__PURE__ */ jsx13("div", {
858
+ /* @__PURE__ */ jsx17("div", {
593
859
  ref: tableContainerRef,
594
860
  className: "--table-container",
595
- children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ jsx13(VirtualTable, {
861
+ children: (config == null ? void 0 : config.virtual) ? /* @__PURE__ */ jsx17(VirtualTable, {
596
862
  containerRef: tableContainerRef,
597
863
  table,
864
+ isLoading,
598
865
  stickyHeader: header == null ? void 0 : header.stickyHeader
599
- }) : /* @__PURE__ */ jsx13(BasicTable, {
866
+ }) : /* @__PURE__ */ jsx17(BasicTable, {
600
867
  table,
868
+ isLoading,
601
869
  stickyHeader: header == null ? void 0 : header.stickyHeader
602
870
  })
603
871
  })
@@ -607,9 +875,9 @@ function DataTable({ columns, data, header, filters, config }) {
607
875
 
608
876
  // src/DataTable/Provider.tsx
609
877
  import { Provider } from "jotai";
610
- import { jsx as jsx14 } from "react/jsx-runtime";
878
+ import { jsx as jsx18 } from "react/jsx-runtime";
611
879
  function DataTableProvider({ children, ...props }) {
612
- return /* @__PURE__ */ jsx14(Provider, {
880
+ return /* @__PURE__ */ jsx18(Provider, {
613
881
  ...props,
614
882
  children
615
883
  });
@@ -623,7 +891,13 @@ export {
623
891
  AppSidebar,
624
892
  ChipsCell,
625
893
  DataTable2 as DataTable,
894
+ DynamicCell,
895
+ HierarchyCell,
896
+ SelectColumnDef,
897
+ StickyCell,
898
+ TypographyCustom,
626
899
  globalFilterAtom,
900
+ prependSelectColumn,
627
901
  rowSelectionAtom,
628
902
  tableSortingAtom
629
903
  };