@equinor/apollo-components 1.10.0 → 1.11.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 +14 -9
- package/dist/index.js +53 -45
- package/dist/index.mjs +74 -67
- 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, ComponentProps } from 'react';
|
|
4
|
-
import { Cell, CellContext, Table, Row, ColumnDef, RowSelectionState, SortingState, HeaderContext } from '@tanstack/react-table';
|
|
4
|
+
import { Cell, CellContext, Table, Row, ColumnDef, VisibilityState, RowSelectionState, SortingState, HeaderContext } from '@tanstack/react-table';
|
|
5
5
|
import { ColumnDef as ColumnDef$1 } from '@tanstack/table-core';
|
|
6
6
|
import * as styled_components from 'styled-components';
|
|
7
7
|
import { CellProps, TypographyProps as TypographyProps$1 } from '@equinor/eds-core-react';
|
|
@@ -64,9 +64,17 @@ interface RowConfig<T> {
|
|
|
64
64
|
onMouseEnter?: (row: Row<T>) => void;
|
|
65
65
|
onMouseLeave?: (row: Row<T>) => void;
|
|
66
66
|
}
|
|
67
|
+
declare type TruncateMode = 'wrap' | 'hover';
|
|
67
68
|
interface CellConfig<T> {
|
|
68
69
|
getStickyCellColor?: (cell: Cell<T, unknown>) => string;
|
|
69
70
|
getShouldHighlight?: (cell: Cell<T, unknown>) => boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Whether to wrap or truncate default cells. Accepts `"wrap"` or `"hover"` and or a function returning a boolean.
|
|
73
|
+
* Defauls to `"hover"` (i.e. all cells is truncated by default).
|
|
74
|
+
*
|
|
75
|
+
* ***Note**: This only applies to default cells. Custom cells need custom implementation.*
|
|
76
|
+
*/
|
|
77
|
+
truncateMode?: TruncateMode | ((cell: Cell<T, unknown>) => TruncateMode);
|
|
70
78
|
}
|
|
71
79
|
declare type RowSelectionMode = 'single' | 'multiple';
|
|
72
80
|
declare type TableLayout = 'auto' | 'fixed';
|
|
@@ -115,6 +123,9 @@ declare function DataTable$1<T>(props: DataTableProps<T>): JSX.Element;
|
|
|
115
123
|
declare type DataTableProviderProps = ComponentProps<typeof Provider>;
|
|
116
124
|
declare function DataTableProvider({ children, ...props }: DataTableProviderProps): JSX.Element;
|
|
117
125
|
|
|
126
|
+
declare const columnVisibilityAtom: jotai.PrimitiveAtom<VisibilityState> & {
|
|
127
|
+
init: VisibilityState;
|
|
128
|
+
};
|
|
118
129
|
declare const globalFilterAtom: jotai.PrimitiveAtom<string> & {
|
|
119
130
|
init: string;
|
|
120
131
|
};
|
|
@@ -157,14 +168,8 @@ declare function SelectColumnDef<T>(props?: DataTableConfig<T>): ColumnDef$1<T,
|
|
|
157
168
|
declare const StickyCell: styled_components.StyledComponent<react.ForwardRefExoticComponent<CellProps & react.RefAttributes<HTMLTableCellElement>>, any, {} & CellProps, never>;
|
|
158
169
|
|
|
159
170
|
declare type TypographyProps = {
|
|
160
|
-
|
|
161
|
-
/** Requires noWrap prop in order to function */
|
|
162
|
-
showAllOnHover?: boolean;
|
|
171
|
+
truncate?: boolean;
|
|
163
172
|
} & TypographyProps$1;
|
|
164
|
-
/** A cell used to wrap text in EDS Typography
|
|
165
|
-
*
|
|
166
|
-
* Developed for Plant Tracker.
|
|
167
|
-
*/
|
|
168
173
|
declare const TypographyCustom: (props: TypographyProps) => JSX.Element;
|
|
169
174
|
|
|
170
|
-
export { AppShell, AppSidebar, CellConfig, ChipsCell, ColumnSelect, DataTable, DataTableCommonProps, DataTableConfig, DataTableProps, DataTableRawProps, DynamicCell, FilterConfig, HeaderConfig, HierarchyCell, RowConfig, RowSelectionMode, SelectColumnDef, StickyCell, TableHeader, TableLayout, TableRowWrapper, TableRowWrapperProps, TypographyCustom, capitalizeHeader, globalFilterAtom, prependSelectColumn, rowSelectionAtom, tableSortingAtom };
|
|
175
|
+
export { AppShell, AppSidebar, CellConfig, ChipsCell, ColumnSelect, DataTable, DataTableCommonProps, DataTableConfig, DataTableProps, DataTableRawProps, DynamicCell, FilterConfig, HeaderConfig, HierarchyCell, RowConfig, RowSelectionMode, SelectColumnDef, StickyCell, TableHeader, TableLayout, TableRowWrapper, TableRowWrapperProps, TruncateMode, TypographyCustom, capitalizeHeader, columnVisibilityAtom, globalFilterAtom, prependSelectColumn, rowSelectionAtom, tableSortingAtom };
|
package/dist/index.js
CHANGED
|
@@ -38,6 +38,7 @@ __export(src_exports, {
|
|
|
38
38
|
TableHeader: () => TableHeader,
|
|
39
39
|
TypographyCustom: () => TypographyCustom,
|
|
40
40
|
capitalizeHeader: () => capitalizeHeader,
|
|
41
|
+
columnVisibilityAtom: () => columnVisibilityAtom,
|
|
41
42
|
globalFilterAtom: () => globalFilterAtom,
|
|
42
43
|
prependSelectColumn: () => prependSelectColumn,
|
|
43
44
|
rowSelectionAtom: () => rowSelectionAtom,
|
|
@@ -233,7 +234,7 @@ var StyledStickyCell = (0, import_styled_components5.default)(StickyCell)`
|
|
|
233
234
|
background-color: ${({ backgroundColor: bg }) => bg ? `${bg} !important` : `inherit`};
|
|
234
235
|
`;
|
|
235
236
|
var StyledCell = (0, import_styled_components5.default)(import_eds_core_react4.Table.Cell)`
|
|
236
|
-
${({ backgroundColor: bg }) => bg ?
|
|
237
|
+
background-color: ${({ backgroundColor: bg }) => bg ? `${bg} !important` : `inherit`};
|
|
237
238
|
`;
|
|
238
239
|
function DynamicCell({ cell, highlight, getStickyCellColor }) {
|
|
239
240
|
var _a;
|
|
@@ -267,53 +268,48 @@ var truncateStyle = {
|
|
|
267
268
|
textOverflow: "ellipsis"
|
|
268
269
|
};
|
|
269
270
|
var TypographyCustom = (props) => {
|
|
270
|
-
const {
|
|
271
|
-
if (
|
|
272
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.
|
|
273
|
-
children:
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
whiteSpace: "nowrap"
|
|
281
|
-
}
|
|
282
|
-
})
|
|
283
|
-
}),
|
|
284
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_eds_core_react5.Typography, {
|
|
285
|
-
...edsTypographyProps,
|
|
286
|
-
style: {
|
|
287
|
-
...styleFromProps,
|
|
288
|
-
...truncateStyle
|
|
289
|
-
}
|
|
290
|
-
})
|
|
291
|
-
]
|
|
271
|
+
const { truncate, style: styleFromProps, ...edsTypographyProps } = props;
|
|
272
|
+
if (truncate)
|
|
273
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(HoverCapture, {
|
|
274
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_eds_core_react5.Typography, {
|
|
275
|
+
...edsTypographyProps,
|
|
276
|
+
style: {
|
|
277
|
+
...styleFromProps,
|
|
278
|
+
...truncateStyle
|
|
279
|
+
}
|
|
280
|
+
})
|
|
292
281
|
});
|
|
293
282
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_eds_core_react5.Typography, {
|
|
294
283
|
...edsTypographyProps,
|
|
295
|
-
style:
|
|
284
|
+
style: styleFromProps
|
|
296
285
|
});
|
|
297
286
|
};
|
|
298
287
|
var HoverCapture = import_styled_components6.default.div`
|
|
288
|
+
padding: 0.5em 0;
|
|
289
|
+
margin: -0.5em 0;
|
|
290
|
+
height: ${import_eds_tokens3.tokens.typography.table.cell_text.lineHeight};
|
|
291
|
+
background-color: inherit;
|
|
292
|
+
|
|
299
293
|
position: relative;
|
|
300
|
-
|
|
294
|
+
width: 100%;
|
|
301
295
|
|
|
302
|
-
|
|
303
|
-
|
|
296
|
+
&:hover {
|
|
297
|
+
z-index: 1;
|
|
298
|
+
}
|
|
304
299
|
|
|
305
|
-
|
|
306
|
-
|
|
300
|
+
& > * {
|
|
301
|
+
width: inherit;
|
|
302
|
+
position: absolute;
|
|
307
303
|
}
|
|
308
|
-
`;
|
|
309
|
-
var ShowAllWrapperWrapper = import_styled_components6.default.div`
|
|
310
|
-
position: absolute;
|
|
311
|
-
z-index: 1;
|
|
312
|
-
pointer-events: none;
|
|
313
304
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
305
|
+
&:hover > * {
|
|
306
|
+
width: auto;
|
|
307
|
+
z-index: 1;
|
|
308
|
+
padding: 0.5em 1em;
|
|
309
|
+
margin: -0.5em -1em;
|
|
310
|
+
|
|
311
|
+
background-color: inherit;
|
|
312
|
+
}
|
|
317
313
|
`;
|
|
318
314
|
|
|
319
315
|
// src/cells/HierarchyCell.tsx
|
|
@@ -373,7 +369,7 @@ function SelectColumnDef(props = {}) {
|
|
|
373
369
|
checked: table.getIsAllRowsSelected(),
|
|
374
370
|
indeterminate: table.getIsSomeRowsSelected(),
|
|
375
371
|
"aria-label": table.getIsAllRowsSelected() ? "Deselect all rows" : "Select all rows",
|
|
376
|
-
onChange: table.getToggleAllRowsSelectedHandler()
|
|
372
|
+
onChange: table.getIsSomeRowsSelected() ? () => table.toggleAllRowsSelected(false) : table.getToggleAllRowsSelectedHandler()
|
|
377
373
|
})
|
|
378
374
|
}) : null,
|
|
379
375
|
cell: ({ table, row }) => {
|
|
@@ -714,6 +710,13 @@ function prependSelectColumn(columns, config) {
|
|
|
714
710
|
return [SelectColumnDef(config), ...columns];
|
|
715
711
|
return [config.selectColumn(), ...columns];
|
|
716
712
|
}
|
|
713
|
+
function getFunctionValueOrDefault(valueOrFn, fnProps, defaultValue) {
|
|
714
|
+
if (valueOrFn === void 0)
|
|
715
|
+
return defaultValue;
|
|
716
|
+
if (typeof valueOrFn === "function")
|
|
717
|
+
return valueOrFn(fnProps);
|
|
718
|
+
return valueOrFn;
|
|
719
|
+
}
|
|
717
720
|
|
|
718
721
|
// src/DataTable/components/ColumnSelect.tsx
|
|
719
722
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
@@ -936,7 +939,7 @@ var DataTableWrapper = import_styled_components16.default.div`
|
|
|
936
939
|
}
|
|
937
940
|
`;
|
|
938
941
|
function DataTableRaw(props) {
|
|
939
|
-
const { isLoading, header, filters, config, rowConfig, table } = props;
|
|
942
|
+
const { isLoading, header, filters, config, rowConfig, cellConfig, table } = props;
|
|
940
943
|
const tableContainerRef = (0, import_react4.useRef)(null);
|
|
941
944
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DataTableWrapper, {
|
|
942
945
|
captionPadding: header == null ? void 0 : header.captionPadding,
|
|
@@ -957,11 +960,13 @@ function DataTableRaw(props) {
|
|
|
957
960
|
containerRef: tableContainerRef,
|
|
958
961
|
table,
|
|
959
962
|
rowConfig,
|
|
963
|
+
cellConfig,
|
|
960
964
|
isLoading,
|
|
961
965
|
stickyHeader: header == null ? void 0 : header.stickyHeader
|
|
962
966
|
}) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(BasicTable, {
|
|
963
967
|
table,
|
|
964
968
|
rowConfig,
|
|
969
|
+
cellConfig,
|
|
965
970
|
isLoading,
|
|
966
971
|
stickyHeader: header == null ? void 0 : header.stickyHeader
|
|
967
972
|
})
|
|
@@ -976,7 +981,7 @@ var import_jotai3 = require("jotai");
|
|
|
976
981
|
var import_react5 = require("react");
|
|
977
982
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
978
983
|
function useDataTable(props) {
|
|
979
|
-
const { columns, data, filters, config,
|
|
984
|
+
const { columns, data, filters, config, cellConfig } = props;
|
|
980
985
|
const [columnVisibility, setColumnVisibility] = (0, import_jotai3.useAtom)(columnVisibilityAtom);
|
|
981
986
|
const [globalFilter, setGlobalFilter] = (0, import_jotai3.useAtom)(globalFilterAtom);
|
|
982
987
|
const [sorting, setSorting] = (0, import_jotai3.useAtom)(tableSortingAtom);
|
|
@@ -997,12 +1002,14 @@ function useDataTable(props) {
|
|
|
997
1002
|
columnVisibility
|
|
998
1003
|
},
|
|
999
1004
|
defaultColumn: {
|
|
1000
|
-
cell: (cell) =>
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1005
|
+
cell: ({ cell }) => {
|
|
1006
|
+
const truncateMode = getFunctionValueOrDefault(cellConfig == null ? void 0 : cellConfig.truncateMode, cell, "hover");
|
|
1007
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TypographyCustom, {
|
|
1008
|
+
truncate: truncateMode === "hover",
|
|
1009
|
+
children: cell.getValue()
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1004
1012
|
},
|
|
1005
|
-
meta,
|
|
1006
1013
|
enableSorting: config == null ? void 0 : config.sortable,
|
|
1007
1014
|
enableExpanding: !(config == null ? void 0 : config.hideExpandControls),
|
|
1008
1015
|
enableMultiRowSelection: (config == null ? void 0 : config.rowSelectionMode) === "multiple",
|
|
@@ -1065,6 +1072,7 @@ DataTable2.Provider = DataTableProvider;
|
|
|
1065
1072
|
TableHeader,
|
|
1066
1073
|
TypographyCustom,
|
|
1067
1074
|
capitalizeHeader,
|
|
1075
|
+
columnVisibilityAtom,
|
|
1068
1076
|
globalFilterAtom,
|
|
1069
1077
|
prependSelectColumn,
|
|
1070
1078
|
rowSelectionAtom,
|
package/dist/index.mjs
CHANGED
|
@@ -186,7 +186,7 @@ var StyledStickyCell = styled5(StickyCell)`
|
|
|
186
186
|
background-color: ${({ backgroundColor: bg }) => bg ? `${bg} !important` : `inherit`};
|
|
187
187
|
`;
|
|
188
188
|
var StyledCell = styled5(Table2.Cell)`
|
|
189
|
-
${({ backgroundColor: bg }) => bg ?
|
|
189
|
+
background-color: ${({ backgroundColor: bg }) => bg ? `${bg} !important` : `inherit`};
|
|
190
190
|
`;
|
|
191
191
|
function DynamicCell({ cell, highlight, getStickyCellColor }) {
|
|
192
192
|
var _a;
|
|
@@ -215,64 +215,59 @@ import {
|
|
|
215
215
|
} from "@equinor/eds-core-react";
|
|
216
216
|
import { tokens as tokens3 } from "@equinor/eds-tokens";
|
|
217
217
|
import styled6 from "styled-components";
|
|
218
|
-
import { jsx as jsx5
|
|
218
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
219
219
|
var truncateStyle = {
|
|
220
220
|
overflow: "hidden",
|
|
221
221
|
whiteSpace: "nowrap",
|
|
222
222
|
textOverflow: "ellipsis"
|
|
223
223
|
};
|
|
224
224
|
var TypographyCustom = (props) => {
|
|
225
|
-
const {
|
|
226
|
-
if (
|
|
227
|
-
return /* @__PURE__ */
|
|
228
|
-
children:
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
whiteSpace: "nowrap"
|
|
236
|
-
}
|
|
237
|
-
})
|
|
238
|
-
}),
|
|
239
|
-
/* @__PURE__ */ jsx5(EdsTypography, {
|
|
240
|
-
...edsTypographyProps,
|
|
241
|
-
style: {
|
|
242
|
-
...styleFromProps,
|
|
243
|
-
...truncateStyle
|
|
244
|
-
}
|
|
245
|
-
})
|
|
246
|
-
]
|
|
225
|
+
const { truncate, style: styleFromProps, ...edsTypographyProps } = props;
|
|
226
|
+
if (truncate)
|
|
227
|
+
return /* @__PURE__ */ jsx5(HoverCapture, {
|
|
228
|
+
children: /* @__PURE__ */ jsx5(EdsTypography, {
|
|
229
|
+
...edsTypographyProps,
|
|
230
|
+
style: {
|
|
231
|
+
...styleFromProps,
|
|
232
|
+
...truncateStyle
|
|
233
|
+
}
|
|
234
|
+
})
|
|
247
235
|
});
|
|
248
236
|
return /* @__PURE__ */ jsx5(EdsTypography, {
|
|
249
237
|
...edsTypographyProps,
|
|
250
|
-
style:
|
|
238
|
+
style: styleFromProps
|
|
251
239
|
});
|
|
252
240
|
};
|
|
253
241
|
var HoverCapture = styled6.div`
|
|
242
|
+
padding: 0.5em 0;
|
|
243
|
+
margin: -0.5em 0;
|
|
244
|
+
height: ${tokens3.typography.table.cell_text.lineHeight};
|
|
245
|
+
background-color: inherit;
|
|
246
|
+
|
|
254
247
|
position: relative;
|
|
255
|
-
|
|
248
|
+
width: 100%;
|
|
256
249
|
|
|
257
|
-
|
|
258
|
-
|
|
250
|
+
&:hover {
|
|
251
|
+
z-index: 1;
|
|
252
|
+
}
|
|
259
253
|
|
|
260
|
-
|
|
261
|
-
|
|
254
|
+
& > * {
|
|
255
|
+
width: inherit;
|
|
256
|
+
position: absolute;
|
|
262
257
|
}
|
|
263
|
-
`;
|
|
264
|
-
var ShowAllWrapperWrapper = styled6.div`
|
|
265
|
-
position: absolute;
|
|
266
|
-
z-index: 1;
|
|
267
|
-
pointer-events: none;
|
|
268
258
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
259
|
+
&:hover > * {
|
|
260
|
+
width: auto;
|
|
261
|
+
z-index: 1;
|
|
262
|
+
padding: 0.5em 1em;
|
|
263
|
+
margin: -0.5em -1em;
|
|
264
|
+
|
|
265
|
+
background-color: inherit;
|
|
266
|
+
}
|
|
272
267
|
`;
|
|
273
268
|
|
|
274
269
|
// src/cells/HierarchyCell.tsx
|
|
275
|
-
import { jsx as jsx6, jsxs as
|
|
270
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
276
271
|
var CellWrapper = styled7(TypographyCustom)`
|
|
277
272
|
height: 100%;
|
|
278
273
|
display: flex;
|
|
@@ -293,7 +288,7 @@ var CellWrapper = styled7(TypographyCustom)`
|
|
|
293
288
|
`;
|
|
294
289
|
function HierarchyCell(cell, options = {}) {
|
|
295
290
|
var _a, _b;
|
|
296
|
-
return /* @__PURE__ */
|
|
291
|
+
return /* @__PURE__ */ jsxs3(CellWrapper, {
|
|
297
292
|
depth: ((_a = options.getRowDepth) == null ? void 0 : _a.call(options)) ?? cell.row.depth,
|
|
298
293
|
expanded: cell.row.getIsExpanded(),
|
|
299
294
|
children: [
|
|
@@ -309,7 +304,7 @@ function HierarchyCell(cell, options = {}) {
|
|
|
309
304
|
import { Button as Button2, Checkbox, Icon as Icon3, Radio } from "@equinor/eds-core-react";
|
|
310
305
|
import { chevron_down, chevron_up } from "@equinor/eds-icons";
|
|
311
306
|
import styled8 from "styled-components";
|
|
312
|
-
import { Fragment, jsx as jsx7, jsxs as
|
|
307
|
+
import { Fragment, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
313
308
|
var CellWrapper2 = styled8.div`
|
|
314
309
|
display: flex;
|
|
315
310
|
align-items: center;
|
|
@@ -328,7 +323,7 @@ function SelectColumnDef(props = {}) {
|
|
|
328
323
|
checked: table.getIsAllRowsSelected(),
|
|
329
324
|
indeterminate: table.getIsSomeRowsSelected(),
|
|
330
325
|
"aria-label": table.getIsAllRowsSelected() ? "Deselect all rows" : "Select all rows",
|
|
331
|
-
onChange: table.getToggleAllRowsSelectedHandler()
|
|
326
|
+
onChange: table.getIsSomeRowsSelected() ? () => table.toggleAllRowsSelected(false) : table.getToggleAllRowsSelectedHandler()
|
|
332
327
|
})
|
|
333
328
|
}) : null,
|
|
334
329
|
cell: ({ table, row }) => {
|
|
@@ -336,7 +331,7 @@ function SelectColumnDef(props = {}) {
|
|
|
336
331
|
return /* @__PURE__ */ jsx7(CellWrapper2, {
|
|
337
332
|
paddingLeft,
|
|
338
333
|
rowDepth: row.depth,
|
|
339
|
-
children: /* @__PURE__ */
|
|
334
|
+
children: /* @__PURE__ */ jsxs4(Fragment, {
|
|
340
335
|
children: [
|
|
341
336
|
selectionMode === "single" ? /* @__PURE__ */ jsx7(Radio, {
|
|
342
337
|
checked: row.getIsSelected(),
|
|
@@ -412,7 +407,7 @@ import { Icon as Icon4, Table as Table5 } from "@equinor/eds-core-react";
|
|
|
412
407
|
import { arrow_drop_down, arrow_drop_up } from "@equinor/eds-icons";
|
|
413
408
|
import { flexRender as flexRender2 } from "@tanstack/react-table";
|
|
414
409
|
import styled11 from "styled-components";
|
|
415
|
-
import { jsx as jsx9, jsxs as
|
|
410
|
+
import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
416
411
|
var HeaderDiv = styled11.div`
|
|
417
412
|
display: flex;
|
|
418
413
|
align-items: center;
|
|
@@ -448,7 +443,7 @@ var HeaderCell = ({ header }) => {
|
|
|
448
443
|
function HeaderContent({ header }) {
|
|
449
444
|
if (header.isPlaceholder)
|
|
450
445
|
return null;
|
|
451
|
-
return /* @__PURE__ */
|
|
446
|
+
return /* @__PURE__ */ jsxs5(HeaderDiv, {
|
|
452
447
|
children: [
|
|
453
448
|
flexRender2(header.column.columnDef.header, header.getContext()),
|
|
454
449
|
{
|
|
@@ -534,7 +529,7 @@ function handleRowEvent(row, handler) {
|
|
|
534
529
|
}
|
|
535
530
|
|
|
536
531
|
// src/DataTable/components/BasicTable.tsx
|
|
537
|
-
import { jsx as jsx12, jsxs as
|
|
532
|
+
import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
538
533
|
function BasicTable({
|
|
539
534
|
table,
|
|
540
535
|
rowConfig,
|
|
@@ -543,7 +538,7 @@ function BasicTable({
|
|
|
543
538
|
isLoading
|
|
544
539
|
}) {
|
|
545
540
|
const tableRows = table.getRowModel().rows;
|
|
546
|
-
return /* @__PURE__ */
|
|
541
|
+
return /* @__PURE__ */ jsxs6(EdsTable, {
|
|
547
542
|
children: [
|
|
548
543
|
/* @__PURE__ */ jsx12(TableHeader, {
|
|
549
544
|
sticky: stickyHeader,
|
|
@@ -669,9 +664,16 @@ function prependSelectColumn(columns, config) {
|
|
|
669
664
|
return [SelectColumnDef(config), ...columns];
|
|
670
665
|
return [config.selectColumn(), ...columns];
|
|
671
666
|
}
|
|
667
|
+
function getFunctionValueOrDefault(valueOrFn, fnProps, defaultValue) {
|
|
668
|
+
if (valueOrFn === void 0)
|
|
669
|
+
return defaultValue;
|
|
670
|
+
if (typeof valueOrFn === "function")
|
|
671
|
+
return valueOrFn(fnProps);
|
|
672
|
+
return valueOrFn;
|
|
673
|
+
}
|
|
672
674
|
|
|
673
675
|
// src/DataTable/components/ColumnSelect.tsx
|
|
674
|
-
import { Fragment as Fragment2, jsx as jsx14, jsxs as
|
|
676
|
+
import { Fragment as Fragment2, jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
675
677
|
var ColumnSelectContent = styled14.div`
|
|
676
678
|
display: grid;
|
|
677
679
|
grid-template-columns: repeat(2, 1fr);
|
|
@@ -687,7 +689,7 @@ function ColumnSelect({ table }) {
|
|
|
687
689
|
const [isOpen, setIsOpen] = useState3(false);
|
|
688
690
|
const referenceElement = useRef(null);
|
|
689
691
|
const selectableColumns = table.getAllLeafColumns().filter((column) => column.id !== "select");
|
|
690
|
-
return /* @__PURE__ */
|
|
692
|
+
return /* @__PURE__ */ jsxs7(Fragment2, {
|
|
691
693
|
children: [
|
|
692
694
|
/* @__PURE__ */ jsx14(Button4, {
|
|
693
695
|
"aria-haspopup": true,
|
|
@@ -702,14 +704,14 @@ function ColumnSelect({ table }) {
|
|
|
702
704
|
data: view_column
|
|
703
705
|
})
|
|
704
706
|
}),
|
|
705
|
-
/* @__PURE__ */
|
|
707
|
+
/* @__PURE__ */ jsxs7(Popover, {
|
|
706
708
|
open: isOpen,
|
|
707
709
|
id: "column-select-popover",
|
|
708
710
|
anchorEl: referenceElement.current,
|
|
709
711
|
placement: "bottom-end",
|
|
710
712
|
onClose: () => setIsOpen(false),
|
|
711
713
|
children: [
|
|
712
|
-
/* @__PURE__ */
|
|
714
|
+
/* @__PURE__ */ jsxs7(Popover.Header, {
|
|
713
715
|
children: [
|
|
714
716
|
/* @__PURE__ */ jsx14(Popover.Title, {
|
|
715
717
|
children: "Column settings"
|
|
@@ -726,7 +728,7 @@ function ColumnSelect({ table }) {
|
|
|
726
728
|
})
|
|
727
729
|
]
|
|
728
730
|
}),
|
|
729
|
-
/* @__PURE__ */
|
|
731
|
+
/* @__PURE__ */ jsxs7(Popover.Content, {
|
|
730
732
|
children: [
|
|
731
733
|
/* @__PURE__ */ jsx14(ColumnSelectContent, {
|
|
732
734
|
children: selectableColumns.map((column) => {
|
|
@@ -758,7 +760,7 @@ function ColumnSelect({ table }) {
|
|
|
758
760
|
}
|
|
759
761
|
|
|
760
762
|
// src/DataTable/components/DataTableHeader.tsx
|
|
761
|
-
import { Fragment as Fragment3, jsx as jsx15, jsxs as
|
|
763
|
+
import { Fragment as Fragment3, jsx as jsx15, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
762
764
|
var DataTableHeaderWrapper = styled15.div`
|
|
763
765
|
display: flex;
|
|
764
766
|
align-items: center;
|
|
@@ -775,7 +777,7 @@ var FilterContainer = styled15.div`
|
|
|
775
777
|
function DataTableHeader({ config, table, ...props }) {
|
|
776
778
|
var _a;
|
|
777
779
|
const [globalFilter, setGlobalFilter] = useAtom(globalFilterAtom);
|
|
778
|
-
return /* @__PURE__ */
|
|
780
|
+
return /* @__PURE__ */ jsxs8(DataTableHeaderWrapper, {
|
|
779
781
|
className: "--table-caption",
|
|
780
782
|
captionPadding: props.captionPadding,
|
|
781
783
|
children: [
|
|
@@ -785,7 +787,7 @@ function DataTableHeader({ config, table, ...props }) {
|
|
|
785
787
|
}),
|
|
786
788
|
/* @__PURE__ */ jsx15(FilterContainer, {
|
|
787
789
|
className: "--filter-container",
|
|
788
|
-
children: /* @__PURE__ */
|
|
790
|
+
children: /* @__PURE__ */ jsxs8(Fragment3, {
|
|
789
791
|
children: [
|
|
790
792
|
(config == null ? void 0 : config.globalFilter) && /* @__PURE__ */ jsx15(DebouncedInput, {
|
|
791
793
|
value: globalFilter,
|
|
@@ -822,7 +824,7 @@ var PaddingRow = (props) => {
|
|
|
822
824
|
};
|
|
823
825
|
|
|
824
826
|
// src/DataTable/components/VirtualTable.tsx
|
|
825
|
-
import { jsx as jsx17, jsxs as
|
|
827
|
+
import { jsx as jsx17, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
826
828
|
function VirtualTable({
|
|
827
829
|
table,
|
|
828
830
|
rowConfig,
|
|
@@ -840,13 +842,13 @@ function VirtualTable({
|
|
|
840
842
|
const virtualRows = rowVirtualizer.getVirtualItems();
|
|
841
843
|
const paddingTop = virtualRows.length > 0 ? ((_a = virtualRows == null ? void 0 : virtualRows[0]) == null ? void 0 : _a.start) || 0 : 0;
|
|
842
844
|
const paddingBottom = virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (((_b = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b.end) || 0) : 0;
|
|
843
|
-
return /* @__PURE__ */
|
|
845
|
+
return /* @__PURE__ */ jsxs9(Table9, {
|
|
844
846
|
children: [
|
|
845
847
|
/* @__PURE__ */ jsx17(TableHeader, {
|
|
846
848
|
sticky: props.stickyHeader,
|
|
847
849
|
table
|
|
848
850
|
}),
|
|
849
|
-
/* @__PURE__ */
|
|
851
|
+
/* @__PURE__ */ jsxs9(TableBody, {
|
|
850
852
|
children: [
|
|
851
853
|
/* @__PURE__ */ jsx17(PaddingRow, {
|
|
852
854
|
height: paddingTop
|
|
@@ -871,7 +873,7 @@ function VirtualTable({
|
|
|
871
873
|
}
|
|
872
874
|
|
|
873
875
|
// src/DataTable/DataTableRaw.tsx
|
|
874
|
-
import { jsx as jsx18, jsxs as
|
|
876
|
+
import { jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
875
877
|
var DataTableWrapper = styled16.div`
|
|
876
878
|
width: ${(props) => props.width ?? "100%"};
|
|
877
879
|
|
|
@@ -891,9 +893,9 @@ var DataTableWrapper = styled16.div`
|
|
|
891
893
|
}
|
|
892
894
|
`;
|
|
893
895
|
function DataTableRaw(props) {
|
|
894
|
-
const { isLoading, header, filters, config, rowConfig, table } = props;
|
|
896
|
+
const { isLoading, header, filters, config, rowConfig, cellConfig, table } = props;
|
|
895
897
|
const tableContainerRef = useRef2(null);
|
|
896
|
-
return /* @__PURE__ */
|
|
898
|
+
return /* @__PURE__ */ jsxs10(DataTableWrapper, {
|
|
897
899
|
captionPadding: header == null ? void 0 : header.captionPadding,
|
|
898
900
|
height: config == null ? void 0 : config.height,
|
|
899
901
|
width: config == null ? void 0 : config.width,
|
|
@@ -912,11 +914,13 @@ function DataTableRaw(props) {
|
|
|
912
914
|
containerRef: tableContainerRef,
|
|
913
915
|
table,
|
|
914
916
|
rowConfig,
|
|
917
|
+
cellConfig,
|
|
915
918
|
isLoading,
|
|
916
919
|
stickyHeader: header == null ? void 0 : header.stickyHeader
|
|
917
920
|
}) : /* @__PURE__ */ jsx18(BasicTable, {
|
|
918
921
|
table,
|
|
919
922
|
rowConfig,
|
|
923
|
+
cellConfig,
|
|
920
924
|
isLoading,
|
|
921
925
|
stickyHeader: header == null ? void 0 : header.stickyHeader
|
|
922
926
|
})
|
|
@@ -937,7 +941,7 @@ import { useAtom as useAtom2 } from "jotai";
|
|
|
937
941
|
import { useEffect as useEffect2 } from "react";
|
|
938
942
|
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
939
943
|
function useDataTable(props) {
|
|
940
|
-
const { columns, data, filters, config,
|
|
944
|
+
const { columns, data, filters, config, cellConfig } = props;
|
|
941
945
|
const [columnVisibility, setColumnVisibility] = useAtom2(columnVisibilityAtom);
|
|
942
946
|
const [globalFilter, setGlobalFilter] = useAtom2(globalFilterAtom);
|
|
943
947
|
const [sorting, setSorting] = useAtom2(tableSortingAtom);
|
|
@@ -958,12 +962,14 @@ function useDataTable(props) {
|
|
|
958
962
|
columnVisibility
|
|
959
963
|
},
|
|
960
964
|
defaultColumn: {
|
|
961
|
-
cell: (cell) =>
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
+
cell: ({ cell }) => {
|
|
966
|
+
const truncateMode = getFunctionValueOrDefault(cellConfig == null ? void 0 : cellConfig.truncateMode, cell, "hover");
|
|
967
|
+
return /* @__PURE__ */ jsx19(TypographyCustom, {
|
|
968
|
+
truncate: truncateMode === "hover",
|
|
969
|
+
children: cell.getValue()
|
|
970
|
+
});
|
|
971
|
+
}
|
|
965
972
|
},
|
|
966
|
-
meta,
|
|
967
973
|
enableSorting: config == null ? void 0 : config.sortable,
|
|
968
974
|
enableExpanding: !(config == null ? void 0 : config.hideExpandControls),
|
|
969
975
|
enableMultiRowSelection: (config == null ? void 0 : config.rowSelectionMode) === "multiple",
|
|
@@ -1025,6 +1031,7 @@ export {
|
|
|
1025
1031
|
TableHeader,
|
|
1026
1032
|
TypographyCustom,
|
|
1027
1033
|
capitalizeHeader,
|
|
1034
|
+
columnVisibilityAtom,
|
|
1028
1035
|
globalFilterAtom,
|
|
1029
1036
|
prependSelectColumn,
|
|
1030
1037
|
rowSelectionAtom,
|