@equinor/apollo-components 3.4.0-beta.1 → 3.4.0-skeleton.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 +9 -1
- package/dist/index.js +150 -95
- package/dist/index.mjs +144 -89
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -179,7 +179,15 @@ interface DataTableProps<T> {
|
|
|
179
179
|
padding?: string;
|
|
180
180
|
};
|
|
181
181
|
tableContainerProps?: HTMLPropsRef<HTMLDivElement>;
|
|
182
|
-
infiniteScroll?:
|
|
182
|
+
infiniteScroll?: {
|
|
183
|
+
/** Called on scroll below offset. */
|
|
184
|
+
onBottomScroll: () => void;
|
|
185
|
+
/** Pixels above bottom. Defines when the onBottomScroll should be called. Defaults to `300`. */
|
|
186
|
+
offset?: number;
|
|
187
|
+
/** Displays loading row on the bottom of the table */
|
|
188
|
+
isFetchingNextPage?: boolean;
|
|
189
|
+
isLastPage?: boolean;
|
|
190
|
+
};
|
|
183
191
|
}
|
|
184
192
|
declare type ControlledState<T> = {
|
|
185
193
|
state?: T;
|
package/dist/index.js
CHANGED
|
@@ -3073,7 +3073,7 @@ function TableHeader({ table, sticky }) {
|
|
|
3073
3073
|
|
|
3074
3074
|
// src/DataTable/DataTable.tsx
|
|
3075
3075
|
var import_react_table3 = require("@tanstack/react-table");
|
|
3076
|
-
var
|
|
3076
|
+
var import_react9 = require("react");
|
|
3077
3077
|
var import_styled_components16 = __toESM(require("styled-components"));
|
|
3078
3078
|
|
|
3079
3079
|
// src/DataTable/components/BasicTable.tsx
|
|
@@ -3081,20 +3081,43 @@ var import_eds_core_react15 = require("@equinor/eds-core-react");
|
|
|
3081
3081
|
|
|
3082
3082
|
// src/DataTable/components/PlaceholderRow.tsx
|
|
3083
3083
|
var import_eds_core_react12 = require("@equinor/eds-core-react");
|
|
3084
|
-
var
|
|
3084
|
+
var import_react4 = require("react");
|
|
3085
3085
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3086
|
+
function PlaceholderRow({ children }) {
|
|
3087
|
+
const [width, setWidth] = (0, import_react4.useState)();
|
|
3088
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3089
|
+
import_eds_core_react12.Table.Row,
|
|
3090
|
+
{
|
|
3091
|
+
ref: (node) => {
|
|
3092
|
+
var _a, _b, _c;
|
|
3093
|
+
if (!node)
|
|
3094
|
+
return;
|
|
3095
|
+
setWidth((_c = (_b = (_a = node.parentElement) == null ? void 0 : _a.parentElement) == null ? void 0 : _b.parentElement) == null ? void 0 : _c.clientWidth);
|
|
3096
|
+
},
|
|
3097
|
+
style: { pointerEvents: "none" },
|
|
3098
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_eds_core_react12.Table.Cell, { colSpan: 100, style: { padding: 0 }, children: width && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3099
|
+
"div",
|
|
3100
|
+
{
|
|
3101
|
+
style: {
|
|
3102
|
+
width,
|
|
3103
|
+
display: "flex",
|
|
3104
|
+
justifyContent: "center",
|
|
3105
|
+
position: "sticky",
|
|
3106
|
+
left: 0,
|
|
3107
|
+
height: "100%",
|
|
3108
|
+
alignItems: "center"
|
|
3109
|
+
},
|
|
3110
|
+
children
|
|
3111
|
+
}
|
|
3112
|
+
) })
|
|
3113
|
+
}
|
|
3114
|
+
);
|
|
3092
3115
|
}
|
|
3093
3116
|
|
|
3094
3117
|
// src/DataTable/components/TableBody.tsx
|
|
3095
3118
|
var import_eds_core_react13 = require("@equinor/eds-core-react");
|
|
3096
|
-
var
|
|
3097
|
-
var TableBody = (0,
|
|
3119
|
+
var import_styled_components11 = __toESM(require("styled-components"));
|
|
3120
|
+
var TableBody = (0, import_styled_components11.default)(import_eds_core_react13.Table.Body)`
|
|
3098
3121
|
// The following attribute are important for fixed column width
|
|
3099
3122
|
// CHANGE THES WITH CAUTION
|
|
3100
3123
|
background: inherit;
|
|
@@ -3102,7 +3125,7 @@ var TableBody = (0, import_styled_components12.default)(import_eds_core_react13.
|
|
|
3102
3125
|
|
|
3103
3126
|
// src/DataTable/components/TableRow.tsx
|
|
3104
3127
|
var import_eds_core_react14 = require("@equinor/eds-core-react");
|
|
3105
|
-
var
|
|
3128
|
+
var import_styled_components12 = __toESM(require("styled-components"));
|
|
3106
3129
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3107
3130
|
function TableRow({
|
|
3108
3131
|
row,
|
|
@@ -3145,7 +3168,7 @@ function TableRow({
|
|
|
3145
3168
|
);
|
|
3146
3169
|
return rowWrapper ? rowWrapper({ row, children: tableRowContent }) : tableRowContent;
|
|
3147
3170
|
}
|
|
3148
|
-
var StyledTableRow = (0,
|
|
3171
|
+
var StyledTableRow = (0, import_styled_components12.default)(import_eds_core_react14.Table.Row)`
|
|
3149
3172
|
/* Background color must be inherited here. Does not work with inline styling */
|
|
3150
3173
|
${({ active }) => active ? "" : "background-color: inherit;"}
|
|
3151
3174
|
`;
|
|
@@ -3178,18 +3201,18 @@ function BasicTable({
|
|
|
3178
3201
|
// src/DataTable/components/DataTableHeader.tsx
|
|
3179
3202
|
var import_eds_core_react17 = require("@equinor/eds-core-react");
|
|
3180
3203
|
var import_eds_icons7 = require("@equinor/eds-icons");
|
|
3181
|
-
var
|
|
3204
|
+
var import_styled_components14 = __toESM(require("styled-components"));
|
|
3182
3205
|
|
|
3183
3206
|
// src/DataTable/filters/DebouncedInput.tsx
|
|
3184
3207
|
var import_eds_core_react16 = require("@equinor/eds-core-react");
|
|
3185
3208
|
var import_eds_icons6 = require("@equinor/eds-icons");
|
|
3186
|
-
var
|
|
3187
|
-
var
|
|
3209
|
+
var import_react5 = require("react");
|
|
3210
|
+
var import_styled_components13 = __toESM(require("styled-components"));
|
|
3188
3211
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
3189
|
-
var Wrapper3 =
|
|
3212
|
+
var Wrapper3 = import_styled_components13.default.div`
|
|
3190
3213
|
width: 200px;
|
|
3191
3214
|
`;
|
|
3192
|
-
var CloseButton = (0,
|
|
3215
|
+
var CloseButton = (0, import_styled_components13.default)(import_eds_core_react16.Button)`
|
|
3193
3216
|
width: 24px;
|
|
3194
3217
|
height: 24px;
|
|
3195
3218
|
`;
|
|
@@ -3205,11 +3228,11 @@ function DebouncedInput(_a) {
|
|
|
3205
3228
|
"icon",
|
|
3206
3229
|
"debounce"
|
|
3207
3230
|
]);
|
|
3208
|
-
const [value, setValue] = (0,
|
|
3209
|
-
(0,
|
|
3231
|
+
const [value, setValue] = (0, import_react5.useState)(initialValue);
|
|
3232
|
+
(0, import_react5.useEffect)(() => {
|
|
3210
3233
|
setValue(initialValue);
|
|
3211
3234
|
}, [initialValue]);
|
|
3212
|
-
(0,
|
|
3235
|
+
(0, import_react5.useEffect)(() => {
|
|
3213
3236
|
const timeout = setTimeout(() => {
|
|
3214
3237
|
onChange(value);
|
|
3215
3238
|
}, debounce);
|
|
@@ -3238,14 +3261,14 @@ var fuzzyFilter = (row, columnId, value, addMeta) => {
|
|
|
3238
3261
|
|
|
3239
3262
|
// src/DataTable/components/DataTableHeader.tsx
|
|
3240
3263
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3241
|
-
var TableBannerWrapper =
|
|
3264
|
+
var TableBannerWrapper = import_styled_components14.default.div`
|
|
3242
3265
|
display: flex;
|
|
3243
3266
|
align-items: center;
|
|
3244
3267
|
justify-content: space-between;
|
|
3245
3268
|
gap: 0.5rem;
|
|
3246
3269
|
padding: ${(props) => props.padding || "1rem"};
|
|
3247
3270
|
`;
|
|
3248
|
-
var FilterContainer =
|
|
3271
|
+
var FilterContainer = import_styled_components14.default.div`
|
|
3249
3272
|
display: flex;
|
|
3250
3273
|
align-items: center;
|
|
3251
3274
|
gap: 1rem;
|
|
@@ -3289,6 +3312,8 @@ function TableBanner({
|
|
|
3289
3312
|
// src/DataTable/components/VirtualTable.tsx
|
|
3290
3313
|
var import_eds_core_react19 = require("@equinor/eds-core-react");
|
|
3291
3314
|
var import_react_virtual = require("@tanstack/react-virtual");
|
|
3315
|
+
var import_react6 = require("react");
|
|
3316
|
+
var import_styled_components15 = __toESM(require("styled-components"));
|
|
3292
3317
|
|
|
3293
3318
|
// src/DataTable/components/PaddingRow.tsx
|
|
3294
3319
|
var import_eds_core_react18 = require("@equinor/eds-core-react");
|
|
@@ -3313,7 +3338,7 @@ function VirtualTable(_a) {
|
|
|
3313
3338
|
"cellConfig",
|
|
3314
3339
|
"containerRef"
|
|
3315
3340
|
]);
|
|
3316
|
-
var _a2
|
|
3341
|
+
var _a2;
|
|
3317
3342
|
const { rows } = table.getRowModel();
|
|
3318
3343
|
const rowVirtualizer = (0, import_react_virtual.useVirtualizer)({
|
|
3319
3344
|
count: rows.length,
|
|
@@ -3324,13 +3349,13 @@ function VirtualTable(_a) {
|
|
|
3324
3349
|
});
|
|
3325
3350
|
const virtualRows = rowVirtualizer.getVirtualItems();
|
|
3326
3351
|
const paddingTop = virtualRows.length > 0 ? ((_a2 = virtualRows == null ? void 0 : virtualRows[0]) == null ? void 0 : _a2.start) || 0 : 0;
|
|
3327
|
-
const paddingBottom = virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (((_b2 = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b2.end) || 0) : 0;
|
|
3328
|
-
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_eds_core_react19.Table, { children: [
|
|
3352
|
+
const paddingBottom = true ? 0 : virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (((_b2 = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b2.end) || 0) : 0;
|
|
3353
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_eds_core_react19.Table, { style: { position: "relative" }, children: [
|
|
3329
3354
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_eds_core_react19.Table.Caption, { hidden: true, children: props.tableCaption }),
|
|
3330
3355
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TableHeader, { sticky: props.stickyHeader, table }),
|
|
3331
|
-
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(TableBody, { children: [
|
|
3356
|
+
props.isLoading ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_eds_core_react19.Table.Body, { children: new Array(...new Array(30)).map((_, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_eds_core_react19.Table.Row, { children: table.getVisibleLeafColumns().map((column, columnIndex) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_eds_core_react19.Table.Cell, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TableCellSkeleton, { delay: (rowIndex + 1) / 20 + (columnIndex + 1) / 5 }) }, rowIndex + column.id)) }, rowIndex)) }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(TableBody, { children: [
|
|
3332
3357
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(PaddingRow, { height: paddingTop }),
|
|
3333
|
-
rows.length
|
|
3358
|
+
rows.length && virtualRows.map((virtualRow) => {
|
|
3334
3359
|
const row = rows[virtualRow.index];
|
|
3335
3360
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3336
3361
|
TableRow,
|
|
@@ -3343,16 +3368,34 @@ function VirtualTable(_a) {
|
|
|
3343
3368
|
},
|
|
3344
3369
|
row.id
|
|
3345
3370
|
);
|
|
3346
|
-
})
|
|
3371
|
+
}),
|
|
3372
|
+
!rows.length && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(PlaceholderRow, { children: props.isLoading ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_eds_core_react19.DotProgress, { color: "primary" }) : "No data available" }),
|
|
3373
|
+
props.isFetchingNextPage && false,
|
|
3347
3374
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(PaddingRow, { height: paddingBottom })
|
|
3348
3375
|
] })
|
|
3349
3376
|
] });
|
|
3350
3377
|
}
|
|
3378
|
+
var TableCellSkeleton = import_styled_components15.default.div`
|
|
3379
|
+
opacity: 0.5;
|
|
3380
|
+
animation: 1s skeleton-loading ${({ delay }) => `${delay}s`} linear infinite alternate;
|
|
3381
|
+
height: 1rem;
|
|
3382
|
+
border-radius: 0.5rem;
|
|
3383
|
+
background-color: #ccc;
|
|
3384
|
+
|
|
3385
|
+
@keyframes skeleton-loading {
|
|
3386
|
+
0% {
|
|
3387
|
+
background-color: #ccc;
|
|
3388
|
+
}
|
|
3389
|
+
100% {
|
|
3390
|
+
background-color: #eee;
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3393
|
+
`;
|
|
3351
3394
|
|
|
3352
3395
|
// src/DataTable/hooks/useFetchMoreOnBottomReached.tsx
|
|
3353
|
-
var
|
|
3396
|
+
var import_react7 = require("react");
|
|
3354
3397
|
function useFetchMoreOnBottomReached(tableContainerRef, infiniteScrollConfig) {
|
|
3355
|
-
const fetchMoreOnBottomReached = (0,
|
|
3398
|
+
const fetchMoreOnBottomReached = (0, import_react7.useCallback)(
|
|
3356
3399
|
(tableContainer) => {
|
|
3357
3400
|
if (!infiniteScrollConfig)
|
|
3358
3401
|
return;
|
|
@@ -3366,11 +3409,11 @@ function useFetchMoreOnBottomReached(tableContainerRef, infiniteScrollConfig) {
|
|
|
3366
3409
|
},
|
|
3367
3410
|
[infiniteScrollConfig]
|
|
3368
3411
|
);
|
|
3369
|
-
const onTableContainerScroll = (0,
|
|
3412
|
+
const onTableContainerScroll = (0, import_react7.useCallback)(
|
|
3370
3413
|
(event) => fetchMoreOnBottomReached(event.target),
|
|
3371
3414
|
[fetchMoreOnBottomReached]
|
|
3372
3415
|
);
|
|
3373
|
-
(0,
|
|
3416
|
+
(0, import_react7.useEffect)(() => {
|
|
3374
3417
|
if (!infiniteScrollConfig)
|
|
3375
3418
|
return;
|
|
3376
3419
|
fetchMoreOnBottomReached(tableContainerRef.current);
|
|
@@ -3379,10 +3422,10 @@ function useFetchMoreOnBottomReached(tableContainerRef, infiniteScrollConfig) {
|
|
|
3379
3422
|
}
|
|
3380
3423
|
|
|
3381
3424
|
// src/DataTable/hooks/useForceRerender.ts
|
|
3382
|
-
var
|
|
3425
|
+
var import_react8 = require("react");
|
|
3383
3426
|
function useForceRerender() {
|
|
3384
|
-
const [, setTick] = (0,
|
|
3385
|
-
return (0,
|
|
3427
|
+
const [, setTick] = (0, import_react8.useState)(0);
|
|
3428
|
+
return (0, import_react8.useCallback)(() => setTick((tick) => tick + 1), []);
|
|
3386
3429
|
}
|
|
3387
3430
|
|
|
3388
3431
|
// src/DataTable/DataTable.tsx
|
|
@@ -3411,6 +3454,7 @@ var DataTableWrapper = import_styled_components16.default.div`
|
|
|
3411
3454
|
}};
|
|
3412
3455
|
width: '100%';
|
|
3413
3456
|
overflow: auto;
|
|
3457
|
+
${(props) => props.disableYScroll ? "overflow-y: hidden;" : ""}
|
|
3414
3458
|
${(props) => canUseContainStrict(props.height) ? "contain: strict;" : ""}
|
|
3415
3459
|
|
|
3416
3460
|
table {
|
|
@@ -3426,14 +3470,14 @@ var DataTableWrapper = import_styled_components16.default.div`
|
|
|
3426
3470
|
}
|
|
3427
3471
|
`;
|
|
3428
3472
|
function DataTable(props) {
|
|
3429
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
|
|
3473
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H;
|
|
3430
3474
|
const { columns, data, bannerConfig, cellConfig, sorting } = props;
|
|
3431
|
-
const [internalColumnVisibility, setInternalColumnVisibility] = (0,
|
|
3475
|
+
const [internalColumnVisibility, setInternalColumnVisibility] = (0, import_react9.useState)({});
|
|
3432
3476
|
const [columnVisibility, setColumnVisibility] = [
|
|
3433
3477
|
(_b = (_a = props.columnVisibility) == null ? void 0 : _a.state) != null ? _b : internalColumnVisibility,
|
|
3434
3478
|
(_d = (_c = props.columnVisibility) == null ? void 0 : _c.onChange) != null ? _d : setInternalColumnVisibility
|
|
3435
3479
|
];
|
|
3436
|
-
const [internalGlobalFilterState, setInternalGlobalFilterState] = (0,
|
|
3480
|
+
const [internalGlobalFilterState, setInternalGlobalFilterState] = (0, import_react9.useState)("");
|
|
3437
3481
|
const [globalFilterState, setGlobalFilterState] = [
|
|
3438
3482
|
(_f = (_e = props.globalFilter) == null ? void 0 : _e.state) != null ? _f : internalGlobalFilterState,
|
|
3439
3483
|
(_h = (_g = props.globalFilter) == null ? void 0 : _g.onChange) != null ? _h : setInternalGlobalFilterState
|
|
@@ -3442,22 +3486,22 @@ function DataTable(props) {
|
|
|
3442
3486
|
function enableGlobalFilter(value) {
|
|
3443
3487
|
return enableOrUndefined(shouldEnableGlobalFilter, value);
|
|
3444
3488
|
}
|
|
3445
|
-
const [internalSortingState, setInternalSortingState] = (0,
|
|
3489
|
+
const [internalSortingState, setInternalSortingState] = (0, import_react9.useState)([]);
|
|
3446
3490
|
const [sortingState, setSortingState] = [
|
|
3447
3491
|
(_k = (_j = props.sorting) == null ? void 0 : _j.state) != null ? _k : internalSortingState,
|
|
3448
3492
|
(_m = (_l = props.sorting) == null ? void 0 : _l.onChange) != null ? _m : setInternalSortingState
|
|
3449
3493
|
];
|
|
3450
|
-
const [internalRowSelectionState, setInternalRowSelectionState] = (0,
|
|
3494
|
+
const [internalRowSelectionState, setInternalRowSelectionState] = (0, import_react9.useState)({});
|
|
3451
3495
|
const [rowSelectionState, setRowSelectionState] = [
|
|
3452
3496
|
(_o = (_n = props.rowSelection) == null ? void 0 : _n.state) != null ? _o : internalRowSelectionState,
|
|
3453
3497
|
(_q = (_p = props.rowSelection) == null ? void 0 : _p.onChange) != null ? _q : setInternalRowSelectionState
|
|
3454
3498
|
];
|
|
3455
|
-
const [internalExpandedState, setInternalExpandedState] = (0,
|
|
3499
|
+
const [internalExpandedState, setInternalExpandedState] = (0, import_react9.useState)({});
|
|
3456
3500
|
const [expandedState, setExpandedState] = [
|
|
3457
3501
|
(_s = (_r = props.expansion) == null ? void 0 : _r.state) != null ? _s : internalExpandedState,
|
|
3458
3502
|
(_u = (_t = props.expansion) == null ? void 0 : _t.onChange) != null ? _u : setInternalExpandedState
|
|
3459
3503
|
];
|
|
3460
|
-
const [internalColumnPinning, setInternalColumnPinning] = (0,
|
|
3504
|
+
const [internalColumnPinning, setInternalColumnPinning] = (0, import_react9.useState)({});
|
|
3461
3505
|
const [columnPinning, setColumnPinning] = [
|
|
3462
3506
|
typeof props.columnPinning === "object" && props.columnPinning.state ? props.columnPinning.state : internalColumnPinning,
|
|
3463
3507
|
typeof props.columnPinning === "object" && props.columnPinning.onChange ? props.columnPinning.onChange : setInternalColumnPinning
|
|
@@ -3502,72 +3546,83 @@ function DataTable(props) {
|
|
|
3502
3546
|
getSubRows: props == null ? void 0 : props.getSubRows,
|
|
3503
3547
|
getRowId: props == null ? void 0 : props.getRowId
|
|
3504
3548
|
});
|
|
3505
|
-
(0,
|
|
3549
|
+
(0, import_react9.useEffect)(() => {
|
|
3506
3550
|
var _a2;
|
|
3507
3551
|
if ((_a2 = props.expansion) == null ? void 0 : _a2.expandAllByDefault) {
|
|
3508
3552
|
table.toggleAllRowsExpanded();
|
|
3509
3553
|
}
|
|
3510
3554
|
}, [table, (_B = props.expansion) == null ? void 0 : _B.expandAllByDefault]);
|
|
3511
3555
|
const { isLoading, rowConfig } = props;
|
|
3512
|
-
const tableContainerRef = (0,
|
|
3556
|
+
const tableContainerRef = (0, import_react9.useRef)(null);
|
|
3513
3557
|
const onTableContainerScroll = useFetchMoreOnBottomReached(
|
|
3514
3558
|
tableContainerRef,
|
|
3515
3559
|
props.infiniteScroll
|
|
3516
3560
|
);
|
|
3517
3561
|
const forceRerender = useForceRerender();
|
|
3518
|
-
(0,
|
|
3562
|
+
(0, import_react9.useEffect)(() => {
|
|
3519
3563
|
if (Boolean(tableContainerRef.current))
|
|
3520
3564
|
forceRerender();
|
|
3521
3565
|
}, [tableContainerRef.current === null]);
|
|
3522
|
-
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3533
|
-
"div",
|
|
3534
|
-
__spreadProps(__spreadValues({}, props.tableContainerProps), {
|
|
3535
|
-
className: "--table-container " + ((_D = (_C = props.tableContainerProps) == null ? void 0 : _C.className) != null ? _D : ""),
|
|
3536
|
-
onScroll: (_F = (_E = props.tableContainerProps) == null ? void 0 : _E.onScroll) != null ? _F : onTableContainerScroll,
|
|
3537
|
-
ref: (node) => {
|
|
3538
|
-
var _a2;
|
|
3539
|
-
if (node) {
|
|
3540
|
-
tableContainerRef.current = node;
|
|
3541
|
-
if ((_a2 = props.tableContainerProps) == null ? void 0 : _a2.ref) {
|
|
3542
|
-
props.tableContainerProps.ref.current = node;
|
|
3543
|
-
}
|
|
3544
|
-
}
|
|
3545
|
-
},
|
|
3546
|
-
children: (props == null ? void 0 : props.virtual) ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3547
|
-
VirtualTable,
|
|
3548
|
-
{
|
|
3549
|
-
containerRef: tableContainerRef,
|
|
3550
|
-
tableCaption: props.tableCaption,
|
|
3551
|
-
table,
|
|
3552
|
-
rowConfig,
|
|
3553
|
-
cellConfig,
|
|
3554
|
-
isLoading,
|
|
3555
|
-
stickyHeader: props.stickyHeader
|
|
3556
|
-
}
|
|
3557
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3558
|
-
BasicTable,
|
|
3566
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
3567
|
+
DataTableWrapper,
|
|
3568
|
+
{
|
|
3569
|
+
height: props == null ? void 0 : props.height,
|
|
3570
|
+
width: props == null ? void 0 : props.width,
|
|
3571
|
+
tableLayout: props == null ? void 0 : props.tableLayout,
|
|
3572
|
+
disableYScroll: props.isLoading,
|
|
3573
|
+
children: [
|
|
3574
|
+
props.bannerConfig && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3575
|
+
TableBanner,
|
|
3559
3576
|
{
|
|
3560
|
-
tableCaption: props.tableCaption,
|
|
3561
3577
|
table,
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
stickyHeader: props.stickyHeader
|
|
3578
|
+
bannerConfig: props.bannerConfig,
|
|
3579
|
+
globalFilter: { state: globalFilterState, onChange: setGlobalFilterState },
|
|
3580
|
+
tableCaption: props.tableCaption
|
|
3566
3581
|
}
|
|
3582
|
+
),
|
|
3583
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3584
|
+
"div",
|
|
3585
|
+
__spreadProps(__spreadValues({}, props.tableContainerProps), {
|
|
3586
|
+
className: "--table-container " + ((_D = (_C = props.tableContainerProps) == null ? void 0 : _C.className) != null ? _D : ""),
|
|
3587
|
+
onScroll: (_F = (_E = props.tableContainerProps) == null ? void 0 : _E.onScroll) != null ? _F : onTableContainerScroll,
|
|
3588
|
+
ref: (node) => {
|
|
3589
|
+
var _a2;
|
|
3590
|
+
if (node) {
|
|
3591
|
+
tableContainerRef.current = node;
|
|
3592
|
+
if ((_a2 = props.tableContainerProps) == null ? void 0 : _a2.ref) {
|
|
3593
|
+
props.tableContainerProps.ref.current = node;
|
|
3594
|
+
}
|
|
3595
|
+
}
|
|
3596
|
+
},
|
|
3597
|
+
children: (props == null ? void 0 : props.virtual) ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3598
|
+
VirtualTable,
|
|
3599
|
+
{
|
|
3600
|
+
containerRef: tableContainerRef,
|
|
3601
|
+
tableCaption: props.tableCaption,
|
|
3602
|
+
table,
|
|
3603
|
+
rowConfig,
|
|
3604
|
+
cellConfig,
|
|
3605
|
+
isLoading,
|
|
3606
|
+
stickyHeader: props.stickyHeader,
|
|
3607
|
+
isFetchingNextPage: (_G = props.infiniteScroll) == null ? void 0 : _G.isFetchingNextPage
|
|
3608
|
+
}
|
|
3609
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3610
|
+
BasicTable,
|
|
3611
|
+
{
|
|
3612
|
+
tableCaption: props.tableCaption,
|
|
3613
|
+
table,
|
|
3614
|
+
rowConfig,
|
|
3615
|
+
cellConfig,
|
|
3616
|
+
isLoading,
|
|
3617
|
+
stickyHeader: props.stickyHeader,
|
|
3618
|
+
isFetchingNextPage: (_H = props.infiniteScroll) == null ? void 0 : _H.isFetchingNextPage
|
|
3619
|
+
}
|
|
3620
|
+
)
|
|
3621
|
+
})
|
|
3567
3622
|
)
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3623
|
+
]
|
|
3624
|
+
}
|
|
3625
|
+
);
|
|
3571
3626
|
}
|
|
3572
3627
|
|
|
3573
3628
|
// src/form-cells/EditableCheckboxCell.tsx
|
|
@@ -3659,7 +3714,7 @@ function EditableCheckboxCell(_a) {
|
|
|
3659
3714
|
|
|
3660
3715
|
// src/form-cells/EditableDateCell.tsx
|
|
3661
3716
|
var import_eds_core_react22 = require("@equinor/eds-core-react");
|
|
3662
|
-
var
|
|
3717
|
+
var import_react10 = require("react");
|
|
3663
3718
|
var import_react_hook_form3 = require("react-hook-form");
|
|
3664
3719
|
var import_styled_components17 = __toESM(require("styled-components"));
|
|
3665
3720
|
|
|
@@ -3714,7 +3769,7 @@ function EditableDateCell(_a) {
|
|
|
3714
3769
|
]);
|
|
3715
3770
|
const rawValue = context.getValue();
|
|
3716
3771
|
const editMode = useEditMode();
|
|
3717
|
-
const formattedValue = (0,
|
|
3772
|
+
const formattedValue = (0, import_react10.useMemo)(
|
|
3718
3773
|
() => {
|
|
3719
3774
|
var _a2;
|
|
3720
3775
|
return (_a2 = dateStringFormatter == null ? void 0 : dateStringFormatter(rawValue)) != null ? _a2 : rawValue;
|
|
@@ -3934,7 +3989,7 @@ var InlineTextField2 = (0, import_styled_components18.default)(import_eds_core_r
|
|
|
3934
3989
|
// src/form-cells/EditableTextAreaCell.tsx
|
|
3935
3990
|
var import_eds_core_react26 = require("@equinor/eds-core-react");
|
|
3936
3991
|
var import_eds_icons9 = require("@equinor/eds-icons");
|
|
3937
|
-
var
|
|
3992
|
+
var import_react11 = require("react");
|
|
3938
3993
|
var import_react_hook_form6 = require("react-hook-form");
|
|
3939
3994
|
var import_styled_components19 = __toESM(require("styled-components"));
|
|
3940
3995
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
@@ -3948,8 +4003,8 @@ function EditableTextAreaCell(_a) {
|
|
|
3948
4003
|
"error",
|
|
3949
4004
|
"onChange"
|
|
3950
4005
|
]);
|
|
3951
|
-
const [textareaValue, setTextareaValue] = (0,
|
|
3952
|
-
const [open, setOpen] = (0,
|
|
4006
|
+
const [textareaValue, setTextareaValue] = (0, import_react11.useState)(context.getValue());
|
|
4007
|
+
const [open, setOpen] = (0, import_react11.useState)(false);
|
|
3953
4008
|
const editMode = useEditMode();
|
|
3954
4009
|
const name = context.column.id;
|
|
3955
4010
|
if (!editMode)
|
package/dist/index.mjs
CHANGED
|
@@ -3031,28 +3031,51 @@ import {
|
|
|
3031
3031
|
getSortedRowModel,
|
|
3032
3032
|
useReactTable
|
|
3033
3033
|
} from "@tanstack/react-table";
|
|
3034
|
-
import { useEffect as useEffect3, useRef as useRef3, useState as
|
|
3034
|
+
import { useEffect as useEffect3, useRef as useRef3, useState as useState8 } from "react";
|
|
3035
3035
|
import styled16 from "styled-components";
|
|
3036
3036
|
|
|
3037
3037
|
// src/DataTable/components/BasicTable.tsx
|
|
3038
3038
|
import { Table as EdsTable3 } from "@equinor/eds-core-react";
|
|
3039
3039
|
|
|
3040
3040
|
// src/DataTable/components/PlaceholderRow.tsx
|
|
3041
|
-
import {
|
|
3042
|
-
import
|
|
3041
|
+
import { Table as Table4 } from "@equinor/eds-core-react";
|
|
3042
|
+
import { useState as useState4 } from "react";
|
|
3043
3043
|
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3044
|
+
function PlaceholderRow({ children }) {
|
|
3045
|
+
const [width, setWidth] = useState4();
|
|
3046
|
+
return /* @__PURE__ */ jsx13(
|
|
3047
|
+
Table4.Row,
|
|
3048
|
+
{
|
|
3049
|
+
ref: (node) => {
|
|
3050
|
+
var _a, _b, _c;
|
|
3051
|
+
if (!node)
|
|
3052
|
+
return;
|
|
3053
|
+
setWidth((_c = (_b = (_a = node.parentElement) == null ? void 0 : _a.parentElement) == null ? void 0 : _b.parentElement) == null ? void 0 : _c.clientWidth);
|
|
3054
|
+
},
|
|
3055
|
+
style: { pointerEvents: "none" },
|
|
3056
|
+
children: /* @__PURE__ */ jsx13(Table4.Cell, { colSpan: 100, style: { padding: 0 }, children: width && /* @__PURE__ */ jsx13(
|
|
3057
|
+
"div",
|
|
3058
|
+
{
|
|
3059
|
+
style: {
|
|
3060
|
+
width,
|
|
3061
|
+
display: "flex",
|
|
3062
|
+
justifyContent: "center",
|
|
3063
|
+
position: "sticky",
|
|
3064
|
+
left: 0,
|
|
3065
|
+
height: "100%",
|
|
3066
|
+
alignItems: "center"
|
|
3067
|
+
},
|
|
3068
|
+
children
|
|
3069
|
+
}
|
|
3070
|
+
) })
|
|
3071
|
+
}
|
|
3072
|
+
);
|
|
3050
3073
|
}
|
|
3051
3074
|
|
|
3052
3075
|
// src/DataTable/components/TableBody.tsx
|
|
3053
3076
|
import { Table as Table5 } from "@equinor/eds-core-react";
|
|
3054
|
-
import
|
|
3055
|
-
var TableBody =
|
|
3077
|
+
import styled11 from "styled-components";
|
|
3078
|
+
var TableBody = styled11(Table5.Body)`
|
|
3056
3079
|
// The following attribute are important for fixed column width
|
|
3057
3080
|
// CHANGE THES WITH CAUTION
|
|
3058
3081
|
background: inherit;
|
|
@@ -3060,7 +3083,7 @@ var TableBody = styled12(Table5.Body)`
|
|
|
3060
3083
|
|
|
3061
3084
|
// src/DataTable/components/TableRow.tsx
|
|
3062
3085
|
import { Table as Table6 } from "@equinor/eds-core-react";
|
|
3063
|
-
import
|
|
3086
|
+
import styled12 from "styled-components";
|
|
3064
3087
|
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
3065
3088
|
function TableRow({
|
|
3066
3089
|
row,
|
|
@@ -3103,7 +3126,7 @@ function TableRow({
|
|
|
3103
3126
|
);
|
|
3104
3127
|
return rowWrapper ? rowWrapper({ row, children: tableRowContent }) : tableRowContent;
|
|
3105
3128
|
}
|
|
3106
|
-
var StyledTableRow =
|
|
3129
|
+
var StyledTableRow = styled12(Table6.Row)`
|
|
3107
3130
|
/* Background color must be inherited here. Does not work with inline styling */
|
|
3108
3131
|
${({ active }) => active ? "" : "background-color: inherit;"}
|
|
3109
3132
|
`;
|
|
@@ -3134,20 +3157,20 @@ function BasicTable({
|
|
|
3134
3157
|
}
|
|
3135
3158
|
|
|
3136
3159
|
// src/DataTable/components/DataTableHeader.tsx
|
|
3137
|
-
import { Typography as
|
|
3160
|
+
import { Typography as Typography2 } from "@equinor/eds-core-react";
|
|
3138
3161
|
import { search } from "@equinor/eds-icons";
|
|
3139
|
-
import
|
|
3162
|
+
import styled14 from "styled-components";
|
|
3140
3163
|
|
|
3141
3164
|
// src/DataTable/filters/DebouncedInput.tsx
|
|
3142
3165
|
import { Button as Button4, Icon as Icon6, Input, Tooltip as Tooltip2 } from "@equinor/eds-core-react";
|
|
3143
3166
|
import { close as close2 } from "@equinor/eds-icons";
|
|
3144
|
-
import { useEffect, useState as
|
|
3145
|
-
import
|
|
3167
|
+
import { useEffect, useState as useState5 } from "react";
|
|
3168
|
+
import styled13 from "styled-components";
|
|
3146
3169
|
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
3147
|
-
var Wrapper3 =
|
|
3170
|
+
var Wrapper3 = styled13.div`
|
|
3148
3171
|
width: 200px;
|
|
3149
3172
|
`;
|
|
3150
|
-
var CloseButton =
|
|
3173
|
+
var CloseButton = styled13(Button4)`
|
|
3151
3174
|
width: 24px;
|
|
3152
3175
|
height: 24px;
|
|
3153
3176
|
`;
|
|
@@ -3163,7 +3186,7 @@ function DebouncedInput(_a) {
|
|
|
3163
3186
|
"icon",
|
|
3164
3187
|
"debounce"
|
|
3165
3188
|
]);
|
|
3166
|
-
const [value, setValue] =
|
|
3189
|
+
const [value, setValue] = useState5(initialValue);
|
|
3167
3190
|
useEffect(() => {
|
|
3168
3191
|
setValue(initialValue);
|
|
3169
3192
|
}, [initialValue]);
|
|
@@ -3196,14 +3219,14 @@ var fuzzyFilter = (row, columnId, value, addMeta) => {
|
|
|
3196
3219
|
|
|
3197
3220
|
// src/DataTable/components/DataTableHeader.tsx
|
|
3198
3221
|
import { Fragment as Fragment3, jsx as jsx17, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
3199
|
-
var TableBannerWrapper =
|
|
3222
|
+
var TableBannerWrapper = styled14.div`
|
|
3200
3223
|
display: flex;
|
|
3201
3224
|
align-items: center;
|
|
3202
3225
|
justify-content: space-between;
|
|
3203
3226
|
gap: 0.5rem;
|
|
3204
3227
|
padding: ${(props) => props.padding || "1rem"};
|
|
3205
3228
|
`;
|
|
3206
|
-
var FilterContainer =
|
|
3229
|
+
var FilterContainer = styled14.div`
|
|
3207
3230
|
display: flex;
|
|
3208
3231
|
align-items: center;
|
|
3209
3232
|
gap: 1rem;
|
|
@@ -3218,7 +3241,7 @@ function TableBanner({
|
|
|
3218
3241
|
var _a, _b, _c, _d, _e;
|
|
3219
3242
|
return /* @__PURE__ */ jsxs9(TableBannerWrapper, { className: "--table-caption", padding: bannerConfig == null ? void 0 : bannerConfig.padding, children: [
|
|
3220
3243
|
/* @__PURE__ */ jsxs9(FilterContainer, { className: "--filter-container-left", children: [
|
|
3221
|
-
(bannerConfig == null ? void 0 : bannerConfig.enableTableCaption) && /* @__PURE__ */ jsx17(
|
|
3244
|
+
(bannerConfig == null ? void 0 : bannerConfig.enableTableCaption) && /* @__PURE__ */ jsx17(Typography2, { variant: "h3", as: "h2", children: tableCaption }),
|
|
3222
3245
|
(_c = (_a = bannerConfig == null ? void 0 : bannerConfig.customActionsLeft) == null ? void 0 : _a.call(bannerConfig, table)) != null ? _c : (_b = bannerConfig == null ? void 0 : bannerConfig.customActions) == null ? void 0 : _b.call(bannerConfig, table)
|
|
3223
3246
|
] }),
|
|
3224
3247
|
/* @__PURE__ */ jsx17(FilterContainer, { className: "--filter-container-right", children: /* @__PURE__ */ jsxs9(Fragment3, { children: [
|
|
@@ -3245,8 +3268,10 @@ function TableBanner({
|
|
|
3245
3268
|
}
|
|
3246
3269
|
|
|
3247
3270
|
// src/DataTable/components/VirtualTable.tsx
|
|
3248
|
-
import { Table as Table8 } from "@equinor/eds-core-react";
|
|
3271
|
+
import { DotProgress, Table as Table8 } from "@equinor/eds-core-react";
|
|
3249
3272
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
3273
|
+
import { useState as useState6 } from "react";
|
|
3274
|
+
import styled15 from "styled-components";
|
|
3250
3275
|
|
|
3251
3276
|
// src/DataTable/components/PaddingRow.tsx
|
|
3252
3277
|
import { Table as Table7 } from "@equinor/eds-core-react";
|
|
@@ -3271,7 +3296,7 @@ function VirtualTable(_a) {
|
|
|
3271
3296
|
"cellConfig",
|
|
3272
3297
|
"containerRef"
|
|
3273
3298
|
]);
|
|
3274
|
-
var _a2
|
|
3299
|
+
var _a2;
|
|
3275
3300
|
const { rows } = table.getRowModel();
|
|
3276
3301
|
const rowVirtualizer = useVirtualizer({
|
|
3277
3302
|
count: rows.length,
|
|
@@ -3282,13 +3307,13 @@ function VirtualTable(_a) {
|
|
|
3282
3307
|
});
|
|
3283
3308
|
const virtualRows = rowVirtualizer.getVirtualItems();
|
|
3284
3309
|
const paddingTop = virtualRows.length > 0 ? ((_a2 = virtualRows == null ? void 0 : virtualRows[0]) == null ? void 0 : _a2.start) || 0 : 0;
|
|
3285
|
-
const paddingBottom = virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (((_b2 = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b2.end) || 0) : 0;
|
|
3286
|
-
return /* @__PURE__ */ jsxs10(Table8, { children: [
|
|
3310
|
+
const paddingBottom = true ? 0 : virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (((_b2 = virtualRows == null ? void 0 : virtualRows[virtualRows.length - 1]) == null ? void 0 : _b2.end) || 0) : 0;
|
|
3311
|
+
return /* @__PURE__ */ jsxs10(Table8, { style: { position: "relative" }, children: [
|
|
3287
3312
|
/* @__PURE__ */ jsx19(Table8.Caption, { hidden: true, children: props.tableCaption }),
|
|
3288
3313
|
/* @__PURE__ */ jsx19(TableHeader, { sticky: props.stickyHeader, table }),
|
|
3289
|
-
/* @__PURE__ */ jsxs10(TableBody, { children: [
|
|
3314
|
+
props.isLoading ? /* @__PURE__ */ jsx19(Table8.Body, { children: new Array(...new Array(30)).map((_, rowIndex) => /* @__PURE__ */ jsx19(Table8.Row, { children: table.getVisibleLeafColumns().map((column, columnIndex) => /* @__PURE__ */ jsx19(Table8.Cell, { children: /* @__PURE__ */ jsx19(TableCellSkeleton, { delay: (rowIndex + 1) / 20 + (columnIndex + 1) / 5 }) }, rowIndex + column.id)) }, rowIndex)) }) : /* @__PURE__ */ jsxs10(TableBody, { children: [
|
|
3290
3315
|
/* @__PURE__ */ jsx19(PaddingRow, { height: paddingTop }),
|
|
3291
|
-
rows.length
|
|
3316
|
+
rows.length && virtualRows.map((virtualRow) => {
|
|
3292
3317
|
const row = rows[virtualRow.index];
|
|
3293
3318
|
return /* @__PURE__ */ jsx19(
|
|
3294
3319
|
TableRow,
|
|
@@ -3301,11 +3326,29 @@ function VirtualTable(_a) {
|
|
|
3301
3326
|
},
|
|
3302
3327
|
row.id
|
|
3303
3328
|
);
|
|
3304
|
-
})
|
|
3329
|
+
}),
|
|
3330
|
+
!rows.length && /* @__PURE__ */ jsx19(PlaceholderRow, { children: props.isLoading ? /* @__PURE__ */ jsx19(DotProgress, { color: "primary" }) : "No data available" }),
|
|
3331
|
+
props.isFetchingNextPage && false,
|
|
3305
3332
|
/* @__PURE__ */ jsx19(PaddingRow, { height: paddingBottom })
|
|
3306
3333
|
] })
|
|
3307
3334
|
] });
|
|
3308
3335
|
}
|
|
3336
|
+
var TableCellSkeleton = styled15.div`
|
|
3337
|
+
opacity: 0.5;
|
|
3338
|
+
animation: 1s skeleton-loading ${({ delay }) => `${delay}s`} linear infinite alternate;
|
|
3339
|
+
height: 1rem;
|
|
3340
|
+
border-radius: 0.5rem;
|
|
3341
|
+
background-color: #ccc;
|
|
3342
|
+
|
|
3343
|
+
@keyframes skeleton-loading {
|
|
3344
|
+
0% {
|
|
3345
|
+
background-color: #ccc;
|
|
3346
|
+
}
|
|
3347
|
+
100% {
|
|
3348
|
+
background-color: #eee;
|
|
3349
|
+
}
|
|
3350
|
+
}
|
|
3351
|
+
`;
|
|
3309
3352
|
|
|
3310
3353
|
// src/DataTable/hooks/useFetchMoreOnBottomReached.tsx
|
|
3311
3354
|
import { useCallback, useEffect as useEffect2 } from "react";
|
|
@@ -3337,9 +3380,9 @@ function useFetchMoreOnBottomReached(tableContainerRef, infiniteScrollConfig) {
|
|
|
3337
3380
|
}
|
|
3338
3381
|
|
|
3339
3382
|
// src/DataTable/hooks/useForceRerender.ts
|
|
3340
|
-
import { useCallback as useCallback2, useState as
|
|
3383
|
+
import { useCallback as useCallback2, useState as useState7 } from "react";
|
|
3341
3384
|
function useForceRerender() {
|
|
3342
|
-
const [, setTick] =
|
|
3385
|
+
const [, setTick] = useState7(0);
|
|
3343
3386
|
return useCallback2(() => setTick((tick) => tick + 1), []);
|
|
3344
3387
|
}
|
|
3345
3388
|
|
|
@@ -3369,6 +3412,7 @@ var DataTableWrapper = styled16.div`
|
|
|
3369
3412
|
}};
|
|
3370
3413
|
width: '100%';
|
|
3371
3414
|
overflow: auto;
|
|
3415
|
+
${(props) => props.disableYScroll ? "overflow-y: hidden;" : ""}
|
|
3372
3416
|
${(props) => canUseContainStrict(props.height) ? "contain: strict;" : ""}
|
|
3373
3417
|
|
|
3374
3418
|
table {
|
|
@@ -3384,14 +3428,14 @@ var DataTableWrapper = styled16.div`
|
|
|
3384
3428
|
}
|
|
3385
3429
|
`;
|
|
3386
3430
|
function DataTable(props) {
|
|
3387
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
|
|
3431
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H;
|
|
3388
3432
|
const { columns, data, bannerConfig, cellConfig, sorting } = props;
|
|
3389
|
-
const [internalColumnVisibility, setInternalColumnVisibility] =
|
|
3433
|
+
const [internalColumnVisibility, setInternalColumnVisibility] = useState8({});
|
|
3390
3434
|
const [columnVisibility, setColumnVisibility] = [
|
|
3391
3435
|
(_b = (_a = props.columnVisibility) == null ? void 0 : _a.state) != null ? _b : internalColumnVisibility,
|
|
3392
3436
|
(_d = (_c = props.columnVisibility) == null ? void 0 : _c.onChange) != null ? _d : setInternalColumnVisibility
|
|
3393
3437
|
];
|
|
3394
|
-
const [internalGlobalFilterState, setInternalGlobalFilterState] =
|
|
3438
|
+
const [internalGlobalFilterState, setInternalGlobalFilterState] = useState8("");
|
|
3395
3439
|
const [globalFilterState, setGlobalFilterState] = [
|
|
3396
3440
|
(_f = (_e = props.globalFilter) == null ? void 0 : _e.state) != null ? _f : internalGlobalFilterState,
|
|
3397
3441
|
(_h = (_g = props.globalFilter) == null ? void 0 : _g.onChange) != null ? _h : setInternalGlobalFilterState
|
|
@@ -3400,22 +3444,22 @@ function DataTable(props) {
|
|
|
3400
3444
|
function enableGlobalFilter(value) {
|
|
3401
3445
|
return enableOrUndefined(shouldEnableGlobalFilter, value);
|
|
3402
3446
|
}
|
|
3403
|
-
const [internalSortingState, setInternalSortingState] =
|
|
3447
|
+
const [internalSortingState, setInternalSortingState] = useState8([]);
|
|
3404
3448
|
const [sortingState, setSortingState] = [
|
|
3405
3449
|
(_k = (_j = props.sorting) == null ? void 0 : _j.state) != null ? _k : internalSortingState,
|
|
3406
3450
|
(_m = (_l = props.sorting) == null ? void 0 : _l.onChange) != null ? _m : setInternalSortingState
|
|
3407
3451
|
];
|
|
3408
|
-
const [internalRowSelectionState, setInternalRowSelectionState] =
|
|
3452
|
+
const [internalRowSelectionState, setInternalRowSelectionState] = useState8({});
|
|
3409
3453
|
const [rowSelectionState, setRowSelectionState] = [
|
|
3410
3454
|
(_o = (_n = props.rowSelection) == null ? void 0 : _n.state) != null ? _o : internalRowSelectionState,
|
|
3411
3455
|
(_q = (_p = props.rowSelection) == null ? void 0 : _p.onChange) != null ? _q : setInternalRowSelectionState
|
|
3412
3456
|
];
|
|
3413
|
-
const [internalExpandedState, setInternalExpandedState] =
|
|
3457
|
+
const [internalExpandedState, setInternalExpandedState] = useState8({});
|
|
3414
3458
|
const [expandedState, setExpandedState] = [
|
|
3415
3459
|
(_s = (_r = props.expansion) == null ? void 0 : _r.state) != null ? _s : internalExpandedState,
|
|
3416
3460
|
(_u = (_t = props.expansion) == null ? void 0 : _t.onChange) != null ? _u : setInternalExpandedState
|
|
3417
3461
|
];
|
|
3418
|
-
const [internalColumnPinning, setInternalColumnPinning] =
|
|
3462
|
+
const [internalColumnPinning, setInternalColumnPinning] = useState8({});
|
|
3419
3463
|
const [columnPinning, setColumnPinning] = [
|
|
3420
3464
|
typeof props.columnPinning === "object" && props.columnPinning.state ? props.columnPinning.state : internalColumnPinning,
|
|
3421
3465
|
typeof props.columnPinning === "object" && props.columnPinning.onChange ? props.columnPinning.onChange : setInternalColumnPinning
|
|
@@ -3477,55 +3521,66 @@ function DataTable(props) {
|
|
|
3477
3521
|
if (Boolean(tableContainerRef.current))
|
|
3478
3522
|
forceRerender();
|
|
3479
3523
|
}, [tableContainerRef.current === null]);
|
|
3480
|
-
return /* @__PURE__ */ jsxs11(
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
/* @__PURE__ */ jsx20(
|
|
3491
|
-
"div",
|
|
3492
|
-
__spreadProps(__spreadValues({}, props.tableContainerProps), {
|
|
3493
|
-
className: "--table-container " + ((_D = (_C = props.tableContainerProps) == null ? void 0 : _C.className) != null ? _D : ""),
|
|
3494
|
-
onScroll: (_F = (_E = props.tableContainerProps) == null ? void 0 : _E.onScroll) != null ? _F : onTableContainerScroll,
|
|
3495
|
-
ref: (node) => {
|
|
3496
|
-
var _a2;
|
|
3497
|
-
if (node) {
|
|
3498
|
-
tableContainerRef.current = node;
|
|
3499
|
-
if ((_a2 = props.tableContainerProps) == null ? void 0 : _a2.ref) {
|
|
3500
|
-
props.tableContainerProps.ref.current = node;
|
|
3501
|
-
}
|
|
3502
|
-
}
|
|
3503
|
-
},
|
|
3504
|
-
children: (props == null ? void 0 : props.virtual) ? /* @__PURE__ */ jsx20(
|
|
3505
|
-
VirtualTable,
|
|
3506
|
-
{
|
|
3507
|
-
containerRef: tableContainerRef,
|
|
3508
|
-
tableCaption: props.tableCaption,
|
|
3509
|
-
table,
|
|
3510
|
-
rowConfig,
|
|
3511
|
-
cellConfig,
|
|
3512
|
-
isLoading,
|
|
3513
|
-
stickyHeader: props.stickyHeader
|
|
3514
|
-
}
|
|
3515
|
-
) : /* @__PURE__ */ jsx20(
|
|
3516
|
-
BasicTable,
|
|
3524
|
+
return /* @__PURE__ */ jsxs11(
|
|
3525
|
+
DataTableWrapper,
|
|
3526
|
+
{
|
|
3527
|
+
height: props == null ? void 0 : props.height,
|
|
3528
|
+
width: props == null ? void 0 : props.width,
|
|
3529
|
+
tableLayout: props == null ? void 0 : props.tableLayout,
|
|
3530
|
+
disableYScroll: props.isLoading,
|
|
3531
|
+
children: [
|
|
3532
|
+
props.bannerConfig && /* @__PURE__ */ jsx20(
|
|
3533
|
+
TableBanner,
|
|
3517
3534
|
{
|
|
3518
|
-
tableCaption: props.tableCaption,
|
|
3519
3535
|
table,
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
stickyHeader: props.stickyHeader
|
|
3536
|
+
bannerConfig: props.bannerConfig,
|
|
3537
|
+
globalFilter: { state: globalFilterState, onChange: setGlobalFilterState },
|
|
3538
|
+
tableCaption: props.tableCaption
|
|
3524
3539
|
}
|
|
3540
|
+
),
|
|
3541
|
+
/* @__PURE__ */ jsx20(
|
|
3542
|
+
"div",
|
|
3543
|
+
__spreadProps(__spreadValues({}, props.tableContainerProps), {
|
|
3544
|
+
className: "--table-container " + ((_D = (_C = props.tableContainerProps) == null ? void 0 : _C.className) != null ? _D : ""),
|
|
3545
|
+
onScroll: (_F = (_E = props.tableContainerProps) == null ? void 0 : _E.onScroll) != null ? _F : onTableContainerScroll,
|
|
3546
|
+
ref: (node) => {
|
|
3547
|
+
var _a2;
|
|
3548
|
+
if (node) {
|
|
3549
|
+
tableContainerRef.current = node;
|
|
3550
|
+
if ((_a2 = props.tableContainerProps) == null ? void 0 : _a2.ref) {
|
|
3551
|
+
props.tableContainerProps.ref.current = node;
|
|
3552
|
+
}
|
|
3553
|
+
}
|
|
3554
|
+
},
|
|
3555
|
+
children: (props == null ? void 0 : props.virtual) ? /* @__PURE__ */ jsx20(
|
|
3556
|
+
VirtualTable,
|
|
3557
|
+
{
|
|
3558
|
+
containerRef: tableContainerRef,
|
|
3559
|
+
tableCaption: props.tableCaption,
|
|
3560
|
+
table,
|
|
3561
|
+
rowConfig,
|
|
3562
|
+
cellConfig,
|
|
3563
|
+
isLoading,
|
|
3564
|
+
stickyHeader: props.stickyHeader,
|
|
3565
|
+
isFetchingNextPage: (_G = props.infiniteScroll) == null ? void 0 : _G.isFetchingNextPage
|
|
3566
|
+
}
|
|
3567
|
+
) : /* @__PURE__ */ jsx20(
|
|
3568
|
+
BasicTable,
|
|
3569
|
+
{
|
|
3570
|
+
tableCaption: props.tableCaption,
|
|
3571
|
+
table,
|
|
3572
|
+
rowConfig,
|
|
3573
|
+
cellConfig,
|
|
3574
|
+
isLoading,
|
|
3575
|
+
stickyHeader: props.stickyHeader,
|
|
3576
|
+
isFetchingNextPage: (_H = props.infiniteScroll) == null ? void 0 : _H.isFetchingNextPage
|
|
3577
|
+
}
|
|
3578
|
+
)
|
|
3579
|
+
})
|
|
3525
3580
|
)
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3581
|
+
]
|
|
3582
|
+
}
|
|
3583
|
+
);
|
|
3529
3584
|
}
|
|
3530
3585
|
|
|
3531
3586
|
// src/form-cells/EditableCheckboxCell.tsx
|
|
@@ -3739,7 +3794,7 @@ import { Autocomplete } from "@equinor/eds-core-react";
|
|
|
3739
3794
|
import { Controller as Controller3 } from "react-hook-form";
|
|
3740
3795
|
|
|
3741
3796
|
// src/form-cells/FormHelperText.tsx
|
|
3742
|
-
import { Typography as
|
|
3797
|
+
import { Typography as Typography3 } from "@equinor/eds-core-react";
|
|
3743
3798
|
import { tokens as tokens7 } from "@equinor/eds-tokens";
|
|
3744
3799
|
import { Fragment as Fragment4, jsx as jsx24, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3745
3800
|
var colors = {
|
|
@@ -3760,7 +3815,7 @@ function HelperText({ helperText, variant, helperIcon }) {
|
|
|
3760
3815
|
children: [
|
|
3761
3816
|
/* @__PURE__ */ jsx24("span", { style: { flexShrink: 0 }, children: helperIcon }),
|
|
3762
3817
|
/* @__PURE__ */ jsx24(
|
|
3763
|
-
|
|
3818
|
+
Typography3,
|
|
3764
3819
|
{
|
|
3765
3820
|
style: {
|
|
3766
3821
|
fontSize: "0.75rem",
|
|
@@ -3892,7 +3947,7 @@ var InlineTextField2 = styled18(TextField2)`
|
|
|
3892
3947
|
// src/form-cells/EditableTextAreaCell.tsx
|
|
3893
3948
|
import { Button as Button5, Dialog as EDS, Icon as Icon8, TextField as TextField3 } from "@equinor/eds-core-react";
|
|
3894
3949
|
import { arrow_up } from "@equinor/eds-icons";
|
|
3895
|
-
import { useState as
|
|
3950
|
+
import { useState as useState9 } from "react";
|
|
3896
3951
|
import { Controller as Controller5 } from "react-hook-form";
|
|
3897
3952
|
import styled19 from "styled-components";
|
|
3898
3953
|
import { Fragment as Fragment7, jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
@@ -3906,8 +3961,8 @@ function EditableTextAreaCell(_a) {
|
|
|
3906
3961
|
"error",
|
|
3907
3962
|
"onChange"
|
|
3908
3963
|
]);
|
|
3909
|
-
const [textareaValue, setTextareaValue] =
|
|
3910
|
-
const [open, setOpen] =
|
|
3964
|
+
const [textareaValue, setTextareaValue] = useState9(context.getValue());
|
|
3965
|
+
const [open, setOpen] = useState9(false);
|
|
3911
3966
|
const editMode = useEditMode();
|
|
3912
3967
|
const name = context.column.id;
|
|
3913
3968
|
if (!editMode)
|