@flipdish/portal-library 5.1.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/components/{GenericTableBody → molecules/GenericTable/GenericTableBody}/index.cjs.js +1 -1
  2. package/dist/components/molecules/GenericTable/GenericTableBody/index.cjs.js.map +1 -0
  3. package/dist/components/{GenericTableBody → molecules/GenericTable/GenericTableBody}/index.js +1 -1
  4. package/dist/components/molecules/GenericTable/GenericTableBody/index.js.map +1 -0
  5. package/dist/components/molecules/GenericTable/GenericTableBodyRow/index.cjs.js.map +1 -0
  6. package/dist/components/molecules/GenericTable/GenericTableBodyRow/index.js.map +1 -0
  7. package/dist/components/molecules/GenericTable/GenericTableTitle/index.cjs.js.map +1 -0
  8. package/dist/components/molecules/GenericTable/GenericTableTitle/index.js.map +1 -0
  9. package/dist/components/molecules/GenericTable/HighlightScrollbar.cjs.js +2 -0
  10. package/dist/components/molecules/GenericTable/HighlightScrollbar.cjs.js.map +1 -0
  11. package/dist/components/{GenericTable → molecules/GenericTable}/HighlightScrollbar.d.ts +2 -2
  12. package/dist/components/molecules/GenericTable/HighlightScrollbar.js +2 -0
  13. package/dist/components/molecules/GenericTable/HighlightScrollbar.js.map +1 -0
  14. package/dist/components/molecules/GenericTable/index.cjs.js +18 -0
  15. package/dist/components/molecules/GenericTable/index.cjs.js.map +1 -0
  16. package/dist/components/{GenericTable → molecules/GenericTable}/index.d.ts +1 -1
  17. package/dist/components/molecules/GenericTable/index.js +18 -0
  18. package/dist/components/molecules/GenericTable/index.js.map +1 -0
  19. package/dist/custom-hooks/useMicroFrontendAttributes.cjs.js +1 -1
  20. package/dist/custom-hooks/useMicroFrontendAttributes.cjs.js.map +1 -1
  21. package/dist/custom-hooks/useMicroFrontendAttributes.js +1 -1
  22. package/dist/custom-hooks/useMicroFrontendAttributes.js.map +1 -1
  23. package/dist/utilities/renderUtilities.cjs.js +1 -1
  24. package/dist/utilities/renderUtilities.cjs.js.map +1 -1
  25. package/dist/utilities/renderUtilities.d.ts +8 -4
  26. package/dist/utilities/renderUtilities.js +1 -1
  27. package/dist/utilities/renderUtilities.js.map +1 -1
  28. package/package.json +1 -1
  29. package/dist/components/GenericTable/HighlightScrollbar.cjs.js +0 -2
  30. package/dist/components/GenericTable/HighlightScrollbar.cjs.js.map +0 -1
  31. package/dist/components/GenericTable/HighlightScrollbar.js +0 -2
  32. package/dist/components/GenericTable/HighlightScrollbar.js.map +0 -1
  33. package/dist/components/GenericTable/index.cjs.js +0 -18
  34. package/dist/components/GenericTable/index.cjs.js.map +0 -1
  35. package/dist/components/GenericTable/index.js +0 -18
  36. package/dist/components/GenericTable/index.js.map +0 -1
  37. package/dist/components/GenericTableBody/index.cjs.js.map +0 -1
  38. package/dist/components/GenericTableBody/index.js.map +0 -1
  39. package/dist/components/GenericTableBodyRow/index.cjs.js.map +0 -1
  40. package/dist/components/GenericTableBodyRow/index.js.map +0 -1
  41. package/dist/components/GenericTableTitle/index.cjs.js.map +0 -1
  42. package/dist/components/GenericTableTitle/index.js.map +0 -1
  43. /package/dist/components/{GenericTableBody → molecules/GenericTable/GenericTableBody}/index.d.ts +0 -0
  44. /package/dist/components/{GenericTableBodyRow → molecules/GenericTable/GenericTableBodyRow}/index.cjs.js +0 -0
  45. /package/dist/components/{GenericTableBodyRow → molecules/GenericTable/GenericTableBodyRow}/index.d.ts +0 -0
  46. /package/dist/components/{GenericTableBodyRow → molecules/GenericTable/GenericTableBodyRow}/index.js +0 -0
  47. /package/dist/components/{GenericTableTitle → molecules/GenericTable/GenericTableTitle}/index.cjs.js +0 -0
  48. /package/dist/components/{GenericTableTitle → molecules/GenericTable/GenericTableTitle}/index.d.ts +0 -0
  49. /package/dist/components/{GenericTableTitle → molecules/GenericTable/GenericTableTitle}/index.js +0 -0
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material/Skeleton"),r=require("@mui/material/styles"),l=require("@mui/material/TableBody"),a=require("@mui/material/TableCell"),o=require("@mui/material/TableRow"),n=require("../GenericTableBodyRow/index.cjs.js");const s=r.styled(a,{shouldForwardProp:e=>"align"!==e&&"titleCell"!==e&&"warning"!==e&&"sticky"!==e&&"isTitleRow"!==e})((({align:e,titleCell:i,warning:t,sticky:r,isTitleRow:l})=>({textAlign:e,fontWeight:i||l?"bold":"normal",backgroundColor:t?"#ffcccb":"inherit",position:r?"sticky":"static"}))),c=({colIdx:t,colName:r,hasWarning:l,hasTitle:a,meta:o,row:n,type:c})=>{const d=n[r],m=o[r]?.align??"left",u=o[r]?.hideWhenEmpty??!1?"":"-",w={align:m,warning:l??!1,titleCell:a??!1,sticky:"sticky"===c&&0===t,"data-testid":`col-${r}`,isTitleRow:n.isTitleRow??!1};if(i.isValidElement(d))return e.jsx(s,{...w,children:d});switch(o[r]?.columnType){case"String":default:return e.jsx(s,{...w,children:d??u});case"Custom":return e.jsx(s,{...w,children:d?o[r]?.customComponent?.(d,n):u})}};module.exports=({columns:i,data:r,loading:a,type:d,onRowClick:m,meta:u})=>e.jsx(l,{children:a?Array.from(Array(5)).map(((r,l)=>e.jsx(o,{"data-testid":"row-loader",children:Array.from(i).map(((i,r)=>e.jsx(s,{align:"left","data-testid":`col-${i}`,isTitleRow:!1,sticky:!1,titleCell:!1,warning:!1,children:e.jsx(t,{height:22,width:"90%"})},`col-${i}-loader-${r}`)))},`row-loader-${l}`))):r?.map(((t,r)=>e.jsx(n,{row:t,tableRowTestKey:r.toString(),onRowClick:m,children:Array.from(i).map(((i,r)=>e.jsx(c,{colIdx:r,colName:i,meta:u??{},row:t,type:d},`cell-${i}-${r}`)))},`row-${r}`)))});
1
+ "use strict";var e=require("react/jsx-runtime"),i=require("react"),t=require("@mui/material/Skeleton"),r=require("@mui/material/styles"),l=require("@mui/material/TableBody"),a=require("@mui/material/TableCell"),o=require("@mui/material/TableRow"),n=require("../GenericTableBodyRow/index.cjs.js");const s=r.styled(a,{shouldForwardProp:e=>"align"!==e&&"titleCell"!==e&&"warning"!==e&&"sticky"!==e&&"isTitleRow"!==e})((({align:e,titleCell:i,warning:t,sticky:r,isTitleRow:l})=>({textAlign:e,fontWeight:i||l?"bold":"normal",backgroundColor:t?"#ffcccb":"inherit",position:r?"sticky":"static"}))),c=({colIdx:t,colName:r,hasWarning:l,hasTitle:a,meta:o,row:n,type:c})=>{const d=n[r],m=o[r]?.align??"left",u=o[r]?.hideWhenEmpty??!1?"":"-",w={align:m,warning:l??!1,titleCell:a??!1,sticky:"sticky"===c&&0===t,"data-testid":`col-${r}`,isTitleRow:n.isTitleRow??!1};if(i.isValidElement(d))return e.jsx(s,{...w,children:d});switch(o[r]?.columnType){case"String":default:return e.jsx(s,{...w,children:d??u});case"Custom":return e.jsx(s,{...w,children:d?o[r]?.customComponent?.(d,n):u})}};module.exports=({columns:i,data:r,loading:a,type:d,onRowClick:m,meta:u})=>e.jsx(l,{children:a?Array.from(Array(5)).map(((r,l)=>e.jsx(o,{"data-testid":"row-loader",children:Array.from(i).map(((i,r)=>e.jsx(s,{align:"left","data-testid":`col-${i}`,isTitleRow:!1,sticky:!1,titleCell:!1,warning:!1,children:e.jsx(t,{height:22,width:"90%"})},`col-${i}-loader-${r}`)))},`row-loader-${l}`))):r?.map(((t,r)=>e.jsx(n,{onRowClick:m,row:t,tableRowTestKey:r.toString(),children:Array.from(i).map(((i,r)=>e.jsx(c,{colIdx:r,colName:i,meta:u??{},row:t,type:d},`cell-${i}-${r}`)))},`row-${r}`)))});
2
2
  //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../../../../../src/components/molecules/GenericTable/GenericTableBody/index.tsx"],"sourcesContent":["import React from 'react';\n\nimport Skeleton from '@mui/material/Skeleton';\nimport { styled } from '@mui/material/styles';\nimport MuiTableBody from '@mui/material/TableBody';\nimport TableCell from '@mui/material/TableCell';\nimport TableRow from '@mui/material/TableRow';\n\nimport GenericTableBodyRow from '../GenericTableBodyRow';\n\nexport interface GenericTableColumns {\n columnName: string;\n columnTitle: string;\n columnType: 'Custom' | 'String';\n align?: 'left' | 'right';\n isVisible: boolean;\n ordinal: number;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n customComponent?: (data: any, row: any) => JSX.Element;\n tooltip?: string;\n hideWhenEmpty?: boolean;\n}\n\nconst StyledTableCell = styled(TableCell, {\n shouldForwardProp: (prop) =>\n prop !== 'align' &&\n prop !== 'titleCell' &&\n prop !== 'warning' &&\n prop !== 'sticky' &&\n prop !== 'isTitleRow',\n})<{ align: string; titleCell: boolean; warning: boolean; sticky: boolean; isTitleRow: boolean }>(\n ({ align, titleCell, warning, sticky, isTitleRow }) => ({\n textAlign: align,\n fontWeight: titleCell || isTitleRow ? 'bold' : 'normal',\n backgroundColor: warning ? '#ffcccb' : 'inherit',\n position: sticky ? 'sticky' : 'static',\n }),\n);\n\nexport interface TableCellProps {\n colIdx: number;\n colName: string;\n hasWarning?: boolean;\n hasTitle?: boolean;\n meta: { [key: string]: GenericTableColumns };\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n row: Record<string, any>;\n type: 'normal' | 'sticky';\n}\n\nconst RenderTableCell: React.FC<TableCellProps> = ({\n colIdx,\n colName,\n hasWarning,\n hasTitle,\n meta,\n row,\n type,\n}) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const prop = row[colName];\n const align = meta[colName]?.align ?? 'left';\n const hideWhenEmpty = meta[colName]?.hideWhenEmpty ?? false;\n const fallbackValue = hideWhenEmpty ? '' : '-';\n const tableCellProps = {\n align,\n warning: hasWarning ?? false,\n titleCell: hasTitle ?? false,\n sticky: type === 'sticky' && colIdx === 0,\n 'data-testid': `col-${colName}`,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n isTitleRow: row['isTitleRow'] ?? false,\n };\n\n // When prop is a React element render it as is\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n if (React.isValidElement(prop)) {\n return <StyledTableCell {...tableCellProps}>{prop}</StyledTableCell>;\n }\n\n switch (meta[colName]?.columnType) {\n case 'String':\n return <StyledTableCell {...tableCellProps}>{prop ?? fallbackValue}</StyledTableCell>;\n case 'Custom':\n return (\n <StyledTableCell {...tableCellProps}>\n {prop ? meta[colName]?.customComponent?.(prop, row) : fallbackValue}\n </StyledTableCell>\n );\n default:\n return <StyledTableCell {...tableCellProps}>{prop ?? fallbackValue}</StyledTableCell>;\n }\n};\n\ninterface TableBodyProps {\n columns: Set<string>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data?: any[];\n loading?: boolean;\n meta?: { [key: string]: GenericTableColumns };\n // eslint-disable-next-line @typescript-eslint/ban-types\n onRowClick?: Function;\n type: 'normal' | 'sticky';\n}\n\nconst GenericTableBody: React.FC<TableBodyProps> = ({ columns, data, loading, type, onRowClick, meta }) => {\n const rowsPerPage = 5;\n return (\n <MuiTableBody>\n {loading\n ? Array.from(Array(rowsPerPage)).map((_, idx) => (\n // eslint-disable-next-line react/no-array-index-key\n <TableRow key={`row-loader-${idx}`} data-testid=\"row-loader\">\n {Array.from(columns).map((columnName, colIdx) => (\n <StyledTableCell\n // eslint-disable-next-line react/no-array-index-key\n key={`col-${columnName}-loader-${colIdx}`}\n align={'left'}\n data-testid={`col-${columnName}`}\n isTitleRow={false}\n sticky={false}\n titleCell={false}\n warning={false}\n >\n <Skeleton height={22} width=\"90%\" />\n </StyledTableCell>\n ))}\n </TableRow>\n ))\n : data?.map((row, rowIdx) => (\n <GenericTableBodyRow\n // eslint-disable-next-line react/no-array-index-key\n key={`row-${rowIdx}`}\n onRowClick={onRowClick}\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n row={row}\n tableRowTestKey={rowIdx.toString()}\n >\n {Array.from(columns).map((colName, colIdx) => (\n <RenderTableCell\n // eslint-disable-next-line react/no-array-index-key\n key={`cell-${colName}-${colIdx}`}\n colIdx={colIdx}\n colName={colName}\n meta={meta ?? {}}\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n row={row}\n type={type}\n />\n ))}\n </GenericTableBodyRow>\n ))}\n </MuiTableBody>\n );\n};\n\nexport default GenericTableBody;\n"],"names":["StyledTableCell","styled","TableCell","shouldForwardProp","prop","align","titleCell","warning","sticky","isTitleRow","textAlign","fontWeight","backgroundColor","position","RenderTableCell","colIdx","colName","hasWarning","hasTitle","meta","row","type","fallbackValue","hideWhenEmpty","tableCellProps","React","isValidElement","_jsx","children","columnType","customComponent","columns","data","loading","onRowClick","MuiTableBody","Array","from","map","_","idx","TableRow","columnName","Skeleton","height","width","rowIdx","GenericTableBodyRow","tableRowTestKey","toString"],"mappings":"wSAuBA,MAAMA,EAAkBC,EAAAA,OAAOC,EAAW,CACxCC,kBAAoBC,GACT,UAATA,GACS,cAATA,GACS,YAATA,GACS,WAATA,GACS,eAATA,GANoBH,EAQtB,EAAGI,QAAOC,YAAWC,UAASC,SAAQC,iBAAY,CAChDC,UAAWL,EACXM,WAAYL,GAAaG,EAAa,OAAS,SAC/CG,gBAAiBL,EAAU,UAAY,UACvCM,SAAUL,EAAS,SAAW,aAe5BM,EAA4C,EAChDC,SACAC,UACAC,aACAC,WACAC,OACAC,MACAC,WAGA,MAAMjB,EAAOgB,EAAIJ,GACXX,EAAQc,EAAKH,IAAUX,OAAS,OAEhCiB,EADgBH,EAAKH,IAAUO,gBAAiB,EAChB,GAAK,IACrCC,EAAiB,CACrBnB,QACAE,QAASU,IAAc,EACvBX,UAAWY,IAAY,EACvBV,OAAiB,WAATa,GAAgC,IAAXN,EAC7B,cAAe,OAAOC,IAEtBP,WAAYW,EAAgB,aAAK,GAKnC,GAAIK,EAAMC,eAAetB,GACvB,OAAOuB,EAAAA,IAAC3B,EAAe,IAAKwB,EAAcI,SAAGxB,IAG/C,OAAQe,EAAKH,IAAUa,YACrB,IAAK,SAQL,QACE,OAAOF,EAAAA,IAAC3B,EAAe,IAAKwB,WAAiBpB,GAAQkB,IAPvD,IAAK,SACH,OACEK,EAAAA,IAAC3B,EAAe,IAAKwB,EAAcI,SAChCxB,EAAOe,EAAKH,IAAUc,kBAAkB1B,EAAMgB,GAAOE,qBAmBb,EAAGS,UAASC,OAAMC,UAASZ,OAAMa,aAAYf,UAG5FQ,EAAAA,IAACQ,EAAY,CAAAP,SACVK,EACGG,MAAMC,KAAKD,MAJC,IAImBE,KAAI,CAACC,EAAGC,IAErCb,EAAAA,IAACc,iBAA+C,aAAYb,SACzDQ,MAAMC,KAAKN,GAASO,KAAI,CAACI,EAAY3B,IACpCY,EAAAA,IAAC3B,GAGCK,MAAO,OAAM,cACA,OAAOqC,IACpBjC,YAAY,EACZD,QAAQ,EACRF,WAAW,EACXC,SAAS,EAAKqB,SAEdD,MAACgB,EAAQ,CAACC,OAAQ,GAAIC,MAAM,SARvB,OAAOH,YAAqB3B,QAJxB,cAAcyB,OAiB/BR,GAAMM,KAAI,CAAClB,EAAK0B,IACdnB,EAAAA,IAACoB,EAGC,CAAAb,WAAYA,EAEZd,IAAKA,EACL4B,gBAAiBF,EAAOG,WAAUrB,SAEjCQ,MAAMC,KAAKN,GAASO,KAAI,CAACtB,EAASD,IACjCY,EAAAA,IAACb,GAGCC,OAAQA,EACRC,QAASA,EACTG,KAAMA,GAAQ,CAAA,EAEdC,IAAKA,EACLC,KAAMA,GAND,QAAQL,KAAWD,QATvB,OAAO+B"}
@@ -1,2 +1,2 @@
1
- import{jsx as t}from"react/jsx-runtime";import i from"react";import e from"@mui/material/Skeleton";import{styled as r}from"@mui/material/styles";import l from"@mui/material/TableBody";import o from"@mui/material/TableCell";import a from"@mui/material/TableRow";import n from"../GenericTableBodyRow/index.js";const m=r(o,{shouldForwardProp:t=>"align"!==t&&"titleCell"!==t&&"warning"!==t&&"sticky"!==t&&"isTitleRow"!==t})((({align:t,titleCell:i,warning:e,sticky:r,isTitleRow:l})=>({textAlign:t,fontWeight:i||l?"bold":"normal",backgroundColor:e?"#ffcccb":"inherit",position:r?"sticky":"static"}))),c=({colIdx:e,colName:r,hasWarning:l,hasTitle:o,meta:a,row:n,type:c})=>{const s=n[r],d=a[r]?.align??"left",w=a[r]?.hideWhenEmpty??!1?"":"-",p={align:d,warning:l??!1,titleCell:o??!1,sticky:"sticky"===c&&0===e,"data-testid":`col-${r}`,isTitleRow:n.isTitleRow??!1};if(i.isValidElement(s))return t(m,{...p,children:s});switch(a[r]?.columnType){case"String":default:return t(m,{...p,children:s??w});case"Custom":return t(m,{...p,children:s?a[r]?.customComponent?.(s,n):w})}},s=({columns:i,data:r,loading:o,type:s,onRowClick:d,meta:w})=>t(l,{children:o?Array.from(Array(5)).map(((r,l)=>t(a,{"data-testid":"row-loader",children:Array.from(i).map(((i,r)=>t(m,{align:"left","data-testid":`col-${i}`,isTitleRow:!1,sticky:!1,titleCell:!1,warning:!1,children:t(e,{height:22,width:"90%"})},`col-${i}-loader-${r}`)))},`row-loader-${l}`))):r?.map(((e,r)=>t(n,{row:e,tableRowTestKey:r.toString(),onRowClick:d,children:Array.from(i).map(((i,r)=>t(c,{colIdx:r,colName:i,meta:w??{},row:e,type:s},`cell-${i}-${r}`)))},`row-${r}`)))});export{s as default};
1
+ import{jsx as t}from"react/jsx-runtime";import i from"react";import e from"@mui/material/Skeleton";import{styled as r}from"@mui/material/styles";import l from"@mui/material/TableBody";import o from"@mui/material/TableCell";import a from"@mui/material/TableRow";import n from"../GenericTableBodyRow/index.js";const m=r(o,{shouldForwardProp:t=>"align"!==t&&"titleCell"!==t&&"warning"!==t&&"sticky"!==t&&"isTitleRow"!==t})((({align:t,titleCell:i,warning:e,sticky:r,isTitleRow:l})=>({textAlign:t,fontWeight:i||l?"bold":"normal",backgroundColor:e?"#ffcccb":"inherit",position:r?"sticky":"static"}))),c=({colIdx:e,colName:r,hasWarning:l,hasTitle:o,meta:a,row:n,type:c})=>{const s=n[r],d=a[r]?.align??"left",w=a[r]?.hideWhenEmpty??!1?"":"-",p={align:d,warning:l??!1,titleCell:o??!1,sticky:"sticky"===c&&0===e,"data-testid":`col-${r}`,isTitleRow:n.isTitleRow??!1};if(i.isValidElement(s))return t(m,{...p,children:s});switch(a[r]?.columnType){case"String":default:return t(m,{...p,children:s??w});case"Custom":return t(m,{...p,children:s?a[r]?.customComponent?.(s,n):w})}},s=({columns:i,data:r,loading:o,type:s,onRowClick:d,meta:w})=>t(l,{children:o?Array.from(Array(5)).map(((r,l)=>t(a,{"data-testid":"row-loader",children:Array.from(i).map(((i,r)=>t(m,{align:"left","data-testid":`col-${i}`,isTitleRow:!1,sticky:!1,titleCell:!1,warning:!1,children:t(e,{height:22,width:"90%"})},`col-${i}-loader-${r}`)))},`row-loader-${l}`))):r?.map(((e,r)=>t(n,{onRowClick:d,row:e,tableRowTestKey:r.toString(),children:Array.from(i).map(((i,r)=>t(c,{colIdx:r,colName:i,meta:w??{},row:e,type:s},`cell-${i}-${r}`)))},`row-${r}`)))});export{s as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/components/molecules/GenericTable/GenericTableBody/index.tsx"],"sourcesContent":["import React from 'react';\n\nimport Skeleton from '@mui/material/Skeleton';\nimport { styled } from '@mui/material/styles';\nimport MuiTableBody from '@mui/material/TableBody';\nimport TableCell from '@mui/material/TableCell';\nimport TableRow from '@mui/material/TableRow';\n\nimport GenericTableBodyRow from '../GenericTableBodyRow';\n\nexport interface GenericTableColumns {\n columnName: string;\n columnTitle: string;\n columnType: 'Custom' | 'String';\n align?: 'left' | 'right';\n isVisible: boolean;\n ordinal: number;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n customComponent?: (data: any, row: any) => JSX.Element;\n tooltip?: string;\n hideWhenEmpty?: boolean;\n}\n\nconst StyledTableCell = styled(TableCell, {\n shouldForwardProp: (prop) =>\n prop !== 'align' &&\n prop !== 'titleCell' &&\n prop !== 'warning' &&\n prop !== 'sticky' &&\n prop !== 'isTitleRow',\n})<{ align: string; titleCell: boolean; warning: boolean; sticky: boolean; isTitleRow: boolean }>(\n ({ align, titleCell, warning, sticky, isTitleRow }) => ({\n textAlign: align,\n fontWeight: titleCell || isTitleRow ? 'bold' : 'normal',\n backgroundColor: warning ? '#ffcccb' : 'inherit',\n position: sticky ? 'sticky' : 'static',\n }),\n);\n\nexport interface TableCellProps {\n colIdx: number;\n colName: string;\n hasWarning?: boolean;\n hasTitle?: boolean;\n meta: { [key: string]: GenericTableColumns };\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n row: Record<string, any>;\n type: 'normal' | 'sticky';\n}\n\nconst RenderTableCell: React.FC<TableCellProps> = ({\n colIdx,\n colName,\n hasWarning,\n hasTitle,\n meta,\n row,\n type,\n}) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const prop = row[colName];\n const align = meta[colName]?.align ?? 'left';\n const hideWhenEmpty = meta[colName]?.hideWhenEmpty ?? false;\n const fallbackValue = hideWhenEmpty ? '' : '-';\n const tableCellProps = {\n align,\n warning: hasWarning ?? false,\n titleCell: hasTitle ?? false,\n sticky: type === 'sticky' && colIdx === 0,\n 'data-testid': `col-${colName}`,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n isTitleRow: row['isTitleRow'] ?? false,\n };\n\n // When prop is a React element render it as is\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n if (React.isValidElement(prop)) {\n return <StyledTableCell {...tableCellProps}>{prop}</StyledTableCell>;\n }\n\n switch (meta[colName]?.columnType) {\n case 'String':\n return <StyledTableCell {...tableCellProps}>{prop ?? fallbackValue}</StyledTableCell>;\n case 'Custom':\n return (\n <StyledTableCell {...tableCellProps}>\n {prop ? meta[colName]?.customComponent?.(prop, row) : fallbackValue}\n </StyledTableCell>\n );\n default:\n return <StyledTableCell {...tableCellProps}>{prop ?? fallbackValue}</StyledTableCell>;\n }\n};\n\ninterface TableBodyProps {\n columns: Set<string>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data?: any[];\n loading?: boolean;\n meta?: { [key: string]: GenericTableColumns };\n // eslint-disable-next-line @typescript-eslint/ban-types\n onRowClick?: Function;\n type: 'normal' | 'sticky';\n}\n\nconst GenericTableBody: React.FC<TableBodyProps> = ({ columns, data, loading, type, onRowClick, meta }) => {\n const rowsPerPage = 5;\n return (\n <MuiTableBody>\n {loading\n ? Array.from(Array(rowsPerPage)).map((_, idx) => (\n // eslint-disable-next-line react/no-array-index-key\n <TableRow key={`row-loader-${idx}`} data-testid=\"row-loader\">\n {Array.from(columns).map((columnName, colIdx) => (\n <StyledTableCell\n // eslint-disable-next-line react/no-array-index-key\n key={`col-${columnName}-loader-${colIdx}`}\n align={'left'}\n data-testid={`col-${columnName}`}\n isTitleRow={false}\n sticky={false}\n titleCell={false}\n warning={false}\n >\n <Skeleton height={22} width=\"90%\" />\n </StyledTableCell>\n ))}\n </TableRow>\n ))\n : data?.map((row, rowIdx) => (\n <GenericTableBodyRow\n // eslint-disable-next-line react/no-array-index-key\n key={`row-${rowIdx}`}\n onRowClick={onRowClick}\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n row={row}\n tableRowTestKey={rowIdx.toString()}\n >\n {Array.from(columns).map((colName, colIdx) => (\n <RenderTableCell\n // eslint-disable-next-line react/no-array-index-key\n key={`cell-${colName}-${colIdx}`}\n colIdx={colIdx}\n colName={colName}\n meta={meta ?? {}}\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n row={row}\n type={type}\n />\n ))}\n </GenericTableBodyRow>\n ))}\n </MuiTableBody>\n );\n};\n\nexport default GenericTableBody;\n"],"names":["StyledTableCell","styled","TableCell","shouldForwardProp","prop","align","titleCell","warning","sticky","isTitleRow","textAlign","fontWeight","backgroundColor","position","RenderTableCell","colIdx","colName","hasWarning","hasTitle","meta","row","type","fallbackValue","hideWhenEmpty","tableCellProps","React","isValidElement","_jsx","children","columnType","customComponent","GenericTableBody","columns","data","loading","onRowClick","MuiTableBody","Array","from","map","_","idx","TableRow","columnName","Skeleton","height","width","rowIdx","GenericTableBodyRow","tableRowTestKey","toString"],"mappings":"oTAuBA,MAAMA,EAAkBC,EAAOC,EAAW,CACxCC,kBAAoBC,GACT,UAATA,GACS,cAATA,GACS,YAATA,GACS,WAATA,GACS,eAATA,GANoBH,EAQtB,EAAGI,QAAOC,YAAWC,UAASC,SAAQC,iBAAY,CAChDC,UAAWL,EACXM,WAAYL,GAAaG,EAAa,OAAS,SAC/CG,gBAAiBL,EAAU,UAAY,UACvCM,SAAUL,EAAS,SAAW,aAe5BM,EAA4C,EAChDC,SACAC,UACAC,aACAC,WACAC,OACAC,MACAC,WAGA,MAAMjB,EAAOgB,EAAIJ,GACXX,EAAQc,EAAKH,IAAUX,OAAS,OAEhCiB,EADgBH,EAAKH,IAAUO,gBAAiB,EAChB,GAAK,IACrCC,EAAiB,CACrBnB,QACAE,QAASU,IAAc,EACvBX,UAAWY,IAAY,EACvBV,OAAiB,WAATa,GAAgC,IAAXN,EAC7B,cAAe,OAAOC,IAEtBP,WAAYW,EAAgB,aAAK,GAKnC,GAAIK,EAAMC,eAAetB,GACvB,OAAOuB,EAAC3B,EAAe,IAAKwB,EAAcI,SAAGxB,IAG/C,OAAQe,EAAKH,IAAUa,YACrB,IAAK,SAQL,QACE,OAAOF,EAAC3B,EAAe,IAAKwB,WAAiBpB,GAAQkB,IAPvD,IAAK,SACH,OACEK,EAAC3B,EAAe,IAAKwB,EAAcI,SAChCxB,EAAOe,EAAKH,IAAUc,kBAAkB1B,EAAMgB,GAAOE,MAmB1DS,EAA6C,EAAGC,UAASC,OAAMC,UAASb,OAAMc,aAAYhB,UAG5FQ,EAACS,EAAY,CAAAR,SACVM,EACGG,MAAMC,KAAKD,MAJC,IAImBE,KAAI,CAACC,EAAGC,IAErCd,EAACe,iBAA+C,aAAYd,SACzDS,MAAMC,KAAKN,GAASO,KAAI,CAACI,EAAY5B,IACpCY,EAAC3B,GAGCK,MAAO,OAAM,cACA,OAAOsC,IACpBlC,YAAY,EACZD,QAAQ,EACRF,WAAW,EACXC,SAAS,EAAKqB,SAEdD,EAACiB,EAAQ,CAACC,OAAQ,GAAIC,MAAM,SARvB,OAAOH,YAAqB5B,QAJxB,cAAc0B,OAiB/BR,GAAMM,KAAI,CAACnB,EAAK2B,IACdpB,EAACqB,EAGC,CAAAb,WAAYA,EAEZf,IAAKA,EACL6B,gBAAiBF,EAAOG,WAAUtB,SAEjCS,MAAMC,KAAKN,GAASO,KAAI,CAACvB,EAASD,IACjCY,EAACb,GAGCC,OAAQA,EACRC,QAASA,EACTG,KAAMA,GAAQ,CAAA,EAEdC,IAAKA,EACLC,KAAMA,GAND,QAAQL,KAAWD,QATvB,OAAOgC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../../../../../src/components/molecules/GenericTable/GenericTableBodyRow/index.tsx"],"sourcesContent":["import React from 'react';\n\nimport { styled } from '@mui/material/styles';\nimport TableRow from '@mui/material/TableRow';\n\nexport interface TableBodyRowProps {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n row: any;\n // eslint-disable-next-line @typescript-eslint/ban-types\n onRowClick?: Function;\n tableRowTestKey: string;\n}\n\nconst StyledTableRow = styled(TableRow, {\n shouldForwardProp: (prop) => prop !== 'isTitleRow',\n})<{ isTitleRow: boolean }>(({ theme, isTitleRow }) => {\n if (!isTitleRow) {\n return {};\n }\n\n return {\n backgroundColor: theme.palette.semantic.background['background-sunken'],\n };\n});\n\ntype TableBodyRowProp = TableBodyRowProps & { children: React.ReactNode };\n\nconst GenericTableBodyRow: React.FC<React.PropsWithChildren<TableBodyRowProp>> = (props) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const { onRowClick, row, children, tableRowTestKey } = props;\n\n const onClick = (event: React.MouseEvent<HTMLTableRowElement>): void => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n event.preventDefault();\n onRowClick?.(row);\n };\n\n if (onRowClick) {\n return (\n <StyledTableRow\n data-testid={`row-clickable-${tableRowTestKey}`}\n hover={onClick !== undefined}\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n isTitleRow={row['isTitleRow'] ?? false}\n onClick={onClick}\n >\n {children}\n </StyledTableRow>\n );\n }\n\n return <TableRow data-testid={`row-${tableRowTestKey}`}>{children}</TableRow>;\n};\n\nexport default GenericTableBodyRow;\n"],"names":["StyledTableRow","styled","TableRow","shouldForwardProp","prop","theme","isTitleRow","backgroundColor","palette","semantic","background","props","onRowClick","row","children","tableRowTestKey","onClick","event","preventDefault","_jsx","hover","undefined"],"mappings":"2IAaA,MAAMA,EAAiBC,EAAAA,OAAOC,EAAU,CACtCC,kBAAoBC,GAAkB,eAATA,GADRH,EAEK,EAAGI,QAAOC,gBAC/BA,EAIE,CACLC,gBAAiBF,EAAMG,QAAQC,SAASC,WAAW,sBAJ5C,CAAA,mBAUuEC,IAEhF,MAAMC,WAAEA,EAAUC,IAAEA,EAAGC,SAAEA,EAAQC,gBAAEA,GAAoBJ,EAEjDK,EAAWC,IAEfA,EAAMC,iBACNN,IAAaC,IAGf,OAAID,EAEAO,EAAAA,IAACnB,EAAc,CAAA,cACA,iBAAiBe,IAC9BK,WAAmBC,IAAZL,EAEPV,WAAYO,EAAgB,aAAK,EACjCG,QAASA,EAAOF,SAEfA,IAKAK,EAAAA,IAACjB,EAAQ,CAAA,cAAc,OAAOa,IAAiBD,SAAGA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/components/molecules/GenericTable/GenericTableBodyRow/index.tsx"],"sourcesContent":["import React from 'react';\n\nimport { styled } from '@mui/material/styles';\nimport TableRow from '@mui/material/TableRow';\n\nexport interface TableBodyRowProps {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n row: any;\n // eslint-disable-next-line @typescript-eslint/ban-types\n onRowClick?: Function;\n tableRowTestKey: string;\n}\n\nconst StyledTableRow = styled(TableRow, {\n shouldForwardProp: (prop) => prop !== 'isTitleRow',\n})<{ isTitleRow: boolean }>(({ theme, isTitleRow }) => {\n if (!isTitleRow) {\n return {};\n }\n\n return {\n backgroundColor: theme.palette.semantic.background['background-sunken'],\n };\n});\n\ntype TableBodyRowProp = TableBodyRowProps & { children: React.ReactNode };\n\nconst GenericTableBodyRow: React.FC<React.PropsWithChildren<TableBodyRowProp>> = (props) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const { onRowClick, row, children, tableRowTestKey } = props;\n\n const onClick = (event: React.MouseEvent<HTMLTableRowElement>): void => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n event.preventDefault();\n onRowClick?.(row);\n };\n\n if (onRowClick) {\n return (\n <StyledTableRow\n data-testid={`row-clickable-${tableRowTestKey}`}\n hover={onClick !== undefined}\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n isTitleRow={row['isTitleRow'] ?? false}\n onClick={onClick}\n >\n {children}\n </StyledTableRow>\n );\n }\n\n return <TableRow data-testid={`row-${tableRowTestKey}`}>{children}</TableRow>;\n};\n\nexport default GenericTableBodyRow;\n"],"names":["StyledTableRow","styled","TableRow","shouldForwardProp","prop","theme","isTitleRow","backgroundColor","palette","semantic","background","GenericTableBodyRow","props","onRowClick","row","children","tableRowTestKey","onClick","event","preventDefault","_jsx","hover","undefined"],"mappings":"0IAaA,MAAMA,EAAiBC,EAAOC,EAAU,CACtCC,kBAAoBC,GAAkB,eAATA,GADRH,EAEK,EAAGI,QAAOC,gBAC/BA,EAIE,CACLC,gBAAiBF,EAAMG,QAAQC,SAASC,WAAW,sBAJ5C,CAAA,IAULC,EAA4EC,IAEhF,MAAMC,WAAEA,EAAUC,IAAEA,EAAGC,SAAEA,EAAQC,gBAAEA,GAAoBJ,EAEjDK,EAAWC,IAEfA,EAAMC,iBACNN,IAAaC,IAGf,OAAID,EAEAO,EAACpB,EAAc,CAAA,cACA,iBAAiBgB,IAC9BK,WAAmBC,IAAZL,EAEPX,WAAYQ,EAAgB,aAAK,EACjCG,QAASA,EAAOF,SAEfA,IAKAK,EAAClB,EAAQ,CAAA,cAAc,OAAOc,IAAiBD,SAAGA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../../../../../src/components/molecules/GenericTable/GenericTableTitle/index.tsx"],"sourcesContent":["import { type ReactNode } from 'react';\n\nimport { styled } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\n\nimport Grid, { type GridSize } from '../../../atoms/Grid';\n\ninterface OuterProps {\n maxGridWidth?: GridSize;\n subTitle?: string;\n title?: string;\n children?: ReactNode;\n titlePadding?: 'medium' | 'small';\n}\n\nconst HeaderContainer = styled(Grid, {\n shouldForwardProp: (prop) => prop !== 'titlePadding',\n})<{ titlePadding: OuterProps['titlePadding'] }>(({ theme, titlePadding }) => {\n switch (titlePadding) {\n case 'small':\n return {\n padding: theme.spacing(3, 0, 1.5),\n [theme.breakpoints.down('tablet')]: {\n padding: theme.spacing(3, 2, 1.5),\n },\n };\n case 'medium':\n return {\n padding: theme.spacing(4, 0, 2),\n [theme.breakpoints.down('tablet')]: {\n padding: theme.spacing(4, 2, 2),\n },\n };\n default:\n return { padding: 0 };\n }\n});\n\nconst SubTitle = styled(Typography)({\n width: 191,\n height: 16,\n fontSize: 12,\n fontWeight: 'normal',\n lineHeight: 1.33,\n letterSpacing: 0.4,\n color: 'rgba(0, 0, 0, 0.38)',\n});\n\nconst GenericTableTitle = ({\n maxGridWidth = 12,\n subTitle,\n title,\n children,\n titlePadding = 'medium',\n}: OuterProps): JSX.Element => {\n return (\n <HeaderContainer container titlePadding={titlePadding}>\n <Grid size={{ base: maxGridWidth, mobile: maxGridWidth }}>\n {title && <Typography variant=\"h5\">{title}</Typography>}\n {subTitle && (\n <div>\n <SubTitle variant=\"caption\">{subTitle}</SubTitle>\n </div>\n )}\n </Grid>\n\n {children}\n </HeaderContainer>\n );\n};\n\nexport default GenericTableTitle;\n"],"names":["HeaderContainer","styled","Grid","shouldForwardProp","prop","theme","titlePadding","padding","spacing","breakpoints","down","SubTitle","Typography","width","height","fontSize","fontWeight","lineHeight","letterSpacing","color","maxGridWidth","subTitle","title","children","_jsxs","container","size","base","mobile","_jsx","variant"],"mappings":"8KAeA,MAAMA,EAAkBC,EAAAA,OAAOC,EAAM,CACnCC,kBAAoBC,GAAkB,iBAATA,GADPH,EAEyB,EAAGI,QAAOC,mBACzD,OAAQA,GACN,IAAK,QACH,MAAO,CACLC,QAASF,EAAMG,QAAQ,EAAG,EAAG,KAC7B,CAACH,EAAMI,YAAYC,KAAK,WAAY,CAClCH,QAASF,EAAMG,QAAQ,EAAG,EAAG,OAGnC,IAAK,SACH,MAAO,CACLD,QAASF,EAAMG,QAAQ,EAAG,EAAG,GAC7B,CAACH,EAAMI,YAAYC,KAAK,WAAY,CAClCH,QAASF,EAAMG,QAAQ,EAAG,EAAG,KAGnC,QACE,MAAO,CAAED,QAAS,OAIlBI,EAAWV,EAAAA,OAAOW,EAAPX,CAAmB,CAClCY,MAAO,IACPC,OAAQ,GACRC,SAAU,GACVC,WAAY,SACZC,WAAY,KACZC,cAAe,GACfC,MAAO,uCAGiB,EACxBC,eAAe,GACfC,WACAC,QACAC,WACAjB,eAAe,YAGbkB,EAAAA,KAACxB,EAAe,CAACyB,WAAS,EAACnB,aAAcA,EAAYiB,SAAA,CACnDC,OAACtB,EAAI,CAACwB,KAAM,CAAEC,KAAMP,EAAcQ,OAAQR,GAAcG,SAAA,CACrDD,GAASO,EAAAA,IAACjB,EAAU,CAACkB,QAAQ,KAAIP,SAAED,IACnCD,GACCQ,EAAAA,IAAA,MAAA,CAAAN,SACEM,MAAClB,EAAQ,CAACmB,QAAQ,UAASP,SAAEF,SAKlCE"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/components/molecules/GenericTable/GenericTableTitle/index.tsx"],"sourcesContent":["import { type ReactNode } from 'react';\n\nimport { styled } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\n\nimport Grid, { type GridSize } from '../../../atoms/Grid';\n\ninterface OuterProps {\n maxGridWidth?: GridSize;\n subTitle?: string;\n title?: string;\n children?: ReactNode;\n titlePadding?: 'medium' | 'small';\n}\n\nconst HeaderContainer = styled(Grid, {\n shouldForwardProp: (prop) => prop !== 'titlePadding',\n})<{ titlePadding: OuterProps['titlePadding'] }>(({ theme, titlePadding }) => {\n switch (titlePadding) {\n case 'small':\n return {\n padding: theme.spacing(3, 0, 1.5),\n [theme.breakpoints.down('tablet')]: {\n padding: theme.spacing(3, 2, 1.5),\n },\n };\n case 'medium':\n return {\n padding: theme.spacing(4, 0, 2),\n [theme.breakpoints.down('tablet')]: {\n padding: theme.spacing(4, 2, 2),\n },\n };\n default:\n return { padding: 0 };\n }\n});\n\nconst SubTitle = styled(Typography)({\n width: 191,\n height: 16,\n fontSize: 12,\n fontWeight: 'normal',\n lineHeight: 1.33,\n letterSpacing: 0.4,\n color: 'rgba(0, 0, 0, 0.38)',\n});\n\nconst GenericTableTitle = ({\n maxGridWidth = 12,\n subTitle,\n title,\n children,\n titlePadding = 'medium',\n}: OuterProps): JSX.Element => {\n return (\n <HeaderContainer container titlePadding={titlePadding}>\n <Grid size={{ base: maxGridWidth, mobile: maxGridWidth }}>\n {title && <Typography variant=\"h5\">{title}</Typography>}\n {subTitle && (\n <div>\n <SubTitle variant=\"caption\">{subTitle}</SubTitle>\n </div>\n )}\n </Grid>\n\n {children}\n </HeaderContainer>\n );\n};\n\nexport default GenericTableTitle;\n"],"names":["HeaderContainer","styled","Grid","shouldForwardProp","prop","theme","titlePadding","padding","spacing","breakpoints","down","SubTitle","Typography","width","height","fontSize","fontWeight","lineHeight","letterSpacing","color","GenericTableTitle","maxGridWidth","subTitle","title","children","_jsxs","container","size","base","mobile","_jsx","variant"],"mappings":"yLAeA,MAAMA,EAAkBC,EAAOC,EAAM,CACnCC,kBAAoBC,GAAkB,iBAATA,GADPH,EAEyB,EAAGI,QAAOC,mBACzD,OAAQA,GACN,IAAK,QACH,MAAO,CACLC,QAASF,EAAMG,QAAQ,EAAG,EAAG,KAC7B,CAACH,EAAMI,YAAYC,KAAK,WAAY,CAClCH,QAASF,EAAMG,QAAQ,EAAG,EAAG,OAGnC,IAAK,SACH,MAAO,CACLD,QAASF,EAAMG,QAAQ,EAAG,EAAG,GAC7B,CAACH,EAAMI,YAAYC,KAAK,WAAY,CAClCH,QAASF,EAAMG,QAAQ,EAAG,EAAG,KAGnC,QACE,MAAO,CAAED,QAAS,OAIlBI,EAAWV,EAAOW,EAAPX,CAAmB,CAClCY,MAAO,IACPC,OAAQ,GACRC,SAAU,GACVC,WAAY,SACZC,WAAY,KACZC,cAAe,GACfC,MAAO,wBAGHC,EAAoB,EACxBC,eAAe,GACfC,WACAC,QACAC,WACAlB,eAAe,YAGbmB,EAACzB,EAAe,CAAC0B,WAAS,EAACpB,aAAcA,EAAYkB,SAAA,CACnDC,EAACvB,EAAI,CAACyB,KAAM,CAAEC,KAAMP,EAAcQ,OAAQR,GAAcG,SAAA,CACrDD,GAASO,EAAClB,EAAU,CAACmB,QAAQ,KAAIP,SAAED,IACnCD,GACCQ,EAAA,MAAA,CAAAN,SACEM,EAACnB,EAAQ,CAACoB,QAAQ,UAASP,SAAEF,SAKlCE"}
@@ -0,0 +1,2 @@
1
+ "use strict";var e=require("react/jsx-runtime"),r=require("react");const t=require("@mui/material/styles").styled("div")((({hovered:e,isScrolling:r,theme:t})=>({overflowX:"auto","&::-webkit-scrollbar":{padding:"2px 0",height:"6px",border:`1px solid ${t.palette.divider}`},"&::-webkit-scrollbar-track":{background:t.palette.background.paper},"&::-webkit-scrollbar-thumb":{background:e?"rgba(5, 20, 158, 0.3)":t.palette.background.paper,borderRadius:"3px"},"&::-webkit-scrollbar-thumb:horizontal:active, &::-webkit-scrollbar-thumb:vertical:active":{background:e?"rgba(5, 20, 158, 0.6)":t.palette.background.paper},"&:hover .sticky":{boxShadow:r?`0px 2px 6px ${t.palette.background.paper}`:"none",transition:"box-shadow 200ms"}})));module.exports=o=>{const{children:a,onScroll:l,setIsScrolling:i,setScrollStarted:c}=o,[s,n]=r.useState(!1);return e.jsx(t,{hovered:s,isScrolling:!!i,onMouseEnter:()=>n(!0),onMouseLeave:()=>{n(!1),i&&i(!1),c&&c(!1)},onScroll:l,children:a})};
2
+ //# sourceMappingURL=HighlightScrollbar.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HighlightScrollbar.cjs.js","sources":["../../../../src/components/molecules/GenericTable/HighlightScrollbar.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport styled from '@fd/utilities/styledUtilities';\n\ninterface HighlightScrollbarProps {\n children: React.ReactNode;\n onScroll?: () => void;\n setIsScrolling?: React.Dispatch<React.SetStateAction<boolean>>;\n setScrollStarted?: React.Dispatch<React.SetStateAction<boolean>>;\n}\n\ninterface ContainerProps {\n hovered: boolean;\n isScrolling: boolean;\n}\n\nconst StyledContainer = styled('div')<ContainerProps>(({ hovered, isScrolling, theme }) => ({\n overflowX: 'auto',\n '&::-webkit-scrollbar': {\n padding: '2px 0',\n height: '6px',\n border: `1px solid ${theme.palette.divider}`,\n },\n '&::-webkit-scrollbar-track': {\n background: theme.palette.background.paper,\n },\n '&::-webkit-scrollbar-thumb': {\n background: hovered ? 'rgba(5, 20, 158, 0.3)' : theme.palette.background.paper,\n borderRadius: '3px',\n },\n '&::-webkit-scrollbar-thumb:horizontal:active, &::-webkit-scrollbar-thumb:vertical:active': {\n background: hovered ? 'rgba(5, 20, 158, 0.6)' : theme.palette.background.paper,\n },\n '&:hover .sticky': {\n boxShadow: isScrolling ? `0px 2px 6px ${theme.palette.background.paper}` : 'none',\n transition: 'box-shadow 200ms',\n },\n}));\n\nconst HighlightScrollbar: React.FC<React.PropsWithChildren<HighlightScrollbarProps>> = (props) => {\n const { children, onScroll, setIsScrolling, setScrollStarted } = props;\n const [hoveredTable, setHoveredTable] = useState(false);\n\n const highlightScrollbar = () => setHoveredTable(true);\n\n const fadeScrollbar = () => {\n setHoveredTable(false);\n if (setIsScrolling) setIsScrolling(false);\n if (setScrollStarted) setScrollStarted(false);\n };\n\n return (\n <StyledContainer\n hovered={hoveredTable}\n isScrolling={!!setIsScrolling}\n onMouseEnter={highlightScrollbar}\n onMouseLeave={fadeScrollbar}\n onScroll={onScroll}\n >\n {children}\n </StyledContainer>\n );\n};\n\nexport default HighlightScrollbar;\n"],"names":["StyledContainer","styled","hovered","isScrolling","theme","overflowX","padding","height","border","palette","divider","background","paper","borderRadius","boxShadow","transition","props","children","onScroll","setIsScrolling","setScrollStarted","hoveredTable","setHoveredTable","useState","_jsx","onMouseEnter","onMouseLeave"],"mappings":"mEAgBA,MAAMA,kCAAkBC,OAAO,MAAPA,EAA8B,EAAGC,UAASC,cAAaC,YAAO,CACpFC,UAAW,OACX,uBAAwB,CACtBC,QAAS,QACTC,OAAQ,MACRC,OAAQ,aAAaJ,EAAMK,QAAQC,WAErC,6BAA8B,CAC5BC,WAAYP,EAAMK,QAAQE,WAAWC,OAEvC,6BAA8B,CAC5BD,WAAYT,EAAU,wBAA0BE,EAAMK,QAAQE,WAAWC,MACzEC,aAAc,OAEhB,2FAA4F,CAC1FF,WAAYT,EAAU,wBAA0BE,EAAMK,QAAQE,WAAWC,OAE3E,kBAAmB,CACjBE,UAAWX,EAAc,eAAeC,EAAMK,QAAQE,WAAWC,QAAU,OAC3EG,WAAY,uCAIwEC,IACtF,MAAMC,SAAEA,EAAQC,SAAEA,EAAQC,eAAEA,EAAcC,iBAAEA,GAAqBJ,GAC1DK,EAAcC,GAAmBC,EAAAA,UAAS,GAUjD,OACEC,EAAAA,IAACxB,EAAe,CACdE,QAASmB,EACTlB,cAAegB,EACfM,aAZuB,IAAMH,GAAgB,GAa7CI,aAXkB,KACpBJ,GAAgB,GACZH,GAAgBA,GAAe,GAC/BC,GAAkBA,GAAiB,IASrCF,SAAUA,EAAQD,SAEjBA"}
@@ -1,11 +1,11 @@
1
1
  import react__default from 'react';
2
2
 
3
- type HighlightScrollbarProps = {
3
+ interface HighlightScrollbarProps {
4
4
  children: react__default.ReactNode;
5
5
  onScroll?: () => void;
6
6
  setIsScrolling?: react__default.Dispatch<react__default.SetStateAction<boolean>>;
7
7
  setScrollStarted?: react__default.Dispatch<react__default.SetStateAction<boolean>>;
8
- };
8
+ }
9
9
  declare const HighlightScrollbar: react__default.FC<react__default.PropsWithChildren<HighlightScrollbarProps>>;
10
10
 
11
11
  export { HighlightScrollbar as default };
@@ -0,0 +1,2 @@
1
+ import{jsx as r}from"react/jsx-runtime";import{useState as e}from"react";import{styled as o}from"@mui/material/styles";const t=o("div")((({hovered:r,isScrolling:e,theme:o})=>({overflowX:"auto","&::-webkit-scrollbar":{padding:"2px 0",height:"6px",border:`1px solid ${o.palette.divider}`},"&::-webkit-scrollbar-track":{background:o.palette.background.paper},"&::-webkit-scrollbar-thumb":{background:r?"rgba(5, 20, 158, 0.3)":o.palette.background.paper,borderRadius:"3px"},"&::-webkit-scrollbar-thumb:horizontal:active, &::-webkit-scrollbar-thumb:vertical:active":{background:r?"rgba(5, 20, 158, 0.6)":o.palette.background.paper},"&:hover .sticky":{boxShadow:e?`0px 2px 6px ${o.palette.background.paper}`:"none",transition:"box-shadow 200ms"}}))),a=o=>{const{children:a,onScroll:l,setIsScrolling:i,setScrollStarted:c}=o,[n,b]=e(!1);return r(t,{hovered:n,isScrolling:!!i,onMouseEnter:()=>b(!0),onMouseLeave:()=>{b(!1),i&&i(!1),c&&c(!1)},onScroll:l,children:a})};export{a as default};
2
+ //# sourceMappingURL=HighlightScrollbar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HighlightScrollbar.js","sources":["../../../../src/components/molecules/GenericTable/HighlightScrollbar.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport styled from '@fd/utilities/styledUtilities';\n\ninterface HighlightScrollbarProps {\n children: React.ReactNode;\n onScroll?: () => void;\n setIsScrolling?: React.Dispatch<React.SetStateAction<boolean>>;\n setScrollStarted?: React.Dispatch<React.SetStateAction<boolean>>;\n}\n\ninterface ContainerProps {\n hovered: boolean;\n isScrolling: boolean;\n}\n\nconst StyledContainer = styled('div')<ContainerProps>(({ hovered, isScrolling, theme }) => ({\n overflowX: 'auto',\n '&::-webkit-scrollbar': {\n padding: '2px 0',\n height: '6px',\n border: `1px solid ${theme.palette.divider}`,\n },\n '&::-webkit-scrollbar-track': {\n background: theme.palette.background.paper,\n },\n '&::-webkit-scrollbar-thumb': {\n background: hovered ? 'rgba(5, 20, 158, 0.3)' : theme.palette.background.paper,\n borderRadius: '3px',\n },\n '&::-webkit-scrollbar-thumb:horizontal:active, &::-webkit-scrollbar-thumb:vertical:active': {\n background: hovered ? 'rgba(5, 20, 158, 0.6)' : theme.palette.background.paper,\n },\n '&:hover .sticky': {\n boxShadow: isScrolling ? `0px 2px 6px ${theme.palette.background.paper}` : 'none',\n transition: 'box-shadow 200ms',\n },\n}));\n\nconst HighlightScrollbar: React.FC<React.PropsWithChildren<HighlightScrollbarProps>> = (props) => {\n const { children, onScroll, setIsScrolling, setScrollStarted } = props;\n const [hoveredTable, setHoveredTable] = useState(false);\n\n const highlightScrollbar = () => setHoveredTable(true);\n\n const fadeScrollbar = () => {\n setHoveredTable(false);\n if (setIsScrolling) setIsScrolling(false);\n if (setScrollStarted) setScrollStarted(false);\n };\n\n return (\n <StyledContainer\n hovered={hoveredTable}\n isScrolling={!!setIsScrolling}\n onMouseEnter={highlightScrollbar}\n onMouseLeave={fadeScrollbar}\n onScroll={onScroll}\n >\n {children}\n </StyledContainer>\n );\n};\n\nexport default HighlightScrollbar;\n"],"names":["StyledContainer","styled","hovered","isScrolling","theme","overflowX","padding","height","border","palette","divider","background","paper","borderRadius","boxShadow","transition","HighlightScrollbar","props","children","onScroll","setIsScrolling","setScrollStarted","hoveredTable","setHoveredTable","useState","_jsx","onMouseEnter","onMouseLeave"],"mappings":"uHAgBA,MAAMA,EAAkBC,EAAO,MAAPA,EAA8B,EAAGC,UAASC,cAAaC,YAAO,CACpFC,UAAW,OACX,uBAAwB,CACtBC,QAAS,QACTC,OAAQ,MACRC,OAAQ,aAAaJ,EAAMK,QAAQC,WAErC,6BAA8B,CAC5BC,WAAYP,EAAMK,QAAQE,WAAWC,OAEvC,6BAA8B,CAC5BD,WAAYT,EAAU,wBAA0BE,EAAMK,QAAQE,WAAWC,MACzEC,aAAc,OAEhB,2FAA4F,CAC1FF,WAAYT,EAAU,wBAA0BE,EAAMK,QAAQE,WAAWC,OAE3E,kBAAmB,CACjBE,UAAWX,EAAc,eAAeC,EAAMK,QAAQE,WAAWC,QAAU,OAC3EG,WAAY,wBAIVC,EAAkFC,IACtF,MAAMC,SAAEA,EAAQC,SAAEA,EAAQC,eAAEA,EAAcC,iBAAEA,GAAqBJ,GAC1DK,EAAcC,GAAmBC,GAAS,GAUjD,OACEC,EAACzB,EAAe,CACdE,QAASoB,EACTnB,cAAeiB,EACfM,aAZuB,IAAMH,GAAgB,GAa7CI,aAXkB,KACpBJ,GAAgB,GACZH,GAAgBA,GAAe,GAC/BC,GAAkBA,GAAiB,IASrCF,SAAUA,EAAQD,SAEjBA"}
@@ -0,0 +1,18 @@
1
+ "use strict";var e=require("react/jsx-runtime"),i=require("@mui/material/Table"),t=require("@mui/material/TableCell"),r=require("@mui/material/TableHead"),a=require("@mui/material/TableRow"),l=require("@mui/material/Tooltip"),s=require("@mui/material/useMediaQuery"),o=require("../../atoms/IconButton/index.cjs.js"),n=require("@mui/material/styles"),d=require("@mui/material/styles/useTheme"),c=require("../../../icons/InformationCircle/index.cjs.js"),u=require("./GenericTableBody/index.cjs.js"),m=require("./GenericTableTitle/index.cjs.js"),h=require("./HighlightScrollbar.cjs.js");const x=n.styled("div")`
2
+ overflow-x: auto;
3
+ &::-webkit-scrollbar {
4
+ padding: 2px 0;
5
+ height: 6px;
6
+ border: 1px solid #d5d5d5;
7
+ }
8
+ &::-webkit-scrollbar-track {
9
+ background: #f1f1f1;
10
+ }
11
+ &::-webkit-scrollbar-thumb {
12
+ background: #f5f5f5;
13
+ border-radius: 3px;
14
+ }
15
+ `,p=n.styled(t,{shouldForwardProp:e=>"isSticky"!==e&&"titleVariant"!==e})((({theme:e,isSticky:i,titleVariant:t})=>({fontSize:13,fontWeight:"light"===t?400:e.typography.fontWeightMedium,color:"light"===t?e.palette.semantic.text["text-weak"]:e.palette.semantic.text["text-strong"],padding:e.spacing(1.25,2),whiteSpace:"nowrap",position:i?"sticky":"relative",zIndex:i?1:"auto"}))),b=n.styled("div")`
16
+ overflow: hidden;
17
+ `,g=n.styled(l)((({theme:e})=>({marginLeft:e.spacing(.5),svg:{fontSize:e.typography.body1.fontSize}})));module.exports=({data:t,title:l,subTitle:n,showTitle:j=!0,onRowClick:f,loading:y,metadata:k,titleVariant:w="default"})=>{const q=new Set(k.filter((e=>e.isVisible)).sort(((e,i)=>e.ordinal-i.ordinal)).map((e=>e.columnName))),T=k.reduce(((e,i)=>(e[i.columnName]=i,e)),{}),v=d(),S=!s(v.breakpoints.up("tablet")),I=S?"normal":"sticky";return e.jsxs(x,{children:[j&&e.jsx(m,{subTitle:n,title:l}),e.jsx(b,{children:e.jsx(h,{children:e.jsxs(i,{"aria-label":l,"data-testid":"generic-table"+(j?`-${l?.replace(" ","-").toLowerCase()}`:""),sx:{borderTop:"1px solid #e0e0e0",height:"10vh"},children:[e.jsx(r,{children:e.jsx(a,{children:Array.from(q).map(((i,t)=>{const{columnName:r,columnTitle:a,align:l="left",tooltip:s}=T[i]||{};return e.jsx(p,{align:l,isSticky:0===t&&!S,titleVariant:w,children:e.jsxs("div",{children:[e.jsx("span",{children:a}),s&&e.jsx(g,{placement:"right-start",title:s,children:e.jsx(o.IconButton,{"aria-label":"Info",size:"small",children:e.jsx(c,{"data-testid":"InfoOutlinedIcon",size:"sm"})})})]})},r)}))})}),e.jsx(u,{columns:q,data:t,loading:y,meta:T,onRowClick:f,type:I})]})})})]})};
18
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../../../../src/components/molecules/GenericTable/index.tsx"],"sourcesContent":["import Table from '@mui/material/Table';\nimport TableCell from '@mui/material/TableCell';\nimport TableHead from '@mui/material/TableHead';\nimport TableRow from '@mui/material/TableRow';\nimport Tooltip from '@mui/material/Tooltip';\nimport useMediaQuery from '@mui/material/useMediaQuery';\n\nimport IconButton from '@fd/components/atoms/IconButton';\nimport styled from '@fd/utilities/styledUtilities';\nimport useTheme from '@fd/utilities/useTheme';\n\nimport InfoOutlinedIcon from '../../../icons/InformationCircle';\nimport GenericTableBody, { type GenericTableColumns } from './GenericTableBody';\nimport GenericTableTitle from './GenericTableTitle';\nimport HighlightScrollbar from './HighlightScrollbar';\n\ninterface GenericTableProps {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data?: any[];\n loading?: boolean;\n metadata: GenericTableColumns[];\n // eslint-disable-next-line @typescript-eslint/ban-types\n onRowClick?: Function;\n showTitle?: boolean;\n subTitle?: string;\n title?: string;\n titleVariant?: 'default' | 'light';\n}\n\nconst StyledContainer = styled('div')`\n overflow-x: auto;\n &::-webkit-scrollbar {\n padding: 2px 0;\n height: 6px;\n border: 1px solid #d5d5d5;\n }\n &::-webkit-scrollbar-track {\n background: #f1f1f1;\n }\n &::-webkit-scrollbar-thumb {\n background: #f5f5f5;\n border-radius: 3px;\n }\n`;\n\nconst StyledTableCell = styled(TableCell, {\n shouldForwardProp: (prop) => prop !== 'isSticky' && prop !== 'titleVariant',\n})<{ isSticky: boolean; titleVariant: 'default' | 'light' }>(({ theme, isSticky, titleVariant }) => ({\n fontSize: 13,\n fontWeight: titleVariant === 'light' ? 400 : theme.typography.fontWeightMedium,\n color:\n titleVariant === 'light'\n ? theme.palette.semantic.text['text-weak']\n : theme.palette.semantic.text['text-strong'],\n padding: theme.spacing(1.25, 2),\n whiteSpace: 'nowrap',\n position: isSticky ? 'sticky' : 'relative',\n zIndex: isSticky ? 1 : 'auto',\n}));\n\nconst StyledSpacingContainer = styled('div')`\n overflow: hidden;\n`;\n\nconst StyledTooltip = styled(Tooltip)(({ theme }) => ({\n marginLeft: theme.spacing(0.5),\n svg: {\n fontSize: theme.typography.body1.fontSize,\n },\n}));\n\nconst GenericTable = ({\n data,\n title,\n subTitle,\n showTitle = true,\n onRowClick,\n loading,\n metadata,\n titleVariant = 'default',\n}: GenericTableProps) => {\n const columns = new Set(\n metadata\n .filter((m) => m.isVisible)\n .sort((a, b) => a.ordinal - b.ordinal)\n .map((m) => m.columnName),\n );\n const tableMeta = metadata.reduce<{ [key: string]: GenericTableColumns }>((obj, mData) => {\n obj[mData.columnName] = mData;\n return obj;\n }, {});\n\n const theme = useTheme();\n const isMobile = !useMediaQuery(theme.breakpoints.up('tablet'));\n\n // We never want sticky on mobile - only on desktop\n const firstColumnStylePosition = isMobile ? 'normal' : 'sticky';\n\n const renderTableHeader = () => (\n <TableHead>\n <TableRow>\n {Array.from(columns).map((prop, idx) => {\n const { columnName, columnTitle, align = 'left', tooltip } = tableMeta[prop] || {};\n\n return (\n <StyledTableCell\n key={columnName}\n align={align}\n isSticky={idx === 0 && !isMobile}\n titleVariant={titleVariant}\n >\n <div>\n <span>{columnTitle}</span>\n {tooltip && (\n <StyledTooltip placement=\"right-start\" title={tooltip}>\n <IconButton aria-label=\"Info\" size=\"small\">\n <InfoOutlinedIcon data-testid=\"InfoOutlinedIcon\" size=\"sm\" />\n </IconButton>\n </StyledTooltip>\n )}\n </div>\n </StyledTableCell>\n );\n })}\n </TableRow>\n </TableHead>\n );\n\n return (\n <StyledContainer>\n {showTitle && <GenericTableTitle subTitle={subTitle} title={title}></GenericTableTitle>}\n <StyledSpacingContainer>\n <HighlightScrollbar>\n <Table\n aria-label={title}\n data-testid={`generic-table` + (showTitle ? `-${title?.replace(' ', '-').toLowerCase()}` : '')}\n sx={{\n borderTop: '1px solid #e0e0e0',\n height: '10vh',\n }}\n >\n {renderTableHeader()}\n <GenericTableBody\n columns={columns}\n data={data}\n loading={loading}\n meta={tableMeta}\n onRowClick={onRowClick}\n type={firstColumnStylePosition}\n />\n </Table>\n </HighlightScrollbar>\n </StyledSpacingContainer>\n </StyledContainer>\n );\n};\n\nexport default GenericTable;\n"],"names":["StyledContainer","styled","StyledTableCell","TableCell","shouldForwardProp","prop","theme","isSticky","titleVariant","fontSize","fontWeight","typography","fontWeightMedium","color","palette","semantic","text","padding","spacing","whiteSpace","position","zIndex","StyledSpacingContainer","StyledTooltip","Tooltip","marginLeft","svg","body1","data","title","subTitle","showTitle","onRowClick","loading","metadata","columns","Set","filter","m","isVisible","sort","a","b","ordinal","map","columnName","tableMeta","reduce","obj","mData","useTheme","isMobile","useMediaQuery","breakpoints","up","firstColumnStylePosition","_jsxs","children","_jsx","GenericTableTitle","HighlightScrollbar","Table","replace","toLowerCase","sx","borderTop","height","TableHead","TableRow","Array","from","idx","columnTitle","align","tooltip","placement","IconButton","size","InfoOutlinedIcon","GenericTableBody","meta","type"],"mappings":"wkBA6BA,MAAMA,EAAkBC,EAAAA,OAAO,MAAM;;;;;;;;;;;;;;EAgB/BC,EAAkBD,EAAAA,OAAOE,EAAW,CACxCC,kBAAoBC,GAAkB,aAATA,GAAgC,iBAATA,GAD9BJ,EAEqC,EAAGK,QAAOC,WAAUC,mBAAc,CAC7FC,SAAU,GACVC,WAA6B,UAAjBF,EAA2B,IAAMF,EAAMK,WAAWC,iBAC9DC,MACmB,UAAjBL,EACIF,EAAMQ,QAAQC,SAASC,KAAK,aAC5BV,EAAMQ,QAAQC,SAASC,KAAK,eAClCC,QAASX,EAAMY,QAAQ,KAAM,GAC7BC,WAAY,SACZC,SAAUb,EAAW,SAAW,WAChCc,OAAQd,EAAW,EAAI,WAGnBe,EAAyBrB,EAAAA,OAAO,MAAM;;EAItCsB,EAAgBtB,EAAAA,OAAOuB,EAAPvB,EAAgB,EAAGK,YAAO,CAC9CmB,WAAYnB,EAAMY,QAAQ,IAC1BQ,IAAK,CACHjB,SAAUH,EAAMK,WAAWgB,MAAMlB,6BAIhB,EACnBmB,OACAC,QACAC,WACAC,aAAY,EACZC,aACAC,UACAC,WACA1B,eAAe,cAEf,MAAM2B,EAAU,IAAIC,IAClBF,EACGG,QAAQC,GAAMA,EAAEC,YAChBC,MAAK,CAACC,EAAGC,IAAMD,EAAEE,QAAUD,EAAEC,UAC7BC,KAAKN,GAAMA,EAAEO,cAEZC,EAAYZ,EAASa,QAA+C,CAACC,EAAKC,KAC9ED,EAAIC,EAAMJ,YAAcI,EACjBD,IACN,CAAA,GAEG1C,EAAQ4C,IACRC,GAAYC,EAAc9C,EAAM+C,YAAYC,GAAG,WAG/CC,EAA2BJ,EAAW,SAAW,SAgCvD,OACEK,EAAAA,KAACxD,EAAe,CAAAyD,SAAA,CACb1B,GAAa2B,EAAAA,IAACC,EAAiB,CAAC7B,SAAUA,EAAUD,MAAOA,IAC5D6B,EAAAA,IAACpC,EAAsB,CAAAmC,SACrBC,MAACE,EAAkB,CAAAH,SACjBD,EAAAA,KAACK,EAAK,CAAA,aACQhC,gBACC,iBAAmBE,EAAY,IAAIF,GAAOiC,QAAQ,IAAK,KAAKC,gBAAkB,IAC3FC,GAAI,CACFC,UAAW,oBACXC,OAAQ,QACTT,SAAA,CAxCTC,EAAAA,IAACS,EAAS,CAAAV,SACRC,EAAAA,IAACU,EAAQ,CAAAX,SACNY,MAAMC,KAAKnC,GAASS,KAAI,CAACvC,EAAMkE,KAC9B,MAAM1B,WAAEA,EAAU2B,YAAEA,EAAWC,MAAEA,EAAQ,OAAMC,QAAEA,GAAY5B,EAAUzC,IAAS,CAAA,EAEhF,OACEqD,MAACxD,EAAe,CAEduE,MAAOA,EACPlE,SAAkB,IAARgE,IAAcpB,EACxB3C,aAAcA,EAAYiD,SAE1BD,EAAAA,sBACEE,EAAAA,IAAA,OAAA,CAAAD,SAAOe,IACNE,GACChB,EAAAA,IAACnC,EAAa,CAACoD,UAAU,cAAc9C,MAAO6C,EAAOjB,SACnDC,EAAAA,IAACkB,aAAU,CAAA,aAAY,OAAOC,KAAK,QAAOpB,SACxCC,MAACoB,EAAgB,CAAA,cAAa,mBAAmBD,KAAK,eAVzDhC,UAoCPa,MAACqB,EAAgB,CACf5C,QAASA,EACTP,KAAMA,EACNK,QAASA,EACT+C,KAAMlC,EACNd,WAAYA,EACZiD,KAAM1B"}
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { GenericTableColumns } from '../GenericTableBody/index.js';
2
+ import { GenericTableColumns } from './GenericTableBody/index.js';
3
3
 
4
4
  interface GenericTableProps {
5
5
  data?: any[];
@@ -0,0 +1,18 @@
1
+ import{jsxs as t,jsx as e}from"react/jsx-runtime";import i from"@mui/material/Table";import r from"@mui/material/TableCell";import a from"@mui/material/TableHead";import o from"@mui/material/TableRow";import l from"@mui/material/Tooltip";import n from"@mui/material/useMediaQuery";import{IconButton as m}from"../../atoms/IconButton/index.js";import{styled as d}from"@mui/material/styles";import s from"@mui/material/styles/useTheme";import c from"../../../icons/InformationCircle/index.js";import p from"./GenericTableBody/index.js";import f from"./GenericTableTitle/index.js";import u from"./HighlightScrollbar.js";const h=d("div")`
2
+ overflow-x: auto;
3
+ &::-webkit-scrollbar {
4
+ padding: 2px 0;
5
+ height: 6px;
6
+ border: 1px solid #d5d5d5;
7
+ }
8
+ &::-webkit-scrollbar-track {
9
+ background: #f1f1f1;
10
+ }
11
+ &::-webkit-scrollbar-thumb {
12
+ background: #f5f5f5;
13
+ border-radius: 3px;
14
+ }
15
+ `,b=d(r,{shouldForwardProp:t=>"isSticky"!==t&&"titleVariant"!==t})((({theme:t,isSticky:e,titleVariant:i})=>({fontSize:13,fontWeight:"light"===i?400:t.typography.fontWeightMedium,color:"light"===i?t.palette.semantic.text["text-weak"]:t.palette.semantic.text["text-strong"],padding:t.spacing(1.25,2),whiteSpace:"nowrap",position:e?"sticky":"relative",zIndex:e?1:"auto"}))),g=d("div")`
16
+ overflow: hidden;
17
+ `,x=d(l)((({theme:t})=>({marginLeft:t.spacing(.5),svg:{fontSize:t.typography.body1.fontSize}}))),y=({data:r,title:l,subTitle:d,showTitle:y=!0,onRowClick:k,loading:w,metadata:T,titleVariant:S="default"})=>{const v=new Set(T.filter((t=>t.isVisible)).sort(((t,e)=>t.ordinal-e.ordinal)).map((t=>t.columnName))),j=T.reduce(((t,e)=>(t[e.columnName]=e,t)),{}),z=s(),I=!n(z.breakpoints.up("tablet")),C=I?"normal":"sticky";return t(h,{children:[y&&e(f,{subTitle:d,title:l}),e(g,{children:e(u,{children:t(i,{"aria-label":l,"data-testid":"generic-table"+(y?`-${l?.replace(" ","-").toLowerCase()}`:""),sx:{borderTop:"1px solid #e0e0e0",height:"10vh"},children:[e(a,{children:e(o,{children:Array.from(v).map(((i,r)=>{const{columnName:a,columnTitle:o,align:l="left",tooltip:n}=j[i]||{};return e(b,{align:l,isSticky:0===r&&!I,titleVariant:S,children:t("div",{children:[e("span",{children:o}),n&&e(x,{placement:"right-start",title:n,children:e(m,{"aria-label":"Info",size:"small",children:e(c,{"data-testid":"InfoOutlinedIcon",size:"sm"})})})]})},a)}))})}),e(p,{columns:v,data:r,loading:w,meta:j,onRowClick:k,type:C})]})})})]})};export{y as default};
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/molecules/GenericTable/index.tsx"],"sourcesContent":["import Table from '@mui/material/Table';\nimport TableCell from '@mui/material/TableCell';\nimport TableHead from '@mui/material/TableHead';\nimport TableRow from '@mui/material/TableRow';\nimport Tooltip from '@mui/material/Tooltip';\nimport useMediaQuery from '@mui/material/useMediaQuery';\n\nimport IconButton from '@fd/components/atoms/IconButton';\nimport styled from '@fd/utilities/styledUtilities';\nimport useTheme from '@fd/utilities/useTheme';\n\nimport InfoOutlinedIcon from '../../../icons/InformationCircle';\nimport GenericTableBody, { type GenericTableColumns } from './GenericTableBody';\nimport GenericTableTitle from './GenericTableTitle';\nimport HighlightScrollbar from './HighlightScrollbar';\n\ninterface GenericTableProps {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data?: any[];\n loading?: boolean;\n metadata: GenericTableColumns[];\n // eslint-disable-next-line @typescript-eslint/ban-types\n onRowClick?: Function;\n showTitle?: boolean;\n subTitle?: string;\n title?: string;\n titleVariant?: 'default' | 'light';\n}\n\nconst StyledContainer = styled('div')`\n overflow-x: auto;\n &::-webkit-scrollbar {\n padding: 2px 0;\n height: 6px;\n border: 1px solid #d5d5d5;\n }\n &::-webkit-scrollbar-track {\n background: #f1f1f1;\n }\n &::-webkit-scrollbar-thumb {\n background: #f5f5f5;\n border-radius: 3px;\n }\n`;\n\nconst StyledTableCell = styled(TableCell, {\n shouldForwardProp: (prop) => prop !== 'isSticky' && prop !== 'titleVariant',\n})<{ isSticky: boolean; titleVariant: 'default' | 'light' }>(({ theme, isSticky, titleVariant }) => ({\n fontSize: 13,\n fontWeight: titleVariant === 'light' ? 400 : theme.typography.fontWeightMedium,\n color:\n titleVariant === 'light'\n ? theme.palette.semantic.text['text-weak']\n : theme.palette.semantic.text['text-strong'],\n padding: theme.spacing(1.25, 2),\n whiteSpace: 'nowrap',\n position: isSticky ? 'sticky' : 'relative',\n zIndex: isSticky ? 1 : 'auto',\n}));\n\nconst StyledSpacingContainer = styled('div')`\n overflow: hidden;\n`;\n\nconst StyledTooltip = styled(Tooltip)(({ theme }) => ({\n marginLeft: theme.spacing(0.5),\n svg: {\n fontSize: theme.typography.body1.fontSize,\n },\n}));\n\nconst GenericTable = ({\n data,\n title,\n subTitle,\n showTitle = true,\n onRowClick,\n loading,\n metadata,\n titleVariant = 'default',\n}: GenericTableProps) => {\n const columns = new Set(\n metadata\n .filter((m) => m.isVisible)\n .sort((a, b) => a.ordinal - b.ordinal)\n .map((m) => m.columnName),\n );\n const tableMeta = metadata.reduce<{ [key: string]: GenericTableColumns }>((obj, mData) => {\n obj[mData.columnName] = mData;\n return obj;\n }, {});\n\n const theme = useTheme();\n const isMobile = !useMediaQuery(theme.breakpoints.up('tablet'));\n\n // We never want sticky on mobile - only on desktop\n const firstColumnStylePosition = isMobile ? 'normal' : 'sticky';\n\n const renderTableHeader = () => (\n <TableHead>\n <TableRow>\n {Array.from(columns).map((prop, idx) => {\n const { columnName, columnTitle, align = 'left', tooltip } = tableMeta[prop] || {};\n\n return (\n <StyledTableCell\n key={columnName}\n align={align}\n isSticky={idx === 0 && !isMobile}\n titleVariant={titleVariant}\n >\n <div>\n <span>{columnTitle}</span>\n {tooltip && (\n <StyledTooltip placement=\"right-start\" title={tooltip}>\n <IconButton aria-label=\"Info\" size=\"small\">\n <InfoOutlinedIcon data-testid=\"InfoOutlinedIcon\" size=\"sm\" />\n </IconButton>\n </StyledTooltip>\n )}\n </div>\n </StyledTableCell>\n );\n })}\n </TableRow>\n </TableHead>\n );\n\n return (\n <StyledContainer>\n {showTitle && <GenericTableTitle subTitle={subTitle} title={title}></GenericTableTitle>}\n <StyledSpacingContainer>\n <HighlightScrollbar>\n <Table\n aria-label={title}\n data-testid={`generic-table` + (showTitle ? `-${title?.replace(' ', '-').toLowerCase()}` : '')}\n sx={{\n borderTop: '1px solid #e0e0e0',\n height: '10vh',\n }}\n >\n {renderTableHeader()}\n <GenericTableBody\n columns={columns}\n data={data}\n loading={loading}\n meta={tableMeta}\n onRowClick={onRowClick}\n type={firstColumnStylePosition}\n />\n </Table>\n </HighlightScrollbar>\n </StyledSpacingContainer>\n </StyledContainer>\n );\n};\n\nexport default GenericTable;\n"],"names":["StyledContainer","styled","StyledTableCell","TableCell","shouldForwardProp","prop","theme","isSticky","titleVariant","fontSize","fontWeight","typography","fontWeightMedium","color","palette","semantic","text","padding","spacing","whiteSpace","position","zIndex","StyledSpacingContainer","StyledTooltip","Tooltip","marginLeft","svg","body1","GenericTable","data","title","subTitle","showTitle","onRowClick","loading","metadata","columns","Set","filter","m","isVisible","sort","a","b","ordinal","map","columnName","tableMeta","reduce","obj","mData","useTheme","isMobile","useMediaQuery","breakpoints","up","firstColumnStylePosition","_jsxs","children","_jsx","GenericTableTitle","HighlightScrollbar","Table","replace","toLowerCase","sx","borderTop","height","TableHead","TableRow","Array","from","idx","columnTitle","align","tooltip","placement","IconButton","size","InfoOutlinedIcon","GenericTableBody","meta","type"],"mappings":"wmBA6BA,MAAMA,EAAkBC,EAAO,MAAM;;;;;;;;;;;;;;EAgB/BC,EAAkBD,EAAOE,EAAW,CACxCC,kBAAoBC,GAAkB,aAATA,GAAgC,iBAATA,GAD9BJ,EAEqC,EAAGK,QAAOC,WAAUC,mBAAc,CAC7FC,SAAU,GACVC,WAA6B,UAAjBF,EAA2B,IAAMF,EAAMK,WAAWC,iBAC9DC,MACmB,UAAjBL,EACIF,EAAMQ,QAAQC,SAASC,KAAK,aAC5BV,EAAMQ,QAAQC,SAASC,KAAK,eAClCC,QAASX,EAAMY,QAAQ,KAAM,GAC7BC,WAAY,SACZC,SAAUb,EAAW,SAAW,WAChCc,OAAQd,EAAW,EAAI,WAGnBe,EAAyBrB,EAAO,MAAM;;EAItCsB,EAAgBtB,EAAOuB,EAAPvB,EAAgB,EAAGK,YAAO,CAC9CmB,WAAYnB,EAAMY,QAAQ,IAC1BQ,IAAK,CACHjB,SAAUH,EAAMK,WAAWgB,MAAMlB,cAI/BmB,EAAe,EACnBC,OACAC,QACAC,WACAC,aAAY,EACZC,aACAC,UACAC,WACA3B,eAAe,cAEf,MAAM4B,EAAU,IAAIC,IAClBF,EACGG,QAAQC,GAAMA,EAAEC,YAChBC,MAAK,CAACC,EAAGC,IAAMD,EAAEE,QAAUD,EAAEC,UAC7BC,KAAKN,GAAMA,EAAEO,cAEZC,EAAYZ,EAASa,QAA+C,CAACC,EAAKC,KAC9ED,EAAIC,EAAMJ,YAAcI,EACjBD,IACN,CAAA,GAEG3C,EAAQ6C,IACRC,GAAYC,EAAc/C,EAAMgD,YAAYC,GAAG,WAG/CC,EAA2BJ,EAAW,SAAW,SAgCvD,OACEK,EAACzD,EAAe,CAAA0D,SAAA,CACb1B,GAAa2B,EAACC,EAAiB,CAAC7B,SAAUA,EAAUD,MAAOA,IAC5D6B,EAACrC,EAAsB,CAAAoC,SACrBC,EAACE,EAAkB,CAAAH,SACjBD,EAACK,EAAK,CAAA,aACQhC,gBACC,iBAAmBE,EAAY,IAAIF,GAAOiC,QAAQ,IAAK,KAAKC,gBAAkB,IAC3FC,GAAI,CACFC,UAAW,oBACXC,OAAQ,QACTT,SAAA,CAxCTC,EAACS,EAAS,CAAAV,SACRC,EAACU,EAAQ,CAAAX,SACNY,MAAMC,KAAKnC,GAASS,KAAI,CAACxC,EAAMmE,KAC9B,MAAM1B,WAAEA,EAAU2B,YAAEA,EAAWC,MAAEA,EAAQ,OAAMC,QAAEA,GAAY5B,EAAU1C,IAAS,CAAA,EAEhF,OACEsD,EAACzD,EAAe,CAEdwE,MAAOA,EACPnE,SAAkB,IAARiE,IAAcpB,EACxB5C,aAAcA,EAAYkD,SAE1BD,mBACEE,EAAA,OAAA,CAAAD,SAAOe,IACNE,GACChB,EAACpC,EAAa,CAACqD,UAAU,cAAc9C,MAAO6C,EAAOjB,SACnDC,EAACkB,EAAU,CAAA,aAAY,OAAOC,KAAK,QAAOpB,SACxCC,EAACoB,EAAgB,CAAA,cAAa,mBAAmBD,KAAK,eAVzDhC,UAoCPa,EAACqB,EAAgB,CACf5C,QAASA,EACTP,KAAMA,EACNK,QAASA,EACT+C,KAAMlC,EACNd,WAAYA,EACZiD,KAAM1B"}
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("react");const e=["orgId","appId",{key:"isFlipdishStaff",type:"boolean"}],n=(t,e)=>t||"boolean"===e?"boolean"===e?"true"===t:"number"===e?Number(t):t:null,r=t=>[...e.map((t=>"string"==typeof t?t:t.key)),...t.map((t=>"string"==typeof t?t:t.key))];module.exports=(o=[])=>{const[s,i]=t.useState((()=>(t=>{const e=r(t),n={};return e.forEach((t=>{const e="string"==typeof t?t:t.key;n[e]=null})),n})(o)));return t.useEffect((()=>{const t=document.getElementById("flipdish-micro-frontend");if(!t)return void console.warn("Micro-frontend div not found");const s=r(o),u=[...e,...o],c=()=>{i((e=>{const r={...e};let o=!1;return s.forEach((e=>{const{value:s,key:i}=((t,e,r)=>{const o=((t,e)=>e.find((e=>"string"==typeof e?e===t:e.key===t)))(t,r),s=(t=>t&&"string"!=typeof t&&"type"in t?t.type??"string":"string")(o),i="string"==typeof t?t:t.key,u=(void 0)[`VITE_${i.toUpperCase()}_OVERRIDE`],c=`data-${i}`,a=e.getAttribute(c);return{value:n(u?u.toString():a,s),key:i}})(e,t,u);r[i]!==s&&(r[i]=s,o=!0)})),o?r:e}))};c();const a=new MutationObserver(c);return a.observe(t,{attributes:!0}),()=>a.disconnect()}),[o]),s};
1
+ "use strict";var t=require("react");const e=["org-id","app-id",{key:"is-flipdish-staff",type:"boolean"}],n=(t,e)=>t||"boolean"===e?"boolean"===e?"true"===t:"number"===e?Number(t):t:null,r=t=>[...e.map((t=>"string"==typeof t?t:t.key)),...t.map((t=>"string"==typeof t?t:t.key))];module.exports=(o=[])=>{const[s,i]=t.useState((()=>(t=>{const e=r(t),n={};return e.forEach((t=>{const e="string"==typeof t?t:t.key;n[e]=null})),n})(o)));return t.useEffect((()=>{const t=document.getElementById("flipdish-micro-frontend");if(!t)return void console.warn("Micro-frontend div not found");const s=r(o),u=[...e,...o],c=()=>{i((e=>{const r={...e};let o=!1;return s.forEach((e=>{const{value:s,key:i}=((t,e,r)=>{const o=((t,e)=>e.find((e=>"string"==typeof e?e===t:e.key===t)))(t,r),s=(t=>t&&"string"!=typeof t&&"type"in t?t.type??"string":"string")(o),i="string"==typeof t?t:t.key,u=(void 0)[`VITE_${i.toUpperCase()}_OVERRIDE`],c=`data-${i}`,a=e.getAttribute(c);return{value:n(u?u.toString():a,s),key:i}})(e,t,u);r[i]!==s&&(r[i]=s,o=!0)})),o?r:e}))};c();const a=new MutationObserver(c);return a.observe(t,{attributes:!0}),()=>a.disconnect()}),[o]),s};
2
2
  //# sourceMappingURL=useMicroFrontendAttributes.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useMicroFrontendAttributes.cjs.js","sources":["../../src/custom-hooks/useMicroFrontendAttributes.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\ntype KeyType = 'boolean' | 'number' | 'string';\n\ninterface KeyConfig {\n key: string;\n type?: KeyType; // type is optional, defaults to 'string'\n}\n\nconst ALWAYS_RETURN_KEYS: (KeyConfig | string)[] = [\n 'orgId',\n 'appId',\n { key: 'isFlipdishStaff', type: 'boolean' },\n] as const;\n\ntype AlwaysReturnKeys = (typeof ALWAYS_RETURN_KEYS)[number] extends KeyConfig\n ? (typeof ALWAYS_RETURN_KEYS)[number]['key']\n : (typeof ALWAYS_RETURN_KEYS)[number];\n\ntype ExtractKey<T> = T extends KeyConfig ? T['key'] : T;\n\ntype AttributeValue = boolean | number | string | null;\n\n// Utility functions moved outside\ntype KeyArg<T> = AlwaysReturnKeys | T | string;\nconst getKeyConfig = <T extends KeyConfig | string>(key: KeyArg<T>, allConfigs: (KeyConfig | string)[]) => {\n return allConfigs.find((config) => (typeof config === 'string' ? config === key : config.key === key));\n};\n\nconst getValueType = (keyConfig: KeyConfig | string | undefined): KeyType => {\n return keyConfig && typeof keyConfig !== 'string' && 'type' in keyConfig\n ? (keyConfig.type ?? 'string')\n : 'string';\n};\n\nconst parseValue = (value: string | null, type: KeyType): AttributeValue => {\n if (!value && type !== 'boolean') return null;\n if (type === 'boolean') return value === 'true';\n if (type === 'number') return Number(value);\n return value;\n};\n\nconst getAllKeys = <T extends KeyConfig | string>(\n customKeys: (KeyConfig | T)[],\n): (AlwaysReturnKeys | T | string)[] => {\n return [\n ...ALWAYS_RETURN_KEYS.map((key) => (typeof key === 'string' ? key : key.key)),\n ...customKeys.map((key) => (typeof key === 'string' ? key : key.key)),\n ];\n};\n\nconst getInitialState = <T extends KeyConfig | string>(\n customKeys: (KeyConfig | T)[],\n): Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue> => {\n const allKeys = getAllKeys(customKeys);\n const initialState = {} as Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue>;\n allKeys.forEach((key) => {\n const typedKey = (typeof key === 'string' ? key : key.key) as ExtractKey<AlwaysReturnKeys | T>;\n initialState[typedKey] = null;\n });\n return initialState;\n};\n\nconst processAttribute = <T extends KeyConfig | string>(\n key: AlwaysReturnKeys | T | string,\n microFrontendDiv: HTMLElement,\n allConfigs: (KeyConfig | string)[],\n): { value: AttributeValue; key: ExtractKey<AlwaysReturnKeys | T> } => {\n const keyConfig = getKeyConfig(key, allConfigs);\n const type = getValueType(keyConfig);\n const keyString = typeof key === 'string' ? key : key.key;\n\n const envVar = import.meta.env[`VITE_${keyString.toUpperCase()}_OVERRIDE`] as string | null | undefined;\n const attributeKey = `data-${keyString}`;\n const domValue = microFrontendDiv.getAttribute(attributeKey);\n\n const value = envVar ? parseValue(envVar.toString(), type) : parseValue(domValue, type);\n return { value, key: keyString as ExtractKey<AlwaysReturnKeys | T> };\n};\n\n/**\n * Custom hook to manage micro-frontend attributes.\n *\n * This hook initializes and updates a set of attributes based on a combination of predefined keys (ALWAYS_RETURN_KEYS)\n * and custom keys provided as arguments. The attributes are fetched from environment variables or DOM attributes\n * and are updated dynamically using a MutationObserver.\n *\n * @template T - The type of custom keys, which can be either a string or a KeyConfig object.\n *\n * @param {Array<T | KeyConfig>} [customKeys=[]] - An array of custom keys or KeyConfig objects to be included in the attributes.\n *\n * @returns {Record<ExtractKey<AlwaysReturnKeys | T>, string | boolean | number | null>} - A record of attributes with their values.\n *\n * @example\n * const attributes = useMicroFrontendAttributes(['customKey1', { key: 'customKey2', type: 'boolean' }]);\n * console.log(attributes);\n */\nconst useMicroFrontendAttributes = <T extends KeyConfig | string>(\n customKeys: (KeyConfig | T)[] = [],\n): Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue> => {\n const [attributes, setAttributes] = useState(() => getInitialState(customKeys));\n\n useEffect(() => {\n const microFrontendDiv = document.getElementById('flipdish-micro-frontend');\n if (!microFrontendDiv) {\n console.warn('Micro-frontend div not found');\n return;\n }\n\n const allKeys = getAllKeys(customKeys);\n const allConfigs = [...ALWAYS_RETURN_KEYS, ...customKeys];\n\n const updateValues = () => {\n setAttributes((prev) => {\n const newAttributes = { ...prev };\n let isChanged = false;\n\n allKeys.forEach((key) => {\n const { value, key: typedKey } = processAttribute(key, microFrontendDiv, allConfigs);\n if (newAttributes[typedKey] !== value) {\n newAttributes[typedKey] = value;\n isChanged = true;\n }\n });\n\n return isChanged ? newAttributes : prev;\n });\n };\n\n updateValues();\n\n const observer = new MutationObserver(updateValues);\n observer.observe(microFrontendDiv, { attributes: true });\n\n return () => observer.disconnect();\n }, [customKeys]);\n\n return attributes;\n};\n\nexport default useMicroFrontendAttributes;\n"],"names":["ALWAYS_RETURN_KEYS","key","type","parseValue","value","Number","getAllKeys","customKeys","map","attributes","setAttributes","useState","allKeys","initialState","forEach","typedKey","getInitialState","useEffect","microFrontendDiv","document","getElementById","console","warn","allConfigs","updateValues","prev","newAttributes","isChanged","keyConfig","find","config","getKeyConfig","getValueType","keyString","envVar","undefined","toUpperCase","attributeKey","domValue","getAttribute","toString","processAttribute","observer","MutationObserver","observe","disconnect"],"mappings":"oCASA,MAAMA,EAA6C,CACjD,QACA,QACA,CAAEC,IAAK,kBAAmBC,KAAM,YAuB5BC,EAAa,CAACC,EAAsBF,IACnCE,GAAkB,YAATF,EACD,YAATA,EAAqC,SAAVE,EAClB,WAATF,EAA0BG,OAAOD,GAC9BA,EAHkC,KAMrCE,EACJC,GAEO,IACFP,EAAmBQ,KAAKP,GAAwB,iBAARA,EAAmBA,EAAMA,EAAIA,SACrEM,EAAWC,KAAKP,GAAwB,iBAARA,EAAmBA,EAAMA,EAAIA,sBAkDjC,CACjCM,EAAgC,MAEhC,MAAOE,EAAYC,GAAiBC,EAAAA,UAAS,IAjDvB,CACtBJ,IAEA,MAAMK,EAAUN,EAAWC,GACrBM,EAAe,CAAA,EAKrB,OAJAD,EAAQE,SAASb,IACf,MAAMc,EAA2B,iBAARd,EAAmBA,EAAMA,EAAIA,IACtDY,EAAaE,GAAY,QAEpBF,GAwC4CG,CAAgBT,KAqCnE,OAnCAU,EAAAA,WAAU,KACR,MAAMC,EAAmBC,SAASC,eAAe,2BACjD,IAAKF,EAEH,YADAG,QAAQC,KAAK,gCAIf,MAAMV,EAAUN,EAAWC,GACrBgB,EAAa,IAAIvB,KAAuBO,GAExCiB,EAAe,KACnBd,GAAee,IACb,MAAMC,EAAgB,IAAKD,GAC3B,IAAIE,GAAY,EAUhB,OARAf,EAAQE,SAASb,IACf,MAAMG,MAAEA,EAAOH,IAAKc,GAvDL,EACvBd,EACAiB,EACAK,KAEA,MAAMK,EA3Ca,EAA+B3B,EAAgBsB,IAC3DA,EAAWM,MAAMC,GAA8B,iBAAXA,EAAsBA,IAAW7B,EAAM6B,EAAO7B,MAAQA,IA0C/E8B,CAAa9B,EAAKsB,GAC9BrB,EAxCa,CAAC0B,GACbA,GAAkC,iBAAdA,GAA0B,SAAUA,EAC1DA,EAAU1B,MAAQ,SACnB,SAqCS8B,CAAaJ,GACpBK,EAA2B,iBAARhC,EAAmBA,EAAMA,EAAIA,IAEhDiC,QAASC,GAAgB,QAAQF,EAAUG,0BAC3CC,EAAe,QAAQJ,IACvBK,EAAWpB,EAAiBqB,aAAaF,GAG/C,MAAO,CAAEjC,MADcD,EAAT+B,EAAoBA,EAAOM,WAA+BF,EAAnBpC,GACrCD,IAAKgC,IAyCoBQ,CAAiBxC,EAAKiB,EAAkBK,GACrEG,EAAcX,KAAcX,IAC9BsB,EAAcX,GAAYX,EAC1BuB,GAAY,MAITA,EAAYD,EAAgBD,MAIvCD,IAEA,MAAMkB,EAAW,IAAIC,iBAAiBnB,GAGtC,OAFAkB,EAASE,QAAQ1B,EAAkB,CAAET,YAAY,IAE1C,IAAMiC,EAASG,eACrB,CAACtC,IAEGE"}
1
+ {"version":3,"file":"useMicroFrontendAttributes.cjs.js","sources":["../../src/custom-hooks/useMicroFrontendAttributes.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\ntype KeyType = 'boolean' | 'number' | 'string';\n\ninterface KeyConfig {\n key: string;\n type?: KeyType; // type is optional, defaults to 'string'\n}\n\nconst ALWAYS_RETURN_KEYS: (KeyConfig | string)[] = [\n 'org-id',\n 'app-id',\n { key: 'is-flipdish-staff', type: 'boolean' },\n] as const;\n\ntype AlwaysReturnKeys = (typeof ALWAYS_RETURN_KEYS)[number] extends KeyConfig\n ? (typeof ALWAYS_RETURN_KEYS)[number]['key']\n : (typeof ALWAYS_RETURN_KEYS)[number];\n\ntype ExtractKey<T> = T extends KeyConfig ? T['key'] : T;\n\ntype AttributeValue = boolean | number | string | null;\n\n// Utility functions moved outside\ntype KeyArg<T> = AlwaysReturnKeys | T | string;\nconst getKeyConfig = <T extends KeyConfig | string>(key: KeyArg<T>, allConfigs: (KeyConfig | string)[]) => {\n return allConfigs.find((config) => (typeof config === 'string' ? config === key : config.key === key));\n};\n\nconst getValueType = (keyConfig: KeyConfig | string | undefined): KeyType => {\n return keyConfig && typeof keyConfig !== 'string' && 'type' in keyConfig\n ? (keyConfig.type ?? 'string')\n : 'string';\n};\n\nconst parseValue = (value: string | null, type: KeyType): AttributeValue => {\n if (!value && type !== 'boolean') return null;\n if (type === 'boolean') return value === 'true';\n if (type === 'number') return Number(value);\n return value;\n};\n\nconst getAllKeys = <T extends KeyConfig | string>(\n customKeys: (KeyConfig | T)[],\n): (AlwaysReturnKeys | T | string)[] => {\n return [\n ...ALWAYS_RETURN_KEYS.map((key) => (typeof key === 'string' ? key : key.key)),\n ...customKeys.map((key) => (typeof key === 'string' ? key : key.key)),\n ];\n};\n\nconst getInitialState = <T extends KeyConfig | string>(\n customKeys: (KeyConfig | T)[],\n): Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue> => {\n const allKeys = getAllKeys(customKeys);\n const initialState = {} as Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue>;\n allKeys.forEach((key) => {\n const typedKey = (typeof key === 'string' ? key : key.key) as ExtractKey<AlwaysReturnKeys | T>;\n initialState[typedKey] = null;\n });\n return initialState;\n};\n\nconst processAttribute = <T extends KeyConfig | string>(\n key: AlwaysReturnKeys | T | string,\n microFrontendDiv: HTMLElement,\n allConfigs: (KeyConfig | string)[],\n): { value: AttributeValue; key: ExtractKey<AlwaysReturnKeys | T> } => {\n const keyConfig = getKeyConfig(key, allConfigs);\n const type = getValueType(keyConfig);\n const keyString = typeof key === 'string' ? key : key.key;\n\n const envVar = import.meta.env[`VITE_${keyString.toUpperCase()}_OVERRIDE`] as string | null | undefined;\n const attributeKey = `data-${keyString}`;\n const domValue = microFrontendDiv.getAttribute(attributeKey);\n\n const value = envVar ? parseValue(envVar.toString(), type) : parseValue(domValue, type);\n return { value, key: keyString as ExtractKey<AlwaysReturnKeys | T> };\n};\n\n/**\n * Custom hook to manage micro-frontend attributes.\n *\n * This hook initializes and updates a set of attributes based on a combination of predefined keys (ALWAYS_RETURN_KEYS)\n * and custom keys provided as arguments. The attributes are fetched from environment variables or DOM attributes\n * and are updated dynamically using a MutationObserver.\n *\n * @template T - The type of custom keys, which can be either a string or a KeyConfig object.\n *\n * @param {Array<T | KeyConfig>} [customKeys=[]] - An array of custom keys or KeyConfig objects to be included in the attributes.\n *\n * @returns {Record<ExtractKey<AlwaysReturnKeys | T>, string | boolean | number | null>} - A record of attributes with their values.\n *\n * @example\n * const attributes = useMicroFrontendAttributes(['customKey1', { key: 'customKey2', type: 'boolean' }]);\n * console.log(attributes);\n */\nconst useMicroFrontendAttributes = <T extends KeyConfig | string>(\n customKeys: (KeyConfig | T)[] = [],\n): Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue> => {\n const [attributes, setAttributes] = useState(() => getInitialState(customKeys));\n\n useEffect(() => {\n const microFrontendDiv = document.getElementById('flipdish-micro-frontend');\n if (!microFrontendDiv) {\n console.warn('Micro-frontend div not found');\n return;\n }\n\n const allKeys = getAllKeys(customKeys);\n const allConfigs = [...ALWAYS_RETURN_KEYS, ...customKeys];\n\n const updateValues = () => {\n setAttributes((prev) => {\n const newAttributes = { ...prev };\n let isChanged = false;\n\n allKeys.forEach((key) => {\n const { value, key: typedKey } = processAttribute(key, microFrontendDiv, allConfigs);\n if (newAttributes[typedKey] !== value) {\n newAttributes[typedKey] = value;\n isChanged = true;\n }\n });\n\n return isChanged ? newAttributes : prev;\n });\n };\n\n updateValues();\n\n const observer = new MutationObserver(updateValues);\n observer.observe(microFrontendDiv, { attributes: true });\n\n return () => observer.disconnect();\n }, [customKeys]);\n\n return attributes;\n};\n\nexport default useMicroFrontendAttributes;\n"],"names":["ALWAYS_RETURN_KEYS","key","type","parseValue","value","Number","getAllKeys","customKeys","map","attributes","setAttributes","useState","allKeys","initialState","forEach","typedKey","getInitialState","useEffect","microFrontendDiv","document","getElementById","console","warn","allConfigs","updateValues","prev","newAttributes","isChanged","keyConfig","find","config","getKeyConfig","getValueType","keyString","envVar","undefined","toUpperCase","attributeKey","domValue","getAttribute","toString","processAttribute","observer","MutationObserver","observe","disconnect"],"mappings":"oCASA,MAAMA,EAA6C,CACjD,SACA,SACA,CAAEC,IAAK,oBAAqBC,KAAM,YAuB9BC,EAAa,CAACC,EAAsBF,IACnCE,GAAkB,YAATF,EACD,YAATA,EAAqC,SAAVE,EAClB,WAATF,EAA0BG,OAAOD,GAC9BA,EAHkC,KAMrCE,EACJC,GAEO,IACFP,EAAmBQ,KAAKP,GAAwB,iBAARA,EAAmBA,EAAMA,EAAIA,SACrEM,EAAWC,KAAKP,GAAwB,iBAARA,EAAmBA,EAAMA,EAAIA,sBAkDjC,CACjCM,EAAgC,MAEhC,MAAOE,EAAYC,GAAiBC,EAAAA,UAAS,IAjDvB,CACtBJ,IAEA,MAAMK,EAAUN,EAAWC,GACrBM,EAAe,CAAA,EAKrB,OAJAD,EAAQE,SAASb,IACf,MAAMc,EAA2B,iBAARd,EAAmBA,EAAMA,EAAIA,IACtDY,EAAaE,GAAY,QAEpBF,GAwC4CG,CAAgBT,KAqCnE,OAnCAU,EAAAA,WAAU,KACR,MAAMC,EAAmBC,SAASC,eAAe,2BACjD,IAAKF,EAEH,YADAG,QAAQC,KAAK,gCAIf,MAAMV,EAAUN,EAAWC,GACrBgB,EAAa,IAAIvB,KAAuBO,GAExCiB,EAAe,KACnBd,GAAee,IACb,MAAMC,EAAgB,IAAKD,GAC3B,IAAIE,GAAY,EAUhB,OARAf,EAAQE,SAASb,IACf,MAAMG,MAAEA,EAAOH,IAAKc,GAvDL,EACvBd,EACAiB,EACAK,KAEA,MAAMK,EA3Ca,EAA+B3B,EAAgBsB,IAC3DA,EAAWM,MAAMC,GAA8B,iBAAXA,EAAsBA,IAAW7B,EAAM6B,EAAO7B,MAAQA,IA0C/E8B,CAAa9B,EAAKsB,GAC9BrB,EAxCa,CAAC0B,GACbA,GAAkC,iBAAdA,GAA0B,SAAUA,EAC1DA,EAAU1B,MAAQ,SACnB,SAqCS8B,CAAaJ,GACpBK,EAA2B,iBAARhC,EAAmBA,EAAMA,EAAIA,IAEhDiC,QAASC,GAAgB,QAAQF,EAAUG,0BAC3CC,EAAe,QAAQJ,IACvBK,EAAWpB,EAAiBqB,aAAaF,GAG/C,MAAO,CAAEjC,MADcD,EAAT+B,EAAoBA,EAAOM,WAA+BF,EAAnBpC,GACrCD,IAAKgC,IAyCoBQ,CAAiBxC,EAAKiB,EAAkBK,GACrEG,EAAcX,KAAcX,IAC9BsB,EAAcX,GAAYX,EAC1BuB,GAAY,MAITA,EAAYD,EAAgBD,MAIvCD,IAEA,MAAMkB,EAAW,IAAIC,iBAAiBnB,GAGtC,OAFAkB,EAASE,QAAQ1B,EAAkB,CAAET,YAAY,IAE1C,IAAMiC,EAASG,eACrB,CAACtC,IAEGE"}
@@ -1,2 +1,2 @@
1
- import{useState as t,useEffect as e}from"react";const n=["orgId","appId",{key:"isFlipdishStaff",type:"boolean"}],o=(t,e)=>t||"boolean"===e?"boolean"===e?"true"===t:"number"===e?Number(t):t:null,r=t=>[...n.map((t=>"string"==typeof t?t:t.key)),...t.map((t=>"string"==typeof t?t:t.key))],s=(s=[])=>{const[i,a]=t((()=>(t=>{const e=r(t),n={};return e.forEach((t=>{const e="string"==typeof t?t:t.key;n[e]=null})),n})(s)));return e((()=>{const t=document.getElementById("flipdish-micro-frontend");if(!t)return void console.warn("Micro-frontend div not found");const e=r(s),i=[...n,...s],p=()=>{a((n=>{const r={...n};let s=!1;return e.forEach((e=>{const{value:n,key:a}=((t,e,n)=>{const r=((t,e)=>e.find((e=>"string"==typeof e?e===t:e.key===t)))(t,n),s=(t=>t&&"string"!=typeof t&&"type"in t?t.type??"string":"string")(r),i="string"==typeof t?t:t.key,a=import.meta.env[`VITE_${i.toUpperCase()}_OVERRIDE`],p=`data-${i}`,c=e.getAttribute(p);return{value:o(a?a.toString():c,s),key:i}})(e,t,i);r[a]!==n&&(r[a]=n,s=!0)})),s?r:n}))};p();const c=new MutationObserver(p);return c.observe(t,{attributes:!0}),()=>c.disconnect()}),[s]),i};export{s as default};
1
+ import{useState as t,useEffect as e}from"react";const n=["org-id","app-id",{key:"is-flipdish-staff",type:"boolean"}],o=(t,e)=>t||"boolean"===e?"boolean"===e?"true"===t:"number"===e?Number(t):t:null,r=t=>[...n.map((t=>"string"==typeof t?t:t.key)),...t.map((t=>"string"==typeof t?t:t.key))],i=(i=[])=>{const[s,a]=t((()=>(t=>{const e=r(t),n={};return e.forEach((t=>{const e="string"==typeof t?t:t.key;n[e]=null})),n})(i)));return e((()=>{const t=document.getElementById("flipdish-micro-frontend");if(!t)return void console.warn("Micro-frontend div not found");const e=r(i),s=[...n,...i],p=()=>{a((n=>{const r={...n};let i=!1;return e.forEach((e=>{const{value:n,key:a}=((t,e,n)=>{const r=((t,e)=>e.find((e=>"string"==typeof e?e===t:e.key===t)))(t,n),i=(t=>t&&"string"!=typeof t&&"type"in t?t.type??"string":"string")(r),s="string"==typeof t?t:t.key,a=import.meta.env[`VITE_${s.toUpperCase()}_OVERRIDE`],p=`data-${s}`,c=e.getAttribute(p);return{value:o(a?a.toString():c,i),key:s}})(e,t,s);r[a]!==n&&(r[a]=n,i=!0)})),i?r:n}))};p();const c=new MutationObserver(p);return c.observe(t,{attributes:!0}),()=>c.disconnect()}),[i]),s};export{i as default};
2
2
  //# sourceMappingURL=useMicroFrontendAttributes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useMicroFrontendAttributes.js","sources":["../../src/custom-hooks/useMicroFrontendAttributes.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\ntype KeyType = 'boolean' | 'number' | 'string';\n\ninterface KeyConfig {\n key: string;\n type?: KeyType; // type is optional, defaults to 'string'\n}\n\nconst ALWAYS_RETURN_KEYS: (KeyConfig | string)[] = [\n 'orgId',\n 'appId',\n { key: 'isFlipdishStaff', type: 'boolean' },\n] as const;\n\ntype AlwaysReturnKeys = (typeof ALWAYS_RETURN_KEYS)[number] extends KeyConfig\n ? (typeof ALWAYS_RETURN_KEYS)[number]['key']\n : (typeof ALWAYS_RETURN_KEYS)[number];\n\ntype ExtractKey<T> = T extends KeyConfig ? T['key'] : T;\n\ntype AttributeValue = boolean | number | string | null;\n\n// Utility functions moved outside\ntype KeyArg<T> = AlwaysReturnKeys | T | string;\nconst getKeyConfig = <T extends KeyConfig | string>(key: KeyArg<T>, allConfigs: (KeyConfig | string)[]) => {\n return allConfigs.find((config) => (typeof config === 'string' ? config === key : config.key === key));\n};\n\nconst getValueType = (keyConfig: KeyConfig | string | undefined): KeyType => {\n return keyConfig && typeof keyConfig !== 'string' && 'type' in keyConfig\n ? (keyConfig.type ?? 'string')\n : 'string';\n};\n\nconst parseValue = (value: string | null, type: KeyType): AttributeValue => {\n if (!value && type !== 'boolean') return null;\n if (type === 'boolean') return value === 'true';\n if (type === 'number') return Number(value);\n return value;\n};\n\nconst getAllKeys = <T extends KeyConfig | string>(\n customKeys: (KeyConfig | T)[],\n): (AlwaysReturnKeys | T | string)[] => {\n return [\n ...ALWAYS_RETURN_KEYS.map((key) => (typeof key === 'string' ? key : key.key)),\n ...customKeys.map((key) => (typeof key === 'string' ? key : key.key)),\n ];\n};\n\nconst getInitialState = <T extends KeyConfig | string>(\n customKeys: (KeyConfig | T)[],\n): Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue> => {\n const allKeys = getAllKeys(customKeys);\n const initialState = {} as Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue>;\n allKeys.forEach((key) => {\n const typedKey = (typeof key === 'string' ? key : key.key) as ExtractKey<AlwaysReturnKeys | T>;\n initialState[typedKey] = null;\n });\n return initialState;\n};\n\nconst processAttribute = <T extends KeyConfig | string>(\n key: AlwaysReturnKeys | T | string,\n microFrontendDiv: HTMLElement,\n allConfigs: (KeyConfig | string)[],\n): { value: AttributeValue; key: ExtractKey<AlwaysReturnKeys | T> } => {\n const keyConfig = getKeyConfig(key, allConfigs);\n const type = getValueType(keyConfig);\n const keyString = typeof key === 'string' ? key : key.key;\n\n const envVar = import.meta.env[`VITE_${keyString.toUpperCase()}_OVERRIDE`] as string | null | undefined;\n const attributeKey = `data-${keyString}`;\n const domValue = microFrontendDiv.getAttribute(attributeKey);\n\n const value = envVar ? parseValue(envVar.toString(), type) : parseValue(domValue, type);\n return { value, key: keyString as ExtractKey<AlwaysReturnKeys | T> };\n};\n\n/**\n * Custom hook to manage micro-frontend attributes.\n *\n * This hook initializes and updates a set of attributes based on a combination of predefined keys (ALWAYS_RETURN_KEYS)\n * and custom keys provided as arguments. The attributes are fetched from environment variables or DOM attributes\n * and are updated dynamically using a MutationObserver.\n *\n * @template T - The type of custom keys, which can be either a string or a KeyConfig object.\n *\n * @param {Array<T | KeyConfig>} [customKeys=[]] - An array of custom keys or KeyConfig objects to be included in the attributes.\n *\n * @returns {Record<ExtractKey<AlwaysReturnKeys | T>, string | boolean | number | null>} - A record of attributes with their values.\n *\n * @example\n * const attributes = useMicroFrontendAttributes(['customKey1', { key: 'customKey2', type: 'boolean' }]);\n * console.log(attributes);\n */\nconst useMicroFrontendAttributes = <T extends KeyConfig | string>(\n customKeys: (KeyConfig | T)[] = [],\n): Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue> => {\n const [attributes, setAttributes] = useState(() => getInitialState(customKeys));\n\n useEffect(() => {\n const microFrontendDiv = document.getElementById('flipdish-micro-frontend');\n if (!microFrontendDiv) {\n console.warn('Micro-frontend div not found');\n return;\n }\n\n const allKeys = getAllKeys(customKeys);\n const allConfigs = [...ALWAYS_RETURN_KEYS, ...customKeys];\n\n const updateValues = () => {\n setAttributes((prev) => {\n const newAttributes = { ...prev };\n let isChanged = false;\n\n allKeys.forEach((key) => {\n const { value, key: typedKey } = processAttribute(key, microFrontendDiv, allConfigs);\n if (newAttributes[typedKey] !== value) {\n newAttributes[typedKey] = value;\n isChanged = true;\n }\n });\n\n return isChanged ? newAttributes : prev;\n });\n };\n\n updateValues();\n\n const observer = new MutationObserver(updateValues);\n observer.observe(microFrontendDiv, { attributes: true });\n\n return () => observer.disconnect();\n }, [customKeys]);\n\n return attributes;\n};\n\nexport default useMicroFrontendAttributes;\n"],"names":["ALWAYS_RETURN_KEYS","key","type","parseValue","value","Number","getAllKeys","customKeys","map","useMicroFrontendAttributes","attributes","setAttributes","useState","allKeys","initialState","forEach","typedKey","getInitialState","useEffect","microFrontendDiv","document","getElementById","console","warn","allConfigs","updateValues","prev","newAttributes","isChanged","keyConfig","find","config","getKeyConfig","getValueType","keyString","envVar","env","toUpperCase","attributeKey","domValue","getAttribute","toString","processAttribute","observer","MutationObserver","observe","disconnect"],"mappings":"gDASA,MAAMA,EAA6C,CACjD,QACA,QACA,CAAEC,IAAK,kBAAmBC,KAAM,YAuB5BC,EAAa,CAACC,EAAsBF,IACnCE,GAAkB,YAATF,EACD,YAATA,EAAqC,SAAVE,EAClB,WAATF,EAA0BG,OAAOD,GAC9BA,EAHkC,KAMrCE,EACJC,GAEO,IACFP,EAAmBQ,KAAKP,GAAwB,iBAARA,EAAmBA,EAAMA,EAAIA,SACrEM,EAAWC,KAAKP,GAAwB,iBAARA,EAAmBA,EAAMA,EAAIA,OAkD9DQ,EAA6B,CACjCF,EAAgC,MAEhC,MAAOG,EAAYC,GAAiBC,GAAS,IAjDvB,CACtBL,IAEA,MAAMM,EAAUP,EAAWC,GACrBO,EAAe,CAAA,EAKrB,OAJAD,EAAQE,SAASd,IACf,MAAMe,EAA2B,iBAARf,EAAmBA,EAAMA,EAAIA,IACtDa,EAAaE,GAAY,QAEpBF,GAwC4CG,CAAgBV,KAqCnE,OAnCAW,GAAU,KACR,MAAMC,EAAmBC,SAASC,eAAe,2BACjD,IAAKF,EAEH,YADAG,QAAQC,KAAK,gCAIf,MAAMV,EAAUP,EAAWC,GACrBiB,EAAa,IAAIxB,KAAuBO,GAExCkB,EAAe,KACnBd,GAAee,IACb,MAAMC,EAAgB,IAAKD,GAC3B,IAAIE,GAAY,EAUhB,OARAf,EAAQE,SAASd,IACf,MAAMG,MAAEA,EAAOH,IAAKe,GAvDL,EACvBf,EACAkB,EACAK,KAEA,MAAMK,EA3Ca,EAA+B5B,EAAgBuB,IAC3DA,EAAWM,MAAMC,GAA8B,iBAAXA,EAAsBA,IAAW9B,EAAM8B,EAAO9B,MAAQA,IA0C/E+B,CAAa/B,EAAKuB,GAC9BtB,EAxCa,CAAC2B,GACbA,GAAkC,iBAAdA,GAA0B,SAAUA,EAC1DA,EAAU3B,MAAQ,SACnB,SAqCS+B,CAAaJ,GACpBK,EAA2B,iBAARjC,EAAmBA,EAAMA,EAAIA,IAEhDkC,cAAqBC,IAAI,QAAQF,EAAUG,0BAC3CC,EAAe,QAAQJ,IACvBK,EAAWpB,EAAiBqB,aAAaF,GAG/C,MAAO,CAAElC,MADcD,EAATgC,EAAoBA,EAAOM,WAA+BF,EAAnBrC,GACrCD,IAAKiC,IAyCoBQ,CAAiBzC,EAAKkB,EAAkBK,GACrEG,EAAcX,KAAcZ,IAC9BuB,EAAcX,GAAYZ,EAC1BwB,GAAY,MAITA,EAAYD,EAAgBD,MAIvCD,IAEA,MAAMkB,EAAW,IAAIC,iBAAiBnB,GAGtC,OAFAkB,EAASE,QAAQ1B,EAAkB,CAAET,YAAY,IAE1C,IAAMiC,EAASG,eACrB,CAACvC,IAEGG"}
1
+ {"version":3,"file":"useMicroFrontendAttributes.js","sources":["../../src/custom-hooks/useMicroFrontendAttributes.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\ntype KeyType = 'boolean' | 'number' | 'string';\n\ninterface KeyConfig {\n key: string;\n type?: KeyType; // type is optional, defaults to 'string'\n}\n\nconst ALWAYS_RETURN_KEYS: (KeyConfig | string)[] = [\n 'org-id',\n 'app-id',\n { key: 'is-flipdish-staff', type: 'boolean' },\n] as const;\n\ntype AlwaysReturnKeys = (typeof ALWAYS_RETURN_KEYS)[number] extends KeyConfig\n ? (typeof ALWAYS_RETURN_KEYS)[number]['key']\n : (typeof ALWAYS_RETURN_KEYS)[number];\n\ntype ExtractKey<T> = T extends KeyConfig ? T['key'] : T;\n\ntype AttributeValue = boolean | number | string | null;\n\n// Utility functions moved outside\ntype KeyArg<T> = AlwaysReturnKeys | T | string;\nconst getKeyConfig = <T extends KeyConfig | string>(key: KeyArg<T>, allConfigs: (KeyConfig | string)[]) => {\n return allConfigs.find((config) => (typeof config === 'string' ? config === key : config.key === key));\n};\n\nconst getValueType = (keyConfig: KeyConfig | string | undefined): KeyType => {\n return keyConfig && typeof keyConfig !== 'string' && 'type' in keyConfig\n ? (keyConfig.type ?? 'string')\n : 'string';\n};\n\nconst parseValue = (value: string | null, type: KeyType): AttributeValue => {\n if (!value && type !== 'boolean') return null;\n if (type === 'boolean') return value === 'true';\n if (type === 'number') return Number(value);\n return value;\n};\n\nconst getAllKeys = <T extends KeyConfig | string>(\n customKeys: (KeyConfig | T)[],\n): (AlwaysReturnKeys | T | string)[] => {\n return [\n ...ALWAYS_RETURN_KEYS.map((key) => (typeof key === 'string' ? key : key.key)),\n ...customKeys.map((key) => (typeof key === 'string' ? key : key.key)),\n ];\n};\n\nconst getInitialState = <T extends KeyConfig | string>(\n customKeys: (KeyConfig | T)[],\n): Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue> => {\n const allKeys = getAllKeys(customKeys);\n const initialState = {} as Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue>;\n allKeys.forEach((key) => {\n const typedKey = (typeof key === 'string' ? key : key.key) as ExtractKey<AlwaysReturnKeys | T>;\n initialState[typedKey] = null;\n });\n return initialState;\n};\n\nconst processAttribute = <T extends KeyConfig | string>(\n key: AlwaysReturnKeys | T | string,\n microFrontendDiv: HTMLElement,\n allConfigs: (KeyConfig | string)[],\n): { value: AttributeValue; key: ExtractKey<AlwaysReturnKeys | T> } => {\n const keyConfig = getKeyConfig(key, allConfigs);\n const type = getValueType(keyConfig);\n const keyString = typeof key === 'string' ? key : key.key;\n\n const envVar = import.meta.env[`VITE_${keyString.toUpperCase()}_OVERRIDE`] as string | null | undefined;\n const attributeKey = `data-${keyString}`;\n const domValue = microFrontendDiv.getAttribute(attributeKey);\n\n const value = envVar ? parseValue(envVar.toString(), type) : parseValue(domValue, type);\n return { value, key: keyString as ExtractKey<AlwaysReturnKeys | T> };\n};\n\n/**\n * Custom hook to manage micro-frontend attributes.\n *\n * This hook initializes and updates a set of attributes based on a combination of predefined keys (ALWAYS_RETURN_KEYS)\n * and custom keys provided as arguments. The attributes are fetched from environment variables or DOM attributes\n * and are updated dynamically using a MutationObserver.\n *\n * @template T - The type of custom keys, which can be either a string or a KeyConfig object.\n *\n * @param {Array<T | KeyConfig>} [customKeys=[]] - An array of custom keys or KeyConfig objects to be included in the attributes.\n *\n * @returns {Record<ExtractKey<AlwaysReturnKeys | T>, string | boolean | number | null>} - A record of attributes with their values.\n *\n * @example\n * const attributes = useMicroFrontendAttributes(['customKey1', { key: 'customKey2', type: 'boolean' }]);\n * console.log(attributes);\n */\nconst useMicroFrontendAttributes = <T extends KeyConfig | string>(\n customKeys: (KeyConfig | T)[] = [],\n): Record<ExtractKey<AlwaysReturnKeys | T>, AttributeValue> => {\n const [attributes, setAttributes] = useState(() => getInitialState(customKeys));\n\n useEffect(() => {\n const microFrontendDiv = document.getElementById('flipdish-micro-frontend');\n if (!microFrontendDiv) {\n console.warn('Micro-frontend div not found');\n return;\n }\n\n const allKeys = getAllKeys(customKeys);\n const allConfigs = [...ALWAYS_RETURN_KEYS, ...customKeys];\n\n const updateValues = () => {\n setAttributes((prev) => {\n const newAttributes = { ...prev };\n let isChanged = false;\n\n allKeys.forEach((key) => {\n const { value, key: typedKey } = processAttribute(key, microFrontendDiv, allConfigs);\n if (newAttributes[typedKey] !== value) {\n newAttributes[typedKey] = value;\n isChanged = true;\n }\n });\n\n return isChanged ? newAttributes : prev;\n });\n };\n\n updateValues();\n\n const observer = new MutationObserver(updateValues);\n observer.observe(microFrontendDiv, { attributes: true });\n\n return () => observer.disconnect();\n }, [customKeys]);\n\n return attributes;\n};\n\nexport default useMicroFrontendAttributes;\n"],"names":["ALWAYS_RETURN_KEYS","key","type","parseValue","value","Number","getAllKeys","customKeys","map","useMicroFrontendAttributes","attributes","setAttributes","useState","allKeys","initialState","forEach","typedKey","getInitialState","useEffect","microFrontendDiv","document","getElementById","console","warn","allConfigs","updateValues","prev","newAttributes","isChanged","keyConfig","find","config","getKeyConfig","getValueType","keyString","envVar","env","toUpperCase","attributeKey","domValue","getAttribute","toString","processAttribute","observer","MutationObserver","observe","disconnect"],"mappings":"gDASA,MAAMA,EAA6C,CACjD,SACA,SACA,CAAEC,IAAK,oBAAqBC,KAAM,YAuB9BC,EAAa,CAACC,EAAsBF,IACnCE,GAAkB,YAATF,EACD,YAATA,EAAqC,SAAVE,EAClB,WAATF,EAA0BG,OAAOD,GAC9BA,EAHkC,KAMrCE,EACJC,GAEO,IACFP,EAAmBQ,KAAKP,GAAwB,iBAARA,EAAmBA,EAAMA,EAAIA,SACrEM,EAAWC,KAAKP,GAAwB,iBAARA,EAAmBA,EAAMA,EAAIA,OAkD9DQ,EAA6B,CACjCF,EAAgC,MAEhC,MAAOG,EAAYC,GAAiBC,GAAS,IAjDvB,CACtBL,IAEA,MAAMM,EAAUP,EAAWC,GACrBO,EAAe,CAAA,EAKrB,OAJAD,EAAQE,SAASd,IACf,MAAMe,EAA2B,iBAARf,EAAmBA,EAAMA,EAAIA,IACtDa,EAAaE,GAAY,QAEpBF,GAwC4CG,CAAgBV,KAqCnE,OAnCAW,GAAU,KACR,MAAMC,EAAmBC,SAASC,eAAe,2BACjD,IAAKF,EAEH,YADAG,QAAQC,KAAK,gCAIf,MAAMV,EAAUP,EAAWC,GACrBiB,EAAa,IAAIxB,KAAuBO,GAExCkB,EAAe,KACnBd,GAAee,IACb,MAAMC,EAAgB,IAAKD,GAC3B,IAAIE,GAAY,EAUhB,OARAf,EAAQE,SAASd,IACf,MAAMG,MAAEA,EAAOH,IAAKe,GAvDL,EACvBf,EACAkB,EACAK,KAEA,MAAMK,EA3Ca,EAA+B5B,EAAgBuB,IAC3DA,EAAWM,MAAMC,GAA8B,iBAAXA,EAAsBA,IAAW9B,EAAM8B,EAAO9B,MAAQA,IA0C/E+B,CAAa/B,EAAKuB,GAC9BtB,EAxCa,CAAC2B,GACbA,GAAkC,iBAAdA,GAA0B,SAAUA,EAC1DA,EAAU3B,MAAQ,SACnB,SAqCS+B,CAAaJ,GACpBK,EAA2B,iBAARjC,EAAmBA,EAAMA,EAAIA,IAEhDkC,cAAqBC,IAAI,QAAQF,EAAUG,0BAC3CC,EAAe,QAAQJ,IACvBK,EAAWpB,EAAiBqB,aAAaF,GAG/C,MAAO,CAAElC,MADcD,EAATgC,EAAoBA,EAAOM,WAA+BF,EAAnBrC,GACrCD,IAAKiC,IAyCoBQ,CAAiBzC,EAAKkB,EAAkBK,GACrEG,EAAcX,KAAcZ,IAC9BuB,EAAcX,GAAYZ,EAC1BwB,GAAY,MAITA,EAAYD,EAAgBD,MAIvCD,IAEA,MAAMkB,EAAW,IAAIC,iBAAiBnB,GAGtC,OAFAkB,EAASE,QAAQ1B,EAAkB,CAAET,YAAY,IAE1C,IAAMiC,EAASG,eACrB,CAACvC,IAEGG"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("react");const t=e=>{const t=document.getElementById("flipdish-micro-frontend");return t?.getAttribute(e)||""};exports.getAppId=()=>(void 0).VITE_APPID_OVERRIDE||t("data-appId"),exports.getBrandId=()=>(void 0).VITE_BRANDID_OVERRIDE||t("data-brandId"),exports.getIsFlipdishStaff=()=>{const e=(void 0).VITE_ISFLIPDISHSTAFFOVERRIDE||t("data-isFlipdishStaff");return"true"===e?.toString()},exports.getMicroFrontendAttribute=t,exports.getOrgId=()=>(void 0).VITE_ORGID_OVERRIDE||t("data-orgId"),exports.lazyWithRetry=t=>e.lazy((async()=>{const e=JSON.parse(window.sessionStorage.getItem("page-has-been-force-refreshed")||"false");try{const e=await t();return window.sessionStorage.setItem("page-has-been-force-refreshed","false"),e}catch(t){if(!e)return window.sessionStorage.setItem("page-has-been-force-refreshed","true"),window.location.reload();throw t}}));
1
+ "use strict";var e=require("react");const t=e=>{const t=document.getElementById("flipdish-micro-frontend");return t?.getAttribute(e)||""};exports.getAppId=()=>(void 0).VITE_APPID_OVERRIDE||t("data-app-id")||t("data-appid"),exports.getBrandId=()=>(void 0).VITE_BRANDID_OVERRIDE||t("data-brand-id")||t("data-brandid"),exports.getIsFlipdishStaff=()=>{const e=(void 0).VITE_ISFLIPDISHSTAFFOVERRIDE||t("data-is-flipdish-staff")||t("data-isflipdishstaff");return"true"===e?.toString()},exports.getMicroFrontendAttribute=t,exports.getOrgId=()=>(void 0).VITE_ORGID_OVERRIDE||t("data-org-id")||t("data-orgid"),exports.lazyWithRetry=t=>e.lazy((async()=>{const e=JSON.parse(window.sessionStorage.getItem("page-has-been-force-refreshed")||"false");try{const e=await t();return window.sessionStorage.setItem("page-has-been-force-refreshed","false"),e}catch(t){if(!e)return window.sessionStorage.setItem("page-has-been-force-refreshed","true"),window.location.reload();throw t}}));
2
2
  //# sourceMappingURL=renderUtilities.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderUtilities.cjs.js","sources":["../../src/utilities/renderUtilities.ts"],"sourcesContent":["import { lazy } from 'react';\n\nexport const getMicroFrontendAttribute = (key: string): string => {\n const microFrontendDiv = document.getElementById('flipdish-micro-frontend');\n return microFrontendDiv?.getAttribute(key) || '';\n};\n\n/**\n * Retrieves the AppId.\n *\n * Attempts to get the value from the environment variable `VITE_APPID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-appId`.\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getAppId = (): string => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return import.meta.env['VITE_APPID_OVERRIDE'] || getMicroFrontendAttribute('data-appId');\n};\n\n/**\n * Retrieves the OrgId.\n *\n * Attempts to get the value from the environment variable `VITE_ORGID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-orgId`.\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getOrgId = (): string => {\n //TODO: change to kebab case to satisfy html attribute requirements\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return import.meta.env['VITE_ORGID_OVERRIDE'] || getMicroFrontendAttribute('data-orgId');\n};\n\n/**\n * Retrieves the BrandId.\n *\n * Attempts to get the value from the environment variable `VITE_BRANDID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-brandId`.\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getBrandId = (): string => {\n //TODO: change to kebab case to satisfy html attribute requirements\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return import.meta.env['VITE_BRANDID_OVERRIDE'] || getMicroFrontendAttribute('data-brandId');\n};\n\n/**\n * Retrieves the isFlipdishStaff attribute.\n *\n * Attempts to get the value from the environment variable `VITE_ISFLIPDISHSTAFFOVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-isFlipdishStaff`.\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getIsFlipdishStaff = (): boolean => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const stringValue =\n import.meta.env['VITE_ISFLIPDISHSTAFFOVERRIDE'] || getMicroFrontendAttribute('data-isFlipdishStaff');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access\n return stringValue?.toString() === 'true';\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const lazyWithRetry = (componentImport: () => any) =>\n lazy(async () => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const pageHasAlreadyBeenForceRefreshed = JSON.parse(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n window.sessionStorage.getItem('page-has-been-force-refreshed') || 'false',\n );\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const component = await componentImport();\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n window.sessionStorage.setItem('page-has-been-force-refreshed', 'false');\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return component;\n } catch (error) {\n if (!pageHasAlreadyBeenForceRefreshed) {\n // Assuming that the user is not on the latest version of the application.\n // Let's refresh the page immediately.\n window.sessionStorage.setItem('page-has-been-force-refreshed', 'true');\n return window.location.reload();\n }\n\n // The page has already been reloaded\n // Assuming that user is already using the latest version of the application.\n // Let's let the application crash and raise the error.\n throw error;\n }\n });\n"],"names":["getMicroFrontendAttribute","key","microFrontendDiv","document","getElementById","getAttribute","undefined","stringValue","toString","componentImport","lazy","async","pageHasAlreadyBeenForceRefreshed","JSON","parse","window","sessionStorage","getItem","component","setItem","error","location","reload"],"mappings":"oCAEO,MAAMA,EAA6BC,IACxC,MAAMC,EAAmBC,SAASC,eAAe,2BACjD,OAAOF,GAAkBG,aAAaJ,IAAQ,qBAWxB,UAEfK,GAAqC,qBAAKN,EAA0B,iCAyBnD,UAGjBM,GAAuC,uBAAKN,EAA0B,2CAW7C,KAEhC,MAAMO,QACJD,GAA8C,8BAAKN,EAA0B,wBAE/E,MAAmC,SAA5BO,GAAaC,iEAjCE,UAGfF,GAAqC,qBAAKN,EAA0B,oCAkC/CS,GAC5BC,EAAAA,MAAKC,UAEH,MAAMC,EAAmCC,KAAKC,MAE5CC,OAAOC,eAAeC,QAAQ,kCAAoC,SAGpE,IAEE,MAAMC,QAAkBT,IAKxB,OAHAM,OAAOC,eAAeG,QAAQ,gCAAiC,SAGxDD,CACT,CAAE,MAAOE,GACP,IAAKR,EAIH,OADAG,OAAOC,eAAeG,QAAQ,gCAAiC,QACxDJ,OAAOM,SAASC,SAMzB,MAAMF,CACR"}
1
+ {"version":3,"file":"renderUtilities.cjs.js","sources":["../../src/utilities/renderUtilities.ts"],"sourcesContent":["import { lazy } from 'react';\n\nexport const getMicroFrontendAttribute = (key: string): string => {\n const microFrontendDiv = document.getElementById('flipdish-micro-frontend');\n return microFrontendDiv?.getAttribute(key) || '';\n};\n\n/**\n * Retrieves the AppId.\n *\n * Attempts to get the value from the environment variable `VITE_APPID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-app-id`.\n * Fallbacks to `data-appid` for backwards compatibility @flipdish/portal-library@5.1.0 and below\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getAppId = (): string => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return import.meta.env['VITE_APPID_OVERRIDE'] || getMicroFrontendAttribute('data-app-id') || getMicroFrontendAttribute('data-appid');\n};\n\n/**\n * Retrieves the OrgId.\n *\n * Attempts to get the value from the environment variable `VITE_ORGID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-org-id`.\n * Fallbacks to `data-orgid` for backwards compatibility @flipdish/portal-library@5.1.0 and below\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getOrgId = (): string => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return import.meta.env['VITE_ORGID_OVERRIDE'] || getMicroFrontendAttribute('data-org-id') || getMicroFrontendAttribute('data-orgid');\n};\n\n/**\n * Retrieves the BrandId.\n *\n * Attempts to get the value from the environment variable `VITE_BRANDID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-brand-id`.\n * Fallbacks to `data-brandid` for backwards compatibility @flipdish/portal-library@5.1.0 and below\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getBrandId = (): string => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return import.meta.env['VITE_BRANDID_OVERRIDE'] || getMicroFrontendAttribute('data-brand-id') || getMicroFrontendAttribute('data-brandid');\n};\n\n/**\n * Retrieves the isFlipdishStaff attribute.\n *\n * Attempts to get the value from the environment variable `VITE_ISFLIPDISHSTAFFOVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-is-flipdish-staff`.\n * Fallbacks to `data-isflipdishstaff` for backwards compatibility @flipdish/portal-library@5.1.0 and below\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getIsFlipdishStaff = (): boolean => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const stringValue =\n import.meta.env['VITE_ISFLIPDISHSTAFFOVERRIDE'] || getMicroFrontendAttribute('data-is-flipdish-staff') || getMicroFrontendAttribute('data-isflipdishstaff');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access\n return stringValue?.toString() === 'true';\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const lazyWithRetry = (componentImport: () => any) =>\n lazy(async () => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const pageHasAlreadyBeenForceRefreshed = JSON.parse(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n window.sessionStorage.getItem('page-has-been-force-refreshed') || 'false',\n );\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const component = await componentImport();\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n window.sessionStorage.setItem('page-has-been-force-refreshed', 'false');\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return component;\n } catch (error) {\n if (!pageHasAlreadyBeenForceRefreshed) {\n // Assuming that the user is not on the latest version of the application.\n // Let's refresh the page immediately.\n window.sessionStorage.setItem('page-has-been-force-refreshed', 'true');\n return window.location.reload();\n }\n\n // The page has already been reloaded\n // Assuming that user is already using the latest version of the application.\n // Let's let the application crash and raise the error.\n throw error;\n }\n });\n"],"names":["getMicroFrontendAttribute","key","microFrontendDiv","document","getElementById","getAttribute","undefined","stringValue","toString","componentImport","lazy","async","pageHasAlreadyBeenForceRefreshed","JSON","parse","window","sessionStorage","getItem","component","setItem","error","location","reload"],"mappings":"oCAEO,MAAMA,EAA6BC,IACxC,MAAMC,EAAmBC,SAASC,eAAe,2BACjD,OAAOF,GAAkBG,aAAaJ,IAAQ,qBAYxB,UAEfK,GAAqC,qBAAKN,EAA0B,gBAAkBA,EAA0B,iCA0B/F,UAEjBM,GAAuC,uBAAKN,EAA0B,kBAAoBA,EAA0B,2CAY3F,KAEhC,MAAMO,QACJD,GAA8C,8BAAKN,EAA0B,2BAA6BA,EAA0B,wBAEtI,MAAmC,SAA5BO,GAAaC,iEAjCE,UAEfF,GAAqC,qBAAKN,EAA0B,gBAAkBA,EAA0B,oCAmC3FS,GAC5BC,EAAAA,MAAKC,UAEH,MAAMC,EAAmCC,KAAKC,MAE5CC,OAAOC,eAAeC,QAAQ,kCAAoC,SAGpE,IAEE,MAAMC,QAAkBT,IAKxB,OAHAM,OAAOC,eAAeG,QAAQ,gCAAiC,SAGxDD,CACT,CAAE,MAAOE,GACP,IAAKR,EAIH,OADAG,OAAOC,eAAeG,QAAQ,gCAAiC,QACxDJ,OAAOM,SAASC,SAMzB,MAAMF,CACR"}
@@ -5,7 +5,8 @@ declare const getMicroFrontendAttribute: (key: string) => string;
5
5
  * Retrieves the AppId.
6
6
  *
7
7
  * Attempts to get the value from the environment variable `VITE_APPID_OVERRIDE`.
8
- * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-appId`.
8
+ * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-app-id`.
9
+ * Fallbacks to `data-appid` for backwards compatibility @flipdish/portal-library@5.1.0 and below
9
10
  *
10
11
  * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.
11
12
  */
@@ -14,7 +15,8 @@ declare const getAppId: () => string;
14
15
  * Retrieves the OrgId.
15
16
  *
16
17
  * Attempts to get the value from the environment variable `VITE_ORGID_OVERRIDE`.
17
- * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-orgId`.
18
+ * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-org-id`.
19
+ * Fallbacks to `data-orgid` for backwards compatibility @flipdish/portal-library@5.1.0 and below
18
20
  *
19
21
  * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.
20
22
  */
@@ -23,7 +25,8 @@ declare const getOrgId: () => string;
23
25
  * Retrieves the BrandId.
24
26
  *
25
27
  * Attempts to get the value from the environment variable `VITE_BRANDID_OVERRIDE`.
26
- * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-brandId`.
28
+ * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-brand-id`.
29
+ * Fallbacks to `data-brandid` for backwards compatibility @flipdish/portal-library@5.1.0 and below
27
30
  *
28
31
  * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.
29
32
  */
@@ -32,7 +35,8 @@ declare const getBrandId: () => string;
32
35
  * Retrieves the isFlipdishStaff attribute.
33
36
  *
34
37
  * Attempts to get the value from the environment variable `VITE_ISFLIPDISHSTAFFOVERRIDE`.
35
- * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-isFlipdishStaff`.
38
+ * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-is-flipdish-staff`.
39
+ * Fallbacks to `data-isflipdishstaff` for backwards compatibility @flipdish/portal-library@5.1.0 and below
36
40
  *
37
41
  * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.
38
42
  */
@@ -1,2 +1,2 @@
1
- import{lazy as e}from"react";const t=e=>{const t=document.getElementById("flipdish-micro-frontend");return t?.getAttribute(e)||""},r=()=>import.meta.env.VITE_APPID_OVERRIDE||t("data-appId"),a=()=>import.meta.env.VITE_ORGID_OVERRIDE||t("data-orgId"),o=()=>import.meta.env.VITE_BRANDID_OVERRIDE||t("data-brandId"),n=()=>{const e=import.meta.env.VITE_ISFLIPDISHSTAFFOVERRIDE||t("data-isFlipdishStaff");return"true"===e?.toString()},s=t=>e((async()=>{const e=JSON.parse(window.sessionStorage.getItem("page-has-been-force-refreshed")||"false");try{const e=await t();return window.sessionStorage.setItem("page-has-been-force-refreshed","false"),e}catch(t){if(!e)return window.sessionStorage.setItem("page-has-been-force-refreshed","true"),window.location.reload();throw t}}));export{r as getAppId,o as getBrandId,n as getIsFlipdishStaff,t as getMicroFrontendAttribute,a as getOrgId,s as lazyWithRetry};
1
+ import{lazy as e}from"react";const t=e=>{const t=document.getElementById("flipdish-micro-frontend");return t?.getAttribute(e)||""},a=()=>import.meta.env.VITE_APPID_OVERRIDE||t("data-app-id")||t("data-appid"),r=()=>import.meta.env.VITE_ORGID_OVERRIDE||t("data-org-id")||t("data-orgid"),o=()=>import.meta.env.VITE_BRANDID_OVERRIDE||t("data-brand-id")||t("data-brandid"),s=()=>{const e=import.meta.env.VITE_ISFLIPDISHSTAFFOVERRIDE||t("data-is-flipdish-staff")||t("data-isflipdishstaff");return"true"===e?.toString()},i=t=>e((async()=>{const e=JSON.parse(window.sessionStorage.getItem("page-has-been-force-refreshed")||"false");try{const e=await t();return window.sessionStorage.setItem("page-has-been-force-refreshed","false"),e}catch(t){if(!e)return window.sessionStorage.setItem("page-has-been-force-refreshed","true"),window.location.reload();throw t}}));export{a as getAppId,o as getBrandId,s as getIsFlipdishStaff,t as getMicroFrontendAttribute,r as getOrgId,i as lazyWithRetry};
2
2
  //# sourceMappingURL=renderUtilities.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderUtilities.js","sources":["../../src/utilities/renderUtilities.ts"],"sourcesContent":["import { lazy } from 'react';\n\nexport const getMicroFrontendAttribute = (key: string): string => {\n const microFrontendDiv = document.getElementById('flipdish-micro-frontend');\n return microFrontendDiv?.getAttribute(key) || '';\n};\n\n/**\n * Retrieves the AppId.\n *\n * Attempts to get the value from the environment variable `VITE_APPID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-appId`.\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getAppId = (): string => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return import.meta.env['VITE_APPID_OVERRIDE'] || getMicroFrontendAttribute('data-appId');\n};\n\n/**\n * Retrieves the OrgId.\n *\n * Attempts to get the value from the environment variable `VITE_ORGID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-orgId`.\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getOrgId = (): string => {\n //TODO: change to kebab case to satisfy html attribute requirements\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return import.meta.env['VITE_ORGID_OVERRIDE'] || getMicroFrontendAttribute('data-orgId');\n};\n\n/**\n * Retrieves the BrandId.\n *\n * Attempts to get the value from the environment variable `VITE_BRANDID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-brandId`.\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getBrandId = (): string => {\n //TODO: change to kebab case to satisfy html attribute requirements\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return import.meta.env['VITE_BRANDID_OVERRIDE'] || getMicroFrontendAttribute('data-brandId');\n};\n\n/**\n * Retrieves the isFlipdishStaff attribute.\n *\n * Attempts to get the value from the environment variable `VITE_ISFLIPDISHSTAFFOVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-isFlipdishStaff`.\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getIsFlipdishStaff = (): boolean => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const stringValue =\n import.meta.env['VITE_ISFLIPDISHSTAFFOVERRIDE'] || getMicroFrontendAttribute('data-isFlipdishStaff');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access\n return stringValue?.toString() === 'true';\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const lazyWithRetry = (componentImport: () => any) =>\n lazy(async () => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const pageHasAlreadyBeenForceRefreshed = JSON.parse(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n window.sessionStorage.getItem('page-has-been-force-refreshed') || 'false',\n );\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const component = await componentImport();\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n window.sessionStorage.setItem('page-has-been-force-refreshed', 'false');\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return component;\n } catch (error) {\n if (!pageHasAlreadyBeenForceRefreshed) {\n // Assuming that the user is not on the latest version of the application.\n // Let's refresh the page immediately.\n window.sessionStorage.setItem('page-has-been-force-refreshed', 'true');\n return window.location.reload();\n }\n\n // The page has already been reloaded\n // Assuming that user is already using the latest version of the application.\n // Let's let the application crash and raise the error.\n throw error;\n }\n });\n"],"names":["getMicroFrontendAttribute","key","microFrontendDiv","document","getElementById","getAttribute","getAppId","env","getOrgId","getBrandId","getIsFlipdishStaff","stringValue","toString","lazyWithRetry","componentImport","lazy","async","pageHasAlreadyBeenForceRefreshed","JSON","parse","window","sessionStorage","getItem","component","setItem","error","location","reload"],"mappings":"6BAEO,MAAMA,EAA6BC,IACxC,MAAMC,EAAmBC,SAASC,eAAe,2BACjD,OAAOF,GAAkBG,aAAaJ,IAAQ,IAWnCK,EAAW,gBAEHC,IAAyB,qBAAKP,EAA0B,cAWhEQ,EAAW,gBAGHD,IAAyB,qBAAKP,EAA0B,cAWhES,EAAa,gBAGLF,IAA2B,uBAAKP,EAA0B,gBAWlEU,EAAqB,KAEhC,MAAMC,cACQJ,IAAkC,8BAAKP,EAA0B,wBAE/E,MAAmC,SAA5BW,GAAaC,YAITC,EAAiBC,GAC5BC,GAAKC,UAEH,MAAMC,EAAmCC,KAAKC,MAE5CC,OAAOC,eAAeC,QAAQ,kCAAoC,SAGpE,IAEE,MAAMC,QAAkBT,IAKxB,OAHAM,OAAOC,eAAeG,QAAQ,gCAAiC,SAGxDD,CACT,CAAE,MAAOE,GACP,IAAKR,EAIH,OADAG,OAAOC,eAAeG,QAAQ,gCAAiC,QACxDJ,OAAOM,SAASC,SAMzB,MAAMF,CACR"}
1
+ {"version":3,"file":"renderUtilities.js","sources":["../../src/utilities/renderUtilities.ts"],"sourcesContent":["import { lazy } from 'react';\n\nexport const getMicroFrontendAttribute = (key: string): string => {\n const microFrontendDiv = document.getElementById('flipdish-micro-frontend');\n return microFrontendDiv?.getAttribute(key) || '';\n};\n\n/**\n * Retrieves the AppId.\n *\n * Attempts to get the value from the environment variable `VITE_APPID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-app-id`.\n * Fallbacks to `data-appid` for backwards compatibility @flipdish/portal-library@5.1.0 and below\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getAppId = (): string => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return import.meta.env['VITE_APPID_OVERRIDE'] || getMicroFrontendAttribute('data-app-id') || getMicroFrontendAttribute('data-appid');\n};\n\n/**\n * Retrieves the OrgId.\n *\n * Attempts to get the value from the environment variable `VITE_ORGID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-org-id`.\n * Fallbacks to `data-orgid` for backwards compatibility @flipdish/portal-library@5.1.0 and below\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getOrgId = (): string => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return import.meta.env['VITE_ORGID_OVERRIDE'] || getMicroFrontendAttribute('data-org-id') || getMicroFrontendAttribute('data-orgid');\n};\n\n/**\n * Retrieves the BrandId.\n *\n * Attempts to get the value from the environment variable `VITE_BRANDID_OVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-brand-id`.\n * Fallbacks to `data-brandid` for backwards compatibility @flipdish/portal-library@5.1.0 and below\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getBrandId = (): string => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return import.meta.env['VITE_BRANDID_OVERRIDE'] || getMicroFrontendAttribute('data-brand-id') || getMicroFrontendAttribute('data-brandid');\n};\n\n/**\n * Retrieves the isFlipdishStaff attribute.\n *\n * Attempts to get the value from the environment variable `VITE_ISFLIPDISHSTAFFOVERRIDE`.\n * If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-is-flipdish-staff`.\n * Fallbacks to `data-isflipdishstaff` for backwards compatibility @flipdish/portal-library@5.1.0 and below\n *\n * @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.\n */\nexport const getIsFlipdishStaff = (): boolean => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const stringValue =\n import.meta.env['VITE_ISFLIPDISHSTAFFOVERRIDE'] || getMicroFrontendAttribute('data-is-flipdish-staff') || getMicroFrontendAttribute('data-isflipdishstaff');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access\n return stringValue?.toString() === 'true';\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const lazyWithRetry = (componentImport: () => any) =>\n lazy(async () => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const pageHasAlreadyBeenForceRefreshed = JSON.parse(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n window.sessionStorage.getItem('page-has-been-force-refreshed') || 'false',\n );\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const component = await componentImport();\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n window.sessionStorage.setItem('page-has-been-force-refreshed', 'false');\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return component;\n } catch (error) {\n if (!pageHasAlreadyBeenForceRefreshed) {\n // Assuming that the user is not on the latest version of the application.\n // Let's refresh the page immediately.\n window.sessionStorage.setItem('page-has-been-force-refreshed', 'true');\n return window.location.reload();\n }\n\n // The page has already been reloaded\n // Assuming that user is already using the latest version of the application.\n // Let's let the application crash and raise the error.\n throw error;\n }\n });\n"],"names":["getMicroFrontendAttribute","key","microFrontendDiv","document","getElementById","getAttribute","getAppId","env","getOrgId","getBrandId","getIsFlipdishStaff","stringValue","toString","lazyWithRetry","componentImport","lazy","async","pageHasAlreadyBeenForceRefreshed","JSON","parse","window","sessionStorage","getItem","component","setItem","error","location","reload"],"mappings":"6BAEO,MAAMA,EAA6BC,IACxC,MAAMC,EAAmBC,SAASC,eAAe,2BACjD,OAAOF,GAAkBG,aAAaJ,IAAQ,IAYnCK,EAAW,gBAEHC,IAAyB,qBAAKP,EAA0B,gBAAkBA,EAA0B,cAY5GQ,EAAW,gBAEHD,IAAyB,qBAAKP,EAA0B,gBAAkBA,EAA0B,cAY5GS,EAAa,gBAELF,IAA2B,uBAAKP,EAA0B,kBAAoBA,EAA0B,gBAYhHU,EAAqB,KAEhC,MAAMC,cACQJ,IAAkC,8BAAKP,EAA0B,2BAA6BA,EAA0B,wBAEtI,MAAmC,SAA5BW,GAAaC,YAITC,EAAiBC,GAC5BC,GAAKC,UAEH,MAAMC,EAAmCC,KAAKC,MAE5CC,OAAOC,eAAeC,QAAQ,kCAAoC,SAGpE,IAEE,MAAMC,QAAkBT,IAKxB,OAHAM,OAAOC,eAAeG,QAAQ,gCAAiC,SAGxDD,CACT,CAAE,MAAOE,GACP,IAAKR,EAIH,OADAG,OAAOC,eAAeG,QAAQ,gCAAiC,QACxDJ,OAAOM,SAASC,SAMzB,MAAMF,CACR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flipdish/portal-library",
3
- "version": "5.1.0",
3
+ "version": "5.3.0",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -1,2 +0,0 @@
1
- "use strict";var r=require("react/jsx-runtime"),e=require("@mui/material/styles"),o=require("react");const t=e.styled("div")((({hovered:r,isScrolling:e})=>({overflowX:"auto","&::-webkit-scrollbar":{padding:"2px 0",height:"6px",border:"1px solid #d5d5d5"},"&::-webkit-scrollbar-track":{background:"#f1f1f1"},"&::-webkit-scrollbar-thumb":{background:r?"rgba(5, 20, 158, 0.3)":"#f5f5f5",borderRadius:"3px"},"&::-webkit-scrollbar-thumb:horizontal:active, &::-webkit-scrollbar-thumb:vertical:active":{background:r?"rgba(5, 20, 158, 0.6)":"#f5f5f5"},"&:hover .sticky":{boxShadow:e?"0px 2px 6px rgba(0, 0, 0, 0.5)":"none",transition:"box-shadow 200ms"}})));module.exports=e=>{const{children:l,onScroll:i,setIsScrolling:a,setScrollStarted:s}=e,[c,b]=o.useState(!1);return r.jsx(t,{hovered:c,isScrolling:!!a,onMouseEnter:()=>b(!0),onMouseLeave:()=>{b(!1),a&&a(!1),s&&s(!1)},onScroll:i,children:l})};
2
- //# sourceMappingURL=HighlightScrollbar.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HighlightScrollbar.cjs.js","sources":["../../../src/components/GenericTable/HighlightScrollbar.tsx"],"sourcesContent":["import { styled } from '@mui/material/styles';\nimport React, { useState } from 'react';\n\ntype HighlightScrollbarProps = {\n children: React.ReactNode;\n onScroll?: () => void;\n setIsScrolling?: React.Dispatch<React.SetStateAction<boolean>>;\n setScrollStarted?: React.Dispatch<React.SetStateAction<boolean>>;\n};\n\ninterface ContainerProps {\n hovered: boolean;\n isScrolling: boolean;\n}\n\nconst StyledContainer = styled('div')<ContainerProps>(({ hovered, isScrolling }) => ({\n overflowX: 'auto',\n '&::-webkit-scrollbar': {\n padding: '2px 0',\n height: '6px',\n border: '1px solid #d5d5d5',\n },\n '&::-webkit-scrollbar-track': {\n background: '#f1f1f1',\n },\n '&::-webkit-scrollbar-thumb': {\n background: hovered ? 'rgba(5, 20, 158, 0.3)' : '#f5f5f5',\n borderRadius: '3px',\n },\n '&::-webkit-scrollbar-thumb:horizontal:active, &::-webkit-scrollbar-thumb:vertical:active': {\n background: hovered ? 'rgba(5, 20, 158, 0.6)' : '#f5f5f5',\n },\n '&:hover .sticky': {\n boxShadow: isScrolling ? '0px 2px 6px rgba(0, 0, 0, 0.5)' : 'none',\n transition: 'box-shadow 200ms',\n },\n}));\n\nconst HighlightScrollbar: React.FC<React.PropsWithChildren<HighlightScrollbarProps>> = (props) => {\n const { children, onScroll, setIsScrolling, setScrollStarted } = props;\n const [hoveredTable, setHoveredTable] = useState(false);\n\n const highlightScrollbar = () => setHoveredTable(true);\n\n const fadeScrollbar = () => {\n setHoveredTable(false);\n if (setIsScrolling) setIsScrolling(false);\n if (setScrollStarted) setScrollStarted(false);\n };\n\n return (\n <StyledContainer\n hovered={hoveredTable}\n isScrolling={!!setIsScrolling}\n onMouseEnter={highlightScrollbar}\n onMouseLeave={fadeScrollbar}\n onScroll={onScroll}\n >\n {children}\n </StyledContainer>\n );\n};\n\nexport default HighlightScrollbar;\n"],"names":["StyledContainer","styled","hovered","isScrolling","overflowX","padding","height","border","background","borderRadius","boxShadow","transition","props","children","onScroll","setIsScrolling","setScrollStarted","hoveredTable","setHoveredTable","useState","_jsx","onMouseEnter","onMouseLeave"],"mappings":"qGAeA,MAAMA,EAAkBC,EAAAA,OAAO,MAAPA,EAA8B,EAAGC,UAASC,kBAAa,CAC3EC,UAAW,OACX,uBAAwB,CACpBC,QAAS,QACTC,OAAQ,MACRC,OAAQ,qBAEZ,6BAA8B,CAC1BC,WAAY,WAEhB,6BAA8B,CAC1BA,WAAYN,EAAU,wBAA0B,UAChDO,aAAc,OAElB,2FAA4F,CACxFD,WAAYN,EAAU,wBAA0B,WAEpD,kBAAmB,CACfQ,UAAWP,EAAc,iCAAmC,OAC5DQ,WAAY,uCAIoEC,IACpF,MAAMC,SAAEA,EAAQC,SAAEA,EAAQC,eAAEA,EAAcC,iBAAEA,GAAqBJ,GAC1DK,EAAcC,GAAmBC,EAAAA,UAAS,GAUjD,OACIC,EAAAA,IAACpB,EAAe,CACZE,QAASe,EACTd,cAAeY,EACfM,aAZmB,IAAMH,GAAgB,GAazCI,aAXc,KAClBJ,GAAgB,GACZH,GAAgBA,GAAe,GAC/BC,GAAkBA,GAAiB,IASnCF,SAAUA,EAAQD,SAEjBA"}
@@ -1,2 +0,0 @@
1
- import{jsx as r}from"react/jsx-runtime";import{styled as o}from"@mui/material/styles";import{useState as e}from"react";const t=o("div")((({hovered:r,isScrolling:o})=>({overflowX:"auto","&::-webkit-scrollbar":{padding:"2px 0",height:"6px",border:"1px solid #d5d5d5"},"&::-webkit-scrollbar-track":{background:"#f1f1f1"},"&::-webkit-scrollbar-thumb":{background:r?"rgba(5, 20, 158, 0.3)":"#f5f5f5",borderRadius:"3px"},"&::-webkit-scrollbar-thumb:horizontal:active, &::-webkit-scrollbar-thumb:vertical:active":{background:r?"rgba(5, 20, 158, 0.6)":"#f5f5f5"},"&:hover .sticky":{boxShadow:o?"0px 2px 6px rgba(0, 0, 0, 0.5)":"none",transition:"box-shadow 200ms"}}))),l=o=>{const{children:l,onScroll:a,setIsScrolling:i,setScrollStarted:c}=o,[s,b]=e(!1);return r(t,{hovered:s,isScrolling:!!i,onMouseEnter:()=>b(!0),onMouseLeave:()=>{b(!1),i&&i(!1),c&&c(!1)},onScroll:a,children:l})};export{l as default};
2
- //# sourceMappingURL=HighlightScrollbar.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HighlightScrollbar.js","sources":["../../../src/components/GenericTable/HighlightScrollbar.tsx"],"sourcesContent":["import { styled } from '@mui/material/styles';\nimport React, { useState } from 'react';\n\ntype HighlightScrollbarProps = {\n children: React.ReactNode;\n onScroll?: () => void;\n setIsScrolling?: React.Dispatch<React.SetStateAction<boolean>>;\n setScrollStarted?: React.Dispatch<React.SetStateAction<boolean>>;\n};\n\ninterface ContainerProps {\n hovered: boolean;\n isScrolling: boolean;\n}\n\nconst StyledContainer = styled('div')<ContainerProps>(({ hovered, isScrolling }) => ({\n overflowX: 'auto',\n '&::-webkit-scrollbar': {\n padding: '2px 0',\n height: '6px',\n border: '1px solid #d5d5d5',\n },\n '&::-webkit-scrollbar-track': {\n background: '#f1f1f1',\n },\n '&::-webkit-scrollbar-thumb': {\n background: hovered ? 'rgba(5, 20, 158, 0.3)' : '#f5f5f5',\n borderRadius: '3px',\n },\n '&::-webkit-scrollbar-thumb:horizontal:active, &::-webkit-scrollbar-thumb:vertical:active': {\n background: hovered ? 'rgba(5, 20, 158, 0.6)' : '#f5f5f5',\n },\n '&:hover .sticky': {\n boxShadow: isScrolling ? '0px 2px 6px rgba(0, 0, 0, 0.5)' : 'none',\n transition: 'box-shadow 200ms',\n },\n}));\n\nconst HighlightScrollbar: React.FC<React.PropsWithChildren<HighlightScrollbarProps>> = (props) => {\n const { children, onScroll, setIsScrolling, setScrollStarted } = props;\n const [hoveredTable, setHoveredTable] = useState(false);\n\n const highlightScrollbar = () => setHoveredTable(true);\n\n const fadeScrollbar = () => {\n setHoveredTable(false);\n if (setIsScrolling) setIsScrolling(false);\n if (setScrollStarted) setScrollStarted(false);\n };\n\n return (\n <StyledContainer\n hovered={hoveredTable}\n isScrolling={!!setIsScrolling}\n onMouseEnter={highlightScrollbar}\n onMouseLeave={fadeScrollbar}\n onScroll={onScroll}\n >\n {children}\n </StyledContainer>\n );\n};\n\nexport default HighlightScrollbar;\n"],"names":["StyledContainer","styled","hovered","isScrolling","overflowX","padding","height","border","background","borderRadius","boxShadow","transition","HighlightScrollbar","props","children","onScroll","setIsScrolling","setScrollStarted","hoveredTable","setHoveredTable","useState","_jsx","onMouseEnter","onMouseLeave"],"mappings":"uHAeA,MAAMA,EAAkBC,EAAO,MAAPA,EAA8B,EAAGC,UAASC,kBAAa,CAC3EC,UAAW,OACX,uBAAwB,CACpBC,QAAS,QACTC,OAAQ,MACRC,OAAQ,qBAEZ,6BAA8B,CAC1BC,WAAY,WAEhB,6BAA8B,CAC1BA,WAAYN,EAAU,wBAA0B,UAChDO,aAAc,OAElB,2FAA4F,CACxFD,WAAYN,EAAU,wBAA0B,WAEpD,kBAAmB,CACfQ,UAAWP,EAAc,iCAAmC,OAC5DQ,WAAY,wBAIdC,EAAkFC,IACpF,MAAMC,SAAEA,EAAQC,SAAEA,EAAQC,eAAEA,EAAcC,iBAAEA,GAAqBJ,GAC1DK,EAAcC,GAAmBC,GAAS,GAUjD,OACIC,EAACrB,EAAe,CACZE,QAASgB,EACTf,cAAea,EACfM,aAZmB,IAAMH,GAAgB,GAazCI,aAXc,KAClBJ,GAAgB,GACZH,GAAgBA,GAAe,GAC/BC,GAAkBA,GAAiB,IASnCF,SAAUA,EAAQD,SAEjBA"}
@@ -1,18 +0,0 @@
1
- "use strict";var e=require("react/jsx-runtime"),i=require("@mui/material/Card"),t=require("@mui/material/IconButton"),r=require("@mui/material/styles"),a=require("@mui/material/Table"),l=require("@mui/material/TableCell"),s=require("@mui/material/TableHead"),n=require("@mui/material/TableRow"),o=require("@mui/material/Tooltip"),d=require("@mui/material/useMediaQuery"),c=require("../../icons/InformationCircle/index.cjs.js"),u=require("../GenericTableBody/index.cjs.js"),m=require("../GenericTableTitle/index.cjs.js"),h=require("./HighlightScrollbar.cjs.js");const p=r.styled("div")`
2
- overflow-x: auto;
3
- &::-webkit-scrollbar {
4
- padding: 2px 0;
5
- height: 6px;
6
- border: 1px solid #d5d5d5;
7
- }
8
- &::-webkit-scrollbar-track {
9
- background: #f1f1f1;
10
- }
11
- &::-webkit-scrollbar-thumb {
12
- background: #f5f5f5;
13
- border-radius: 3px;
14
- }
15
- `,x=r.styled(l,{shouldForwardProp:e=>"isSticky"!==e&&"titleVariant"!==e})((({theme:e,isSticky:i,titleVariant:t})=>({fontSize:13,fontWeight:"light"===t?400:e.typography.fontWeightMedium,color:"light"===t?e.palette.semantic.text["text-weak"]:e.palette.semantic.text["text-strong"],padding:e.spacing(1.25,2),whiteSpace:"nowrap",position:i?"sticky":"relative",zIndex:i?1:"auto"}))),b=r.styled(i)`
16
- overflow: hidden;
17
- `,g=r.styled(o)((({theme:e})=>({marginLeft:e.spacing(.5),svg:{fontSize:e.typography.body1.fontSize}})));module.exports=({data:i,title:l,subTitle:o,showTitle:j=!0,onRowClick:f,loading:y,metadata:k,titleVariant:w="default"})=>{const q=new Set(k.filter((e=>e.isVisible)).sort(((e,i)=>e.ordinal-i.ordinal)).map((e=>e.columnName))),T=k.reduce(((e,i)=>(e[i.columnName]=i,e)),{}),S=r.useTheme(),v=!d(S.breakpoints.up("tablet")),z=v?"normal":"sticky";return e.jsxs(p,{children:[j&&e.jsx(m,{subTitle:o,title:l}),e.jsx(b,{children:e.jsx(h,{children:e.jsxs(a,{"aria-label":l,"data-testid":"generic-table"+(j?`-${l?.replace(" ","-").toLowerCase()}`:""),children:[e.jsx(s,{children:e.jsx(n,{children:Array.from(q).map(((i,r)=>{const{columnName:a,columnTitle:l,align:s="left",tooltip:n}=T[i]||{};return e.jsx(x,{align:s,isSticky:0===r&&!v,titleVariant:w,children:e.jsxs("div",{children:[e.jsx("span",{children:l}),n&&e.jsx(g,{placement:"right-start",title:n,children:e.jsx(t,{size:"small",children:e.jsx(c,{"data-testid":"InfoOutlinedIcon",size:"sm"})})})]})},a)}))})}),e.jsx(u,{columns:q,data:i,loading:y,meta:T,type:z,onRowClick:f})]})})})]})};
18
- //# sourceMappingURL=index.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../../../src/components/GenericTable/index.tsx"],"sourcesContent":["import Card from '@mui/material/Card';\nimport IconButton from '@mui/material/IconButton';\nimport { styled, useTheme } from '@mui/material/styles';\nimport Table from '@mui/material/Table';\nimport TableCell from '@mui/material/TableCell';\nimport TableHead from '@mui/material/TableHead';\nimport TableRow from '@mui/material/TableRow';\nimport Tooltip from '@mui/material/Tooltip';\nimport useMediaQuery from '@mui/material/useMediaQuery';\n\nimport InfoOutlinedIcon from '../../icons/InformationCircle';\nimport GenericTableBody, { type GenericTableColumns } from '../GenericTableBody';\nimport GenericTableTitle from '../GenericTableTitle';\nimport HighlightScrollbar from './HighlightScrollbar';\n\ninterface GenericTableProps {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data?: any[];\n loading?: boolean;\n metadata: GenericTableColumns[];\n // eslint-disable-next-line @typescript-eslint/ban-types\n onRowClick?: Function;\n showTitle?: boolean;\n subTitle?: string;\n title?: string;\n titleVariant?: 'default' | 'light';\n}\n\nconst StyledContainer = styled('div')`\n overflow-x: auto;\n &::-webkit-scrollbar {\n padding: 2px 0;\n height: 6px;\n border: 1px solid #d5d5d5;\n }\n &::-webkit-scrollbar-track {\n background: #f1f1f1;\n }\n &::-webkit-scrollbar-thumb {\n background: #f5f5f5;\n border-radius: 3px;\n }\n`;\n\nconst StyledTableCell = styled(TableCell, {\n shouldForwardProp: (prop) => prop !== 'isSticky' && prop !== 'titleVariant',\n})<{ isSticky: boolean; titleVariant: 'default' | 'light' }>(({ theme, isSticky, titleVariant }) => ({\n fontSize: 13,\n fontWeight: titleVariant === 'light' ? 400 : theme.typography.fontWeightMedium,\n color:\n titleVariant === 'light'\n ? theme.palette.semantic.text['text-weak']\n : theme.palette.semantic.text['text-strong'],\n padding: theme.spacing(1.25, 2),\n whiteSpace: 'nowrap',\n position: isSticky ? 'sticky' : 'relative',\n zIndex: isSticky ? 1 : 'auto',\n}));\n\nconst StyledPaper = styled(Card)`\n overflow: hidden;\n`;\n\nconst StyledTooltip = styled(Tooltip)(({ theme }) => ({\n marginLeft: theme.spacing(0.5),\n svg: {\n fontSize: theme.typography.body1.fontSize,\n },\n}));\n\nconst GenericTable = ({\n data,\n title,\n subTitle,\n showTitle = true,\n onRowClick,\n loading,\n metadata,\n titleVariant = 'default',\n}: GenericTableProps) => {\n const columns = new Set(\n metadata\n .filter((m) => m.isVisible)\n .sort((a, b) => a.ordinal - b.ordinal)\n .map((m) => m.columnName),\n );\n const tableMeta = metadata.reduce<{ [key: string]: GenericTableColumns }>((obj, mData) => {\n obj[mData.columnName] = mData;\n return obj;\n }, {});\n\n const theme = useTheme();\n const isMobile = !useMediaQuery(theme.breakpoints.up('tablet'));\n\n // We never want sticky on mobile - only on desktop\n const firstColumnStylePosition = isMobile ? 'normal' : 'sticky';\n\n const renderTableHeader = () => (\n <TableHead>\n <TableRow>\n {Array.from(columns).map((prop, idx) => {\n const { columnName, columnTitle, align = 'left', tooltip } = tableMeta[prop] || {};\n\n return (\n <StyledTableCell\n key={columnName}\n align={align}\n isSticky={idx === 0 && !isMobile}\n titleVariant={titleVariant}\n >\n <div>\n <span>{columnTitle}</span>\n {tooltip && (\n <StyledTooltip placement=\"right-start\" title={tooltip}>\n <IconButton size=\"small\">\n <InfoOutlinedIcon data-testid=\"InfoOutlinedIcon\" size=\"sm\" />\n </IconButton>\n </StyledTooltip>\n )}\n </div>\n </StyledTableCell>\n );\n })}\n </TableRow>\n </TableHead>\n );\n\n return (\n <StyledContainer>\n {showTitle && <GenericTableTitle subTitle={subTitle} title={title}></GenericTableTitle>}\n <StyledPaper>\n <HighlightScrollbar>\n <Table\n aria-label={title}\n data-testid={`generic-table` + (showTitle ? `-${title?.replace(' ', '-').toLowerCase()}` : '')}\n >\n {renderTableHeader()}\n <GenericTableBody\n columns={columns}\n data={data}\n loading={loading}\n meta={tableMeta}\n type={firstColumnStylePosition}\n onRowClick={onRowClick}\n />\n </Table>\n </HighlightScrollbar>\n </StyledPaper>\n </StyledContainer>\n );\n};\n\nexport default GenericTable;\n"],"names":["StyledContainer","styled","StyledTableCell","TableCell","shouldForwardProp","prop","theme","isSticky","titleVariant","fontSize","fontWeight","typography","fontWeightMedium","color","palette","semantic","text","padding","spacing","whiteSpace","position","zIndex","StyledPaper","Card","StyledTooltip","Tooltip","marginLeft","svg","body1","data","title","subTitle","showTitle","onRowClick","loading","metadata","columns","Set","filter","m","isVisible","sort","a","b","ordinal","map","columnName","tableMeta","reduce","obj","mData","useTheme","isMobile","useMediaQuery","breakpoints","up","firstColumnStylePosition","_jsxs","_jsx","GenericTableTitle","children","HighlightScrollbar","Table","replace","toLowerCase","TableHead","TableRow","Array","from","idx","columnTitle","align","tooltip","placement","IconButton","size","InfoOutlinedIcon","GenericTableBody","meta","type"],"mappings":"ijBA4BA,MAAMA,EAAkBC,EAAAA,OAAO,MAAM;;;;;;;;;;;;;;EAgB/BC,EAAkBD,EAAAA,OAAOE,EAAW,CACxCC,kBAAoBC,GAAkB,aAATA,GAAgC,iBAATA,GAD9BJ,EAEqC,EAAGK,QAAOC,WAAUC,mBAAc,CAC7FC,SAAU,GACVC,WAA6B,UAAjBF,EAA2B,IAAMF,EAAMK,WAAWC,iBAC9DC,MACmB,UAAjBL,EACIF,EAAMQ,QAAQC,SAASC,KAAK,aAC5BV,EAAMQ,QAAQC,SAASC,KAAK,eAClCC,QAASX,EAAMY,QAAQ,KAAM,GAC7BC,WAAY,SACZC,SAAUb,EAAW,SAAW,WAChCc,OAAQd,EAAW,EAAI,WAGnBe,EAAcrB,EAAAA,OAAOsB,EAAK;;EAI1BC,EAAgBvB,EAAAA,OAAOwB,EAAPxB,EAAgB,EAAGK,YAAO,CAC9CoB,WAAYpB,EAAMY,QAAQ,IAC1BS,IAAK,CACHlB,SAAUH,EAAMK,WAAWiB,MAAMnB,6BAIhB,EACnBoB,OACAC,QACAC,WACAC,aAAY,EACZC,aACAC,UACAC,WACA3B,eAAe,cAEf,MAAM4B,EAAU,IAAIC,IAClBF,EACGG,QAAQC,GAAMA,EAAEC,YAChBC,MAAK,CAACC,EAAGC,IAAMD,EAAEE,QAAUD,EAAEC,UAC7BC,KAAKN,GAAMA,EAAEO,cAEZC,EAAYZ,EAASa,QAA+C,CAACC,EAAKC,KAC9ED,EAAIC,EAAMJ,YAAcI,EACjBD,IACN,CAAA,GAEG3C,EAAQ6C,EAAAA,WACRC,GAAYC,EAAc/C,EAAMgD,YAAYC,GAAG,WAG/CC,EAA2BJ,EAAW,SAAW,SAgCvD,OACEK,EAAAA,KAACzD,aACEgC,GAAa0B,EAAAA,IAACC,EAAiB,CAAC5B,SAAUA,EAAUD,MAAOA,IAC5D4B,EAAAA,IAACpC,EAAW,CAAAsC,SACVF,EAAAA,IAACG,EAAkB,CAAAD,SACjBH,EAAAA,KAACK,EAAK,CAAA,aACQhC,EAAK,cACJ,iBAAmBE,EAAY,IAAIF,GAAOiC,QAAQ,IAAK,KAAKC,gBAAkB,IAAGJ,SAAA,CApCtGF,EAAAA,IAACO,EAAS,CAAAL,SACRF,EAAAA,IAACQ,EAAQ,CAAAN,SACNO,MAAMC,KAAKhC,GAASS,KAAI,CAACxC,EAAMgE,KAC9B,MAAMvB,WAAEA,EAAUwB,YAAEA,EAAWC,MAAEA,EAAQ,OAAMC,QAAEA,GAAYzB,EAAU1C,IAAS,CAAA,EAEhF,OACEqD,MAACxD,EAAe,CAEdqE,MAAOA,EACPhE,SAAkB,IAAR8D,IAAcjB,EACxB5C,aAAcA,EAAYoD,SAE1BH,EAAAA,KAAA,MAAA,CAAAG,SAAA,CACEF,EAAAA,IAAA,OAAA,CAAAE,SAAOU,IACNE,GACCd,EAAAA,IAAClC,EAAa,CAACiD,UAAU,cAAc3C,MAAO0C,EAAOZ,SACnDF,EAAAA,IAACgB,EAAU,CAACC,KAAK,iBACfjB,EAAAA,IAACkB,EAAgB,CAAA,cAAa,mBAAmBD,KAAK,eAVzD7B,UAgCPY,EAAAA,IAACmB,EAAgB,CACfzC,QAASA,EACTP,KAAMA,EACNK,QAASA,EACT4C,KAAM/B,EACNgC,KAAMvB,EACNvB,WAAYA"}
@@ -1,18 +0,0 @@
1
- import{jsxs as t,jsx as i}from"react/jsx-runtime";import e from"@mui/material/Card";import r from"@mui/material/IconButton";import{styled as a,useTheme as o}from"@mui/material/styles";import l from"@mui/material/Table";import m from"@mui/material/TableCell";import n from"@mui/material/TableHead";import d from"@mui/material/TableRow";import c from"@mui/material/Tooltip";import s from"@mui/material/useMediaQuery";import p from"../../icons/InformationCircle/index.js";import f from"../GenericTableBody/index.js";import u from"../GenericTableTitle/index.js";import h from"./HighlightScrollbar.js";const b=a("div")`
2
- overflow-x: auto;
3
- &::-webkit-scrollbar {
4
- padding: 2px 0;
5
- height: 6px;
6
- border: 1px solid #d5d5d5;
7
- }
8
- &::-webkit-scrollbar-track {
9
- background: #f1f1f1;
10
- }
11
- &::-webkit-scrollbar-thumb {
12
- background: #f5f5f5;
13
- border-radius: 3px;
14
- }
15
- `,g=a(m,{shouldForwardProp:t=>"isSticky"!==t&&"titleVariant"!==t})((({theme:t,isSticky:i,titleVariant:e})=>({fontSize:13,fontWeight:"light"===e?400:t.typography.fontWeightMedium,color:"light"===e?t.palette.semantic.text["text-weak"]:t.palette.semantic.text["text-strong"],padding:t.spacing(1.25,2),whiteSpace:"nowrap",position:i?"sticky":"relative",zIndex:i?1:"auto"}))),k=a(e)`
16
- overflow: hidden;
17
- `,w=a(c)((({theme:t})=>({marginLeft:t.spacing(.5),svg:{fontSize:t.typography.body1.fontSize}}))),x=({data:e,title:a,subTitle:m,showTitle:c=!0,onRowClick:x,loading:y,metadata:T,titleVariant:S="default"})=>{const v=new Set(T.filter((t=>t.isVisible)).sort(((t,i)=>t.ordinal-i.ordinal)).map((t=>t.columnName))),z=T.reduce(((t,i)=>(t[i.columnName]=i,t)),{}),C=o(),j=!s(C.breakpoints.up("tablet")),I=j?"normal":"sticky";return t(b,{children:[c&&i(u,{subTitle:m,title:a}),i(k,{children:i(h,{children:t(l,{"aria-label":a,"data-testid":"generic-table"+(c?`-${a?.replace(" ","-").toLowerCase()}`:""),children:[i(n,{children:i(d,{children:Array.from(v).map(((e,a)=>{const{columnName:o,columnTitle:l,align:m="left",tooltip:n}=z[e]||{};return i(g,{align:m,isSticky:0===a&&!j,titleVariant:S,children:t("div",{children:[i("span",{children:l}),n&&i(w,{placement:"right-start",title:n,children:i(r,{size:"small",children:i(p,{"data-testid":"InfoOutlinedIcon",size:"sm"})})})]})},o)}))})}),i(f,{columns:v,data:e,loading:y,meta:z,type:I,onRowClick:x})]})})})]})};export{x as default};
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/GenericTable/index.tsx"],"sourcesContent":["import Card from '@mui/material/Card';\nimport IconButton from '@mui/material/IconButton';\nimport { styled, useTheme } from '@mui/material/styles';\nimport Table from '@mui/material/Table';\nimport TableCell from '@mui/material/TableCell';\nimport TableHead from '@mui/material/TableHead';\nimport TableRow from '@mui/material/TableRow';\nimport Tooltip from '@mui/material/Tooltip';\nimport useMediaQuery from '@mui/material/useMediaQuery';\n\nimport InfoOutlinedIcon from '../../icons/InformationCircle';\nimport GenericTableBody, { type GenericTableColumns } from '../GenericTableBody';\nimport GenericTableTitle from '../GenericTableTitle';\nimport HighlightScrollbar from './HighlightScrollbar';\n\ninterface GenericTableProps {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data?: any[];\n loading?: boolean;\n metadata: GenericTableColumns[];\n // eslint-disable-next-line @typescript-eslint/ban-types\n onRowClick?: Function;\n showTitle?: boolean;\n subTitle?: string;\n title?: string;\n titleVariant?: 'default' | 'light';\n}\n\nconst StyledContainer = styled('div')`\n overflow-x: auto;\n &::-webkit-scrollbar {\n padding: 2px 0;\n height: 6px;\n border: 1px solid #d5d5d5;\n }\n &::-webkit-scrollbar-track {\n background: #f1f1f1;\n }\n &::-webkit-scrollbar-thumb {\n background: #f5f5f5;\n border-radius: 3px;\n }\n`;\n\nconst StyledTableCell = styled(TableCell, {\n shouldForwardProp: (prop) => prop !== 'isSticky' && prop !== 'titleVariant',\n})<{ isSticky: boolean; titleVariant: 'default' | 'light' }>(({ theme, isSticky, titleVariant }) => ({\n fontSize: 13,\n fontWeight: titleVariant === 'light' ? 400 : theme.typography.fontWeightMedium,\n color:\n titleVariant === 'light'\n ? theme.palette.semantic.text['text-weak']\n : theme.palette.semantic.text['text-strong'],\n padding: theme.spacing(1.25, 2),\n whiteSpace: 'nowrap',\n position: isSticky ? 'sticky' : 'relative',\n zIndex: isSticky ? 1 : 'auto',\n}));\n\nconst StyledPaper = styled(Card)`\n overflow: hidden;\n`;\n\nconst StyledTooltip = styled(Tooltip)(({ theme }) => ({\n marginLeft: theme.spacing(0.5),\n svg: {\n fontSize: theme.typography.body1.fontSize,\n },\n}));\n\nconst GenericTable = ({\n data,\n title,\n subTitle,\n showTitle = true,\n onRowClick,\n loading,\n metadata,\n titleVariant = 'default',\n}: GenericTableProps) => {\n const columns = new Set(\n metadata\n .filter((m) => m.isVisible)\n .sort((a, b) => a.ordinal - b.ordinal)\n .map((m) => m.columnName),\n );\n const tableMeta = metadata.reduce<{ [key: string]: GenericTableColumns }>((obj, mData) => {\n obj[mData.columnName] = mData;\n return obj;\n }, {});\n\n const theme = useTheme();\n const isMobile = !useMediaQuery(theme.breakpoints.up('tablet'));\n\n // We never want sticky on mobile - only on desktop\n const firstColumnStylePosition = isMobile ? 'normal' : 'sticky';\n\n const renderTableHeader = () => (\n <TableHead>\n <TableRow>\n {Array.from(columns).map((prop, idx) => {\n const { columnName, columnTitle, align = 'left', tooltip } = tableMeta[prop] || {};\n\n return (\n <StyledTableCell\n key={columnName}\n align={align}\n isSticky={idx === 0 && !isMobile}\n titleVariant={titleVariant}\n >\n <div>\n <span>{columnTitle}</span>\n {tooltip && (\n <StyledTooltip placement=\"right-start\" title={tooltip}>\n <IconButton size=\"small\">\n <InfoOutlinedIcon data-testid=\"InfoOutlinedIcon\" size=\"sm\" />\n </IconButton>\n </StyledTooltip>\n )}\n </div>\n </StyledTableCell>\n );\n })}\n </TableRow>\n </TableHead>\n );\n\n return (\n <StyledContainer>\n {showTitle && <GenericTableTitle subTitle={subTitle} title={title}></GenericTableTitle>}\n <StyledPaper>\n <HighlightScrollbar>\n <Table\n aria-label={title}\n data-testid={`generic-table` + (showTitle ? `-${title?.replace(' ', '-').toLowerCase()}` : '')}\n >\n {renderTableHeader()}\n <GenericTableBody\n columns={columns}\n data={data}\n loading={loading}\n meta={tableMeta}\n type={firstColumnStylePosition}\n onRowClick={onRowClick}\n />\n </Table>\n </HighlightScrollbar>\n </StyledPaper>\n </StyledContainer>\n );\n};\n\nexport default GenericTable;\n"],"names":["StyledContainer","styled","StyledTableCell","TableCell","shouldForwardProp","prop","theme","isSticky","titleVariant","fontSize","fontWeight","typography","fontWeightMedium","color","palette","semantic","text","padding","spacing","whiteSpace","position","zIndex","StyledPaper","Card","StyledTooltip","Tooltip","marginLeft","svg","body1","GenericTable","data","title","subTitle","showTitle","onRowClick","loading","metadata","columns","Set","filter","m","isVisible","sort","a","b","ordinal","map","columnName","tableMeta","reduce","obj","mData","useTheme","isMobile","useMediaQuery","breakpoints","up","firstColumnStylePosition","_jsxs","_jsx","GenericTableTitle","children","HighlightScrollbar","Table","replace","toLowerCase","TableHead","TableRow","Array","from","idx","columnTitle","align","tooltip","placement","IconButton","size","InfoOutlinedIcon","GenericTableBody","meta","type"],"mappings":"qlBA4BA,MAAMA,EAAkBC,EAAO,MAAM;;;;;;;;;;;;;;EAgB/BC,EAAkBD,EAAOE,EAAW,CACxCC,kBAAoBC,GAAkB,aAATA,GAAgC,iBAATA,GAD9BJ,EAEqC,EAAGK,QAAOC,WAAUC,mBAAc,CAC7FC,SAAU,GACVC,WAA6B,UAAjBF,EAA2B,IAAMF,EAAMK,WAAWC,iBAC9DC,MACmB,UAAjBL,EACIF,EAAMQ,QAAQC,SAASC,KAAK,aAC5BV,EAAMQ,QAAQC,SAASC,KAAK,eAClCC,QAASX,EAAMY,QAAQ,KAAM,GAC7BC,WAAY,SACZC,SAAUb,EAAW,SAAW,WAChCc,OAAQd,EAAW,EAAI,WAGnBe,EAAcrB,EAAOsB,EAAK;;EAI1BC,EAAgBvB,EAAOwB,EAAPxB,EAAgB,EAAGK,YAAO,CAC9CoB,WAAYpB,EAAMY,QAAQ,IAC1BS,IAAK,CACHlB,SAAUH,EAAMK,WAAWiB,MAAMnB,cAI/BoB,EAAe,EACnBC,OACAC,QACAC,WACAC,aAAY,EACZC,aACAC,UACAC,WACA5B,eAAe,cAEf,MAAM6B,EAAU,IAAIC,IAClBF,EACGG,QAAQC,GAAMA,EAAEC,YAChBC,MAAK,CAACC,EAAGC,IAAMD,EAAEE,QAAUD,EAAEC,UAC7BC,KAAKN,GAAMA,EAAEO,cAEZC,EAAYZ,EAASa,QAA+C,CAACC,EAAKC,KAC9ED,EAAIC,EAAMJ,YAAcI,EACjBD,IACN,CAAA,GAEG5C,EAAQ8C,IACRC,GAAYC,EAAchD,EAAMiD,YAAYC,GAAG,WAG/CC,EAA2BJ,EAAW,SAAW,SAgCvD,OACEK,EAAC1D,aACEiC,GAAa0B,EAACC,EAAiB,CAAC5B,SAAUA,EAAUD,MAAOA,IAC5D4B,EAACrC,EAAW,CAAAuC,SACVF,EAACG,EAAkB,CAAAD,SACjBH,EAACK,EAAK,CAAA,aACQhC,EAAK,cACJ,iBAAmBE,EAAY,IAAIF,GAAOiC,QAAQ,IAAK,KAAKC,gBAAkB,IAAGJ,SAAA,CApCtGF,EAACO,EAAS,CAAAL,SACRF,EAACQ,EAAQ,CAAAN,SACNO,MAAMC,KAAKhC,GAASS,KAAI,CAACzC,EAAMiE,KAC9B,MAAMvB,WAAEA,EAAUwB,YAAEA,EAAWC,MAAEA,EAAQ,OAAMC,QAAEA,GAAYzB,EAAU3C,IAAS,CAAA,EAEhF,OACEsD,EAACzD,EAAe,CAEdsE,MAAOA,EACPjE,SAAkB,IAAR+D,IAAcjB,EACxB7C,aAAcA,EAAYqD,SAE1BH,EAAA,MAAA,CAAAG,SAAA,CACEF,EAAA,OAAA,CAAAE,SAAOU,IACNE,GACCd,EAACnC,EAAa,CAACkD,UAAU,cAAc3C,MAAO0C,EAAOZ,SACnDF,EAACgB,EAAU,CAACC,KAAK,iBACfjB,EAACkB,EAAgB,CAAA,cAAa,mBAAmBD,KAAK,eAVzD7B,UAgCPY,EAACmB,EAAgB,CACfzC,QAASA,EACTP,KAAMA,EACNK,QAASA,EACT4C,KAAM/B,EACNgC,KAAMvB,EACNvB,WAAYA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../../../src/components/GenericTableBody/index.tsx"],"sourcesContent":["import React from 'react';\n\nimport Skeleton from '@mui/material/Skeleton';\nimport { styled } from '@mui/material/styles';\nimport MuiTableBody from '@mui/material/TableBody';\nimport TableCell from '@mui/material/TableCell';\nimport TableRow from '@mui/material/TableRow';\n\nimport GenericTableBodyRow from '../GenericTableBodyRow';\n\nexport interface GenericTableColumns {\n columnName: string;\n columnTitle: string;\n columnType: 'Custom' | 'String';\n align?: 'left' | 'right';\n isVisible: boolean;\n ordinal: number;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n customComponent?: (data: any, row: any) => JSX.Element;\n tooltip?: string;\n hideWhenEmpty?: boolean;\n}\n\nconst StyledTableCell = styled(TableCell, {\n shouldForwardProp: (prop) =>\n prop !== 'align' &&\n prop !== 'titleCell' &&\n prop !== 'warning' &&\n prop !== 'sticky' &&\n prop !== 'isTitleRow',\n})<{ align: string; titleCell: boolean; warning: boolean; sticky: boolean; isTitleRow: boolean }>(\n ({ align, titleCell, warning, sticky, isTitleRow }) => ({\n textAlign: align,\n fontWeight: titleCell || isTitleRow ? 'bold' : 'normal',\n backgroundColor: warning ? '#ffcccb' : 'inherit',\n position: sticky ? 'sticky' : 'static',\n }),\n);\n\nexport interface TableCellProps {\n colIdx: number;\n colName: string;\n hasWarning?: boolean;\n hasTitle?: boolean;\n meta: { [key: string]: GenericTableColumns };\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n row: Record<string, any>;\n type: 'normal' | 'sticky';\n}\n\nconst RenderTableCell: React.FC<TableCellProps> = ({\n colIdx,\n colName,\n hasWarning,\n hasTitle,\n meta,\n row,\n type,\n}) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const prop = row[colName];\n const align = meta[colName]?.align ?? 'left';\n const hideWhenEmpty = meta[colName]?.hideWhenEmpty ?? false;\n const fallbackValue = hideWhenEmpty ? '' : '-';\n const tableCellProps = {\n align,\n warning: hasWarning ?? false,\n titleCell: hasTitle ?? false,\n sticky: type === 'sticky' && colIdx === 0,\n 'data-testid': `col-${colName}`,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n isTitleRow: row['isTitleRow'] ?? false,\n };\n\n // When prop is a React element render it as is\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n if (React.isValidElement(prop)) {\n return <StyledTableCell {...tableCellProps}>{prop}</StyledTableCell>;\n }\n\n switch (meta[colName]?.columnType) {\n case 'String':\n return <StyledTableCell {...tableCellProps}>{prop ?? fallbackValue}</StyledTableCell>;\n case 'Custom':\n return (\n <StyledTableCell {...tableCellProps}>\n {prop ? meta[colName]?.customComponent?.(prop, row) : fallbackValue}\n </StyledTableCell>\n );\n default:\n return <StyledTableCell {...tableCellProps}>{prop ?? fallbackValue}</StyledTableCell>;\n }\n};\n\ninterface TableBodyProps {\n columns: Set<string>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data?: any[];\n loading?: boolean;\n meta?: { [key: string]: GenericTableColumns };\n // eslint-disable-next-line @typescript-eslint/ban-types\n onRowClick?: Function;\n type: 'normal' | 'sticky';\n}\n\nconst GenericTableBody: React.FC<TableBodyProps> = ({ columns, data, loading, type, onRowClick, meta }) => {\n const rowsPerPage = 5;\n return (\n <MuiTableBody>\n {loading\n ? Array.from(Array(rowsPerPage)).map((_, idx) => (\n // eslint-disable-next-line react/no-array-index-key\n <TableRow key={`row-loader-${idx}`} data-testid=\"row-loader\">\n {Array.from(columns).map((columnName, colIdx) => (\n <StyledTableCell\n // eslint-disable-next-line react/no-array-index-key\n key={`col-${columnName}-loader-${colIdx}`}\n align={'left'}\n data-testid={`col-${columnName}`}\n isTitleRow={false}\n sticky={false}\n titleCell={false}\n warning={false}\n >\n <Skeleton height={22} width=\"90%\" />\n </StyledTableCell>\n ))}\n </TableRow>\n ))\n : data?.map((row, rowIdx) => (\n <GenericTableBodyRow\n // eslint-disable-next-line react/no-array-index-key\n key={`row-${rowIdx}`}\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n row={row}\n tableRowTestKey={rowIdx.toString()}\n onRowClick={onRowClick}\n >\n {Array.from(columns).map((colName, colIdx) => (\n <RenderTableCell\n // eslint-disable-next-line react/no-array-index-key\n key={`cell-${colName}-${colIdx}`}\n colIdx={colIdx}\n colName={colName}\n meta={meta ?? {}}\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n row={row}\n type={type}\n />\n ))}\n </GenericTableBodyRow>\n ))}\n </MuiTableBody>\n );\n};\n\nexport default GenericTableBody;\n"],"names":["StyledTableCell","styled","TableCell","shouldForwardProp","prop","align","titleCell","warning","sticky","isTitleRow","textAlign","fontWeight","backgroundColor","position","RenderTableCell","colIdx","colName","hasWarning","hasTitle","meta","row","type","fallbackValue","hideWhenEmpty","tableCellProps","React","isValidElement","_jsx","children","columnType","customComponent","columns","data","loading","onRowClick","MuiTableBody","Array","from","map","_","idx","TableRow","columnName","Skeleton","height","width","rowIdx","GenericTableBodyRow","tableRowTestKey","toString"],"mappings":"wSAuBA,MAAMA,EAAkBC,EAAAA,OAAOC,EAAW,CACxCC,kBAAoBC,GACT,UAATA,GACS,cAATA,GACS,YAATA,GACS,WAATA,GACS,eAATA,GANoBH,EAQtB,EAAGI,QAAOC,YAAWC,UAASC,SAAQC,iBAAY,CAChDC,UAAWL,EACXM,WAAYL,GAAaG,EAAa,OAAS,SAC/CG,gBAAiBL,EAAU,UAAY,UACvCM,SAAUL,EAAS,SAAW,aAe5BM,EAA4C,EAChDC,SACAC,UACAC,aACAC,WACAC,OACAC,MACAC,WAGA,MAAMjB,EAAOgB,EAAIJ,GACXX,EAAQc,EAAKH,IAAUX,OAAS,OAEhCiB,EADgBH,EAAKH,IAAUO,gBAAiB,EAChB,GAAK,IACrCC,EAAiB,CACrBnB,QACAE,QAASU,IAAc,EACvBX,UAAWY,IAAY,EACvBV,OAAiB,WAATa,GAAgC,IAAXN,EAC7B,cAAe,OAAOC,IAEtBP,WAAYW,EAAgB,aAAK,GAKnC,GAAIK,EAAMC,eAAetB,GACvB,OAAOuB,EAAAA,IAAC3B,EAAe,IAAKwB,EAAcI,SAAGxB,IAG/C,OAAQe,EAAKH,IAAUa,YACrB,IAAK,SAQL,QACE,OAAOF,EAAAA,IAAC3B,EAAe,IAAKwB,WAAiBpB,GAAQkB,IAPvD,IAAK,SACH,OACEK,EAAAA,IAAC3B,EAAe,IAAKwB,EAAcI,SAChCxB,EAAOe,EAAKH,IAAUc,kBAAkB1B,EAAMgB,GAAOE,qBAmBb,EAAGS,UAASC,OAAMC,UAASZ,OAAMa,aAAYf,UAG5FQ,EAAAA,IAACQ,EAAY,CAAAP,SACVK,EACGG,MAAMC,KAAKD,MAJC,IAImBE,KAAI,CAACC,EAAGC,IAErCb,EAAAA,IAACc,iBAA+C,aAAYb,SACzDQ,MAAMC,KAAKN,GAASO,KAAI,CAACI,EAAY3B,IACpCY,EAAAA,IAAC3B,GAGCK,MAAO,OAAM,cACA,OAAOqC,IACpBjC,YAAY,EACZD,QAAQ,EACRF,WAAW,EACXC,SAAS,EAAKqB,SAEdD,MAACgB,EAAQ,CAACC,OAAQ,GAAIC,MAAM,SARvB,OAAOH,YAAqB3B,QAJxB,cAAcyB,OAiB/BR,GAAMM,KAAI,CAAClB,EAAK0B,IACdnB,EAAAA,IAACoB,GAIC3B,IAAKA,EACL4B,gBAAiBF,EAAOG,WACxBf,WAAYA,WAEXE,MAAMC,KAAKN,GAASO,KAAI,CAACtB,EAASD,IACjCY,MAACb,GAGCC,OAAQA,EACRC,QAASA,EACTG,KAAMA,GAAQ,CAAA,EAEdC,IAAKA,EACLC,KAAMA,GAND,QAAQL,KAAWD,QATvB,OAAO+B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/GenericTableBody/index.tsx"],"sourcesContent":["import React from 'react';\n\nimport Skeleton from '@mui/material/Skeleton';\nimport { styled } from '@mui/material/styles';\nimport MuiTableBody from '@mui/material/TableBody';\nimport TableCell from '@mui/material/TableCell';\nimport TableRow from '@mui/material/TableRow';\n\nimport GenericTableBodyRow from '../GenericTableBodyRow';\n\nexport interface GenericTableColumns {\n columnName: string;\n columnTitle: string;\n columnType: 'Custom' | 'String';\n align?: 'left' | 'right';\n isVisible: boolean;\n ordinal: number;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n customComponent?: (data: any, row: any) => JSX.Element;\n tooltip?: string;\n hideWhenEmpty?: boolean;\n}\n\nconst StyledTableCell = styled(TableCell, {\n shouldForwardProp: (prop) =>\n prop !== 'align' &&\n prop !== 'titleCell' &&\n prop !== 'warning' &&\n prop !== 'sticky' &&\n prop !== 'isTitleRow',\n})<{ align: string; titleCell: boolean; warning: boolean; sticky: boolean; isTitleRow: boolean }>(\n ({ align, titleCell, warning, sticky, isTitleRow }) => ({\n textAlign: align,\n fontWeight: titleCell || isTitleRow ? 'bold' : 'normal',\n backgroundColor: warning ? '#ffcccb' : 'inherit',\n position: sticky ? 'sticky' : 'static',\n }),\n);\n\nexport interface TableCellProps {\n colIdx: number;\n colName: string;\n hasWarning?: boolean;\n hasTitle?: boolean;\n meta: { [key: string]: GenericTableColumns };\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n row: Record<string, any>;\n type: 'normal' | 'sticky';\n}\n\nconst RenderTableCell: React.FC<TableCellProps> = ({\n colIdx,\n colName,\n hasWarning,\n hasTitle,\n meta,\n row,\n type,\n}) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const prop = row[colName];\n const align = meta[colName]?.align ?? 'left';\n const hideWhenEmpty = meta[colName]?.hideWhenEmpty ?? false;\n const fallbackValue = hideWhenEmpty ? '' : '-';\n const tableCellProps = {\n align,\n warning: hasWarning ?? false,\n titleCell: hasTitle ?? false,\n sticky: type === 'sticky' && colIdx === 0,\n 'data-testid': `col-${colName}`,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n isTitleRow: row['isTitleRow'] ?? false,\n };\n\n // When prop is a React element render it as is\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n if (React.isValidElement(prop)) {\n return <StyledTableCell {...tableCellProps}>{prop}</StyledTableCell>;\n }\n\n switch (meta[colName]?.columnType) {\n case 'String':\n return <StyledTableCell {...tableCellProps}>{prop ?? fallbackValue}</StyledTableCell>;\n case 'Custom':\n return (\n <StyledTableCell {...tableCellProps}>\n {prop ? meta[colName]?.customComponent?.(prop, row) : fallbackValue}\n </StyledTableCell>\n );\n default:\n return <StyledTableCell {...tableCellProps}>{prop ?? fallbackValue}</StyledTableCell>;\n }\n};\n\ninterface TableBodyProps {\n columns: Set<string>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data?: any[];\n loading?: boolean;\n meta?: { [key: string]: GenericTableColumns };\n // eslint-disable-next-line @typescript-eslint/ban-types\n onRowClick?: Function;\n type: 'normal' | 'sticky';\n}\n\nconst GenericTableBody: React.FC<TableBodyProps> = ({ columns, data, loading, type, onRowClick, meta }) => {\n const rowsPerPage = 5;\n return (\n <MuiTableBody>\n {loading\n ? Array.from(Array(rowsPerPage)).map((_, idx) => (\n // eslint-disable-next-line react/no-array-index-key\n <TableRow key={`row-loader-${idx}`} data-testid=\"row-loader\">\n {Array.from(columns).map((columnName, colIdx) => (\n <StyledTableCell\n // eslint-disable-next-line react/no-array-index-key\n key={`col-${columnName}-loader-${colIdx}`}\n align={'left'}\n data-testid={`col-${columnName}`}\n isTitleRow={false}\n sticky={false}\n titleCell={false}\n warning={false}\n >\n <Skeleton height={22} width=\"90%\" />\n </StyledTableCell>\n ))}\n </TableRow>\n ))\n : data?.map((row, rowIdx) => (\n <GenericTableBodyRow\n // eslint-disable-next-line react/no-array-index-key\n key={`row-${rowIdx}`}\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n row={row}\n tableRowTestKey={rowIdx.toString()}\n onRowClick={onRowClick}\n >\n {Array.from(columns).map((colName, colIdx) => (\n <RenderTableCell\n // eslint-disable-next-line react/no-array-index-key\n key={`cell-${colName}-${colIdx}`}\n colIdx={colIdx}\n colName={colName}\n meta={meta ?? {}}\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n row={row}\n type={type}\n />\n ))}\n </GenericTableBodyRow>\n ))}\n </MuiTableBody>\n );\n};\n\nexport default GenericTableBody;\n"],"names":["StyledTableCell","styled","TableCell","shouldForwardProp","prop","align","titleCell","warning","sticky","isTitleRow","textAlign","fontWeight","backgroundColor","position","RenderTableCell","colIdx","colName","hasWarning","hasTitle","meta","row","type","fallbackValue","hideWhenEmpty","tableCellProps","React","isValidElement","_jsx","children","columnType","customComponent","GenericTableBody","columns","data","loading","onRowClick","MuiTableBody","Array","from","map","_","idx","TableRow","columnName","Skeleton","height","width","rowIdx","GenericTableBodyRow","tableRowTestKey","toString"],"mappings":"oTAuBA,MAAMA,EAAkBC,EAAOC,EAAW,CACxCC,kBAAoBC,GACT,UAATA,GACS,cAATA,GACS,YAATA,GACS,WAATA,GACS,eAATA,GANoBH,EAQtB,EAAGI,QAAOC,YAAWC,UAASC,SAAQC,iBAAY,CAChDC,UAAWL,EACXM,WAAYL,GAAaG,EAAa,OAAS,SAC/CG,gBAAiBL,EAAU,UAAY,UACvCM,SAAUL,EAAS,SAAW,aAe5BM,EAA4C,EAChDC,SACAC,UACAC,aACAC,WACAC,OACAC,MACAC,WAGA,MAAMjB,EAAOgB,EAAIJ,GACXX,EAAQc,EAAKH,IAAUX,OAAS,OAEhCiB,EADgBH,EAAKH,IAAUO,gBAAiB,EAChB,GAAK,IACrCC,EAAiB,CACrBnB,QACAE,QAASU,IAAc,EACvBX,UAAWY,IAAY,EACvBV,OAAiB,WAATa,GAAgC,IAAXN,EAC7B,cAAe,OAAOC,IAEtBP,WAAYW,EAAgB,aAAK,GAKnC,GAAIK,EAAMC,eAAetB,GACvB,OAAOuB,EAAC3B,EAAe,IAAKwB,EAAcI,SAAGxB,IAG/C,OAAQe,EAAKH,IAAUa,YACrB,IAAK,SAQL,QACE,OAAOF,EAAC3B,EAAe,IAAKwB,WAAiBpB,GAAQkB,IAPvD,IAAK,SACH,OACEK,EAAC3B,EAAe,IAAKwB,EAAcI,SAChCxB,EAAOe,EAAKH,IAAUc,kBAAkB1B,EAAMgB,GAAOE,MAmB1DS,EAA6C,EAAGC,UAASC,OAAMC,UAASb,OAAMc,aAAYhB,UAG5FQ,EAACS,EAAY,CAAAR,SACVM,EACGG,MAAMC,KAAKD,MAJC,IAImBE,KAAI,CAACC,EAAGC,IAErCd,EAACe,iBAA+C,aAAYd,SACzDS,MAAMC,KAAKN,GAASO,KAAI,CAACI,EAAY5B,IACpCY,EAAC3B,GAGCK,MAAO,OAAM,cACA,OAAOsC,IACpBlC,YAAY,EACZD,QAAQ,EACRF,WAAW,EACXC,SAAS,EAAKqB,SAEdD,EAACiB,EAAQ,CAACC,OAAQ,GAAIC,MAAM,SARvB,OAAOH,YAAqB5B,QAJxB,cAAc0B,OAiB/BR,GAAMM,KAAI,CAACnB,EAAK2B,IACdpB,EAACqB,GAIC5B,IAAKA,EACL6B,gBAAiBF,EAAOG,WACxBf,WAAYA,WAEXE,MAAMC,KAAKN,GAASO,KAAI,CAACvB,EAASD,IACjCY,EAACb,GAGCC,OAAQA,EACRC,QAASA,EACTG,KAAMA,GAAQ,CAAA,EAEdC,IAAKA,EACLC,KAAMA,GAND,QAAQL,KAAWD,QATvB,OAAOgC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../../../src/components/GenericTableBodyRow/index.tsx"],"sourcesContent":["import React from 'react';\n\nimport { styled } from '@mui/material/styles';\nimport TableRow from '@mui/material/TableRow';\n\nexport interface TableBodyRowProps {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n row: any;\n // eslint-disable-next-line @typescript-eslint/ban-types\n onRowClick?: Function;\n tableRowTestKey: string;\n}\n\nconst StyledTableRow = styled(TableRow, {\n shouldForwardProp: (prop) => prop !== 'isTitleRow',\n})<{ isTitleRow: boolean }>(({ theme, isTitleRow }) => {\n if (!isTitleRow) {\n return {};\n }\n\n return {\n backgroundColor: theme.palette.semantic.background['background-sunken'],\n };\n});\n\ntype TableBodyRowProp = TableBodyRowProps & { children: React.ReactNode };\n\nconst GenericTableBodyRow: React.FC<React.PropsWithChildren<TableBodyRowProp>> = (props) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const { onRowClick, row, children, tableRowTestKey } = props;\n\n const onClick = (event: React.MouseEvent<HTMLTableRowElement>): void => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n event.preventDefault();\n onRowClick?.(row);\n };\n\n if (onRowClick) {\n return (\n <StyledTableRow\n data-testid={`row-clickable-${tableRowTestKey}`}\n hover={onClick !== undefined}\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n isTitleRow={row['isTitleRow'] ?? false}\n onClick={onClick}\n >\n {children}\n </StyledTableRow>\n );\n }\n\n return <TableRow data-testid={`row-${tableRowTestKey}`}>{children}</TableRow>;\n};\n\nexport default GenericTableBodyRow;\n"],"names":["StyledTableRow","styled","TableRow","shouldForwardProp","prop","theme","isTitleRow","backgroundColor","palette","semantic","background","props","onRowClick","row","children","tableRowTestKey","onClick","event","preventDefault","_jsx","hover","undefined"],"mappings":"2IAaA,MAAMA,EAAiBC,EAAAA,OAAOC,EAAU,CACtCC,kBAAoBC,GAAkB,eAATA,GADRH,EAEK,EAAGI,QAAOC,gBAC/BA,EAIE,CACLC,gBAAiBF,EAAMG,QAAQC,SAASC,WAAW,sBAJ5C,CAAA,mBAUuEC,IAEhF,MAAMC,WAAEA,EAAUC,IAAEA,EAAGC,SAAEA,EAAQC,gBAAEA,GAAoBJ,EAEjDK,EAAWC,IAEfA,EAAMC,iBACNN,IAAaC,IAGf,OAAID,EAEAO,EAAAA,IAACnB,EAAc,CAAA,cACA,iBAAiBe,IAC9BK,WAAmBC,IAAZL,EAEPV,WAAYO,EAAgB,aAAK,EACjCG,QAASA,EAAOF,SAEfA,IAKAK,EAAAA,IAACjB,EAAQ,CAAA,cAAc,OAAOa,IAAiBD,SAAGA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/GenericTableBodyRow/index.tsx"],"sourcesContent":["import React from 'react';\n\nimport { styled } from '@mui/material/styles';\nimport TableRow from '@mui/material/TableRow';\n\nexport interface TableBodyRowProps {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n row: any;\n // eslint-disable-next-line @typescript-eslint/ban-types\n onRowClick?: Function;\n tableRowTestKey: string;\n}\n\nconst StyledTableRow = styled(TableRow, {\n shouldForwardProp: (prop) => prop !== 'isTitleRow',\n})<{ isTitleRow: boolean }>(({ theme, isTitleRow }) => {\n if (!isTitleRow) {\n return {};\n }\n\n return {\n backgroundColor: theme.palette.semantic.background['background-sunken'],\n };\n});\n\ntype TableBodyRowProp = TableBodyRowProps & { children: React.ReactNode };\n\nconst GenericTableBodyRow: React.FC<React.PropsWithChildren<TableBodyRowProp>> = (props) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const { onRowClick, row, children, tableRowTestKey } = props;\n\n const onClick = (event: React.MouseEvent<HTMLTableRowElement>): void => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n event.preventDefault();\n onRowClick?.(row);\n };\n\n if (onRowClick) {\n return (\n <StyledTableRow\n data-testid={`row-clickable-${tableRowTestKey}`}\n hover={onClick !== undefined}\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n isTitleRow={row['isTitleRow'] ?? false}\n onClick={onClick}\n >\n {children}\n </StyledTableRow>\n );\n }\n\n return <TableRow data-testid={`row-${tableRowTestKey}`}>{children}</TableRow>;\n};\n\nexport default GenericTableBodyRow;\n"],"names":["StyledTableRow","styled","TableRow","shouldForwardProp","prop","theme","isTitleRow","backgroundColor","palette","semantic","background","GenericTableBodyRow","props","onRowClick","row","children","tableRowTestKey","onClick","event","preventDefault","_jsx","hover","undefined"],"mappings":"0IAaA,MAAMA,EAAiBC,EAAOC,EAAU,CACtCC,kBAAoBC,GAAkB,eAATA,GADRH,EAEK,EAAGI,QAAOC,gBAC/BA,EAIE,CACLC,gBAAiBF,EAAMG,QAAQC,SAASC,WAAW,sBAJ5C,CAAA,IAULC,EAA4EC,IAEhF,MAAMC,WAAEA,EAAUC,IAAEA,EAAGC,SAAEA,EAAQC,gBAAEA,GAAoBJ,EAEjDK,EAAWC,IAEfA,EAAMC,iBACNN,IAAaC,IAGf,OAAID,EAEAO,EAACpB,EAAc,CAAA,cACA,iBAAiBgB,IAC9BK,WAAmBC,IAAZL,EAEPX,WAAYQ,EAAgB,aAAK,EACjCG,QAASA,EAAOF,SAEfA,IAKAK,EAAClB,EAAQ,CAAA,cAAc,OAAOc,IAAiBD,SAAGA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../../../src/components/GenericTableTitle/index.tsx"],"sourcesContent":["import { type ReactNode } from 'react';\n\nimport { styled } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\n\nimport Grid, {type GridSize} from '../atoms/Grid';\n\ninterface OuterProps {\n maxGridWidth?: GridSize;\n subTitle?: string;\n title?: string;\n children?: ReactNode;\n titlePadding?: 'medium' | 'small';\n}\n\nconst HeaderContainer = styled(Grid, {\n shouldForwardProp: (prop) => prop !== 'titlePadding',\n})<{ titlePadding: OuterProps['titlePadding'] }>(({ theme, titlePadding }) => {\n switch (titlePadding) {\n case 'small':\n return {\n padding: theme.spacing(3, 0, 1.5),\n [theme.breakpoints.down('tablet')]: {\n padding: theme.spacing(3, 2, 1.5),\n },\n };\n case 'medium':\n return {\n padding: theme.spacing(4, 0, 2),\n [theme.breakpoints.down('tablet')]: {\n padding: theme.spacing(4, 2, 2),\n },\n };\n default:\n return { padding: 0 };\n }\n});\n\nconst SubTitle = styled(Typography)({\n width: 191,\n height: 16,\n fontSize: 12,\n fontWeight: 'normal',\n lineHeight: 1.33,\n letterSpacing: 0.4,\n color: 'rgba(0, 0, 0, 0.38)',\n});\n\nconst GenericTableTitle = ({\n maxGridWidth = 12,\n subTitle,\n title,\n children,\n titlePadding = 'medium',\n}: OuterProps): JSX.Element => {\n return (\n <HeaderContainer container titlePadding={titlePadding}>\n <Grid size={{ base: maxGridWidth, mobile: maxGridWidth }}>\n {title && <Typography variant=\"h5\">{title}</Typography>}\n {subTitle && (\n <div>\n <SubTitle variant=\"caption\">{subTitle}</SubTitle>\n </div>\n )}\n </Grid>\n\n {children}\n </HeaderContainer>\n );\n};\n\nexport default GenericTableTitle;\n"],"names":["HeaderContainer","styled","Grid","shouldForwardProp","prop","theme","titlePadding","padding","spacing","breakpoints","down","SubTitle","Typography","width","height","fontSize","fontWeight","lineHeight","letterSpacing","color","maxGridWidth","subTitle","title","children","_jsxs","container","size","base","mobile","_jsx","variant"],"mappings":"8KAeA,MAAMA,EAAkBC,EAAAA,OAAOC,EAAM,CACnCC,kBAAoBC,GAAkB,iBAATA,GADPH,EAEyB,EAAGI,QAAOC,mBACzD,OAAQA,GACN,IAAK,QACH,MAAO,CACLC,QAASF,EAAMG,QAAQ,EAAG,EAAG,KAC7B,CAACH,EAAMI,YAAYC,KAAK,WAAY,CAClCH,QAASF,EAAMG,QAAQ,EAAG,EAAG,OAGnC,IAAK,SACH,MAAO,CACLD,QAASF,EAAMG,QAAQ,EAAG,EAAG,GAC7B,CAACH,EAAMI,YAAYC,KAAK,WAAY,CAClCH,QAASF,EAAMG,QAAQ,EAAG,EAAG,KAGnC,QACE,MAAO,CAAED,QAAS,OAIlBI,EAAWV,EAAAA,OAAOW,EAAPX,CAAmB,CAClCY,MAAO,IACPC,OAAQ,GACRC,SAAU,GACVC,WAAY,SACZC,WAAY,KACZC,cAAe,GACfC,MAAO,uCAGiB,EACxBC,eAAe,GACfC,WACAC,QACAC,WACAjB,eAAe,YAGbkB,EAAAA,KAACxB,EAAe,CAACyB,WAAS,EAACnB,aAAcA,EAAYiB,SAAA,CACnDC,OAACtB,EAAI,CAACwB,KAAM,CAAEC,KAAMP,EAAcQ,OAAQR,GAAcG,SAAA,CACrDD,GAASO,EAAAA,IAACjB,EAAU,CAACkB,QAAQ,KAAIP,SAAED,IACnCD,GACCQ,EAAAA,IAAA,MAAA,CAAAN,SACEM,MAAClB,EAAQ,CAACmB,QAAQ,UAASP,SAAEF,SAKlCE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/GenericTableTitle/index.tsx"],"sourcesContent":["import { type ReactNode } from 'react';\n\nimport { styled } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\n\nimport Grid, {type GridSize} from '../atoms/Grid';\n\ninterface OuterProps {\n maxGridWidth?: GridSize;\n subTitle?: string;\n title?: string;\n children?: ReactNode;\n titlePadding?: 'medium' | 'small';\n}\n\nconst HeaderContainer = styled(Grid, {\n shouldForwardProp: (prop) => prop !== 'titlePadding',\n})<{ titlePadding: OuterProps['titlePadding'] }>(({ theme, titlePadding }) => {\n switch (titlePadding) {\n case 'small':\n return {\n padding: theme.spacing(3, 0, 1.5),\n [theme.breakpoints.down('tablet')]: {\n padding: theme.spacing(3, 2, 1.5),\n },\n };\n case 'medium':\n return {\n padding: theme.spacing(4, 0, 2),\n [theme.breakpoints.down('tablet')]: {\n padding: theme.spacing(4, 2, 2),\n },\n };\n default:\n return { padding: 0 };\n }\n});\n\nconst SubTitle = styled(Typography)({\n width: 191,\n height: 16,\n fontSize: 12,\n fontWeight: 'normal',\n lineHeight: 1.33,\n letterSpacing: 0.4,\n color: 'rgba(0, 0, 0, 0.38)',\n});\n\nconst GenericTableTitle = ({\n maxGridWidth = 12,\n subTitle,\n title,\n children,\n titlePadding = 'medium',\n}: OuterProps): JSX.Element => {\n return (\n <HeaderContainer container titlePadding={titlePadding}>\n <Grid size={{ base: maxGridWidth, mobile: maxGridWidth }}>\n {title && <Typography variant=\"h5\">{title}</Typography>}\n {subTitle && (\n <div>\n <SubTitle variant=\"caption\">{subTitle}</SubTitle>\n </div>\n )}\n </Grid>\n\n {children}\n </HeaderContainer>\n );\n};\n\nexport default GenericTableTitle;\n"],"names":["HeaderContainer","styled","Grid","shouldForwardProp","prop","theme","titlePadding","padding","spacing","breakpoints","down","SubTitle","Typography","width","height","fontSize","fontWeight","lineHeight","letterSpacing","color","GenericTableTitle","maxGridWidth","subTitle","title","children","_jsxs","container","size","base","mobile","_jsx","variant"],"mappings":"yLAeA,MAAMA,EAAkBC,EAAOC,EAAM,CACnCC,kBAAoBC,GAAkB,iBAATA,GADPH,EAEyB,EAAGI,QAAOC,mBACzD,OAAQA,GACN,IAAK,QACH,MAAO,CACLC,QAASF,EAAMG,QAAQ,EAAG,EAAG,KAC7B,CAACH,EAAMI,YAAYC,KAAK,WAAY,CAClCH,QAASF,EAAMG,QAAQ,EAAG,EAAG,OAGnC,IAAK,SACH,MAAO,CACLD,QAASF,EAAMG,QAAQ,EAAG,EAAG,GAC7B,CAACH,EAAMI,YAAYC,KAAK,WAAY,CAClCH,QAASF,EAAMG,QAAQ,EAAG,EAAG,KAGnC,QACE,MAAO,CAAED,QAAS,OAIlBI,EAAWV,EAAOW,EAAPX,CAAmB,CAClCY,MAAO,IACPC,OAAQ,GACRC,SAAU,GACVC,WAAY,SACZC,WAAY,KACZC,cAAe,GACfC,MAAO,wBAGHC,EAAoB,EACxBC,eAAe,GACfC,WACAC,QACAC,WACAlB,eAAe,YAGbmB,EAACzB,EAAe,CAAC0B,WAAS,EAACpB,aAAcA,EAAYkB,SAAA,CACnDC,EAACvB,EAAI,CAACyB,KAAM,CAAEC,KAAMP,EAAcQ,OAAQR,GAAcG,SAAA,CACrDD,GAASO,EAAClB,EAAU,CAACmB,QAAQ,KAAIP,SAAED,IACnCD,GACCQ,EAAA,MAAA,CAAAN,SACEM,EAACnB,EAAQ,CAACoB,QAAQ,UAASP,SAAEF,SAKlCE"}