@xyo-network/react-payload-table 6.2.0 → 7.0.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/browser/components/DynamicTable/DynamicTable.stories.d.ts +3 -3
- package/dist/browser/components/DynamicTable/DynamicTable.stories.d.ts.map +1 -1
- package/dist/browser/components/Table/FetchMoreTable.stories.d.ts +1 -1
- package/dist/browser/components/Table/FetchMoreTable.stories.d.ts.map +1 -1
- package/dist/browser/components/Table/Table.stories.d.ts +7 -7
- package/dist/browser/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/browser/index.mjs +441 -472
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +42 -35
- package/typedoc.json +0 -5
- package/xy.config.ts +0 -10
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, index) => {
|
|
299
|
+
return /* @__PURE__ */ jsx2(TableCell2, { align: column.alignment ?? "left", width: column.width, children: /* @__PURE__ */ jsx2(Typography2, { variant: "body2", noWrap: true, children: column.name }) }, index);
|
|
300
|
+
}) }) }),
|
|
301
|
+
/* @__PURE__ */ jsxs(TableBody, { sx: { overflowY: "scroll " }, children: [
|
|
302
|
+
payloadPairs?.map(([payload, hash], index) => {
|
|
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}-${index}`
|
|
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,314 +366,333 @@ 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 { TableEx } from "@xyo-network/react-table";
|
|
425
|
-
import
|
|
373
|
+
import { useMemo as useMemo5, useState as useState2 } from "react";
|
|
426
374
|
|
|
427
375
|
// src/components/Table/TableBody.tsx
|
|
428
|
-
import {
|
|
376
|
+
import {
|
|
377
|
+
Alert as Alert2,
|
|
378
|
+
TableBody as TableBody2,
|
|
379
|
+
Typography as Typography4
|
|
380
|
+
} from "@mui/material";
|
|
429
381
|
import { ThrownErrorBoundary as ThrownErrorBoundary2 } from "@xylabs/react-error";
|
|
430
382
|
import { usePayloadHashes as usePayloadHashes2 } from "@xyo-network/react-shared";
|
|
431
|
-
import React4 from "react";
|
|
432
383
|
|
|
433
384
|
// src/components/Table/TableRow.tsx
|
|
434
|
-
import {
|
|
435
|
-
|
|
385
|
+
import {
|
|
386
|
+
CheckCircleOutlineRounded as CheckCircleOutlineRoundedIcon2,
|
|
387
|
+
ErrorOutlineRounded as ErrorOutlineRoundedIcon2,
|
|
388
|
+
WarningAmberRounded as WarningAmberRoundedIcon2
|
|
389
|
+
} from "@mui/icons-material";
|
|
390
|
+
import {
|
|
391
|
+
alpha,
|
|
392
|
+
Link,
|
|
393
|
+
TableCell as TableCell3,
|
|
394
|
+
TableRow as TableRow3,
|
|
395
|
+
Typography as Typography3
|
|
396
|
+
} from "@mui/material";
|
|
436
397
|
import { usePromise as usePromise2 } from "@xylabs/react-promise";
|
|
437
398
|
import { useBreakpoint as useBreakpoint3 } from "@xylabs/react-shared";
|
|
438
399
|
import { isDefined } from "@xylabs/typeof";
|
|
439
400
|
import { PayloadValidator as PayloadValidator2 } from "@xyo-network/payload-validator";
|
|
440
401
|
import { useEvent } from "@xyo-network/react-event";
|
|
441
402
|
import { HashTableCell as HashTableCell2, usePayloadHash as usePayloadHash2 } from "@xyo-network/react-shared";
|
|
442
|
-
import
|
|
443
|
-
|
|
403
|
+
import { useMemo as useMemo3 } from "react";
|
|
404
|
+
import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
405
|
+
var PayloadTableRow = ({
|
|
406
|
+
clickableFields,
|
|
407
|
+
columns,
|
|
408
|
+
maxSchemaDepth,
|
|
409
|
+
network: networkProp,
|
|
410
|
+
onHashClick,
|
|
411
|
+
payload,
|
|
412
|
+
...props
|
|
413
|
+
}) => {
|
|
444
414
|
const breakPoint = useBreakpoint3();
|
|
445
415
|
const payloadHash = usePayloadHash2(payload);
|
|
446
416
|
const [anchorRef, dispatch] = useEvent();
|
|
447
|
-
const [errors = []] = usePromise2(async () => payload ? await new PayloadValidator2(payload).validate() : void 0, [
|
|
448
|
-
payload
|
|
449
|
-
]);
|
|
417
|
+
const [errors = []] = usePromise2(async () => payload ? await new PayloadValidator2(payload).validate() : void 0, [payload]);
|
|
450
418
|
const isValid = errors.length === 0;
|
|
451
|
-
const hash =
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
}, payloadHash) : payloadHash)), "hash");
|
|
465
|
-
const reduceSchemaDepth = /* @__PURE__ */ __name((schema2, maxSchemaDepth2) => {
|
|
419
|
+
const hash = (props2) => /* @__PURE__ */ jsx3(
|
|
420
|
+
HashTableCell2,
|
|
421
|
+
{
|
|
422
|
+
dataType: "payload",
|
|
423
|
+
onHashClick,
|
|
424
|
+
value: payloadHash,
|
|
425
|
+
width: "100%",
|
|
426
|
+
...props2,
|
|
427
|
+
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 })
|
|
428
|
+
},
|
|
429
|
+
"hash"
|
|
430
|
+
);
|
|
431
|
+
const reduceSchemaDepth = (schema2, maxSchemaDepth2) => {
|
|
466
432
|
if (isDefined(maxSchemaDepth2)) {
|
|
467
433
|
const parts = schema2?.split(".") ?? [];
|
|
468
434
|
const partsToRemove = Math.max(parts.length - maxSchemaDepth2, 0);
|
|
469
435
|
if (partsToRemove > 0) {
|
|
470
|
-
return /* @__PURE__ */
|
|
436
|
+
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
437
|
+
/* @__PURE__ */ jsx3(Fragment, { children: "\u2026" }),
|
|
438
|
+
`${parts.slice(partsToRemove).reduce((previousValue, part) => previousValue + "." + part, "")}`
|
|
439
|
+
] });
|
|
471
440
|
}
|
|
472
441
|
}
|
|
473
442
|
return schema2;
|
|
474
|
-
}
|
|
475
|
-
const schema = /* @__PURE__ */
|
|
476
|
-
|
|
477
|
-
key: "payloads",
|
|
478
|
-
align: "center",
|
|
479
|
-
...props2
|
|
480
|
-
}, /* @__PURE__ */ React3.createElement(Typography3, {
|
|
481
|
-
fontFamily: "monospace",
|
|
482
|
-
variant: "body2",
|
|
483
|
-
noWrap: true
|
|
484
|
-
}, clickableFields?.includes("schema") ? /* @__PURE__ */ React3.createElement(Link, {
|
|
485
|
-
sx: {
|
|
486
|
-
cursor: "pointer"
|
|
487
|
-
}
|
|
488
|
-
}, reduceSchemaDepth(payload?.schema, maxSchemaDepth)) : reduceSchemaDepth(payload?.schema, maxSchemaDepth))), "schema");
|
|
489
|
-
const valid = /* @__PURE__ */ __name((props2) => /* @__PURE__ */ React3.createElement(TableCell3, {
|
|
490
|
-
key: "valid",
|
|
491
|
-
align: "center",
|
|
492
|
-
...props2
|
|
493
|
-
}, isValid === void 0 && payload != void 0 ? /* @__PURE__ */ React3.createElement(WarningAmberRoundedIcon2, {
|
|
494
|
-
fontSize: "small",
|
|
495
|
-
color: "warning"
|
|
496
|
-
}) : isValid === true ? /* @__PURE__ */ React3.createElement(CheckCircleOutlineRoundedIcon2, {
|
|
497
|
-
fontSize: "small",
|
|
498
|
-
color: "success"
|
|
499
|
-
}) : isValid === false ? /* @__PURE__ */ React3.createElement(ErrorOutlineRoundedIcon2, {
|
|
500
|
-
color: "error",
|
|
501
|
-
fontSize: "small"
|
|
502
|
-
}) : /* @__PURE__ */ React3.createElement(ErrorOutlineRoundedIcon2, {
|
|
503
|
-
sx: {
|
|
504
|
-
color: alpha("#fff", 0)
|
|
505
|
-
},
|
|
506
|
-
fontSize: "small"
|
|
507
|
-
})), "valid");
|
|
443
|
+
};
|
|
444
|
+
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");
|
|
445
|
+
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");
|
|
508
446
|
const tableCells = {
|
|
509
447
|
hash,
|
|
510
448
|
schema,
|
|
511
449
|
valid
|
|
512
450
|
};
|
|
513
|
-
const columnsMemo = useMemo3(() => columns ?? payloadTableColumnConfigDefaults(), [
|
|
514
|
-
|
|
515
|
-
]);
|
|
516
|
-
return isDefined(breakPoint) ? /* @__PURE__ */ React3.createElement(TableRow3, {
|
|
517
|
-
style: {
|
|
518
|
-
maxWidth: "100vw"
|
|
519
|
-
},
|
|
520
|
-
...props
|
|
521
|
-
}, columnsMemo[breakPoint]?.map((column) => {
|
|
451
|
+
const columnsMemo = useMemo3(() => columns ?? payloadTableColumnConfigDefaults(), [columns]);
|
|
452
|
+
return isDefined(breakPoint) ? /* @__PURE__ */ jsx3(TableRow3, { style: { maxWidth: "100vw" }, ...props, children: columnsMemo[breakPoint]?.map((column) => {
|
|
522
453
|
return tableCells[column]({});
|
|
523
|
-
})) : null;
|
|
524
|
-
}
|
|
454
|
+
}) }) : null;
|
|
455
|
+
};
|
|
525
456
|
|
|
526
457
|
// src/components/Table/TableBody.tsx
|
|
527
|
-
|
|
458
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
459
|
+
var PayloadTableBody = ({
|
|
460
|
+
children,
|
|
461
|
+
clickableFields,
|
|
462
|
+
payloads,
|
|
463
|
+
maxSchemaDepth,
|
|
464
|
+
onHashClick,
|
|
465
|
+
onRowClick,
|
|
466
|
+
emptyRows,
|
|
467
|
+
noResults,
|
|
468
|
+
NoResultRowComponent,
|
|
469
|
+
...props
|
|
470
|
+
}) => {
|
|
528
471
|
const payloadPairs = usePayloadHashes2(payloads);
|
|
529
|
-
return /* @__PURE__ */
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
472
|
+
return /* @__PURE__ */ jsxs3(TableBody2, { ...props, children: [
|
|
473
|
+
noResults && NoResultRowComponent ? /* @__PURE__ */ jsx4(NoResultRowComponent, {}) : null,
|
|
474
|
+
payloadPairs?.map(([payload, hash], index) => {
|
|
475
|
+
return /* @__PURE__ */ jsx4(
|
|
476
|
+
ThrownErrorBoundary2,
|
|
477
|
+
{
|
|
478
|
+
boundaryName: "PayloadTableBody",
|
|
479
|
+
errorComponent: (e) => /* @__PURE__ */ jsxs3(Alert2, { severity: "error", children: [
|
|
480
|
+
"Error Loading Payload:",
|
|
481
|
+
" ",
|
|
482
|
+
/* @__PURE__ */ jsx4(Typography4, { fontWeight: "bold", children: e.message })
|
|
483
|
+
] }),
|
|
484
|
+
children: /* @__PURE__ */ jsx4(
|
|
485
|
+
PayloadTableRow,
|
|
486
|
+
{
|
|
487
|
+
clickableFields,
|
|
488
|
+
maxSchemaDepth,
|
|
489
|
+
onClick: onRowClick ? () => {
|
|
490
|
+
onRowClick(payload);
|
|
491
|
+
} : void 0,
|
|
492
|
+
onHashClick,
|
|
493
|
+
payload
|
|
494
|
+
}
|
|
495
|
+
)
|
|
496
|
+
},
|
|
497
|
+
`${hash}-${index}`
|
|
498
|
+
);
|
|
499
|
+
}),
|
|
500
|
+
children,
|
|
501
|
+
emptyRows ? Array.from({ length: emptyRows }).fill(/* @__PURE__ */ jsx4(PayloadTableRow, {})) : null
|
|
502
|
+
] });
|
|
503
|
+
};
|
|
551
504
|
|
|
552
505
|
// src/components/Table/TableFooter.tsx
|
|
553
|
-
import {
|
|
506
|
+
import {
|
|
507
|
+
styled,
|
|
508
|
+
TablePagination as TablePagination2,
|
|
509
|
+
TableRow as TableRow4
|
|
510
|
+
} from "@mui/material";
|
|
554
511
|
import { TableFooterEx } from "@xyo-network/react-table";
|
|
555
|
-
import React6 from "react";
|
|
556
512
|
|
|
557
513
|
// src/components/Table/TablePagination.tsx
|
|
558
|
-
import {
|
|
559
|
-
|
|
514
|
+
import {
|
|
515
|
+
FirstPage as FirstPageIcon2,
|
|
516
|
+
KeyboardArrowLeft as KeyboardArrowLeft2,
|
|
517
|
+
KeyboardArrowRight as KeyboardArrowRight2,
|
|
518
|
+
LastPage as LastPageIcon2
|
|
519
|
+
} from "@mui/icons-material";
|
|
520
|
+
import {
|
|
521
|
+
Box as Box2,
|
|
522
|
+
CircularProgress,
|
|
523
|
+
IconButton as IconButton2,
|
|
524
|
+
useTheme as useTheme2
|
|
525
|
+
} from "@mui/material";
|
|
560
526
|
import { useEvent as useEvent2 } from "@xyo-network/react-event";
|
|
561
|
-
import
|
|
562
|
-
function TablePaginationActions2({
|
|
527
|
+
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
528
|
+
function TablePaginationActions2({
|
|
529
|
+
count,
|
|
530
|
+
enableNextPage,
|
|
531
|
+
loading,
|
|
532
|
+
onPageChange,
|
|
533
|
+
page,
|
|
534
|
+
rowsPerPage
|
|
535
|
+
}) {
|
|
563
536
|
const theme = useTheme2();
|
|
564
537
|
const [paginationRef, paginationDispatch] = useEvent2();
|
|
565
|
-
const handleFirstPageButtonClick =
|
|
538
|
+
const handleFirstPageButtonClick = (event) => {
|
|
566
539
|
paginationDispatch("firstPage", "click", "true");
|
|
567
540
|
onPageChange(event, 0);
|
|
568
|
-
}
|
|
569
|
-
const handleBackButtonClick =
|
|
541
|
+
};
|
|
542
|
+
const handleBackButtonClick = (event) => {
|
|
570
543
|
paginationDispatch("previousPage", "click", (page - 1)?.toString());
|
|
571
544
|
onPageChange(event, page - 1);
|
|
572
|
-
}
|
|
573
|
-
const handleNextButtonClick =
|
|
545
|
+
};
|
|
546
|
+
const handleNextButtonClick = (event) => {
|
|
574
547
|
paginationDispatch("nextPage", "click", (page + 1)?.toString());
|
|
575
548
|
onPageChange(event, page + 1);
|
|
576
|
-
}
|
|
577
|
-
const handleLastPageButtonClick =
|
|
549
|
+
};
|
|
550
|
+
const handleLastPageButtonClick = (event) => {
|
|
578
551
|
paginationDispatch("lastPage", "click", "true");
|
|
579
552
|
onPageChange(event, Math.max(0, Math.ceil(count / rowsPerPage) - 1));
|
|
580
|
-
}
|
|
581
|
-
return /* @__PURE__ */
|
|
582
|
-
|
|
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
|
-
disabled: page >= Math.ceil(count / rowsPerPage) - 1,
|
|
610
|
-
"aria-label": "last page"
|
|
611
|
-
}, theme.direction === "rtl" ? /* @__PURE__ */ React5.createElement(FirstPageIcon2, null) : /* @__PURE__ */ React5.createElement(LastPageIcon2, null))));
|
|
553
|
+
};
|
|
554
|
+
return /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
555
|
+
loading ? /* @__PURE__ */ jsx5(
|
|
556
|
+
CircularProgress,
|
|
557
|
+
{
|
|
558
|
+
size: "small",
|
|
559
|
+
sx: {
|
|
560
|
+
height: theme.spacing(2),
|
|
561
|
+
position: "absolute",
|
|
562
|
+
width: theme.spacing(2)
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
) : null,
|
|
566
|
+
/* @__PURE__ */ jsxs4(Box2, { sx: { flexShrink: 0, ml: 2.5 }, children: [
|
|
567
|
+
/* @__PURE__ */ jsx5(IconButton2, { onClick: handleFirstPageButtonClick, disabled: page === 0, "aria-label": "first page", children: theme.direction === "rtl" ? /* @__PURE__ */ jsx5(LastPageIcon2, {}) : /* @__PURE__ */ jsx5(FirstPageIcon2, {}) }),
|
|
568
|
+
/* @__PURE__ */ jsx5(IconButton2, { ref: paginationRef, onClick: handleBackButtonClick, disabled: page === 0, "aria-label": "previous page", children: theme.direction === "rtl" ? /* @__PURE__ */ jsx5(KeyboardArrowRight2, {}) : /* @__PURE__ */ jsx5(KeyboardArrowLeft2, {}) }),
|
|
569
|
+
/* @__PURE__ */ jsx5(
|
|
570
|
+
IconButton2,
|
|
571
|
+
{
|
|
572
|
+
ref: paginationRef,
|
|
573
|
+
onClick: handleNextButtonClick,
|
|
574
|
+
disabled: !enableNextPage && page >= Math.ceil(count / rowsPerPage) - 1,
|
|
575
|
+
"aria-label": "next page",
|
|
576
|
+
children: theme.direction === "rtl" ? /* @__PURE__ */ jsx5(KeyboardArrowLeft2, {}) : /* @__PURE__ */ jsx5(KeyboardArrowRight2, {})
|
|
577
|
+
}
|
|
578
|
+
),
|
|
579
|
+
/* @__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, {}) })
|
|
580
|
+
] })
|
|
581
|
+
] });
|
|
612
582
|
}
|
|
613
|
-
__name(TablePaginationActions2, "TablePaginationActions");
|
|
614
583
|
|
|
615
584
|
// src/components/Table/TableFooter.tsx
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
585
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
586
|
+
var PayloadTableFooter = ({
|
|
587
|
+
count,
|
|
588
|
+
variant,
|
|
589
|
+
page,
|
|
590
|
+
rowsPerPage,
|
|
591
|
+
handleChangePage,
|
|
592
|
+
handleChangeRowsPerPage,
|
|
593
|
+
fetchMorePayloads,
|
|
594
|
+
loading
|
|
595
|
+
}) => /* @__PURE__ */ jsx6(TableFooterEx, { variant, children: /* @__PURE__ */ jsx6(TableRow4, { children: /* @__PURE__ */ jsx6(
|
|
596
|
+
StyledTablePagination,
|
|
597
|
+
{
|
|
598
|
+
rowsPerPageOptions: [5, 10, 25, { label: "All", value: -1 }],
|
|
599
|
+
count: count ?? 0,
|
|
600
|
+
rowsPerPage: rowsPerPage ?? 10,
|
|
601
|
+
page: page ?? 0,
|
|
602
|
+
SelectProps: {
|
|
603
|
+
inputProps: { "aria-label": "rows per page" },
|
|
604
|
+
native: true
|
|
634
605
|
},
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
ActionsComponent: /* @__PURE__ */ __name((props) => /* @__PURE__ */ React6.createElement(TablePaginationActions2, {
|
|
643
|
-
enableNextPage: !!fetchMorePayloads,
|
|
644
|
-
loading,
|
|
645
|
-
...props
|
|
646
|
-
}), "ActionsComponent")
|
|
647
|
-
}))), "PayloadTableFooter");
|
|
606
|
+
onPageChange: handleChangePage ?? (() => {
|
|
607
|
+
}),
|
|
608
|
+
onRowsPerPageChange: handleChangeRowsPerPage ?? (() => {
|
|
609
|
+
}),
|
|
610
|
+
ActionsComponent: (props) => /* @__PURE__ */ jsx6(TablePaginationActions2, { enableNextPage: !!fetchMorePayloads, loading, ...props })
|
|
611
|
+
}
|
|
612
|
+
) }) });
|
|
648
613
|
var StyledTablePagination = styled(TablePagination2)(({ theme }) => ({
|
|
649
|
-
"& > .MuiToolbar-root": {
|
|
650
|
-
paddingLeft: theme.spacing(1)
|
|
651
|
-
},
|
|
614
|
+
"& > .MuiToolbar-root": { paddingLeft: theme.spacing(1) },
|
|
652
615
|
"borderTop": "1px solid",
|
|
653
616
|
"borderTopColor": theme.vars.palette.divider
|
|
654
617
|
}));
|
|
655
618
|
|
|
656
619
|
// src/components/Table/TableHead.tsx
|
|
657
|
-
import {
|
|
620
|
+
import {
|
|
621
|
+
TableCell as TableCell4,
|
|
622
|
+
TableHead as TableHead2,
|
|
623
|
+
TableRow as TableRow5,
|
|
624
|
+
Typography as Typography5
|
|
625
|
+
} from "@mui/material";
|
|
658
626
|
import { useBreakpoint as useBreakpoint4 } from "@xylabs/react-shared";
|
|
659
|
-
import
|
|
660
|
-
|
|
627
|
+
import { useMemo as useMemo4 } from "react";
|
|
628
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
629
|
+
var PayloadTableHead = ({ columns, ...props }) => {
|
|
661
630
|
const breakPoint = useBreakpoint4();
|
|
662
|
-
const columnsMemo = useMemo4(() => columns ?? payloadTableColumnConfigDefaults(), [
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
key: index,
|
|
668
|
-
width: index === 0 ? "100%" : void 0,
|
|
669
|
-
align: index === 0 ? "left" : "center"
|
|
670
|
-
}, /* @__PURE__ */ React7.createElement(Typography5, {
|
|
671
|
-
variant: "body2",
|
|
672
|
-
noWrap: true
|
|
673
|
-
}, payloadColumnNames[column]));
|
|
674
|
-
}) : null));
|
|
675
|
-
}, "PayloadTableHead");
|
|
631
|
+
const columnsMemo = useMemo4(() => columns ?? payloadTableColumnConfigDefaults(), [columns]);
|
|
632
|
+
return /* @__PURE__ */ jsx7(TableHead2, { ...props, children: /* @__PURE__ */ jsx7(TableRow5, { children: breakPoint ? columnsMemo[breakPoint]?.map((column, index) => {
|
|
633
|
+
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] }) }, index);
|
|
634
|
+
}) : null }) });
|
|
635
|
+
};
|
|
676
636
|
|
|
677
637
|
// src/components/Table/TableRowNoData.tsx
|
|
678
|
-
import {
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
638
|
+
import {
|
|
639
|
+
styled as styled2,
|
|
640
|
+
TableCell as TableCell5,
|
|
641
|
+
TableRow as TableRow6,
|
|
642
|
+
Typography as Typography6
|
|
643
|
+
} from "@mui/material";
|
|
644
|
+
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
645
|
+
var TableRowNoData = ({
|
|
646
|
+
additionalCells,
|
|
647
|
+
hideBorder = false,
|
|
648
|
+
typographyProps,
|
|
649
|
+
...props
|
|
650
|
+
}) => {
|
|
651
|
+
return /* @__PURE__ */ jsxs5(TableRow6, { ...props, children: [
|
|
652
|
+
/* @__PURE__ */ jsx8(StyledTableCell, { hideBorder, children: /* @__PURE__ */ jsx8(Typography6, { variant: "body2", ...typographyProps, children: "No Data To Display..." }) }),
|
|
653
|
+
additionalCells ? Array.from({ length: additionalCells }).fill(null).map((_fill, index) => /* @__PURE__ */ jsx8(StyledTableCell, { hideBorder }, index)) : null
|
|
654
|
+
] });
|
|
655
|
+
};
|
|
693
656
|
var StyledTableCell = styled2(TableCell5, {
|
|
694
657
|
name: "StyledTableCell",
|
|
695
|
-
shouldForwardProp:
|
|
696
|
-
})(({ hideBorder }) => ({
|
|
697
|
-
...hideBorder && {
|
|
698
|
-
border: "none"
|
|
699
|
-
}
|
|
700
|
-
}));
|
|
658
|
+
shouldForwardProp: (prop) => prop !== "hideBorder"
|
|
659
|
+
})(({ hideBorder }) => ({ ...hideBorder && { border: "none" } }));
|
|
701
660
|
|
|
702
661
|
// src/components/Table/Table.tsx
|
|
703
|
-
|
|
662
|
+
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
663
|
+
var PayloadTableWithRef = ({
|
|
664
|
+
clickableFields,
|
|
665
|
+
onHashClick,
|
|
666
|
+
onRowClick,
|
|
667
|
+
fetchMorePayloads,
|
|
668
|
+
rowsPerPage: rowsPerPageProp = 25,
|
|
669
|
+
payloads,
|
|
670
|
+
columns,
|
|
671
|
+
PayloadTableHeadComponent = PayloadTableHead,
|
|
672
|
+
PayloadTableBodyComponent = PayloadTableBody,
|
|
673
|
+
PayloadTableFooterComponent = PayloadTableFooter,
|
|
674
|
+
maxSchemaDepth,
|
|
675
|
+
count = 0,
|
|
676
|
+
loading = false,
|
|
677
|
+
variant = "scrollable",
|
|
678
|
+
...props
|
|
679
|
+
}) => {
|
|
704
680
|
const [page, setPage] = useState2(0);
|
|
705
681
|
const [rowsPerPage, setRowsPerPage] = useState2(rowsPerPageProp);
|
|
706
682
|
const [visiblePayloads, setVisiblePayloads] = useState2([]);
|
|
707
683
|
const emptyRows = page > 0 ? Math.max(0, (1 + page) * rowsPerPage - count || 0) : 0;
|
|
708
684
|
useMemo5(() => {
|
|
709
685
|
setRowsPerPage(rowsPerPageProp);
|
|
710
|
-
}, [
|
|
711
|
-
rowsPerPageProp
|
|
712
|
-
]);
|
|
686
|
+
}, [rowsPerPageProp]);
|
|
713
687
|
useMemo5(() => {
|
|
714
688
|
if (payloads) {
|
|
715
689
|
setVisiblePayloads(payloads.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage));
|
|
716
690
|
}
|
|
717
|
-
}, [
|
|
718
|
-
count,
|
|
719
|
-
page,
|
|
720
|
-
payloads,
|
|
721
|
-
rowsPerPage
|
|
722
|
-
]);
|
|
691
|
+
}, [count, page, payloads, rowsPerPage]);
|
|
723
692
|
useMemo5(() => {
|
|
724
693
|
setPage(0);
|
|
725
|
-
}, [
|
|
726
|
-
|
|
727
|
-
]);
|
|
728
|
-
const handleAdditionalPayloads = /* @__PURE__ */ __name(() => {
|
|
694
|
+
}, [payloads]);
|
|
695
|
+
const handleAdditionalPayloads = () => {
|
|
729
696
|
if (fetchMorePayloads && payloads) {
|
|
730
697
|
const buffer = rowsPerPage * 2;
|
|
731
698
|
const lastVisiblePayload = visiblePayloads?.at(-1);
|
|
@@ -736,46 +703,48 @@ var PayloadTableWithRef = /* @__PURE__ */ __name(({ clickableFields, onHashClick
|
|
|
736
703
|
}
|
|
737
704
|
}
|
|
738
705
|
}
|
|
739
|
-
}
|
|
740
|
-
const handleChangePage =
|
|
706
|
+
};
|
|
707
|
+
const handleChangePage = (_event, newPage) => {
|
|
741
708
|
handleAdditionalPayloads();
|
|
742
709
|
setPage(newPage);
|
|
743
|
-
}
|
|
744
|
-
const handleChangeRowsPerPage =
|
|
710
|
+
};
|
|
711
|
+
const handleChangeRowsPerPage = (event) => {
|
|
745
712
|
setRowsPerPage(Number.parseInt(event.target.value, 10));
|
|
746
713
|
setPage(0);
|
|
747
|
-
}
|
|
714
|
+
};
|
|
748
715
|
const noResults = useMemo5(() => {
|
|
749
716
|
return !loading && visiblePayloads.length === 0;
|
|
750
|
-
}, [
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
717
|
+
}, [loading, visiblePayloads]);
|
|
718
|
+
return /* @__PURE__ */ jsxs6(TableEx, { variant, ...props, children: [
|
|
719
|
+
/* @__PURE__ */ jsx9(PayloadTableHeadComponent, { columns }),
|
|
720
|
+
/* @__PURE__ */ jsx9(
|
|
721
|
+
PayloadTableBodyComponent,
|
|
722
|
+
{
|
|
723
|
+
clickableFields,
|
|
724
|
+
payloads: visiblePayloads,
|
|
725
|
+
maxSchemaDepth,
|
|
726
|
+
onRowClick,
|
|
727
|
+
onHashClick,
|
|
728
|
+
emptyRows,
|
|
729
|
+
noResults,
|
|
730
|
+
NoResultRowComponent: TableRowNoData
|
|
731
|
+
}
|
|
732
|
+
),
|
|
733
|
+
/* @__PURE__ */ jsx9(
|
|
734
|
+
PayloadTableFooterComponent,
|
|
735
|
+
{
|
|
736
|
+
count,
|
|
737
|
+
variant,
|
|
738
|
+
rowsPerPage,
|
|
739
|
+
handleChangePage,
|
|
740
|
+
handleChangeRowsPerPage,
|
|
741
|
+
fetchMorePayloads,
|
|
742
|
+
loading,
|
|
743
|
+
page
|
|
744
|
+
}
|
|
745
|
+
)
|
|
746
|
+
] });
|
|
747
|
+
};
|
|
779
748
|
PayloadTableWithRef.displayName = "PayloadTable";
|
|
780
749
|
var PayloadTable = PayloadTableWithRef;
|
|
781
750
|
export {
|