@equinor/apollo-components 3.6.0 → 3.6.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 +38 -33
- package/dist/index.js +11 -20
- package/dist/index.mjs +11 -20
- package/package.json +1 -1
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
3
|
import { ReactNode, ReactElement, HTMLProps, MutableRefObject, Dispatch, SetStateAction, SyntheticEvent } from 'react';
|
|
4
|
-
import { CellContext,
|
|
4
|
+
import { CellContext, Table, Row, SortingState, OnChangeFn, Cell, ColumnDef, ColumnResizeMode, RowSelectionState, ExpandedState, ColumnPinningState, VisibilityState, HeaderContext, Column, Header } from '@tanstack/react-table';
|
|
5
5
|
export { Cell, CellContext, ColumnDef, ColumnPinningState, ColumnResizeMode, ColumnSort, ExpandedState, HeaderContext, OnChangeFn, Row, RowSelectionState, SortingState, Table, VisibilityState, createColumnHelper } from '@tanstack/react-table';
|
|
6
6
|
import * as styled_components from 'styled-components';
|
|
7
7
|
import * as _equinor_eds_core_react from '@equinor/eds-core-react';
|
|
@@ -27,38 +27,6 @@ declare const ChipsCell: (props: {
|
|
|
27
27
|
values?: string[];
|
|
28
28
|
}) => JSX.Element;
|
|
29
29
|
|
|
30
|
-
type TableCellProps<T> = {
|
|
31
|
-
cell: Cell<T, unknown>;
|
|
32
|
-
highlight?: boolean;
|
|
33
|
-
getStickyCellColor?: (cell: Cell<T, unknown>) => string;
|
|
34
|
-
};
|
|
35
|
-
type StyledStickyCellProps = {
|
|
36
|
-
highlight?: boolean;
|
|
37
|
-
backgroundColor?: string;
|
|
38
|
-
};
|
|
39
|
-
declare const StyledStickyCell: styled_components.StyledComponent<react.ForwardRefExoticComponent<_equinor_eds_core_react.CellProps & react.RefAttributes<HTMLTableCellElement>>, any, ({} & _equinor_eds_core_react.CellProps) & StyledStickyCellProps, never>;
|
|
40
|
-
declare function DynamicCell<T>({ cell, highlight, getStickyCellColor }: TableCellProps<T>): JSX.Element;
|
|
41
|
-
|
|
42
|
-
interface HeaderCellProps<TData, TValue> {
|
|
43
|
-
header: Header<TData, TValue>;
|
|
44
|
-
/** Needed for column resizing */
|
|
45
|
-
table: Table<TData>;
|
|
46
|
-
}
|
|
47
|
-
declare const HeaderCell: <TData, TValue>({ header, table }: HeaderCellProps<TData, TValue>) => JSX.Element;
|
|
48
|
-
|
|
49
|
-
type HierarchyCellOptions = {
|
|
50
|
-
getRowDepth?: () => number;
|
|
51
|
-
getDisplayName?: () => string;
|
|
52
|
-
};
|
|
53
|
-
declare function HierarchyCell<T>(cell: CellContext<T, any>, options?: HierarchyCellOptions): JSX.Element;
|
|
54
|
-
|
|
55
|
-
interface PopoverCellProps {
|
|
56
|
-
id: string;
|
|
57
|
-
value: string;
|
|
58
|
-
title?: string | JSX.Element | ReactNode;
|
|
59
|
-
}
|
|
60
|
-
declare function PopoverCell(props: PopoverCellProps): JSX.Element;
|
|
61
|
-
|
|
62
30
|
interface ColumnSelectProps<T> {
|
|
63
31
|
table: Table<T>;
|
|
64
32
|
}
|
|
@@ -108,6 +76,13 @@ interface CellConfig<T> {
|
|
|
108
76
|
* ***Note**: This only applies to default cells. Custom cells need custom implementation.*
|
|
109
77
|
*/
|
|
110
78
|
truncateMode?: TruncateMode | ((cell: Cell<T, unknown>) => TruncateMode);
|
|
79
|
+
/**
|
|
80
|
+
* Manually set the cell background color. Prioritized over highlight color.
|
|
81
|
+
*
|
|
82
|
+
* @param cell
|
|
83
|
+
* @returns color in hex, rgb or rgba, undefined to use default
|
|
84
|
+
*/
|
|
85
|
+
getCellColor?: (cell: Cell<T, unknown>) => string | undefined;
|
|
111
86
|
}
|
|
112
87
|
type RowSelectionMode = 'single' | 'multiple';
|
|
113
88
|
type TableLayout = 'auto' | 'fixed';
|
|
@@ -222,6 +197,36 @@ declare function prependSelectColumn<T>(columns: ColumnDef<T>[], config?: DataTa
|
|
|
222
197
|
/** Useful in cases where you either have a value, function or undefined. */
|
|
223
198
|
declare function getFunctionValueOrDefault<T extends boolean | string | number, P>(valueOrFn: ((props: P) => T) | T | undefined, fnProps: P, defaultValue: T): T;
|
|
224
199
|
|
|
200
|
+
type TableCellProps<T> = {
|
|
201
|
+
cell: Cell<T, unknown>;
|
|
202
|
+
cellConfig?: CellConfig<T>;
|
|
203
|
+
};
|
|
204
|
+
type StyledStickyCellProps = {
|
|
205
|
+
backgroundColor?: string;
|
|
206
|
+
};
|
|
207
|
+
declare const StyledStickyCell: styled_components.StyledComponent<react.ForwardRefExoticComponent<_equinor_eds_core_react.CellProps & react.RefAttributes<HTMLTableCellElement>>, any, ({} & _equinor_eds_core_react.CellProps) & StyledStickyCellProps, never>;
|
|
208
|
+
declare function DynamicCell<T>({ cell, cellConfig }: TableCellProps<T>): JSX.Element;
|
|
209
|
+
|
|
210
|
+
interface HeaderCellProps<TData, TValue> {
|
|
211
|
+
header: Header<TData, TValue>;
|
|
212
|
+
/** Needed for column resizing */
|
|
213
|
+
table: Table<TData>;
|
|
214
|
+
}
|
|
215
|
+
declare const HeaderCell: <TData, TValue>({ header, table }: HeaderCellProps<TData, TValue>) => JSX.Element;
|
|
216
|
+
|
|
217
|
+
type HierarchyCellOptions = {
|
|
218
|
+
getRowDepth?: () => number;
|
|
219
|
+
getDisplayName?: () => string;
|
|
220
|
+
};
|
|
221
|
+
declare function HierarchyCell<T>(cell: CellContext<T, any>, options?: HierarchyCellOptions): JSX.Element;
|
|
222
|
+
|
|
223
|
+
interface PopoverCellProps {
|
|
224
|
+
id: string;
|
|
225
|
+
value: string;
|
|
226
|
+
title?: string | JSX.Element | ReactNode;
|
|
227
|
+
}
|
|
228
|
+
declare function PopoverCell(props: PopoverCellProps): JSX.Element;
|
|
229
|
+
|
|
225
230
|
declare function SelectColumnDef<T>(props: SetRequired<DataTableProps<T>, 'rowSelection'>['rowSelection']): ColumnDef$1<T, any>;
|
|
226
231
|
|
|
227
232
|
declare const leftCellShadow: styled_components.FlattenSimpleInterpolation;
|
package/dist/index.js
CHANGED
|
@@ -2603,15 +2603,17 @@ var StickyHeaderCell = (0, import_styled_components4.default)(StickyCell)`
|
|
|
2603
2603
|
// src/cells/DynamicCell.tsx
|
|
2604
2604
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
2605
2605
|
var StyledStickyCell = (0, import_styled_components5.default)(StickyCell)`
|
|
2606
|
-
background-color: ${({ backgroundColor
|
|
2606
|
+
background-color: ${({ backgroundColor }) => backgroundColor ? `${backgroundColor} !important` : `inherit`};
|
|
2607
2607
|
`;
|
|
2608
2608
|
var StyledCell = (0, import_styled_components5.default)(import_eds_core_react5.Table.Cell)`
|
|
2609
|
-
background-color: ${({ backgroundColor
|
|
2609
|
+
background-color: ${({ backgroundColor }) => backgroundColor ? `${backgroundColor} !important` : `inherit`};
|
|
2610
2610
|
`;
|
|
2611
|
-
function DynamicCell({ cell,
|
|
2612
|
-
var _a, _b;
|
|
2611
|
+
function DynamicCell({ cell, cellConfig }) {
|
|
2612
|
+
var _a, _b, _c, _d, _e;
|
|
2613
2613
|
const cellContent = (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext());
|
|
2614
2614
|
const columnPinningDirection = cell.column.getIsPinned();
|
|
2615
|
+
const stickyCellColor = (_a = cellConfig == null ? void 0 : cellConfig.getStickyCellColor) == null ? void 0 : _a.call(cellConfig, cell);
|
|
2616
|
+
const regularCellColor = (_d = (_b = cellConfig == null ? void 0 : cellConfig.getCellColor) == null ? void 0 : _b.call(cellConfig, cell)) != null ? _d : ((_c = cellConfig == null ? void 0 : cellConfig.getShouldHighlight) == null ? void 0 : _c.call(cellConfig, cell)) ? "#d5eaf4" : void 0;
|
|
2615
2617
|
if (columnPinningDirection) {
|
|
2616
2618
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2617
2619
|
import_eds_core_react5.Table.Cell,
|
|
@@ -2620,7 +2622,7 @@ function DynamicCell({ cell, highlight, getStickyCellColor }) {
|
|
|
2620
2622
|
style: __spreadValues({
|
|
2621
2623
|
position: "sticky",
|
|
2622
2624
|
top: 0,
|
|
2623
|
-
backgroundColor:
|
|
2625
|
+
backgroundColor: stickyCellColor != null ? stickyCellColor : "inherit",
|
|
2624
2626
|
zIndex: 5,
|
|
2625
2627
|
backgroundClip: "padding-box",
|
|
2626
2628
|
display: "table-cell"
|
|
@@ -2635,10 +2637,10 @@ function DynamicCell({ cell, highlight, getStickyCellColor }) {
|
|
|
2635
2637
|
}
|
|
2636
2638
|
);
|
|
2637
2639
|
}
|
|
2638
|
-
if ((
|
|
2639
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(StyledStickyCell, { backgroundColor:
|
|
2640
|
+
if ((_e = cell.column.columnDef.meta) == null ? void 0 : _e.sticky) {
|
|
2641
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(StyledStickyCell, { backgroundColor: stickyCellColor, "data-column": cell.column.id, children: cellContent });
|
|
2640
2642
|
}
|
|
2641
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(StyledCell, { "data-column": cell.column.id, backgroundColor:
|
|
2643
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(StyledCell, { "data-column": cell.column.id, backgroundColor: regularCellColor, children: cellContent });
|
|
2642
2644
|
}
|
|
2643
2645
|
|
|
2644
2646
|
// src/cells/HeaderCell.tsx
|
|
@@ -3144,18 +3146,7 @@ function TableRow({
|
|
|
3144
3146
|
},
|
|
3145
3147
|
onMouseEnter: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseEnter),
|
|
3146
3148
|
onMouseLeave: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseLeave),
|
|
3147
|
-
children: row.getVisibleCells().map((cell) => {
|
|
3148
|
-
var _a2;
|
|
3149
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3150
|
-
DynamicCell,
|
|
3151
|
-
{
|
|
3152
|
-
cell,
|
|
3153
|
-
getStickyCellColor: cellConfig == null ? void 0 : cellConfig.getStickyCellColor,
|
|
3154
|
-
highlight: (_a2 = cellConfig == null ? void 0 : cellConfig.getShouldHighlight) == null ? void 0 : _a2.call(cellConfig, cell)
|
|
3155
|
-
},
|
|
3156
|
-
cell.id
|
|
3157
|
-
);
|
|
3158
|
-
})
|
|
3149
|
+
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DynamicCell, { cell, cellConfig }, cell.id))
|
|
3159
3150
|
}
|
|
3160
3151
|
);
|
|
3161
3152
|
return rowWrapper ? rowWrapper({ row, children: tableRowContent }) : tableRowContent;
|
package/dist/index.mjs
CHANGED
|
@@ -2548,15 +2548,17 @@ var StickyHeaderCell = styled4(StickyCell)`
|
|
|
2548
2548
|
// src/cells/DynamicCell.tsx
|
|
2549
2549
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
2550
2550
|
var StyledStickyCell = styled5(StickyCell)`
|
|
2551
|
-
background-color: ${({ backgroundColor
|
|
2551
|
+
background-color: ${({ backgroundColor }) => backgroundColor ? `${backgroundColor} !important` : `inherit`};
|
|
2552
2552
|
`;
|
|
2553
2553
|
var StyledCell = styled5(EdsTable.Cell)`
|
|
2554
|
-
background-color: ${({ backgroundColor
|
|
2554
|
+
background-color: ${({ backgroundColor }) => backgroundColor ? `${backgroundColor} !important` : `inherit`};
|
|
2555
2555
|
`;
|
|
2556
|
-
function DynamicCell({ cell,
|
|
2557
|
-
var _a, _b;
|
|
2556
|
+
function DynamicCell({ cell, cellConfig }) {
|
|
2557
|
+
var _a, _b, _c, _d, _e;
|
|
2558
2558
|
const cellContent = flexRender(cell.column.columnDef.cell, cell.getContext());
|
|
2559
2559
|
const columnPinningDirection = cell.column.getIsPinned();
|
|
2560
|
+
const stickyCellColor = (_a = cellConfig == null ? void 0 : cellConfig.getStickyCellColor) == null ? void 0 : _a.call(cellConfig, cell);
|
|
2561
|
+
const regularCellColor = (_d = (_b = cellConfig == null ? void 0 : cellConfig.getCellColor) == null ? void 0 : _b.call(cellConfig, cell)) != null ? _d : ((_c = cellConfig == null ? void 0 : cellConfig.getShouldHighlight) == null ? void 0 : _c.call(cellConfig, cell)) ? "#d5eaf4" : void 0;
|
|
2560
2562
|
if (columnPinningDirection) {
|
|
2561
2563
|
return /* @__PURE__ */ jsx5(
|
|
2562
2564
|
EdsTable.Cell,
|
|
@@ -2565,7 +2567,7 @@ function DynamicCell({ cell, highlight, getStickyCellColor }) {
|
|
|
2565
2567
|
style: __spreadValues({
|
|
2566
2568
|
position: "sticky",
|
|
2567
2569
|
top: 0,
|
|
2568
|
-
backgroundColor:
|
|
2570
|
+
backgroundColor: stickyCellColor != null ? stickyCellColor : "inherit",
|
|
2569
2571
|
zIndex: 5,
|
|
2570
2572
|
backgroundClip: "padding-box",
|
|
2571
2573
|
display: "table-cell"
|
|
@@ -2580,10 +2582,10 @@ function DynamicCell({ cell, highlight, getStickyCellColor }) {
|
|
|
2580
2582
|
}
|
|
2581
2583
|
);
|
|
2582
2584
|
}
|
|
2583
|
-
if ((
|
|
2584
|
-
return /* @__PURE__ */ jsx5(StyledStickyCell, { backgroundColor:
|
|
2585
|
+
if ((_e = cell.column.columnDef.meta) == null ? void 0 : _e.sticky) {
|
|
2586
|
+
return /* @__PURE__ */ jsx5(StyledStickyCell, { backgroundColor: stickyCellColor, "data-column": cell.column.id, children: cellContent });
|
|
2585
2587
|
}
|
|
2586
|
-
return /* @__PURE__ */ jsx5(StyledCell, { "data-column": cell.column.id, backgroundColor:
|
|
2588
|
+
return /* @__PURE__ */ jsx5(StyledCell, { "data-column": cell.column.id, backgroundColor: regularCellColor, children: cellContent });
|
|
2587
2589
|
}
|
|
2588
2590
|
|
|
2589
2591
|
// src/cells/HeaderCell.tsx
|
|
@@ -3097,18 +3099,7 @@ function TableRow({
|
|
|
3097
3099
|
},
|
|
3098
3100
|
onMouseEnter: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseEnter),
|
|
3099
3101
|
onMouseLeave: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseLeave),
|
|
3100
|
-
children: row.getVisibleCells().map((cell) => {
|
|
3101
|
-
var _a2;
|
|
3102
|
-
return /* @__PURE__ */ jsx14(
|
|
3103
|
-
DynamicCell,
|
|
3104
|
-
{
|
|
3105
|
-
cell,
|
|
3106
|
-
getStickyCellColor: cellConfig == null ? void 0 : cellConfig.getStickyCellColor,
|
|
3107
|
-
highlight: (_a2 = cellConfig == null ? void 0 : cellConfig.getShouldHighlight) == null ? void 0 : _a2.call(cellConfig, cell)
|
|
3108
|
-
},
|
|
3109
|
-
cell.id
|
|
3110
|
-
);
|
|
3111
|
-
})
|
|
3102
|
+
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx14(DynamicCell, { cell, cellConfig }, cell.id))
|
|
3112
3103
|
}
|
|
3113
3104
|
);
|
|
3114
3105
|
return rowWrapper ? rowWrapper({ row, children: tableRowContent }) : tableRowContent;
|