@heliux-org/design-system-core 0.0.294-TableTestBuild → 0.0.294

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. package/dist/Table.css +1 -1
  2. package/dist/Table.css.map +1 -1
  3. package/dist/Table.js +1 -1
  4. package/dist/Table.js.map +1 -1
  5. package/dist/components/NewTable/Table.js +1 -2
  6. package/dist/components/NewTable/Table.js.map +1 -1
  7. package/dist/components/NewTable/components/useLeafyGreenTable/useLeafyGreenTable.js +3 -0
  8. package/dist/components/NewTable/components/useLeafyGreenTable/useLeafyGreenTable.js.map +1 -1
  9. package/dist/esm/components/NewTable/Table.d.ts.map +1 -1
  10. package/dist/esm/components/NewTable/components/useLeafyGreenTable/useLeafyGreenTable.d.ts.map +1 -1
  11. package/dist/esm/src/components/NewTable/Table.js +1 -1
  12. package/dist/esm/src/components/NewTable/Table.js.map +1 -1
  13. package/dist/esm/src/components/NewTable/Table.module.scss.js +1 -1
  14. package/dist/esm/src/components/NewTable/components/useLeafyGreenTable/useLeafyGreenTable.js +1 -1
  15. package/dist/esm/src/components/NewTable/components/useLeafyGreenTable/useLeafyGreenTable.js.map +1 -1
  16. package/dist/main.css +1 -1
  17. package/dist/main.css.map +1 -1
  18. package/dist/main.js +2 -2
  19. package/dist/main.js.map +1 -1
  20. package/dist/mocked_classnames_esm/components/NewTable/Table.d.ts.map +1 -1
  21. package/dist/mocked_classnames_esm/components/NewTable/components/useLeafyGreenTable/useLeafyGreenTable.d.ts.map +1 -1
  22. package/dist/mocked_classnames_esm/src/components/NewTable/Table.js +1 -1
  23. package/dist/mocked_classnames_esm/src/components/NewTable/Table.js.map +1 -1
  24. package/dist/mocked_classnames_esm/src/components/NewTable/Table.module.scss.js +1 -1
  25. package/dist/mocked_classnames_esm/src/components/NewTable/components/useLeafyGreenTable/useLeafyGreenTable.js +1 -1
  26. package/dist/mocked_classnames_esm/src/components/NewTable/components/useLeafyGreenTable/useLeafyGreenTable.js.map +1 -1
  27. package/dist/types/components/NewTable/Table.d.ts.map +1 -1
  28. package/dist/types/components/NewTable/components/useLeafyGreenTable/useLeafyGreenTable.d.ts.map +1 -1
  29. package/package.json +2 -2
  30. package/src/components/NewTable/Table.module.scss +9 -0
  31. package/src/components/NewTable/Table.tsx +6 -22
  32. package/src/components/NewTable/__stories__/NewTable.stories.tsx +4 -2
  33. package/src/components/NewTable/__stories__/newTable.mdx +23 -0
  34. package/src/components/NewTable/components/useLeafyGreenTable/useLeafyGreenTable.tsx +4 -0
@@ -1 +1 @@
1
- {"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../../src/components/NewTable/Table.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8C,MAAM,OAAO,CAAC;AAUnE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,QAAA,MAAM,KAAK,wFAyGV,CAAC;AAQF,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../../src/components/NewTable/Table.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8C,MAAM,OAAO,CAAC;AAUnE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,QAAA,MAAM,KAAK,wFAyFV,CAAC;AAQF,eAAe,KAAK,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useLeafyGreenTable.d.ts","sourceRoot":"","sources":["../../../../../../src/components/NewTable/components/useLeafyGreenTable/useLeafyGreenTable.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,sBAAsB,EAAa,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAgC,MAAM,GAAG,CAAC;AAYlE,QAAA,MAAM,kBAAkB,ogBAwVvB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"useLeafyGreenTable.d.ts","sourceRoot":"","sources":["../../../../../../src/components/NewTable/components/useLeafyGreenTable/useLeafyGreenTable.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,sBAAsB,EAAa,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAgC,MAAM,GAAG,CAAC;AAYlE,QAAA,MAAM,kBAAkB,ogBA4VvB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -1,2 +1,2 @@
1
- import{__rest as e}from"../../../_virtual/_tslib.js";import{jsx as t,jsxs as o}from"@emotion/react/jsx-runtime";import{forwardRef as a}from"react";import n from"prop-types";import r from"classnames";import i from"./components/TableContext/TableContext.js";import l from"./Table.module.scss.js";import s from"./components/newComponents/pagination/Pagination.js";import c from"../Text/Text.js";import d from"../Loader/Loader.js";var m=a((function(a,n){var m=a.children,g=a.className,p=a.shouldAlternateRowColor,b=void 0!==p&&p,h=a.table,u=a.disableAnimations,C=void 0!==u&&u,f=a.header,j=a.withPagination,P=void 0!==j&&j,v=a.emptyTableContent,T=void 0===v?t(c,Object.assign({color:c.colors.SECONDARY,align:c.align.CENTER},{children:"No Data."})):v,w=a.paginationProps,N=e(a,["children","className","shouldAlternateRowColor","baseFontSize","darkMode","table","disableAnimations","header","withPagination","emptyTableContent","paginationProps"]),S=h.getState,y=h.setPageSize,A=h.setPageIndex,O=h.previousPage,x=h.nextPage,R=h.loadedData,I=h.loadMoreTriggerRef,M=h.infiniteScrolling;h.getRowModel();var k=h.getSelectedRowModel().rows.length;return o("div",Object.assign({className:"".concat(l.tableContainerStyles," ").concat(l.tableWrapper)},{children:[f,t("div",Object.assign({ref:n,className:r(l.tableContainerStyles,l.tableContainer,g),tabIndex:0},{children:o(i,Object.assign({shouldAlternateRowColor:b,table:h,disableAnimations:C},{children:[o("table",Object.assign({className:r(l.baseStyles,l.themeLight)},N,{children:[m,0===R.length&&t("tbody",{children:t("tr",{children:t("td",Object.assign({colSpan:h.getAllColumns().length,className:l.emptyTableContent},{children:T}))})})]})),M&&t("div",Object.assign({ref:I,style:{height:"1px"}},{children:t("div",Object.assign({className:r(l.baseStyles,l.loader)},{children:t(d,{size:20,color:d.colors.PRIMARY,className:l.loader})}))}))]}))})),P&&t(s,Object.assign({itemsPerPage:S().pagination.pageSize,onItemsPerPageOptionChange:function(e){return y(Number(e))},numTotalItems:null==w?void 0:w.numTotalItems,currentPage:S().pagination.pageIndex+1,onCurrentPageOptionChange:function(e){return A(Number(e)-1)},onBackArrowClick:function(){return O()},onForwardArrowClick:function(){return x()},numSelectedItems:k},w))]}))}));m.propTypes={darkMode:n.bool,shouldAlternateRowColor:n.bool,emptyTableContent:n.node};export{m as default};
1
+ import{__rest as e}from"../../../_virtual/_tslib.js";import{jsx as t,jsxs as o}from"@emotion/react/jsx-runtime";import{forwardRef as n}from"react";import a from"prop-types";import i from"classnames";import r from"./components/TableContext/TableContext.js";import l from"./Table.module.scss.js";import s from"./components/newComponents/pagination/Pagination.js";import d from"../Text/Text.js";import c from"../Loader/Loader.js";var m=n((function(n,a){var m=n.children,g=n.className,p=n.shouldAlternateRowColor,b=void 0!==p&&p,h=n.table,u=n.disableAnimations,C=void 0!==u&&u,f=n.header,j=n.withPagination,v=void 0!==j&&j,P=n.emptyTableContent,T=void 0===P?t(d,Object.assign({color:d.colors.SECONDARY,align:d.align.CENTER},{children:"No Data."})):P,w=n.paginationProps,N=e(n,["children","className","shouldAlternateRowColor","baseFontSize","darkMode","table","disableAnimations","header","withPagination","emptyTableContent","paginationProps"]),x=h.getState,y=h.setPageSize,A=h.setPageIndex,O=h.previousPage,S=h.nextPage,R=h.loadedData,I=h.isLoading,M=h.loadMoreTriggerRef,k=h.infiniteScrolling;h.getRowModel();var z=h.getSelectedRowModel().rows.length;return o("div",Object.assign({className:"".concat(l.tableContainerStyles," ").concat(l.tableWrapper)},{children:[f,t("div",Object.assign({ref:a,className:i(l.tableContainerStyles,l.tableContainer,g),tabIndex:0},{children:o(r,Object.assign({shouldAlternateRowColor:b,table:h,disableAnimations:C},{children:[o("table",Object.assign({className:i(l.baseStyles,l.themeLight)},N,{children:[m,0===R.length&&t("tbody",{children:t("tr",{children:t("td",Object.assign({colSpan:h.getAllColumns().length,className:l.emptyTableContent},{children:T}))})})]})),o("div",Object.assign({style:{position:"relative",paddingBottom:"20px"}},{children:[t("div",{ref:M,style:{height:"1px"}}),k&&I&&t("div",Object.assign({className:i(l.loaderContainer)},{children:t(c,{size:20,color:c.colors.PRIMARY,className:l.loader})}))]}))]}))})),v&&t(s,Object.assign({itemsPerPage:x().pagination.pageSize,onItemsPerPageOptionChange:function(e){return y(Number(e))},numTotalItems:null==w?void 0:w.numTotalItems,currentPage:x().pagination.pageIndex+1,onCurrentPageOptionChange:function(e){return A(Number(e)-1)},onBackArrowClick:function(){return O()},onForwardArrowClick:function(){return S()},numSelectedItems:z},w))]}))}));m.propTypes={darkMode:a.bool,shouldAlternateRowColor:a.bool,emptyTableContent:a.node};export{m as default};
2
2
  //# sourceMappingURL=Table.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Table.js","sources":["../../../../../src/components/NewTable/Table.tsx"],"sourcesContent":["import React, { ForwardedRef, forwardRef, ReactNode } from \"react\";\n\nimport PropTypes from \"prop-types\";\nimport EmptyState from \"../EmptyState/EmptyState\";\nimport cx from \"classnames\";\n\nimport { TableContextProvider } from \"./components/TableContext\";\nimport { LGRowData } from \"./components/useLeafyGreenTable\";\n\nimport styles from \"./Table.module.scss\"; // Import SCSS styles\nimport { TableProps } from \"./Table.types\";\nimport Pagination from \"./components/newComponents/pagination\";\nimport Text from \"../Text/Text\";\nimport Loader from \"../Loader/Loader\";\n\nconst Table = forwardRef<HTMLDivElement, TableProps<any>>(\n <T extends LGRowData>(\n {\n children,\n className,\n shouldAlternateRowColor = false,\n baseFontSize: baseFontSizeProp,\n darkMode: darkModeProp,\n table,\n disableAnimations = false,\n header,\n withPagination = false,\n emptyTableContent = <Text color={Text.colors.SECONDARY} align={Text.align.CENTER}>No Data.</Text>,\n paginationProps,\n ...rest\n }: TableProps<T>,\n containerRef: ForwardedRef<HTMLDivElement>\n ) => {\n //@ts-ignore\n const { getState, setPageSize, setPageIndex, previousPage, nextPage, loadedData, isLoading, loadMoreTriggerRef, infiniteScrolling } = table;\n const rows = table.getRowModel().rows;\n const numSelectedItems = table.getSelectedRowModel().rows.length;\n\n return (\n <div className={`${styles.tableContainerStyles} ${styles.tableWrapper}`}>\n {header}\n <div\n ref={containerRef}\n className={cx(styles.tableContainerStyles, styles.tableContainer,className)} // Use class from SCSS module\n tabIndex={0} // Allows keyboard interaction\n >\n <TableContextProvider\n shouldAlternateRowColor={shouldAlternateRowColor}\n table={table}\n disableAnimations={disableAnimations}\n >\n <table\n className={cx(\n styles.baseStyles, // Base styles from SCSS module\n styles.themeLight // Conditional theme styles\n )}\n {...rest}\n >\n {children}\n {loadedData.length === 0 && (\n <tbody>\n <tr>\n <td\n colSpan={table.getAllColumns().length}\n className={styles.emptyTableContent}\n >\n {emptyTableContent}\n </td>\n </tr>\n </tbody>\n )}\n {/* @ts-ignore */}\n {/* {isLoading && (\n <tr className={styles.loaderRow}>\n <td colSpan={table.getAllColumns().length}>\n <div className={styles.loader}>\n <Loader\n size={20}\n color={Loader.colors.PRIMARY}\n className={styles.loader}\n />\n </div>\n </td>\n </tr>\n )} */}\n </table>\n {infiniteScrolling && (\n <div ref={loadMoreTriggerRef} style={{ height: '1px' }} >\n <div className={cx(\n styles.baseStyles, // Base styles from SCSS module\n styles.loader\n )}>\n <Loader\n size={20}\n color={Loader.colors.PRIMARY}\n className={styles.loader}\n />\n </div>\n </div>\n )}\n </TableContextProvider>\n </div>\n {withPagination && (\n <Pagination\n itemsPerPage={getState().pagination.pageSize}\n onItemsPerPageOptionChange={(value) => setPageSize(Number(value))}\n numTotalItems={paginationProps?.numTotalItems}\n currentPage={getState().pagination.pageIndex + 1}\n onCurrentPageOptionChange={(value) =>\n setPageIndex(Number(value) - 1)\n }\n onBackArrowClick={() => previousPage()}\n onForwardArrowClick={() => nextPage()}\n numSelectedItems={numSelectedItems}\n {...paginationProps}\n />\n )}\n </div>\n );\n }\n);\n\nTable.propTypes = {\n darkMode: PropTypes.bool,\n shouldAlternateRowColor: PropTypes.bool,\n emptyTableContent: PropTypes.node,\n};\n\nexport default Table;\n"],"names":["Table","forwardRef","_a","containerRef","children","className","_a$shouldAlternateRow","shouldAlternateRowColor","table","_a$disableAnimations","disableAnimations","header","_a$withPagination","withPagination","_a$emptyTableContent","emptyTableContent","_jsx","Text","Object","assign","color","colors","SECONDARY","align","CENTER","paginationProps","rest","__rest","getState","setPageSize","setPageIndex","previousPage","nextPage","loadedData","loadMoreTriggerRef","infiniteScrolling","getRowModel","numSelectedItems","getSelectedRowModel","rows","length","_jsxs","concat","styles","tableContainerStyles","tableWrapper","ref","cx","tableContainer","tabIndex","TableContextProvider","baseStyles","themeLight","colSpan","getAllColumns","style","height","loader","Loader","size","PRIMARY","Pagination","itemsPerPage","pagination","pageSize","onItemsPerPageOptionChange","value","Number","numTotalItems","currentPage","pageIndex","onCurrentPageOptionChange","onBackArrowClick","onForwardArrowClick","propTypes","darkMode","PropTypes","bool","node"],"mappings":"2aAeMA,IAAAA,EAAQC,GACZ,SACEC,EAcAC,OAbEC,EAUeF,EAVfE,SACAC,EASeH,EATfG,UAASC,EASMJ,EARfK,wBAAAA,OAA0B,IAAHD,GAAQA,EAG/BE,EAKeN,EALfM,MAAKC,EAKUP,EAJfQ,kBAAAA,OAAoB,IAAHD,GAAQA,EACzBE,EAGeT,EAHfS,OAAMC,EAGSV,EAFfW,eAAAA,OAAiB,IAAHD,GAAQA,EAAAE,EAEPZ,EADfa,kBAAAA,OAAiB,IAAAD,EAAGE,EAACC,EAAIC,OAAAC,OAAA,CAACC,MAAOH,EAAKI,OAAOC,UAAWC,MAAON,EAAKM,MAAMC,QAAuB,CAAApB,SAAA,cAAAU,EACjGW,EAAevB,EAAfuB,gBACGC,EAZLC,EAAAzB,EAAA,CAAA,WAAA,YAAA,0BAAA,eAAA,WAAA,QAAA,oBAAA,SAAA,iBAAA,oBAAA,oBAiBQ0B,EAA8HpB,EAA9HoB,SAAUC,EAAoHrB,EAApHqB,YAAaC,EAAuGtB,EAAvGsB,aAAcC,EAAy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CC,2BAA4B,SAACC,GAAK,OAAKrC,EAAYsC,OAAOD,GAAO,EACjEE,cAAe3C,aAAA,EAAAA,EAAiB2C,cAChCC,YAAazC,IAAWmC,WAAWO,UAAY,EAC/CC,0BAA2B,SAACL,GAAK,OAC/BpC,EAAaqC,OAAOD,GAAS,EAAE,EAEjCM,iBAAkB,WAAA,OAAMzC,GAAc,EACtC0C,oBAAqB,WAAA,OAAMzC,GAAU,EACrCK,iBAAkBA,GACdZ,OAKd,IAGFzB,EAAM0E,UAAY,CAChBC,SAAUC,EAAUC,KACpBtE,wBAAyBqE,EAAUC,KACnC9D,kBAAmB6D,EAAUE"}
1
+ {"version":3,"file":"Table.js","sources":["../../../../../src/components/NewTable/Table.tsx"],"sourcesContent":["import React, { ForwardedRef, forwardRef, ReactNode } from \"react\";\n\nimport PropTypes from \"prop-types\";\nimport EmptyState from \"../EmptyState/EmptyState\";\nimport cx from \"classnames\";\n\nimport { TableContextProvider } from \"./components/TableContext\";\nimport { LGRowData } from \"./components/useLeafyGreenTable\";\n\nimport styles from \"./Table.module.scss\"; // Import SCSS styles\nimport { TableProps } from \"./Table.types\";\nimport Pagination from \"./components/newComponents/pagination\";\nimport Text from \"../Text/Text\";\nimport Loader from \"../Loader/Loader\";\n\nconst Table = forwardRef<HTMLDivElement, TableProps<any>>(\n <T extends LGRowData>(\n {\n children,\n className,\n shouldAlternateRowColor = false,\n baseFontSize: baseFontSizeProp,\n darkMode: darkModeProp,\n table,\n disableAnimations = false,\n header,\n withPagination = false,\n emptyTableContent = <Text color={Text.colors.SECONDARY} align={Text.align.CENTER}>No Data.</Text>,\n paginationProps,\n ...rest\n }: TableProps<T>,\n containerRef: ForwardedRef<HTMLDivElement>\n ) => {\n //@ts-ignore\n const { getState, setPageSize, setPageIndex, previousPage, nextPage, loadedData, isLoading, loadMoreTriggerRef, infiniteScrolling } = table;\n const rows = table.getRowModel().rows;\n const numSelectedItems = table.getSelectedRowModel().rows.length;\n\n return (\n <div className={`${styles.tableContainerStyles} ${styles.tableWrapper}`}>\n {header}\n <div\n ref={containerRef}\n className={cx(styles.tableContainerStyles, styles.tableContainer,className)} // Use class from SCSS module\n tabIndex={0} // Allows keyboard interaction\n >\n <TableContextProvider\n shouldAlternateRowColor={shouldAlternateRowColor}\n table={table}\n disableAnimations={disableAnimations}\n >\n <table\n className={cx(\n styles.baseStyles, // Base styles from SCSS module\n styles.themeLight // Conditional theme styles\n )}\n {...rest}\n >\n {children}\n {loadedData.length === 0 && (\n <tbody>\n <tr>\n <td\n colSpan={table.getAllColumns().length}\n className={styles.emptyTableContent}\n >\n {emptyTableContent}\n </td>\n </tr>\n </tbody>\n )}\n </table>\n <div style={{ position: \"relative\", paddingBottom: \"20px\" }}>\n <div ref={loadMoreTriggerRef} style={{ height: \"1px\" }} />\n {infiniteScrolling && isLoading && (\n <div className={cx(styles.loaderContainer)}>\n <Loader\n size={20}\n color={Loader.colors.PRIMARY}\n className={styles.loader}\n />\n </div>\n )}\n </div>\n </TableContextProvider>\n </div>\n {withPagination && (\n <Pagination\n itemsPerPage={getState().pagination.pageSize}\n onItemsPerPageOptionChange={(value) => setPageSize(Number(value))}\n numTotalItems={paginationProps?.numTotalItems}\n currentPage={getState().pagination.pageIndex + 1}\n onCurrentPageOptionChange={(value) =>\n setPageIndex(Number(value) - 1)\n }\n onBackArrowClick={() => previousPage()}\n onForwardArrowClick={() => nextPage()}\n numSelectedItems={numSelectedItems}\n {...paginationProps}\n />\n )}\n </div>\n );\n }\n);\n\nTable.propTypes = {\n darkMode: PropTypes.bool,\n shouldAlternateRowColor: PropTypes.bool,\n emptyTableContent: PropTypes.node,\n};\n\nexport default Table;\n"],"names":["Table","forwardRef","_a","containerRef","children","className","_a$shouldAlternateRow","shouldAlternateRowColor","table","_a$disableAnimations","disableAnimations","header","_a$withPagination","withPagination","_a$emptyTableContent","emptyTableContent","_jsx","Text","Object","assign","color","colors","SECONDARY","align","CENTER","paginationProps","rest","__rest","getState","setPageSize","setPageIndex","previousPage","nextPage","loadedData","isLoading","loadMoreTriggerRef","infiniteScrolling","getRowModel","numSelectedItems","getSelectedRowModel","rows","length","_jsxs","concat","styles","tableContainerStyles","tableWrapper","ref","cx","tableContainer","tabIndex","TableContextProvider","baseStyles","themeLight","colSpan","getAllColumns","style","position","paddingBottom","height","loaderContainer","Loader","size","PRIMARY","loader","Pagination","itemsPerPage","pagination","pageSize","onItemsPerPageOptionChange","value","Number","numTotalItems","currentPage","pageIndex","onCurrentPageOptionChange","onBackArrowClick","onForwardArrowClick","propTypes","darkMode","PropTypes","bool","node"],"mappings":"2aAeMA,IAAAA,EAAQC,GACZ,SACEC,EAcAC,OAbEC,EAUeF,EAVfE,SACAC,EASeH,EATfG,UAASC,EASMJ,EARfK,wBAAAA,OAA0B,IAAHD,GAAQA,EAG/BE,EAKeN,EALfM,MAAKC,EAKUP,EAJfQ,kBAAAA,OAAoB,IAAHD,GAAQA,EACzBE,EAGeT,EAHfS,OAAMC,EAGSV,EAFfW,eAAAA,OAAiB,IAAHD,GAAQA,EAAAE,EAEPZ,EADfa,kBAAAA,OAAiB,IAAAD,EAAGE,EAACC,EAAIC,OAAAC,OAAA,CAACC,MAAOH,EAAKI,OAAOC,UAAWC,MAAON,EAAKM,MAAMC,QAAuB,CAAApB,SAAA,cAAAU,EACjGW,EAAevB,EAAfuB,gBACGC,EAZLC,EAAAzB,EAAA,CAAA,WAAA,YAAA,0BAAA,eAAA,WAAA,QAAA,oBAAA,SAAA,iBAAA,oBAAA,oBAiBQ0B,EAA8HpB,EAA9HoB,SAAUC,EAAoHrB,EAApHqB,YAAaC,EAAuGtB,EAAvGsB,aAAcC,EAAyFvB,EAAzFuB,aAAcC,EAA2ExB,EAA3EwB,SAAUC,EAAiEzB,EAAjEyB,WAAYC,EAAqD1B,EAArD0B,UAAWC,EAA0C3B,EAA1C2B,mBAAoBC,EAAsB5B,EAAtB4B,kBACnG5B,EAAM6B,cACnB,IAAMC,EAAmB9B,EAAM+B,sBAAsBC,KAAKC,OAE1D,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S,EAAE,EAEjCM,iBAAkB,WAAA,OAAM7C,GAAc,EACtC8C,oBAAqB,WAAA,OAAM7C,GAAU,EACrCM,iBAAkBA,GACdb,OAKd,IAGFzB,EAAM8E,UAAY,CAChBC,SAAUC,EAAUC,KACpB1E,wBAAyByE,EAAUC,KACnClE,kBAAmBiE,EAAUE"}
@@ -1,2 +1,2 @@
1
- var e={tableContainerStyles:"tableContainerStyles",tableWrapper:"tableWrapper",tableContainer:"tableContainer",baseStyles:"baseStyles",emptyTableContent:"emptyTableContent",loaderRow:"loaderRow",loader:"loader"};!function(e){if("undefined"==typeof document)return;const n=document.head||document.getElementsByTagName("head")[0],t="s_id-32a092483b92_0_0_293";if(n.querySelector("#"+t))return;const a=document.createElement("style");a.id=t,n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),a.appendChild(document.createTextNode(e))}(".tableContainerStyles {\n position: relative;\n}\n\n.tableWrapper {\n width: 100%;\n height: 100%;\n overflow: hidden;\n}\n\n.tableContainer {\n overflow-x: auto;\n overflow-y: auto;\n height: 90%;\n}\n\n.baseStyles {\n border-spacing: 0;\n border-collapse: collapse;\n margin: 0;\n padding: 0;\n border: none;\n vertical-align: baseline;\n flex-direction: column;\n isolation: isolate;\n overflow: auto;\n scrollbar-gutter: stable;\n background-color: transparent;\n font-size: 14px;\n}\n\n.emptyTableContent {\n text-align: center;\n padding: 20px;\n}\n\n.loaderRow {\n width: 100%;\n}\n\n.loader {\n margin: 16px auto;\n display: flex;\n justify-content: center;\n align-items: center;\n}");export{e as default};
1
+ var n={tableContainerStyles:"tableContainerStyles",tableWrapper:"tableWrapper",tableContainer:"tableContainer",baseStyles:"baseStyles",emptyTableContent:"emptyTableContent",loaderRow:"loaderRow",loader:"loader",loaderContainer:"loaderContainer"};!function(n){if("undefined"==typeof document)return;const e=document.head||document.getElementsByTagName("head")[0],t="s_id-06926aa6367a_0_0_293";if(e.querySelector("#"+t))return;const a=document.createElement("style");a.id=t,e.firstChild?e.insertBefore(a,e.firstChild):e.appendChild(a),a.appendChild(document.createTextNode(n))}(".tableContainerStyles {\n position: relative;\n}\n\n.tableWrapper {\n width: 100%;\n height: 100%;\n overflow: hidden;\n}\n\n.tableContainer {\n overflow-x: auto;\n overflow-y: auto;\n height: 90%;\n}\n\n.baseStyles {\n border-spacing: 0;\n border-collapse: collapse;\n margin: 0;\n padding: 0;\n border: none;\n vertical-align: baseline;\n flex-direction: column;\n isolation: isolate;\n overflow: auto;\n scrollbar-gutter: stable;\n background-color: transparent;\n font-size: 14px;\n}\n\n.emptyTableContent {\n text-align: center;\n padding: 20px;\n}\n\n.loaderRow {\n width: 100%;\n}\n\n.loader {\n margin: 16px auto;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.loaderContainer {\n display: flex;\n justify-content: center;\n align-items: center;\n position: absolute;\n bottom: 0;\n width: 100%;\n}");export{n as default};
2
2
  //# sourceMappingURL=Table.module.scss.js.map
@@ -1,2 +1,2 @@
1
- import{slicedToArray as e,toConsumableArray as n}from"../../../../../_virtual/_rollupPluginBabelHelpers.js";import{__rest as t}from"../../../../../_virtual/_tslib.js";import{jsx as o}from"@emotion/react/jsx-runtime";import{useState as i,useRef as l,useCallback as r,useEffect as a,useMemo as c}from"react";import{useVirtual as s}from"react-virtual";import{getCoreRowModel as u,getSortedRowModel as d,getPaginationRowModel as g,useReactTable as f}from"@tanstack/react-table";import m from"lodash/omit";import{TableHeaderCheckbox as h}from"./TableHeaderCheckbox.js";import{TableRowCheckbox as v}from"./TableRowCheckbox.js";import w from"../../../Icon/Icons/components/Settings.js";import b from"../../../IconButton/IconButton.js";import R from"../ToggleExpandedIcon/ToggleExpandedIcon.js";import S from"../../../Dialog/Dialog.js";import p from"../../../DialogContentContainer/DialogContentContainer.js";import C from"../../../Checkbox/Checkbox.js";import I from"../../../ListItem/ListItem.js";var j=function(j){var x=j.containerRef,O=j.data,M=j.columns,y=j.hasSelectableRows,z=j.withPagination,T=void 0!==z&&z,k=j.useVirtualScrolling,E=void 0!==k&&k,A=j.allowSelectAll,L=void 0===A||A,P=j.allowSelectSingle,D=void 0!==P&&P,_=j.onSelect,B=j.virtualizerOptions,H=j.initiallySelectedRowIds,V=void 0===H?[]:H,F=j.onRowSelectionChange,U=j.columnManager,K=void 0!==U&&U,X=j.isExpandable,N=void 0!==X&&X,q=j.hoverIcon,G=j.selectCurrentPageOnly,J=void 0!==G&&G,Q=j.onUnselectAll,W=j.initialState,Y=j.initialLoadCount,Z=void 0===Y?20:Y,$=j.loadMoreCount,ee=void 0===$?10:$,ne=j.onLoadMore,te=j.infiniteScrolling,oe=void 0!==te&&te,ie=j.autoResetPageIndex,le=void 0===ie||ie,re=j.selectAllRows,ae=void 0!==re&&re,ce=t(j,["containerRef","data","columns","hasSelectableRows","withPagination","useVirtualScrolling","allowSelectAll","allowSelectSingle","onSelect","virtualizerOptions","initiallySelectedRowIds","onRowSelectionChange","columnManager","isExpandable","hoverIcon","selectCurrentPageOnly","onUnselectAll","initialState","initialLoadCount","loadMoreCount","onLoadMore","infiniteScrolling","autoResetPageIndex","selectAllRows"]),se=i({}),ue=e(se,2),de=ue[0],ge=ue[1],fe=i(null),me=e(fe,2),he=me[0],ve=me[1],we=i(!1),be=e(we,2),Re=be[0],Se=be[1],pe=i([]),Ce=e(pe,2),Ie=Ce[0],je=Ce[1],xe=i(!1),Oe=e(xe,2),Me=Oe[0],ye=Oe[1],ze=i(!1),Te=e(ze,2),ke=Te[0],Ee=Te[1],Ae=l(null),Le=l(!1),Pe=l({}),De=l([]),_e=l(null),Be=l(null),He=r((function(e,n){var t,o;return y&&null!==(o=null===(t=e.id)||void 0===t?void 0:""+t)&&void 0!==o?o:""+n}),[y]);a((function(){!Le.current&&y&&(Pe.current=V.reduce((function(e,n){return e[""+n]=!0,e}),{}),Le.current=!0)}),[V,y]),a((function(){je(oe?O.slice(0,Z):O)}),[O,oe,Z]),a((function(){if(O!==De.current&&y){var e=Object.assign(Object.assign({},Pe.current),de),n={};O.forEach((function(t,o){var i=He(t,o);e[i]&&(n[i]=!0)})),ge(n),De.current=O}}),[O,He,y]);var Ve={id:"select",size:14,header:h,cell:v};a((function(){if(ae&&y){var e=O.reduce((function(e,n,t){return e[He(n,t)]=!0,e}),{});ge(e)}}),[ae,y,O,He]);var Fe=c((function(){return M.some((function(e){return!!e.enableSorting}))}),[M]),Ue=L?Ve:m(Ve,"header"),Ke={id:"expander",size:30,header:function(){return null},cell:function(e){var n=e.row;return n.getCanExpand()?o(R,{isExpanded:n.getIsExpanded(),toggleExpanded:function(){return n.toggleExpanded()},disabled:!1}):null}},Xe={id:"hoverIcon",size:30,sticky:"right",header:function(){return null},cell:function(e){return o("span",Object.assign({style:{display:"block",height:"100%"}},{children:he===e.row.index&&q}))}},Ne=c((function(){var e=M.filter((function(e){return"left"===e.sticky})),t=M.filter((function(e){return"right"===e.sticky})),i=0,l=0;return[].concat(n(y?[Ue]:[]),n(N?[Ke]:[]),n(M.map((function(n,o){var r,a,c,s=Object.assign(Object.assign({},n),{align:null!==(r=n.align)&&void 0!==r?r:"left",enableSorting:null!==(a=n.enableSorting)&&void 0!==a&&a,isResizable:null!==(c=n.isResizable)&&void 0!==c&&c,cell:n.cell||function(e){return(0,e.getValue)()}});return"left"===n.sticky?(s.left=i,i+=n.size,s.isLastStickyLeft=o===e.length-1):"right"===n.sticky&&(s.right=(l+=n.size)-n.size,s.isFirstStickyRight=o===M.length-t.length),s})).map((function(e,n,o){return"right"===e.sticky&&(e.isFirstStickyRight=n===o.length-t.length),e}))),[q?Xe:null],n(K?[{id:"columnManager",size:20,header:function(){var e;return o(S,Object.assign({showTrigger:[S.hideShowTriggers.CLICK],hideTrigger:[S.hideShowTriggers.CLICK_OUTSIDE],position:S.positions.BOTTOM_END,open:ke,content:o(p,{children:tn.getAllLeafColumns().slice(0,-1).map((function(e,n){return o(I,{children:o(C,{checked:e.getIsVisible(),label:e.columnDef.header||e.id,onChange:e.getToggleVisibilityHandler(),"aria-labelledby":"iui-column-".concat(e.id)})},"".concat(e.id,"-").concat(n))}))},"small"),onDialogDidHide:function(){return Ee(!1)}},{children:o(b,{ariaLabel:"Customize",size:null===(e=null==b?void 0:b.sizes)||void 0===e?void 0:e.XXS,icon:w,ref:Ae,onClick:function(){return Ee(!0)}})}))},cell:function(){return null}}]:[])).filter(Boolean)}),[M,y,Ue,K,N,q,ke]),qe=i("onChange"),Ge=e(qe,2),Je=Ge[0],Qe=i("ltr"),We=e(Qe,2),Ye=We[0],Ze=function(e){if(y){var n=Object.assign({},Pe.current),t=J?tn.getPageRows():tn.getPreFilteredRowModel().rows,o=null!=e?e:!tn.getIsAllRowsSelected();t.forEach((function(e){n[e.id]=o})),ge(n)}},$e=function(){y&&(ge({}),Pe.current={},null==Q||Q())},en=r((function(){oe&&!Me&&O.length>Ie.length&&(ye(!0),setTimeout((function(){je((function(e){var t=O.slice(e.length,e.length+ee);return[].concat(n(e),n(t))})),ye(!1),ne&&ne()}),500))}),[oe,Me,O,ee,ne,Ie.length]);a((function(){return oe&&Be.current&&(_e.current=new IntersectionObserver((function(e){e[0].isIntersecting&&en()}),{threshold:.1}),_e.current.observe(Be.current)),function(){_e.current&&_e.current.disconnect()}}),[oe,en]);var nn=Object.assign({data:Ie,columns:Ne,getCoreRowModel:u(),getRowCanExpand:function(e){var n;return!!e.original.renderExpandedContent||!!(null===(n=e.subRows)||void 0===n?void 0:n.length)},enableExpanding:!0,enableSortingRemoval:!!Fe||void 0,getSubRows:function(e){return e.subRows},getSortedRowModel:d(),getPaginationRowModel:T?g():void 0,initialState:W||void 0,columnResizeMode:Je,columnResizeDirection:Ye,autoResetPageIndex:le},ce);y&&(nn.getRowId=He,nn.state={rowSelection:de},nn.onRowSelectionChange=ge);var tn=f(nn);tn.toggleAllRowsSelected=Ze,tn.unselectAllRows=$e;var on=tn.getCoreRowModel().rows,ln=(tn.getPaginationRowModel(),s(Object.assign({parentRef:x,size:on.length,overscan:30},B)));return a((function(){if(F&&y){var e=O.filter((function(e,n){return de[He(e,n)]}));F(e)}}),[de,O,F,He,y]),Object.assign(Object.assign(Object.assign(Object.assign({},tn),{handleRowClick:function(e){if(D){var n=O.find((function(n,t){return He(n,t)===e}));null==_||_(n)}},toggleAllRowsSelected:Ze,unselectAllRows:$e}),E&&{virtualRows:ln.virtualItems,totalSize:ln.totalSize,scrollToIndex:ln.scrollToIndex,scrollToOffset:ln.scrollToOffset,measure:ln.measure}),{hasSelectableRows:y,showColumnManager:Re,setShowColumnManager:Se,columnManagerRef:Ae,setHoveredRow:ve,isLoading:Me,loadedData:Ie,loadMoreTriggerRef:Be,infiniteScrolling:oe,loadMoreRows:en})};export{j as default};
1
+ import{slicedToArray as e,toConsumableArray as n}from"../../../../../_virtual/_rollupPluginBabelHelpers.js";import{__rest as t}from"../../../../../_virtual/_tslib.js";import{jsx as o}from"@emotion/react/jsx-runtime";import{useState as i,useRef as l,useCallback as r,useEffect as a,useMemo as c}from"react";import{useVirtual as s}from"react-virtual";import{getCoreRowModel as u,getSortedRowModel as d,getPaginationRowModel as g,useReactTable as f}from"@tanstack/react-table";import h from"lodash/omit";import{TableHeaderCheckbox as m}from"./TableHeaderCheckbox.js";import{TableRowCheckbox as v}from"./TableRowCheckbox.js";import w from"../../../Icon/Icons/components/Settings.js";import b from"../../../IconButton/IconButton.js";import R from"../ToggleExpandedIcon/ToggleExpandedIcon.js";import S from"../../../Dialog/Dialog.js";import p from"../../../DialogContentContainer/DialogContentContainer.js";import C from"../../../Checkbox/Checkbox.js";import I from"../../../ListItem/ListItem.js";var j=function(j){var x=j.containerRef,O=j.data,M=j.columns,y=j.hasSelectableRows,z=j.withPagination,T=void 0!==z&&z,k=j.useVirtualScrolling,E=void 0!==k&&k,A=j.allowSelectAll,L=void 0===A||A,P=j.allowSelectSingle,D=void 0!==P&&P,_=j.onSelect,B=j.virtualizerOptions,H=j.initiallySelectedRowIds,V=void 0===H?[]:H,F=j.onRowSelectionChange,U=j.columnManager,K=void 0!==U&&U,X=j.isExpandable,N=void 0!==X&&X,q=j.hoverIcon,G=j.selectCurrentPageOnly,J=void 0!==G&&G,Q=j.onUnselectAll,W=j.initialState,Y=j.initialLoadCount,Z=void 0===Y?20:Y,$=j.loadMoreCount,ee=void 0===$?10:$,ne=j.onLoadMore,te=j.infiniteScrolling,oe=void 0!==te&&te,ie=j.autoResetPageIndex,le=void 0===ie||ie,re=j.selectAllRows,ae=void 0!==re&&re,ce=t(j,["containerRef","data","columns","hasSelectableRows","withPagination","useVirtualScrolling","allowSelectAll","allowSelectSingle","onSelect","virtualizerOptions","initiallySelectedRowIds","onRowSelectionChange","columnManager","isExpandable","hoverIcon","selectCurrentPageOnly","onUnselectAll","initialState","initialLoadCount","loadMoreCount","onLoadMore","infiniteScrolling","autoResetPageIndex","selectAllRows"]),se=i({}),ue=e(se,2),de=ue[0],ge=ue[1],fe=i(null),he=e(fe,2),me=he[0],ve=he[1],we=i(!1),be=e(we,2),Re=be[0],Se=be[1],pe=i([]),Ce=e(pe,2),Ie=Ce[0],je=Ce[1],xe=i(!1),Oe=e(xe,2),Me=Oe[0],ye=Oe[1],ze=i(!1),Te=e(ze,2),ke=Te[0],Ee=Te[1],Ae=l(null),Le=l(!1),Pe=l({}),De=l([]),_e=l(null),Be=l(null),He=r((function(e,n){var t,o;return y&&null!==(o=null===(t=e.id)||void 0===t?void 0:""+t)&&void 0!==o?o:""+n}),[y]);a((function(){!Le.current&&y&&(Pe.current=V.reduce((function(e,n){return e[""+n]=!0,e}),{}),Le.current=!0)}),[V,y]),a((function(){je(oe?O.slice(0,Z):O)}),[O,oe,Z]),a((function(){if(O!==De.current&&y){var e=Object.assign(Object.assign({},Pe.current),de),n={};O.forEach((function(t,o){var i=He(t,o);e[i]&&(n[i]=!0)})),ge(n),De.current=O}}),[O,He,y]);var Ve={id:"select",size:14,header:m,cell:v};a((function(){if(ae&&y){var e=O.reduce((function(e,n,t){return e[He(n,t)]=!0,e}),{});ge(e)}}),[ae,y,O,He]);var Fe=c((function(){return M.some((function(e){return!!e.enableSorting}))}),[M]),Ue=L?Ve:h(Ve,"header"),Ke={id:"expander",size:30,header:function(){return null},cell:function(e){var n=e.row;return n.getCanExpand()?o(R,{isExpanded:n.getIsExpanded(),toggleExpanded:function(){return n.toggleExpanded()},disabled:!1}):null}},Xe={id:"hoverIcon",size:30,sticky:"right",header:function(){return null},cell:function(e){return o("span",Object.assign({style:{display:"block",height:"100%"}},{children:me===e.row.index&&q}))}},Ne=c((function(){var e=M.filter((function(e){return"left"===e.sticky})),t=M.filter((function(e){return"right"===e.sticky})),i=0,l=0;return[].concat(n(y?[Ue]:[]),n(N?[Ke]:[]),n(M.map((function(n,o){var r,a,c,s=Object.assign(Object.assign({},n),{align:null!==(r=n.align)&&void 0!==r?r:"left",enableSorting:null!==(a=n.enableSorting)&&void 0!==a&&a,isResizable:null!==(c=n.isResizable)&&void 0!==c&&c,cell:n.cell||function(e){return(0,e.getValue)()}});return"left"===n.sticky?(s.left=i,i+=n.size,s.isLastStickyLeft=o===e.length-1):"right"===n.sticky&&(s.right=(l+=n.size)-n.size,s.isFirstStickyRight=o===M.length-t.length),s})).map((function(e,n,o){return"right"===e.sticky&&(e.isFirstStickyRight=n===o.length-t.length),e}))),[q?Xe:null],n(K?[{id:"columnManager",size:20,header:function(){var e;return o(S,Object.assign({showTrigger:[S.hideShowTriggers.CLICK],hideTrigger:[S.hideShowTriggers.CLICK_OUTSIDE],position:S.positions.BOTTOM_END,open:ke,content:o(p,{children:tn.getAllLeafColumns().slice(0,-1).map((function(e,n){return o(I,{children:o(C,{checked:e.getIsVisible(),label:e.columnDef.header||e.id,onChange:e.getToggleVisibilityHandler(),"aria-labelledby":"iui-column-".concat(e.id)})},"".concat(e.id,"-").concat(n))}))},"small"),onDialogDidHide:function(){return Ee(!1)}},{children:o(b,{ariaLabel:"Customize",size:null===(e=null==b?void 0:b.sizes)||void 0===e?void 0:e.XXS,icon:w,ref:Ae,onClick:function(){return Ee(!0)}})}))},cell:function(){return null}}]:[])).filter(Boolean)}),[M,y,Ue,K,N,q,ke]),qe=i("onChange"),Ge=e(qe,2),Je=Ge[0],Qe=i("ltr"),We=e(Qe,2),Ye=We[0],Ze=function(e){if(y){var n=Object.assign({},Pe.current),t=J?tn.getPageRows():tn.getPreFilteredRowModel().rows,o=null!=e?e:!tn.getIsAllRowsSelected();t.forEach((function(e){n[e.id]=o})),ge(n)}},$e=function(){y&&(ge({}),Pe.current={},null==Q||Q())},en=r((function(){oe&&!Me&&O.length>Ie.length&&(ye(!0),setTimeout((function(){je((function(e){var t=O.slice(e.length,e.length+ee);return e.length+t.length>=O.length&&_e.current&&_e.current.disconnect(),[].concat(n(e),n(t))})),ye(!1),ne&&ne()}),500))}),[oe,Me,O,ee,ne,Ie.length]);a((function(){return oe&&Be.current&&(_e.current=new IntersectionObserver((function(e){e[0].isIntersecting&&en()}),{threshold:.1}),_e.current.observe(Be.current)),function(){_e.current&&_e.current.disconnect()}}),[oe,en]);var nn=Object.assign({data:Ie,columns:Ne,getCoreRowModel:u(),getRowCanExpand:function(e){var n;return!!e.original.renderExpandedContent||!!(null===(n=e.subRows)||void 0===n?void 0:n.length)},enableExpanding:!0,enableSortingRemoval:!!Fe||void 0,getSubRows:function(e){return e.subRows},getSortedRowModel:d(),getPaginationRowModel:T?g():void 0,initialState:W||void 0,columnResizeMode:Je,columnResizeDirection:Ye,autoResetPageIndex:le},ce);y&&(nn.getRowId=He,nn.state={rowSelection:de},nn.onRowSelectionChange=ge);var tn=f(nn);tn.toggleAllRowsSelected=Ze,tn.unselectAllRows=$e;var on=tn.getCoreRowModel().rows,ln=(tn.getPaginationRowModel(),s(Object.assign({parentRef:x,size:on.length,overscan:30},B)));return a((function(){if(F&&y){var e=O.filter((function(e,n){return de[He(e,n)]}));F(e)}}),[de,O,F,He,y]),Object.assign(Object.assign(Object.assign(Object.assign({},tn),{handleRowClick:function(e){if(D){var n=O.find((function(n,t){return He(n,t)===e}));null==_||_(n)}},toggleAllRowsSelected:Ze,unselectAllRows:$e}),E&&{virtualRows:ln.virtualItems,totalSize:ln.totalSize,scrollToIndex:ln.scrollToIndex,scrollToOffset:ln.scrollToOffset,measure:ln.measure}),{hasSelectableRows:y,showColumnManager:Re,setShowColumnManager:Se,columnManagerRef:Ae,setHoveredRow:ve,isLoading:Me,loadedData:Ie,loadMoreTriggerRef:Be,infiniteScrolling:oe,loadMoreRows:en})};export{j as default};
2
2
  //# sourceMappingURL=useLeafyGreenTable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLeafyGreenTable.js","sources":["../../../../../../../src/components/NewTable/components/useLeafyGreenTable/useLeafyGreenTable.tsx"],"sourcesContent":["//@ts-nocheck\nimport { useEffect, useLayoutEffect, useMemo, useRef, useState, useCallback } from \"react\";\nimport { useVirtual } from \"react-virtual\";\nimport { useReactTable, ColumnResizeMode, ColumnResizeDirection } from \"@tanstack/react-table\";\nimport { getCoreRowModel, getPaginationRowModel, getSortedRowModel } from \"@tanstack/react-table\";\nimport omit from \"lodash/omit\";\nimport { TableHeaderCheckbox } from \"./TableHeaderCheckbox\";\nimport { TableRowCheckbox } from \"./TableRowCheckbox\";\nimport { LeafyGreenTableOptions, LGRowData } from \"./useLeafyGreenTable.types\";\nimport { LeafyGreenTable, LGColumnDef, LGTableDataType } from \".\";\nimport Settings from \"../../../Icon/Icons/components/Settings\";\nimport IconButton from \"../../../IconButton/IconButton\";\nimport ToggleExpandedIcon from \"../ToggleExpandedIcon\";\nimport Dialog from \"../../../Dialog/Dialog\";\nimport List from \"../../../List/List\";\nimport DialogContentContainer from \"../../../DialogContentContainer/DialogContentContainer\";\nimport Checkbox from \"../../../Checkbox/Checkbox\";\nimport ListItem from \"../../../ListItem/ListItem\";\n\nconst CHECKBOX_WIDTH = 14;\n\nconst useLeafyGreenTable = <T extends LGRowData, V extends unknown = unknown>({\n containerRef,\n data,\n columns: columnsProp,\n hasSelectableRows,\n withPagination = false,\n useVirtualScrolling = false,\n allowSelectAll = true,\n allowSelectSingle = false,\n onSelect,\n virtualizerOptions,\n initiallySelectedRowIds = [],\n onRowSelectionChange,\n columnManager = false,\n isExpandable = false,\n hoverIcon,\n selectCurrentPageOnly = false,\n onUnselectAll,\n initialState,\n initialLoadCount = 20, \n loadMoreCount = 10, \n onLoadMore, \n infiniteScrolling = false,\n autoResetPageIndex = true,\n selectAllRows = false,\n ...rest\n}: LeafyGreenTableOptions<T, V>): LeafyGreenTable<T> => {\n const [rowSelection, setRowSelection] = useState<{ [key: string]: boolean }>({});\n const [hoveredRow, setHoveredRow] = useState<number | null>(null);\n const [showColumnManager, setShowColumnManager] = useState(false);\n const [loadedData, setLoadedData] = useState<T[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n const [isDialogOpen, setIsDialogOpen] = useState(false);\n\n const columnManagerRef = useRef<HTMLButtonElement>(null);\n const isInitialSetupDone = useRef(false);\n const initialSelectionRef = useRef<{ [key: string]: boolean }>({});\n const previousDataRef = useRef<T[]>([]);\n const observerRef = useRef<IntersectionObserver | null>(null);\n const loadMoreTriggerRef = useRef<HTMLDivElement | null>(null);\n\n const getRowId = useCallback((row: T, index: number) => {\n if (hasSelectableRows) {\n return row.id?.toString() ?? index.toString();\n }\n return index.toString();\n }, [hasSelectableRows]);\n\n useEffect(() => {\n if (!isInitialSetupDone.current && hasSelectableRows) {\n initialSelectionRef.current = initiallySelectedRowIds.reduce((acc, id) => {\n acc[id.toString()] = true;\n return acc;\n }, {});\n isInitialSetupDone.current = true;\n }\n }, [initiallySelectedRowIds, hasSelectableRows]);\n\n useEffect(() => {\n setLoadedData(infiniteScrolling ? data.slice(0, initialLoadCount) : data);\n }, [data, infiniteScrolling, initialLoadCount]);\n\n useEffect(() => {\n if (data !== previousDataRef.current && hasSelectableRows) {\n const newRowSelection = { ...initialSelectionRef.current, ...rowSelection };\n const filteredSelection = {};\n data.forEach((row, index) => {\n const rowId = getRowId(row, index);\n if (newRowSelection[rowId]) {\n filteredSelection[rowId] = true;\n }\n });\n \n setRowSelection(filteredSelection);\n previousDataRef.current = data;\n }\n }, [data, getRowId, hasSelectableRows]);\n\n const baseSelectColumnConfig: LGColumnDef<T, V> = {\n id: \"select\",\n size: CHECKBOX_WIDTH,\n header: TableHeaderCheckbox,\n cell: TableRowCheckbox,\n };\n\n useEffect(() => {\n if (selectAllRows && hasSelectableRows) {\n const allSelected = data.reduce((acc, row, index) => {\n acc[getRowId(row, index)] = true;\n return acc;\n }, {});\n setRowSelection(allSelected);\n }\n }, [selectAllRows, hasSelectableRows, data, getRowId]);\n\n const handleRowClick = (rowId: string) => {\n if (allowSelectSingle) {\n const selectedRowData = data.find((d, index) => getRowId(d, index) === rowId);\n onSelect?.(selectedRowData);\n }\n };\n\n const hasSortableColumns = useMemo(() => columnsProp.some((propCol) => !!propCol.enableSorting), [columnsProp]);\n\n const selectColumnConfig = allowSelectAll ? baseSelectColumnConfig : omit(baseSelectColumnConfig, \"header\");\n\n const expandColumnConfig: LGColumnDef<T, V> = {\n id: \"expander\",\n size: 30,\n header: () => null,\n cell: ({ row }) => {\n const isExpandable = row.getCanExpand();\n return isExpandable ? (\n <ToggleExpandedIcon\n isExpanded={row.getIsExpanded()}\n toggleExpanded={() => row.toggleExpanded()}\n disabled={false}\n />\n ) : null;\n },\n };\n\n const hoverIconConfig: LGColumnDef<T, V> = {\n id: \"hoverIcon\",\n size: 30,\n sticky: \"right\",\n header: () => null,\n cell: ({ row }) => (\n <span style={{ display: \"block\", height: \"100%\" }}>\n {hoveredRow === row.index && hoverIcon}\n </span>\n ),\n };\n\n const columns = useMemo<Array<LGColumnDef<T, V>>>(() => {\n const stickyLeftColumns = columnsProp.filter((col) => col.sticky === \"left\");\n const stickyRightColumns = columnsProp.filter((col) => col.sticky === \"right\");\n\n let leftOffset = 0;\n let rightOffset = 0;\n\n return [\n ...(hasSelectableRows ? [selectColumnConfig as LGColumnDef<T, V>] : []),\n ...(isExpandable ? [expandColumnConfig] : []),\n ...columnsProp\n .map((propColumn, index) => {\n const newColumn = {\n ...propColumn,\n align: propColumn.align ?? \"left\",\n enableSorting: propColumn.enableSorting ?? false,\n isResizable: propColumn.isResizable ?? false,\n cell: propColumn.cell || (({ getValue }) => getValue()),\n };\n\n if (propColumn.sticky === \"left\") {\n newColumn.left = leftOffset;\n leftOffset += propColumn.size;\n newColumn.isLastStickyLeft = index === stickyLeftColumns.length - 1;\n } else if (propColumn.sticky === \"right\") {\n rightOffset += propColumn.size;\n newColumn.right = rightOffset - propColumn.size;\n newColumn.isFirstStickyRight = index === columnsProp.length - stickyRightColumns.length;\n }\n\n return newColumn;\n })\n .map((column, index, columns) => {\n if (column.sticky === \"right\") {\n column.isFirstStickyRight = index === columns.length - stickyRightColumns.length;\n }\n return column;\n }),\n hoverIcon ? hoverIconConfig : null,\n ...(columnManager\n ? [\n {\n id: \"columnManager\",\n size: 20,\n header: () => (\n <Dialog\n showTrigger={[Dialog.hideShowTriggers.CLICK]}\n hideTrigger={[Dialog.hideShowTriggers.CLICK_OUTSIDE]}\n position={Dialog.positions.BOTTOM_END}\n open={isDialogOpen}\n content={\n <DialogContentContainer key=\"small\">\n {table.getAllLeafColumns().slice(0, -1).map((column, index) => (\n <ListItem key={`${column.id}-${index}`}>\n <Checkbox\n checked={column.getIsVisible()}\n label={column.columnDef.header as string || column.id}\n onChange={column.getToggleVisibilityHandler()}\n aria-labelledby={`iui-column-${column.id}`}\n />\n </ListItem>\n ))}\n </DialogContentContainer> \n }\n onDialogDidHide={() => setIsDialogOpen(false)}\n >\n <IconButton\n ariaLabel=\"Customize\"\n size={IconButton?.sizes?.XXS}\n icon={Settings}\n ref={columnManagerRef}\n onClick={() => setIsDialogOpen(true)}\n />\n </Dialog>\n ),\n cell: () => null,\n },\n ]\n : []),\n ].filter(Boolean);\n }, [columnsProp, hasSelectableRows, selectColumnConfig, columnManager, isExpandable, hoverIcon, isDialogOpen]);\n\n const [columnResizeMode, setColumnResizeMode] = useState<ColumnResizeMode>(\"onChange\");\n const [columnResizeDirection, setColumnResizeDirection] = useState<ColumnResizeDirection>(\"ltr\");\n\n const toggleAllRowsSelected = (value?: boolean) => {\n if (!hasSelectableRows) return;\n\n const newSelection = { ...initialSelectionRef.current };\n const rowsToSelect = selectCurrentPageOnly ? table.getPageRows() : table.getPreFilteredRowModel().rows;\n\n const setTo = value ?? !table.getIsAllRowsSelected();\n rowsToSelect.forEach((row) => {\n newSelection[row.id] = setTo;\n });\n\n setRowSelection(newSelection);\n };\n\n const unselectAllRows = () => {\n if (!hasSelectableRows) return;\n\n setRowSelection({});\n initialSelectionRef.current = {};\n onUnselectAll?.();\n };\n\n const loadMoreRows = useCallback(() => {\n if (!infiniteScrolling || isLoading || loadedData.length >= data.length) return;\n setIsLoading(true);\n setTimeout(() => {\n setLoadedData((prevData) => {\n const nextData = data.slice(prevData.length, prevData.length + loadMoreCount);\n return [...prevData, ...nextData];\n });\n setIsLoading(false);\n if (onLoadMore) {\n onLoadMore();\n }\n }, 500);\n }, [infiniteScrolling, isLoading, data, loadMoreCount, onLoadMore, loadedData.length]);\n\n useEffect(() => {\n if (infiniteScrolling && loadMoreTriggerRef.current) {\n observerRef.current = new IntersectionObserver(\n (entries) => {\n if (entries[0].isIntersecting) {\n loadMoreRows();\n }\n },\n { threshold: 0.1 }\n );\n\n observerRef.current.observe(loadMoreTriggerRef.current);\n }\n\n return () => {\n if (observerRef.current) {\n observerRef.current.disconnect();\n }\n };\n }, [infiniteScrolling, loadMoreRows]);\n\n const tableOptions = {\n data: loadedData,\n columns,\n getCoreRowModel: getCoreRowModel(),\n getRowCanExpand: (row) => !!row.original.renderExpandedContent || !!row.subRows?.length,\n enableExpanding: true,\n enableSortingRemoval: hasSortableColumns ? true : undefined,\n getSubRows: (row) => row.subRows,\n getSortedRowModel: getSortedRowModel(),\n getPaginationRowModel: withPagination ? getPaginationRowModel() : undefined,\n initialState: initialState ? initialState : undefined,\n columnResizeMode,\n columnResizeDirection,\n autoResetPageIndex,\n ...rest,\n };\n\n if (hasSelectableRows) {\n tableOptions.getRowId = getRowId;\n tableOptions.state = { rowSelection };\n tableOptions.onRowSelectionChange = setRowSelection;\n }\n\n const table = useReactTable<LGTableDataType<T>>(tableOptions);\n\n table.toggleAllRowsSelected = toggleAllRowsSelected;\n table.unselectAllRows = unselectAllRows;\n\n const { rows } = table.getCoreRowModel();\n const { rows: paginationRows } = table.getPaginationRowModel();\n const _rowVirtualizer = useVirtual({\n parentRef: containerRef,\n size: rows.length,\n overscan: 30,\n ...virtualizerOptions,\n });\n\n useEffect(() => {\n if (onRowSelectionChange && hasSelectableRows) {\n const selectedRows = data.filter((row, index) => rowSelection[getRowId(row, index)]);\n onRowSelectionChange(selectedRows);\n }\n }, [rowSelection, data, onRowSelectionChange, getRowId, hasSelectableRows]);\n\n return {\n ...table,\n handleRowClick,\n toggleAllRowsSelected, \n unselectAllRows, \n ...(useVirtualScrolling && {\n virtualRows: _rowVirtualizer.virtualItems,\n totalSize: _rowVirtualizer.totalSize,\n scrollToIndex: _rowVirtualizer.scrollToIndex,\n scrollToOffset: _rowVirtualizer.scrollToOffset,\n measure: _rowVirtualizer.measure,\n }),\n hasSelectableRows,\n showColumnManager,\n setShowColumnManager,\n columnManagerRef,\n setHoveredRow,\n isLoading,\n loadedData,\n loadMoreTriggerRef,\n infiniteScrolling,\n loadMoreRows,\n } as LeafyGreenTable<T>;\n};\n\nexport default useLeafyGreenTable;\n"],"names":["useLeafyGreenTable","_a","containerRef","data","columnsProp","columns","hasSelectableRows","_a$withPagination","withPagination","_a$useVirtualScrollin","useVirtualScrolling","_a$allowSelectAll","allowSelectAll","_a$allowSelectSingle","allowSelectSingle","onSelect","virtualizerOptions","_a$initiallySelectedR","initiallySelectedRowIds","onRowSelectionChange","_a$columnManager","columnManager","_a$isExpandable","isExpandable","hoverIcon","_a$selectCurrentPageO","selectCurrentPageOnly","onUnselectAll","initialState","_a$initialLoadCount","initialLoadCount","_a$loadMoreCount","loadMoreCount","onLoadMore","_a$infiniteScrolling","infiniteScrolling","_a$autoResetPageIndex","autoResetPageIndex","_a$selectAllRows","selectAllRows","rest","__rest","_useState","useState","_useState2","_slicedToArray","rowSelection","setRowSelection","_useState3","_useState4","hoveredRow","setHoveredRow","_useState5","_useState6","showColumnManager","setShowColumnManager","_useState7","_useState8","loadedData","setLoadedData","_useState9","_useState10","isLoading","setIsLoading","_useState11","_useState12","isDialogOpen","setIsDialogOpen","columnManagerRef","useRef","isInitialSetupDone","initialSelectionRef","previousDataRef","observerRef","loadMoreTriggerRef","getRowId","useCallback","row","index","_b","id","useEffect","current","reduce","acc","slice","newRowSelection","filteredSelection","forEach","rowId","baseSelectColumnConfig","size","header","TableHeaderCheckbox","cell","TableRowCheckbox","allSelected","hasSortableColumns","useMemo","some","propCol","enableSorting","selectColumnConfig","omit","expandColumnConfig","_ref","getCanExpand","_jsx","ToggleExpandedIcon","isExpanded","getIsExpanded","toggleExpanded","disabled","hoverIconConfig","sticky","_ref2","Object","assign","style","display","height","children","stickyLeftColumns","filter","col","stickyRightColumns","leftOffset","rightOffset","concat","_toConsumableArray","map","propColumn","newColumn","align","isResizable","_c","_ref3","getValue","left","isLastStickyLeft","length","right","isFirstStickyRight","column","Dialog","showTrigger","hideShowTriggers","CLICK","hideTrigger","CLICK_OUTSIDE","position","positions","BOTTOM_END","open","content","DialogContentContainer","table","getAllLeafColumns","ListItem","Checkbox","checked","getIsVisible","label","columnDef","onChange","getToggleVisibilityHandler","onDialogDidHide","IconButton","ariaLabel","sizes","XXS","icon","Settings","ref","onClick","Boolean","_useState13","_useState14","columnResizeMode","_useState15","_useState16","columnResizeDirection","toggleAllRowsSelected","value","newSelection","rowsToSelect","getPageRows","getPreFilteredRowModel","rows","setTo","getIsAllRowsSelected","unselectAllRows","loadMoreRows","setTimeout","prevData","nextData","IntersectionObserver","entries","isIntersecting","threshold","observe","disconnect","tableOptions","getCoreRowModel","getRowCanExpand","original","renderExpandedContent","subRows","enableExpanding","enableSortingRemoval","undefined","getSubRows","getSortedRowModel","getPaginationRowModel","state","useReactTable","_rowVirtualizer","useVirtual","parentRef","overscan","selectedRows","handleRowClick","selectedRowData","find","d","virtualRows","virtualItems","totalSize","sc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GAAKhD,OACX+E,SAAU,IACP3M,KAUL,OAPAiE,GAAU,WACR,GAAI9D,GAAwBb,EAAmB,CAC7C,IAAMsN,EAAezN,EAAKwH,QAAO,SAAC9C,EAAKC,GAAK,OAAKhC,GAAa6B,GAASE,EAAKC,OAC5E3D,EAAqByM,EACtB,CACH,GAAG,CAAC9K,GAAc3C,EAAMgB,EAAsBwD,GAAUrE,IAEjD8G,OAAAC,OAAAD,OAAAC,OAAAD,OAAAC,OAAAD,OAAAC,OAAA,CAAA,EACFuC,IAAK,CACRiE,eApOqB,SAACpI,GACtB,GAAI3E,EAAmB,CACrB,IAAMgN,EAAkB3N,EAAK4N,MAAK,SAACC,EAAGlJ,GAAK,OAAKH,GAASqJ,EAAGlJ,KAAWW,KACvE1E,SAAAA,EAAW+M,EACZ,GAiODxC,sBAAAA,GACAS,gBAAAA,KACIrL,GAAuB,CACzBuN,YAAaT,GAAgBU,aAC7BC,UAAWX,GAAgBW,UAC3BC,cAAeZ,GAAgBY,cAC/BC,eAAgBb,GAAgBa,eAChCC,QAASd,GAAgBc,WAE3BhO,kBAAAA,EACAgD,kBAAAA,GACAC,qBAAAA,GACAa,iBAAAA,GACAjB,cAAAA,GACAW,UAAAA,GACAJ,WAAAA,GACAgB,mBAAAA,GACAvC,kBAAAA,GACA6J,aAAAA,IAEJ"}
1
+ {"version":3,"file":"useLeafyGreenTable.js","sources":["../../../../../../../src/components/NewTable/components/useLeafyGreenTable/useLeafyGreenTable.tsx"],"sourcesContent":["//@ts-nocheck\nimport { useEffect, useLayoutEffect, useMemo, useRef, useState, useCallback } from \"react\";\nimport { useVirtual } from \"react-virtual\";\nimport { useReactTable, ColumnResizeMode, ColumnResizeDirection } from \"@tanstack/react-table\";\nimport { getCoreRowModel, getPaginationRowModel, getSortedRowModel } from \"@tanstack/react-table\";\nimport omit from \"lodash/omit\";\nimport { TableHeaderCheckbox } from \"./TableHeaderCheckbox\";\nimport { TableRowCheckbox } from \"./TableRowCheckbox\";\nimport { LeafyGreenTableOptions, LGRowData } from \"./useLeafyGreenTable.types\";\nimport { LeafyGreenTable, LGColumnDef, LGTableDataType } from \".\";\nimport Settings from \"../../../Icon/Icons/components/Settings\";\nimport IconButton from \"../../../IconButton/IconButton\";\nimport ToggleExpandedIcon from \"../ToggleExpandedIcon\";\nimport Dialog from \"../../../Dialog/Dialog\";\nimport List from \"../../../List/List\";\nimport DialogContentContainer from \"../../../DialogContentContainer/DialogContentContainer\";\nimport Checkbox from \"../../../Checkbox/Checkbox\";\nimport ListItem from \"../../../ListItem/ListItem\";\n\nconst CHECKBOX_WIDTH = 14;\n\nconst useLeafyGreenTable = <T extends LGRowData, V extends unknown = unknown>({\n containerRef,\n data,\n columns: columnsProp,\n hasSelectableRows,\n withPagination = false,\n useVirtualScrolling = false,\n allowSelectAll = true,\n allowSelectSingle = false,\n onSelect,\n virtualizerOptions,\n initiallySelectedRowIds = [],\n onRowSelectionChange,\n columnManager = false,\n isExpandable = false,\n hoverIcon,\n selectCurrentPageOnly = false,\n onUnselectAll,\n initialState,\n initialLoadCount = 20, \n loadMoreCount = 10, \n onLoadMore, \n infiniteScrolling = false,\n autoResetPageIndex = true,\n selectAllRows = false,\n ...rest\n}: LeafyGreenTableOptions<T, V>): LeafyGreenTable<T> => {\n const [rowSelection, setRowSelection] = useState<{ [key: string]: boolean }>({});\n const [hoveredRow, setHoveredRow] = useState<number | null>(null);\n const [showColumnManager, setShowColumnManager] = useState(false);\n const [loadedData, setLoadedData] = useState<T[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n const [isDialogOpen, setIsDialogOpen] = useState(false);\n\n const columnManagerRef = useRef<HTMLButtonElement>(null);\n const isInitialSetupDone = useRef(false);\n const initialSelectionRef = useRef<{ [key: string]: boolean }>({});\n const previousDataRef = useRef<T[]>([]);\n const observerRef = useRef<IntersectionObserver | null>(null);\n const loadMoreTriggerRef = useRef<HTMLDivElement | null>(null);\n\n const getRowId = useCallback((row: T, index: number) => {\n if (hasSelectableRows) {\n return row.id?.toString() ?? index.toString();\n }\n return index.toString();\n }, [hasSelectableRows]);\n\n useEffect(() => {\n if (!isInitialSetupDone.current && hasSelectableRows) {\n initialSelectionRef.current = initiallySelectedRowIds.reduce((acc, id) => {\n acc[id.toString()] = true;\n return acc;\n }, {});\n isInitialSetupDone.current = true;\n }\n }, [initiallySelectedRowIds, hasSelectableRows]);\n\n useEffect(() => {\n setLoadedData(infiniteScrolling ? data.slice(0, initialLoadCount) : data);\n }, [data, infiniteScrolling, initialLoadCount]);\n\n useEffect(() => {\n if (data !== previousDataRef.current && hasSelectableRows) {\n const newRowSelection = { ...initialSelectionRef.current, ...rowSelection };\n const filteredSelection = {};\n data.forEach((row, index) => {\n const rowId = getRowId(row, index);\n if (newRowSelection[rowId]) {\n filteredSelection[rowId] = true;\n }\n });\n \n setRowSelection(filteredSelection);\n previousDataRef.current = data;\n }\n }, [data, getRowId, hasSelectableRows]);\n\n const baseSelectColumnConfig: LGColumnDef<T, V> = {\n id: \"select\",\n size: CHECKBOX_WIDTH,\n header: TableHeaderCheckbox,\n cell: TableRowCheckbox,\n };\n\n useEffect(() => {\n if (selectAllRows && hasSelectableRows) {\n const allSelected = data.reduce((acc, row, index) => {\n acc[getRowId(row, index)] = true;\n return acc;\n }, {});\n setRowSelection(allSelected);\n }\n }, [selectAllRows, hasSelectableRows, data, getRowId]);\n\n const handleRowClick = (rowId: string) => {\n if (allowSelectSingle) {\n const selectedRowData = data.find((d, index) => getRowId(d, index) === rowId);\n onSelect?.(selectedRowData);\n }\n };\n\n const hasSortableColumns = useMemo(() => columnsProp.some((propCol) => !!propCol.enableSorting), [columnsProp]);\n\n const selectColumnConfig = allowSelectAll ? baseSelectColumnConfig : omit(baseSelectColumnConfig, \"header\");\n\n const expandColumnConfig: LGColumnDef<T, V> = {\n id: \"expander\",\n size: 30,\n header: () => null,\n cell: ({ row }) => {\n const isExpandable = row.getCanExpand();\n return isExpandable ? (\n <ToggleExpandedIcon\n isExpanded={row.getIsExpanded()}\n toggleExpanded={() => row.toggleExpanded()}\n disabled={false}\n />\n ) : null;\n },\n };\n\n const hoverIconConfig: LGColumnDef<T, V> = {\n id: \"hoverIcon\",\n size: 30,\n sticky: \"right\",\n header: () => null,\n cell: ({ row }) => (\n <span style={{ display: \"block\", height: \"100%\" }}>\n {hoveredRow === row.index && hoverIcon}\n </span>\n ),\n };\n\n const columns = useMemo<Array<LGColumnDef<T, V>>>(() => {\n const stickyLeftColumns = columnsProp.filter((col) => col.sticky === \"left\");\n const stickyRightColumns = columnsProp.filter((col) => col.sticky === \"right\");\n\n let leftOffset = 0;\n let rightOffset = 0;\n\n return [\n ...(hasSelectableRows ? [selectColumnConfig as LGColumnDef<T, V>] : []),\n ...(isExpandable ? [expandColumnConfig] : []),\n ...columnsProp\n .map((propColumn, index) => {\n const newColumn = {\n ...propColumn,\n align: propColumn.align ?? \"left\",\n enableSorting: propColumn.enableSorting ?? false,\n isResizable: propColumn.isResizable ?? false,\n cell: propColumn.cell || (({ getValue }) => getValue()),\n };\n\n if (propColumn.sticky === \"left\") {\n newColumn.left = leftOffset;\n leftOffset += propColumn.size;\n newColumn.isLastStickyLeft = index === stickyLeftColumns.length - 1;\n } else if (propColumn.sticky === \"right\") {\n rightOffset += propColumn.size;\n newColumn.right = rightOffset - propColumn.size;\n newColumn.isFirstStickyRight = index === columnsProp.length - stickyRightColumns.length;\n }\n\n return newColumn;\n })\n .map((column, index, columns) => {\n if (column.sticky === \"right\") {\n column.isFirstStickyRight = index === columns.length - stickyRightColumns.length;\n }\n return column;\n }),\n hoverIcon ? hoverIconConfig : null,\n ...(columnManager\n ? [\n {\n id: \"columnManager\",\n size: 20,\n header: () => (\n <Dialog\n showTrigger={[Dialog.hideShowTriggers.CLICK]}\n hideTrigger={[Dialog.hideShowTriggers.CLICK_OUTSIDE]}\n position={Dialog.positions.BOTTOM_END}\n open={isDialogOpen}\n content={\n <DialogContentContainer key=\"small\">\n {table.getAllLeafColumns().slice(0, -1).map((column, index) => (\n <ListItem key={`${column.id}-${index}`}>\n <Checkbox\n checked={column.getIsVisible()}\n label={column.columnDef.header as string || column.id}\n onChange={column.getToggleVisibilityHandler()}\n aria-labelledby={`iui-column-${column.id}`}\n />\n </ListItem>\n ))}\n </DialogContentContainer> \n }\n onDialogDidHide={() => setIsDialogOpen(false)}\n >\n <IconButton\n ariaLabel=\"Customize\"\n size={IconButton?.sizes?.XXS}\n icon={Settings}\n ref={columnManagerRef}\n onClick={() => setIsDialogOpen(true)}\n />\n </Dialog>\n ),\n cell: () => null,\n },\n ]\n : []),\n ].filter(Boolean);\n }, [columnsProp, hasSelectableRows, selectColumnConfig, columnManager, isExpandable, hoverIcon, isDialogOpen]);\n\n const [columnResizeMode, setColumnResizeMode] = useState<ColumnResizeMode>(\"onChange\");\n const [columnResizeDirection, setColumnResizeDirection] = useState<ColumnResizeDirection>(\"ltr\");\n\n const toggleAllRowsSelected = (value?: boolean) => {\n if (!hasSelectableRows) return;\n\n const newSelection = { ...initialSelectionRef.current };\n const rowsToSelect = selectCurrentPageOnly ? table.getPageRows() : table.getPreFilteredRowModel().rows;\n\n const setTo = value ?? !table.getIsAllRowsSelected();\n rowsToSelect.forEach((row) => {\n newSelection[row.id] = setTo;\n });\n\n setRowSelection(newSelection);\n };\n\n const unselectAllRows = () => {\n if (!hasSelectableRows) return;\n\n setRowSelection({});\n initialSelectionRef.current = {};\n onUnselectAll?.();\n };\n\n const loadMoreRows = useCallback(() => {\n if (!infiniteScrolling || isLoading || loadedData.length >= data.length) return;\n setIsLoading(true);\n setTimeout(() => {\n setLoadedData((prevData) => {\n const nextData = data.slice(prevData.length, prevData.length + loadMoreCount);\n if (prevData.length + nextData.length >= data.length && observerRef.current) {\n observerRef.current.disconnect();\n }\n\n return [...prevData, ...nextData];\n });\n setIsLoading(false);\n if (onLoadMore) {\n onLoadMore();\n }\n }, 500);\n }, [infiniteScrolling, isLoading, data, loadMoreCount, onLoadMore, loadedData.length]);\n\n useEffect(() => {\n if (infiniteScrolling && loadMoreTriggerRef.current) {\n observerRef.current = new IntersectionObserver(\n (entries) => {\n if (entries[0].isIntersecting) {\n loadMoreRows();\n }\n },\n { threshold: 0.1 }\n );\n\n observerRef.current.observe(loadMoreTriggerRef.current);\n }\n\n return () => {\n if (observerRef.current) {\n observerRef.current.disconnect();\n }\n };\n }, [infiniteScrolling, loadMoreRows]);\n\n const tableOptions = {\n data: loadedData,\n columns,\n getCoreRowModel: getCoreRowModel(),\n getRowCanExpand: (row) => !!row.original.renderExpandedContent || !!row.subRows?.length,\n enableExpanding: true,\n enableSortingRemoval: hasSortableColumns ? true : undefined,\n getSubRows: (row) => row.subRows,\n getSortedRowModel: getSortedRowModel(),\n getPaginationRowModel: withPagination ? getPaginationRowModel() : undefined,\n initialState: initialState ? initialState : undefined,\n columnResizeMode,\n columnResizeDirection,\n autoResetPageIndex,\n ...rest,\n };\n\n if (hasSelectableRows) {\n tableOptions.getRowId = getRowId;\n tableOptions.state = { rowSelection };\n tableOptions.onRowSelectionChange = setRowSelection;\n }\n\n const table = useReactTable<LGTableDataType<T>>(tableOptions);\n\n table.toggleAllRowsSelected = toggleAllRowsSelected;\n table.unselectAllRows = unselectAllRows;\n\n const { rows } = table.getCoreRowModel();\n const { rows: paginationRows } = table.getPaginationRowModel();\n const _rowVirtualizer = useVirtual({\n parentRef: containerRef,\n size: rows.length,\n overscan: 30,\n ...virtualizerOptions,\n });\n\n useEffect(() => {\n if (onRowSelectionChange && hasSelectableRows) {\n const selectedRows = data.filter((row, index) => rowSelection[getRowId(row, index)]);\n onRowSelectionChange(selectedRows);\n }\n }, [rowSelection, data, onRowSelectionChange, getRowId, hasSelectableRows]);\n\n return {\n ...table,\n handleRowClick,\n toggleAllRowsSelected, \n unselectAllRows, \n ...(useVirtualScrolling && {\n virtualRows: _rowVirtualizer.virtualItems,\n totalSize: _rowVirtualizer.totalSize,\n scrollToIndex: _rowVirtualizer.scrollToIndex,\n scrollToOffset: _rowVirtualizer.scrollToOffset,\n measure: _rowVirtualizer.measure,\n }),\n hasSelectableRows,\n showColumnManager,\n setShowColumnManager,\n columnManagerRef,\n setHoveredRow,\n isLoading,\n loadedData,\n loadMoreTriggerRef,\n infiniteScrolling,\n loadMoreRows,\n } as LeafyGreenTable<T>;\n};\n\nexport default useLeafyGreenTable;\n"],"names":["useLeafyGreenTable","_a","containerRef","data","columnsProp","columns","hasSelectableRows","_a$withPagination","withPagination","_a$useVirtualScrollin","useVirtualScrolling","_a$allowSelectAll","allowSelectAll","_a$allowSelectSingle","allowSelectSingle","onSelect","virtualizerOptions","_a$initiallySelectedR","initiallySelectedRowIds","onRowSelectionChange","_a$columnManager","columnManager","_a$isExpandable","isExpandable","hoverIcon","_a$selectCurrentPageO","selectCurrentPageOnly","onUnselectAll","initialState","_a$initialLoadCount","initialLoadCount","_a$loadMoreCount","loadMoreCount","onLoadMore","_a$infiniteScrolling","infiniteScrolling","_a$autoResetPageIndex","autoResetPageIndex","_a$selectAllRows","selectAllRows","rest","__rest","_useState","useState","_useState2","_slicedToArray","rowSelection","setRowSelection","_useState3","_useState4","hoveredRow","setHoveredRow","_useState5","_useState6","showColumnManager","setShowColumnManager","_useState7","_useState8","loadedData","setLoadedData","_useState9","_useState10","isLoading","setIsLoading","_useState11","_useState12","isDialogOpen","setIsDialogOpen","columnManagerRef","useRef","isInitialSetupDone","initialSelectionRef","previousDataRef","observerRef","loadMoreTriggerRef","getRowId","useCallback","row","index","_b","id","useEffect","current","reduce","acc","slice","newRowSelection","filteredSelection","forEach","rowId","baseSelectColumnConfig","size","header","TableHeaderCheckbox","cell","TableRowCheckbox","allSelected","hasSortableColumns","useMemo","some","propCol","enableSorting","selectColumnConfig","omit","expandColumnConfig","_ref","getCanExpand","_jsx","ToggleExpandedIcon","isExpanded","getIsExpanded","toggleExpanded","disabled","hoverIconConfig","sticky","_ref2","Object","assign","style","display","height","children","stickyLeftColumns","filter","col","stickyRightColumns","leftOffset","rightOffset","concat","_toConsumableArray","map","propColumn","newColumn","align","isResizable","_c","_ref3","getValue","left","isLastStickyLeft","length","right","isFirstStickyRight","column","Dialog","showTrigger","hideShowTriggers","CLICK","hideTrigger","CLICK_OUTSIDE","position","positions","BOTTOM_END","open","content","DialogContentContainer","table","getAllLeafColumns","ListItem","Checkbox","checked","getIsVisible","label","columnDef","onChange","getToggleVisibilityHandler","onDialogDidHide","IconButton","ariaLabel","sizes","XXS","icon","Settings","ref","onClick","Boolean","_useState13","_useState14","columnResizeMode","_useState15","_useState16","columnResizeDirection","toggleAllRowsSelected","value","newSelection","rowsToSelect","getPageRows","getPreFilteredRowModel","rows","setTo","getIsAllRowsSelected","unselectAllRows","loadMoreRows","setTimeout","prevData","nextData","disconnect","IntersectionObserver","entries","isIntersecting","threshold","observe","tableOptions","getCoreRowModel","getRowCanExpand","original","renderExpandedContent","subRows","enableExpanding","enableSortingRemoval","undefined","getSubRows","getSortedRowModel","getPaginationRowModel","state","useReactTable","_rowVirtualizer","useVirtual","parentRef","overscan","selectedRows","handleRowClick","selectedRowData","find","d","virtualRows","virtualItems","totalSize","scrollToIndex","scrollToOffset","measure"],"mappings":"+9BAmBA,IAEMA,EAAqB,SAAmDC,GAAA,IAC5EC,EAuBqBD,EAvBrBC,aACAC,EAsBqBF,EAtBrBE,KACSC,EAqBYH,EArBrBI,QACAC,EAoBqBL,EApBrBK,kBAAiBC,EAoBIN,EAnBrBO,eAAAA,OAAiB,IAAHD,GAAQA,EAAAE,EAmBDR,EAlBrBS,oBAAAA,OAAsB,IAAHD,GAAQA,EAAAE,EAkBNV,EAjBrBW,eAAAA,OAAiB,IAAHD,GAAOA,EAAAE,EAiBAZ,EAhBrBa,kBAAAA,OAAoB,IAAHD,GAAQA,EACzBE,EAeqBd,EAfrBc,SACAC,EAcqBf,EAdrBe,mBAAkBC,EAcGhB,EAbrBiB,wBAAAA,OAA0B,IAAHD,EAAG,GAAEA,EAC5BE,EAYqBlB,EAZrBkB,qBAAoBC,EAYCnB,EAXrBoB,cAAAA,OAAgB,IAAHD,GAAQA,EAAAE,EAWArB,EA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AS,gBAAAA,KACIrL,GAAuB,CACzBuN,YAAaT,GAAgBU,aAC7BC,UAAWX,GAAgBW,UAC3BC,cAAeZ,GAAgBY,cAC/BC,eAAgBb,GAAgBa,eAChCC,QAASd,GAAgBc,WAE3BhO,kBAAAA,EACAgD,kBAAAA,GACAC,qBAAAA,GACAa,iBAAAA,GACAjB,cAAAA,GACAW,UAAAA,GACAJ,WAAAA,GACAgB,mBAAAA,GACAvC,kBAAAA,GACA6J,aAAAA,IAEJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../../src/components/NewTable/Table.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8C,MAAM,OAAO,CAAC;AAUnE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,QAAA,MAAM,KAAK,wFAyGV,CAAC;AAQF,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../../src/components/NewTable/Table.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8C,MAAM,OAAO,CAAC;AAUnE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,QAAA,MAAM,KAAK,wFAyFV,CAAC;AAQF,eAAe,KAAK,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useLeafyGreenTable.d.ts","sourceRoot":"","sources":["../../../../../../src/components/NewTable/components/useLeafyGreenTable/useLeafyGreenTable.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,sBAAsB,EAAa,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAgC,MAAM,GAAG,CAAC;AAYlE,QAAA,MAAM,kBAAkB,ogBAwVvB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"useLeafyGreenTable.d.ts","sourceRoot":"","sources":["../../../../../../src/components/NewTable/components/useLeafyGreenTable/useLeafyGreenTable.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,sBAAsB,EAAa,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAgC,MAAM,GAAG,CAAC;AAYlE,QAAA,MAAM,kBAAkB,ogBA4VvB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heliux-org/design-system-core",
3
- "version": "0.0.294-TableTestBuild",
3
+ "version": "0.0.294",
4
4
  "description": "Official Heliux design system resources for application development in React.js",
5
5
  "main": "./dist/main.js",
6
6
  "types": "./dist/types/index.d.ts",
@@ -298,5 +298,5 @@
298
298
  "PR: Icon 💎": "New Icons"
299
299
  }
300
300
  },
301
- "gitHead": "548537fda45988de82568c16e68438fc797de5d2"
301
+ "gitHead": "5341ddbfbf52e32ef2e55c52228e03b1569138b5"
302
302
  }
@@ -45,4 +45,13 @@
45
45
  display: flex;
46
46
  justify-content: center;
47
47
  align-items: center;
48
+ }
49
+
50
+ .loaderContainer {
51
+ display: flex;
52
+ justify-content: center;
53
+ align-items: center;
54
+ position: absolute;
55
+ bottom: 0;
56
+ width: 100%;
48
57
  }
@@ -69,35 +69,19 @@ const Table = forwardRef<HTMLDivElement, TableProps<any>>(
69
69
  </tr>
70
70
  </tbody>
71
71
  )}
72
- {/* @ts-ignore */}
73
- {/* {isLoading && (
74
- <tr className={styles.loaderRow}>
75
- <td colSpan={table.getAllColumns().length}>
76
- <div className={styles.loader}>
77
- <Loader
78
- size={20}
79
- color={Loader.colors.PRIMARY}
80
- className={styles.loader}
81
- />
82
- </div>
83
- </td>
84
- </tr>
85
- )} */}
86
72
  </table>
87
- {infiniteScrolling && (
88
- <div ref={loadMoreTriggerRef} style={{ height: '1px' }} >
89
- <div className={cx(
90
- styles.baseStyles, // Base styles from SCSS module
91
- styles.loader
92
- )}>
73
+ <div style={{ position: "relative", paddingBottom: "20px" }}>
74
+ <div ref={loadMoreTriggerRef} style={{ height: "1px" }} />
75
+ {infiniteScrolling && isLoading && (
76
+ <div className={cx(styles.loaderContainer)}>
93
77
  <Loader
94
78
  size={20}
95
79
  color={Loader.colors.PRIMARY}
96
80
  className={styles.loader}
97
81
  />
98
82
  </div>
99
- </div>
100
- )}
83
+ )}
84
+ </div>
101
85
  </TableContextProvider>
102
86
  </div>
103
87
  {withPagination && (
@@ -3185,7 +3185,7 @@ export const WithFilters: StoryFn<StoryTableProps> = (args) => {
3185
3185
  );
3186
3186
  };
3187
3187
 
3188
- export const TestingStory: StoryFn<StoryTableProps> = (args) => {
3188
+ export const WithInfiniteScrolling: StoryFn<StoryTableProps> = (args) => {
3189
3189
  const tableContainerRef = React.useRef<HTMLDivElement>(null);
3190
3190
 
3191
3191
  const columns = useMemo(
@@ -3267,7 +3267,7 @@ export const TestingStory: StoryFn<StoryTableProps> = (args) => {
3267
3267
  }));
3268
3268
  };
3269
3269
 
3270
- const data = useMemo(() => generateRandomData(5000), []);
3270
+ const data = useMemo(() => generateRandomData(100), []);
3271
3271
  const [filteredData, setFilteredData] = useState(data);
3272
3272
 
3273
3273
  const table = useLeafyGreenTable<Person>({
@@ -3275,6 +3275,8 @@ export const TestingStory: StoryFn<StoryTableProps> = (args) => {
3275
3275
  data: filteredData,
3276
3276
  columns,
3277
3277
  infiniteScrolling: true,
3278
+ loadMoreCount: 20,
3279
+ initialLoadCount: 50
3278
3280
  });
3279
3281
 
3280
3282
  const { rows } = table.getRowModel();
@@ -65,18 +65,29 @@ To enable sorting functionality for your table columns, you can use the `enableS
65
65
 
66
66
  ## Selectable Rows
67
67
 
68
+ `hasSelectableRows` This prop is used for making mutiple rows to be selectable. When enabled, it ensures that mutiple rows can be selected at a time.
69
+
70
+ `onRowSelectionChange` This prop is used to handle row selections. It triggers a callback when rows are selected, passing the selected rows data so you can perform actions like displaying details or updating the state.
71
+
68
72
  <Canvas>
69
73
  <Story of={NewTableStories.SelectableRows} />
70
74
  </Canvas>
71
75
 
72
76
  ## Pre Selected Rows
73
77
 
78
+ The `initiallySelectedRowIds` prop is used to preselect the table rows. Its type is `Array of ids`, meaning it will accept an array of ids of the rows you want to pre select when table is rendered.
79
+
74
80
  <Canvas>
75
81
  <Story of={NewTableStories.PreSelectedRows} />
76
82
  </Canvas>
77
83
 
78
84
  ## Expandable Content
79
85
 
86
+ This example demonstrates how to enable expandable rows in the `NewTable` component using the `isExpandable` and `renderExpandedContent` props.
87
+
88
+ - **`isExpandable` (type: `boolean`)**: This prop enables rows in the table to be expandable. When set to `true`, rows can be expanded to display additional content.
89
+ - **`renderExpandedContent` (type: `(row: any) => React.ReactNode`)**: This prop defines the additional content to be displayed when a row is expanded. It accepts a function that returns a React node, allowing custom content for each row.
90
+
80
91
  <Canvas>
81
92
  <Story of={NewTableStories.ExpandableContent} />
82
93
  </Canvas>
@@ -101,24 +112,32 @@ To enable sorting functionality for your table columns, you can use the `enableS
101
112
 
102
113
  ## Horizontal Scroll
103
114
 
115
+ The `size` prop is passed in the column object to set the custom size for that column. Its type is `number`. When the columns width accumulatively increases more than the view width the table becomes horizontally scrollable.
116
+
104
117
  <Canvas>
105
118
  <Story of={NewTableStories.HorizontalScroll} />
106
119
  </Canvas>
107
120
 
108
121
  ## Resizable Columns
109
122
 
123
+ The `isResizable` prop is passed in the column object to make that column resizzable. Its type is `boolean`. when passed true, the corresponding column becomes resizzable.
124
+
110
125
  <Canvas>
111
126
  <Story of={NewTableStories.ResizableColumns} />
112
127
  </Canvas>
113
128
 
114
129
  ## Column Manager
115
130
 
131
+ To enable the column manager feature, you can use `columnManager` prop in the `useLeafyGreenTable` hook. The type of `columnManager` is `boolean`.
132
+
116
133
  <Canvas>
117
134
  <Story of={NewTableStories.ColumnManager} />
118
135
  </Canvas>
119
136
 
120
137
  ## With Header
121
138
 
139
+ To display the header above the table, you can pass the `header` prop in the NewTable component. The type of `header` is 'React.ReactNode'. This header can have filters like dropdown filter and global filters.
140
+
122
141
  <Canvas>
123
142
  <Story of={NewTableStories.WithHeader} />
124
143
  </Canvas>
@@ -131,12 +150,16 @@ To enable sorting functionality for your table columns, you can use the `enableS
131
150
 
132
151
  ## With Pagination
133
152
 
153
+ To enable the pagination in the table, you can pass the prop `withPagination: true`.
154
+
134
155
  <Canvas>
135
156
  <Story of={NewTableStories.WithPagination} />
136
157
  </Canvas>
137
158
 
138
159
  ## Sticky Columns
139
160
 
161
+ The columns of the table can either be left or right sticky. You can pass `sticky` prop in the column object. The value of will be either `left` or `right`.
162
+
140
163
  <Canvas>
141
164
  <Story of={NewTableStories.StickyColumns} />
142
165
  </Canvas>
@@ -266,6 +266,10 @@ const useLeafyGreenTable = <T extends LGRowData, V extends unknown = unknown>({
266
266
  setTimeout(() => {
267
267
  setLoadedData((prevData) => {
268
268
  const nextData = data.slice(prevData.length, prevData.length + loadMoreCount);
269
+ if (prevData.length + nextData.length >= data.length && observerRef.current) {
270
+ observerRef.current.disconnect();
271
+ }
272
+
269
273
  return [...prevData, ...nextData];
270
274
  });
271
275
  setIsLoading(false);