@xyo-network/react-payload-table 2.78.0 → 2.78.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/index.cjs +591 -1
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +589 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/neutral/index.cjs +591 -1
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.js +589 -1
- package/dist/neutral/index.js.map +1 -1
- package/dist/node/index.cjs +612 -1
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +597 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +17 -17
package/dist/node/index.js
CHANGED
|
@@ -1,2 +1,598 @@
|
|
|
1
|
-
import{CheckCircleOutlineRounded as Ce,ErrorOutlineRounded as Re,WarningAmberRounded as we}from"@mui/icons-material";import{TableCell as D,TableRow as xe,Typography as O}from"@mui/material";import{usePromise as ve}from"@xylabs/react-promise";import{useBreakpoint as He}from"@xylabs/react-shared";import{PayloadHasher as ke}from"@xyo-network/hash";import{PayloadValidator as De}from"@xyo-network/payload-validator";import{useNetwork as Be}from"@xyo-network/react-network";import{usePayloadRenderPluginResolver as Ee}from"@xyo-network/react-payload-plugin-resolver";import{HashTableCell as Se,usePayloadHash as Me}from"@xyo-network/react-shared";var M=()=>({lg:[{alignment:"left",name:"Icon",slug:"icon",width:"50px"},{alignment:"left",name:"Hash",slug:"hash",width:"100%"},{alignment:"left",name:"Schema",slug:"schema",width:"50px"},{alignment:"left",name:"Render",slug:"render",width:"50px"},{alignment:"left",name:"Valid",slug:"valid",width:"50px"}],md:[{alignment:"left",name:"Icon",slug:"icon",width:"50px"},{alignment:"left",name:"Hash",slug:"hash",width:"100%"},{alignment:"left",name:"Schema",slug:"schema",width:"50px"},{alignment:"left",name:"Valid",slug:"valid",width:"50px"}],sm:[{alignment:"left",name:"Icon",slug:"icon",width:"50px"},{alignment:"left",name:"Hash",slug:"hash",width:"100%"},{alignment:"left",name:"Schema",slug:"schema",width:"50px"},{alignment:"left",name:"Valid",slug:"valid",width:"50px"}],xl:[{alignment:"left",name:"Icon",slug:"icon",width:"50px"},{alignment:"left",name:"Hash",slug:"hash",width:"100%"},{alignment:"left",name:"Schema",slug:"schema",width:"50px"},{alignment:"left",name:"Render",slug:"render",width:"50px"},{alignment:"left",name:"Valid",slug:"valid",width:"50px"}],xs:[{alignment:"left",name:"Hash",slug:"hash",width:"100%"},{alignment:"left",name:"Schema",slug:"schema",width:"50px"},{alignment:"left",name:"Valid",slug:"valid",width:"50px"}]});import{jsx as y}from"react/jsx-runtime";var z=({archive:l,columns:r=M(),exploreDomain:s,network:n,payload:e,...t})=>{var g;let a=He(),P=Me(e),{network:c}=Be(),{resolver:m}=Ee(),[u=[]]=ve(async()=>e?await new De(e).validate():void 0,[e]),p=u.length===0,T=e?Object.keys(ke.hashFields(e)).length:0,i={details:o=>y(D,{align:"left",...o,children:y(O,{fontFamily:"monospace",variant:"body2",noWrap:!0,children:T})},"payloads"),hash:o=>y(Se,{align:"left",archive:l,value:P,dataType:"payload",exploreDomain:s,network:n??(c==null?void 0:c.slug),...o},"hash"),icon:o=>{var R;let f=e?(R=m==null?void 0:m.resolve(e))==null?void 0:R.components.avatar.image:void 0;return y(D,{align:"left",...o,children:f?y(f,{payload:e}):null},"payloads")},render:o=>{var R;let f=e?(R=m==null?void 0:m.resolve(e))==null?void 0:R.components.table.cell:void 0;return f?y(f,{payload:e,...o}):y(D,{align:"left",...o},"payloads")},schema:o=>y(D,{align:"left",...o,children:y(O,{fontFamily:"monospace",variant:"body2",noWrap:!0,children:e==null?void 0:e.schema})},"payloads"),valid:o=>y(D,{align:"center",...o,children:p===void 0&&e!=null?y(we,{fontSize:"small",color:"warning"}):p===!0?y(Ce,{fontSize:"small",color:"success"}):p===!1?y(Re,{color:"error",fontSize:"small"}):y(O,{children:" \xA0"})},"valid")};return a?y(xe,{style:{maxWidth:"100vw"},...t,children:(g=r[a])==null?void 0:g.map(o=>o.slug?i[o.slug]({}):null)}):null};import{FirstPage as J,KeyboardArrowLeft as Q,KeyboardArrowRight as U,LastPage as X}from"@mui/icons-material";import{Alert as Fe,Box as Ae,IconButton as F,Table as Ie,TableBody as Le,TableCell as Ne,TableFooter as We,TableHead as Ve,TablePagination as Oe,TableRow as Z,Typography as j,useTheme as ze}from"@mui/material";import{useBreakpoint as $e}from"@xylabs/react-shared";import{ThrownErrorBoundary as Ke}from"@xyo-network/react-error";import{usePayloadHashes as _e}from"@xyo-network/react-shared";import{useEffect as Ye,useMemo as qe,useState as ee}from"react";import{jsx as d,jsxs as A}from"react/jsx-runtime";function Ge(l){let r=ze(),{count:s,page:n,rowsPerPage:e,onPageChange:t}=l,a=u=>{t(u,0)},P=u=>{t(u,n-1)},c=u=>{t(u,n+1)},m=u=>{t(u,Math.max(0,Math.ceil(s/e)-1))};return A(Ae,{sx:{flexShrink:0,ml:2.5},children:[d(F,{onClick:a,disabled:n===0,"aria-label":"first page",children:r.direction==="rtl"?d(X,{}):d(J,{})}),d(F,{onClick:P,disabled:n===0,"aria-label":"previous page",children:r.direction==="rtl"?d(U,{}):d(Q,{})}),d(F,{onClick:c,disabled:n>=Math.ceil(s/e)-1,"aria-label":"next page",children:r.direction==="rtl"?d(Q,{}):d(U,{})}),d(F,{onClick:m,disabled:n>=Math.ceil(s/e)-1,"aria-label":"last page",children:r.direction==="rtl"?d(J,{}):d(X,{})})]})}var uo=({archive:l,children:r,columns:s=M(),exploreDomain:n,onRowClick:e,rowsPerPage:t=10,payloads:a,...P})=>{var i;let c=$e(),[m,u]=ee(0),[p,T]=ee(t),b=a?a.length:0,w=m>0?Math.max(0,(1+m)*p-b):0,H=qe(()=>a==null?void 0:a.slice(m*p,m*p+p),[a,m,p]),k=_e(H);Ye(()=>{T(t)},[t]);let C=(g,o)=>{u(o)},v=g=>{T(Number.parseInt(g.target.value,10)),u(0)};return c?A(Ie,{stickyHeader:!0,...P,children:[d(Ve,{children:d(Z,{children:(i=s[c])==null?void 0:i.map((g,o)=>d(Ne,{align:g.alignment??"left",width:g.width,children:d(j,{variant:"body2",noWrap:!0,children:g.name})},o))})}),A(Le,{sx:{overflowY:"scroll "},children:[k==null?void 0:k.map(([g,o],f)=>d(Ke,{boundaryName:"PayloadTableBody",errorComponent:R=>A(Fe,{severity:"error",children:["Error Loading Payload: ",d(j,{fontWeight:"bold",children:R.message})]}),children:d(z,{archive:l,onClick:e?()=>{e(g)}:void 0,exploreDomain:n,payload:g})},`${o}-${f}`)),r,w?Array.from({length:w}).fill(d(z,{})):null]}),d(We,{children:d(Z,{children:d(Oe,{rowsPerPageOptions:[5,10,25,{label:"All",value:-1}],colSpan:5,count:b,rowsPerPage:p,page:m,SelectProps:{inputProps:{"aria-label":"rows per page"},native:!0},onPageChange:C,onRowsPerPageChange:v,ActionsComponent:Ge})})})]}):null};var ae={hash:"Hash",schema:"Schema",valid:"Valid"},I=()=>({lg:["hash","schema","valid"],md:["hash","schema","valid"],sm:["hash","schema","valid"],xl:["hash","schema","valid"],xs:["hash","schema","valid"]});import{TableEx as Sa}from"@xyo-network/react-table";import{forwardRef as Ma,useEffect as _,useMemo as Fa,useState as Y}from"react";import{Alert as ra,TableBody as ia,Typography as sa}from"@mui/material";import{ThrownErrorBoundary as ma}from"@xyo-network/react-error";import{usePayloadHashes as da}from"@xyo-network/react-shared";import{CheckCircleOutlineRounded as Je,ErrorOutlineRounded as oe,WarningAmberRounded as Qe}from"@mui/icons-material";import{alpha as Ue,TableCell as le,TableRow as Xe,Typography as Ze}from"@mui/material";import{usePromise as je}from"@xylabs/react-promise";import{useBreakpoint as ea}from"@xylabs/react-shared";import{PayloadValidator as aa}from"@xyo-network/payload-validator";import{useNetwork as oa}from"@xyo-network/react-network";import{HashTableCell as la,usePayloadHash as na}from"@xyo-network/react-shared";import{Fragment as ne,jsx as x,jsxs as ta}from"react/jsx-runtime";var $=({archive:l,columns:r=I(),exploreDomain:s,maxSchemaDepth:n,network:e,onHashClick:t,payload:a,...P})=>{var v;let c=ea(),m=na(a),{network:u}=oa(),[p=[]]=je(async()=>a?await new aa(a).validate():void 0,[a]),T=p.length===0,b=i=>x(la,{archive:l,width:"100%",value:m,onHashClick:t,dataType:"payload",exploreDomain:s,network:e??(u==null?void 0:u.slug),...i},"hash"),w=(i,g)=>{if(g){let o=(i==null?void 0:i.split("."))??[],f=o.length-g>0?o.length-g:0;if(f>0)return ta(ne,{children:[x(ne,{children:"\u2026"}),`${o.slice(f).reduce((R,V)=>`${R}.${V}`)}`]})}return i},C={hash:b,schema:i=>x(le,{title:a==null?void 0:a.schema,align:"center",...i,children:x(Ze,{fontFamily:"monospace",variant:"body2",noWrap:!0,children:w(a==null?void 0:a.schema,n)})},"payloads"),valid:i=>x(le,{align:"center",...i,children:T===void 0&&a!=null?x(Qe,{fontSize:"small",color:"warning"}):T===!0?x(Je,{fontSize:"small",color:"success"}):T===!1?x(oe,{color:"error",fontSize:"small"}):x(oe,{sx:{color:Ue("#fff",0)},fontSize:"small"})},"valid")};return c?x(Xe,{style:{maxWidth:"100vw"},...P,children:(v=r[c])==null?void 0:v.map(i=>C[i]({}))}):null};import{jsx as B,jsxs as te}from"react/jsx-runtime";var re=({children:l,exploreDomain:r,payloads:s,archive:n,maxSchemaDepth:e,onHashClick:t,onRowClick:a,emptyRows:P,noResults:c,NoResultRowComponent:m,...u})=>{let p=da(s);return te(ia,{...u,children:[c&&m?B(m,{}):null,p==null?void 0:p.map(([T,b],w)=>B(ma,{boundaryName:"PayloadTableBody",errorComponent:H=>te(ra,{severity:"error",children:["Error Loading Payload: ",B(sa,{fontWeight:"bold",children:H.message})]}),children:B($,{maxSchemaDepth:e,archive:n,onClick:a?()=>{a(T)}:void 0,onHashClick:t,exploreDomain:r,payload:T})},`${b}-${w}`)),l,P?Array.from({length:P}).fill(B($,{})):null]})};import{styled as Pa,TablePagination as Ta,TableRow as ya}from"@mui/material";import{TableFooterEx as ha}from"@xyo-network/react-table";import{FirstPage as ie,KeyboardArrowLeft as se,KeyboardArrowRight as me,LastPage as de}from"@mui/icons-material";import{Box as ca,CircularProgress as ua,IconButton as L,useTheme as pa}from"@mui/material";import{useEvent as ba}from"@xyo-network/react-event";import{Fragment as ga,jsx as h,jsxs as ce}from"react/jsx-runtime";function ue({count:l,enableNextPage:r,loading:s,onPageChange:n,page:e,rowsPerPage:t}){let a=pa(),[P,c]=ba(),m=b=>{c("firstPage","click","true"),n(b,0)},u=b=>{c("previousPage","click",(e-1).toString()),n(b,e-1)},p=b=>{c("nextPage","click",(e+1).toString()),n(b,e+1)},T=b=>{c("lastPage","click","true"),n(b,Math.max(0,Math.ceil(l/t)-1))};return ce(ga,{children:[s?h(ua,{size:"small",sx:{height:a.spacing(2),position:"absolute",width:a.spacing(2)}}):null,ce(ca,{sx:{flexShrink:0,ml:2.5},children:[h(L,{onClick:m,disabled:e===0,"aria-label":"first page",children:a.direction==="rtl"?h(de,{}):h(ie,{})}),h(L,{ref:P,onClick:u,disabled:e===0,"aria-label":"previous page",children:a.direction==="rtl"?h(me,{}):h(se,{})}),h(L,{ref:P,onClick:p,disabled:!r&&e>=Math.ceil(l/t)-1,"aria-label":"next page",children:a.direction==="rtl"?h(se,{}):h(me,{})}),h(L,{onClick:T,disabled:e>=Math.ceil(l/t)-1,"aria-label":"last page",children:a.direction==="rtl"?h(ie,{}):h(de,{})})]})]})}import{jsx as N}from"react/jsx-runtime";var pe=({count:l,variant:r,page:s,rowsPerPage:n,handleChangePage:e=()=>{},handleChangeRowsPerPage:t=()=>{},fetchMorePayloads:a,loading:P})=>N(ha,{variant:r,children:N(ya,{children:N(fa,{rowsPerPageOptions:[5,10,25,{label:"All",value:-1}],count:l??0,rowsPerPage:n??10,page:s??0,SelectProps:{inputProps:{"aria-label":"rows per page"},native:!0},onPageChange:e,onRowsPerPageChange:t,ActionsComponent:c=>N(ue,{enableNextPage:!!a,loading:P,...c})})})}),fa=Pa(Ta)(({theme:l})=>({"& > .MuiToolbar-root":{paddingLeft:l.spacing(1)},borderTop:"1px solid",borderTopColor:l.palette.divider}));import{TableCell as Ca,TableHead as Ra,TableRow as wa,Typography as xa}from"@mui/material";import{useBreakpoint as va}from"@xylabs/react-shared";import{jsx as W}from"react/jsx-runtime";var be=({columns:l=I(),...r})=>{var n;let s=va();return W(Ra,{...r,children:W(wa,{children:s&&l?(n=l[s])==null?void 0:n.map((e,t)=>W(Ca,{width:t===0?"100%":void 0,align:t===0?"left":"center",children:W(xa,{variant:"body2",noWrap:!0,children:ae[e]})},t)):null})})};import{styled as Ha,TableCell as ka,TableRow as Da,Typography as Ba}from"@mui/material";import{jsx as K,jsxs as Ea}from"react/jsx-runtime";var Pe=({additionalCells:l,hideBorder:r=!1,typographyProps:s,...n})=>Ea(Da,{...n,children:[K(ge,{hideBorder:r,children:K(Ba,{variant:"body2",...s,children:"No Data To Display..."})}),l?Array.from({length:l}).fill(null).map((e,t)=>K(ge,{hideBorder:r},t)):null]}),ge=Ha(ka,{name:"StyledTableCell",shouldForwardProp:l=>l!=="hideBorder"})(({hideBorder:l})=>({...l&&{border:"none"}}));import{jsx as q,jsxs as Aa}from"react/jsx-runtime";var Te=Ma(({exploreDomain:l,archive:r,onHashClick:s,onRowClick:n,fetchMorePayloads:e,rowsPerPage:t=25,payloads:a,columns:P,PayloadTableHeadComponent:c=be,PayloadTableBodyComponent:m=re,PayloadTableFooterComponent:u=pe,maxSchemaDepth:p,count:T=0,loading:b=!1,variant:w="scrollable",...H},k)=>{let[C,v]=Y(0),[i,g]=Y(t),[o,f]=Y([]),R=C>0?Math.max(0,(1+C)*i-T||0):0;_(()=>{g(t)},[t]),_(()=>{a&&f(a.slice(C*i,C*i+i))},[T,C,a,i]),_(()=>{v(0)},[a]);let V=()=>{if(e&&a){let E=i*2,S=o==null?void 0:o.at(-1);if(S){let G=a==null?void 0:a.indexOf(S);G!==void 0&&a.length-(G+1)<=E&&e()}}},ye=(E,S)=>{V(),v(S)},he=E=>{g(Number.parseInt(E.target.value,10)),v(0)},fe=Fa(()=>!b&&(!o||o.length===0),[b,o]);return Aa(Sa,{variant:w,ref:k,...H,children:[q(c,{columns:P}),q(m,{payloads:o,exploreDomain:l,archive:r,maxSchemaDepth:p,onRowClick:n,onHashClick:s,emptyRows:R,noResults:fe,NoResultRowComponent:Pe}),q(u,{count:T,variant:w,rowsPerPage:i,handleChangePage:ye,handleChangeRowsPerPage:he,fetchMorePayloads:e,loading:b,page:C})]})});Te.displayName="PayloadTable";var dl=Te;export{uo as PayloadDynamicTable,z as PayloadDynamicTableRow,dl as PayloadTable,$ as PayloadTableRow,Te as PayloadTableWithRef,ue as TablePaginationActions,Pe as TableRowNoData,ae as payloadColumnNames,M as payloadDynamicTableColumnConfigDefaults,I as payloadTableColumnConfigDefaults};
|
|
1
|
+
// src/components/DynamicTable/DynamicTableRow.tsx
|
|
2
|
+
import {
|
|
3
|
+
CheckCircleOutlineRounded as CheckCircleOutlineRoundedIcon,
|
|
4
|
+
ErrorOutlineRounded as ErrorOutlineRoundedIcon,
|
|
5
|
+
WarningAmberRounded as WarningAmberRoundedIcon
|
|
6
|
+
} from "@mui/icons-material";
|
|
7
|
+
import { TableCell, TableRow, Typography } from "@mui/material";
|
|
8
|
+
import { usePromise } from "@xylabs/react-promise";
|
|
9
|
+
import { useBreakpoint } from "@xylabs/react-shared";
|
|
10
|
+
import { PayloadHasher } from "@xyo-network/hash";
|
|
11
|
+
import { PayloadValidator } from "@xyo-network/payload-validator";
|
|
12
|
+
import { useNetwork } from "@xyo-network/react-network";
|
|
13
|
+
import { usePayloadRenderPluginResolver } from "@xyo-network/react-payload-plugin-resolver";
|
|
14
|
+
import { HashTableCell, usePayloadHash } from "@xyo-network/react-shared";
|
|
15
|
+
|
|
16
|
+
// src/components/DynamicTable/PayloadDynamicTableColumnConfig.ts
|
|
17
|
+
var payloadDynamicTableColumnConfigDefaults = () => {
|
|
18
|
+
const xs = [
|
|
19
|
+
{ alignment: "left", name: "Hash", slug: "hash", width: "100%" },
|
|
20
|
+
{ alignment: "left", name: "Schema", slug: "schema", width: "50px" },
|
|
21
|
+
{ alignment: "left", name: "Valid", slug: "valid", width: "50px" }
|
|
22
|
+
];
|
|
23
|
+
const sm = [
|
|
24
|
+
{ alignment: "left", name: "Icon", slug: "icon", width: "50px" },
|
|
25
|
+
{ alignment: "left", name: "Hash", slug: "hash", width: "100%" },
|
|
26
|
+
{ alignment: "left", name: "Schema", slug: "schema", width: "50px" },
|
|
27
|
+
{ alignment: "left", name: "Valid", slug: "valid", width: "50px" }
|
|
28
|
+
];
|
|
29
|
+
const md = [
|
|
30
|
+
{ alignment: "left", name: "Icon", slug: "icon", width: "50px" },
|
|
31
|
+
{ alignment: "left", name: "Hash", slug: "hash", width: "100%" },
|
|
32
|
+
{ alignment: "left", name: "Schema", slug: "schema", width: "50px" },
|
|
33
|
+
{ alignment: "left", name: "Valid", slug: "valid", width: "50px" }
|
|
34
|
+
];
|
|
35
|
+
const lg = [
|
|
36
|
+
{ alignment: "left", name: "Icon", slug: "icon", width: "50px" },
|
|
37
|
+
{ alignment: "left", name: "Hash", slug: "hash", width: "100%" },
|
|
38
|
+
{ alignment: "left", name: "Schema", slug: "schema", width: "50px" },
|
|
39
|
+
{ alignment: "left", name: "Render", slug: "render", width: "50px" },
|
|
40
|
+
{ alignment: "left", name: "Valid", slug: "valid", width: "50px" }
|
|
41
|
+
];
|
|
42
|
+
const xl = [
|
|
43
|
+
{ alignment: "left", name: "Icon", slug: "icon", width: "50px" },
|
|
44
|
+
{ alignment: "left", name: "Hash", slug: "hash", width: "100%" },
|
|
45
|
+
{ alignment: "left", name: "Schema", slug: "schema", width: "50px" },
|
|
46
|
+
{ alignment: "left", name: "Render", slug: "render", width: "50px" },
|
|
47
|
+
{ alignment: "left", name: "Valid", slug: "valid", width: "50px" }
|
|
48
|
+
];
|
|
49
|
+
return { lg, md, sm, xl, xs };
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// src/components/DynamicTable/DynamicTableRow.tsx
|
|
53
|
+
import { jsx } from "react/jsx-runtime";
|
|
54
|
+
var PayloadDynamicTableRow = ({
|
|
55
|
+
archive,
|
|
56
|
+
columns = payloadDynamicTableColumnConfigDefaults(),
|
|
57
|
+
exploreDomain,
|
|
58
|
+
network: networkProp,
|
|
59
|
+
payload,
|
|
60
|
+
...props
|
|
61
|
+
}) => {
|
|
62
|
+
var _a;
|
|
63
|
+
const breakPoint = useBreakpoint();
|
|
64
|
+
const payloadHash = usePayloadHash(payload);
|
|
65
|
+
const { network } = useNetwork();
|
|
66
|
+
const { resolver } = usePayloadRenderPluginResolver();
|
|
67
|
+
const [validationErrors = []] = usePromise(async () => payload ? await new PayloadValidator(payload).validate() : void 0, [payload]);
|
|
68
|
+
const isValid = validationErrors.length === 0;
|
|
69
|
+
const payloadFieldCount = payload ? Object.keys(PayloadHasher.hashFields(payload)).length : 0;
|
|
70
|
+
const hash = (props2) => /* @__PURE__ */ jsx(
|
|
71
|
+
HashTableCell,
|
|
72
|
+
{
|
|
73
|
+
align: "left",
|
|
74
|
+
archive,
|
|
75
|
+
value: payloadHash,
|
|
76
|
+
dataType: "payload",
|
|
77
|
+
exploreDomain,
|
|
78
|
+
network: networkProp ?? (network == null ? void 0 : network.slug),
|
|
79
|
+
...props2
|
|
80
|
+
},
|
|
81
|
+
"hash"
|
|
82
|
+
);
|
|
83
|
+
const schema = (props2) => /* @__PURE__ */ jsx(TableCell, { align: "left", ...props2, children: /* @__PURE__ */ jsx(Typography, { fontFamily: "monospace", variant: "body2", noWrap: true, children: payload == null ? void 0 : payload.schema }) }, "payloads");
|
|
84
|
+
const details = (props2) => /* @__PURE__ */ jsx(TableCell, { align: "left", ...props2, children: /* @__PURE__ */ jsx(Typography, { fontFamily: "monospace", variant: "body2", noWrap: true, children: payloadFieldCount }) }, "payloads");
|
|
85
|
+
const render = (props2) => {
|
|
86
|
+
var _a2;
|
|
87
|
+
const Render = payload ? (_a2 = resolver == null ? void 0 : resolver.resolve(payload)) == null ? void 0 : _a2.components.table.cell : void 0;
|
|
88
|
+
return Render ? /* @__PURE__ */ jsx(Render, { payload, ...props2 }) : /* @__PURE__ */ jsx(TableCell, { align: "left", ...props2 }, "payloads");
|
|
89
|
+
};
|
|
90
|
+
const icon = (props2) => {
|
|
91
|
+
var _a2;
|
|
92
|
+
const Avatar = payload ? (_a2 = resolver == null ? void 0 : resolver.resolve(payload)) == null ? void 0 : _a2.components.avatar.image : void 0;
|
|
93
|
+
return /* @__PURE__ */ jsx(TableCell, { align: "left", ...props2, children: Avatar ? /* @__PURE__ */ jsx(Avatar, { payload }) : null }, "payloads");
|
|
94
|
+
};
|
|
95
|
+
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");
|
|
96
|
+
const tableCells = {
|
|
97
|
+
details,
|
|
98
|
+
hash,
|
|
99
|
+
icon,
|
|
100
|
+
render,
|
|
101
|
+
schema,
|
|
102
|
+
valid
|
|
103
|
+
};
|
|
104
|
+
return breakPoint ? /* @__PURE__ */ jsx(TableRow, { style: { maxWidth: "100vw" }, ...props, children: (_a = columns[breakPoint]) == null ? void 0 : _a.map((column) => {
|
|
105
|
+
return column.slug ? tableCells[column.slug]({}) : null;
|
|
106
|
+
}) }) : null;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// src/components/DynamicTable/Table.tsx
|
|
110
|
+
import { FirstPage as FirstPageIcon, KeyboardArrowLeft, KeyboardArrowRight, LastPage as LastPageIcon } from "@mui/icons-material";
|
|
111
|
+
import {
|
|
112
|
+
Alert,
|
|
113
|
+
Box,
|
|
114
|
+
IconButton,
|
|
115
|
+
Table,
|
|
116
|
+
TableBody,
|
|
117
|
+
TableCell as TableCell2,
|
|
118
|
+
TableFooter,
|
|
119
|
+
TableHead,
|
|
120
|
+
TablePagination,
|
|
121
|
+
TableRow as TableRow2,
|
|
122
|
+
Typography as Typography2,
|
|
123
|
+
useTheme
|
|
124
|
+
} from "@mui/material";
|
|
125
|
+
import { useBreakpoint as useBreakpoint2 } from "@xylabs/react-shared";
|
|
126
|
+
import { ThrownErrorBoundary } from "@xyo-network/react-error";
|
|
127
|
+
import { usePayloadHashes } from "@xyo-network/react-shared";
|
|
128
|
+
import { useEffect, useMemo, useState } from "react";
|
|
129
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
130
|
+
function TablePaginationActions(props) {
|
|
131
|
+
const theme = useTheme();
|
|
132
|
+
const { count, page, rowsPerPage, onPageChange } = props;
|
|
133
|
+
const handleFirstPageButtonClick = (event) => {
|
|
134
|
+
onPageChange(event, 0);
|
|
135
|
+
};
|
|
136
|
+
const handleBackButtonClick = (event) => {
|
|
137
|
+
onPageChange(event, page - 1);
|
|
138
|
+
};
|
|
139
|
+
const handleNextButtonClick = (event) => {
|
|
140
|
+
onPageChange(event, page + 1);
|
|
141
|
+
};
|
|
142
|
+
const handleLastPageButtonClick = (event) => {
|
|
143
|
+
onPageChange(event, Math.max(0, Math.ceil(count / rowsPerPage) - 1));
|
|
144
|
+
};
|
|
145
|
+
return /* @__PURE__ */ jsxs(Box, { sx: { flexShrink: 0, ml: 2.5 }, children: [
|
|
146
|
+
/* @__PURE__ */ jsx2(IconButton, { onClick: handleFirstPageButtonClick, disabled: page === 0, "aria-label": "first page", children: theme.direction === "rtl" ? /* @__PURE__ */ jsx2(LastPageIcon, {}) : /* @__PURE__ */ jsx2(FirstPageIcon, {}) }),
|
|
147
|
+
/* @__PURE__ */ jsx2(IconButton, { onClick: handleBackButtonClick, disabled: page === 0, "aria-label": "previous page", children: theme.direction === "rtl" ? /* @__PURE__ */ jsx2(KeyboardArrowRight, {}) : /* @__PURE__ */ jsx2(KeyboardArrowLeft, {}) }),
|
|
148
|
+
/* @__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, {}) }),
|
|
149
|
+
/* @__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, {}) })
|
|
150
|
+
] });
|
|
151
|
+
}
|
|
152
|
+
var PayloadDynamicTable = ({
|
|
153
|
+
archive,
|
|
154
|
+
children,
|
|
155
|
+
columns = payloadDynamicTableColumnConfigDefaults(),
|
|
156
|
+
exploreDomain,
|
|
157
|
+
onRowClick,
|
|
158
|
+
rowsPerPage: rowsPerPageProp = 10,
|
|
159
|
+
payloads,
|
|
160
|
+
...props
|
|
161
|
+
}) => {
|
|
162
|
+
var _a;
|
|
163
|
+
const breakPoint = useBreakpoint2();
|
|
164
|
+
const [page, setPage] = useState(0);
|
|
165
|
+
const [rowsPerPage, setRowsPerPage] = useState(rowsPerPageProp);
|
|
166
|
+
const payloadCount = payloads ? payloads.length : 0;
|
|
167
|
+
const emptyRows = page > 0 ? Math.max(0, (1 + page) * rowsPerPage - payloadCount) : 0;
|
|
168
|
+
const pagedPayloads = useMemo(() => payloads == null ? void 0 : payloads.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage), [payloads, page, rowsPerPage]);
|
|
169
|
+
const payloadPairs = usePayloadHashes(pagedPayloads);
|
|
170
|
+
useEffect(() => {
|
|
171
|
+
setRowsPerPage(rowsPerPageProp);
|
|
172
|
+
}, [rowsPerPageProp]);
|
|
173
|
+
const handleChangePage = (event, newPage) => {
|
|
174
|
+
setPage(newPage);
|
|
175
|
+
};
|
|
176
|
+
const handleChangeRowsPerPage = (event) => {
|
|
177
|
+
setRowsPerPage(Number.parseInt(event.target.value, 10));
|
|
178
|
+
setPage(0);
|
|
179
|
+
};
|
|
180
|
+
return breakPoint ? /* @__PURE__ */ jsxs(Table, { stickyHeader: true, ...props, children: [
|
|
181
|
+
/* @__PURE__ */ jsx2(TableHead, { children: /* @__PURE__ */ jsx2(TableRow2, { children: (_a = columns[breakPoint]) == null ? void 0 : _a.map((column, index) => {
|
|
182
|
+
return /* @__PURE__ */ jsx2(TableCell2, { align: column.alignment ?? "left", width: column.width, children: /* @__PURE__ */ jsx2(Typography2, { variant: "body2", noWrap: true, children: column.name }) }, index);
|
|
183
|
+
}) }) }),
|
|
184
|
+
/* @__PURE__ */ jsxs(TableBody, { sx: { overflowY: "scroll " }, children: [
|
|
185
|
+
payloadPairs == null ? void 0 : payloadPairs.map(([payload, hash], index) => {
|
|
186
|
+
return /* @__PURE__ */ jsx2(
|
|
187
|
+
ThrownErrorBoundary,
|
|
188
|
+
{
|
|
189
|
+
boundaryName: "PayloadTableBody",
|
|
190
|
+
errorComponent: (e) => /* @__PURE__ */ jsxs(Alert, { severity: "error", children: [
|
|
191
|
+
"Error Loading Payload: ",
|
|
192
|
+
/* @__PURE__ */ jsx2(Typography2, { fontWeight: "bold", children: e.message })
|
|
193
|
+
] }),
|
|
194
|
+
children: /* @__PURE__ */ jsx2(
|
|
195
|
+
PayloadDynamicTableRow,
|
|
196
|
+
{
|
|
197
|
+
archive,
|
|
198
|
+
onClick: onRowClick ? () => {
|
|
199
|
+
onRowClick(payload);
|
|
200
|
+
} : void 0,
|
|
201
|
+
exploreDomain,
|
|
202
|
+
payload
|
|
203
|
+
}
|
|
204
|
+
)
|
|
205
|
+
},
|
|
206
|
+
`${hash}-${index}`
|
|
207
|
+
);
|
|
208
|
+
}),
|
|
209
|
+
children,
|
|
210
|
+
emptyRows ? Array.from({ length: emptyRows }).fill(/* @__PURE__ */ jsx2(PayloadDynamicTableRow, {})) : null
|
|
211
|
+
] }),
|
|
212
|
+
/* @__PURE__ */ jsx2(TableFooter, { children: /* @__PURE__ */ jsx2(TableRow2, { children: /* @__PURE__ */ jsx2(
|
|
213
|
+
TablePagination,
|
|
214
|
+
{
|
|
215
|
+
rowsPerPageOptions: [5, 10, 25, { label: "All", value: -1 }],
|
|
216
|
+
colSpan: 5,
|
|
217
|
+
count: payloadCount,
|
|
218
|
+
rowsPerPage,
|
|
219
|
+
page,
|
|
220
|
+
SelectProps: {
|
|
221
|
+
inputProps: {
|
|
222
|
+
"aria-label": "rows per page"
|
|
223
|
+
},
|
|
224
|
+
native: true
|
|
225
|
+
},
|
|
226
|
+
onPageChange: handleChangePage,
|
|
227
|
+
onRowsPerPageChange: handleChangeRowsPerPage,
|
|
228
|
+
ActionsComponent: TablePaginationActions
|
|
229
|
+
}
|
|
230
|
+
) }) })
|
|
231
|
+
] }) : null;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
// src/components/Table/PayloadTableColumnConfig.ts
|
|
235
|
+
var payloadColumnNames = {
|
|
236
|
+
hash: "Hash",
|
|
237
|
+
schema: "Schema",
|
|
238
|
+
valid: "Valid"
|
|
239
|
+
};
|
|
240
|
+
var payloadTableColumnConfigDefaults = () => {
|
|
241
|
+
const xs = ["hash", "schema", "valid"];
|
|
242
|
+
const sm = ["hash", "schema", "valid"];
|
|
243
|
+
const md = ["hash", "schema", "valid"];
|
|
244
|
+
const lg = ["hash", "schema", "valid"];
|
|
245
|
+
const xl = ["hash", "schema", "valid"];
|
|
246
|
+
return { lg, md, sm, xl, xs };
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
// src/components/Table/Table.tsx
|
|
250
|
+
import { TableEx } from "@xyo-network/react-table";
|
|
251
|
+
import { forwardRef, useEffect as useEffect2, useMemo as useMemo2, useState as useState2 } from "react";
|
|
252
|
+
|
|
253
|
+
// src/components/Table/TableBody.tsx
|
|
254
|
+
import { Alert as Alert2, TableBody as TableBody2, Typography as Typography4 } from "@mui/material";
|
|
255
|
+
import { ThrownErrorBoundary as ThrownErrorBoundary2 } from "@xyo-network/react-error";
|
|
256
|
+
import { usePayloadHashes as usePayloadHashes2 } from "@xyo-network/react-shared";
|
|
257
|
+
|
|
258
|
+
// src/components/Table/TableRow.tsx
|
|
259
|
+
import {
|
|
260
|
+
CheckCircleOutlineRounded as CheckCircleOutlineRoundedIcon2,
|
|
261
|
+
ErrorOutlineRounded as ErrorOutlineRoundedIcon2,
|
|
262
|
+
WarningAmberRounded as WarningAmberRoundedIcon2
|
|
263
|
+
} from "@mui/icons-material";
|
|
264
|
+
import { alpha, TableCell as TableCell3, TableRow as TableRow3, Typography as Typography3 } from "@mui/material";
|
|
265
|
+
import { usePromise as usePromise2 } from "@xylabs/react-promise";
|
|
266
|
+
import { useBreakpoint as useBreakpoint3 } from "@xylabs/react-shared";
|
|
267
|
+
import { PayloadValidator as PayloadValidator2 } from "@xyo-network/payload-validator";
|
|
268
|
+
import { useNetwork as useNetwork2 } from "@xyo-network/react-network";
|
|
269
|
+
import { HashTableCell as HashTableCell2, usePayloadHash as usePayloadHash2 } from "@xyo-network/react-shared";
|
|
270
|
+
import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
271
|
+
var PayloadTableRow = ({
|
|
272
|
+
archive,
|
|
273
|
+
columns = payloadTableColumnConfigDefaults(),
|
|
274
|
+
exploreDomain,
|
|
275
|
+
maxSchemaDepth,
|
|
276
|
+
network: networkProp,
|
|
277
|
+
onHashClick,
|
|
278
|
+
payload,
|
|
279
|
+
...props
|
|
280
|
+
}) => {
|
|
281
|
+
var _a;
|
|
282
|
+
const breakPoint = useBreakpoint3();
|
|
283
|
+
const payloadHash = usePayloadHash2(payload);
|
|
284
|
+
const { network } = useNetwork2();
|
|
285
|
+
const [errors = []] = usePromise2(async () => payload ? await new PayloadValidator2(payload).validate() : void 0, [payload]);
|
|
286
|
+
const isValid = errors.length === 0;
|
|
287
|
+
const hash = (props2) => /* @__PURE__ */ jsx3(
|
|
288
|
+
HashTableCell2,
|
|
289
|
+
{
|
|
290
|
+
archive,
|
|
291
|
+
width: "100%",
|
|
292
|
+
value: payloadHash,
|
|
293
|
+
onHashClick,
|
|
294
|
+
dataType: "payload",
|
|
295
|
+
exploreDomain,
|
|
296
|
+
network: networkProp ?? (network == null ? void 0 : network.slug),
|
|
297
|
+
...props2
|
|
298
|
+
},
|
|
299
|
+
"hash"
|
|
300
|
+
);
|
|
301
|
+
const reduceSchemaDepth = (schema2, maxSchemaDepth2) => {
|
|
302
|
+
if (maxSchemaDepth2) {
|
|
303
|
+
const parts = (schema2 == null ? void 0 : schema2.split(".")) ?? [];
|
|
304
|
+
const partsToRemove = parts.length - maxSchemaDepth2 > 0 ? parts.length - maxSchemaDepth2 : 0;
|
|
305
|
+
if (partsToRemove > 0) {
|
|
306
|
+
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
307
|
+
/* @__PURE__ */ jsx3(Fragment, { children: "\u2026" }),
|
|
308
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
309
|
+
`${parts.slice(partsToRemove).reduce((previousValue, part) => `${previousValue}.${part}`)}`
|
|
310
|
+
] });
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return schema2;
|
|
314
|
+
};
|
|
315
|
+
const schema = (props2) => /* @__PURE__ */ jsx3(TableCell3, { title: payload == null ? void 0 : payload.schema, align: "center", ...props2, children: /* @__PURE__ */ jsx3(Typography3, { fontFamily: "monospace", variant: "body2", noWrap: true, children: reduceSchemaDepth(payload == null ? void 0 : payload.schema, maxSchemaDepth) }) }, "payloads");
|
|
316
|
+
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");
|
|
317
|
+
const tableCells = {
|
|
318
|
+
hash,
|
|
319
|
+
schema,
|
|
320
|
+
valid
|
|
321
|
+
};
|
|
322
|
+
return breakPoint ? /* @__PURE__ */ jsx3(TableRow3, { style: { maxWidth: "100vw" }, ...props, children: (_a = columns[breakPoint]) == null ? void 0 : _a.map((column) => {
|
|
323
|
+
return tableCells[column]({});
|
|
324
|
+
}) }) : null;
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
// src/components/Table/TableBody.tsx
|
|
328
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
329
|
+
var PayloadTableBody = ({
|
|
330
|
+
children,
|
|
331
|
+
exploreDomain,
|
|
332
|
+
payloads,
|
|
333
|
+
archive,
|
|
334
|
+
maxSchemaDepth,
|
|
335
|
+
onHashClick,
|
|
336
|
+
onRowClick,
|
|
337
|
+
emptyRows,
|
|
338
|
+
noResults,
|
|
339
|
+
NoResultRowComponent,
|
|
340
|
+
...props
|
|
341
|
+
}) => {
|
|
342
|
+
const payloadPairs = usePayloadHashes2(payloads);
|
|
343
|
+
return /* @__PURE__ */ jsxs3(TableBody2, { ...props, children: [
|
|
344
|
+
noResults && NoResultRowComponent ? /* @__PURE__ */ jsx4(NoResultRowComponent, {}) : null,
|
|
345
|
+
payloadPairs == null ? void 0 : payloadPairs.map(([payload, hash], index) => {
|
|
346
|
+
return /* @__PURE__ */ jsx4(
|
|
347
|
+
ThrownErrorBoundary2,
|
|
348
|
+
{
|
|
349
|
+
boundaryName: "PayloadTableBody",
|
|
350
|
+
errorComponent: (e) => /* @__PURE__ */ jsxs3(Alert2, { severity: "error", children: [
|
|
351
|
+
"Error Loading Payload: ",
|
|
352
|
+
/* @__PURE__ */ jsx4(Typography4, { fontWeight: "bold", children: e.message })
|
|
353
|
+
] }),
|
|
354
|
+
children: /* @__PURE__ */ jsx4(
|
|
355
|
+
PayloadTableRow,
|
|
356
|
+
{
|
|
357
|
+
maxSchemaDepth,
|
|
358
|
+
archive,
|
|
359
|
+
onClick: onRowClick ? () => {
|
|
360
|
+
onRowClick(payload);
|
|
361
|
+
} : void 0,
|
|
362
|
+
onHashClick,
|
|
363
|
+
exploreDomain,
|
|
364
|
+
payload
|
|
365
|
+
}
|
|
366
|
+
)
|
|
367
|
+
},
|
|
368
|
+
`${hash}-${index}`
|
|
369
|
+
);
|
|
370
|
+
}),
|
|
371
|
+
children,
|
|
372
|
+
emptyRows ? Array.from({ length: emptyRows }).fill(/* @__PURE__ */ jsx4(PayloadTableRow, {})) : null
|
|
373
|
+
] });
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
// src/components/Table/TableFooter.tsx
|
|
377
|
+
import { styled, TablePagination as TablePagination2, TableRow as TableRow4 } from "@mui/material";
|
|
378
|
+
import { TableFooterEx } from "@xyo-network/react-table";
|
|
379
|
+
|
|
380
|
+
// src/components/Table/TablePagination.tsx
|
|
381
|
+
import { FirstPage as FirstPageIcon2, KeyboardArrowLeft as KeyboardArrowLeft2, KeyboardArrowRight as KeyboardArrowRight2, LastPage as LastPageIcon2 } from "@mui/icons-material";
|
|
382
|
+
import { Box as Box2, CircularProgress, IconButton as IconButton2, useTheme as useTheme2 } from "@mui/material";
|
|
383
|
+
import { useEvent } from "@xyo-network/react-event";
|
|
384
|
+
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
385
|
+
function TablePaginationActions2({ count, enableNextPage, loading, onPageChange, page, rowsPerPage }) {
|
|
386
|
+
const theme = useTheme2();
|
|
387
|
+
const [paginationRef, paginationDispatch] = useEvent();
|
|
388
|
+
const handleFirstPageButtonClick = (event) => {
|
|
389
|
+
paginationDispatch("firstPage", "click", "true");
|
|
390
|
+
onPageChange(event, 0);
|
|
391
|
+
};
|
|
392
|
+
const handleBackButtonClick = (event) => {
|
|
393
|
+
var _a;
|
|
394
|
+
paginationDispatch("previousPage", "click", (_a = page - 1) == null ? void 0 : _a.toString());
|
|
395
|
+
onPageChange(event, page - 1);
|
|
396
|
+
};
|
|
397
|
+
const handleNextButtonClick = (event) => {
|
|
398
|
+
var _a;
|
|
399
|
+
paginationDispatch("nextPage", "click", (_a = page + 1) == null ? void 0 : _a.toString());
|
|
400
|
+
onPageChange(event, page + 1);
|
|
401
|
+
};
|
|
402
|
+
const handleLastPageButtonClick = (event) => {
|
|
403
|
+
paginationDispatch("lastPage", "click", "true");
|
|
404
|
+
onPageChange(event, Math.max(0, Math.ceil(count / rowsPerPage) - 1));
|
|
405
|
+
};
|
|
406
|
+
return /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
407
|
+
loading ? /* @__PURE__ */ jsx5(CircularProgress, { size: "small", sx: { height: theme.spacing(2), position: "absolute", width: theme.spacing(2) } }) : null,
|
|
408
|
+
/* @__PURE__ */ jsxs4(Box2, { sx: { flexShrink: 0, ml: 2.5 }, children: [
|
|
409
|
+
/* @__PURE__ */ jsx5(IconButton2, { onClick: handleFirstPageButtonClick, disabled: page === 0, "aria-label": "first page", children: theme.direction === "rtl" ? /* @__PURE__ */ jsx5(LastPageIcon2, {}) : /* @__PURE__ */ jsx5(FirstPageIcon2, {}) }),
|
|
410
|
+
/* @__PURE__ */ jsx5(IconButton2, { ref: paginationRef, onClick: handleBackButtonClick, disabled: page === 0, "aria-label": "previous page", children: theme.direction === "rtl" ? /* @__PURE__ */ jsx5(KeyboardArrowRight2, {}) : /* @__PURE__ */ jsx5(KeyboardArrowLeft2, {}) }),
|
|
411
|
+
/* @__PURE__ */ jsx5(
|
|
412
|
+
IconButton2,
|
|
413
|
+
{
|
|
414
|
+
ref: paginationRef,
|
|
415
|
+
onClick: handleNextButtonClick,
|
|
416
|
+
disabled: !enableNextPage && page >= Math.ceil(count / rowsPerPage) - 1,
|
|
417
|
+
"aria-label": "next page",
|
|
418
|
+
children: theme.direction === "rtl" ? /* @__PURE__ */ jsx5(KeyboardArrowLeft2, {}) : /* @__PURE__ */ jsx5(KeyboardArrowRight2, {})
|
|
419
|
+
}
|
|
420
|
+
),
|
|
421
|
+
/* @__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, {}) })
|
|
422
|
+
] })
|
|
423
|
+
] });
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// src/components/Table/TableFooter.tsx
|
|
427
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
428
|
+
var PayloadTableFooter = ({
|
|
429
|
+
count,
|
|
430
|
+
variant,
|
|
431
|
+
page,
|
|
432
|
+
rowsPerPage,
|
|
433
|
+
handleChangePage = () => {
|
|
434
|
+
},
|
|
435
|
+
handleChangeRowsPerPage = () => {
|
|
436
|
+
},
|
|
437
|
+
fetchMorePayloads,
|
|
438
|
+
loading
|
|
439
|
+
}) => /* @__PURE__ */ jsx6(TableFooterEx, { variant, children: /* @__PURE__ */ jsx6(TableRow4, { children: /* @__PURE__ */ jsx6(
|
|
440
|
+
StyledTablePagination,
|
|
441
|
+
{
|
|
442
|
+
rowsPerPageOptions: [5, 10, 25, { label: "All", value: -1 }],
|
|
443
|
+
count: count ?? 0,
|
|
444
|
+
rowsPerPage: rowsPerPage ?? 10,
|
|
445
|
+
page: page ?? 0,
|
|
446
|
+
SelectProps: {
|
|
447
|
+
inputProps: {
|
|
448
|
+
"aria-label": "rows per page"
|
|
449
|
+
},
|
|
450
|
+
native: true
|
|
451
|
+
},
|
|
452
|
+
onPageChange: handleChangePage,
|
|
453
|
+
onRowsPerPageChange: handleChangeRowsPerPage,
|
|
454
|
+
ActionsComponent: (props) => /* @__PURE__ */ jsx6(TablePaginationActions2, { enableNextPage: !!fetchMorePayloads, loading, ...props })
|
|
455
|
+
}
|
|
456
|
+
) }) });
|
|
457
|
+
var StyledTablePagination = styled(TablePagination2)(({ theme }) => ({
|
|
458
|
+
"& > .MuiToolbar-root": {
|
|
459
|
+
paddingLeft: theme.spacing(1)
|
|
460
|
+
},
|
|
461
|
+
borderTop: "1px solid",
|
|
462
|
+
borderTopColor: theme.palette.divider
|
|
463
|
+
}));
|
|
464
|
+
|
|
465
|
+
// src/components/Table/TableHead.tsx
|
|
466
|
+
import { TableCell as TableCell4, TableHead as TableHead2, TableRow as TableRow5, Typography as Typography5 } from "@mui/material";
|
|
467
|
+
import { useBreakpoint as useBreakpoint4 } from "@xylabs/react-shared";
|
|
468
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
469
|
+
var PayloadTableHead = ({ columns = payloadTableColumnConfigDefaults(), ...props }) => {
|
|
470
|
+
var _a;
|
|
471
|
+
const breakPoint = useBreakpoint4();
|
|
472
|
+
return /* @__PURE__ */ jsx7(TableHead2, { ...props, children: /* @__PURE__ */ jsx7(TableRow5, { children: breakPoint && columns ? (_a = columns[breakPoint]) == null ? void 0 : _a.map((column, index) => {
|
|
473
|
+
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);
|
|
474
|
+
}) : null }) });
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
// src/components/Table/TableRowNoData.tsx
|
|
478
|
+
import { styled as styled2, TableCell as TableCell5, TableRow as TableRow6, Typography as Typography6 } from "@mui/material";
|
|
479
|
+
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
480
|
+
var TableRowNoData = ({ additionalCells, hideBorder = false, typographyProps, ...props }) => {
|
|
481
|
+
return /* @__PURE__ */ jsxs5(TableRow6, { ...props, children: [
|
|
482
|
+
/* @__PURE__ */ jsx8(StyledTableCell, { hideBorder, children: /* @__PURE__ */ jsx8(Typography6, { variant: "body2", ...typographyProps, children: "No Data To Display..." }) }),
|
|
483
|
+
additionalCells ? Array.from({ length: additionalCells }).fill(null).map((_fill, index) => /* @__PURE__ */ jsx8(StyledTableCell, { hideBorder }, index)) : null
|
|
484
|
+
] });
|
|
485
|
+
};
|
|
486
|
+
var StyledTableCell = styled2(TableCell5, {
|
|
487
|
+
name: "StyledTableCell",
|
|
488
|
+
shouldForwardProp: (prop) => prop !== "hideBorder"
|
|
489
|
+
})(({ hideBorder }) => ({
|
|
490
|
+
...hideBorder && { border: "none" }
|
|
491
|
+
}));
|
|
492
|
+
|
|
493
|
+
// src/components/Table/Table.tsx
|
|
494
|
+
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
495
|
+
var PayloadTableWithRef = forwardRef(
|
|
496
|
+
({
|
|
497
|
+
exploreDomain,
|
|
498
|
+
archive,
|
|
499
|
+
onHashClick,
|
|
500
|
+
onRowClick,
|
|
501
|
+
fetchMorePayloads,
|
|
502
|
+
rowsPerPage: rowsPerPageProp = 25,
|
|
503
|
+
payloads,
|
|
504
|
+
columns,
|
|
505
|
+
PayloadTableHeadComponent = PayloadTableHead,
|
|
506
|
+
PayloadTableBodyComponent = PayloadTableBody,
|
|
507
|
+
PayloadTableFooterComponent = PayloadTableFooter,
|
|
508
|
+
maxSchemaDepth,
|
|
509
|
+
count = 0,
|
|
510
|
+
loading = false,
|
|
511
|
+
variant = "scrollable",
|
|
512
|
+
...props
|
|
513
|
+
}, ref) => {
|
|
514
|
+
const [page, setPage] = useState2(0);
|
|
515
|
+
const [rowsPerPage, setRowsPerPage] = useState2(rowsPerPageProp);
|
|
516
|
+
const [visiblePayloads, setVisiblePayloads] = useState2([]);
|
|
517
|
+
const emptyRows = page > 0 ? Math.max(0, (1 + page) * rowsPerPage - count || 0) : 0;
|
|
518
|
+
useEffect2(() => {
|
|
519
|
+
setRowsPerPage(rowsPerPageProp);
|
|
520
|
+
}, [rowsPerPageProp]);
|
|
521
|
+
useEffect2(() => {
|
|
522
|
+
if (payloads) {
|
|
523
|
+
setVisiblePayloads(payloads.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage));
|
|
524
|
+
}
|
|
525
|
+
}, [count, page, payloads, rowsPerPage]);
|
|
526
|
+
useEffect2(() => {
|
|
527
|
+
setPage(0);
|
|
528
|
+
}, [payloads]);
|
|
529
|
+
const handleAdditionalPayloads = () => {
|
|
530
|
+
if (fetchMorePayloads && payloads) {
|
|
531
|
+
const buffer = rowsPerPage * 2;
|
|
532
|
+
const lastVisiblePayload = visiblePayloads == null ? void 0 : visiblePayloads.at(-1);
|
|
533
|
+
if (lastVisiblePayload) {
|
|
534
|
+
const lastVisibleIndex = payloads == null ? void 0 : payloads.indexOf(lastVisiblePayload);
|
|
535
|
+
if (lastVisibleIndex !== void 0 && payloads.length - (lastVisibleIndex + 1) <= buffer) {
|
|
536
|
+
fetchMorePayloads();
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
const handleChangePage = (_event, newPage) => {
|
|
542
|
+
handleAdditionalPayloads();
|
|
543
|
+
setPage(newPage);
|
|
544
|
+
};
|
|
545
|
+
const handleChangeRowsPerPage = (event) => {
|
|
546
|
+
setRowsPerPage(Number.parseInt(event.target.value, 10));
|
|
547
|
+
setPage(0);
|
|
548
|
+
};
|
|
549
|
+
const noResults = useMemo2(() => {
|
|
550
|
+
return !loading && (!visiblePayloads || visiblePayloads.length === 0);
|
|
551
|
+
}, [loading, visiblePayloads]);
|
|
552
|
+
return /* @__PURE__ */ jsxs6(TableEx, { variant, ref, ...props, children: [
|
|
553
|
+
/* @__PURE__ */ jsx9(PayloadTableHeadComponent, { columns }),
|
|
554
|
+
/* @__PURE__ */ jsx9(
|
|
555
|
+
PayloadTableBodyComponent,
|
|
556
|
+
{
|
|
557
|
+
payloads: visiblePayloads,
|
|
558
|
+
exploreDomain,
|
|
559
|
+
archive,
|
|
560
|
+
maxSchemaDepth,
|
|
561
|
+
onRowClick,
|
|
562
|
+
onHashClick,
|
|
563
|
+
emptyRows,
|
|
564
|
+
noResults,
|
|
565
|
+
NoResultRowComponent: TableRowNoData
|
|
566
|
+
}
|
|
567
|
+
),
|
|
568
|
+
/* @__PURE__ */ jsx9(
|
|
569
|
+
PayloadTableFooterComponent,
|
|
570
|
+
{
|
|
571
|
+
count,
|
|
572
|
+
variant,
|
|
573
|
+
rowsPerPage,
|
|
574
|
+
handleChangePage,
|
|
575
|
+
handleChangeRowsPerPage,
|
|
576
|
+
fetchMorePayloads,
|
|
577
|
+
loading,
|
|
578
|
+
page
|
|
579
|
+
}
|
|
580
|
+
)
|
|
581
|
+
] });
|
|
582
|
+
}
|
|
583
|
+
);
|
|
584
|
+
PayloadTableWithRef.displayName = "PayloadTable";
|
|
585
|
+
var PayloadTable = PayloadTableWithRef;
|
|
586
|
+
export {
|
|
587
|
+
PayloadDynamicTable,
|
|
588
|
+
PayloadDynamicTableRow,
|
|
589
|
+
PayloadTable,
|
|
590
|
+
PayloadTableRow,
|
|
591
|
+
PayloadTableWithRef,
|
|
592
|
+
TablePaginationActions2 as TablePaginationActions,
|
|
593
|
+
TableRowNoData,
|
|
594
|
+
payloadColumnNames,
|
|
595
|
+
payloadDynamicTableColumnConfigDefaults,
|
|
596
|
+
payloadTableColumnConfigDefaults
|
|
597
|
+
};
|
|
2
598
|
//# sourceMappingURL=index.js.map
|