@equinor/apollo-components 3.6.0-beta.0 → 3.6.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 +33 -38
- package/dist/index.js +20 -11
- package/dist/index.mjs +20 -11
- 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, Table, Row, SortingState, OnChangeFn,
|
|
4
|
+
import { CellContext, Cell, Header, Table, Row, SortingState, OnChangeFn, ColumnDef, ColumnResizeMode, RowSelectionState, ExpandedState, ColumnPinningState, VisibilityState, HeaderContext, Column } 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,6 +27,38 @@ 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
|
+
|
|
30
62
|
interface ColumnSelectProps<T> {
|
|
31
63
|
table: Table<T>;
|
|
32
64
|
}
|
|
@@ -76,13 +108,6 @@ interface CellConfig<T> {
|
|
|
76
108
|
* ***Note**: This only applies to default cells. Custom cells need custom implementation.*
|
|
77
109
|
*/
|
|
78
110
|
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
|
|
84
|
-
*/
|
|
85
|
-
getCellColor?: (cell: Cell<T, unknown>) => string;
|
|
86
111
|
}
|
|
87
112
|
type RowSelectionMode = 'single' | 'multiple';
|
|
88
113
|
type TableLayout = 'auto' | 'fixed';
|
|
@@ -197,36 +222,6 @@ declare function prependSelectColumn<T>(columns: ColumnDef<T>[], config?: DataTa
|
|
|
197
222
|
/** Useful in cases where you either have a value, function or undefined. */
|
|
198
223
|
declare function getFunctionValueOrDefault<T extends boolean | string | number, P>(valueOrFn: ((props: P) => T) | T | undefined, fnProps: P, defaultValue: T): T;
|
|
199
224
|
|
|
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
|
-
|
|
230
225
|
declare function SelectColumnDef<T>(props: SetRequired<DataTableProps<T>, 'rowSelection'>['rowSelection']): ColumnDef$1<T, any>;
|
|
231
226
|
|
|
232
227
|
declare const leftCellShadow: styled_components.FlattenSimpleInterpolation;
|
package/dist/index.js
CHANGED
|
@@ -2603,17 +2603,15 @@ 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: bg }) => bg ? `${bg} !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: bg }) => bg ? `${bg} !important` : `inherit`};
|
|
2610
2610
|
`;
|
|
2611
|
-
function DynamicCell({ cell,
|
|
2612
|
-
var _a, _b
|
|
2611
|
+
function DynamicCell({ cell, highlight, getStickyCellColor }) {
|
|
2612
|
+
var _a, _b;
|
|
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;
|
|
2617
2615
|
if (columnPinningDirection) {
|
|
2618
2616
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2619
2617
|
import_eds_core_react5.Table.Cell,
|
|
@@ -2622,7 +2620,7 @@ function DynamicCell({ cell, cellConfig }) {
|
|
|
2622
2620
|
style: __spreadValues({
|
|
2623
2621
|
position: "sticky",
|
|
2624
2622
|
top: 0,
|
|
2625
|
-
backgroundColor:
|
|
2623
|
+
backgroundColor: (_a = getStickyCellColor == null ? void 0 : getStickyCellColor(cell)) != null ? _a : "inherit",
|
|
2626
2624
|
zIndex: 5,
|
|
2627
2625
|
backgroundClip: "padding-box",
|
|
2628
2626
|
display: "table-cell"
|
|
@@ -2637,10 +2635,10 @@ function DynamicCell({ cell, cellConfig }) {
|
|
|
2637
2635
|
}
|
|
2638
2636
|
);
|
|
2639
2637
|
}
|
|
2640
|
-
if ((
|
|
2641
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(StyledStickyCell, { backgroundColor:
|
|
2638
|
+
if ((_b = cell.column.columnDef.meta) == null ? void 0 : _b.sticky) {
|
|
2639
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(StyledStickyCell, { backgroundColor: getStickyCellColor == null ? void 0 : getStickyCellColor(cell), "data-column": cell.column.id, children: cellContent });
|
|
2642
2640
|
}
|
|
2643
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(StyledCell, { "data-column": cell.column.id, backgroundColor:
|
|
2641
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(StyledCell, { "data-column": cell.column.id, backgroundColor: highlight ? "#d5eaf4" : void 0, children: cellContent });
|
|
2644
2642
|
}
|
|
2645
2643
|
|
|
2646
2644
|
// src/cells/HeaderCell.tsx
|
|
@@ -3146,7 +3144,18 @@ function TableRow({
|
|
|
3146
3144
|
},
|
|
3147
3145
|
onMouseEnter: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseEnter),
|
|
3148
3146
|
onMouseLeave: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseLeave),
|
|
3149
|
-
children: row.getVisibleCells().map((cell) =>
|
|
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
|
+
})
|
|
3150
3159
|
}
|
|
3151
3160
|
);
|
|
3152
3161
|
return rowWrapper ? rowWrapper({ row, children: tableRowContent }) : tableRowContent;
|
package/dist/index.mjs
CHANGED
|
@@ -2548,17 +2548,15 @@ 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: bg }) => bg ? `${bg} !important` : `inherit`};
|
|
2552
2552
|
`;
|
|
2553
2553
|
var StyledCell = styled5(EdsTable.Cell)`
|
|
2554
|
-
background-color: ${({ backgroundColor }) =>
|
|
2554
|
+
background-color: ${({ backgroundColor: bg }) => bg ? `${bg} !important` : `inherit`};
|
|
2555
2555
|
`;
|
|
2556
|
-
function DynamicCell({ cell,
|
|
2557
|
-
var _a, _b
|
|
2556
|
+
function DynamicCell({ cell, highlight, getStickyCellColor }) {
|
|
2557
|
+
var _a, _b;
|
|
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;
|
|
2562
2560
|
if (columnPinningDirection) {
|
|
2563
2561
|
return /* @__PURE__ */ jsx5(
|
|
2564
2562
|
EdsTable.Cell,
|
|
@@ -2567,7 +2565,7 @@ function DynamicCell({ cell, cellConfig }) {
|
|
|
2567
2565
|
style: __spreadValues({
|
|
2568
2566
|
position: "sticky",
|
|
2569
2567
|
top: 0,
|
|
2570
|
-
backgroundColor:
|
|
2568
|
+
backgroundColor: (_a = getStickyCellColor == null ? void 0 : getStickyCellColor(cell)) != null ? _a : "inherit",
|
|
2571
2569
|
zIndex: 5,
|
|
2572
2570
|
backgroundClip: "padding-box",
|
|
2573
2571
|
display: "table-cell"
|
|
@@ -2582,10 +2580,10 @@ function DynamicCell({ cell, cellConfig }) {
|
|
|
2582
2580
|
}
|
|
2583
2581
|
);
|
|
2584
2582
|
}
|
|
2585
|
-
if ((
|
|
2586
|
-
return /* @__PURE__ */ jsx5(StyledStickyCell, { backgroundColor:
|
|
2583
|
+
if ((_b = cell.column.columnDef.meta) == null ? void 0 : _b.sticky) {
|
|
2584
|
+
return /* @__PURE__ */ jsx5(StyledStickyCell, { backgroundColor: getStickyCellColor == null ? void 0 : getStickyCellColor(cell), "data-column": cell.column.id, children: cellContent });
|
|
2587
2585
|
}
|
|
2588
|
-
return /* @__PURE__ */ jsx5(StyledCell, { "data-column": cell.column.id, backgroundColor:
|
|
2586
|
+
return /* @__PURE__ */ jsx5(StyledCell, { "data-column": cell.column.id, backgroundColor: highlight ? "#d5eaf4" : void 0, children: cellContent });
|
|
2589
2587
|
}
|
|
2590
2588
|
|
|
2591
2589
|
// src/cells/HeaderCell.tsx
|
|
@@ -3099,7 +3097,18 @@ function TableRow({
|
|
|
3099
3097
|
},
|
|
3100
3098
|
onMouseEnter: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseEnter),
|
|
3101
3099
|
onMouseLeave: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseLeave),
|
|
3102
|
-
children: row.getVisibleCells().map((cell) =>
|
|
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
|
+
})
|
|
3103
3112
|
}
|
|
3104
3113
|
);
|
|
3105
3114
|
return rowWrapper ? rowWrapper({ row, children: tableRowContent }) : tableRowContent;
|