@xyo-network/react-payload-table 7.5.8 → 7.5.11
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/browser/components/Table/TableRowNoData.d.ts.map +1 -1
- package/dist/browser/index.mjs +438 -460
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +182 -44
- package/src/components/DynamicTable/DynamicTable.stories.tsx +0 -72
- package/src/components/DynamicTable/DynamicTableRow.tsx +0 -134
- package/src/components/DynamicTable/PayloadDynamicTableColumnConfig.ts +0 -98
- package/src/components/DynamicTable/Table.tsx +0 -194
- package/src/components/DynamicTable/index.ts +0 -3
- package/src/components/Table/FetchMoreTable.stories.tsx +0 -100
- package/src/components/Table/PayloadTableColumnConfig.ts +0 -22
- package/src/components/Table/Table.stories.tsx +0 -98
- package/src/components/Table/Table.tsx +0 -139
- package/src/components/Table/TableBody.tsx +0 -64
- package/src/components/Table/TableFooter.tsx +0 -44
- package/src/components/Table/TableHead.tsx +0 -31
- package/src/components/Table/TablePagination.tsx +0 -88
- package/src/components/Table/TableRow.tsx +0 -135
- package/src/components/Table/TableRowNoData.tsx +0 -39
- package/src/components/Table/index.ts +0 -7
- package/src/components/Table/lib/TableColumns.ts +0 -12
- package/src/components/Table/lib/index.ts +0 -1
- package/src/components/Table/types/PaginationEventNouns.ts +0 -1
- package/src/components/Table/types/PayloadTableBodyProps.ts +0 -21
- package/src/components/Table/types/PayloadTableFooterProps.ts +0 -13
- package/src/components/Table/types/PayloadTableHeadProps.ts +0 -7
- package/src/components/Table/types/index.ts +0 -4
- package/src/components/index.ts +0 -2
- package/src/components/lib/index.ts +0 -3
- package/src/global.d.ts +0 -1
- package/src/index.ts +0 -1
package/dist/browser/index.mjs
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/components/DynamicTable/DynamicTableRow.tsx
|
|
5
|
-
import {
|
|
6
|
-
|
|
2
|
+
import {
|
|
3
|
+
CheckCircleOutlineRounded as CheckCircleOutlineRoundedIcon,
|
|
4
|
+
ErrorOutlineRounded as ErrorOutlineRoundedIcon,
|
|
5
|
+
WarningAmberRounded as WarningAmberRoundedIcon
|
|
6
|
+
} from "@mui/icons-material";
|
|
7
|
+
import {
|
|
8
|
+
TableCell,
|
|
9
|
+
TableRow,
|
|
10
|
+
Typography
|
|
11
|
+
} from "@mui/material";
|
|
7
12
|
import { usePromise } from "@xylabs/react-promise";
|
|
8
13
|
import { useBreakpoint } from "@xylabs/react-shared";
|
|
9
14
|
import { PayloadBuilder } from "@xyo-network/payload-builder";
|
|
@@ -11,10 +16,10 @@ import { PayloadValidator } from "@xyo-network/payload-validator";
|
|
|
11
16
|
import { useNetwork } from "@xyo-network/react-network";
|
|
12
17
|
import { usePayloadRenderPluginResolver } from "@xyo-network/react-payload-plugin-resolver";
|
|
13
18
|
import { HashTableCell, usePayloadHash } from "@xyo-network/react-shared";
|
|
14
|
-
import
|
|
19
|
+
import { useMemo } from "react";
|
|
15
20
|
|
|
16
21
|
// src/components/DynamicTable/PayloadDynamicTableColumnConfig.ts
|
|
17
|
-
var payloadDynamicTableColumnConfigDefaults =
|
|
22
|
+
var payloadDynamicTableColumnConfigDefaults = () => {
|
|
18
23
|
const xs = [
|
|
19
24
|
{
|
|
20
25
|
alignment: "left",
|
|
@@ -158,80 +163,45 @@ var payloadDynamicTableColumnConfigDefaults = /* @__PURE__ */ __name(() => {
|
|
|
158
163
|
xl,
|
|
159
164
|
xs
|
|
160
165
|
};
|
|
161
|
-
}
|
|
166
|
+
};
|
|
162
167
|
|
|
163
168
|
// src/components/DynamicTable/DynamicTableRow.tsx
|
|
164
|
-
|
|
169
|
+
import { jsx } from "react/jsx-runtime";
|
|
170
|
+
var PayloadDynamicTableRow = ({
|
|
171
|
+
columns,
|
|
172
|
+
network: networkProp,
|
|
173
|
+
payload,
|
|
174
|
+
...props
|
|
175
|
+
}) => {
|
|
165
176
|
const breakPoint = useBreakpoint();
|
|
166
177
|
const payloadHash = usePayloadHash(payload);
|
|
167
178
|
const { network } = useNetwork();
|
|
168
179
|
const { resolver } = usePayloadRenderPluginResolver();
|
|
169
|
-
const [validationErrors = []] = usePromise(async () => payload ? await new PayloadValidator(payload).validate() : void 0, [
|
|
170
|
-
payload
|
|
171
|
-
]);
|
|
180
|
+
const [validationErrors = []] = usePromise(async () => payload ? await new PayloadValidator(payload).validate() : void 0, [payload]);
|
|
172
181
|
const isValid = validationErrors.length === 0;
|
|
173
182
|
const payloadFieldCount = payload ? Object.keys(PayloadBuilder.hashableFields(payload)).length : 0;
|
|
174
|
-
const hash =
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
value: payloadHash,
|
|
178
|
-
dataType: "payload",
|
|
179
|
-
network: networkProp ?? network?.slug,
|
|
180
|
-
...props2
|
|
181
|
-
}), "hash");
|
|
182
|
-
const schema = /* @__PURE__ */ __name((props2) => /* @__PURE__ */ React.createElement(TableCell, {
|
|
183
|
-
key: "payloads",
|
|
184
|
-
align: "left",
|
|
185
|
-
...props2
|
|
186
|
-
}, /* @__PURE__ */ React.createElement(Typography, {
|
|
187
|
-
fontFamily: "monospace",
|
|
188
|
-
variant: "body2",
|
|
189
|
-
noWrap: true
|
|
190
|
-
}, payload?.schema)), "schema");
|
|
191
|
-
const details = /* @__PURE__ */ __name((props2) => /* @__PURE__ */ React.createElement(TableCell, {
|
|
192
|
-
key: "payloads",
|
|
193
|
-
align: "left",
|
|
194
|
-
...props2
|
|
195
|
-
}, /* @__PURE__ */ React.createElement(Typography, {
|
|
196
|
-
fontFamily: "monospace",
|
|
197
|
-
variant: "body2",
|
|
198
|
-
noWrap: true
|
|
199
|
-
}, payloadFieldCount)), "details");
|
|
200
|
-
const render = /* @__PURE__ */ __name((props2) => {
|
|
201
|
-
const Render = payload ? resolver?.resolve(payload)?.components.table.cell : void 0;
|
|
202
|
-
return Render ? /* @__PURE__ */ React.createElement(Render, {
|
|
203
|
-
payload,
|
|
204
|
-
...props2
|
|
205
|
-
}) : /* @__PURE__ */ React.createElement(TableCell, {
|
|
206
|
-
key: "payloads",
|
|
183
|
+
const hash = (props2) => /* @__PURE__ */ jsx(
|
|
184
|
+
HashTableCell,
|
|
185
|
+
{
|
|
207
186
|
align: "left",
|
|
187
|
+
value: payloadHash,
|
|
188
|
+
dataType: "payload",
|
|
189
|
+
network: networkProp ?? network?.slug,
|
|
208
190
|
...props2
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
|
|
191
|
+
},
|
|
192
|
+
"hash"
|
|
193
|
+
);
|
|
194
|
+
const schema = (props2) => /* @__PURE__ */ jsx(TableCell, { align: "left", ...props2, children: /* @__PURE__ */ jsx(Typography, { fontFamily: "monospace", variant: "body2", noWrap: true, children: payload?.schema }) }, "payloads");
|
|
195
|
+
const details = (props2) => /* @__PURE__ */ jsx(TableCell, { align: "left", ...props2, children: /* @__PURE__ */ jsx(Typography, { fontFamily: "monospace", variant: "body2", noWrap: true, children: payloadFieldCount }) }, "payloads");
|
|
196
|
+
const render = (props2) => {
|
|
197
|
+
const Render = payload ? resolver?.resolve(payload)?.components.table.cell : void 0;
|
|
198
|
+
return Render ? /* @__PURE__ */ jsx(Render, { payload, ...props2 }) : /* @__PURE__ */ jsx(TableCell, { align: "left", ...props2 }, "payloads");
|
|
199
|
+
};
|
|
200
|
+
const icon = (props2) => {
|
|
212
201
|
const Avatar = payload ? resolver?.resolve(payload)?.components.avatar.image : void 0;
|
|
213
|
-
return /* @__PURE__ */
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
...props2
|
|
217
|
-
}, Avatar ? /* @__PURE__ */ React.createElement(Avatar, {
|
|
218
|
-
payload
|
|
219
|
-
}) : null);
|
|
220
|
-
}, "icon");
|
|
221
|
-
const valid = /* @__PURE__ */ __name((props2) => /* @__PURE__ */ React.createElement(TableCell, {
|
|
222
|
-
key: "valid",
|
|
223
|
-
align: "center",
|
|
224
|
-
...props2
|
|
225
|
-
}, isValid === void 0 && payload != void 0 ? /* @__PURE__ */ React.createElement(WarningAmberRoundedIcon, {
|
|
226
|
-
fontSize: "small",
|
|
227
|
-
color: "warning"
|
|
228
|
-
}) : isValid === true ? /* @__PURE__ */ React.createElement(CheckCircleOutlineRoundedIcon, {
|
|
229
|
-
fontSize: "small",
|
|
230
|
-
color: "success"
|
|
231
|
-
}) : isValid === false ? /* @__PURE__ */ React.createElement(ErrorOutlineRoundedIcon, {
|
|
232
|
-
color: "error",
|
|
233
|
-
fontSize: "small"
|
|
234
|
-
}) : /* @__PURE__ */ React.createElement(Typography, null, "\xA0")), "valid");
|
|
202
|
+
return /* @__PURE__ */ jsx(TableCell, { align: "left", ...props2, children: Avatar ? /* @__PURE__ */ jsx(Avatar, { payload }) : null }, "payloads");
|
|
203
|
+
};
|
|
204
|
+
const valid = (props2) => /* @__PURE__ */ jsx(TableCell, { align: "center", ...props2, children: isValid === void 0 && payload != void 0 ? /* @__PURE__ */ jsx(WarningAmberRoundedIcon, { fontSize: "small", color: "warning" }) : isValid === true ? /* @__PURE__ */ jsx(CheckCircleOutlineRoundedIcon, { fontSize: "small", color: "success" }) : isValid === false ? /* @__PURE__ */ jsx(ErrorOutlineRoundedIcon, { color: "error", fontSize: "small" }) : /* @__PURE__ */ jsx(Typography, { children: " \xA0" }) }, "valid");
|
|
235
205
|
const tableCells = {
|
|
236
206
|
details,
|
|
237
207
|
hash,
|
|
@@ -240,144 +210,142 @@ var PayloadDynamicTableRow = /* @__PURE__ */ __name(({ columns, network: network
|
|
|
240
210
|
schema,
|
|
241
211
|
valid
|
|
242
212
|
};
|
|
243
|
-
const columnsMemo = useMemo(() => columns ?? payloadDynamicTableColumnConfigDefaults(), [
|
|
244
|
-
|
|
245
|
-
]);
|
|
246
|
-
return breakPoint ? /* @__PURE__ */ React.createElement(TableRow, {
|
|
247
|
-
style: {
|
|
248
|
-
maxWidth: "100vw"
|
|
249
|
-
},
|
|
250
|
-
...props
|
|
251
|
-
}, columnsMemo[breakPoint]?.map((column) => {
|
|
213
|
+
const columnsMemo = useMemo(() => columns ?? payloadDynamicTableColumnConfigDefaults(), [columns]);
|
|
214
|
+
return breakPoint ? /* @__PURE__ */ jsx(TableRow, { style: { maxWidth: "100vw" }, ...props, children: columnsMemo[breakPoint]?.map((column) => {
|
|
252
215
|
return column.slug ? tableCells[column.slug]({}) : null;
|
|
253
|
-
})) : null;
|
|
254
|
-
}
|
|
216
|
+
}) }) : null;
|
|
217
|
+
};
|
|
255
218
|
|
|
256
219
|
// src/components/DynamicTable/Table.tsx
|
|
257
|
-
import {
|
|
258
|
-
|
|
220
|
+
import {
|
|
221
|
+
FirstPage as FirstPageIcon,
|
|
222
|
+
KeyboardArrowLeft,
|
|
223
|
+
KeyboardArrowRight,
|
|
224
|
+
LastPage as LastPageIcon
|
|
225
|
+
} from "@mui/icons-material";
|
|
226
|
+
import {
|
|
227
|
+
Alert,
|
|
228
|
+
Box,
|
|
229
|
+
IconButton,
|
|
230
|
+
Table,
|
|
231
|
+
TableBody,
|
|
232
|
+
TableCell as TableCell2,
|
|
233
|
+
TableFooter,
|
|
234
|
+
TableHead,
|
|
235
|
+
TablePagination,
|
|
236
|
+
TableRow as TableRow2,
|
|
237
|
+
Typography as Typography2,
|
|
238
|
+
useTheme
|
|
239
|
+
} from "@mui/material";
|
|
259
240
|
import { ThrownErrorBoundary } from "@xylabs/react-error";
|
|
260
241
|
import { useResetState } from "@xylabs/react-hooks";
|
|
261
242
|
import { useBreakpoint as useBreakpoint2 } from "@xylabs/react-shared";
|
|
262
243
|
import { usePayloadHashes } from "@xyo-network/react-shared";
|
|
263
|
-
import
|
|
264
|
-
|
|
244
|
+
import { useMemo as useMemo2, useState } from "react";
|
|
245
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
246
|
+
var TablePaginationActions = (props) => {
|
|
265
247
|
const theme = useTheme();
|
|
266
|
-
const {
|
|
267
|
-
|
|
248
|
+
const {
|
|
249
|
+
count,
|
|
250
|
+
page,
|
|
251
|
+
rowsPerPage,
|
|
252
|
+
onPageChange
|
|
253
|
+
} = props;
|
|
254
|
+
const handleFirstPageButtonClick = (event) => {
|
|
268
255
|
onPageChange(event, 0);
|
|
269
|
-
}
|
|
270
|
-
const handleBackButtonClick =
|
|
256
|
+
};
|
|
257
|
+
const handleBackButtonClick = (event) => {
|
|
271
258
|
onPageChange(event, page - 1);
|
|
272
|
-
}
|
|
273
|
-
const handleNextButtonClick =
|
|
259
|
+
};
|
|
260
|
+
const handleNextButtonClick = (event) => {
|
|
274
261
|
onPageChange(event, page + 1);
|
|
275
|
-
}
|
|
276
|
-
const handleLastPageButtonClick =
|
|
262
|
+
};
|
|
263
|
+
const handleLastPageButtonClick = (event) => {
|
|
277
264
|
onPageChange(event, Math.max(0, Math.ceil(count / rowsPerPage) - 1));
|
|
278
|
-
}
|
|
279
|
-
return /* @__PURE__ */
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}, theme.direction === "rtl" ? /* @__PURE__ */ React2.createElement(KeyboardArrowLeft, null) : /* @__PURE__ */ React2.createElement(KeyboardArrowRight, null)), /* @__PURE__ */ React2.createElement(IconButton, {
|
|
297
|
-
onClick: handleLastPageButtonClick,
|
|
298
|
-
disabled: page >= Math.ceil(count / rowsPerPage) - 1,
|
|
299
|
-
"aria-label": "last page"
|
|
300
|
-
}, theme.direction === "rtl" ? /* @__PURE__ */ React2.createElement(FirstPageIcon, null) : /* @__PURE__ */ React2.createElement(LastPageIcon, null)));
|
|
301
|
-
}, "TablePaginationActions");
|
|
302
|
-
var PayloadDynamicTable = /* @__PURE__ */ __name(({ archive, children, columns, exploreDomain, onRowClick, rowsPerPage: rowsPerPageProp = 10, payloads, ...props }) => {
|
|
265
|
+
};
|
|
266
|
+
return /* @__PURE__ */ jsxs(Box, { sx: { flexShrink: 0, ml: 2.5 }, children: [
|
|
267
|
+
/* @__PURE__ */ jsx2(IconButton, { onClick: handleFirstPageButtonClick, disabled: page === 0, "aria-label": "first page", children: theme.direction === "rtl" ? /* @__PURE__ */ jsx2(LastPageIcon, {}) : /* @__PURE__ */ jsx2(FirstPageIcon, {}) }),
|
|
268
|
+
/* @__PURE__ */ jsx2(IconButton, { onClick: handleBackButtonClick, disabled: page === 0, "aria-label": "previous page", children: theme.direction === "rtl" ? /* @__PURE__ */ jsx2(KeyboardArrowRight, {}) : /* @__PURE__ */ jsx2(KeyboardArrowLeft, {}) }),
|
|
269
|
+
/* @__PURE__ */ jsx2(IconButton, { onClick: handleNextButtonClick, disabled: page >= Math.ceil(count / rowsPerPage) - 1, "aria-label": "next page", children: theme.direction === "rtl" ? /* @__PURE__ */ jsx2(KeyboardArrowLeft, {}) : /* @__PURE__ */ jsx2(KeyboardArrowRight, {}) }),
|
|
270
|
+
/* @__PURE__ */ jsx2(IconButton, { onClick: handleLastPageButtonClick, disabled: page >= Math.ceil(count / rowsPerPage) - 1, "aria-label": "last page", children: theme.direction === "rtl" ? /* @__PURE__ */ jsx2(FirstPageIcon, {}) : /* @__PURE__ */ jsx2(LastPageIcon, {}) })
|
|
271
|
+
] });
|
|
272
|
+
};
|
|
273
|
+
var PayloadDynamicTable = ({
|
|
274
|
+
archive,
|
|
275
|
+
children,
|
|
276
|
+
columns,
|
|
277
|
+
exploreDomain,
|
|
278
|
+
onRowClick,
|
|
279
|
+
rowsPerPage: rowsPerPageProp = 10,
|
|
280
|
+
payloads,
|
|
281
|
+
...props
|
|
282
|
+
}) => {
|
|
303
283
|
const breakPoint = useBreakpoint2();
|
|
304
284
|
const [page, setPage] = useState(0);
|
|
305
285
|
const [rowsPerPage, setRowsPerPage] = useResetState(rowsPerPageProp);
|
|
306
286
|
const payloadCount = payloads ? payloads.length : 0;
|
|
307
287
|
const emptyRows = page > 0 ? Math.max(0, (1 + page) * rowsPerPage - payloadCount) : 0;
|
|
308
|
-
const pagedPayloads = useMemo2(() => payloads?.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage), [
|
|
309
|
-
payloads,
|
|
310
|
-
page,
|
|
311
|
-
rowsPerPage
|
|
312
|
-
]);
|
|
288
|
+
const pagedPayloads = useMemo2(() => payloads?.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage), [payloads, page, rowsPerPage]);
|
|
313
289
|
const payloadPairs = usePayloadHashes(pagedPayloads);
|
|
314
|
-
const handleChangePage =
|
|
290
|
+
const handleChangePage = (event, newPage) => {
|
|
315
291
|
setPage(newPage);
|
|
316
|
-
}
|
|
317
|
-
const handleChangeRowsPerPage =
|
|
292
|
+
};
|
|
293
|
+
const handleChangeRowsPerPage = (event) => {
|
|
318
294
|
setRowsPerPage(Number.parseInt(event.target.value, 10));
|
|
319
295
|
setPage(0);
|
|
320
|
-
}
|
|
321
|
-
return breakPoint ? /* @__PURE__ */
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
})
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
}).fill(/* @__PURE__ */ React2.createElement(PayloadDynamicTableRow, null)) : null), /* @__PURE__ */ React2.createElement(TableFooter, null, /* @__PURE__ */ React2.createElement(TableRow2, null, /* @__PURE__ */ React2.createElement(TablePagination, {
|
|
357
|
-
rowsPerPageOptions: [
|
|
358
|
-
5,
|
|
359
|
-
10,
|
|
360
|
-
25,
|
|
296
|
+
};
|
|
297
|
+
return breakPoint ? /* @__PURE__ */ jsxs(Table, { stickyHeader: true, ...props, children: [
|
|
298
|
+
/* @__PURE__ */ jsx2(TableHead, { children: /* @__PURE__ */ jsx2(TableRow2, { children: (columns ?? payloadDynamicTableColumnConfigDefaults())[breakPoint]?.map((column) => {
|
|
299
|
+
return /* @__PURE__ */ jsx2(TableCell2, { align: column.alignment ?? "left", width: column.width, children: /* @__PURE__ */ jsx2(Typography2, { variant: "body2", noWrap: true, children: column.name }) }, column.name);
|
|
300
|
+
}) }) }),
|
|
301
|
+
/* @__PURE__ */ jsxs(TableBody, { sx: { overflowY: "scroll " }, children: [
|
|
302
|
+
payloadPairs?.map(([payload, hash]) => {
|
|
303
|
+
return /* @__PURE__ */ jsx2(
|
|
304
|
+
ThrownErrorBoundary,
|
|
305
|
+
{
|
|
306
|
+
boundaryName: "PayloadTableBody",
|
|
307
|
+
errorComponent: (e) => /* @__PURE__ */ jsxs(Alert, { severity: "error", children: [
|
|
308
|
+
"Error Loading Payload:",
|
|
309
|
+
" ",
|
|
310
|
+
/* @__PURE__ */ jsx2(Typography2, { fontWeight: "bold", children: e.message })
|
|
311
|
+
] }),
|
|
312
|
+
children: /* @__PURE__ */ jsx2(
|
|
313
|
+
PayloadDynamicTableRow,
|
|
314
|
+
{
|
|
315
|
+
archive,
|
|
316
|
+
onClick: onRowClick ? () => {
|
|
317
|
+
onRowClick(payload);
|
|
318
|
+
} : void 0,
|
|
319
|
+
exploreDomain,
|
|
320
|
+
payload
|
|
321
|
+
}
|
|
322
|
+
)
|
|
323
|
+
},
|
|
324
|
+
hash
|
|
325
|
+
);
|
|
326
|
+
}),
|
|
327
|
+
children,
|
|
328
|
+
emptyRows ? Array.from({ length: emptyRows }).fill(/* @__PURE__ */ jsx2(PayloadDynamicTableRow, {})) : null
|
|
329
|
+
] }),
|
|
330
|
+
/* @__PURE__ */ jsx2(TableFooter, { children: /* @__PURE__ */ jsx2(TableRow2, { children: /* @__PURE__ */ jsx2(
|
|
331
|
+
TablePagination,
|
|
361
332
|
{
|
|
362
|
-
label: "All",
|
|
363
|
-
|
|
333
|
+
rowsPerPageOptions: [5, 10, 25, { label: "All", value: -1 }],
|
|
334
|
+
colSpan: 5,
|
|
335
|
+
count: payloadCount,
|
|
336
|
+
rowsPerPage,
|
|
337
|
+
page,
|
|
338
|
+
SelectProps: {
|
|
339
|
+
inputProps: { "aria-label": "rows per page" },
|
|
340
|
+
native: true
|
|
341
|
+
},
|
|
342
|
+
onPageChange: handleChangePage,
|
|
343
|
+
onRowsPerPageChange: handleChangeRowsPerPage,
|
|
344
|
+
ActionsComponent: TablePaginationActions
|
|
364
345
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
rowsPerPage,
|
|
369
|
-
page,
|
|
370
|
-
SelectProps: {
|
|
371
|
-
inputProps: {
|
|
372
|
-
"aria-label": "rows per page"
|
|
373
|
-
},
|
|
374
|
-
native: true
|
|
375
|
-
},
|
|
376
|
-
onPageChange: handleChangePage,
|
|
377
|
-
onRowsPerPageChange: handleChangeRowsPerPage,
|
|
378
|
-
ActionsComponent: TablePaginationActions
|
|
379
|
-
})))) : null;
|
|
380
|
-
}, "PayloadDynamicTable");
|
|
346
|
+
) }) })
|
|
347
|
+
] }) : null;
|
|
348
|
+
};
|
|
381
349
|
|
|
382
350
|
// src/components/Table/PayloadTableColumnConfig.ts
|
|
383
351
|
var payloadColumnNames = {
|
|
@@ -385,32 +353,12 @@ var payloadColumnNames = {
|
|
|
385
353
|
schema: "Schema",
|
|
386
354
|
valid: "Valid"
|
|
387
355
|
};
|
|
388
|
-
var payloadTableColumnConfigDefaults =
|
|
389
|
-
const xs = [
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
];
|
|
394
|
-
const sm = [
|
|
395
|
-
"hash",
|
|
396
|
-
"schema",
|
|
397
|
-
"valid"
|
|
398
|
-
];
|
|
399
|
-
const md = [
|
|
400
|
-
"hash",
|
|
401
|
-
"schema",
|
|
402
|
-
"valid"
|
|
403
|
-
];
|
|
404
|
-
const lg = [
|
|
405
|
-
"hash",
|
|
406
|
-
"schema",
|
|
407
|
-
"valid"
|
|
408
|
-
];
|
|
409
|
-
const xl = [
|
|
410
|
-
"hash",
|
|
411
|
-
"schema",
|
|
412
|
-
"valid"
|
|
413
|
-
];
|
|
356
|
+
var payloadTableColumnConfigDefaults = () => {
|
|
357
|
+
const xs = ["hash", "schema", "valid"];
|
|
358
|
+
const sm = ["hash", "schema", "valid"];
|
|
359
|
+
const md = ["hash", "schema", "valid"];
|
|
360
|
+
const lg = ["hash", "schema", "valid"];
|
|
361
|
+
const xl = ["hash", "schema", "valid"];
|
|
414
362
|
return {
|
|
415
363
|
lg,
|
|
416
364
|
md,
|
|
@@ -418,290 +366,318 @@ var payloadTableColumnConfigDefaults = /* @__PURE__ */ __name(() => {
|
|
|
418
366
|
xl,
|
|
419
367
|
xs
|
|
420
368
|
};
|
|
421
|
-
}
|
|
369
|
+
};
|
|
422
370
|
|
|
423
371
|
// src/components/Table/Table.tsx
|
|
424
372
|
import { isDefinedNotNull } from "@xylabs/sdk-js";
|
|
425
373
|
import { TableEx } from "@xyo-network/react-table";
|
|
426
|
-
import
|
|
374
|
+
import { useMemo as useMemo5, useState as useState2 } from "react";
|
|
427
375
|
|
|
428
376
|
// src/components/Table/TableBody.tsx
|
|
429
|
-
import {
|
|
377
|
+
import {
|
|
378
|
+
Alert as Alert2,
|
|
379
|
+
TableBody as TableBody2,
|
|
380
|
+
Typography as Typography4
|
|
381
|
+
} from "@mui/material";
|
|
430
382
|
import { ThrownErrorBoundary as ThrownErrorBoundary2 } from "@xylabs/react-error";
|
|
431
383
|
import { usePayloadHashes as usePayloadHashes2 } from "@xyo-network/react-shared";
|
|
432
|
-
import React4 from "react";
|
|
433
384
|
|
|
434
385
|
// src/components/Table/TableRow.tsx
|
|
435
|
-
import {
|
|
436
|
-
|
|
386
|
+
import {
|
|
387
|
+
CheckCircleOutlineRounded as CheckCircleOutlineRoundedIcon2,
|
|
388
|
+
ErrorOutlineRounded as ErrorOutlineRoundedIcon2,
|
|
389
|
+
WarningAmberRounded as WarningAmberRoundedIcon2
|
|
390
|
+
} from "@mui/icons-material";
|
|
391
|
+
import {
|
|
392
|
+
alpha,
|
|
393
|
+
Link,
|
|
394
|
+
TableCell as TableCell3,
|
|
395
|
+
TableRow as TableRow3,
|
|
396
|
+
Typography as Typography3
|
|
397
|
+
} from "@mui/material";
|
|
437
398
|
import { usePromise as usePromise2 } from "@xylabs/react-promise";
|
|
438
399
|
import { useBreakpoint as useBreakpoint3 } from "@xylabs/react-shared";
|
|
439
400
|
import { isDefined } from "@xylabs/sdk-js";
|
|
440
401
|
import { PayloadValidator as PayloadValidator2 } from "@xyo-network/payload-validator";
|
|
441
402
|
import { useEvent } from "@xyo-network/react-event";
|
|
442
403
|
import { HashTableCell as HashTableCell2, usePayloadHash as usePayloadHash2 } from "@xyo-network/react-shared";
|
|
443
|
-
import
|
|
444
|
-
|
|
404
|
+
import { useMemo as useMemo3 } from "react";
|
|
405
|
+
import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
406
|
+
var PayloadTableRow = ({
|
|
407
|
+
clickableFields,
|
|
408
|
+
columns,
|
|
409
|
+
maxSchemaDepth,
|
|
410
|
+
network: networkProp,
|
|
411
|
+
onHashClick,
|
|
412
|
+
payload,
|
|
413
|
+
...props
|
|
414
|
+
}) => {
|
|
445
415
|
const breakPoint = useBreakpoint3();
|
|
446
416
|
const payloadHash = usePayloadHash2(payload);
|
|
447
417
|
const [anchorRef, dispatch] = useEvent();
|
|
448
|
-
const [errors = []] = usePromise2(async () => payload ? await new PayloadValidator2(payload).validate() : void 0, [
|
|
449
|
-
payload
|
|
450
|
-
]);
|
|
418
|
+
const [errors = []] = usePromise2(async () => payload ? await new PayloadValidator2(payload).validate() : void 0, [payload]);
|
|
451
419
|
const isValid = errors.length === 0;
|
|
452
|
-
const hash =
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}, payloadHash) : payloadHash)), "hash");
|
|
466
|
-
const reduceSchemaDepth = /* @__PURE__ */ __name((schema2, maxSchemaDepth2) => {
|
|
420
|
+
const hash = (props2) => /* @__PURE__ */ jsx3(
|
|
421
|
+
HashTableCell2,
|
|
422
|
+
{
|
|
423
|
+
dataType: "payload",
|
|
424
|
+
onHashClick,
|
|
425
|
+
value: payloadHash,
|
|
426
|
+
width: "100%",
|
|
427
|
+
...props2,
|
|
428
|
+
children: isDefined(payloadHash) && /* @__PURE__ */ jsx3(Fragment, { children: clickableFields?.includes("hash") ? /* @__PURE__ */ jsx3(Link, { onClick: () => dispatch("hash", "click", payloadHash), ref: anchorRef, sx: { cursor: "pointer" }, children: payloadHash }) : payloadHash })
|
|
429
|
+
},
|
|
430
|
+
"hash"
|
|
431
|
+
);
|
|
432
|
+
const reduceSchemaDepth = (schema2, maxSchemaDepth2) => {
|
|
467
433
|
if (isDefined(maxSchemaDepth2)) {
|
|
468
434
|
const parts = schema2?.split(".") ?? [];
|
|
469
435
|
const partsToRemove = Math.max(parts.length - maxSchemaDepth2, 0);
|
|
470
436
|
if (partsToRemove > 0) {
|
|
471
|
-
return /* @__PURE__ */
|
|
437
|
+
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
438
|
+
/* @__PURE__ */ jsx3(Fragment, { children: "\u2026" }),
|
|
439
|
+
`${parts.slice(partsToRemove).reduce((previousValue, part) => previousValue + "." + part, "")}`
|
|
440
|
+
] });
|
|
472
441
|
}
|
|
473
442
|
}
|
|
474
443
|
return schema2;
|
|
475
|
-
}
|
|
476
|
-
const schema = /* @__PURE__ */
|
|
477
|
-
|
|
478
|
-
key: "payloads",
|
|
479
|
-
align: "center",
|
|
480
|
-
...props2
|
|
481
|
-
}, /* @__PURE__ */ React3.createElement(Typography3, {
|
|
482
|
-
fontFamily: "monospace",
|
|
483
|
-
variant: "body2",
|
|
484
|
-
noWrap: true
|
|
485
|
-
}, clickableFields?.includes("schema") ? /* @__PURE__ */ React3.createElement(Link, {
|
|
486
|
-
sx: {
|
|
487
|
-
cursor: "pointer"
|
|
488
|
-
}
|
|
489
|
-
}, reduceSchemaDepth(payload?.schema, maxSchemaDepth)) : reduceSchemaDepth(payload?.schema, maxSchemaDepth))), "schema");
|
|
490
|
-
const valid = /* @__PURE__ */ __name((props2) => /* @__PURE__ */ React3.createElement(TableCell3, {
|
|
491
|
-
key: "valid",
|
|
492
|
-
align: "center",
|
|
493
|
-
...props2
|
|
494
|
-
}, isValid === void 0 && payload != void 0 ? /* @__PURE__ */ React3.createElement(WarningAmberRoundedIcon2, {
|
|
495
|
-
fontSize: "small",
|
|
496
|
-
color: "warning"
|
|
497
|
-
}) : isValid === true ? /* @__PURE__ */ React3.createElement(CheckCircleOutlineRoundedIcon2, {
|
|
498
|
-
fontSize: "small",
|
|
499
|
-
color: "success"
|
|
500
|
-
}) : isValid === false ? /* @__PURE__ */ React3.createElement(ErrorOutlineRoundedIcon2, {
|
|
501
|
-
color: "error",
|
|
502
|
-
fontSize: "small"
|
|
503
|
-
}) : /* @__PURE__ */ React3.createElement(ErrorOutlineRoundedIcon2, {
|
|
504
|
-
sx: {
|
|
505
|
-
color: alpha("#fff", 0)
|
|
506
|
-
},
|
|
507
|
-
fontSize: "small"
|
|
508
|
-
})), "valid");
|
|
444
|
+
};
|
|
445
|
+
const schema = (props2) => /* @__PURE__ */ jsx3(TableCell3, { title: payload?.schema, align: "center", ...props2, children: /* @__PURE__ */ jsx3(Typography3, { fontFamily: "monospace", variant: "body2", noWrap: true, children: clickableFields?.includes("schema") ? /* @__PURE__ */ jsx3(Link, { sx: { cursor: "pointer" }, children: reduceSchemaDepth(payload?.schema, maxSchemaDepth) }) : reduceSchemaDepth(payload?.schema, maxSchemaDepth) }) }, "payloads");
|
|
446
|
+
const valid = (props2) => /* @__PURE__ */ jsx3(TableCell3, { align: "center", ...props2, children: isValid === void 0 && payload != void 0 ? /* @__PURE__ */ jsx3(WarningAmberRoundedIcon2, { fontSize: "small", color: "warning" }) : isValid === true ? /* @__PURE__ */ jsx3(CheckCircleOutlineRoundedIcon2, { fontSize: "small", color: "success" }) : isValid === false ? /* @__PURE__ */ jsx3(ErrorOutlineRoundedIcon2, { color: "error", fontSize: "small" }) : /* @__PURE__ */ jsx3(ErrorOutlineRoundedIcon2, { sx: { color: alpha("#fff", 0) }, fontSize: "small" }) }, "valid");
|
|
509
447
|
const tableCells = {
|
|
510
448
|
hash,
|
|
511
449
|
schema,
|
|
512
450
|
valid
|
|
513
451
|
};
|
|
514
|
-
const columnsMemo = useMemo3(() => columns ?? payloadTableColumnConfigDefaults(), [
|
|
515
|
-
|
|
516
|
-
]);
|
|
517
|
-
return isDefined(breakPoint) ? /* @__PURE__ */ React3.createElement(TableRow3, {
|
|
518
|
-
style: {
|
|
519
|
-
maxWidth: "100vw"
|
|
520
|
-
},
|
|
521
|
-
...props
|
|
522
|
-
}, columnsMemo[breakPoint]?.map((column) => {
|
|
452
|
+
const columnsMemo = useMemo3(() => columns ?? payloadTableColumnConfigDefaults(), [columns]);
|
|
453
|
+
return isDefined(breakPoint) ? /* @__PURE__ */ jsx3(TableRow3, { style: { maxWidth: "100vw" }, ...props, children: columnsMemo[breakPoint]?.map((column) => {
|
|
523
454
|
return tableCells[column]({});
|
|
524
|
-
})) : null;
|
|
525
|
-
}
|
|
455
|
+
}) }) : null;
|
|
456
|
+
};
|
|
526
457
|
|
|
527
458
|
// src/components/Table/TableBody.tsx
|
|
528
|
-
|
|
459
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
460
|
+
var PayloadTableBody = ({
|
|
461
|
+
children,
|
|
462
|
+
clickableFields,
|
|
463
|
+
payloads,
|
|
464
|
+
maxSchemaDepth,
|
|
465
|
+
onHashClick,
|
|
466
|
+
onRowClick,
|
|
467
|
+
emptyRows,
|
|
468
|
+
noResults,
|
|
469
|
+
NoResultRowComponent,
|
|
470
|
+
...props
|
|
471
|
+
}) => {
|
|
529
472
|
const payloadPairs = usePayloadHashes2(payloads);
|
|
530
|
-
return /* @__PURE__ */
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
473
|
+
return /* @__PURE__ */ jsxs3(TableBody2, { ...props, children: [
|
|
474
|
+
noResults && NoResultRowComponent ? /* @__PURE__ */ jsx4(NoResultRowComponent, {}) : null,
|
|
475
|
+
payloadPairs?.map(([payload, hash]) => {
|
|
476
|
+
return /* @__PURE__ */ jsx4(
|
|
477
|
+
ThrownErrorBoundary2,
|
|
478
|
+
{
|
|
479
|
+
boundaryName: "PayloadTableBody",
|
|
480
|
+
errorComponent: (e) => /* @__PURE__ */ jsxs3(Alert2, { severity: "error", children: [
|
|
481
|
+
"Error Loading Payload:",
|
|
482
|
+
" ",
|
|
483
|
+
/* @__PURE__ */ jsx4(Typography4, { fontWeight: "bold", children: e.message })
|
|
484
|
+
] }),
|
|
485
|
+
children: /* @__PURE__ */ jsx4(
|
|
486
|
+
PayloadTableRow,
|
|
487
|
+
{
|
|
488
|
+
clickableFields,
|
|
489
|
+
maxSchemaDepth,
|
|
490
|
+
onClick: onRowClick ? () => {
|
|
491
|
+
onRowClick(payload);
|
|
492
|
+
} : void 0,
|
|
493
|
+
onHashClick,
|
|
494
|
+
payload
|
|
495
|
+
}
|
|
496
|
+
)
|
|
497
|
+
},
|
|
498
|
+
hash
|
|
499
|
+
);
|
|
500
|
+
}),
|
|
501
|
+
children,
|
|
502
|
+
emptyRows ? Array.from({ length: emptyRows }).fill(/* @__PURE__ */ jsx4(PayloadTableRow, {})) : null
|
|
503
|
+
] });
|
|
504
|
+
};
|
|
552
505
|
|
|
553
506
|
// src/components/Table/TableFooter.tsx
|
|
554
|
-
import {
|
|
507
|
+
import {
|
|
508
|
+
styled,
|
|
509
|
+
TablePagination as TablePagination2,
|
|
510
|
+
TableRow as TableRow4
|
|
511
|
+
} from "@mui/material";
|
|
555
512
|
import { TableFooterEx } from "@xyo-network/react-table";
|
|
556
|
-
import React6 from "react";
|
|
557
513
|
|
|
558
514
|
// src/components/Table/TablePagination.tsx
|
|
559
|
-
import {
|
|
560
|
-
|
|
515
|
+
import {
|
|
516
|
+
FirstPage as FirstPageIcon2,
|
|
517
|
+
KeyboardArrowLeft as KeyboardArrowLeft2,
|
|
518
|
+
KeyboardArrowRight as KeyboardArrowRight2,
|
|
519
|
+
LastPage as LastPageIcon2
|
|
520
|
+
} from "@mui/icons-material";
|
|
521
|
+
import {
|
|
522
|
+
Box as Box2,
|
|
523
|
+
CircularProgress,
|
|
524
|
+
IconButton as IconButton2,
|
|
525
|
+
useTheme as useTheme2
|
|
526
|
+
} from "@mui/material";
|
|
561
527
|
import { useEvent as useEvent2 } from "@xyo-network/react-event";
|
|
562
|
-
import
|
|
563
|
-
function TablePaginationActions2({
|
|
528
|
+
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
529
|
+
function TablePaginationActions2({
|
|
530
|
+
count,
|
|
531
|
+
enableNextPage,
|
|
532
|
+
loading,
|
|
533
|
+
onPageChange,
|
|
534
|
+
page,
|
|
535
|
+
rowsPerPage
|
|
536
|
+
}) {
|
|
564
537
|
const theme = useTheme2();
|
|
565
538
|
const [paginationRef, paginationDispatch] = useEvent2();
|
|
566
|
-
const handleFirstPageButtonClick =
|
|
539
|
+
const handleFirstPageButtonClick = (event) => {
|
|
567
540
|
paginationDispatch("firstPage", "click", "true");
|
|
568
541
|
onPageChange(event, 0);
|
|
569
|
-
}
|
|
570
|
-
const handleBackButtonClick =
|
|
542
|
+
};
|
|
543
|
+
const handleBackButtonClick = (event) => {
|
|
571
544
|
paginationDispatch("previousPage", "click", (page - 1)?.toString());
|
|
572
545
|
onPageChange(event, page - 1);
|
|
573
|
-
}
|
|
574
|
-
const handleNextButtonClick =
|
|
546
|
+
};
|
|
547
|
+
const handleNextButtonClick = (event) => {
|
|
575
548
|
paginationDispatch("nextPage", "click", (page + 1)?.toString());
|
|
576
549
|
onPageChange(event, page + 1);
|
|
577
|
-
}
|
|
578
|
-
const handleLastPageButtonClick =
|
|
550
|
+
};
|
|
551
|
+
const handleLastPageButtonClick = (event) => {
|
|
579
552
|
paginationDispatch("lastPage", "click", "true");
|
|
580
553
|
onPageChange(event, Math.max(0, Math.ceil(count / rowsPerPage) - 1));
|
|
581
|
-
}
|
|
582
|
-
return /* @__PURE__ */
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
disabled: page >= Math.ceil(count / rowsPerPage) - 1,
|
|
611
|
-
"aria-label": "last page"
|
|
612
|
-
}, theme.direction === "rtl" ? /* @__PURE__ */ React5.createElement(FirstPageIcon2, null) : /* @__PURE__ */ React5.createElement(LastPageIcon2, null))));
|
|
554
|
+
};
|
|
555
|
+
return /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
556
|
+
loading ? /* @__PURE__ */ jsx5(
|
|
557
|
+
CircularProgress,
|
|
558
|
+
{
|
|
559
|
+
size: "small",
|
|
560
|
+
sx: {
|
|
561
|
+
height: theme.spacing(2),
|
|
562
|
+
position: "absolute",
|
|
563
|
+
width: theme.spacing(2)
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
) : null,
|
|
567
|
+
/* @__PURE__ */ jsxs4(Box2, { sx: { flexShrink: 0, ml: 2.5 }, children: [
|
|
568
|
+
/* @__PURE__ */ jsx5(IconButton2, { onClick: handleFirstPageButtonClick, disabled: page === 0, "aria-label": "first page", children: theme.direction === "rtl" ? /* @__PURE__ */ jsx5(LastPageIcon2, {}) : /* @__PURE__ */ jsx5(FirstPageIcon2, {}) }),
|
|
569
|
+
/* @__PURE__ */ jsx5(IconButton2, { ref: paginationRef, onClick: handleBackButtonClick, disabled: page === 0, "aria-label": "previous page", children: theme.direction === "rtl" ? /* @__PURE__ */ jsx5(KeyboardArrowRight2, {}) : /* @__PURE__ */ jsx5(KeyboardArrowLeft2, {}) }),
|
|
570
|
+
/* @__PURE__ */ jsx5(
|
|
571
|
+
IconButton2,
|
|
572
|
+
{
|
|
573
|
+
ref: paginationRef,
|
|
574
|
+
onClick: handleNextButtonClick,
|
|
575
|
+
disabled: !enableNextPage && page >= Math.ceil(count / rowsPerPage) - 1,
|
|
576
|
+
"aria-label": "next page",
|
|
577
|
+
children: theme.direction === "rtl" ? /* @__PURE__ */ jsx5(KeyboardArrowLeft2, {}) : /* @__PURE__ */ jsx5(KeyboardArrowRight2, {})
|
|
578
|
+
}
|
|
579
|
+
),
|
|
580
|
+
/* @__PURE__ */ jsx5(IconButton2, { onClick: handleLastPageButtonClick, disabled: page >= Math.ceil(count / rowsPerPage) - 1, "aria-label": "last page", children: theme.direction === "rtl" ? /* @__PURE__ */ jsx5(FirstPageIcon2, {}) : /* @__PURE__ */ jsx5(LastPageIcon2, {}) })
|
|
581
|
+
] })
|
|
582
|
+
] });
|
|
613
583
|
}
|
|
614
|
-
__name(TablePaginationActions2, "TablePaginationActions");
|
|
615
584
|
|
|
616
585
|
// src/components/Table/TableFooter.tsx
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
586
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
587
|
+
var PayloadTableFooter = ({
|
|
588
|
+
count,
|
|
589
|
+
variant,
|
|
590
|
+
page,
|
|
591
|
+
rowsPerPage,
|
|
592
|
+
handleChangePage,
|
|
593
|
+
handleChangeRowsPerPage,
|
|
594
|
+
fetchMorePayloads,
|
|
595
|
+
loading
|
|
596
|
+
}) => /* @__PURE__ */ jsx6(TableFooterEx, { variant, children: /* @__PURE__ */ jsx6(TableRow4, { children: /* @__PURE__ */ jsx6(
|
|
597
|
+
StyledTablePagination,
|
|
598
|
+
{
|
|
599
|
+
rowsPerPageOptions: [5, 10, 25, { label: "All", value: -1 }],
|
|
600
|
+
count: count ?? 0,
|
|
601
|
+
rowsPerPage: rowsPerPage ?? 10,
|
|
602
|
+
page: page ?? 0,
|
|
603
|
+
SelectProps: {
|
|
604
|
+
inputProps: { "aria-label": "rows per page" },
|
|
605
|
+
native: true
|
|
635
606
|
},
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
ActionsComponent: /* @__PURE__ */ __name((props) => /* @__PURE__ */ React6.createElement(TablePaginationActions2, {
|
|
644
|
-
enableNextPage: !!fetchMorePayloads,
|
|
645
|
-
loading,
|
|
646
|
-
...props
|
|
647
|
-
}), "ActionsComponent")
|
|
648
|
-
}))), "PayloadTableFooter");
|
|
607
|
+
onPageChange: handleChangePage ?? (() => {
|
|
608
|
+
}),
|
|
609
|
+
onRowsPerPageChange: handleChangeRowsPerPage ?? (() => {
|
|
610
|
+
}),
|
|
611
|
+
ActionsComponent: (props) => /* @__PURE__ */ jsx6(TablePaginationActions2, { enableNextPage: !!fetchMorePayloads, loading, ...props })
|
|
612
|
+
}
|
|
613
|
+
) }) });
|
|
649
614
|
var StyledTablePagination = styled(TablePagination2)(({ theme }) => ({
|
|
650
|
-
"& > .MuiToolbar-root": {
|
|
651
|
-
paddingLeft: theme.spacing(1)
|
|
652
|
-
},
|
|
615
|
+
"& > .MuiToolbar-root": { paddingLeft: theme.spacing(1) },
|
|
653
616
|
"borderTop": "1px solid",
|
|
654
617
|
"borderTopColor": theme.vars.palette.divider
|
|
655
618
|
}));
|
|
656
619
|
|
|
657
620
|
// src/components/Table/TableHead.tsx
|
|
658
|
-
import {
|
|
621
|
+
import {
|
|
622
|
+
TableCell as TableCell4,
|
|
623
|
+
TableHead as TableHead2,
|
|
624
|
+
TableRow as TableRow5,
|
|
625
|
+
Typography as Typography5
|
|
626
|
+
} from "@mui/material";
|
|
659
627
|
import { useBreakpoint as useBreakpoint4 } from "@xylabs/react-shared";
|
|
660
|
-
import
|
|
661
|
-
|
|
628
|
+
import { useMemo as useMemo4 } from "react";
|
|
629
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
630
|
+
var PayloadTableHead = ({ columns, ...props }) => {
|
|
662
631
|
const breakPoint = useBreakpoint4();
|
|
663
|
-
const columnsMemo = useMemo4(() => columns ?? payloadTableColumnConfigDefaults(), [
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
key: index,
|
|
669
|
-
width: index === 0 ? "100%" : void 0,
|
|
670
|
-
align: index === 0 ? "left" : "center"
|
|
671
|
-
}, /* @__PURE__ */ React7.createElement(Typography5, {
|
|
672
|
-
variant: "body2",
|
|
673
|
-
noWrap: true
|
|
674
|
-
}, payloadColumnNames[column]));
|
|
675
|
-
}) : null));
|
|
676
|
-
}, "PayloadTableHead");
|
|
632
|
+
const columnsMemo = useMemo4(() => columns ?? payloadTableColumnConfigDefaults(), [columns]);
|
|
633
|
+
return /* @__PURE__ */ jsx7(TableHead2, { ...props, children: /* @__PURE__ */ jsx7(TableRow5, { children: breakPoint ? columnsMemo[breakPoint]?.map((column, index) => {
|
|
634
|
+
return /* @__PURE__ */ jsx7(TableCell4, { width: index === 0 ? "100%" : void 0, align: index === 0 ? "left" : "center", children: /* @__PURE__ */ jsx7(Typography5, { variant: "body2", noWrap: true, children: payloadColumnNames[column] }) }, column);
|
|
635
|
+
}) : null }) });
|
|
636
|
+
};
|
|
677
637
|
|
|
678
638
|
// src/components/Table/TableRowNoData.tsx
|
|
679
|
-
import {
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
639
|
+
import {
|
|
640
|
+
styled as styled2,
|
|
641
|
+
TableCell as TableCell5,
|
|
642
|
+
TableRow as TableRow6,
|
|
643
|
+
Typography as Typography6
|
|
644
|
+
} from "@mui/material";
|
|
645
|
+
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
646
|
+
var TableRowNoData = ({
|
|
647
|
+
additionalCells,
|
|
648
|
+
hideBorder = false,
|
|
649
|
+
typographyProps,
|
|
650
|
+
...props
|
|
651
|
+
}) => {
|
|
652
|
+
return /* @__PURE__ */ jsxs5(TableRow6, { ...props, children: [
|
|
653
|
+
/* @__PURE__ */ jsx8(StyledTableCell, { hideBorder, children: /* @__PURE__ */ jsx8(Typography6, { variant: "body2", ...typographyProps, children: "No Data To Display..." }) }),
|
|
654
|
+
additionalCells ? Array.from({ length: additionalCells }).fill(null).map((_fill, index) => /* @__PURE__ */ jsx8(StyledTableCell, { hideBorder }, `empty-row-${index}`)) : null
|
|
655
|
+
] });
|
|
656
|
+
};
|
|
694
657
|
var StyledTableCell = styled2(TableCell5, {
|
|
695
658
|
name: "StyledTableCell",
|
|
696
|
-
shouldForwardProp:
|
|
697
|
-
})(({ hideBorder }) => ({
|
|
698
|
-
...hideBorder && {
|
|
699
|
-
border: "none"
|
|
700
|
-
}
|
|
701
|
-
}));
|
|
659
|
+
shouldForwardProp: (prop) => prop !== "hideBorder"
|
|
660
|
+
})(({ hideBorder }) => ({ ...hideBorder && { border: "none" } }));
|
|
702
661
|
|
|
703
662
|
// src/components/Table/Table.tsx
|
|
704
|
-
|
|
663
|
+
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
664
|
+
var PayloadTableWithRef = ({
|
|
665
|
+
clickableFields,
|
|
666
|
+
onHashClick,
|
|
667
|
+
onRowClick,
|
|
668
|
+
fetchMorePayloads,
|
|
669
|
+
rowsPerPage: rowsPerPageProp = 25,
|
|
670
|
+
payloads,
|
|
671
|
+
columns,
|
|
672
|
+
PayloadTableHeadComponent = PayloadTableHead,
|
|
673
|
+
PayloadTableBodyComponent = PayloadTableBody,
|
|
674
|
+
PayloadTableFooterComponent = PayloadTableFooter,
|
|
675
|
+
maxSchemaDepth,
|
|
676
|
+
count = 0,
|
|
677
|
+
loading = false,
|
|
678
|
+
variant = "scrollable",
|
|
679
|
+
...props
|
|
680
|
+
}) => {
|
|
705
681
|
const [page, setPage] = useState2(0);
|
|
706
682
|
const [rowsPerPage, setRowsPerPage] = useState2(rowsPerPageProp);
|
|
707
683
|
const [previousRowsPerPage, setPreviousRowsPerPage] = useState2(rowsPerPageProp);
|
|
@@ -719,7 +695,7 @@ var PayloadTableWithRef = /* @__PURE__ */ __name(({ clickableFields, onHashClick
|
|
|
719
695
|
setVisiblePayloads(payloads.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage));
|
|
720
696
|
}
|
|
721
697
|
}
|
|
722
|
-
const handleAdditionalPayloads =
|
|
698
|
+
const handleAdditionalPayloads = () => {
|
|
723
699
|
if (fetchMorePayloads && payloads) {
|
|
724
700
|
const buffer = rowsPerPage * 2;
|
|
725
701
|
const lastVisiblePayload = visiblePayloads?.at(-1);
|
|
@@ -730,46 +706,48 @@ var PayloadTableWithRef = /* @__PURE__ */ __name(({ clickableFields, onHashClick
|
|
|
730
706
|
}
|
|
731
707
|
}
|
|
732
708
|
}
|
|
733
|
-
}
|
|
734
|
-
const handleChangePage =
|
|
709
|
+
};
|
|
710
|
+
const handleChangePage = (_event, newPage) => {
|
|
735
711
|
handleAdditionalPayloads();
|
|
736
712
|
setPage(newPage);
|
|
737
|
-
}
|
|
738
|
-
const handleChangeRowsPerPage =
|
|
713
|
+
};
|
|
714
|
+
const handleChangeRowsPerPage = (event) => {
|
|
739
715
|
setRowsPerPage(Number.parseInt(event.target.value, 10));
|
|
740
716
|
setPage(0);
|
|
741
|
-
}
|
|
717
|
+
};
|
|
742
718
|
const noResults = useMemo5(() => {
|
|
743
719
|
return !loading && visiblePayloads.length === 0;
|
|
744
|
-
}, [
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
720
|
+
}, [loading, visiblePayloads]);
|
|
721
|
+
return /* @__PURE__ */ jsxs6(TableEx, { variant, ...props, children: [
|
|
722
|
+
/* @__PURE__ */ jsx9(PayloadTableHeadComponent, { columns }),
|
|
723
|
+
/* @__PURE__ */ jsx9(
|
|
724
|
+
PayloadTableBodyComponent,
|
|
725
|
+
{
|
|
726
|
+
clickableFields,
|
|
727
|
+
payloads: visiblePayloads,
|
|
728
|
+
maxSchemaDepth,
|
|
729
|
+
onRowClick,
|
|
730
|
+
onHashClick,
|
|
731
|
+
emptyRows,
|
|
732
|
+
noResults,
|
|
733
|
+
NoResultRowComponent: TableRowNoData
|
|
734
|
+
}
|
|
735
|
+
),
|
|
736
|
+
/* @__PURE__ */ jsx9(
|
|
737
|
+
PayloadTableFooterComponent,
|
|
738
|
+
{
|
|
739
|
+
count,
|
|
740
|
+
variant,
|
|
741
|
+
rowsPerPage,
|
|
742
|
+
handleChangePage,
|
|
743
|
+
handleChangeRowsPerPage,
|
|
744
|
+
fetchMorePayloads,
|
|
745
|
+
loading,
|
|
746
|
+
page
|
|
747
|
+
}
|
|
748
|
+
)
|
|
749
|
+
] });
|
|
750
|
+
};
|
|
773
751
|
PayloadTableWithRef.displayName = "PayloadTable";
|
|
774
752
|
var PayloadTable = PayloadTableWithRef;
|
|
775
753
|
export {
|