@equinor/apollo-components 1.10.0 → 1.10.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 +10 -8
- package/dist/index.js +51 -45
- package/dist/index.mjs +73 -67
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -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';
|
|
@@ -157,14 +165,8 @@ declare function SelectColumnDef<T>(props?: DataTableConfig<T>): ColumnDef$1<T,
|
|
|
157
165
|
declare const StickyCell: styled_components.StyledComponent<react.ForwardRefExoticComponent<CellProps & react.RefAttributes<HTMLTableCellElement>>, any, {} & CellProps, never>;
|
|
158
166
|
|
|
159
167
|
declare type TypographyProps = {
|
|
160
|
-
|
|
161
|
-
/** Requires noWrap prop in order to function */
|
|
162
|
-
showAllOnHover?: boolean;
|
|
168
|
+
truncate?: boolean;
|
|
163
169
|
} & TypographyProps$1;
|
|
164
|
-
/** A cell used to wrap text in EDS Typography
|
|
165
|
-
*
|
|
166
|
-
* Developed for Plant Tracker.
|
|
167
|
-
*/
|
|
168
170
|
declare const TypographyCustom: (props: TypographyProps) => JSX.Element;
|
|
169
171
|
|
|
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 };
|
|
172
|
+
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, globalFilterAtom, prependSelectColumn, rowSelectionAtom, tableSortingAtom };
|
package/dist/index.js
CHANGED
|
@@ -233,7 +233,7 @@ var StyledStickyCell = (0, import_styled_components5.default)(StickyCell)`
|
|
|
233
233
|
background-color: ${({ backgroundColor: bg }) => bg ? `${bg} !important` : `inherit`};
|
|
234
234
|
`;
|
|
235
235
|
var StyledCell = (0, import_styled_components5.default)(import_eds_core_react4.Table.Cell)`
|
|
236
|
-
${({ backgroundColor: bg }) => bg ?
|
|
236
|
+
background-color: ${({ backgroundColor: bg }) => bg ? `${bg} !important` : `inherit`};
|
|
237
237
|
`;
|
|
238
238
|
function DynamicCell({ cell, highlight, getStickyCellColor }) {
|
|
239
239
|
var _a;
|
|
@@ -267,53 +267,48 @@ var truncateStyle = {
|
|
|
267
267
|
textOverflow: "ellipsis"
|
|
268
268
|
};
|
|
269
269
|
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
|
-
]
|
|
270
|
+
const { truncate, style: styleFromProps, ...edsTypographyProps } = props;
|
|
271
|
+
if (truncate)
|
|
272
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(HoverCapture, {
|
|
273
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_eds_core_react5.Typography, {
|
|
274
|
+
...edsTypographyProps,
|
|
275
|
+
style: {
|
|
276
|
+
...styleFromProps,
|
|
277
|
+
...truncateStyle
|
|
278
|
+
}
|
|
279
|
+
})
|
|
292
280
|
});
|
|
293
281
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_eds_core_react5.Typography, {
|
|
294
282
|
...edsTypographyProps,
|
|
295
|
-
style:
|
|
283
|
+
style: styleFromProps
|
|
296
284
|
});
|
|
297
285
|
};
|
|
298
286
|
var HoverCapture = import_styled_components6.default.div`
|
|
287
|
+
padding: 0.5em 0;
|
|
288
|
+
margin: -0.5em 0;
|
|
289
|
+
height: ${import_eds_tokens3.tokens.typography.table.cell_text.lineHeight};
|
|
290
|
+
background-color: inherit;
|
|
291
|
+
|
|
299
292
|
position: relative;
|
|
300
|
-
|
|
293
|
+
width: 100%;
|
|
301
294
|
|
|
302
|
-
|
|
303
|
-
|
|
295
|
+
&:hover {
|
|
296
|
+
z-index: 1;
|
|
297
|
+
}
|
|
304
298
|
|
|
305
|
-
|
|
306
|
-
|
|
299
|
+
& > * {
|
|
300
|
+
width: inherit;
|
|
301
|
+
position: absolute;
|
|
307
302
|
}
|
|
308
|
-
`;
|
|
309
|
-
var ShowAllWrapperWrapper = import_styled_components6.default.div`
|
|
310
|
-
position: absolute;
|
|
311
|
-
z-index: 1;
|
|
312
|
-
pointer-events: none;
|
|
313
303
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
304
|
+
&:hover > * {
|
|
305
|
+
width: auto;
|
|
306
|
+
z-index: 1;
|
|
307
|
+
padding: 0.5em 1em;
|
|
308
|
+
margin: -0.5em -1em;
|
|
309
|
+
|
|
310
|
+
background-color: inherit;
|
|
311
|
+
}
|
|
317
312
|
`;
|
|
318
313
|
|
|
319
314
|
// src/cells/HierarchyCell.tsx
|
|
@@ -373,7 +368,7 @@ function SelectColumnDef(props = {}) {
|
|
|
373
368
|
checked: table.getIsAllRowsSelected(),
|
|
374
369
|
indeterminate: table.getIsSomeRowsSelected(),
|
|
375
370
|
"aria-label": table.getIsAllRowsSelected() ? "Deselect all rows" : "Select all rows",
|
|
376
|
-
onChange: table.getToggleAllRowsSelectedHandler()
|
|
371
|
+
onChange: table.getIsSomeRowsSelected() ? () => table.toggleAllRowsSelected(false) : table.getToggleAllRowsSelectedHandler()
|
|
377
372
|
})
|
|
378
373
|
}) : null,
|
|
379
374
|
cell: ({ table, row }) => {
|
|
@@ -714,6 +709,13 @@ function prependSelectColumn(columns, config) {
|
|
|
714
709
|
return [SelectColumnDef(config), ...columns];
|
|
715
710
|
return [config.selectColumn(), ...columns];
|
|
716
711
|
}
|
|
712
|
+
function getFunctionValueOrDefault(valueOrFn, fnProps, defaultValue) {
|
|
713
|
+
if (valueOrFn === void 0)
|
|
714
|
+
return defaultValue;
|
|
715
|
+
if (typeof valueOrFn === "function")
|
|
716
|
+
return valueOrFn(fnProps);
|
|
717
|
+
return valueOrFn;
|
|
718
|
+
}
|
|
717
719
|
|
|
718
720
|
// src/DataTable/components/ColumnSelect.tsx
|
|
719
721
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
@@ -936,7 +938,7 @@ var DataTableWrapper = import_styled_components16.default.div`
|
|
|
936
938
|
}
|
|
937
939
|
`;
|
|
938
940
|
function DataTableRaw(props) {
|
|
939
|
-
const { isLoading, header, filters, config, rowConfig, table } = props;
|
|
941
|
+
const { isLoading, header, filters, config, rowConfig, cellConfig, table } = props;
|
|
940
942
|
const tableContainerRef = (0, import_react4.useRef)(null);
|
|
941
943
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DataTableWrapper, {
|
|
942
944
|
captionPadding: header == null ? void 0 : header.captionPadding,
|
|
@@ -957,11 +959,13 @@ function DataTableRaw(props) {
|
|
|
957
959
|
containerRef: tableContainerRef,
|
|
958
960
|
table,
|
|
959
961
|
rowConfig,
|
|
962
|
+
cellConfig,
|
|
960
963
|
isLoading,
|
|
961
964
|
stickyHeader: header == null ? void 0 : header.stickyHeader
|
|
962
965
|
}) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(BasicTable, {
|
|
963
966
|
table,
|
|
964
967
|
rowConfig,
|
|
968
|
+
cellConfig,
|
|
965
969
|
isLoading,
|
|
966
970
|
stickyHeader: header == null ? void 0 : header.stickyHeader
|
|
967
971
|
})
|
|
@@ -976,7 +980,7 @@ var import_jotai3 = require("jotai");
|
|
|
976
980
|
var import_react5 = require("react");
|
|
977
981
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
978
982
|
function useDataTable(props) {
|
|
979
|
-
const { columns, data, filters, config,
|
|
983
|
+
const { columns, data, filters, config, cellConfig } = props;
|
|
980
984
|
const [columnVisibility, setColumnVisibility] = (0, import_jotai3.useAtom)(columnVisibilityAtom);
|
|
981
985
|
const [globalFilter, setGlobalFilter] = (0, import_jotai3.useAtom)(globalFilterAtom);
|
|
982
986
|
const [sorting, setSorting] = (0, import_jotai3.useAtom)(tableSortingAtom);
|
|
@@ -997,12 +1001,14 @@ function useDataTable(props) {
|
|
|
997
1001
|
columnVisibility
|
|
998
1002
|
},
|
|
999
1003
|
defaultColumn: {
|
|
1000
|
-
cell: (cell) =>
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
+
cell: ({ cell }) => {
|
|
1005
|
+
const truncateMode = getFunctionValueOrDefault(cellConfig == null ? void 0 : cellConfig.truncateMode, cell, "hover");
|
|
1006
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TypographyCustom, {
|
|
1007
|
+
truncate: truncateMode === "hover",
|
|
1008
|
+
children: cell.getValue()
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1004
1011
|
},
|
|
1005
|
-
meta,
|
|
1006
1012
|
enableSorting: config == null ? void 0 : config.sortable,
|
|
1007
1013
|
enableExpanding: !(config == null ? void 0 : config.hideExpandControls),
|
|
1008
1014
|
enableMultiRowSelection: (config == null ? void 0 : config.rowSelectionMode) === "multiple",
|
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",
|