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