@equinor/apollo-components 3.4.0 → 3.5.1-beta.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.d.ts +24 -17
- package/dist/index.js +94 -23
- package/dist/index.mjs +105 -37
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { IconData } from '@equinor/eds-icons';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode, ReactElement, 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';
|
|
4
|
+
import { CellContext, Cell, Header, Table, Row, SortingState, OnChangeFn, ColumnDef, ColumnResizeMode, RowSelectionState, ExpandedState, ColumnPinningState, VisibilityState, HeaderContext, Column } from '@tanstack/react-table';
|
|
5
|
+
export { Cell, ColumnDef, ColumnPinningState, ColumnResizeMode, ExpandedState, OnChangeFn, Row, RowSelectionState, SortingState, Table, VisibilityState } from '@tanstack/react-table';
|
|
5
6
|
import * as styled_components from 'styled-components';
|
|
6
7
|
import * as _equinor_eds_core_react from '@equinor/eds-core-react';
|
|
7
8
|
import { CellProps, TypographyProps as TypographyProps$1 } from '@equinor/eds-core-react';
|
|
8
9
|
import { ColumnDef as ColumnDef$1 } from '@tanstack/table-core';
|
|
9
10
|
import { SetRequired } from 'type-fest';
|
|
10
|
-
import { TableOptions } from '@tanstack/table-core/build/lib/types';
|
|
11
11
|
import { Variants } from '@equinor/eds-core-react/dist/types/components/types';
|
|
12
12
|
import { FieldError } from 'react-hook-form';
|
|
13
13
|
|
|
@@ -27,12 +27,12 @@ declare const ChipsCell: (props: {
|
|
|
27
27
|
values?: string[];
|
|
28
28
|
}) => JSX.Element;
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
type TableCellProps<T> = {
|
|
31
31
|
cell: Cell<T, unknown>;
|
|
32
32
|
highlight?: boolean;
|
|
33
33
|
getStickyCellColor?: (cell: Cell<T, unknown>) => string;
|
|
34
34
|
};
|
|
35
|
-
|
|
35
|
+
type StyledStickyCellProps = {
|
|
36
36
|
highlight?: boolean;
|
|
37
37
|
backgroundColor?: string;
|
|
38
38
|
};
|
|
@@ -46,7 +46,7 @@ interface HeaderCellProps<TData, TValue> {
|
|
|
46
46
|
}
|
|
47
47
|
declare const HeaderCell: <TData, TValue>({ header, table }: HeaderCellProps<TData, TValue>) => JSX.Element;
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
type HierarchyCellOptions = {
|
|
50
50
|
getRowDepth?: () => number;
|
|
51
51
|
getDisplayName?: () => string;
|
|
52
52
|
};
|
|
@@ -87,8 +87,8 @@ interface RowConfig<T> {
|
|
|
87
87
|
onMouseEnter?: (row: Row<T>) => void;
|
|
88
88
|
onMouseLeave?: (row: Row<T>) => void;
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
type TruncateMode = 'wrap' | 'hover';
|
|
91
|
+
type SortConfig = {
|
|
92
92
|
enableSorting?: boolean;
|
|
93
93
|
manualSorting?: boolean;
|
|
94
94
|
sorting?: SortingState;
|
|
@@ -105,8 +105,8 @@ interface CellConfig<T> {
|
|
|
105
105
|
*/
|
|
106
106
|
truncateMode?: TruncateMode | ((cell: Cell<T, unknown>) => TruncateMode);
|
|
107
107
|
}
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
type RowSelectionMode = 'single' | 'multiple';
|
|
109
|
+
type TableLayout = 'auto' | 'fixed';
|
|
110
110
|
interface HTMLPropsRef<T extends HTMLElement> extends HTMLProps<T> {
|
|
111
111
|
ref?: MutableRefObject<T | null> | null;
|
|
112
112
|
}
|
|
@@ -138,7 +138,7 @@ interface DataTableProps<T> {
|
|
|
138
138
|
virtual?: boolean;
|
|
139
139
|
getRowId?: (originalRow: T, index: number, parent: Row<T> | undefined) => string;
|
|
140
140
|
getSubRows?: (originalRow: T) => T[] | undefined;
|
|
141
|
-
columnResizing?: boolean |
|
|
141
|
+
columnResizing?: boolean | ColumnResizeMode;
|
|
142
142
|
rowSelection?: Partial<ControlledState<RowSelectionState>> & {
|
|
143
143
|
mode?: RowSelectionMode;
|
|
144
144
|
selectColumn?: 'default' | ((options?: Record<string, any>) => ColumnDef<T, any>);
|
|
@@ -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
|
/**
|
|
@@ -178,8 +181,8 @@ interface DataTableProps<T> {
|
|
|
178
181
|
tableContainerProps?: HTMLPropsRef<HTMLDivElement>;
|
|
179
182
|
infiniteScroll?: InfiniteScrollConfig;
|
|
180
183
|
}
|
|
181
|
-
|
|
182
|
-
state
|
|
184
|
+
type ControlledState<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
|
};
|
|
@@ -195,7 +198,7 @@ declare function DataTable<T>(props: DataTableProps<T>): JSX.Element;
|
|
|
195
198
|
*/
|
|
196
199
|
declare function capitalizeHeader<T>(context: HeaderContext<T, any>): string;
|
|
197
200
|
/** Prepend a column definition array with a select column. */
|
|
198
|
-
declare function prependSelectColumn<T>(columns: ColumnDef<T>[], config?: DataTableProps<T>['rowSelection']): ColumnDef<T
|
|
201
|
+
declare function prependSelectColumn<T>(columns: ColumnDef<T>[], config?: DataTableProps<T>['rowSelection']): ColumnDef<T>[];
|
|
199
202
|
|
|
200
203
|
declare function SelectColumnDef<T>(props: SetRequired<DataTableProps<T>, 'rowSelection'>['rowSelection']): ColumnDef$1<T, any>;
|
|
201
204
|
|
|
@@ -203,7 +206,7 @@ declare const leftCellShadow: styled_components.FlattenSimpleInterpolation;
|
|
|
203
206
|
declare const StickyCell: styled_components.StyledComponent<react.ForwardRefExoticComponent<CellProps & react.RefAttributes<HTMLTableCellElement>>, any, {} & CellProps, never>;
|
|
204
207
|
declare const StickyHeaderCell: styled_components.StyledComponent<react.ForwardRefExoticComponent<CellProps & react.RefAttributes<HTMLTableCellElement>>, any, ({} & CellProps) & CellProps, never>;
|
|
205
208
|
|
|
206
|
-
|
|
209
|
+
type TypographyProps = {
|
|
207
210
|
truncate?: boolean;
|
|
208
211
|
enableShowAllOnHover?: boolean;
|
|
209
212
|
} & TypographyProps$1;
|
|
@@ -218,13 +221,17 @@ 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
|
+
type FormMeta = {
|
|
223
230
|
_isNew?: boolean;
|
|
224
231
|
_editMode?: boolean;
|
|
225
232
|
_hasRemoteChange?: boolean;
|
|
226
233
|
};
|
|
227
|
-
|
|
234
|
+
type WithoutFormMeta<T extends FormMeta> = Omit<T, keyof FormMeta>;
|
|
228
235
|
|
|
229
236
|
/**
|
|
230
237
|
* Subscribes to the `_editMode` field in a `react-hook-form` context.
|
|
@@ -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
|
-
|
|
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
|
|
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: ${
|
|
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
|
}
|
|
@@ -2665,9 +2724,9 @@ function HeaderContent({ header, table }) {
|
|
|
2665
2724
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(HeaderDiv, { children: [
|
|
2666
2725
|
(0, import_react_table2.flexRender)(header.column.columnDef.header, header.getContext()),
|
|
2667
2726
|
(_a = {
|
|
2668
|
-
asc: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_eds_core_react6.Icon, { data: import_eds_icons3.arrow_drop_up }),
|
|
2669
|
-
desc: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_eds_core_react6.Icon, { data: import_eds_icons3.arrow_drop_down }),
|
|
2670
|
-
none: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_eds_core_react6.Icon, { data: import_eds_icons3.arrow_drop_down })
|
|
2727
|
+
asc: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_eds_core_react6.Icon, { data: import_eds_icons3.arrow_drop_up, style: { flexShrink: 0 } }),
|
|
2728
|
+
desc: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_eds_core_react6.Icon, { data: import_eds_icons3.arrow_drop_down, style: { flexShrink: 0 } }),
|
|
2729
|
+
none: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_eds_core_react6.Icon, { data: import_eds_icons3.arrow_drop_down, style: { flexShrink: 0 } })
|
|
2671
2730
|
}[header.column.getIsSorted()]) != null ? _a : null,
|
|
2672
2731
|
table.options.enableColumnResizing && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2673
2732
|
"div",
|
|
@@ -2697,12 +2756,12 @@ function getSort({ column }) {
|
|
|
2697
2756
|
}
|
|
2698
2757
|
|
|
2699
2758
|
// src/cells/HierarchyCell.tsx
|
|
2700
|
-
var
|
|
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
|
|
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: ${
|
|
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 ${
|
|
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: ${
|
|
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
|
}
|
|
@@ -2895,6 +2954,7 @@ var import_react3 = require("react");
|
|
|
2895
2954
|
var import_styled_components10 = __toESM(require("styled-components"));
|
|
2896
2955
|
|
|
2897
2956
|
// src/DataTable/utils.tsx
|
|
2957
|
+
var import_react_table3 = require("@tanstack/react-table");
|
|
2898
2958
|
function capitalizeHeader(context) {
|
|
2899
2959
|
const header = context.header.id;
|
|
2900
2960
|
return header.charAt(0).toUpperCase() + header.slice(1);
|
|
@@ -3013,7 +3073,7 @@ function TableHeader({ table, sticky }) {
|
|
|
3013
3073
|
}
|
|
3014
3074
|
|
|
3015
3075
|
// src/DataTable/DataTable.tsx
|
|
3016
|
-
var
|
|
3076
|
+
var import_react_table4 = require("@tanstack/react-table");
|
|
3017
3077
|
var import_react7 = require("react");
|
|
3018
3078
|
var import_styled_components16 = __toESM(require("styled-components"));
|
|
3019
3079
|
|
|
@@ -3398,7 +3458,12 @@ function DataTable(props) {
|
|
|
3398
3458
|
(_s = (_r = props.expansion) == null ? void 0 : _r.state) != null ? _s : internalExpandedState,
|
|
3399
3459
|
(_u = (_t = props.expansion) == null ? void 0 : _t.onChange) != null ? _u : setInternalExpandedState
|
|
3400
3460
|
];
|
|
3401
|
-
const
|
|
3461
|
+
const [internalColumnPinning, setInternalColumnPinning] = (0, import_react7.useState)({});
|
|
3462
|
+
const [columnPinning, setColumnPinning] = [
|
|
3463
|
+
typeof props.columnPinning === "object" && props.columnPinning.state ? props.columnPinning.state : internalColumnPinning,
|
|
3464
|
+
typeof props.columnPinning === "object" && props.columnPinning.onChange ? props.columnPinning.onChange : setInternalColumnPinning
|
|
3465
|
+
];
|
|
3466
|
+
const table = (0, import_react_table4.useReactTable)({
|
|
3402
3467
|
columns: prependSelectColumn(columns, props.rowSelection),
|
|
3403
3468
|
data,
|
|
3404
3469
|
globalFilterFn: enableGlobalFilter(fuzzyFilter),
|
|
@@ -3407,7 +3472,8 @@ function DataTable(props) {
|
|
|
3407
3472
|
globalFilter: enableGlobalFilter(globalFilterState),
|
|
3408
3473
|
sorting: ((_v = props.sorting) == null ? void 0 : _v.enableSorting) ? (_x = (_w = props.sorting) == null ? void 0 : _w.state) != null ? _x : sortingState : void 0,
|
|
3409
3474
|
rowSelection: rowSelectionState,
|
|
3410
|
-
columnVisibility
|
|
3475
|
+
columnVisibility,
|
|
3476
|
+
columnPinning
|
|
3411
3477
|
},
|
|
3412
3478
|
defaultColumn: {
|
|
3413
3479
|
cell: ({ cell }) => {
|
|
@@ -3423,12 +3489,14 @@ function DataTable(props) {
|
|
|
3423
3489
|
enableMultiRowSelection: ((_y = props.rowSelection) == null ? void 0 : _y.mode) === "multiple",
|
|
3424
3490
|
enableSubRowSelection: ((_z = props.rowSelection) == null ? void 0 : _z.mode) !== "single",
|
|
3425
3491
|
filterFromLeafRows: bannerConfig == null ? void 0 : bannerConfig.filterFromLeafRows,
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3492
|
+
enablePinning: props.columnPinning !== void 0 && (typeof props.columnPinning === "boolean" ? props.columnPinning : props.columnPinning.enable),
|
|
3493
|
+
getFilteredRowModel: enableGlobalFilter((0, import_react_table4.getFilteredRowModel)()),
|
|
3494
|
+
getCoreRowModel: (0, import_react_table4.getCoreRowModel)(),
|
|
3495
|
+
getExpandedRowModel: (0, import_react_table4.getExpandedRowModel)(),
|
|
3496
|
+
getSortedRowModel: (0, import_react_table4.getSortedRowModel)(),
|
|
3430
3497
|
onExpandedChange: setExpandedState,
|
|
3431
3498
|
onRowSelectionChange: setRowSelectionState,
|
|
3499
|
+
onColumnPinningChange: setColumnPinning,
|
|
3432
3500
|
onSortingChange: (sorting == null ? void 0 : sorting.enableSorting) ? (_A = sorting == null ? void 0 : sorting.onChange) != null ? _A : setSortingState : void 0,
|
|
3433
3501
|
onColumnVisibilityChange: setColumnVisibility,
|
|
3434
3502
|
onGlobalFilterChange: enableGlobalFilter(setGlobalFilterState),
|
|
@@ -3715,12 +3783,12 @@ var import_react_hook_form4 = require("react-hook-form");
|
|
|
3715
3783
|
|
|
3716
3784
|
// src/form-cells/FormHelperText.tsx
|
|
3717
3785
|
var import_eds_core_react23 = require("@equinor/eds-core-react");
|
|
3718
|
-
var
|
|
3786
|
+
var import_eds_tokens7 = require("@equinor/eds-tokens");
|
|
3719
3787
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
3720
3788
|
var colors = {
|
|
3721
|
-
error:
|
|
3722
|
-
warning:
|
|
3723
|
-
success:
|
|
3789
|
+
error: import_eds_tokens7.tokens.colors.interactive.danger__text.hex,
|
|
3790
|
+
warning: import_eds_tokens7.tokens.colors.interactive.warning__text.hex,
|
|
3791
|
+
success: import_eds_tokens7.tokens.colors.interactive.success__text.hex
|
|
3724
3792
|
};
|
|
3725
3793
|
function HelperText({ helperText, variant, helperIcon }) {
|
|
3726
3794
|
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 +4145,9 @@ var InlineTextField3 = (0, import_styled_components20.default)(import_eds_core_r
|
|
|
4077
4145
|
addFormMeta,
|
|
4078
4146
|
capitalizeHeader,
|
|
4079
4147
|
getHelperTextProps,
|
|
4148
|
+
getIsFirstRightPinnedColumn,
|
|
4149
|
+
getIsLastLeftPinnedColumn,
|
|
4150
|
+
getTotalRight,
|
|
4080
4151
|
leftCellShadow,
|
|
4081
4152
|
prependSelectColumn,
|
|
4082
4153
|
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
|
|
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(
|
|
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
|
-
|
|
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
|
|
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
|
|
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: ${
|
|
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(
|
|
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
|
}
|
|
@@ -2618,9 +2674,9 @@ function HeaderContent({ header, table }) {
|
|
|
2618
2674
|
return /* @__PURE__ */ jsxs3(HeaderDiv, { children: [
|
|
2619
2675
|
flexRender2(header.column.columnDef.header, header.getContext()),
|
|
2620
2676
|
(_a = {
|
|
2621
|
-
asc: /* @__PURE__ */ jsx6(Icon3, { data: arrow_drop_up }),
|
|
2622
|
-
desc: /* @__PURE__ */ jsx6(Icon3, { data: arrow_drop_down }),
|
|
2623
|
-
none: /* @__PURE__ */ jsx6(Icon3, { data: arrow_drop_down })
|
|
2677
|
+
asc: /* @__PURE__ */ jsx6(Icon3, { data: arrow_drop_up, style: { flexShrink: 0 } }),
|
|
2678
|
+
desc: /* @__PURE__ */ jsx6(Icon3, { data: arrow_drop_down, style: { flexShrink: 0 } }),
|
|
2679
|
+
none: /* @__PURE__ */ jsx6(Icon3, { data: arrow_drop_down, style: { flexShrink: 0 } })
|
|
2624
2680
|
}[header.column.getIsSorted()]) != null ? _a : null,
|
|
2625
2681
|
table.options.enableColumnResizing && /* @__PURE__ */ jsx6(
|
|
2626
2682
|
"div",
|
|
@@ -2650,14 +2706,14 @@ function getSort({ column }) {
|
|
|
2650
2706
|
}
|
|
2651
2707
|
|
|
2652
2708
|
// src/cells/HierarchyCell.tsx
|
|
2653
|
-
import { tokens as
|
|
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
|
|
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: ${
|
|
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 ${
|
|
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: ${
|
|
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
|
}
|
|
@@ -2850,6 +2906,7 @@ import { useRef as useRef2, useState as useState3 } from "react";
|
|
|
2850
2906
|
import styled10 from "styled-components";
|
|
2851
2907
|
|
|
2852
2908
|
// src/DataTable/utils.tsx
|
|
2909
|
+
import { createColumnHelper } from "@tanstack/react-table";
|
|
2853
2910
|
function capitalizeHeader(context) {
|
|
2854
2911
|
const header = context.header.id;
|
|
2855
2912
|
return header.charAt(0).toUpperCase() + header.slice(1);
|
|
@@ -2961,10 +3018,10 @@ function ColumnSelect({ table }) {
|
|
|
2961
3018
|
}
|
|
2962
3019
|
|
|
2963
3020
|
// src/DataTable/components/TableHeader.tsx
|
|
2964
|
-
import { Table as
|
|
3021
|
+
import { Table as Table3 } from "@equinor/eds-core-react";
|
|
2965
3022
|
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
2966
3023
|
function TableHeader({ table, sticky }) {
|
|
2967
|
-
return /* @__PURE__ */ jsx12(
|
|
3024
|
+
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
3025
|
}
|
|
2969
3026
|
|
|
2970
3027
|
// src/DataTable/DataTable.tsx
|
|
@@ -2979,10 +3036,10 @@ import { useEffect as useEffect3, useRef as useRef3, useState as useState6 } fro
|
|
|
2979
3036
|
import styled16 from "styled-components";
|
|
2980
3037
|
|
|
2981
3038
|
// src/DataTable/components/BasicTable.tsx
|
|
2982
|
-
import { Table as
|
|
3039
|
+
import { Table as EdsTable3 } from "@equinor/eds-core-react";
|
|
2983
3040
|
|
|
2984
3041
|
// src/DataTable/components/PlaceholderRow.tsx
|
|
2985
|
-
import { DotProgress, Table as
|
|
3042
|
+
import { DotProgress, Table as Table4, Typography as Typography2 } from "@equinor/eds-core-react";
|
|
2986
3043
|
import styled11 from "styled-components";
|
|
2987
3044
|
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
2988
3045
|
var PlaceholderTextWrapper = styled11.div`
|
|
@@ -2990,20 +3047,20 @@ var PlaceholderTextWrapper = styled11.div`
|
|
|
2990
3047
|
justify-content: center;
|
|
2991
3048
|
`;
|
|
2992
3049
|
function PlaceholderRow({ isLoading }) {
|
|
2993
|
-
return /* @__PURE__ */ jsx13(
|
|
3050
|
+
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
3051
|
}
|
|
2995
3052
|
|
|
2996
3053
|
// src/DataTable/components/TableBody.tsx
|
|
2997
|
-
import { Table as
|
|
3054
|
+
import { Table as Table5 } from "@equinor/eds-core-react";
|
|
2998
3055
|
import styled12 from "styled-components";
|
|
2999
|
-
var TableBody = styled12(
|
|
3056
|
+
var TableBody = styled12(Table5.Body)`
|
|
3000
3057
|
// The following attribute are important for fixed column width
|
|
3001
3058
|
// CHANGE THES WITH CAUTION
|
|
3002
3059
|
background: inherit;
|
|
3003
3060
|
`;
|
|
3004
3061
|
|
|
3005
3062
|
// src/DataTable/components/TableRow.tsx
|
|
3006
|
-
import { Table as
|
|
3063
|
+
import { Table as Table6 } from "@equinor/eds-core-react";
|
|
3007
3064
|
import styled13 from "styled-components";
|
|
3008
3065
|
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
3009
3066
|
function TableRow({
|
|
@@ -3047,7 +3104,7 @@ function TableRow({
|
|
|
3047
3104
|
);
|
|
3048
3105
|
return rowWrapper ? rowWrapper({ row, children: tableRowContent }) : tableRowContent;
|
|
3049
3106
|
}
|
|
3050
|
-
var StyledTableRow = styled13(
|
|
3107
|
+
var StyledTableRow = styled13(Table6.Row)`
|
|
3051
3108
|
/* Background color must be inherited here. Does not work with inline styling */
|
|
3052
3109
|
${({ active }) => active ? "" : "background-color: inherit;"}
|
|
3053
3110
|
`;
|
|
@@ -3070,8 +3127,8 @@ function BasicTable({
|
|
|
3070
3127
|
tableCaption
|
|
3071
3128
|
}) {
|
|
3072
3129
|
const tableRows = table.getRowModel().rows;
|
|
3073
|
-
return /* @__PURE__ */ jsxs8(
|
|
3074
|
-
/* @__PURE__ */ jsx15(
|
|
3130
|
+
return /* @__PURE__ */ jsxs8(EdsTable3, { children: [
|
|
3131
|
+
/* @__PURE__ */ jsx15(EdsTable3.Caption, { hidden: true, children: tableCaption }),
|
|
3075
3132
|
/* @__PURE__ */ jsx15(TableHeader, { sticky: stickyHeader, table }),
|
|
3076
3133
|
/* @__PURE__ */ jsx15(TableBody, { children: tableRows.length ? tableRows.map((row) => /* @__PURE__ */ jsx15(TableRow, { row, rowConfig, cellConfig }, row.id)) : /* @__PURE__ */ jsx15(PlaceholderRow, { isLoading }) })
|
|
3077
3134
|
] });
|
|
@@ -3189,16 +3246,16 @@ function TableBanner({
|
|
|
3189
3246
|
}
|
|
3190
3247
|
|
|
3191
3248
|
// src/DataTable/components/VirtualTable.tsx
|
|
3192
|
-
import { Table as
|
|
3249
|
+
import { Table as Table8 } from "@equinor/eds-core-react";
|
|
3193
3250
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
3194
3251
|
|
|
3195
3252
|
// src/DataTable/components/PaddingRow.tsx
|
|
3196
|
-
import { Table as
|
|
3253
|
+
import { Table as Table7 } from "@equinor/eds-core-react";
|
|
3197
3254
|
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
3198
3255
|
var PaddingRow = (props) => {
|
|
3199
3256
|
if (!props.height)
|
|
3200
3257
|
return null;
|
|
3201
|
-
return /* @__PURE__ */ jsx18(
|
|
3258
|
+
return /* @__PURE__ */ jsx18(Table7.Row, { style: { pointerEvents: "none" }, children: /* @__PURE__ */ jsx18(Table7.Cell, { style: { height: `${props.height}px` } }) });
|
|
3202
3259
|
};
|
|
3203
3260
|
|
|
3204
3261
|
// src/DataTable/components/VirtualTable.tsx
|
|
@@ -3227,8 +3284,8 @@ function VirtualTable(_a) {
|
|
|
3227
3284
|
const virtualRows = rowVirtualizer.getVirtualItems();
|
|
3228
3285
|
const paddingTop = virtualRows.length > 0 ? ((_a2 = virtualRows == null ? void 0 : virtualRows[0]) == null ? void 0 : _a2.start) || 0 : 0;
|
|
3229
3286
|
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(
|
|
3231
|
-
/* @__PURE__ */ jsx19(
|
|
3287
|
+
return /* @__PURE__ */ jsxs10(Table8, { children: [
|
|
3288
|
+
/* @__PURE__ */ jsx19(Table8.Caption, { hidden: true, children: props.tableCaption }),
|
|
3232
3289
|
/* @__PURE__ */ jsx19(TableHeader, { sticky: props.stickyHeader, table }),
|
|
3233
3290
|
/* @__PURE__ */ jsxs10(TableBody, { children: [
|
|
3234
3291
|
/* @__PURE__ */ jsx19(PaddingRow, { height: paddingTop }),
|
|
@@ -3359,6 +3416,11 @@ function DataTable(props) {
|
|
|
3359
3416
|
(_s = (_r = props.expansion) == null ? void 0 : _r.state) != null ? _s : internalExpandedState,
|
|
3360
3417
|
(_u = (_t = props.expansion) == null ? void 0 : _t.onChange) != null ? _u : setInternalExpandedState
|
|
3361
3418
|
];
|
|
3419
|
+
const [internalColumnPinning, setInternalColumnPinning] = useState6({});
|
|
3420
|
+
const [columnPinning, setColumnPinning] = [
|
|
3421
|
+
typeof props.columnPinning === "object" && props.columnPinning.state ? props.columnPinning.state : internalColumnPinning,
|
|
3422
|
+
typeof props.columnPinning === "object" && props.columnPinning.onChange ? props.columnPinning.onChange : setInternalColumnPinning
|
|
3423
|
+
];
|
|
3362
3424
|
const table = useReactTable({
|
|
3363
3425
|
columns: prependSelectColumn(columns, props.rowSelection),
|
|
3364
3426
|
data,
|
|
@@ -3368,7 +3430,8 @@ function DataTable(props) {
|
|
|
3368
3430
|
globalFilter: enableGlobalFilter(globalFilterState),
|
|
3369
3431
|
sorting: ((_v = props.sorting) == null ? void 0 : _v.enableSorting) ? (_x = (_w = props.sorting) == null ? void 0 : _w.state) != null ? _x : sortingState : void 0,
|
|
3370
3432
|
rowSelection: rowSelectionState,
|
|
3371
|
-
columnVisibility
|
|
3433
|
+
columnVisibility,
|
|
3434
|
+
columnPinning
|
|
3372
3435
|
},
|
|
3373
3436
|
defaultColumn: {
|
|
3374
3437
|
cell: ({ cell }) => {
|
|
@@ -3384,12 +3447,14 @@ function DataTable(props) {
|
|
|
3384
3447
|
enableMultiRowSelection: ((_y = props.rowSelection) == null ? void 0 : _y.mode) === "multiple",
|
|
3385
3448
|
enableSubRowSelection: ((_z = props.rowSelection) == null ? void 0 : _z.mode) !== "single",
|
|
3386
3449
|
filterFromLeafRows: bannerConfig == null ? void 0 : bannerConfig.filterFromLeafRows,
|
|
3450
|
+
enablePinning: props.columnPinning !== void 0 && (typeof props.columnPinning === "boolean" ? props.columnPinning : props.columnPinning.enable),
|
|
3387
3451
|
getFilteredRowModel: enableGlobalFilter(getFilteredRowModel()),
|
|
3388
3452
|
getCoreRowModel: getCoreRowModel(),
|
|
3389
3453
|
getExpandedRowModel: getExpandedRowModel(),
|
|
3390
3454
|
getSortedRowModel: getSortedRowModel(),
|
|
3391
3455
|
onExpandedChange: setExpandedState,
|
|
3392
3456
|
onRowSelectionChange: setRowSelectionState,
|
|
3457
|
+
onColumnPinningChange: setColumnPinning,
|
|
3393
3458
|
onSortingChange: (sorting == null ? void 0 : sorting.enableSorting) ? (_A = sorting == null ? void 0 : sorting.onChange) != null ? _A : setSortingState : void 0,
|
|
3394
3459
|
onColumnVisibilityChange: setColumnVisibility,
|
|
3395
3460
|
onGlobalFilterChange: enableGlobalFilter(setGlobalFilterState),
|
|
@@ -3676,12 +3741,12 @@ import { Controller as Controller3 } from "react-hook-form";
|
|
|
3676
3741
|
|
|
3677
3742
|
// src/form-cells/FormHelperText.tsx
|
|
3678
3743
|
import { Typography as Typography4 } from "@equinor/eds-core-react";
|
|
3679
|
-
import { tokens as
|
|
3744
|
+
import { tokens as tokens7 } from "@equinor/eds-tokens";
|
|
3680
3745
|
import { Fragment as Fragment4, jsx as jsx24, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3681
3746
|
var colors = {
|
|
3682
|
-
error:
|
|
3683
|
-
warning:
|
|
3684
|
-
success:
|
|
3747
|
+
error: tokens7.colors.interactive.danger__text.hex,
|
|
3748
|
+
warning: tokens7.colors.interactive.warning__text.hex,
|
|
3749
|
+
success: tokens7.colors.interactive.success__text.hex
|
|
3685
3750
|
};
|
|
3686
3751
|
function HelperText({ helperText, variant, helperIcon }) {
|
|
3687
3752
|
return /* @__PURE__ */ jsx24(Fragment4, { children: helperText && /* @__PURE__ */ jsx24("div", { style: { marginTop: "8px", marginLeft: "8px" }, children: /* @__PURE__ */ jsxs12(
|
|
@@ -4037,6 +4102,9 @@ export {
|
|
|
4037
4102
|
addFormMeta,
|
|
4038
4103
|
capitalizeHeader,
|
|
4039
4104
|
getHelperTextProps,
|
|
4105
|
+
getIsFirstRightPinnedColumn,
|
|
4106
|
+
getIsLastLeftPinnedColumn,
|
|
4107
|
+
getTotalRight,
|
|
4040
4108
|
leftCellShadow,
|
|
4041
4109
|
prependSelectColumn,
|
|
4042
4110
|
removeFormMeta,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/apollo-components",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.1-beta.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@equinor/eds-icons": "^0.19.1",
|
|
21
21
|
"@equinor/eds-tokens": "^0.9.1",
|
|
22
22
|
"@tanstack/match-sorter-utils": "^8.8.4",
|
|
23
|
-
"@tanstack/react-table": "^8.9.
|
|
23
|
+
"@tanstack/react-table": "^8.9.8",
|
|
24
24
|
"@tanstack/react-virtual": "^3.0.0-beta.54",
|
|
25
25
|
"tsup": "^6.7.0",
|
|
26
26
|
"type-fest": "^3.11.0"
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"eslint-config-custom": "*",
|
|
47
47
|
"storybook": "^7.0.0-alpha.38",
|
|
48
48
|
"tsconfig": "*",
|
|
49
|
-
"typescript": "^
|
|
49
|
+
"typescript": "^5.2.2"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|