@equinor/apollo-components 3.4.0-beta.0 → 3.4.0-beta.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
@@ -1,7 +1,7 @@
1
1
  import { IconData } from '@equinor/eds-icons';
2
2
  import * as react from 'react';
3
- import { ReactNode, ReactElement, MouseEvent, HTMLProps, MutableRefObject, Dispatch, SetStateAction, SyntheticEvent } from 'react';
4
- import { CellContext, Cell, Header, Table, Row, SortingState, OnChangeFn, ColumnDef, RowSelectionState, ExpandedState, VisibilityState, HeaderContext } from '@tanstack/react-table';
3
+ import { ReactNode, ReactElement, HTMLProps, MutableRefObject, Dispatch, SetStateAction, SyntheticEvent } from 'react';
4
+ import { CellContext, Cell, Header, Table, Row, SortingState, OnChangeFn, ColumnDef, RowSelectionState, ExpandedState, ColumnPinningState, VisibilityState, HeaderContext, Column } from '@tanstack/react-table';
5
5
  import * as styled_components from 'styled-components';
6
6
  import * as _equinor_eds_core_react from '@equinor/eds-core-react';
7
7
  import { CellProps, TypographyProps as TypographyProps$1 } from '@equinor/eds-core-react';
@@ -83,7 +83,7 @@ interface RowConfig<T> {
83
83
  */
84
84
  rowWrapper?: TableRowWrapper<T>;
85
85
  getRowBackground?: (row: Row<T>) => string | undefined;
86
- onClick?: (row: Row<T>, e: MouseEvent) => void;
86
+ onClick?: (row: Row<T>) => void;
87
87
  onMouseEnter?: (row: Row<T>) => void;
88
88
  onMouseLeave?: (row: Row<T>) => void;
89
89
  }
@@ -151,6 +151,9 @@ interface DataTableProps<T> {
151
151
  enableSorting?: boolean;
152
152
  manualSorting?: boolean;
153
153
  };
154
+ columnPinning?: boolean | (ControlledState<ColumnPinningState> & {
155
+ enable?: boolean;
156
+ });
154
157
  globalFilter?: ControlledState<string>;
155
158
  columnVisibility?: ControlledState<VisibilityState>;
156
159
  /**
@@ -179,7 +182,7 @@ interface DataTableProps<T> {
179
182
  infiniteScroll?: InfiniteScrollConfig;
180
183
  }
181
184
  declare type ControlledState<T> = {
182
- state: T;
185
+ state?: T;
183
186
  /** Callback when state chagnes. Using this requires the state to be fully controlled. */
184
187
  onChange?: Dispatch<SetStateAction<T>>;
185
188
  };
@@ -218,6 +221,10 @@ declare const TypographyCustom: (props: TypographyProps) => JSX.Element;
218
221
  declare function stringToHslColor(str: string, s?: number, l?: number): string;
219
222
  /** Wrap an event handler and stop event propagation */
220
223
  declare function stopPropagation<T extends HTMLElement>(handler: (e: SyntheticEvent<T>) => void): (e: SyntheticEvent<T>) => void;
224
+ /** Used for calculating the `right` px value of pinned cells */
225
+ declare function getTotalRight<TData>(table: Table<TData>, column: Column<TData>): number;
226
+ declare function getIsFirstRightPinnedColumn<TData>(column: Column<TData>): boolean;
227
+ declare function getIsLastLeftPinnedColumn<TData>(table: Table<TData>, column: Column<TData>): boolean;
221
228
 
222
229
  declare type FormMeta = {
223
230
  _isNew?: boolean;
@@ -303,4 +310,4 @@ declare function EditableTextFieldCell<T extends FormMeta>({ error: errorFromPro
303
310
  declare const WARNING_PREFIX = "WARNING";
304
311
  declare function getHelperTextProps({ error, warning, helperText, }: GetHelperTextPropsProps): GetHelperTextProps;
305
312
 
306
- export { AppShell, AppSidebar, CellConfig, CheckboxCell, ChipsCell, ColumnSelect, DataTable, DataTableProps, DynamicCell, EditableCellBaseProps, EditableCheckboxCell, EditableDateCell, EditableDateCellProps, EditableDropdownSingleCell, EditableDropdownSingleCellProps, EditableNumberCell, EditableTextAreaCell, EditableTextFieldCell, FormMeta, GetHelperTextProps, GetHelperTextPropsProps, HTMLPropsRef, HeaderCell, HierarchyCell, InfiniteScrollConfig, Option, PopoverCell, RowConfig, RowSelectionMode, SelectColumnDef, SortConfig, StickyCell, StickyHeaderCell, StyledStickyCell, TableHeader, TableLayout, TableRowWrapper, TableRowWrapperProps, TruncateMode, TypographyCustom, TypographyProps, WARNING_PREFIX, WithoutFormMeta, addFormMeta, capitalizeHeader, getHelperTextProps, leftCellShadow, prependSelectColumn, removeFormMeta, stopPropagation, stringToHslColor, useEditMode, useGetIsNew, useHasRemoteChange, useSetFormMeta };
313
+ export { AppShell, AppSidebar, CellConfig, CheckboxCell, ChipsCell, ColumnSelect, DataTable, DataTableProps, DynamicCell, EditableCellBaseProps, EditableCheckboxCell, EditableDateCell, EditableDateCellProps, EditableDropdownSingleCell, EditableDropdownSingleCellProps, EditableNumberCell, EditableTextAreaCell, EditableTextFieldCell, FormMeta, GetHelperTextProps, GetHelperTextPropsProps, HTMLPropsRef, HeaderCell, HierarchyCell, InfiniteScrollConfig, Option, PopoverCell, RowConfig, RowSelectionMode, SelectColumnDef, SortConfig, StickyCell, StickyHeaderCell, StyledStickyCell, TableHeader, TableLayout, TableRowWrapper, TableRowWrapperProps, TruncateMode, TypographyCustom, TypographyProps, WARNING_PREFIX, WithoutFormMeta, addFormMeta, capitalizeHeader, getHelperTextProps, getIsFirstRightPinnedColumn, getIsLastLeftPinnedColumn, getTotalRight, leftCellShadow, prependSelectColumn, removeFormMeta, stopPropagation, stringToHslColor, useEditMode, useGetIsNew, useHasRemoteChange, useSetFormMeta };
package/dist/index.js CHANGED
@@ -2398,6 +2398,9 @@ __export(src_exports, {
2398
2398
  addFormMeta: () => addFormMeta,
2399
2399
  capitalizeHeader: () => capitalizeHeader,
2400
2400
  getHelperTextProps: () => getHelperTextProps,
2401
+ getIsFirstRightPinnedColumn: () => getIsFirstRightPinnedColumn,
2402
+ getIsLastLeftPinnedColumn: () => getIsLastLeftPinnedColumn,
2403
+ getTotalRight: () => getTotalRight,
2401
2404
  leftCellShadow: () => leftCellShadow,
2402
2405
  prependSelectColumn: () => prependSelectColumn,
2403
2406
  removeFormMeta: () => removeFormMeta,
@@ -2524,6 +2527,15 @@ function stopPropagation(handler) {
2524
2527
  handler(e);
2525
2528
  };
2526
2529
  }
2530
+ function getTotalRight(table, column) {
2531
+ return table.getRightLeafHeaders().slice(column.getPinnedIndex() + 1).reduce((acc, col) => acc + col.getSize(), 0);
2532
+ }
2533
+ function getIsFirstRightPinnedColumn(column) {
2534
+ return column.getIsPinned() === "right" && column.getPinnedIndex() === 0;
2535
+ }
2536
+ function getIsLastLeftPinnedColumn(table, column) {
2537
+ return column.getIsPinned() === "left" && table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex();
2538
+ }
2527
2539
 
2528
2540
  // src/cells/ChipsCell.tsx
2529
2541
  var import_jsx_runtime4 = require("react/jsx-runtime");
@@ -2553,6 +2565,7 @@ var ChipsCell = (props) => {
2553
2565
 
2554
2566
  // src/cells/DynamicCell.tsx
2555
2567
  var import_eds_core_react5 = require("@equinor/eds-core-react");
2568
+ var import_eds_tokens3 = require("@equinor/eds-tokens");
2556
2569
  var import_react_table = require("@tanstack/react-table");
2557
2570
  var import_styled_components5 = __toESM(require("styled-components"));
2558
2571
 
@@ -2591,9 +2604,33 @@ var StyledCell = (0, import_styled_components5.default)(import_eds_core_react5.T
2591
2604
  background-color: ${({ backgroundColor: bg }) => bg ? `${bg} !important` : `inherit`};
2592
2605
  `;
2593
2606
  function DynamicCell({ cell, highlight, getStickyCellColor }) {
2594
- var _a;
2607
+ var _a, _b;
2595
2608
  const cellContent = (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext());
2596
- if ((_a = cell.column.columnDef.meta) == null ? void 0 : _a.sticky) {
2609
+ const columnPinningDirection = cell.column.getIsPinned();
2610
+ if (columnPinningDirection) {
2611
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2612
+ import_eds_core_react5.Table.Cell,
2613
+ {
2614
+ "data-column": cell.column.id,
2615
+ style: __spreadValues({
2616
+ position: "sticky",
2617
+ top: 0,
2618
+ backgroundColor: (_a = getStickyCellColor == null ? void 0 : getStickyCellColor(cell)) != null ? _a : "inherit",
2619
+ zIndex: 5,
2620
+ backgroundClip: "padding-box",
2621
+ display: "table-cell"
2622
+ }, columnPinningDirection === "left" ? {
2623
+ left: `${cell.column.getStart("left")}px`,
2624
+ borderRight: getIsLastLeftPinnedColumn(cell.getContext().table, cell.column) ? `1px solid ${import_eds_tokens3.tokens.colors.ui.background__medium.hex}` : void 0
2625
+ } : {
2626
+ right: `${getTotalRight(cell.getContext().table, cell.column)}px`,
2627
+ borderLeft: getIsFirstRightPinnedColumn(cell.column) ? `1px solid ${import_eds_tokens3.tokens.colors.ui.background__medium.hex}` : void 0
2628
+ }),
2629
+ children: cellContent
2630
+ }
2631
+ );
2632
+ }
2633
+ if ((_b = cell.column.columnDef.meta) == null ? void 0 : _b.sticky) {
2597
2634
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(StyledStickyCell, { backgroundColor: getStickyCellColor == null ? void 0 : getStickyCellColor(cell), "data-column": cell.column.id, children: cellContent });
2598
2635
  }
2599
2636
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(StyledCell, { "data-column": cell.column.id, backgroundColor: highlight ? "#d5eaf4" : void 0, children: cellContent });
@@ -2602,7 +2639,7 @@ function DynamicCell({ cell, highlight, getStickyCellColor }) {
2602
2639
  // src/cells/HeaderCell.tsx
2603
2640
  var import_eds_core_react6 = require("@equinor/eds-core-react");
2604
2641
  var import_eds_icons3 = require("@equinor/eds-icons");
2605
- var import_eds_tokens3 = require("@equinor/eds-tokens");
2642
+ var import_eds_tokens4 = require("@equinor/eds-tokens");
2606
2643
  var import_react_table2 = require("@tanstack/react-table");
2607
2644
  var import_styled_components6 = __toESM(require("styled-components"));
2608
2645
  var import_jsx_runtime6 = require("react/jsx-runtime");
@@ -2621,7 +2658,7 @@ var resizeCellStyle = import_styled_components6.css`
2621
2658
  }
2622
2659
 
2623
2660
  .resizer.isResizing {
2624
- background: ${import_eds_tokens3.tokens.colors.interactive.focus.hex};
2661
+ background: ${import_eds_tokens4.tokens.colors.interactive.focus.hex};
2625
2662
  opacity: 1;
2626
2663
  }
2627
2664
 
@@ -2647,6 +2684,28 @@ var HeaderCell = ({ header, table }) => {
2647
2684
  onClick: header.column.getToggleSortingHandler(),
2648
2685
  colSpan: header.colSpan
2649
2686
  };
2687
+ const columnPinningDirection = header.column.getIsPinned();
2688
+ if (columnPinningDirection) {
2689
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2690
+ import_eds_core_react6.Table.Cell,
2691
+ __spreadProps(__spreadValues({}, cellProps), {
2692
+ style: __spreadValues(__spreadProps(__spreadValues({}, cellProps.style), {
2693
+ position: "sticky",
2694
+ top: 0,
2695
+ zIndex: 11,
2696
+ backgroundClip: "padding-box",
2697
+ display: "table-cell"
2698
+ }), columnPinningDirection === "left" ? {
2699
+ left: `${header.column.getStart("left")}px`,
2700
+ borderRight: getIsLastLeftPinnedColumn(table, header.column) ? `1px solid ${import_eds_tokens4.tokens.colors.ui.background__medium.hex}` : void 0
2701
+ } : {
2702
+ right: `${getTotalRight(table, header.column)}px`,
2703
+ borderLeft: getIsFirstRightPinnedColumn(header.column) ? `1px solid ${import_eds_tokens4.tokens.colors.ui.background__medium.hex}` : void 0
2704
+ }),
2705
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(HeaderContent, { header, table })
2706
+ })
2707
+ );
2708
+ }
2650
2709
  if ((_a = header.column.columnDef.meta) == null ? void 0 : _a.sticky) {
2651
2710
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StickyCell2, __spreadProps(__spreadValues({}, cellProps), { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(HeaderContent, { header, table }) }), header.id);
2652
2711
  }
@@ -2697,12 +2756,12 @@ function getSort({ column }) {
2697
2756
  }
2698
2757
 
2699
2758
  // src/cells/HierarchyCell.tsx
2700
- var import_eds_tokens5 = require("@equinor/eds-tokens");
2759
+ var import_eds_tokens6 = require("@equinor/eds-tokens");
2701
2760
  var import_styled_components8 = __toESM(require("styled-components"));
2702
2761
 
2703
2762
  // src/cells/TypographyCustom.tsx
2704
2763
  var import_eds_core_react7 = require("@equinor/eds-core-react");
2705
- var import_eds_tokens4 = require("@equinor/eds-tokens");
2764
+ var import_eds_tokens5 = require("@equinor/eds-tokens");
2706
2765
  var import_styled_components7 = __toESM(require("styled-components"));
2707
2766
  var import_jsx_runtime7 = require("react/jsx-runtime");
2708
2767
  var truncateStyle = {
@@ -2729,7 +2788,7 @@ var TypographyCustom = (props) => {
2729
2788
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react7.Typography, __spreadProps(__spreadValues({}, edsTypographyProps), { style: styleFromProps }));
2730
2789
  };
2731
2790
  var HoverCapture = import_styled_components7.default.div`
2732
- height: ${import_eds_tokens4.tokens.typography.table.cell_text.lineHeight};
2791
+ height: ${import_eds_tokens5.tokens.typography.table.cell_text.lineHeight};
2733
2792
  background-color: inherit;
2734
2793
 
2735
2794
  position: relative;
@@ -2764,11 +2823,11 @@ var CellWrapper = (0, import_styled_components8.default)(TypographyCustom)`
2764
2823
  ${({ depth, expanded }) => expanded && depth === 0 && "font-weight: bold;"}
2765
2824
 
2766
2825
  ${({ depth }) => depth > 0 && import_styled_components8.css`
2767
- border-left: 3px solid ${import_eds_tokens5.tokens.colors.infographic.primary__moss_green_34.hex};
2826
+ border-left: 3px solid ${import_eds_tokens6.tokens.colors.infographic.primary__moss_green_34.hex};
2768
2827
  gap: 0.5rem;
2769
2828
  .--divider {
2770
2829
  width: ${depth * 32}px;
2771
- background-color: ${import_eds_tokens5.tokens.colors.infographic.primary__moss_green_34.hex};
2830
+ background-color: ${import_eds_tokens6.tokens.colors.infographic.primary__moss_green_34.hex};
2772
2831
  height: 3px;
2773
2832
  border-radius: 0 5px 5px 0;
2774
2833
  }
@@ -3064,9 +3123,9 @@ function TableRow({
3064
3123
  cursor: (rowConfig == null ? void 0 : rowConfig.onClick) ? "pointer" : "initial",
3065
3124
  backgroundColor: (_a = rowConfig == null ? void 0 : rowConfig.getRowBackground) == null ? void 0 : _a.call(rowConfig, row)
3066
3125
  },
3067
- onClick: (e) => {
3126
+ onClick: () => {
3068
3127
  var _a2;
3069
- return (_a2 = rowConfig == null ? void 0 : rowConfig.onClick) == null ? void 0 : _a2.call(rowConfig, row, e);
3128
+ return (_a2 = rowConfig == null ? void 0 : rowConfig.onClick) == null ? void 0 : _a2.call(rowConfig, row);
3070
3129
  },
3071
3130
  onMouseEnter: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseEnter),
3072
3131
  onMouseLeave: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseLeave),
@@ -3398,6 +3457,11 @@ function DataTable(props) {
3398
3457
  (_s = (_r = props.expansion) == null ? void 0 : _r.state) != null ? _s : internalExpandedState,
3399
3458
  (_u = (_t = props.expansion) == null ? void 0 : _t.onChange) != null ? _u : setInternalExpandedState
3400
3459
  ];
3460
+ const [internalColumnPinning, setInternalColumnPinning] = (0, import_react7.useState)({});
3461
+ const [columnPinning, setColumnPinning] = [
3462
+ typeof props.columnPinning === "object" && props.columnPinning.state ? props.columnPinning.state : internalColumnPinning,
3463
+ typeof props.columnPinning === "object" && props.columnPinning.onChange ? props.columnPinning.onChange : setInternalColumnPinning
3464
+ ];
3401
3465
  const table = (0, import_react_table3.useReactTable)({
3402
3466
  columns: prependSelectColumn(columns, props.rowSelection),
3403
3467
  data,
@@ -3407,7 +3471,8 @@ function DataTable(props) {
3407
3471
  globalFilter: enableGlobalFilter(globalFilterState),
3408
3472
  sorting: ((_v = props.sorting) == null ? void 0 : _v.enableSorting) ? (_x = (_w = props.sorting) == null ? void 0 : _w.state) != null ? _x : sortingState : void 0,
3409
3473
  rowSelection: rowSelectionState,
3410
- columnVisibility
3474
+ columnVisibility,
3475
+ columnPinning
3411
3476
  },
3412
3477
  defaultColumn: {
3413
3478
  cell: ({ cell }) => {
@@ -3423,12 +3488,14 @@ function DataTable(props) {
3423
3488
  enableMultiRowSelection: ((_y = props.rowSelection) == null ? void 0 : _y.mode) === "multiple",
3424
3489
  enableSubRowSelection: ((_z = props.rowSelection) == null ? void 0 : _z.mode) !== "single",
3425
3490
  filterFromLeafRows: bannerConfig == null ? void 0 : bannerConfig.filterFromLeafRows,
3491
+ enablePinning: props.columnPinning !== void 0 && (typeof props.columnPinning === "boolean" ? props.columnPinning : props.columnPinning.enable),
3426
3492
  getFilteredRowModel: enableGlobalFilter((0, import_react_table3.getFilteredRowModel)()),
3427
3493
  getCoreRowModel: (0, import_react_table3.getCoreRowModel)(),
3428
3494
  getExpandedRowModel: (0, import_react_table3.getExpandedRowModel)(),
3429
3495
  getSortedRowModel: (0, import_react_table3.getSortedRowModel)(),
3430
3496
  onExpandedChange: setExpandedState,
3431
3497
  onRowSelectionChange: setRowSelectionState,
3498
+ onColumnPinningChange: setColumnPinning,
3432
3499
  onSortingChange: (sorting == null ? void 0 : sorting.enableSorting) ? (_A = sorting == null ? void 0 : sorting.onChange) != null ? _A : setSortingState : void 0,
3433
3500
  onColumnVisibilityChange: setColumnVisibility,
3434
3501
  onGlobalFilterChange: enableGlobalFilter(setGlobalFilterState),
@@ -3715,12 +3782,12 @@ var import_react_hook_form4 = require("react-hook-form");
3715
3782
 
3716
3783
  // src/form-cells/FormHelperText.tsx
3717
3784
  var import_eds_core_react23 = require("@equinor/eds-core-react");
3718
- var import_eds_tokens6 = require("@equinor/eds-tokens");
3785
+ var import_eds_tokens7 = require("@equinor/eds-tokens");
3719
3786
  var import_jsx_runtime24 = require("react/jsx-runtime");
3720
3787
  var colors = {
3721
- error: import_eds_tokens6.tokens.colors.interactive.danger__text.hex,
3722
- warning: import_eds_tokens6.tokens.colors.interactive.warning__text.hex,
3723
- success: import_eds_tokens6.tokens.colors.interactive.success__text.hex
3788
+ error: import_eds_tokens7.tokens.colors.interactive.danger__text.hex,
3789
+ warning: import_eds_tokens7.tokens.colors.interactive.warning__text.hex,
3790
+ success: import_eds_tokens7.tokens.colors.interactive.success__text.hex
3724
3791
  };
3725
3792
  function HelperText({ helperText, variant, helperIcon }) {
3726
3793
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: helperText && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { style: { marginTop: "8px", marginLeft: "8px" }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
@@ -4077,6 +4144,9 @@ var InlineTextField3 = (0, import_styled_components20.default)(import_eds_core_r
4077
4144
  addFormMeta,
4078
4145
  capitalizeHeader,
4079
4146
  getHelperTextProps,
4147
+ getIsFirstRightPinnedColumn,
4148
+ getIsLastLeftPinnedColumn,
4149
+ getTotalRight,
4080
4150
  leftCellShadow,
4081
4151
  prependSelectColumn,
4082
4152
  removeFormMeta,
package/dist/index.mjs CHANGED
@@ -2477,6 +2477,15 @@ function stopPropagation(handler) {
2477
2477
  handler(e);
2478
2478
  };
2479
2479
  }
2480
+ function getTotalRight(table, column) {
2481
+ return table.getRightLeafHeaders().slice(column.getPinnedIndex() + 1).reduce((acc, col) => acc + col.getSize(), 0);
2482
+ }
2483
+ function getIsFirstRightPinnedColumn(column) {
2484
+ return column.getIsPinned() === "right" && column.getPinnedIndex() === 0;
2485
+ }
2486
+ function getIsLastLeftPinnedColumn(table, column) {
2487
+ return column.getIsPinned() === "left" && table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex();
2488
+ }
2480
2489
 
2481
2490
  // src/cells/ChipsCell.tsx
2482
2491
  import { jsx as jsx4 } from "react/jsx-runtime";
@@ -2505,7 +2514,8 @@ var ChipsCell = (props) => {
2505
2514
  };
2506
2515
 
2507
2516
  // src/cells/DynamicCell.tsx
2508
- import { Table as Table2 } from "@equinor/eds-core-react";
2517
+ import { Table as EdsTable } from "@equinor/eds-core-react";
2518
+ import { tokens as tokens3 } from "@equinor/eds-tokens";
2509
2519
  import { flexRender } from "@tanstack/react-table";
2510
2520
  import styled5 from "styled-components";
2511
2521
 
@@ -2540,22 +2550,46 @@ import { jsx as jsx5 } from "react/jsx-runtime";
2540
2550
  var StyledStickyCell = styled5(StickyCell)`
2541
2551
  background-color: ${({ backgroundColor: bg }) => bg ? `${bg} !important` : `inherit`};
2542
2552
  `;
2543
- var StyledCell = styled5(Table2.Cell)`
2553
+ var StyledCell = styled5(EdsTable.Cell)`
2544
2554
  background-color: ${({ backgroundColor: bg }) => bg ? `${bg} !important` : `inherit`};
2545
2555
  `;
2546
2556
  function DynamicCell({ cell, highlight, getStickyCellColor }) {
2547
- var _a;
2557
+ var _a, _b;
2548
2558
  const cellContent = flexRender(cell.column.columnDef.cell, cell.getContext());
2549
- if ((_a = cell.column.columnDef.meta) == null ? void 0 : _a.sticky) {
2559
+ const columnPinningDirection = cell.column.getIsPinned();
2560
+ if (columnPinningDirection) {
2561
+ return /* @__PURE__ */ jsx5(
2562
+ EdsTable.Cell,
2563
+ {
2564
+ "data-column": cell.column.id,
2565
+ style: __spreadValues({
2566
+ position: "sticky",
2567
+ top: 0,
2568
+ backgroundColor: (_a = getStickyCellColor == null ? void 0 : getStickyCellColor(cell)) != null ? _a : "inherit",
2569
+ zIndex: 5,
2570
+ backgroundClip: "padding-box",
2571
+ display: "table-cell"
2572
+ }, columnPinningDirection === "left" ? {
2573
+ left: `${cell.column.getStart("left")}px`,
2574
+ borderRight: getIsLastLeftPinnedColumn(cell.getContext().table, cell.column) ? `1px solid ${tokens3.colors.ui.background__medium.hex}` : void 0
2575
+ } : {
2576
+ right: `${getTotalRight(cell.getContext().table, cell.column)}px`,
2577
+ borderLeft: getIsFirstRightPinnedColumn(cell.column) ? `1px solid ${tokens3.colors.ui.background__medium.hex}` : void 0
2578
+ }),
2579
+ children: cellContent
2580
+ }
2581
+ );
2582
+ }
2583
+ if ((_b = cell.column.columnDef.meta) == null ? void 0 : _b.sticky) {
2550
2584
  return /* @__PURE__ */ jsx5(StyledStickyCell, { backgroundColor: getStickyCellColor == null ? void 0 : getStickyCellColor(cell), "data-column": cell.column.id, children: cellContent });
2551
2585
  }
2552
2586
  return /* @__PURE__ */ jsx5(StyledCell, { "data-column": cell.column.id, backgroundColor: highlight ? "#d5eaf4" : void 0, children: cellContent });
2553
2587
  }
2554
2588
 
2555
2589
  // src/cells/HeaderCell.tsx
2556
- import { Icon as Icon3, Table as EdsTable } from "@equinor/eds-core-react";
2590
+ import { Icon as Icon3, Table as EdsTable2 } from "@equinor/eds-core-react";
2557
2591
  import { arrow_drop_down, arrow_drop_up } from "@equinor/eds-icons";
2558
- import { tokens as tokens3 } from "@equinor/eds-tokens";
2592
+ import { tokens as tokens4 } from "@equinor/eds-tokens";
2559
2593
  import { flexRender as flexRender2 } from "@tanstack/react-table";
2560
2594
  import styled6, { css as css3 } from "styled-components";
2561
2595
  import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
@@ -2574,7 +2608,7 @@ var resizeCellStyle = css3`
2574
2608
  }
2575
2609
 
2576
2610
  .resizer.isResizing {
2577
- background: ${tokens3.colors.interactive.focus.hex};
2611
+ background: ${tokens4.colors.interactive.focus.hex};
2578
2612
  opacity: 1;
2579
2613
  }
2580
2614
 
@@ -2585,7 +2619,7 @@ var resizeCellStyle = css3`
2585
2619
  var StickyCell2 = styled6(StickyHeaderCell)`
2586
2620
  ${resizeCellStyle}
2587
2621
  `;
2588
- var Cell2 = styled6(EdsTable.Cell)`
2622
+ var Cell2 = styled6(EdsTable2.Cell)`
2589
2623
  ${resizeCellStyle}
2590
2624
  `;
2591
2625
  var HeaderCell = ({ header, table }) => {
@@ -2600,6 +2634,28 @@ var HeaderCell = ({ header, table }) => {
2600
2634
  onClick: header.column.getToggleSortingHandler(),
2601
2635
  colSpan: header.colSpan
2602
2636
  };
2637
+ const columnPinningDirection = header.column.getIsPinned();
2638
+ if (columnPinningDirection) {
2639
+ return /* @__PURE__ */ jsx6(
2640
+ EdsTable2.Cell,
2641
+ __spreadProps(__spreadValues({}, cellProps), {
2642
+ style: __spreadValues(__spreadProps(__spreadValues({}, cellProps.style), {
2643
+ position: "sticky",
2644
+ top: 0,
2645
+ zIndex: 11,
2646
+ backgroundClip: "padding-box",
2647
+ display: "table-cell"
2648
+ }), columnPinningDirection === "left" ? {
2649
+ left: `${header.column.getStart("left")}px`,
2650
+ borderRight: getIsLastLeftPinnedColumn(table, header.column) ? `1px solid ${tokens4.colors.ui.background__medium.hex}` : void 0
2651
+ } : {
2652
+ right: `${getTotalRight(table, header.column)}px`,
2653
+ borderLeft: getIsFirstRightPinnedColumn(header.column) ? `1px solid ${tokens4.colors.ui.background__medium.hex}` : void 0
2654
+ }),
2655
+ children: /* @__PURE__ */ jsx6(HeaderContent, { header, table })
2656
+ })
2657
+ );
2658
+ }
2603
2659
  if ((_a = header.column.columnDef.meta) == null ? void 0 : _a.sticky) {
2604
2660
  return /* @__PURE__ */ jsx6(StickyCell2, __spreadProps(__spreadValues({}, cellProps), { children: /* @__PURE__ */ jsx6(HeaderContent, { header, table }) }), header.id);
2605
2661
  }
@@ -2650,14 +2706,14 @@ function getSort({ column }) {
2650
2706
  }
2651
2707
 
2652
2708
  // src/cells/HierarchyCell.tsx
2653
- import { tokens as tokens5 } from "@equinor/eds-tokens";
2709
+ import { tokens as tokens6 } from "@equinor/eds-tokens";
2654
2710
  import styled8, { css as css4 } from "styled-components";
2655
2711
 
2656
2712
  // src/cells/TypographyCustom.tsx
2657
2713
  import {
2658
2714
  Typography as EdsTypography
2659
2715
  } from "@equinor/eds-core-react";
2660
- import { tokens as tokens4 } from "@equinor/eds-tokens";
2716
+ import { tokens as tokens5 } from "@equinor/eds-tokens";
2661
2717
  import styled7 from "styled-components";
2662
2718
  import { jsx as jsx7 } from "react/jsx-runtime";
2663
2719
  var truncateStyle = {
@@ -2684,7 +2740,7 @@ var TypographyCustom = (props) => {
2684
2740
  return /* @__PURE__ */ jsx7(EdsTypography, __spreadProps(__spreadValues({}, edsTypographyProps), { style: styleFromProps }));
2685
2741
  };
2686
2742
  var HoverCapture = styled7.div`
2687
- height: ${tokens4.typography.table.cell_text.lineHeight};
2743
+ height: ${tokens5.typography.table.cell_text.lineHeight};
2688
2744
  background-color: inherit;
2689
2745
 
2690
2746
  position: relative;
@@ -2719,11 +2775,11 @@ var CellWrapper = styled8(TypographyCustom)`
2719
2775
  ${({ depth, expanded }) => expanded && depth === 0 && "font-weight: bold;"}
2720
2776
 
2721
2777
  ${({ depth }) => depth > 0 && css4`
2722
- border-left: 3px solid ${tokens5.colors.infographic.primary__moss_green_34.hex};
2778
+ border-left: 3px solid ${tokens6.colors.infographic.primary__moss_green_34.hex};
2723
2779
  gap: 0.5rem;
2724
2780
  .--divider {
2725
2781
  width: ${depth * 32}px;
2726
- background-color: ${tokens5.colors.infographic.primary__moss_green_34.hex};
2782
+ background-color: ${tokens6.colors.infographic.primary__moss_green_34.hex};
2727
2783
  height: 3px;
2728
2784
  border-radius: 0 5px 5px 0;
2729
2785
  }
@@ -2961,10 +3017,10 @@ function ColumnSelect({ table }) {
2961
3017
  }
2962
3018
 
2963
3019
  // src/DataTable/components/TableHeader.tsx
2964
- import { Table as Table4 } from "@equinor/eds-core-react";
3020
+ import { Table as Table3 } from "@equinor/eds-core-react";
2965
3021
  import { jsx as jsx12 } from "react/jsx-runtime";
2966
3022
  function TableHeader({ table, sticky }) {
2967
- return /* @__PURE__ */ jsx12(Table4.Head, { sticky, children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx12(Table4.Row, { children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx12(HeaderCell, { header, table }, header.id)) }, headerGroup.id)) });
3023
+ return /* @__PURE__ */ jsx12(Table3.Head, { sticky, children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx12(Table3.Row, { children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx12(HeaderCell, { header, table }, header.id)) }, headerGroup.id)) });
2968
3024
  }
2969
3025
 
2970
3026
  // src/DataTable/DataTable.tsx
@@ -2979,10 +3035,10 @@ import { useEffect as useEffect3, useRef as useRef3, useState as useState6 } fro
2979
3035
  import styled16 from "styled-components";
2980
3036
 
2981
3037
  // src/DataTable/components/BasicTable.tsx
2982
- import { Table as EdsTable2 } from "@equinor/eds-core-react";
3038
+ import { Table as EdsTable3 } from "@equinor/eds-core-react";
2983
3039
 
2984
3040
  // src/DataTable/components/PlaceholderRow.tsx
2985
- import { DotProgress, Table as Table5, Typography as Typography2 } from "@equinor/eds-core-react";
3041
+ import { DotProgress, Table as Table4, Typography as Typography2 } from "@equinor/eds-core-react";
2986
3042
  import styled11 from "styled-components";
2987
3043
  import { jsx as jsx13 } from "react/jsx-runtime";
2988
3044
  var PlaceholderTextWrapper = styled11.div`
@@ -2990,20 +3046,20 @@ var PlaceholderTextWrapper = styled11.div`
2990
3046
  justify-content: center;
2991
3047
  `;
2992
3048
  function PlaceholderRow({ isLoading }) {
2993
- return /* @__PURE__ */ jsx13(Table5.Row, { children: /* @__PURE__ */ jsx13(Table5.Cell, { colSpan: 100, children: /* @__PURE__ */ jsx13(PlaceholderTextWrapper, { children: isLoading ? /* @__PURE__ */ jsx13(DotProgress, { color: "primary" }) : /* @__PURE__ */ jsx13(Typography2, { children: "No data available" }) }) }) });
3049
+ return /* @__PURE__ */ jsx13(Table4.Row, { children: /* @__PURE__ */ jsx13(Table4.Cell, { colSpan: 100, children: /* @__PURE__ */ jsx13(PlaceholderTextWrapper, { children: isLoading ? /* @__PURE__ */ jsx13(DotProgress, { color: "primary" }) : /* @__PURE__ */ jsx13(Typography2, { children: "No data available" }) }) }) });
2994
3050
  }
2995
3051
 
2996
3052
  // src/DataTable/components/TableBody.tsx
2997
- import { Table as Table6 } from "@equinor/eds-core-react";
3053
+ import { Table as Table5 } from "@equinor/eds-core-react";
2998
3054
  import styled12 from "styled-components";
2999
- var TableBody = styled12(Table6.Body)`
3055
+ var TableBody = styled12(Table5.Body)`
3000
3056
  // The following attribute are important for fixed column width
3001
3057
  // CHANGE THES WITH CAUTION
3002
3058
  background: inherit;
3003
3059
  `;
3004
3060
 
3005
3061
  // src/DataTable/components/TableRow.tsx
3006
- import { Table as Table7 } from "@equinor/eds-core-react";
3062
+ import { Table as Table6 } from "@equinor/eds-core-react";
3007
3063
  import styled13 from "styled-components";
3008
3064
  import { jsx as jsx14 } from "react/jsx-runtime";
3009
3065
  function TableRow({
@@ -3025,9 +3081,9 @@ function TableRow({
3025
3081
  cursor: (rowConfig == null ? void 0 : rowConfig.onClick) ? "pointer" : "initial",
3026
3082
  backgroundColor: (_a = rowConfig == null ? void 0 : rowConfig.getRowBackground) == null ? void 0 : _a.call(rowConfig, row)
3027
3083
  },
3028
- onClick: (e) => {
3084
+ onClick: () => {
3029
3085
  var _a2;
3030
- return (_a2 = rowConfig == null ? void 0 : rowConfig.onClick) == null ? void 0 : _a2.call(rowConfig, row, e);
3086
+ return (_a2 = rowConfig == null ? void 0 : rowConfig.onClick) == null ? void 0 : _a2.call(rowConfig, row);
3031
3087
  },
3032
3088
  onMouseEnter: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseEnter),
3033
3089
  onMouseLeave: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseLeave),
@@ -3047,7 +3103,7 @@ function TableRow({
3047
3103
  );
3048
3104
  return rowWrapper ? rowWrapper({ row, children: tableRowContent }) : tableRowContent;
3049
3105
  }
3050
- var StyledTableRow = styled13(Table7.Row)`
3106
+ var StyledTableRow = styled13(Table6.Row)`
3051
3107
  /* Background color must be inherited here. Does not work with inline styling */
3052
3108
  ${({ active }) => active ? "" : "background-color: inherit;"}
3053
3109
  `;
@@ -3070,8 +3126,8 @@ function BasicTable({
3070
3126
  tableCaption
3071
3127
  }) {
3072
3128
  const tableRows = table.getRowModel().rows;
3073
- return /* @__PURE__ */ jsxs8(EdsTable2, { children: [
3074
- /* @__PURE__ */ jsx15(EdsTable2.Caption, { hidden: true, children: tableCaption }),
3129
+ return /* @__PURE__ */ jsxs8(EdsTable3, { children: [
3130
+ /* @__PURE__ */ jsx15(EdsTable3.Caption, { hidden: true, children: tableCaption }),
3075
3131
  /* @__PURE__ */ jsx15(TableHeader, { sticky: stickyHeader, table }),
3076
3132
  /* @__PURE__ */ jsx15(TableBody, { children: tableRows.length ? tableRows.map((row) => /* @__PURE__ */ jsx15(TableRow, { row, rowConfig, cellConfig }, row.id)) : /* @__PURE__ */ jsx15(PlaceholderRow, { isLoading }) })
3077
3133
  ] });
@@ -3189,16 +3245,16 @@ function TableBanner({
3189
3245
  }
3190
3246
 
3191
3247
  // src/DataTable/components/VirtualTable.tsx
3192
- import { Table as Table9 } from "@equinor/eds-core-react";
3248
+ import { Table as Table8 } from "@equinor/eds-core-react";
3193
3249
  import { useVirtualizer } from "@tanstack/react-virtual";
3194
3250
 
3195
3251
  // src/DataTable/components/PaddingRow.tsx
3196
- import { Table as Table8 } from "@equinor/eds-core-react";
3252
+ import { Table as Table7 } from "@equinor/eds-core-react";
3197
3253
  import { jsx as jsx18 } from "react/jsx-runtime";
3198
3254
  var PaddingRow = (props) => {
3199
3255
  if (!props.height)
3200
3256
  return null;
3201
- return /* @__PURE__ */ jsx18(Table8.Row, { style: { pointerEvents: "none" }, children: /* @__PURE__ */ jsx18(Table8.Cell, { style: { height: `${props.height}px` } }) });
3257
+ return /* @__PURE__ */ jsx18(Table7.Row, { style: { pointerEvents: "none" }, children: /* @__PURE__ */ jsx18(Table7.Cell, { style: { height: `${props.height}px` } }) });
3202
3258
  };
3203
3259
 
3204
3260
  // src/DataTable/components/VirtualTable.tsx
@@ -3227,8 +3283,8 @@ function VirtualTable(_a) {
3227
3283
  const virtualRows = rowVirtualizer.getVirtualItems();
3228
3284
  const paddingTop = virtualRows.length > 0 ? ((_a2 = virtualRows == null ? void 0 : virtualRows[0]) == null ? void 0 : _a2.start) || 0 : 0;
3229
3285
  const paddingBottom = virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (((_b2 = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b2.end) || 0) : 0;
3230
- return /* @__PURE__ */ jsxs10(Table9, { children: [
3231
- /* @__PURE__ */ jsx19(Table9.Caption, { hidden: true, children: props.tableCaption }),
3286
+ return /* @__PURE__ */ jsxs10(Table8, { children: [
3287
+ /* @__PURE__ */ jsx19(Table8.Caption, { hidden: true, children: props.tableCaption }),
3232
3288
  /* @__PURE__ */ jsx19(TableHeader, { sticky: props.stickyHeader, table }),
3233
3289
  /* @__PURE__ */ jsxs10(TableBody, { children: [
3234
3290
  /* @__PURE__ */ jsx19(PaddingRow, { height: paddingTop }),
@@ -3359,6 +3415,11 @@ function DataTable(props) {
3359
3415
  (_s = (_r = props.expansion) == null ? void 0 : _r.state) != null ? _s : internalExpandedState,
3360
3416
  (_u = (_t = props.expansion) == null ? void 0 : _t.onChange) != null ? _u : setInternalExpandedState
3361
3417
  ];
3418
+ const [internalColumnPinning, setInternalColumnPinning] = useState6({});
3419
+ const [columnPinning, setColumnPinning] = [
3420
+ typeof props.columnPinning === "object" && props.columnPinning.state ? props.columnPinning.state : internalColumnPinning,
3421
+ typeof props.columnPinning === "object" && props.columnPinning.onChange ? props.columnPinning.onChange : setInternalColumnPinning
3422
+ ];
3362
3423
  const table = useReactTable({
3363
3424
  columns: prependSelectColumn(columns, props.rowSelection),
3364
3425
  data,
@@ -3368,7 +3429,8 @@ function DataTable(props) {
3368
3429
  globalFilter: enableGlobalFilter(globalFilterState),
3369
3430
  sorting: ((_v = props.sorting) == null ? void 0 : _v.enableSorting) ? (_x = (_w = props.sorting) == null ? void 0 : _w.state) != null ? _x : sortingState : void 0,
3370
3431
  rowSelection: rowSelectionState,
3371
- columnVisibility
3432
+ columnVisibility,
3433
+ columnPinning
3372
3434
  },
3373
3435
  defaultColumn: {
3374
3436
  cell: ({ cell }) => {
@@ -3384,12 +3446,14 @@ function DataTable(props) {
3384
3446
  enableMultiRowSelection: ((_y = props.rowSelection) == null ? void 0 : _y.mode) === "multiple",
3385
3447
  enableSubRowSelection: ((_z = props.rowSelection) == null ? void 0 : _z.mode) !== "single",
3386
3448
  filterFromLeafRows: bannerConfig == null ? void 0 : bannerConfig.filterFromLeafRows,
3449
+ enablePinning: props.columnPinning !== void 0 && (typeof props.columnPinning === "boolean" ? props.columnPinning : props.columnPinning.enable),
3387
3450
  getFilteredRowModel: enableGlobalFilter(getFilteredRowModel()),
3388
3451
  getCoreRowModel: getCoreRowModel(),
3389
3452
  getExpandedRowModel: getExpandedRowModel(),
3390
3453
  getSortedRowModel: getSortedRowModel(),
3391
3454
  onExpandedChange: setExpandedState,
3392
3455
  onRowSelectionChange: setRowSelectionState,
3456
+ onColumnPinningChange: setColumnPinning,
3393
3457
  onSortingChange: (sorting == null ? void 0 : sorting.enableSorting) ? (_A = sorting == null ? void 0 : sorting.onChange) != null ? _A : setSortingState : void 0,
3394
3458
  onColumnVisibilityChange: setColumnVisibility,
3395
3459
  onGlobalFilterChange: enableGlobalFilter(setGlobalFilterState),
@@ -3676,12 +3740,12 @@ import { Controller as Controller3 } from "react-hook-form";
3676
3740
 
3677
3741
  // src/form-cells/FormHelperText.tsx
3678
3742
  import { Typography as Typography4 } from "@equinor/eds-core-react";
3679
- import { tokens as tokens6 } from "@equinor/eds-tokens";
3743
+ import { tokens as tokens7 } from "@equinor/eds-tokens";
3680
3744
  import { Fragment as Fragment4, jsx as jsx24, jsxs as jsxs12 } from "react/jsx-runtime";
3681
3745
  var colors = {
3682
- error: tokens6.colors.interactive.danger__text.hex,
3683
- warning: tokens6.colors.interactive.warning__text.hex,
3684
- success: tokens6.colors.interactive.success__text.hex
3746
+ error: tokens7.colors.interactive.danger__text.hex,
3747
+ warning: tokens7.colors.interactive.warning__text.hex,
3748
+ success: tokens7.colors.interactive.success__text.hex
3685
3749
  };
3686
3750
  function HelperText({ helperText, variant, helperIcon }) {
3687
3751
  return /* @__PURE__ */ jsx24(Fragment4, { children: helperText && /* @__PURE__ */ jsx24("div", { style: { marginTop: "8px", marginLeft: "8px" }, children: /* @__PURE__ */ jsxs12(
@@ -4037,6 +4101,9 @@ export {
4037
4101
  addFormMeta,
4038
4102
  capitalizeHeader,
4039
4103
  getHelperTextProps,
4104
+ getIsFirstRightPinnedColumn,
4105
+ getIsLastLeftPinnedColumn,
4106
+ getTotalRight,
4040
4107
  leftCellShadow,
4041
4108
  prependSelectColumn,
4042
4109
  removeFormMeta,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/apollo-components",
3
- "version": "3.4.0-beta.0",
3
+ "version": "3.4.0-beta.1",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",