@equinor/apollo-components 3.3.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 +29 -5
- package/dist/index.js +100 -22
- package/dist/index.mjs +115 -42
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
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, 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';
|
|
8
8
|
import { ColumnDef as ColumnDef$1 } from '@tanstack/table-core';
|
|
9
9
|
import { SetRequired } from 'type-fest';
|
|
10
10
|
import { TableOptions } from '@tanstack/table-core/build/lib/types';
|
|
11
|
+
import { Variants } from '@equinor/eds-core-react/dist/types/components/types';
|
|
11
12
|
import { FieldError } from 'react-hook-form';
|
|
12
13
|
|
|
13
14
|
interface AppShellProps {
|
|
@@ -150,6 +151,9 @@ interface DataTableProps<T> {
|
|
|
150
151
|
enableSorting?: boolean;
|
|
151
152
|
manualSorting?: boolean;
|
|
152
153
|
};
|
|
154
|
+
columnPinning?: boolean | (ControlledState<ColumnPinningState> & {
|
|
155
|
+
enable?: boolean;
|
|
156
|
+
});
|
|
153
157
|
globalFilter?: ControlledState<string>;
|
|
154
158
|
columnVisibility?: ControlledState<VisibilityState>;
|
|
155
159
|
/**
|
|
@@ -178,7 +182,7 @@ interface DataTableProps<T> {
|
|
|
178
182
|
infiniteScroll?: InfiniteScrollConfig;
|
|
179
183
|
}
|
|
180
184
|
declare type ControlledState<T> = {
|
|
181
|
-
state
|
|
185
|
+
state?: T;
|
|
182
186
|
/** Callback when state chagnes. Using this requires the state to be fully controlled. */
|
|
183
187
|
onChange?: Dispatch<SetStateAction<T>>;
|
|
184
188
|
};
|
|
@@ -217,6 +221,10 @@ declare const TypographyCustom: (props: TypographyProps) => JSX.Element;
|
|
|
217
221
|
declare function stringToHslColor(str: string, s?: number, l?: number): string;
|
|
218
222
|
/** Wrap an event handler and stop event propagation */
|
|
219
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;
|
|
220
228
|
|
|
221
229
|
declare type FormMeta = {
|
|
222
230
|
_isNew?: boolean;
|
|
@@ -245,10 +253,23 @@ declare function useSetFormMeta<T extends FormMeta>(): (newValues: Partial<T>) =
|
|
|
245
253
|
declare function removeFormMeta<T extends FormMeta>(withFormMeta: T): Omit<T, keyof FormMeta>;
|
|
246
254
|
declare function addFormMeta<T>(withoutFormMeta: T): T & FormMeta;
|
|
247
255
|
|
|
256
|
+
interface GetHelperTextPropsProps {
|
|
257
|
+
error?: {
|
|
258
|
+
message?: string;
|
|
259
|
+
};
|
|
260
|
+
warning?: {
|
|
261
|
+
message: string;
|
|
262
|
+
};
|
|
263
|
+
helperText?: string;
|
|
264
|
+
}
|
|
265
|
+
interface GetHelperTextProps {
|
|
266
|
+
variant?: Variants;
|
|
267
|
+
helperText?: string;
|
|
268
|
+
helperIcon: JSX.Element | null;
|
|
269
|
+
}
|
|
248
270
|
interface EditableCellBaseProps<T extends FormMeta, Value> extends CellContext<T, Value> {
|
|
249
271
|
/**
|
|
250
|
-
* FieldError object used to overwrite react-hook-form validation result. It is prioritized over
|
|
251
|
-
* react-hook-form's validation.
|
|
272
|
+
* FieldError object used to overwrite react-hook-form validation result. It is prioritized over react-hook-form's validation. If prefixed with the exported `WARNING_PREFIX` it will be displayed as an warning.
|
|
252
273
|
*/
|
|
253
274
|
error?: FieldError;
|
|
254
275
|
/**
|
|
@@ -286,4 +307,7 @@ declare function EditableTextAreaCell<T extends FormMeta>({ title, error: errorF
|
|
|
286
307
|
|
|
287
308
|
declare function EditableTextFieldCell<T extends FormMeta>({ error: errorFromProps, ...context }: EditableCellBaseProps<T, string>): JSX.Element;
|
|
288
309
|
|
|
289
|
-
|
|
310
|
+
declare const WARNING_PREFIX = "WARNING";
|
|
311
|
+
declare function getHelperTextProps({ error, warning, helperText, }: GetHelperTextPropsProps): GetHelperTextProps;
|
|
312
|
+
|
|
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
|
@@ -2394,8 +2394,13 @@ __export(src_exports, {
|
|
|
2394
2394
|
StyledStickyCell: () => StyledStickyCell,
|
|
2395
2395
|
TableHeader: () => TableHeader,
|
|
2396
2396
|
TypographyCustom: () => TypographyCustom,
|
|
2397
|
+
WARNING_PREFIX: () => WARNING_PREFIX,
|
|
2397
2398
|
addFormMeta: () => addFormMeta,
|
|
2398
2399
|
capitalizeHeader: () => capitalizeHeader,
|
|
2400
|
+
getHelperTextProps: () => getHelperTextProps,
|
|
2401
|
+
getIsFirstRightPinnedColumn: () => getIsFirstRightPinnedColumn,
|
|
2402
|
+
getIsLastLeftPinnedColumn: () => getIsLastLeftPinnedColumn,
|
|
2403
|
+
getTotalRight: () => getTotalRight,
|
|
2399
2404
|
leftCellShadow: () => leftCellShadow,
|
|
2400
2405
|
prependSelectColumn: () => prependSelectColumn,
|
|
2401
2406
|
removeFormMeta: () => removeFormMeta,
|
|
@@ -2522,6 +2527,15 @@ function stopPropagation(handler) {
|
|
|
2522
2527
|
handler(e);
|
|
2523
2528
|
};
|
|
2524
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
|
+
}
|
|
2525
2539
|
|
|
2526
2540
|
// src/cells/ChipsCell.tsx
|
|
2527
2541
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
@@ -2551,6 +2565,7 @@ var ChipsCell = (props) => {
|
|
|
2551
2565
|
|
|
2552
2566
|
// src/cells/DynamicCell.tsx
|
|
2553
2567
|
var import_eds_core_react5 = require("@equinor/eds-core-react");
|
|
2568
|
+
var import_eds_tokens3 = require("@equinor/eds-tokens");
|
|
2554
2569
|
var import_react_table = require("@tanstack/react-table");
|
|
2555
2570
|
var import_styled_components5 = __toESM(require("styled-components"));
|
|
2556
2571
|
|
|
@@ -2589,9 +2604,33 @@ var StyledCell = (0, import_styled_components5.default)(import_eds_core_react5.T
|
|
|
2589
2604
|
background-color: ${({ backgroundColor: bg }) => bg ? `${bg} !important` : `inherit`};
|
|
2590
2605
|
`;
|
|
2591
2606
|
function DynamicCell({ cell, highlight, getStickyCellColor }) {
|
|
2592
|
-
var _a;
|
|
2607
|
+
var _a, _b;
|
|
2593
2608
|
const cellContent = (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext());
|
|
2594
|
-
|
|
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) {
|
|
2595
2634
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(StyledStickyCell, { backgroundColor: getStickyCellColor == null ? void 0 : getStickyCellColor(cell), "data-column": cell.column.id, children: cellContent });
|
|
2596
2635
|
}
|
|
2597
2636
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(StyledCell, { "data-column": cell.column.id, backgroundColor: highlight ? "#d5eaf4" : void 0, children: cellContent });
|
|
@@ -2600,7 +2639,7 @@ function DynamicCell({ cell, highlight, getStickyCellColor }) {
|
|
|
2600
2639
|
// src/cells/HeaderCell.tsx
|
|
2601
2640
|
var import_eds_core_react6 = require("@equinor/eds-core-react");
|
|
2602
2641
|
var import_eds_icons3 = require("@equinor/eds-icons");
|
|
2603
|
-
var
|
|
2642
|
+
var import_eds_tokens4 = require("@equinor/eds-tokens");
|
|
2604
2643
|
var import_react_table2 = require("@tanstack/react-table");
|
|
2605
2644
|
var import_styled_components6 = __toESM(require("styled-components"));
|
|
2606
2645
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
@@ -2619,7 +2658,7 @@ var resizeCellStyle = import_styled_components6.css`
|
|
|
2619
2658
|
}
|
|
2620
2659
|
|
|
2621
2660
|
.resizer.isResizing {
|
|
2622
|
-
background: ${
|
|
2661
|
+
background: ${import_eds_tokens4.tokens.colors.interactive.focus.hex};
|
|
2623
2662
|
opacity: 1;
|
|
2624
2663
|
}
|
|
2625
2664
|
|
|
@@ -2645,6 +2684,28 @@ var HeaderCell = ({ header, table }) => {
|
|
|
2645
2684
|
onClick: header.column.getToggleSortingHandler(),
|
|
2646
2685
|
colSpan: header.colSpan
|
|
2647
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
|
+
}
|
|
2648
2709
|
if ((_a = header.column.columnDef.meta) == null ? void 0 : _a.sticky) {
|
|
2649
2710
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StickyCell2, __spreadProps(__spreadValues({}, cellProps), { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(HeaderContent, { header, table }) }), header.id);
|
|
2650
2711
|
}
|
|
@@ -2695,12 +2756,12 @@ function getSort({ column }) {
|
|
|
2695
2756
|
}
|
|
2696
2757
|
|
|
2697
2758
|
// src/cells/HierarchyCell.tsx
|
|
2698
|
-
var
|
|
2759
|
+
var import_eds_tokens6 = require("@equinor/eds-tokens");
|
|
2699
2760
|
var import_styled_components8 = __toESM(require("styled-components"));
|
|
2700
2761
|
|
|
2701
2762
|
// src/cells/TypographyCustom.tsx
|
|
2702
2763
|
var import_eds_core_react7 = require("@equinor/eds-core-react");
|
|
2703
|
-
var
|
|
2764
|
+
var import_eds_tokens5 = require("@equinor/eds-tokens");
|
|
2704
2765
|
var import_styled_components7 = __toESM(require("styled-components"));
|
|
2705
2766
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
2706
2767
|
var truncateStyle = {
|
|
@@ -2727,7 +2788,7 @@ var TypographyCustom = (props) => {
|
|
|
2727
2788
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react7.Typography, __spreadProps(__spreadValues({}, edsTypographyProps), { style: styleFromProps }));
|
|
2728
2789
|
};
|
|
2729
2790
|
var HoverCapture = import_styled_components7.default.div`
|
|
2730
|
-
height: ${
|
|
2791
|
+
height: ${import_eds_tokens5.tokens.typography.table.cell_text.lineHeight};
|
|
2731
2792
|
background-color: inherit;
|
|
2732
2793
|
|
|
2733
2794
|
position: relative;
|
|
@@ -2762,11 +2823,11 @@ var CellWrapper = (0, import_styled_components8.default)(TypographyCustom)`
|
|
|
2762
2823
|
${({ depth, expanded }) => expanded && depth === 0 && "font-weight: bold;"}
|
|
2763
2824
|
|
|
2764
2825
|
${({ depth }) => depth > 0 && import_styled_components8.css`
|
|
2765
|
-
border-left: 3px solid ${
|
|
2826
|
+
border-left: 3px solid ${import_eds_tokens6.tokens.colors.infographic.primary__moss_green_34.hex};
|
|
2766
2827
|
gap: 0.5rem;
|
|
2767
2828
|
.--divider {
|
|
2768
2829
|
width: ${depth * 32}px;
|
|
2769
|
-
background-color: ${
|
|
2830
|
+
background-color: ${import_eds_tokens6.tokens.colors.infographic.primary__moss_green_34.hex};
|
|
2770
2831
|
height: 3px;
|
|
2771
2832
|
border-radius: 0 5px 5px 0;
|
|
2772
2833
|
}
|
|
@@ -3396,6 +3457,11 @@ function DataTable(props) {
|
|
|
3396
3457
|
(_s = (_r = props.expansion) == null ? void 0 : _r.state) != null ? _s : internalExpandedState,
|
|
3397
3458
|
(_u = (_t = props.expansion) == null ? void 0 : _t.onChange) != null ? _u : setInternalExpandedState
|
|
3398
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
|
+
];
|
|
3399
3465
|
const table = (0, import_react_table3.useReactTable)({
|
|
3400
3466
|
columns: prependSelectColumn(columns, props.rowSelection),
|
|
3401
3467
|
data,
|
|
@@ -3405,7 +3471,8 @@ function DataTable(props) {
|
|
|
3405
3471
|
globalFilter: enableGlobalFilter(globalFilterState),
|
|
3406
3472
|
sorting: ((_v = props.sorting) == null ? void 0 : _v.enableSorting) ? (_x = (_w = props.sorting) == null ? void 0 : _w.state) != null ? _x : sortingState : void 0,
|
|
3407
3473
|
rowSelection: rowSelectionState,
|
|
3408
|
-
columnVisibility
|
|
3474
|
+
columnVisibility,
|
|
3475
|
+
columnPinning
|
|
3409
3476
|
},
|
|
3410
3477
|
defaultColumn: {
|
|
3411
3478
|
cell: ({ cell }) => {
|
|
@@ -3421,12 +3488,14 @@ function DataTable(props) {
|
|
|
3421
3488
|
enableMultiRowSelection: ((_y = props.rowSelection) == null ? void 0 : _y.mode) === "multiple",
|
|
3422
3489
|
enableSubRowSelection: ((_z = props.rowSelection) == null ? void 0 : _z.mode) !== "single",
|
|
3423
3490
|
filterFromLeafRows: bannerConfig == null ? void 0 : bannerConfig.filterFromLeafRows,
|
|
3491
|
+
enablePinning: props.columnPinning !== void 0 && (typeof props.columnPinning === "boolean" ? props.columnPinning : props.columnPinning.enable),
|
|
3424
3492
|
getFilteredRowModel: enableGlobalFilter((0, import_react_table3.getFilteredRowModel)()),
|
|
3425
3493
|
getCoreRowModel: (0, import_react_table3.getCoreRowModel)(),
|
|
3426
3494
|
getExpandedRowModel: (0, import_react_table3.getExpandedRowModel)(),
|
|
3427
3495
|
getSortedRowModel: (0, import_react_table3.getSortedRowModel)(),
|
|
3428
3496
|
onExpandedChange: setExpandedState,
|
|
3429
3497
|
onRowSelectionChange: setRowSelectionState,
|
|
3498
|
+
onColumnPinningChange: setColumnPinning,
|
|
3430
3499
|
onSortingChange: (sorting == null ? void 0 : sorting.enableSorting) ? (_A = sorting == null ? void 0 : sorting.onChange) != null ? _A : setSortingState : void 0,
|
|
3431
3500
|
onColumnVisibilityChange: setColumnVisibility,
|
|
3432
3501
|
onGlobalFilterChange: enableGlobalFilter(setGlobalFilterState),
|
|
@@ -3598,17 +3667,27 @@ var import_styled_components17 = __toESM(require("styled-components"));
|
|
|
3598
3667
|
var import_eds_core_react21 = require("@equinor/eds-core-react");
|
|
3599
3668
|
var import_eds_icons8 = require("@equinor/eds-icons");
|
|
3600
3669
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
3670
|
+
var WARNING_PREFIX = "WARNING";
|
|
3601
3671
|
function getHelperTextProps({
|
|
3602
3672
|
error,
|
|
3603
3673
|
warning,
|
|
3604
3674
|
helperText
|
|
3605
3675
|
}) {
|
|
3606
|
-
|
|
3676
|
+
var _a;
|
|
3677
|
+
if (error) {
|
|
3678
|
+
if ((_a = error.message) == null ? void 0 : _a.startsWith(WARNING_PREFIX)) {
|
|
3679
|
+
return {
|
|
3680
|
+
variant: "warning",
|
|
3681
|
+
helperText: error.message.substring(WARNING_PREFIX.length),
|
|
3682
|
+
helperIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_eds_core_react21.Icon, { data: import_eds_icons8.warning_filled, size: 16 })
|
|
3683
|
+
};
|
|
3684
|
+
}
|
|
3607
3685
|
return {
|
|
3608
3686
|
variant: "error",
|
|
3609
3687
|
helperText: error.message,
|
|
3610
3688
|
helperIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_eds_core_react21.Icon, { data: import_eds_icons8.error_filled, size: 16 })
|
|
3611
3689
|
};
|
|
3690
|
+
}
|
|
3612
3691
|
if (warning)
|
|
3613
3692
|
return {
|
|
3614
3693
|
variant: "warning",
|
|
@@ -3620,12 +3699,6 @@ function getHelperTextProps({
|
|
|
3620
3699
|
helperIcon: null
|
|
3621
3700
|
};
|
|
3622
3701
|
}
|
|
3623
|
-
function stopPropagation2(handler) {
|
|
3624
|
-
return (e) => {
|
|
3625
|
-
e.stopPropagation();
|
|
3626
|
-
handler(e);
|
|
3627
|
-
};
|
|
3628
|
-
}
|
|
3629
3702
|
|
|
3630
3703
|
// src/form-cells/EditableDateCell.tsx
|
|
3631
3704
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
@@ -3709,12 +3782,12 @@ var import_react_hook_form4 = require("react-hook-form");
|
|
|
3709
3782
|
|
|
3710
3783
|
// src/form-cells/FormHelperText.tsx
|
|
3711
3784
|
var import_eds_core_react23 = require("@equinor/eds-core-react");
|
|
3712
|
-
var
|
|
3785
|
+
var import_eds_tokens7 = require("@equinor/eds-tokens");
|
|
3713
3786
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
3714
3787
|
var colors = {
|
|
3715
|
-
error:
|
|
3716
|
-
warning:
|
|
3717
|
-
success:
|
|
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
|
|
3718
3791
|
};
|
|
3719
3792
|
function HelperText({ helperText, variant, helperIcon }) {
|
|
3720
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)(
|
|
@@ -3907,7 +3980,7 @@ function EditableTextAreaCell(_a) {
|
|
|
3907
3980
|
ref
|
|
3908
3981
|
}, field), getHelperTextProps({ error: errorFromProps != null ? errorFromProps : error }))
|
|
3909
3982
|
),
|
|
3910
|
-
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(IconButton, { variant: "ghost_icon", onClick:
|
|
3983
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(IconButton, { variant: "ghost_icon", onClick: stopPropagation(openDialog), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_eds_core_react26.Icon, { data: import_eds_icons9.arrow_up, size: 24, style: { transform: "rotateZ(45deg)" } }) })
|
|
3911
3984
|
]
|
|
3912
3985
|
}
|
|
3913
3986
|
),
|
|
@@ -4067,8 +4140,13 @@ var InlineTextField3 = (0, import_styled_components20.default)(import_eds_core_r
|
|
|
4067
4140
|
StyledStickyCell,
|
|
4068
4141
|
TableHeader,
|
|
4069
4142
|
TypographyCustom,
|
|
4143
|
+
WARNING_PREFIX,
|
|
4070
4144
|
addFormMeta,
|
|
4071
4145
|
capitalizeHeader,
|
|
4146
|
+
getHelperTextProps,
|
|
4147
|
+
getIsFirstRightPinnedColumn,
|
|
4148
|
+
getIsLastLeftPinnedColumn,
|
|
4149
|
+
getTotalRight,
|
|
4072
4150
|
leftCellShadow,
|
|
4073
4151
|
prependSelectColumn,
|
|
4074
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
|
|
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
|
}
|
|
@@ -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
|
}
|
|
@@ -2961,10 +3017,10 @@ function ColumnSelect({ table }) {
|
|
|
2961
3017
|
}
|
|
2962
3018
|
|
|
2963
3019
|
// src/DataTable/components/TableHeader.tsx
|
|
2964
|
-
import { Table as
|
|
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(
|
|
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
|
|
3038
|
+
import { Table as EdsTable3 } from "@equinor/eds-core-react";
|
|
2983
3039
|
|
|
2984
3040
|
// src/DataTable/components/PlaceholderRow.tsx
|
|
2985
|
-
import { DotProgress, Table as
|
|
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(
|
|
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
|
|
3053
|
+
import { Table as Table5 } from "@equinor/eds-core-react";
|
|
2998
3054
|
import styled12 from "styled-components";
|
|
2999
|
-
var TableBody = styled12(
|
|
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
|
|
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({
|
|
@@ -3047,7 +3103,7 @@ function TableRow({
|
|
|
3047
3103
|
);
|
|
3048
3104
|
return rowWrapper ? rowWrapper({ row, children: tableRowContent }) : tableRowContent;
|
|
3049
3105
|
}
|
|
3050
|
-
var StyledTableRow = styled13(
|
|
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(
|
|
3074
|
-
/* @__PURE__ */ jsx15(
|
|
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
|
|
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
|
|
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(
|
|
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(
|
|
3231
|
-
/* @__PURE__ */ jsx19(
|
|
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),
|
|
@@ -3561,17 +3625,27 @@ import styled17 from "styled-components";
|
|
|
3561
3625
|
import { Icon as Icon7 } from "@equinor/eds-core-react";
|
|
3562
3626
|
import { error_filled, warning_filled } from "@equinor/eds-icons";
|
|
3563
3627
|
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
3628
|
+
var WARNING_PREFIX = "WARNING";
|
|
3564
3629
|
function getHelperTextProps({
|
|
3565
3630
|
error,
|
|
3566
3631
|
warning,
|
|
3567
3632
|
helperText
|
|
3568
3633
|
}) {
|
|
3569
|
-
|
|
3634
|
+
var _a;
|
|
3635
|
+
if (error) {
|
|
3636
|
+
if ((_a = error.message) == null ? void 0 : _a.startsWith(WARNING_PREFIX)) {
|
|
3637
|
+
return {
|
|
3638
|
+
variant: "warning",
|
|
3639
|
+
helperText: error.message.substring(WARNING_PREFIX.length),
|
|
3640
|
+
helperIcon: /* @__PURE__ */ jsx22(Icon7, { data: warning_filled, size: 16 })
|
|
3641
|
+
};
|
|
3642
|
+
}
|
|
3570
3643
|
return {
|
|
3571
3644
|
variant: "error",
|
|
3572
3645
|
helperText: error.message,
|
|
3573
3646
|
helperIcon: /* @__PURE__ */ jsx22(Icon7, { data: error_filled, size: 16 })
|
|
3574
3647
|
};
|
|
3648
|
+
}
|
|
3575
3649
|
if (warning)
|
|
3576
3650
|
return {
|
|
3577
3651
|
variant: "warning",
|
|
@@ -3583,12 +3657,6 @@ function getHelperTextProps({
|
|
|
3583
3657
|
helperIcon: null
|
|
3584
3658
|
};
|
|
3585
3659
|
}
|
|
3586
|
-
function stopPropagation2(handler) {
|
|
3587
|
-
return (e) => {
|
|
3588
|
-
e.stopPropagation();
|
|
3589
|
-
handler(e);
|
|
3590
|
-
};
|
|
3591
|
-
}
|
|
3592
3660
|
|
|
3593
3661
|
// src/form-cells/EditableDateCell.tsx
|
|
3594
3662
|
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
@@ -3672,12 +3740,12 @@ import { Controller as Controller3 } from "react-hook-form";
|
|
|
3672
3740
|
|
|
3673
3741
|
// src/form-cells/FormHelperText.tsx
|
|
3674
3742
|
import { Typography as Typography4 } from "@equinor/eds-core-react";
|
|
3675
|
-
import { tokens as
|
|
3743
|
+
import { tokens as tokens7 } from "@equinor/eds-tokens";
|
|
3676
3744
|
import { Fragment as Fragment4, jsx as jsx24, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3677
3745
|
var colors = {
|
|
3678
|
-
error:
|
|
3679
|
-
warning:
|
|
3680
|
-
success:
|
|
3746
|
+
error: tokens7.colors.interactive.danger__text.hex,
|
|
3747
|
+
warning: tokens7.colors.interactive.warning__text.hex,
|
|
3748
|
+
success: tokens7.colors.interactive.success__text.hex
|
|
3681
3749
|
};
|
|
3682
3750
|
function HelperText({ helperText, variant, helperIcon }) {
|
|
3683
3751
|
return /* @__PURE__ */ jsx24(Fragment4, { children: helperText && /* @__PURE__ */ jsx24("div", { style: { marginTop: "8px", marginLeft: "8px" }, children: /* @__PURE__ */ jsxs12(
|
|
@@ -3870,7 +3938,7 @@ function EditableTextAreaCell(_a) {
|
|
|
3870
3938
|
ref
|
|
3871
3939
|
}, field), getHelperTextProps({ error: errorFromProps != null ? errorFromProps : error }))
|
|
3872
3940
|
),
|
|
3873
|
-
/* @__PURE__ */ jsx27(IconButton, { variant: "ghost_icon", onClick:
|
|
3941
|
+
/* @__PURE__ */ jsx27(IconButton, { variant: "ghost_icon", onClick: stopPropagation(openDialog), children: /* @__PURE__ */ jsx27(Icon8, { data: arrow_up, size: 24, style: { transform: "rotateZ(45deg)" } }) })
|
|
3874
3942
|
]
|
|
3875
3943
|
}
|
|
3876
3944
|
),
|
|
@@ -4029,8 +4097,13 @@ export {
|
|
|
4029
4097
|
StyledStickyCell,
|
|
4030
4098
|
TableHeader,
|
|
4031
4099
|
TypographyCustom,
|
|
4100
|
+
WARNING_PREFIX,
|
|
4032
4101
|
addFormMeta,
|
|
4033
4102
|
capitalizeHeader,
|
|
4103
|
+
getHelperTextProps,
|
|
4104
|
+
getIsFirstRightPinnedColumn,
|
|
4105
|
+
getIsLastLeftPinnedColumn,
|
|
4106
|
+
getTotalRight,
|
|
4034
4107
|
leftCellShadow,
|
|
4035
4108
|
prependSelectColumn,
|
|
4036
4109
|
removeFormMeta,
|