@bigbinary/neeto-atoms 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DataTable-Y4POx0WN.js +3737 -0
- package/dist/DataTable-Y4POx0WN.js.map +1 -0
- package/dist/button-COIbN8dg.js +40 -0
- package/dist/button-COIbN8dg.js.map +1 -0
- package/dist/check-Cpkv29p1.js +15 -0
- package/dist/check-Cpkv29p1.js.map +1 -0
- package/dist/chevron-down-BNi0ntys.js +15 -0
- package/dist/chevron-down-BNi0ntys.js.map +1 -0
- package/dist/chevron-left-BDoT8E2-.js +15 -0
- package/dist/chevron-left-BDoT8E2-.js.map +1 -0
- package/dist/chevron-right-DQnrO-ek.js +15 -0
- package/dist/chevron-right-DQnrO-ek.js.map +1 -0
- package/dist/chevron-up-Bf2G3AAU.js +15 -0
- package/dist/chevron-up-Bf2G3AAU.js.map +1 -0
- package/dist/cjs/DataTable-DJw2SZ7b.js +3764 -0
- package/dist/cjs/DataTable-DJw2SZ7b.js.map +1 -0
- package/dist/cjs/button-B8XGl69v.js +63 -0
- package/dist/cjs/button-B8XGl69v.js.map +1 -0
- package/dist/cjs/check-BQgcDXys.js +17 -0
- package/dist/cjs/check-BQgcDXys.js.map +1 -0
- package/dist/cjs/chevron-down-CPsWSS51.js +17 -0
- package/dist/cjs/chevron-down-CPsWSS51.js.map +1 -0
- package/dist/cjs/chevron-left-BldoOh5p.js +17 -0
- package/dist/cjs/chevron-left-BldoOh5p.js.map +1 -0
- package/dist/cjs/chevron-right-0jNdwX2Q.js +17 -0
- package/dist/cjs/chevron-right-0jNdwX2Q.js.map +1 -0
- package/dist/cjs/chevron-up-BpwpBnZU.js +17 -0
- package/dist/cjs/chevron-up-BpwpBnZU.js.map +1 -0
- package/dist/cjs/components/DataTable.js +53 -0
- package/dist/cjs/components/DataTable.js.map +1 -0
- package/dist/cjs/createLucideIcon-D0tRgV6l.js +149 -0
- package/dist/cjs/createLucideIcon-D0tRgV6l.js.map +1 -0
- package/dist/cjs/dialog-DzNWLbJ6.js +50 -0
- package/dist/cjs/dialog-DzNWLbJ6.js.map +1 -0
- package/dist/cjs/ellipsis-4aubOI2n.js +21 -0
- package/dist/cjs/ellipsis-4aubOI2n.js.map +1 -0
- package/dist/cjs/floating-ui.react-dom-B4Aw6O7R.js +2293 -0
- package/dist/cjs/floating-ui.react-dom-B4Aw6O7R.js.map +1 -0
- package/dist/cjs/index-9jC1advf.js +34 -0
- package/dist/cjs/index-9jC1advf.js.map +1 -0
- package/dist/cjs/index-BZhTddX0.js +47 -0
- package/dist/cjs/index-BZhTddX0.js.map +1 -0
- package/dist/cjs/index-Bf0WsHta.js +63 -0
- package/dist/cjs/index-Bf0WsHta.js.map +1 -0
- package/dist/cjs/index-BqCr1H3u.js +173 -0
- package/dist/cjs/index-BqCr1H3u.js.map +1 -0
- package/dist/cjs/index-BrpkRQoS.js +99 -0
- package/dist/cjs/index-BrpkRQoS.js.map +1 -0
- package/dist/cjs/index-Bvu9MiFi.js +247 -0
- package/dist/cjs/index-Bvu9MiFi.js.map +1 -0
- package/dist/cjs/index-BwAq9ba8.js +38 -0
- package/dist/cjs/index-BwAq9ba8.js.map +1 -0
- package/dist/cjs/index-C9ICrOhM.js +328 -0
- package/dist/cjs/index-C9ICrOhM.js.map +1 -0
- package/dist/cjs/index-CB9xFokC.js +59 -0
- package/dist/cjs/index-CB9xFokC.js.map +1 -0
- package/dist/cjs/index-CCdG4z4E.js +30 -0
- package/dist/cjs/index-CCdG4z4E.js.map +1 -0
- package/dist/cjs/index-CF951Pw9.js +38 -0
- package/dist/cjs/index-CF951Pw9.js.map +1 -0
- package/dist/cjs/index-CGUGhyIp.js +103 -0
- package/dist/cjs/index-CGUGhyIp.js.map +1 -0
- package/dist/cjs/index-CGet1HH4.js +953 -0
- package/dist/cjs/index-CGet1HH4.js.map +1 -0
- package/dist/cjs/index-COPkC3I5.js +14 -0
- package/dist/cjs/index-COPkC3I5.js.map +1 -0
- package/dist/cjs/index-Ch55j1or.js +176 -0
- package/dist/cjs/index-Ch55j1or.js.map +1 -0
- package/dist/cjs/index-ChSOMM8b.js +1153 -0
- package/dist/cjs/index-ChSOMM8b.js.map +1 -0
- package/dist/cjs/index-CyrAgb4H.js +93 -0
- package/dist/cjs/index-CyrAgb4H.js.map +1 -0
- package/dist/cjs/index-D-iDn9RI.js +63 -0
- package/dist/cjs/index-D-iDn9RI.js.map +1 -0
- package/dist/cjs/index-DAds6mf_.js +433 -0
- package/dist/cjs/index-DAds6mf_.js.map +1 -0
- package/dist/cjs/index-DMbj7vXd.js +152 -0
- package/dist/cjs/index-DMbj7vXd.js.map +1 -0
- package/dist/cjs/index-DR7GJU4J.js +248 -0
- package/dist/cjs/index-DR7GJU4J.js.map +1 -0
- package/dist/cjs/index-DcCSSgb7.js +153 -0
- package/dist/cjs/index-DcCSSgb7.js.map +1 -0
- package/dist/cjs/index-Df-Ffa3s.js +43 -0
- package/dist/cjs/index-Df-Ffa3s.js.map +1 -0
- package/dist/cjs/index-DnKJmaCq.js +8 -0
- package/dist/cjs/index-DnKJmaCq.js.map +1 -0
- package/dist/cjs/index-DuNgWCXZ.js +113 -0
- package/dist/cjs/index-DuNgWCXZ.js.map +1 -0
- package/dist/cjs/index-EyWRfsCG.js +9 -0
- package/dist/cjs/index-EyWRfsCG.js.map +1 -0
- package/dist/cjs/index-lWVw05cs.js +35 -0
- package/dist/cjs/index-lWVw05cs.js.map +1 -0
- package/dist/cjs/index.js +53 -66844
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/input-CgKPISj_.js +11 -0
- package/dist/cjs/input-CgKPISj_.js.map +1 -0
- package/dist/cjs/input-group-DoK0-4fL.js +66 -0
- package/dist/cjs/input-group-DoK0-4fL.js.map +1 -0
- package/dist/cjs/label-Bdc9ytTI.js +52 -0
- package/dist/cjs/label-Bdc9ytTI.js.map +1 -0
- package/dist/cjs/loader-circle-Bw7zP2Gn.js +17 -0
- package/dist/cjs/loader-circle-Bw7zP2Gn.js.map +1 -0
- package/dist/cjs/primitives/Accordion.js +340 -0
- package/dist/cjs/primitives/Accordion.js.map +1 -0
- package/dist/cjs/primitives/Alert.js +40 -0
- package/dist/cjs/primitives/Alert.js.map +1 -0
- package/dist/cjs/primitives/AlertDialog.js +256 -0
- package/dist/cjs/primitives/AlertDialog.js.map +1 -0
- package/dist/cjs/primitives/AspectRatio.js +75 -0
- package/dist/cjs/primitives/AspectRatio.js.map +1 -0
- package/dist/cjs/primitives/Avatar.js +189 -0
- package/dist/cjs/primitives/Avatar.js.map +1 -0
- package/dist/cjs/primitives/Badge.js +34 -0
- package/dist/cjs/primitives/Badge.js.map +1 -0
- package/dist/cjs/primitives/Breadcrumb.js +50 -0
- package/dist/cjs/primitives/Breadcrumb.js.map +1 -0
- package/dist/cjs/primitives/Button.js +16 -0
- package/dist/cjs/primitives/Button.js.map +1 -0
- package/dist/cjs/primitives/ButtonGroup.js +43 -0
- package/dist/cjs/primitives/ButtonGroup.js.map +1 -0
- package/dist/cjs/primitives/Calendar.js +8030 -0
- package/dist/cjs/primitives/Calendar.js.map +1 -0
- package/dist/cjs/primitives/Card.js +43 -0
- package/dist/cjs/primitives/Card.js.map +1 -0
- package/dist/cjs/primitives/Carousel.js +1867 -0
- package/dist/cjs/primitives/Carousel.js.map +1 -0
- package/dist/cjs/primitives/Chart.js +18787 -0
- package/dist/cjs/primitives/Chart.js.map +1 -0
- package/dist/cjs/primitives/Checkbox.js +304 -0
- package/dist/cjs/primitives/Checkbox.js.map +1 -0
- package/dist/cjs/primitives/Collapsible.js +33 -0
- package/dist/cjs/primitives/Collapsible.js.map +1 -0
- package/dist/cjs/primitives/Combobox.js +10288 -0
- package/dist/cjs/primitives/Combobox.js.map +1 -0
- package/dist/cjs/primitives/Command.js +248 -0
- package/dist/cjs/primitives/Command.js.map +1 -0
- package/dist/cjs/primitives/ContextMenu.js +404 -0
- package/dist/cjs/primitives/ContextMenu.js.map +1 -0
- package/dist/cjs/primitives/Dialog.js +48 -0
- package/dist/cjs/primitives/Dialog.js.map +1 -0
- package/dist/cjs/primitives/Drawer.js +1715 -0
- package/dist/cjs/primitives/Drawer.js.map +1 -0
- package/dist/cjs/primitives/DropdownMenu.js +383 -0
- package/dist/cjs/primitives/DropdownMenu.js.map +1 -0
- package/dist/cjs/primitives/Empty.js +50 -0
- package/dist/cjs/primitives/Empty.js.map +1 -0
- package/dist/cjs/primitives/Field.js +95 -0
- package/dist/cjs/primitives/Field.js.map +1 -0
- package/dist/cjs/primitives/HoverCard.js +291 -0
- package/dist/cjs/primitives/HoverCard.js.map +1 -0
- package/dist/cjs/primitives/Input.js +10 -0
- package/dist/cjs/primitives/Input.js.map +1 -0
- package/dist/cjs/primitives/InputGroup.js +27 -0
- package/dist/cjs/primitives/InputGroup.js.map +1 -0
- package/dist/cjs/primitives/InputOTP.js +84 -0
- package/dist/cjs/primitives/InputOTP.js.map +1 -0
- package/dist/cjs/primitives/Item.js +96 -0
- package/dist/cjs/primitives/Item.js.map +1 -0
- package/dist/cjs/primitives/Kbd.js +18 -0
- package/dist/cjs/primitives/Kbd.js.map +1 -0
- package/dist/cjs/primitives/Label.js +14 -0
- package/dist/cjs/primitives/Label.js.map +1 -0
- package/dist/cjs/primitives/Menubar.js +547 -0
- package/dist/cjs/primitives/Menubar.js.map +1 -0
- package/dist/cjs/primitives/NativeSelect.js +26 -0
- package/dist/cjs/primitives/NativeSelect.js.map +1 -0
- package/dist/cjs/primitives/NavigationMenu.js +856 -0
- package/dist/cjs/primitives/NavigationMenu.js.map +1 -0
- package/dist/cjs/primitives/Pagination.js +52 -0
- package/dist/cjs/primitives/Pagination.js.map +1 -0
- package/dist/cjs/primitives/Popover.js +444 -0
- package/dist/cjs/primitives/Popover.js.map +1 -0
- package/dist/cjs/primitives/Progress.js +125 -0
- package/dist/cjs/primitives/Progress.js.map +1 -0
- package/dist/cjs/primitives/RadioGroup.js +322 -0
- package/dist/cjs/primitives/RadioGroup.js.map +1 -0
- package/dist/cjs/primitives/Resizable.js +2051 -0
- package/dist/cjs/primitives/Resizable.js.map +1 -0
- package/dist/cjs/primitives/ScrollArea.js +754 -0
- package/dist/cjs/primitives/ScrollArea.js.map +1 -0
- package/dist/cjs/primitives/Select.js +1318 -0
- package/dist/cjs/primitives/Select.js.map +1 -0
- package/dist/cjs/primitives/Separator.js +14 -0
- package/dist/cjs/primitives/Separator.js.map +1 -0
- package/dist/cjs/primitives/Sheet.js +44 -0
- package/dist/cjs/primitives/Sheet.js.map +1 -0
- package/dist/cjs/primitives/Sidebar.js +310 -0
- package/dist/cjs/primitives/Sidebar.js.map +1 -0
- package/dist/cjs/primitives/Skeleton.js +10 -0
- package/dist/cjs/primitives/Skeleton.js.map +1 -0
- package/dist/cjs/primitives/Slider.js +591 -0
- package/dist/cjs/primitives/Slider.js.map +1 -0
- package/dist/cjs/primitives/Sonner.js +1260 -0
- package/dist/cjs/primitives/Sonner.js.map +1 -0
- package/dist/cjs/primitives/Spinner.js +16 -0
- package/dist/cjs/primitives/Spinner.js.map +1 -0
- package/dist/cjs/primitives/Switch.js +184 -0
- package/dist/cjs/primitives/Switch.js.map +1 -0
- package/dist/cjs/primitives/Table.js +45 -0
- package/dist/cjs/primitives/Table.js.map +1 -0
- package/dist/cjs/primitives/Tabs.js +250 -0
- package/dist/cjs/primitives/Tabs.js.map +1 -0
- package/dist/cjs/primitives/Textarea.js +10 -0
- package/dist/cjs/primitives/Textarea.js.map +1 -0
- package/dist/cjs/primitives/Toggle.js +19 -0
- package/dist/cjs/primitives/Toggle.js.map +1 -0
- package/dist/cjs/primitives/ToggleGroup.js +221 -0
- package/dist/cjs/primitives/ToggleGroup.js.map +1 -0
- package/dist/cjs/primitives/Tooltip.js +33 -0
- package/dist/cjs/primitives/Tooltip.js.map +1 -0
- package/dist/cjs/primitives/Typography.js +105 -0
- package/dist/cjs/primitives/Typography.js.map +1 -0
- package/dist/cjs/primitives/index.js +422 -0
- package/dist/cjs/primitives/index.js.map +1 -0
- package/dist/cjs/reselect-CeyIIDM-.js +457 -0
- package/dist/cjs/reselect-CeyIIDM-.js.map +1 -0
- package/dist/cjs/separator-CPy2gyg1.js +58 -0
- package/dist/cjs/separator-CPy2gyg1.js.map +1 -0
- package/dist/cjs/sheet-nHSYZxAA.js +48 -0
- package/dist/cjs/sheet-nHSYZxAA.js.map +1 -0
- package/dist/cjs/skeleton-DffZ8bV7.js +11 -0
- package/dist/cjs/skeleton-DffZ8bV7.js.map +1 -0
- package/dist/cjs/textarea-CZSSY75H.js +11 -0
- package/dist/cjs/textarea-CZSSY75H.js.map +1 -0
- package/dist/cjs/toggle-CaqzT8dI.js +84 -0
- package/dist/cjs/toggle-CaqzT8dI.js.map +1 -0
- package/dist/cjs/tooltip-CRkOMh1b.js +542 -0
- package/dist/cjs/tooltip-CRkOMh1b.js.map +1 -0
- package/dist/cjs/use-mobile-B-UYxtqX.js +41 -0
- package/dist/cjs/use-mobile-B-UYxtqX.js.map +1 -0
- package/dist/cjs/utils-CTr7wn5d.js +3210 -0
- package/dist/cjs/utils-CTr7wn5d.js.map +1 -0
- package/dist/cjs/x-Brw3FJst.js +20 -0
- package/dist/cjs/x-Brw3FJst.js.map +1 -0
- package/dist/components/DataTable.js +41 -0
- package/dist/components/DataTable.js.map +1 -0
- package/dist/createLucideIcon-C8ycilSN.js +147 -0
- package/dist/createLucideIcon-C8ycilSN.js.map +1 -0
- package/dist/dialog-C97DOTvO.js +39 -0
- package/dist/dialog-C97DOTvO.js.map +1 -0
- package/dist/ellipsis-lb8Ws6br.js +19 -0
- package/dist/ellipsis-lb8Ws6br.js.map +1 -0
- package/dist/floating-ui.react-dom-CcGbtPEK.js +2243 -0
- package/dist/floating-ui.react-dom-CcGbtPEK.js.map +1 -0
- package/dist/index-0o2E3Cnw.js +146 -0
- package/dist/index-0o2E3Cnw.js.map +1 -0
- package/dist/index-30QpKM0j.js +16 -0
- package/dist/index-30QpKM0j.js.map +1 -0
- package/dist/index-B4_fVWDx.js +1129 -0
- package/dist/index-B4_fVWDx.js.map +1 -0
- package/dist/index-BA158WEj.js +12 -0
- package/dist/index-BA158WEj.js.map +1 -0
- package/dist/index-BNPynZWM.js +225 -0
- package/dist/index-BNPynZWM.js.map +1 -0
- package/dist/index-BYZaLNq1.js +41 -0
- package/dist/index-BYZaLNq1.js.map +1 -0
- package/dist/index-BfAAoDv6.js +7 -0
- package/dist/index-BfAAoDv6.js.map +1 -0
- package/dist/index-BtkPdosV.js +40 -0
- package/dist/index-BtkPdosV.js.map +1 -0
- package/dist/index-BwxI_qgh.js +915 -0
- package/dist/index-BwxI_qgh.js.map +1 -0
- package/dist/index-ByEpUy7w.js +302 -0
- package/dist/index-ByEpUy7w.js.map +1 -0
- package/dist/index-CSMSzzKM.js +93 -0
- package/dist/index-CSMSzzKM.js.map +1 -0
- package/dist/index-CSUSJzOJ.js +13 -0
- package/dist/index-CSUSJzOJ.js.map +1 -0
- package/dist/index-CSggBaQF.js +36 -0
- package/dist/index-CSggBaQF.js.map +1 -0
- package/dist/index-CfriMyrd.js +91 -0
- package/dist/index-CfriMyrd.js.map +1 -0
- package/dist/index-CiyxEyB0.js +80 -0
- package/dist/index-CiyxEyB0.js.map +1 -0
- package/dist/index-Cor698lu.js +71 -0
- package/dist/index-Cor698lu.js.map +1 -0
- package/dist/index-D7Zy7P05.js +45 -0
- package/dist/index-D7Zy7P05.js.map +1 -0
- package/dist/index-DNzunGHb.js +12 -0
- package/dist/index-DNzunGHb.js.map +1 -0
- package/dist/index-DOzu5J1s.js +8 -0
- package/dist/index-DOzu5J1s.js.map +1 -0
- package/dist/index-DZXbzIgC.js +6 -0
- package/dist/index-DZXbzIgC.js.map +1 -0
- package/dist/index-Dd1i1d2M.js +155 -0
- package/dist/index-Dd1i1d2M.js.map +1 -0
- package/dist/index-DhnfW8wQ.js +128 -0
- package/dist/index-DhnfW8wQ.js.map +1 -0
- package/dist/index-PF0ms7Xn.js +402 -0
- package/dist/index-PF0ms7Xn.js.map +1 -0
- package/dist/index-fV_U4ZJM.js +18 -0
- package/dist/index-fV_U4ZJM.js.map +1 -0
- package/dist/index-j_qxDBFl.js +224 -0
- package/dist/index-j_qxDBFl.js.map +1 -0
- package/dist/index-yFgkK_AM.js +131 -0
- package/dist/index-yFgkK_AM.js.map +1 -0
- package/dist/index-zW4GjM5L.js +16 -0
- package/dist/index-zW4GjM5L.js.map +1 -0
- package/dist/index.d.ts +0 -55
- package/dist/index.js +41 -66510
- package/dist/index.js.map +1 -1
- package/dist/input-GLCCE2kT.js +9 -0
- package/dist/input-GLCCE2kT.js.map +1 -0
- package/dist/input-group-CDBpz6Pb.js +59 -0
- package/dist/input-group-CDBpz6Pb.js.map +1 -0
- package/dist/label-B4qDF3W1.js +30 -0
- package/dist/label-B4qDF3W1.js.map +1 -0
- package/dist/loader-circle-DycHUAWN.js +15 -0
- package/dist/loader-circle-DycHUAWN.js.map +1 -0
- package/dist/primitives/Accordion.js +331 -0
- package/dist/primitives/Accordion.js.map +1 -0
- package/dist/primitives/Alert.js +35 -0
- package/dist/primitives/Alert.js.map +1 -0
- package/dist/primitives/AlertDialog.js +223 -0
- package/dist/primitives/AlertDialog.js.map +1 -0
- package/dist/primitives/AspectRatio.js +53 -0
- package/dist/primitives/AspectRatio.js.map +1 -0
- package/dist/primitives/Avatar.js +162 -0
- package/dist/primitives/Avatar.js.map +1 -0
- package/dist/primitives/Badge.js +31 -0
- package/dist/primitives/Badge.js.map +1 -0
- package/dist/primitives/Breadcrumb.js +42 -0
- package/dist/primitives/Breadcrumb.js.map +1 -0
- package/dist/{components → primitives}/Button.d.ts +1 -1
- package/dist/primitives/Button.js +14 -0
- package/dist/primitives/Button.js.map +1 -0
- package/dist/primitives/ButtonGroup.js +38 -0
- package/dist/primitives/ButtonGroup.js.map +1 -0
- package/dist/primitives/Calendar.js +8008 -0
- package/dist/primitives/Calendar.js.map +1 -0
- package/dist/primitives/Card.js +35 -0
- package/dist/primitives/Card.js.map +1 -0
- package/dist/{components → primitives}/Carousel.d.ts +1 -1
- package/dist/primitives/Carousel.js +1841 -0
- package/dist/primitives/Carousel.js.map +1 -0
- package/dist/primitives/Chart.js +18761 -0
- package/dist/primitives/Chart.js.map +1 -0
- package/dist/primitives/Checkbox.js +282 -0
- package/dist/primitives/Checkbox.js.map +1 -0
- package/dist/primitives/Collapsible.js +29 -0
- package/dist/primitives/Collapsible.js.map +1 -0
- package/dist/primitives/Combobox.js +10251 -0
- package/dist/primitives/Combobox.js.map +1 -0
- package/dist/primitives/Command.js +218 -0
- package/dist/primitives/Command.js.map +1 -0
- package/dist/primitives/ContextMenu.js +368 -0
- package/dist/primitives/ContextMenu.js.map +1 -0
- package/dist/primitives/Dialog.js +37 -0
- package/dist/primitives/Dialog.js.map +1 -0
- package/dist/primitives/Drawer.js +1685 -0
- package/dist/primitives/Drawer.js.map +1 -0
- package/dist/primitives/DropdownMenu.js +347 -0
- package/dist/primitives/DropdownMenu.js.map +1 -0
- package/dist/primitives/Empty.js +43 -0
- package/dist/primitives/Empty.js.map +1 -0
- package/dist/primitives/Field.js +84 -0
- package/dist/primitives/Field.js.map +1 -0
- package/dist/primitives/HoverCard.js +267 -0
- package/dist/primitives/HoverCard.js.map +1 -0
- package/dist/primitives/Input.js +8 -0
- package/dist/primitives/Input.js.map +1 -0
- package/dist/primitives/InputGroup.js +20 -0
- package/dist/primitives/InputGroup.js.map +1 -0
- package/dist/primitives/InputOTP.js +59 -0
- package/dist/primitives/InputOTP.js.map +1 -0
- package/dist/primitives/Item.js +85 -0
- package/dist/primitives/Item.js.map +1 -0
- package/dist/primitives/Kbd.js +15 -0
- package/dist/primitives/Kbd.js.map +1 -0
- package/dist/primitives/Label.js +12 -0
- package/dist/primitives/Label.js.map +1 -0
- package/dist/primitives/Menubar.js +510 -0
- package/dist/primitives/Menubar.js.map +1 -0
- package/dist/primitives/NativeSelect.js +22 -0
- package/dist/primitives/NativeSelect.js.map +1 -0
- package/dist/primitives/NavigationMenu.js +823 -0
- package/dist/primitives/NavigationMenu.js.map +1 -0
- package/dist/primitives/Pagination.js +44 -0
- package/dist/primitives/Pagination.js.map +1 -0
- package/dist/primitives/Popover.js +416 -0
- package/dist/primitives/Popover.js.map +1 -0
- package/dist/primitives/Progress.js +103 -0
- package/dist/primitives/Progress.js.map +1 -0
- package/dist/primitives/RadioGroup.js +299 -0
- package/dist/primitives/RadioGroup.js.map +1 -0
- package/dist/primitives/Resizable.js +2047 -0
- package/dist/primitives/Resizable.js.map +1 -0
- package/dist/primitives/ScrollArea.js +731 -0
- package/dist/primitives/ScrollArea.js.map +1 -0
- package/dist/primitives/Select.js +1286 -0
- package/dist/primitives/Select.js.map +1 -0
- package/dist/primitives/Separator.js +12 -0
- package/dist/primitives/Separator.js.map +1 -0
- package/dist/primitives/Sheet.js +35 -0
- package/dist/primitives/Sheet.js.map +1 -0
- package/dist/primitives/Sidebar.js +265 -0
- package/dist/primitives/Sidebar.js.map +1 -0
- package/dist/primitives/Skeleton.js +8 -0
- package/dist/primitives/Skeleton.js.map +1 -0
- package/dist/primitives/Slider.js +569 -0
- package/dist/primitives/Slider.js.map +1 -0
- package/dist/primitives/Sonner.js +1236 -0
- package/dist/primitives/Sonner.js.map +1 -0
- package/dist/primitives/Spinner.js +14 -0
- package/dist/primitives/Spinner.js.map +1 -0
- package/dist/primitives/Switch.js +162 -0
- package/dist/primitives/Switch.js.map +1 -0
- package/dist/primitives/Table.js +36 -0
- package/dist/primitives/Table.js.map +1 -0
- package/dist/primitives/Tabs.js +224 -0
- package/dist/primitives/Tabs.js.map +1 -0
- package/dist/primitives/Textarea.js +8 -0
- package/dist/primitives/Textarea.js.map +1 -0
- package/dist/primitives/Toggle.js +17 -0
- package/dist/primitives/Toggle.js.map +1 -0
- package/dist/primitives/ToggleGroup.js +199 -0
- package/dist/primitives/ToggleGroup.js.map +1 -0
- package/dist/primitives/Tooltip.js +28 -0
- package/dist/primitives/Tooltip.js.map +1 -0
- package/dist/{components → primitives}/Typography.d.ts +1 -1
- package/dist/primitives/Typography.js +83 -0
- package/dist/primitives/Typography.js.map +1 -0
- package/dist/primitives/index.d.ts +55 -0
- package/dist/primitives/index.js +110 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/reselect-CABQm5hA.js +448 -0
- package/dist/reselect-CABQm5hA.js.map +1 -0
- package/dist/separator-BbhgePmX.js +36 -0
- package/dist/separator-BbhgePmX.js.map +1 -0
- package/dist/shadcn/components/badge.d.ts +1 -1
- package/dist/shadcn/components/button.d.ts +2 -2
- package/dist/shadcn/components/typography.d.ts +2 -2
- package/dist/sheet-D1ngftfX.js +39 -0
- package/dist/sheet-D1ngftfX.js.map +1 -0
- package/dist/skeleton-AR83txPr.js +9 -0
- package/dist/skeleton-AR83txPr.js.map +1 -0
- package/dist/textarea-BSZwxzjQ.js +9 -0
- package/dist/textarea-BSZwxzjQ.js.map +1 -0
- package/dist/toggle-2k9K8a5c.js +60 -0
- package/dist/toggle-2k9K8a5c.js.map +1 -0
- package/dist/tooltip-D5soNrAP.js +517 -0
- package/dist/tooltip-D5soNrAP.js.map +1 -0
- package/dist/use-mobile-IRjN_mlT.js +19 -0
- package/dist/use-mobile-IRjN_mlT.js.map +1 -0
- package/dist/utils-DdHUxIdC.js +3207 -0
- package/dist/utils-DdHUxIdC.js.map +1 -0
- package/dist/x-_o2T3n6D.js +18 -0
- package/dist/x-_o2T3n6D.js.map +1 -0
- package/package.json +16 -1
- /package/dist/{components → primitives}/Accordion.d.ts +0 -0
- /package/dist/{components → primitives}/Alert.d.ts +0 -0
- /package/dist/{components → primitives}/AlertDialog.d.ts +0 -0
- /package/dist/{components → primitives}/AspectRatio.d.ts +0 -0
- /package/dist/{components → primitives}/Avatar.d.ts +0 -0
- /package/dist/{components → primitives}/Badge.d.ts +0 -0
- /package/dist/{components → primitives}/Breadcrumb.d.ts +0 -0
- /package/dist/{components → primitives}/ButtonGroup.d.ts +0 -0
- /package/dist/{components → primitives}/Calendar.d.ts +0 -0
- /package/dist/{components → primitives}/Card.d.ts +0 -0
- /package/dist/{components → primitives}/Chart.d.ts +0 -0
- /package/dist/{components → primitives}/Checkbox.d.ts +0 -0
- /package/dist/{components → primitives}/Collapsible.d.ts +0 -0
- /package/dist/{components → primitives}/Combobox.d.ts +0 -0
- /package/dist/{components → primitives}/Command.d.ts +0 -0
- /package/dist/{components → primitives}/ContextMenu.d.ts +0 -0
- /package/dist/{components → primitives}/Dialog.d.ts +0 -0
- /package/dist/{components → primitives}/Drawer.d.ts +0 -0
- /package/dist/{components → primitives}/DropdownMenu.d.ts +0 -0
- /package/dist/{components → primitives}/Empty.d.ts +0 -0
- /package/dist/{components → primitives}/Field.d.ts +0 -0
- /package/dist/{components → primitives}/HoverCard.d.ts +0 -0
- /package/dist/{components → primitives}/Input.d.ts +0 -0
- /package/dist/{components → primitives}/InputGroup.d.ts +0 -0
- /package/dist/{components → primitives}/InputOTP.d.ts +0 -0
- /package/dist/{components → primitives}/Item.d.ts +0 -0
- /package/dist/{components → primitives}/Kbd.d.ts +0 -0
- /package/dist/{components → primitives}/Label.d.ts +0 -0
- /package/dist/{components → primitives}/Menubar.d.ts +0 -0
- /package/dist/{components → primitives}/NativeSelect.d.ts +0 -0
- /package/dist/{components → primitives}/NavigationMenu.d.ts +0 -0
- /package/dist/{components → primitives}/Pagination.d.ts +0 -0
- /package/dist/{components → primitives}/Popover.d.ts +0 -0
- /package/dist/{components → primitives}/Progress.d.ts +0 -0
- /package/dist/{components → primitives}/RadioGroup.d.ts +0 -0
- /package/dist/{components → primitives}/Resizable.d.ts +0 -0
- /package/dist/{components → primitives}/ScrollArea.d.ts +0 -0
- /package/dist/{components → primitives}/Select.d.ts +0 -0
- /package/dist/{components → primitives}/Separator.d.ts +0 -0
- /package/dist/{components → primitives}/Sheet.d.ts +0 -0
- /package/dist/{components → primitives}/Sidebar.d.ts +0 -0
- /package/dist/{components → primitives}/Skeleton.d.ts +0 -0
- /package/dist/{components → primitives}/Slider.d.ts +0 -0
- /package/dist/{components → primitives}/Sonner.d.ts +0 -0
- /package/dist/{components → primitives}/Spinner.d.ts +0 -0
- /package/dist/{components → primitives}/Switch.d.ts +0 -0
- /package/dist/{components → primitives}/Table.d.ts +0 -0
- /package/dist/{components → primitives}/Tabs.d.ts +0 -0
- /package/dist/{components → primitives}/Textarea.d.ts +0 -0
- /package/dist/{components → primitives}/Toggle.d.ts +0 -0
- /package/dist/{components → primitives}/ToggleGroup.d.ts +0 -0
- /package/dist/{components → primitives}/Tooltip.d.ts +0 -0
|
@@ -0,0 +1,3764 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var primitives_Table = require('./primitives/Table.js');
|
|
6
|
+
var utils = require('./utils-CTr7wn5d.js');
|
|
7
|
+
var primitives_Checkbox = require('./primitives/Checkbox.js');
|
|
8
|
+
var primitives_Spinner = require('./primitives/Spinner.js');
|
|
9
|
+
var createLucideIcon = require('./createLucideIcon-D0tRgV6l.js');
|
|
10
|
+
var primitives_Button = require('./primitives/Button.js');
|
|
11
|
+
var primitives_Pagination = require('./primitives/Pagination.js');
|
|
12
|
+
var primitives_DropdownMenu = require('./primitives/DropdownMenu.js');
|
|
13
|
+
var ellipsis = require('./ellipsis-4aubOI2n.js');
|
|
14
|
+
var check = require('./check-BQgcDXys.js');
|
|
15
|
+
|
|
16
|
+
function _interopNamespace(e) {
|
|
17
|
+
if (e && e.__esModule) return e;
|
|
18
|
+
var n = Object.create(null);
|
|
19
|
+
if (e) {
|
|
20
|
+
Object.keys(e).forEach(function (k) {
|
|
21
|
+
if (k !== 'default') {
|
|
22
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
23
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return e[k]; }
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
n.default = e;
|
|
31
|
+
return Object.freeze(n);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* table-core
|
|
38
|
+
*
|
|
39
|
+
* Copyright (c) TanStack
|
|
40
|
+
*
|
|
41
|
+
* This source code is licensed under the MIT license found in the
|
|
42
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
43
|
+
*
|
|
44
|
+
* @license MIT
|
|
45
|
+
*/
|
|
46
|
+
// type Person = {
|
|
47
|
+
// firstName: string
|
|
48
|
+
// lastName: string
|
|
49
|
+
// age: number
|
|
50
|
+
// visits: number
|
|
51
|
+
// status: string
|
|
52
|
+
// progress: number
|
|
53
|
+
// createdAt: Date
|
|
54
|
+
// nested: {
|
|
55
|
+
// foo: [
|
|
56
|
+
// {
|
|
57
|
+
// bar: 'bar'
|
|
58
|
+
// }
|
|
59
|
+
// ]
|
|
60
|
+
// bar: { subBar: boolean }[]
|
|
61
|
+
// baz: {
|
|
62
|
+
// foo: 'foo'
|
|
63
|
+
// bar: {
|
|
64
|
+
// baz: 'baz'
|
|
65
|
+
// }
|
|
66
|
+
// }
|
|
67
|
+
// }
|
|
68
|
+
// }
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
// Is this type a tuple?
|
|
72
|
+
|
|
73
|
+
// If this type is a tuple, what indices are allowed?
|
|
74
|
+
|
|
75
|
+
///
|
|
76
|
+
|
|
77
|
+
function functionalUpdate(updater, input) {
|
|
78
|
+
return typeof updater === 'function' ? updater(input) : updater;
|
|
79
|
+
}
|
|
80
|
+
function makeStateUpdater(key, instance) {
|
|
81
|
+
return updater => {
|
|
82
|
+
instance.setState(old => {
|
|
83
|
+
return {
|
|
84
|
+
...old,
|
|
85
|
+
[key]: functionalUpdate(updater, old[key])
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function isFunction(d) {
|
|
91
|
+
return d instanceof Function;
|
|
92
|
+
}
|
|
93
|
+
function isNumberArray(d) {
|
|
94
|
+
return Array.isArray(d) && d.every(val => typeof val === 'number');
|
|
95
|
+
}
|
|
96
|
+
function flattenBy(arr, getChildren) {
|
|
97
|
+
const flat = [];
|
|
98
|
+
const recurse = subArr => {
|
|
99
|
+
subArr.forEach(item => {
|
|
100
|
+
flat.push(item);
|
|
101
|
+
const children = getChildren(item);
|
|
102
|
+
if (children != null && children.length) {
|
|
103
|
+
recurse(children);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
recurse(arr);
|
|
108
|
+
return flat;
|
|
109
|
+
}
|
|
110
|
+
function memo(getDeps, fn, opts) {
|
|
111
|
+
let deps = [];
|
|
112
|
+
let result;
|
|
113
|
+
return depArgs => {
|
|
114
|
+
let depTime;
|
|
115
|
+
if (opts.key && opts.debug) depTime = Date.now();
|
|
116
|
+
const newDeps = getDeps(depArgs);
|
|
117
|
+
const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep);
|
|
118
|
+
if (!depsChanged) {
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
deps = newDeps;
|
|
122
|
+
let resultTime;
|
|
123
|
+
if (opts.key && opts.debug) resultTime = Date.now();
|
|
124
|
+
result = fn(...newDeps);
|
|
125
|
+
opts == null || opts.onChange == null || opts.onChange(result);
|
|
126
|
+
if (opts.key && opts.debug) {
|
|
127
|
+
if (opts != null && opts.debug()) {
|
|
128
|
+
const depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
|
|
129
|
+
const resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
|
|
130
|
+
const resultFpsPercentage = resultEndTime / 16;
|
|
131
|
+
const pad = (str, num) => {
|
|
132
|
+
str = String(str);
|
|
133
|
+
while (str.length < num) {
|
|
134
|
+
str = ' ' + str;
|
|
135
|
+
}
|
|
136
|
+
return str;
|
|
137
|
+
};
|
|
138
|
+
console.info(`%c⏱ ${pad(resultEndTime, 5)} /${pad(depEndTime, 5)} ms`, `
|
|
139
|
+
font-size: .6rem;
|
|
140
|
+
font-weight: bold;
|
|
141
|
+
color: hsl(${Math.max(0, Math.min(120 - 120 * resultFpsPercentage, 120))}deg 100% 31%);`, opts == null ? void 0 : opts.key);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return result;
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function getMemoOptions(tableOptions, debugLevel, key, onChange) {
|
|
148
|
+
return {
|
|
149
|
+
debug: () => {
|
|
150
|
+
var _tableOptions$debugAl;
|
|
151
|
+
return (_tableOptions$debugAl = tableOptions == null ? void 0 : tableOptions.debugAll) != null ? _tableOptions$debugAl : tableOptions[debugLevel];
|
|
152
|
+
},
|
|
153
|
+
key: "production" === 'development',
|
|
154
|
+
onChange
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function createCell(table, row, column, columnId) {
|
|
159
|
+
const getRenderValue = () => {
|
|
160
|
+
var _cell$getValue;
|
|
161
|
+
return (_cell$getValue = cell.getValue()) != null ? _cell$getValue : table.options.renderFallbackValue;
|
|
162
|
+
};
|
|
163
|
+
const cell = {
|
|
164
|
+
id: `${row.id}_${column.id}`,
|
|
165
|
+
row,
|
|
166
|
+
column,
|
|
167
|
+
getValue: () => row.getValue(columnId),
|
|
168
|
+
renderValue: getRenderValue,
|
|
169
|
+
getContext: memo(() => [table, column, row, cell], (table, column, row, cell) => ({
|
|
170
|
+
table,
|
|
171
|
+
column,
|
|
172
|
+
row,
|
|
173
|
+
cell: cell,
|
|
174
|
+
getValue: cell.getValue,
|
|
175
|
+
renderValue: cell.renderValue
|
|
176
|
+
}), getMemoOptions(table.options, 'debugCells'))
|
|
177
|
+
};
|
|
178
|
+
table._features.forEach(feature => {
|
|
179
|
+
feature.createCell == null || feature.createCell(cell, column, row, table);
|
|
180
|
+
}, {});
|
|
181
|
+
return cell;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function createColumn(table, columnDef, depth, parent) {
|
|
185
|
+
var _ref, _resolvedColumnDef$id;
|
|
186
|
+
const defaultColumn = table._getDefaultColumnDef();
|
|
187
|
+
const resolvedColumnDef = {
|
|
188
|
+
...defaultColumn,
|
|
189
|
+
...columnDef
|
|
190
|
+
};
|
|
191
|
+
const accessorKey = resolvedColumnDef.accessorKey;
|
|
192
|
+
let id = (_ref = (_resolvedColumnDef$id = resolvedColumnDef.id) != null ? _resolvedColumnDef$id : accessorKey ? typeof String.prototype.replaceAll === 'function' ? accessorKey.replaceAll('.', '_') : accessorKey.replace(/\./g, '_') : undefined) != null ? _ref : typeof resolvedColumnDef.header === 'string' ? resolvedColumnDef.header : undefined;
|
|
193
|
+
let accessorFn;
|
|
194
|
+
if (resolvedColumnDef.accessorFn) {
|
|
195
|
+
accessorFn = resolvedColumnDef.accessorFn;
|
|
196
|
+
} else if (accessorKey) {
|
|
197
|
+
// Support deep accessor keys
|
|
198
|
+
if (accessorKey.includes('.')) {
|
|
199
|
+
accessorFn = originalRow => {
|
|
200
|
+
let result = originalRow;
|
|
201
|
+
for (const key of accessorKey.split('.')) {
|
|
202
|
+
var _result;
|
|
203
|
+
result = (_result = result) == null ? void 0 : _result[key];
|
|
204
|
+
}
|
|
205
|
+
return result;
|
|
206
|
+
};
|
|
207
|
+
} else {
|
|
208
|
+
accessorFn = originalRow => originalRow[resolvedColumnDef.accessorKey];
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (!id) {
|
|
212
|
+
throw new Error();
|
|
213
|
+
}
|
|
214
|
+
let column = {
|
|
215
|
+
id: `${String(id)}`,
|
|
216
|
+
accessorFn,
|
|
217
|
+
parent: parent,
|
|
218
|
+
depth,
|
|
219
|
+
columnDef: resolvedColumnDef,
|
|
220
|
+
columns: [],
|
|
221
|
+
getFlatColumns: memo(() => [true], () => {
|
|
222
|
+
var _column$columns;
|
|
223
|
+
return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
|
|
224
|
+
}, getMemoOptions(table.options, 'debugColumns')),
|
|
225
|
+
getLeafColumns: memo(() => [table._getOrderColumnsFn()], orderColumns => {
|
|
226
|
+
var _column$columns2;
|
|
227
|
+
if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
|
|
228
|
+
let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
|
|
229
|
+
return orderColumns(leafColumns);
|
|
230
|
+
}
|
|
231
|
+
return [column];
|
|
232
|
+
}, getMemoOptions(table.options, 'debugColumns'))
|
|
233
|
+
};
|
|
234
|
+
for (const feature of table._features) {
|
|
235
|
+
feature.createColumn == null || feature.createColumn(column, table);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Yes, we have to convert table to unknown, because we know more than the compiler here.
|
|
239
|
+
return column;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const debug = 'debugHeaders';
|
|
243
|
+
//
|
|
244
|
+
|
|
245
|
+
function createHeader(table, column, options) {
|
|
246
|
+
var _options$id;
|
|
247
|
+
const id = (_options$id = options.id) != null ? _options$id : column.id;
|
|
248
|
+
let header = {
|
|
249
|
+
id,
|
|
250
|
+
column,
|
|
251
|
+
index: options.index,
|
|
252
|
+
isPlaceholder: !!options.isPlaceholder,
|
|
253
|
+
placeholderId: options.placeholderId,
|
|
254
|
+
depth: options.depth,
|
|
255
|
+
subHeaders: [],
|
|
256
|
+
colSpan: 0,
|
|
257
|
+
rowSpan: 0,
|
|
258
|
+
headerGroup: null,
|
|
259
|
+
getLeafHeaders: () => {
|
|
260
|
+
const leafHeaders = [];
|
|
261
|
+
const recurseHeader = h => {
|
|
262
|
+
if (h.subHeaders && h.subHeaders.length) {
|
|
263
|
+
h.subHeaders.map(recurseHeader);
|
|
264
|
+
}
|
|
265
|
+
leafHeaders.push(h);
|
|
266
|
+
};
|
|
267
|
+
recurseHeader(header);
|
|
268
|
+
return leafHeaders;
|
|
269
|
+
},
|
|
270
|
+
getContext: () => ({
|
|
271
|
+
table,
|
|
272
|
+
header: header,
|
|
273
|
+
column
|
|
274
|
+
})
|
|
275
|
+
};
|
|
276
|
+
table._features.forEach(feature => {
|
|
277
|
+
feature.createHeader == null || feature.createHeader(header, table);
|
|
278
|
+
});
|
|
279
|
+
return header;
|
|
280
|
+
}
|
|
281
|
+
const Headers = {
|
|
282
|
+
createTable: table => {
|
|
283
|
+
// Header Groups
|
|
284
|
+
|
|
285
|
+
table.getHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
286
|
+
var _left$map$filter, _right$map$filter;
|
|
287
|
+
const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
|
|
288
|
+
const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
|
|
289
|
+
const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
290
|
+
const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], table);
|
|
291
|
+
return headerGroups;
|
|
292
|
+
}, getMemoOptions(table.options, debug));
|
|
293
|
+
table.getCenterHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
294
|
+
leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
295
|
+
return buildHeaderGroups(allColumns, leafColumns, table, 'center');
|
|
296
|
+
}, getMemoOptions(table.options, debug));
|
|
297
|
+
table.getLeftHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
298
|
+
var _left$map$filter2;
|
|
299
|
+
const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
|
|
300
|
+
return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'left');
|
|
301
|
+
}, getMemoOptions(table.options, debug));
|
|
302
|
+
table.getRightHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
|
303
|
+
var _right$map$filter2;
|
|
304
|
+
const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
|
|
305
|
+
return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'right');
|
|
306
|
+
}, getMemoOptions(table.options, debug));
|
|
307
|
+
|
|
308
|
+
// Footer Groups
|
|
309
|
+
|
|
310
|
+
table.getFooterGroups = memo(() => [table.getHeaderGroups()], headerGroups => {
|
|
311
|
+
return [...headerGroups].reverse();
|
|
312
|
+
}, getMemoOptions(table.options, debug));
|
|
313
|
+
table.getLeftFooterGroups = memo(() => [table.getLeftHeaderGroups()], headerGroups => {
|
|
314
|
+
return [...headerGroups].reverse();
|
|
315
|
+
}, getMemoOptions(table.options, debug));
|
|
316
|
+
table.getCenterFooterGroups = memo(() => [table.getCenterHeaderGroups()], headerGroups => {
|
|
317
|
+
return [...headerGroups].reverse();
|
|
318
|
+
}, getMemoOptions(table.options, debug));
|
|
319
|
+
table.getRightFooterGroups = memo(() => [table.getRightHeaderGroups()], headerGroups => {
|
|
320
|
+
return [...headerGroups].reverse();
|
|
321
|
+
}, getMemoOptions(table.options, debug));
|
|
322
|
+
|
|
323
|
+
// Flat Headers
|
|
324
|
+
|
|
325
|
+
table.getFlatHeaders = memo(() => [table.getHeaderGroups()], headerGroups => {
|
|
326
|
+
return headerGroups.map(headerGroup => {
|
|
327
|
+
return headerGroup.headers;
|
|
328
|
+
}).flat();
|
|
329
|
+
}, getMemoOptions(table.options, debug));
|
|
330
|
+
table.getLeftFlatHeaders = memo(() => [table.getLeftHeaderGroups()], left => {
|
|
331
|
+
return left.map(headerGroup => {
|
|
332
|
+
return headerGroup.headers;
|
|
333
|
+
}).flat();
|
|
334
|
+
}, getMemoOptions(table.options, debug));
|
|
335
|
+
table.getCenterFlatHeaders = memo(() => [table.getCenterHeaderGroups()], left => {
|
|
336
|
+
return left.map(headerGroup => {
|
|
337
|
+
return headerGroup.headers;
|
|
338
|
+
}).flat();
|
|
339
|
+
}, getMemoOptions(table.options, debug));
|
|
340
|
+
table.getRightFlatHeaders = memo(() => [table.getRightHeaderGroups()], left => {
|
|
341
|
+
return left.map(headerGroup => {
|
|
342
|
+
return headerGroup.headers;
|
|
343
|
+
}).flat();
|
|
344
|
+
}, getMemoOptions(table.options, debug));
|
|
345
|
+
|
|
346
|
+
// Leaf Headers
|
|
347
|
+
|
|
348
|
+
table.getCenterLeafHeaders = memo(() => [table.getCenterFlatHeaders()], flatHeaders => {
|
|
349
|
+
return flatHeaders.filter(header => {
|
|
350
|
+
var _header$subHeaders;
|
|
351
|
+
return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
|
|
352
|
+
});
|
|
353
|
+
}, getMemoOptions(table.options, debug));
|
|
354
|
+
table.getLeftLeafHeaders = memo(() => [table.getLeftFlatHeaders()], flatHeaders => {
|
|
355
|
+
return flatHeaders.filter(header => {
|
|
356
|
+
var _header$subHeaders2;
|
|
357
|
+
return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
|
|
358
|
+
});
|
|
359
|
+
}, getMemoOptions(table.options, debug));
|
|
360
|
+
table.getRightLeafHeaders = memo(() => [table.getRightFlatHeaders()], flatHeaders => {
|
|
361
|
+
return flatHeaders.filter(header => {
|
|
362
|
+
var _header$subHeaders3;
|
|
363
|
+
return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
|
|
364
|
+
});
|
|
365
|
+
}, getMemoOptions(table.options, debug));
|
|
366
|
+
table.getLeafHeaders = memo(() => [table.getLeftHeaderGroups(), table.getCenterHeaderGroups(), table.getRightHeaderGroups()], (left, center, right) => {
|
|
367
|
+
var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
|
|
368
|
+
return [...((_left$0$headers = (_left$ = left[0]) == null ? void 0 : _left$.headers) != null ? _left$0$headers : []), ...((_center$0$headers = (_center$ = center[0]) == null ? void 0 : _center$.headers) != null ? _center$0$headers : []), ...((_right$0$headers = (_right$ = right[0]) == null ? void 0 : _right$.headers) != null ? _right$0$headers : [])].map(header => {
|
|
369
|
+
return header.getLeafHeaders();
|
|
370
|
+
}).flat();
|
|
371
|
+
}, getMemoOptions(table.options, debug));
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
function buildHeaderGroups(allColumns, columnsToGroup, table, headerFamily) {
|
|
375
|
+
var _headerGroups$0$heade, _headerGroups$;
|
|
376
|
+
// Find the max depth of the columns:
|
|
377
|
+
// build the leaf column row
|
|
378
|
+
// build each buffer row going up
|
|
379
|
+
// placeholder for non-existent level
|
|
380
|
+
// real column for existing level
|
|
381
|
+
|
|
382
|
+
let maxDepth = 0;
|
|
383
|
+
const findMaxDepth = function (columns, depth) {
|
|
384
|
+
if (depth === void 0) {
|
|
385
|
+
depth = 1;
|
|
386
|
+
}
|
|
387
|
+
maxDepth = Math.max(maxDepth, depth);
|
|
388
|
+
columns.filter(column => column.getIsVisible()).forEach(column => {
|
|
389
|
+
var _column$columns;
|
|
390
|
+
if ((_column$columns = column.columns) != null && _column$columns.length) {
|
|
391
|
+
findMaxDepth(column.columns, depth + 1);
|
|
392
|
+
}
|
|
393
|
+
}, 0);
|
|
394
|
+
};
|
|
395
|
+
findMaxDepth(allColumns);
|
|
396
|
+
let headerGroups = [];
|
|
397
|
+
const createHeaderGroup = (headersToGroup, depth) => {
|
|
398
|
+
// The header group we are creating
|
|
399
|
+
const headerGroup = {
|
|
400
|
+
depth,
|
|
401
|
+
id: [headerFamily, `${depth}`].filter(Boolean).join('_'),
|
|
402
|
+
headers: []
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
// The parent columns we're going to scan next
|
|
406
|
+
const pendingParentHeaders = [];
|
|
407
|
+
|
|
408
|
+
// Scan each column for parents
|
|
409
|
+
headersToGroup.forEach(headerToGroup => {
|
|
410
|
+
// What is the latest (last) parent column?
|
|
411
|
+
|
|
412
|
+
const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
|
|
413
|
+
const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
|
|
414
|
+
let column;
|
|
415
|
+
let isPlaceholder = false;
|
|
416
|
+
if (isLeafHeader && headerToGroup.column.parent) {
|
|
417
|
+
// The parent header is new
|
|
418
|
+
column = headerToGroup.column.parent;
|
|
419
|
+
} else {
|
|
420
|
+
// The parent header is repeated
|
|
421
|
+
column = headerToGroup.column;
|
|
422
|
+
isPlaceholder = true;
|
|
423
|
+
}
|
|
424
|
+
if (latestPendingParentHeader && (latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
|
|
425
|
+
// This column is repeated. Add it as a sub header to the next batch
|
|
426
|
+
latestPendingParentHeader.subHeaders.push(headerToGroup);
|
|
427
|
+
} else {
|
|
428
|
+
// This is a new header. Let's create it
|
|
429
|
+
const header = createHeader(table, column, {
|
|
430
|
+
id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
|
|
431
|
+
isPlaceholder,
|
|
432
|
+
placeholderId: isPlaceholder ? `${pendingParentHeaders.filter(d => d.column === column).length}` : undefined,
|
|
433
|
+
depth,
|
|
434
|
+
index: pendingParentHeaders.length
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
// Add the headerToGroup as a subHeader of the new header
|
|
438
|
+
header.subHeaders.push(headerToGroup);
|
|
439
|
+
// Add the new header to the pendingParentHeaders to get grouped
|
|
440
|
+
// in the next batch
|
|
441
|
+
pendingParentHeaders.push(header);
|
|
442
|
+
}
|
|
443
|
+
headerGroup.headers.push(headerToGroup);
|
|
444
|
+
headerToGroup.headerGroup = headerGroup;
|
|
445
|
+
});
|
|
446
|
+
headerGroups.push(headerGroup);
|
|
447
|
+
if (depth > 0) {
|
|
448
|
+
createHeaderGroup(pendingParentHeaders, depth - 1);
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
const bottomHeaders = columnsToGroup.map((column, index) => createHeader(table, column, {
|
|
452
|
+
depth: maxDepth,
|
|
453
|
+
index
|
|
454
|
+
}));
|
|
455
|
+
createHeaderGroup(bottomHeaders, maxDepth - 1);
|
|
456
|
+
headerGroups.reverse();
|
|
457
|
+
|
|
458
|
+
// headerGroups = headerGroups.filter(headerGroup => {
|
|
459
|
+
// return !headerGroup.headers.every(header => header.isPlaceholder)
|
|
460
|
+
// })
|
|
461
|
+
|
|
462
|
+
const recurseHeadersForSpans = headers => {
|
|
463
|
+
const filteredHeaders = headers.filter(header => header.column.getIsVisible());
|
|
464
|
+
return filteredHeaders.map(header => {
|
|
465
|
+
let colSpan = 0;
|
|
466
|
+
let rowSpan = 0;
|
|
467
|
+
let childRowSpans = [0];
|
|
468
|
+
if (header.subHeaders && header.subHeaders.length) {
|
|
469
|
+
childRowSpans = [];
|
|
470
|
+
recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
|
|
471
|
+
let {
|
|
472
|
+
colSpan: childColSpan,
|
|
473
|
+
rowSpan: childRowSpan
|
|
474
|
+
} = _ref;
|
|
475
|
+
colSpan += childColSpan;
|
|
476
|
+
childRowSpans.push(childRowSpan);
|
|
477
|
+
});
|
|
478
|
+
} else {
|
|
479
|
+
colSpan = 1;
|
|
480
|
+
}
|
|
481
|
+
const minChildRowSpan = Math.min(...childRowSpans);
|
|
482
|
+
rowSpan = rowSpan + minChildRowSpan;
|
|
483
|
+
header.colSpan = colSpan;
|
|
484
|
+
header.rowSpan = rowSpan;
|
|
485
|
+
return {
|
|
486
|
+
colSpan,
|
|
487
|
+
rowSpan
|
|
488
|
+
};
|
|
489
|
+
});
|
|
490
|
+
};
|
|
491
|
+
recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
|
|
492
|
+
return headerGroups;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
|
|
496
|
+
let row = {
|
|
497
|
+
id,
|
|
498
|
+
index: rowIndex,
|
|
499
|
+
original,
|
|
500
|
+
depth,
|
|
501
|
+
parentId,
|
|
502
|
+
_valuesCache: {},
|
|
503
|
+
_uniqueValuesCache: {},
|
|
504
|
+
getValue: columnId => {
|
|
505
|
+
if (row._valuesCache.hasOwnProperty(columnId)) {
|
|
506
|
+
return row._valuesCache[columnId];
|
|
507
|
+
}
|
|
508
|
+
const column = table.getColumn(columnId);
|
|
509
|
+
if (!(column != null && column.accessorFn)) {
|
|
510
|
+
return undefined;
|
|
511
|
+
}
|
|
512
|
+
row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
|
|
513
|
+
return row._valuesCache[columnId];
|
|
514
|
+
},
|
|
515
|
+
getUniqueValues: columnId => {
|
|
516
|
+
if (row._uniqueValuesCache.hasOwnProperty(columnId)) {
|
|
517
|
+
return row._uniqueValuesCache[columnId];
|
|
518
|
+
}
|
|
519
|
+
const column = table.getColumn(columnId);
|
|
520
|
+
if (!(column != null && column.accessorFn)) {
|
|
521
|
+
return undefined;
|
|
522
|
+
}
|
|
523
|
+
if (!column.columnDef.getUniqueValues) {
|
|
524
|
+
row._uniqueValuesCache[columnId] = [row.getValue(columnId)];
|
|
525
|
+
return row._uniqueValuesCache[columnId];
|
|
526
|
+
}
|
|
527
|
+
row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(row.original, rowIndex);
|
|
528
|
+
return row._uniqueValuesCache[columnId];
|
|
529
|
+
},
|
|
530
|
+
renderValue: columnId => {
|
|
531
|
+
var _row$getValue;
|
|
532
|
+
return (_row$getValue = row.getValue(columnId)) != null ? _row$getValue : table.options.renderFallbackValue;
|
|
533
|
+
},
|
|
534
|
+
subRows: [],
|
|
535
|
+
getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
|
|
536
|
+
getParentRow: () => row.parentId ? table.getRow(row.parentId, true) : undefined,
|
|
537
|
+
getParentRows: () => {
|
|
538
|
+
let parentRows = [];
|
|
539
|
+
let currentRow = row;
|
|
540
|
+
while (true) {
|
|
541
|
+
const parentRow = currentRow.getParentRow();
|
|
542
|
+
if (!parentRow) break;
|
|
543
|
+
parentRows.push(parentRow);
|
|
544
|
+
currentRow = parentRow;
|
|
545
|
+
}
|
|
546
|
+
return parentRows.reverse();
|
|
547
|
+
},
|
|
548
|
+
getAllCells: memo(() => [table.getAllLeafColumns()], leafColumns => {
|
|
549
|
+
return leafColumns.map(column => {
|
|
550
|
+
return createCell(table, row, column, column.id);
|
|
551
|
+
});
|
|
552
|
+
}, getMemoOptions(table.options, 'debugRows')),
|
|
553
|
+
_getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
|
|
554
|
+
return allCells.reduce((acc, cell) => {
|
|
555
|
+
acc[cell.column.id] = cell;
|
|
556
|
+
return acc;
|
|
557
|
+
}, {});
|
|
558
|
+
}, getMemoOptions(table.options, 'debugRows'))
|
|
559
|
+
};
|
|
560
|
+
for (let i = 0; i < table._features.length; i++) {
|
|
561
|
+
const feature = table._features[i];
|
|
562
|
+
feature == null || feature.createRow == null || feature.createRow(row, table);
|
|
563
|
+
}
|
|
564
|
+
return row;
|
|
565
|
+
};
|
|
566
|
+
|
|
567
|
+
//
|
|
568
|
+
|
|
569
|
+
const ColumnFaceting = {
|
|
570
|
+
createColumn: (column, table) => {
|
|
571
|
+
column._getFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, column.id);
|
|
572
|
+
column.getFacetedRowModel = () => {
|
|
573
|
+
if (!column._getFacetedRowModel) {
|
|
574
|
+
return table.getPreFilteredRowModel();
|
|
575
|
+
}
|
|
576
|
+
return column._getFacetedRowModel();
|
|
577
|
+
};
|
|
578
|
+
column._getFacetedUniqueValues = table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, column.id);
|
|
579
|
+
column.getFacetedUniqueValues = () => {
|
|
580
|
+
if (!column._getFacetedUniqueValues) {
|
|
581
|
+
return new Map();
|
|
582
|
+
}
|
|
583
|
+
return column._getFacetedUniqueValues();
|
|
584
|
+
};
|
|
585
|
+
column._getFacetedMinMaxValues = table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, column.id);
|
|
586
|
+
column.getFacetedMinMaxValues = () => {
|
|
587
|
+
if (!column._getFacetedMinMaxValues) {
|
|
588
|
+
return undefined;
|
|
589
|
+
}
|
|
590
|
+
return column._getFacetedMinMaxValues();
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
const includesString = (row, columnId, filterValue) => {
|
|
596
|
+
var _filterValue$toString, _row$getValue;
|
|
597
|
+
const search = filterValue == null || (_filterValue$toString = filterValue.toString()) == null ? void 0 : _filterValue$toString.toLowerCase();
|
|
598
|
+
return Boolean((_row$getValue = row.getValue(columnId)) == null || (_row$getValue = _row$getValue.toString()) == null || (_row$getValue = _row$getValue.toLowerCase()) == null ? void 0 : _row$getValue.includes(search));
|
|
599
|
+
};
|
|
600
|
+
includesString.autoRemove = val => testFalsey(val);
|
|
601
|
+
const includesStringSensitive = (row, columnId, filterValue) => {
|
|
602
|
+
var _row$getValue2;
|
|
603
|
+
return Boolean((_row$getValue2 = row.getValue(columnId)) == null || (_row$getValue2 = _row$getValue2.toString()) == null ? void 0 : _row$getValue2.includes(filterValue));
|
|
604
|
+
};
|
|
605
|
+
includesStringSensitive.autoRemove = val => testFalsey(val);
|
|
606
|
+
const equalsString = (row, columnId, filterValue) => {
|
|
607
|
+
var _row$getValue3;
|
|
608
|
+
return ((_row$getValue3 = row.getValue(columnId)) == null || (_row$getValue3 = _row$getValue3.toString()) == null ? void 0 : _row$getValue3.toLowerCase()) === (filterValue == null ? void 0 : filterValue.toLowerCase());
|
|
609
|
+
};
|
|
610
|
+
equalsString.autoRemove = val => testFalsey(val);
|
|
611
|
+
const arrIncludes = (row, columnId, filterValue) => {
|
|
612
|
+
var _row$getValue4;
|
|
613
|
+
return (_row$getValue4 = row.getValue(columnId)) == null ? void 0 : _row$getValue4.includes(filterValue);
|
|
614
|
+
};
|
|
615
|
+
arrIncludes.autoRemove = val => testFalsey(val);
|
|
616
|
+
const arrIncludesAll = (row, columnId, filterValue) => {
|
|
617
|
+
return !filterValue.some(val => {
|
|
618
|
+
var _row$getValue5;
|
|
619
|
+
return !((_row$getValue5 = row.getValue(columnId)) != null && _row$getValue5.includes(val));
|
|
620
|
+
});
|
|
621
|
+
};
|
|
622
|
+
arrIncludesAll.autoRemove = val => testFalsey(val) || !(val != null && val.length);
|
|
623
|
+
const arrIncludesSome = (row, columnId, filterValue) => {
|
|
624
|
+
return filterValue.some(val => {
|
|
625
|
+
var _row$getValue6;
|
|
626
|
+
return (_row$getValue6 = row.getValue(columnId)) == null ? void 0 : _row$getValue6.includes(val);
|
|
627
|
+
});
|
|
628
|
+
};
|
|
629
|
+
arrIncludesSome.autoRemove = val => testFalsey(val) || !(val != null && val.length);
|
|
630
|
+
const equals = (row, columnId, filterValue) => {
|
|
631
|
+
return row.getValue(columnId) === filterValue;
|
|
632
|
+
};
|
|
633
|
+
equals.autoRemove = val => testFalsey(val);
|
|
634
|
+
const weakEquals = (row, columnId, filterValue) => {
|
|
635
|
+
return row.getValue(columnId) == filterValue;
|
|
636
|
+
};
|
|
637
|
+
weakEquals.autoRemove = val => testFalsey(val);
|
|
638
|
+
const inNumberRange = (row, columnId, filterValue) => {
|
|
639
|
+
let [min, max] = filterValue;
|
|
640
|
+
const rowValue = row.getValue(columnId);
|
|
641
|
+
return rowValue >= min && rowValue <= max;
|
|
642
|
+
};
|
|
643
|
+
inNumberRange.resolveFilterValue = val => {
|
|
644
|
+
let [unsafeMin, unsafeMax] = val;
|
|
645
|
+
let parsedMin = typeof unsafeMin !== 'number' ? parseFloat(unsafeMin) : unsafeMin;
|
|
646
|
+
let parsedMax = typeof unsafeMax !== 'number' ? parseFloat(unsafeMax) : unsafeMax;
|
|
647
|
+
let min = unsafeMin === null || Number.isNaN(parsedMin) ? -Infinity : parsedMin;
|
|
648
|
+
let max = unsafeMax === null || Number.isNaN(parsedMax) ? Infinity : parsedMax;
|
|
649
|
+
if (min > max) {
|
|
650
|
+
const temp = min;
|
|
651
|
+
min = max;
|
|
652
|
+
max = temp;
|
|
653
|
+
}
|
|
654
|
+
return [min, max];
|
|
655
|
+
};
|
|
656
|
+
inNumberRange.autoRemove = val => testFalsey(val) || testFalsey(val[0]) && testFalsey(val[1]);
|
|
657
|
+
|
|
658
|
+
// Export
|
|
659
|
+
|
|
660
|
+
const filterFns = {
|
|
661
|
+
includesString,
|
|
662
|
+
includesStringSensitive,
|
|
663
|
+
equalsString,
|
|
664
|
+
arrIncludes,
|
|
665
|
+
arrIncludesAll,
|
|
666
|
+
arrIncludesSome,
|
|
667
|
+
equals,
|
|
668
|
+
weakEquals,
|
|
669
|
+
inNumberRange
|
|
670
|
+
};
|
|
671
|
+
// Utils
|
|
672
|
+
|
|
673
|
+
function testFalsey(val) {
|
|
674
|
+
return val === undefined || val === null || val === '';
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
//
|
|
678
|
+
|
|
679
|
+
const ColumnFiltering = {
|
|
680
|
+
getDefaultColumnDef: () => {
|
|
681
|
+
return {
|
|
682
|
+
filterFn: 'auto'
|
|
683
|
+
};
|
|
684
|
+
},
|
|
685
|
+
getInitialState: state => {
|
|
686
|
+
return {
|
|
687
|
+
columnFilters: [],
|
|
688
|
+
...state
|
|
689
|
+
};
|
|
690
|
+
},
|
|
691
|
+
getDefaultOptions: table => {
|
|
692
|
+
return {
|
|
693
|
+
onColumnFiltersChange: makeStateUpdater('columnFilters', table),
|
|
694
|
+
filterFromLeafRows: false,
|
|
695
|
+
maxLeafRowFilterDepth: 100
|
|
696
|
+
};
|
|
697
|
+
},
|
|
698
|
+
createColumn: (column, table) => {
|
|
699
|
+
column.getAutoFilterFn = () => {
|
|
700
|
+
const firstRow = table.getCoreRowModel().flatRows[0];
|
|
701
|
+
const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
|
|
702
|
+
if (typeof value === 'string') {
|
|
703
|
+
return filterFns.includesString;
|
|
704
|
+
}
|
|
705
|
+
if (typeof value === 'number') {
|
|
706
|
+
return filterFns.inNumberRange;
|
|
707
|
+
}
|
|
708
|
+
if (typeof value === 'boolean') {
|
|
709
|
+
return filterFns.equals;
|
|
710
|
+
}
|
|
711
|
+
if (value !== null && typeof value === 'object') {
|
|
712
|
+
return filterFns.equals;
|
|
713
|
+
}
|
|
714
|
+
if (Array.isArray(value)) {
|
|
715
|
+
return filterFns.arrIncludes;
|
|
716
|
+
}
|
|
717
|
+
return filterFns.weakEquals;
|
|
718
|
+
};
|
|
719
|
+
column.getFilterFn = () => {
|
|
720
|
+
var _table$options$filter, _table$options$filter2;
|
|
721
|
+
return isFunction(column.columnDef.filterFn) ? column.columnDef.filterFn : column.columnDef.filterFn === 'auto' ? column.getAutoFilterFn() : // @ts-ignore
|
|
722
|
+
(_table$options$filter = (_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[column.columnDef.filterFn]) != null ? _table$options$filter : filterFns[column.columnDef.filterFn];
|
|
723
|
+
};
|
|
724
|
+
column.getCanFilter = () => {
|
|
725
|
+
var _column$columnDef$ena, _table$options$enable, _table$options$enable2;
|
|
726
|
+
return ((_column$columnDef$ena = column.columnDef.enableColumnFilter) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableColumnFilters) != null ? _table$options$enable : true) && ((_table$options$enable2 = table.options.enableFilters) != null ? _table$options$enable2 : true) && !!column.accessorFn;
|
|
727
|
+
};
|
|
728
|
+
column.getIsFiltered = () => column.getFilterIndex() > -1;
|
|
729
|
+
column.getFilterValue = () => {
|
|
730
|
+
var _table$getState$colum;
|
|
731
|
+
return (_table$getState$colum = table.getState().columnFilters) == null || (_table$getState$colum = _table$getState$colum.find(d => d.id === column.id)) == null ? void 0 : _table$getState$colum.value;
|
|
732
|
+
};
|
|
733
|
+
column.getFilterIndex = () => {
|
|
734
|
+
var _table$getState$colum2, _table$getState$colum3;
|
|
735
|
+
return (_table$getState$colum2 = (_table$getState$colum3 = table.getState().columnFilters) == null ? void 0 : _table$getState$colum3.findIndex(d => d.id === column.id)) != null ? _table$getState$colum2 : -1;
|
|
736
|
+
};
|
|
737
|
+
column.setFilterValue = value => {
|
|
738
|
+
table.setColumnFilters(old => {
|
|
739
|
+
const filterFn = column.getFilterFn();
|
|
740
|
+
const previousFilter = old == null ? void 0 : old.find(d => d.id === column.id);
|
|
741
|
+
const newFilter = functionalUpdate(value, previousFilter ? previousFilter.value : undefined);
|
|
742
|
+
|
|
743
|
+
//
|
|
744
|
+
if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {
|
|
745
|
+
var _old$filter;
|
|
746
|
+
return (_old$filter = old == null ? void 0 : old.filter(d => d.id !== column.id)) != null ? _old$filter : [];
|
|
747
|
+
}
|
|
748
|
+
const newFilterObj = {
|
|
749
|
+
id: column.id,
|
|
750
|
+
value: newFilter
|
|
751
|
+
};
|
|
752
|
+
if (previousFilter) {
|
|
753
|
+
var _old$map;
|
|
754
|
+
return (_old$map = old == null ? void 0 : old.map(d => {
|
|
755
|
+
if (d.id === column.id) {
|
|
756
|
+
return newFilterObj;
|
|
757
|
+
}
|
|
758
|
+
return d;
|
|
759
|
+
})) != null ? _old$map : [];
|
|
760
|
+
}
|
|
761
|
+
if (old != null && old.length) {
|
|
762
|
+
return [...old, newFilterObj];
|
|
763
|
+
}
|
|
764
|
+
return [newFilterObj];
|
|
765
|
+
});
|
|
766
|
+
};
|
|
767
|
+
},
|
|
768
|
+
createRow: (row, _table) => {
|
|
769
|
+
row.columnFilters = {};
|
|
770
|
+
row.columnFiltersMeta = {};
|
|
771
|
+
},
|
|
772
|
+
createTable: table => {
|
|
773
|
+
table.setColumnFilters = updater => {
|
|
774
|
+
const leafColumns = table.getAllLeafColumns();
|
|
775
|
+
const updateFn = old => {
|
|
776
|
+
var _functionalUpdate;
|
|
777
|
+
return (_functionalUpdate = functionalUpdate(updater, old)) == null ? void 0 : _functionalUpdate.filter(filter => {
|
|
778
|
+
const column = leafColumns.find(d => d.id === filter.id);
|
|
779
|
+
if (column) {
|
|
780
|
+
const filterFn = column.getFilterFn();
|
|
781
|
+
if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {
|
|
782
|
+
return false;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
return true;
|
|
786
|
+
});
|
|
787
|
+
};
|
|
788
|
+
table.options.onColumnFiltersChange == null || table.options.onColumnFiltersChange(updateFn);
|
|
789
|
+
};
|
|
790
|
+
table.resetColumnFilters = defaultState => {
|
|
791
|
+
var _table$initialState$c, _table$initialState;
|
|
792
|
+
table.setColumnFilters(defaultState ? [] : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnFilters) != null ? _table$initialState$c : []);
|
|
793
|
+
};
|
|
794
|
+
table.getPreFilteredRowModel = () => table.getCoreRowModel();
|
|
795
|
+
table.getFilteredRowModel = () => {
|
|
796
|
+
if (!table._getFilteredRowModel && table.options.getFilteredRowModel) {
|
|
797
|
+
table._getFilteredRowModel = table.options.getFilteredRowModel(table);
|
|
798
|
+
}
|
|
799
|
+
if (table.options.manualFiltering || !table._getFilteredRowModel) {
|
|
800
|
+
return table.getPreFilteredRowModel();
|
|
801
|
+
}
|
|
802
|
+
return table._getFilteredRowModel();
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
function shouldAutoRemoveFilter(filterFn, value, column) {
|
|
807
|
+
return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
const sum = (columnId, _leafRows, childRows) => {
|
|
811
|
+
// It's faster to just add the aggregations together instead of
|
|
812
|
+
// process leaf nodes individually
|
|
813
|
+
return childRows.reduce((sum, next) => {
|
|
814
|
+
const nextValue = next.getValue(columnId);
|
|
815
|
+
return sum + (typeof nextValue === 'number' ? nextValue : 0);
|
|
816
|
+
}, 0);
|
|
817
|
+
};
|
|
818
|
+
const min = (columnId, _leafRows, childRows) => {
|
|
819
|
+
let min;
|
|
820
|
+
childRows.forEach(row => {
|
|
821
|
+
const value = row.getValue(columnId);
|
|
822
|
+
if (value != null && (min > value || min === undefined && value >= value)) {
|
|
823
|
+
min = value;
|
|
824
|
+
}
|
|
825
|
+
});
|
|
826
|
+
return min;
|
|
827
|
+
};
|
|
828
|
+
const max = (columnId, _leafRows, childRows) => {
|
|
829
|
+
let max;
|
|
830
|
+
childRows.forEach(row => {
|
|
831
|
+
const value = row.getValue(columnId);
|
|
832
|
+
if (value != null && (max < value || max === undefined && value >= value)) {
|
|
833
|
+
max = value;
|
|
834
|
+
}
|
|
835
|
+
});
|
|
836
|
+
return max;
|
|
837
|
+
};
|
|
838
|
+
const extent = (columnId, _leafRows, childRows) => {
|
|
839
|
+
let min;
|
|
840
|
+
let max;
|
|
841
|
+
childRows.forEach(row => {
|
|
842
|
+
const value = row.getValue(columnId);
|
|
843
|
+
if (value != null) {
|
|
844
|
+
if (min === undefined) {
|
|
845
|
+
if (value >= value) min = max = value;
|
|
846
|
+
} else {
|
|
847
|
+
if (min > value) min = value;
|
|
848
|
+
if (max < value) max = value;
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
return [min, max];
|
|
853
|
+
};
|
|
854
|
+
const mean = (columnId, leafRows) => {
|
|
855
|
+
let count = 0;
|
|
856
|
+
let sum = 0;
|
|
857
|
+
leafRows.forEach(row => {
|
|
858
|
+
let value = row.getValue(columnId);
|
|
859
|
+
if (value != null && (value = +value) >= value) {
|
|
860
|
+
++count, sum += value;
|
|
861
|
+
}
|
|
862
|
+
});
|
|
863
|
+
if (count) return sum / count;
|
|
864
|
+
return;
|
|
865
|
+
};
|
|
866
|
+
const median = (columnId, leafRows) => {
|
|
867
|
+
if (!leafRows.length) {
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
const values = leafRows.map(row => row.getValue(columnId));
|
|
871
|
+
if (!isNumberArray(values)) {
|
|
872
|
+
return;
|
|
873
|
+
}
|
|
874
|
+
if (values.length === 1) {
|
|
875
|
+
return values[0];
|
|
876
|
+
}
|
|
877
|
+
const mid = Math.floor(values.length / 2);
|
|
878
|
+
const nums = values.sort((a, b) => a - b);
|
|
879
|
+
return values.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;
|
|
880
|
+
};
|
|
881
|
+
const unique = (columnId, leafRows) => {
|
|
882
|
+
return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
|
|
883
|
+
};
|
|
884
|
+
const uniqueCount = (columnId, leafRows) => {
|
|
885
|
+
return new Set(leafRows.map(d => d.getValue(columnId))).size;
|
|
886
|
+
};
|
|
887
|
+
const count = (_columnId, leafRows) => {
|
|
888
|
+
return leafRows.length;
|
|
889
|
+
};
|
|
890
|
+
const aggregationFns = {
|
|
891
|
+
sum,
|
|
892
|
+
min,
|
|
893
|
+
max,
|
|
894
|
+
extent,
|
|
895
|
+
mean,
|
|
896
|
+
median,
|
|
897
|
+
unique,
|
|
898
|
+
uniqueCount,
|
|
899
|
+
count
|
|
900
|
+
};
|
|
901
|
+
|
|
902
|
+
//
|
|
903
|
+
|
|
904
|
+
const ColumnGrouping = {
|
|
905
|
+
getDefaultColumnDef: () => {
|
|
906
|
+
return {
|
|
907
|
+
aggregatedCell: props => {
|
|
908
|
+
var _toString, _props$getValue;
|
|
909
|
+
return (_toString = (_props$getValue = props.getValue()) == null || _props$getValue.toString == null ? void 0 : _props$getValue.toString()) != null ? _toString : null;
|
|
910
|
+
},
|
|
911
|
+
aggregationFn: 'auto'
|
|
912
|
+
};
|
|
913
|
+
},
|
|
914
|
+
getInitialState: state => {
|
|
915
|
+
return {
|
|
916
|
+
grouping: [],
|
|
917
|
+
...state
|
|
918
|
+
};
|
|
919
|
+
},
|
|
920
|
+
getDefaultOptions: table => {
|
|
921
|
+
return {
|
|
922
|
+
onGroupingChange: makeStateUpdater('grouping', table),
|
|
923
|
+
groupedColumnMode: 'reorder'
|
|
924
|
+
};
|
|
925
|
+
},
|
|
926
|
+
createColumn: (column, table) => {
|
|
927
|
+
column.toggleGrouping = () => {
|
|
928
|
+
table.setGrouping(old => {
|
|
929
|
+
// Find any existing grouping for this column
|
|
930
|
+
if (old != null && old.includes(column.id)) {
|
|
931
|
+
return old.filter(d => d !== column.id);
|
|
932
|
+
}
|
|
933
|
+
return [...(old != null ? old : []), column.id];
|
|
934
|
+
});
|
|
935
|
+
};
|
|
936
|
+
column.getCanGroup = () => {
|
|
937
|
+
var _column$columnDef$ena, _table$options$enable;
|
|
938
|
+
return ((_column$columnDef$ena = column.columnDef.enableGrouping) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableGrouping) != null ? _table$options$enable : true) && (!!column.accessorFn || !!column.columnDef.getGroupingValue);
|
|
939
|
+
};
|
|
940
|
+
column.getIsGrouped = () => {
|
|
941
|
+
var _table$getState$group;
|
|
942
|
+
return (_table$getState$group = table.getState().grouping) == null ? void 0 : _table$getState$group.includes(column.id);
|
|
943
|
+
};
|
|
944
|
+
column.getGroupedIndex = () => {
|
|
945
|
+
var _table$getState$group2;
|
|
946
|
+
return (_table$getState$group2 = table.getState().grouping) == null ? void 0 : _table$getState$group2.indexOf(column.id);
|
|
947
|
+
};
|
|
948
|
+
column.getToggleGroupingHandler = () => {
|
|
949
|
+
const canGroup = column.getCanGroup();
|
|
950
|
+
return () => {
|
|
951
|
+
if (!canGroup) return;
|
|
952
|
+
column.toggleGrouping();
|
|
953
|
+
};
|
|
954
|
+
};
|
|
955
|
+
column.getAutoAggregationFn = () => {
|
|
956
|
+
const firstRow = table.getCoreRowModel().flatRows[0];
|
|
957
|
+
const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
|
|
958
|
+
if (typeof value === 'number') {
|
|
959
|
+
return aggregationFns.sum;
|
|
960
|
+
}
|
|
961
|
+
if (Object.prototype.toString.call(value) === '[object Date]') {
|
|
962
|
+
return aggregationFns.extent;
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
column.getAggregationFn = () => {
|
|
966
|
+
var _table$options$aggreg, _table$options$aggreg2;
|
|
967
|
+
if (!column) {
|
|
968
|
+
throw new Error();
|
|
969
|
+
}
|
|
970
|
+
return isFunction(column.columnDef.aggregationFn) ? column.columnDef.aggregationFn : column.columnDef.aggregationFn === 'auto' ? column.getAutoAggregationFn() : (_table$options$aggreg = (_table$options$aggreg2 = table.options.aggregationFns) == null ? void 0 : _table$options$aggreg2[column.columnDef.aggregationFn]) != null ? _table$options$aggreg : aggregationFns[column.columnDef.aggregationFn];
|
|
971
|
+
};
|
|
972
|
+
},
|
|
973
|
+
createTable: table => {
|
|
974
|
+
table.setGrouping = updater => table.options.onGroupingChange == null ? void 0 : table.options.onGroupingChange(updater);
|
|
975
|
+
table.resetGrouping = defaultState => {
|
|
976
|
+
var _table$initialState$g, _table$initialState;
|
|
977
|
+
table.setGrouping(defaultState ? [] : (_table$initialState$g = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.grouping) != null ? _table$initialState$g : []);
|
|
978
|
+
};
|
|
979
|
+
table.getPreGroupedRowModel = () => table.getFilteredRowModel();
|
|
980
|
+
table.getGroupedRowModel = () => {
|
|
981
|
+
if (!table._getGroupedRowModel && table.options.getGroupedRowModel) {
|
|
982
|
+
table._getGroupedRowModel = table.options.getGroupedRowModel(table);
|
|
983
|
+
}
|
|
984
|
+
if (table.options.manualGrouping || !table._getGroupedRowModel) {
|
|
985
|
+
return table.getPreGroupedRowModel();
|
|
986
|
+
}
|
|
987
|
+
return table._getGroupedRowModel();
|
|
988
|
+
};
|
|
989
|
+
},
|
|
990
|
+
createRow: (row, table) => {
|
|
991
|
+
row.getIsGrouped = () => !!row.groupingColumnId;
|
|
992
|
+
row.getGroupingValue = columnId => {
|
|
993
|
+
if (row._groupingValuesCache.hasOwnProperty(columnId)) {
|
|
994
|
+
return row._groupingValuesCache[columnId];
|
|
995
|
+
}
|
|
996
|
+
const column = table.getColumn(columnId);
|
|
997
|
+
if (!(column != null && column.columnDef.getGroupingValue)) {
|
|
998
|
+
return row.getValue(columnId);
|
|
999
|
+
}
|
|
1000
|
+
row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(row.original);
|
|
1001
|
+
return row._groupingValuesCache[columnId];
|
|
1002
|
+
};
|
|
1003
|
+
row._groupingValuesCache = {};
|
|
1004
|
+
},
|
|
1005
|
+
createCell: (cell, column, row, table) => {
|
|
1006
|
+
cell.getIsGrouped = () => column.getIsGrouped() && column.id === row.groupingColumnId;
|
|
1007
|
+
cell.getIsPlaceholder = () => !cell.getIsGrouped() && column.getIsGrouped();
|
|
1008
|
+
cell.getIsAggregated = () => {
|
|
1009
|
+
var _row$subRows;
|
|
1010
|
+
return !cell.getIsGrouped() && !cell.getIsPlaceholder() && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
};
|
|
1014
|
+
function orderColumns(leafColumns, grouping, groupedColumnMode) {
|
|
1015
|
+
if (!(grouping != null && grouping.length) || !groupedColumnMode) {
|
|
1016
|
+
return leafColumns;
|
|
1017
|
+
}
|
|
1018
|
+
const nonGroupingColumns = leafColumns.filter(col => !grouping.includes(col.id));
|
|
1019
|
+
if (groupedColumnMode === 'remove') {
|
|
1020
|
+
return nonGroupingColumns;
|
|
1021
|
+
}
|
|
1022
|
+
const groupingColumns = grouping.map(g => leafColumns.find(col => col.id === g)).filter(Boolean);
|
|
1023
|
+
return [...groupingColumns, ...nonGroupingColumns];
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
//
|
|
1027
|
+
|
|
1028
|
+
const ColumnOrdering = {
|
|
1029
|
+
getInitialState: state => {
|
|
1030
|
+
return {
|
|
1031
|
+
columnOrder: [],
|
|
1032
|
+
...state
|
|
1033
|
+
};
|
|
1034
|
+
},
|
|
1035
|
+
getDefaultOptions: table => {
|
|
1036
|
+
return {
|
|
1037
|
+
onColumnOrderChange: makeStateUpdater('columnOrder', table)
|
|
1038
|
+
};
|
|
1039
|
+
},
|
|
1040
|
+
createColumn: (column, table) => {
|
|
1041
|
+
column.getIndex = memo(position => [_getVisibleLeafColumns(table, position)], columns => columns.findIndex(d => d.id === column.id), getMemoOptions(table.options, 'debugColumns'));
|
|
1042
|
+
column.getIsFirstColumn = position => {
|
|
1043
|
+
var _columns$;
|
|
1044
|
+
const columns = _getVisibleLeafColumns(table, position);
|
|
1045
|
+
return ((_columns$ = columns[0]) == null ? void 0 : _columns$.id) === column.id;
|
|
1046
|
+
};
|
|
1047
|
+
column.getIsLastColumn = position => {
|
|
1048
|
+
var _columns;
|
|
1049
|
+
const columns = _getVisibleLeafColumns(table, position);
|
|
1050
|
+
return ((_columns = columns[columns.length - 1]) == null ? void 0 : _columns.id) === column.id;
|
|
1051
|
+
};
|
|
1052
|
+
},
|
|
1053
|
+
createTable: table => {
|
|
1054
|
+
table.setColumnOrder = updater => table.options.onColumnOrderChange == null ? void 0 : table.options.onColumnOrderChange(updater);
|
|
1055
|
+
table.resetColumnOrder = defaultState => {
|
|
1056
|
+
var _table$initialState$c;
|
|
1057
|
+
table.setColumnOrder(defaultState ? [] : (_table$initialState$c = table.initialState.columnOrder) != null ? _table$initialState$c : []);
|
|
1058
|
+
};
|
|
1059
|
+
table._getOrderColumnsFn = memo(() => [table.getState().columnOrder, table.getState().grouping, table.options.groupedColumnMode], (columnOrder, grouping, groupedColumnMode) => columns => {
|
|
1060
|
+
// Sort grouped columns to the start of the column list
|
|
1061
|
+
// before the headers are built
|
|
1062
|
+
let orderedColumns = [];
|
|
1063
|
+
|
|
1064
|
+
// If there is no order, return the normal columns
|
|
1065
|
+
if (!(columnOrder != null && columnOrder.length)) {
|
|
1066
|
+
orderedColumns = columns;
|
|
1067
|
+
} else {
|
|
1068
|
+
const columnOrderCopy = [...columnOrder];
|
|
1069
|
+
|
|
1070
|
+
// If there is an order, make a copy of the columns
|
|
1071
|
+
const columnsCopy = [...columns];
|
|
1072
|
+
|
|
1073
|
+
// And make a new ordered array of the columns
|
|
1074
|
+
|
|
1075
|
+
// Loop over the columns and place them in order into the new array
|
|
1076
|
+
while (columnsCopy.length && columnOrderCopy.length) {
|
|
1077
|
+
const targetColumnId = columnOrderCopy.shift();
|
|
1078
|
+
const foundIndex = columnsCopy.findIndex(d => d.id === targetColumnId);
|
|
1079
|
+
if (foundIndex > -1) {
|
|
1080
|
+
orderedColumns.push(columnsCopy.splice(foundIndex, 1)[0]);
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
// If there are any columns left, add them to the end
|
|
1085
|
+
orderedColumns = [...orderedColumns, ...columnsCopy];
|
|
1086
|
+
}
|
|
1087
|
+
return orderColumns(orderedColumns, grouping, groupedColumnMode);
|
|
1088
|
+
}, getMemoOptions(table.options, 'debugTable'));
|
|
1089
|
+
}
|
|
1090
|
+
};
|
|
1091
|
+
|
|
1092
|
+
//
|
|
1093
|
+
|
|
1094
|
+
const getDefaultColumnPinningState = () => ({
|
|
1095
|
+
left: [],
|
|
1096
|
+
right: []
|
|
1097
|
+
});
|
|
1098
|
+
const ColumnPinning = {
|
|
1099
|
+
getInitialState: state => {
|
|
1100
|
+
return {
|
|
1101
|
+
columnPinning: getDefaultColumnPinningState(),
|
|
1102
|
+
...state
|
|
1103
|
+
};
|
|
1104
|
+
},
|
|
1105
|
+
getDefaultOptions: table => {
|
|
1106
|
+
return {
|
|
1107
|
+
onColumnPinningChange: makeStateUpdater('columnPinning', table)
|
|
1108
|
+
};
|
|
1109
|
+
},
|
|
1110
|
+
createColumn: (column, table) => {
|
|
1111
|
+
column.pin = position => {
|
|
1112
|
+
const columnIds = column.getLeafColumns().map(d => d.id).filter(Boolean);
|
|
1113
|
+
table.setColumnPinning(old => {
|
|
1114
|
+
var _old$left3, _old$right3;
|
|
1115
|
+
if (position === 'right') {
|
|
1116
|
+
var _old$left, _old$right;
|
|
1117
|
+
return {
|
|
1118
|
+
left: ((_old$left = old == null ? void 0 : old.left) != null ? _old$left : []).filter(d => !(columnIds != null && columnIds.includes(d))),
|
|
1119
|
+
right: [...((_old$right = old == null ? void 0 : old.right) != null ? _old$right : []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds]
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1122
|
+
if (position === 'left') {
|
|
1123
|
+
var _old$left2, _old$right2;
|
|
1124
|
+
return {
|
|
1125
|
+
left: [...((_old$left2 = old == null ? void 0 : old.left) != null ? _old$left2 : []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds],
|
|
1126
|
+
right: ((_old$right2 = old == null ? void 0 : old.right) != null ? _old$right2 : []).filter(d => !(columnIds != null && columnIds.includes(d)))
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
return {
|
|
1130
|
+
left: ((_old$left3 = old == null ? void 0 : old.left) != null ? _old$left3 : []).filter(d => !(columnIds != null && columnIds.includes(d))),
|
|
1131
|
+
right: ((_old$right3 = old == null ? void 0 : old.right) != null ? _old$right3 : []).filter(d => !(columnIds != null && columnIds.includes(d)))
|
|
1132
|
+
};
|
|
1133
|
+
});
|
|
1134
|
+
};
|
|
1135
|
+
column.getCanPin = () => {
|
|
1136
|
+
const leafColumns = column.getLeafColumns();
|
|
1137
|
+
return leafColumns.some(d => {
|
|
1138
|
+
var _d$columnDef$enablePi, _ref, _table$options$enable;
|
|
1139
|
+
return ((_d$columnDef$enablePi = d.columnDef.enablePinning) != null ? _d$columnDef$enablePi : true) && ((_ref = (_table$options$enable = table.options.enableColumnPinning) != null ? _table$options$enable : table.options.enablePinning) != null ? _ref : true);
|
|
1140
|
+
});
|
|
1141
|
+
};
|
|
1142
|
+
column.getIsPinned = () => {
|
|
1143
|
+
const leafColumnIds = column.getLeafColumns().map(d => d.id);
|
|
1144
|
+
const {
|
|
1145
|
+
left,
|
|
1146
|
+
right
|
|
1147
|
+
} = table.getState().columnPinning;
|
|
1148
|
+
const isLeft = leafColumnIds.some(d => left == null ? void 0 : left.includes(d));
|
|
1149
|
+
const isRight = leafColumnIds.some(d => right == null ? void 0 : right.includes(d));
|
|
1150
|
+
return isLeft ? 'left' : isRight ? 'right' : false;
|
|
1151
|
+
};
|
|
1152
|
+
column.getPinnedIndex = () => {
|
|
1153
|
+
var _table$getState$colum, _table$getState$colum2;
|
|
1154
|
+
const position = column.getIsPinned();
|
|
1155
|
+
return position ? (_table$getState$colum = (_table$getState$colum2 = table.getState().columnPinning) == null || (_table$getState$colum2 = _table$getState$colum2[position]) == null ? void 0 : _table$getState$colum2.indexOf(column.id)) != null ? _table$getState$colum : -1 : 0;
|
|
1156
|
+
};
|
|
1157
|
+
},
|
|
1158
|
+
createRow: (row, table) => {
|
|
1159
|
+
row.getCenterVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allCells, left, right) => {
|
|
1160
|
+
const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
|
|
1161
|
+
return allCells.filter(d => !leftAndRight.includes(d.column.id));
|
|
1162
|
+
}, getMemoOptions(table.options, 'debugRows'));
|
|
1163
|
+
row.getLeftVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left], (allCells, left) => {
|
|
1164
|
+
const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
|
|
1165
|
+
...d,
|
|
1166
|
+
position: 'left'
|
|
1167
|
+
}));
|
|
1168
|
+
return cells;
|
|
1169
|
+
}, getMemoOptions(table.options, 'debugRows'));
|
|
1170
|
+
row.getRightVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.right], (allCells, right) => {
|
|
1171
|
+
const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
|
|
1172
|
+
...d,
|
|
1173
|
+
position: 'right'
|
|
1174
|
+
}));
|
|
1175
|
+
return cells;
|
|
1176
|
+
}, getMemoOptions(table.options, 'debugRows'));
|
|
1177
|
+
},
|
|
1178
|
+
createTable: table => {
|
|
1179
|
+
table.setColumnPinning = updater => table.options.onColumnPinningChange == null ? void 0 : table.options.onColumnPinningChange(updater);
|
|
1180
|
+
table.resetColumnPinning = defaultState => {
|
|
1181
|
+
var _table$initialState$c, _table$initialState;
|
|
1182
|
+
return table.setColumnPinning(defaultState ? getDefaultColumnPinningState() : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnPinning) != null ? _table$initialState$c : getDefaultColumnPinningState());
|
|
1183
|
+
};
|
|
1184
|
+
table.getIsSomeColumnsPinned = position => {
|
|
1185
|
+
var _pinningState$positio;
|
|
1186
|
+
const pinningState = table.getState().columnPinning;
|
|
1187
|
+
if (!position) {
|
|
1188
|
+
var _pinningState$left, _pinningState$right;
|
|
1189
|
+
return Boolean(((_pinningState$left = pinningState.left) == null ? void 0 : _pinningState$left.length) || ((_pinningState$right = pinningState.right) == null ? void 0 : _pinningState$right.length));
|
|
1190
|
+
}
|
|
1191
|
+
return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
|
|
1192
|
+
};
|
|
1193
|
+
table.getLeftLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left], (allColumns, left) => {
|
|
1194
|
+
return (left != null ? left : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
|
|
1195
|
+
}, getMemoOptions(table.options, 'debugColumns'));
|
|
1196
|
+
table.getRightLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.right], (allColumns, right) => {
|
|
1197
|
+
return (right != null ? right : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
|
|
1198
|
+
}, getMemoOptions(table.options, 'debugColumns'));
|
|
1199
|
+
table.getCenterLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, left, right) => {
|
|
1200
|
+
const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
|
|
1201
|
+
return allColumns.filter(d => !leftAndRight.includes(d.id));
|
|
1202
|
+
}, getMemoOptions(table.options, 'debugColumns'));
|
|
1203
|
+
}
|
|
1204
|
+
};
|
|
1205
|
+
|
|
1206
|
+
function safelyAccessDocument(_document) {
|
|
1207
|
+
return _document || (typeof document !== 'undefined' ? document : null);
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
//
|
|
1211
|
+
|
|
1212
|
+
//
|
|
1213
|
+
|
|
1214
|
+
const defaultColumnSizing = {
|
|
1215
|
+
size: 150,
|
|
1216
|
+
minSize: 20,
|
|
1217
|
+
maxSize: Number.MAX_SAFE_INTEGER
|
|
1218
|
+
};
|
|
1219
|
+
const getDefaultColumnSizingInfoState = () => ({
|
|
1220
|
+
startOffset: null,
|
|
1221
|
+
startSize: null,
|
|
1222
|
+
deltaOffset: null,
|
|
1223
|
+
deltaPercentage: null,
|
|
1224
|
+
isResizingColumn: false,
|
|
1225
|
+
columnSizingStart: []
|
|
1226
|
+
});
|
|
1227
|
+
const ColumnSizing = {
|
|
1228
|
+
getDefaultColumnDef: () => {
|
|
1229
|
+
return defaultColumnSizing;
|
|
1230
|
+
},
|
|
1231
|
+
getInitialState: state => {
|
|
1232
|
+
return {
|
|
1233
|
+
columnSizing: {},
|
|
1234
|
+
columnSizingInfo: getDefaultColumnSizingInfoState(),
|
|
1235
|
+
...state
|
|
1236
|
+
};
|
|
1237
|
+
},
|
|
1238
|
+
getDefaultOptions: table => {
|
|
1239
|
+
return {
|
|
1240
|
+
columnResizeMode: 'onEnd',
|
|
1241
|
+
columnResizeDirection: 'ltr',
|
|
1242
|
+
onColumnSizingChange: makeStateUpdater('columnSizing', table),
|
|
1243
|
+
onColumnSizingInfoChange: makeStateUpdater('columnSizingInfo', table)
|
|
1244
|
+
};
|
|
1245
|
+
},
|
|
1246
|
+
createColumn: (column, table) => {
|
|
1247
|
+
column.getSize = () => {
|
|
1248
|
+
var _column$columnDef$min, _ref, _column$columnDef$max;
|
|
1249
|
+
const columnSize = table.getState().columnSizing[column.id];
|
|
1250
|
+
return Math.min(Math.max((_column$columnDef$min = column.columnDef.minSize) != null ? _column$columnDef$min : defaultColumnSizing.minSize, (_ref = columnSize != null ? columnSize : column.columnDef.size) != null ? _ref : defaultColumnSizing.size), (_column$columnDef$max = column.columnDef.maxSize) != null ? _column$columnDef$max : defaultColumnSizing.maxSize);
|
|
1251
|
+
};
|
|
1252
|
+
column.getStart = memo(position => [position, _getVisibleLeafColumns(table, position), table.getState().columnSizing], (position, columns) => columns.slice(0, column.getIndex(position)).reduce((sum, column) => sum + column.getSize(), 0), getMemoOptions(table.options, 'debugColumns'));
|
|
1253
|
+
column.getAfter = memo(position => [position, _getVisibleLeafColumns(table, position), table.getState().columnSizing], (position, columns) => columns.slice(column.getIndex(position) + 1).reduce((sum, column) => sum + column.getSize(), 0), getMemoOptions(table.options, 'debugColumns'));
|
|
1254
|
+
column.resetSize = () => {
|
|
1255
|
+
table.setColumnSizing(_ref2 => {
|
|
1256
|
+
let {
|
|
1257
|
+
[column.id]: _,
|
|
1258
|
+
...rest
|
|
1259
|
+
} = _ref2;
|
|
1260
|
+
return rest;
|
|
1261
|
+
});
|
|
1262
|
+
};
|
|
1263
|
+
column.getCanResize = () => {
|
|
1264
|
+
var _column$columnDef$ena, _table$options$enable;
|
|
1265
|
+
return ((_column$columnDef$ena = column.columnDef.enableResizing) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableColumnResizing) != null ? _table$options$enable : true);
|
|
1266
|
+
};
|
|
1267
|
+
column.getIsResizing = () => {
|
|
1268
|
+
return table.getState().columnSizingInfo.isResizingColumn === column.id;
|
|
1269
|
+
};
|
|
1270
|
+
},
|
|
1271
|
+
createHeader: (header, table) => {
|
|
1272
|
+
header.getSize = () => {
|
|
1273
|
+
let sum = 0;
|
|
1274
|
+
const recurse = header => {
|
|
1275
|
+
if (header.subHeaders.length) {
|
|
1276
|
+
header.subHeaders.forEach(recurse);
|
|
1277
|
+
} else {
|
|
1278
|
+
var _header$column$getSiz;
|
|
1279
|
+
sum += (_header$column$getSiz = header.column.getSize()) != null ? _header$column$getSiz : 0;
|
|
1280
|
+
}
|
|
1281
|
+
};
|
|
1282
|
+
recurse(header);
|
|
1283
|
+
return sum;
|
|
1284
|
+
};
|
|
1285
|
+
header.getStart = () => {
|
|
1286
|
+
if (header.index > 0) {
|
|
1287
|
+
const prevSiblingHeader = header.headerGroup.headers[header.index - 1];
|
|
1288
|
+
return prevSiblingHeader.getStart() + prevSiblingHeader.getSize();
|
|
1289
|
+
}
|
|
1290
|
+
return 0;
|
|
1291
|
+
};
|
|
1292
|
+
header.getResizeHandler = _contextDocument => {
|
|
1293
|
+
const column = table.getColumn(header.column.id);
|
|
1294
|
+
const canResize = column == null ? void 0 : column.getCanResize();
|
|
1295
|
+
return e => {
|
|
1296
|
+
if (!column || !canResize) {
|
|
1297
|
+
return;
|
|
1298
|
+
}
|
|
1299
|
+
e.persist == null || e.persist();
|
|
1300
|
+
if (isTouchStartEvent(e)) {
|
|
1301
|
+
// lets not respond to multiple touches (e.g. 2 or 3 fingers)
|
|
1302
|
+
if (e.touches && e.touches.length > 1) {
|
|
1303
|
+
return;
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
const startSize = header.getSize();
|
|
1307
|
+
const columnSizingStart = header ? header.getLeafHeaders().map(d => [d.column.id, d.column.getSize()]) : [[column.id, column.getSize()]];
|
|
1308
|
+
const clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
|
|
1309
|
+
const newColumnSizing = {};
|
|
1310
|
+
const updateOffset = (eventType, clientXPos) => {
|
|
1311
|
+
if (typeof clientXPos !== 'number') {
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
table.setColumnSizingInfo(old => {
|
|
1315
|
+
var _old$startOffset, _old$startSize;
|
|
1316
|
+
const deltaDirection = table.options.columnResizeDirection === 'rtl' ? -1 : 1;
|
|
1317
|
+
const deltaOffset = (clientXPos - ((_old$startOffset = old == null ? void 0 : old.startOffset) != null ? _old$startOffset : 0)) * deltaDirection;
|
|
1318
|
+
const deltaPercentage = Math.max(deltaOffset / ((_old$startSize = old == null ? void 0 : old.startSize) != null ? _old$startSize : 0), -0.999999);
|
|
1319
|
+
old.columnSizingStart.forEach(_ref3 => {
|
|
1320
|
+
let [columnId, headerSize] = _ref3;
|
|
1321
|
+
newColumnSizing[columnId] = Math.round(Math.max(headerSize + headerSize * deltaPercentage, 0) * 100) / 100;
|
|
1322
|
+
});
|
|
1323
|
+
return {
|
|
1324
|
+
...old,
|
|
1325
|
+
deltaOffset,
|
|
1326
|
+
deltaPercentage
|
|
1327
|
+
};
|
|
1328
|
+
});
|
|
1329
|
+
if (table.options.columnResizeMode === 'onChange' || eventType === 'end') {
|
|
1330
|
+
table.setColumnSizing(old => ({
|
|
1331
|
+
...old,
|
|
1332
|
+
...newColumnSizing
|
|
1333
|
+
}));
|
|
1334
|
+
}
|
|
1335
|
+
};
|
|
1336
|
+
const onMove = clientXPos => updateOffset('move', clientXPos);
|
|
1337
|
+
const onEnd = clientXPos => {
|
|
1338
|
+
updateOffset('end', clientXPos);
|
|
1339
|
+
table.setColumnSizingInfo(old => ({
|
|
1340
|
+
...old,
|
|
1341
|
+
isResizingColumn: false,
|
|
1342
|
+
startOffset: null,
|
|
1343
|
+
startSize: null,
|
|
1344
|
+
deltaOffset: null,
|
|
1345
|
+
deltaPercentage: null,
|
|
1346
|
+
columnSizingStart: []
|
|
1347
|
+
}));
|
|
1348
|
+
};
|
|
1349
|
+
const contextDocument = safelyAccessDocument(_contextDocument);
|
|
1350
|
+
const mouseEvents = {
|
|
1351
|
+
moveHandler: e => onMove(e.clientX),
|
|
1352
|
+
upHandler: e => {
|
|
1353
|
+
contextDocument == null || contextDocument.removeEventListener('mousemove', mouseEvents.moveHandler);
|
|
1354
|
+
contextDocument == null || contextDocument.removeEventListener('mouseup', mouseEvents.upHandler);
|
|
1355
|
+
onEnd(e.clientX);
|
|
1356
|
+
}
|
|
1357
|
+
};
|
|
1358
|
+
const touchEvents = {
|
|
1359
|
+
moveHandler: e => {
|
|
1360
|
+
if (e.cancelable) {
|
|
1361
|
+
e.preventDefault();
|
|
1362
|
+
e.stopPropagation();
|
|
1363
|
+
}
|
|
1364
|
+
onMove(e.touches[0].clientX);
|
|
1365
|
+
return false;
|
|
1366
|
+
},
|
|
1367
|
+
upHandler: e => {
|
|
1368
|
+
var _e$touches$;
|
|
1369
|
+
contextDocument == null || contextDocument.removeEventListener('touchmove', touchEvents.moveHandler);
|
|
1370
|
+
contextDocument == null || contextDocument.removeEventListener('touchend', touchEvents.upHandler);
|
|
1371
|
+
if (e.cancelable) {
|
|
1372
|
+
e.preventDefault();
|
|
1373
|
+
e.stopPropagation();
|
|
1374
|
+
}
|
|
1375
|
+
onEnd((_e$touches$ = e.touches[0]) == null ? void 0 : _e$touches$.clientX);
|
|
1376
|
+
}
|
|
1377
|
+
};
|
|
1378
|
+
const passiveIfSupported = passiveEventSupported() ? {
|
|
1379
|
+
passive: false
|
|
1380
|
+
} : false;
|
|
1381
|
+
if (isTouchStartEvent(e)) {
|
|
1382
|
+
contextDocument == null || contextDocument.addEventListener('touchmove', touchEvents.moveHandler, passiveIfSupported);
|
|
1383
|
+
contextDocument == null || contextDocument.addEventListener('touchend', touchEvents.upHandler, passiveIfSupported);
|
|
1384
|
+
} else {
|
|
1385
|
+
contextDocument == null || contextDocument.addEventListener('mousemove', mouseEvents.moveHandler, passiveIfSupported);
|
|
1386
|
+
contextDocument == null || contextDocument.addEventListener('mouseup', mouseEvents.upHandler, passiveIfSupported);
|
|
1387
|
+
}
|
|
1388
|
+
table.setColumnSizingInfo(old => ({
|
|
1389
|
+
...old,
|
|
1390
|
+
startOffset: clientX,
|
|
1391
|
+
startSize,
|
|
1392
|
+
deltaOffset: 0,
|
|
1393
|
+
deltaPercentage: 0,
|
|
1394
|
+
columnSizingStart,
|
|
1395
|
+
isResizingColumn: column.id
|
|
1396
|
+
}));
|
|
1397
|
+
};
|
|
1398
|
+
};
|
|
1399
|
+
},
|
|
1400
|
+
createTable: table => {
|
|
1401
|
+
table.setColumnSizing = updater => table.options.onColumnSizingChange == null ? void 0 : table.options.onColumnSizingChange(updater);
|
|
1402
|
+
table.setColumnSizingInfo = updater => table.options.onColumnSizingInfoChange == null ? void 0 : table.options.onColumnSizingInfoChange(updater);
|
|
1403
|
+
table.resetColumnSizing = defaultState => {
|
|
1404
|
+
var _table$initialState$c;
|
|
1405
|
+
table.setColumnSizing(defaultState ? {} : (_table$initialState$c = table.initialState.columnSizing) != null ? _table$initialState$c : {});
|
|
1406
|
+
};
|
|
1407
|
+
table.resetHeaderSizeInfo = defaultState => {
|
|
1408
|
+
var _table$initialState$c2;
|
|
1409
|
+
table.setColumnSizingInfo(defaultState ? getDefaultColumnSizingInfoState() : (_table$initialState$c2 = table.initialState.columnSizingInfo) != null ? _table$initialState$c2 : getDefaultColumnSizingInfoState());
|
|
1410
|
+
};
|
|
1411
|
+
table.getTotalSize = () => {
|
|
1412
|
+
var _table$getHeaderGroup, _table$getHeaderGroup2;
|
|
1413
|
+
return (_table$getHeaderGroup = (_table$getHeaderGroup2 = table.getHeaderGroups()[0]) == null ? void 0 : _table$getHeaderGroup2.headers.reduce((sum, header) => {
|
|
1414
|
+
return sum + header.getSize();
|
|
1415
|
+
}, 0)) != null ? _table$getHeaderGroup : 0;
|
|
1416
|
+
};
|
|
1417
|
+
table.getLeftTotalSize = () => {
|
|
1418
|
+
var _table$getLeftHeaderG, _table$getLeftHeaderG2;
|
|
1419
|
+
return (_table$getLeftHeaderG = (_table$getLeftHeaderG2 = table.getLeftHeaderGroups()[0]) == null ? void 0 : _table$getLeftHeaderG2.headers.reduce((sum, header) => {
|
|
1420
|
+
return sum + header.getSize();
|
|
1421
|
+
}, 0)) != null ? _table$getLeftHeaderG : 0;
|
|
1422
|
+
};
|
|
1423
|
+
table.getCenterTotalSize = () => {
|
|
1424
|
+
var _table$getCenterHeade, _table$getCenterHeade2;
|
|
1425
|
+
return (_table$getCenterHeade = (_table$getCenterHeade2 = table.getCenterHeaderGroups()[0]) == null ? void 0 : _table$getCenterHeade2.headers.reduce((sum, header) => {
|
|
1426
|
+
return sum + header.getSize();
|
|
1427
|
+
}, 0)) != null ? _table$getCenterHeade : 0;
|
|
1428
|
+
};
|
|
1429
|
+
table.getRightTotalSize = () => {
|
|
1430
|
+
var _table$getRightHeader, _table$getRightHeader2;
|
|
1431
|
+
return (_table$getRightHeader = (_table$getRightHeader2 = table.getRightHeaderGroups()[0]) == null ? void 0 : _table$getRightHeader2.headers.reduce((sum, header) => {
|
|
1432
|
+
return sum + header.getSize();
|
|
1433
|
+
}, 0)) != null ? _table$getRightHeader : 0;
|
|
1434
|
+
};
|
|
1435
|
+
}
|
|
1436
|
+
};
|
|
1437
|
+
let passiveSupported = null;
|
|
1438
|
+
function passiveEventSupported() {
|
|
1439
|
+
if (typeof passiveSupported === 'boolean') return passiveSupported;
|
|
1440
|
+
let supported = false;
|
|
1441
|
+
try {
|
|
1442
|
+
const options = {
|
|
1443
|
+
get passive() {
|
|
1444
|
+
supported = true;
|
|
1445
|
+
return false;
|
|
1446
|
+
}
|
|
1447
|
+
};
|
|
1448
|
+
const noop = () => {};
|
|
1449
|
+
window.addEventListener('test', noop, options);
|
|
1450
|
+
window.removeEventListener('test', noop);
|
|
1451
|
+
} catch (err) {
|
|
1452
|
+
supported = false;
|
|
1453
|
+
}
|
|
1454
|
+
passiveSupported = supported;
|
|
1455
|
+
return passiveSupported;
|
|
1456
|
+
}
|
|
1457
|
+
function isTouchStartEvent(e) {
|
|
1458
|
+
return e.type === 'touchstart';
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
//
|
|
1462
|
+
|
|
1463
|
+
const ColumnVisibility = {
|
|
1464
|
+
getInitialState: state => {
|
|
1465
|
+
return {
|
|
1466
|
+
columnVisibility: {},
|
|
1467
|
+
...state
|
|
1468
|
+
};
|
|
1469
|
+
},
|
|
1470
|
+
getDefaultOptions: table => {
|
|
1471
|
+
return {
|
|
1472
|
+
onColumnVisibilityChange: makeStateUpdater('columnVisibility', table)
|
|
1473
|
+
};
|
|
1474
|
+
},
|
|
1475
|
+
createColumn: (column, table) => {
|
|
1476
|
+
column.toggleVisibility = value => {
|
|
1477
|
+
if (column.getCanHide()) {
|
|
1478
|
+
table.setColumnVisibility(old => ({
|
|
1479
|
+
...old,
|
|
1480
|
+
[column.id]: value != null ? value : !column.getIsVisible()
|
|
1481
|
+
}));
|
|
1482
|
+
}
|
|
1483
|
+
};
|
|
1484
|
+
column.getIsVisible = () => {
|
|
1485
|
+
var _ref, _table$getState$colum;
|
|
1486
|
+
const childColumns = column.columns;
|
|
1487
|
+
return (_ref = childColumns.length ? childColumns.some(c => c.getIsVisible()) : (_table$getState$colum = table.getState().columnVisibility) == null ? void 0 : _table$getState$colum[column.id]) != null ? _ref : true;
|
|
1488
|
+
};
|
|
1489
|
+
column.getCanHide = () => {
|
|
1490
|
+
var _column$columnDef$ena, _table$options$enable;
|
|
1491
|
+
return ((_column$columnDef$ena = column.columnDef.enableHiding) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableHiding) != null ? _table$options$enable : true);
|
|
1492
|
+
};
|
|
1493
|
+
column.getToggleVisibilityHandler = () => {
|
|
1494
|
+
return e => {
|
|
1495
|
+
column.toggleVisibility == null || column.toggleVisibility(e.target.checked);
|
|
1496
|
+
};
|
|
1497
|
+
};
|
|
1498
|
+
},
|
|
1499
|
+
createRow: (row, table) => {
|
|
1500
|
+
row._getAllVisibleCells = memo(() => [row.getAllCells(), table.getState().columnVisibility], cells => {
|
|
1501
|
+
return cells.filter(cell => cell.column.getIsVisible());
|
|
1502
|
+
}, getMemoOptions(table.options, 'debugRows'));
|
|
1503
|
+
row.getVisibleCells = memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], getMemoOptions(table.options, 'debugRows'));
|
|
1504
|
+
},
|
|
1505
|
+
createTable: table => {
|
|
1506
|
+
const makeVisibleColumnsMethod = (key, getColumns) => {
|
|
1507
|
+
return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
|
|
1508
|
+
return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
|
|
1509
|
+
}, getMemoOptions(table.options, 'debugColumns'));
|
|
1510
|
+
};
|
|
1511
|
+
table.getVisibleFlatColumns = makeVisibleColumnsMethod('getVisibleFlatColumns', () => table.getAllFlatColumns());
|
|
1512
|
+
table.getVisibleLeafColumns = makeVisibleColumnsMethod('getVisibleLeafColumns', () => table.getAllLeafColumns());
|
|
1513
|
+
table.getLeftVisibleLeafColumns = makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => table.getLeftLeafColumns());
|
|
1514
|
+
table.getRightVisibleLeafColumns = makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => table.getRightLeafColumns());
|
|
1515
|
+
table.getCenterVisibleLeafColumns = makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => table.getCenterLeafColumns());
|
|
1516
|
+
table.setColumnVisibility = updater => table.options.onColumnVisibilityChange == null ? void 0 : table.options.onColumnVisibilityChange(updater);
|
|
1517
|
+
table.resetColumnVisibility = defaultState => {
|
|
1518
|
+
var _table$initialState$c;
|
|
1519
|
+
table.setColumnVisibility(defaultState ? {} : (_table$initialState$c = table.initialState.columnVisibility) != null ? _table$initialState$c : {});
|
|
1520
|
+
};
|
|
1521
|
+
table.toggleAllColumnsVisible = value => {
|
|
1522
|
+
var _value;
|
|
1523
|
+
value = (_value = value) != null ? _value : !table.getIsAllColumnsVisible();
|
|
1524
|
+
table.setColumnVisibility(table.getAllLeafColumns().reduce((obj, column) => ({
|
|
1525
|
+
...obj,
|
|
1526
|
+
[column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
|
|
1527
|
+
}), {}));
|
|
1528
|
+
};
|
|
1529
|
+
table.getIsAllColumnsVisible = () => !table.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible()));
|
|
1530
|
+
table.getIsSomeColumnsVisible = () => table.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible());
|
|
1531
|
+
table.getToggleAllColumnsVisibilityHandler = () => {
|
|
1532
|
+
return e => {
|
|
1533
|
+
var _target;
|
|
1534
|
+
table.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
|
|
1535
|
+
};
|
|
1536
|
+
};
|
|
1537
|
+
}
|
|
1538
|
+
};
|
|
1539
|
+
function _getVisibleLeafColumns(table, position) {
|
|
1540
|
+
return !position ? table.getVisibleLeafColumns() : position === 'center' ? table.getCenterVisibleLeafColumns() : position === 'left' ? table.getLeftVisibleLeafColumns() : table.getRightVisibleLeafColumns();
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
//
|
|
1544
|
+
|
|
1545
|
+
const GlobalFaceting = {
|
|
1546
|
+
createTable: table => {
|
|
1547
|
+
table._getGlobalFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, '__global__');
|
|
1548
|
+
table.getGlobalFacetedRowModel = () => {
|
|
1549
|
+
if (table.options.manualFiltering || !table._getGlobalFacetedRowModel) {
|
|
1550
|
+
return table.getPreFilteredRowModel();
|
|
1551
|
+
}
|
|
1552
|
+
return table._getGlobalFacetedRowModel();
|
|
1553
|
+
};
|
|
1554
|
+
table._getGlobalFacetedUniqueValues = table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, '__global__');
|
|
1555
|
+
table.getGlobalFacetedUniqueValues = () => {
|
|
1556
|
+
if (!table._getGlobalFacetedUniqueValues) {
|
|
1557
|
+
return new Map();
|
|
1558
|
+
}
|
|
1559
|
+
return table._getGlobalFacetedUniqueValues();
|
|
1560
|
+
};
|
|
1561
|
+
table._getGlobalFacetedMinMaxValues = table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, '__global__');
|
|
1562
|
+
table.getGlobalFacetedMinMaxValues = () => {
|
|
1563
|
+
if (!table._getGlobalFacetedMinMaxValues) {
|
|
1564
|
+
return;
|
|
1565
|
+
}
|
|
1566
|
+
return table._getGlobalFacetedMinMaxValues();
|
|
1567
|
+
};
|
|
1568
|
+
}
|
|
1569
|
+
};
|
|
1570
|
+
|
|
1571
|
+
//
|
|
1572
|
+
|
|
1573
|
+
const GlobalFiltering = {
|
|
1574
|
+
getInitialState: state => {
|
|
1575
|
+
return {
|
|
1576
|
+
globalFilter: undefined,
|
|
1577
|
+
...state
|
|
1578
|
+
};
|
|
1579
|
+
},
|
|
1580
|
+
getDefaultOptions: table => {
|
|
1581
|
+
return {
|
|
1582
|
+
onGlobalFilterChange: makeStateUpdater('globalFilter', table),
|
|
1583
|
+
globalFilterFn: 'auto',
|
|
1584
|
+
getColumnCanGlobalFilter: column => {
|
|
1585
|
+
var _table$getCoreRowMode;
|
|
1586
|
+
const value = (_table$getCoreRowMode = table.getCoreRowModel().flatRows[0]) == null || (_table$getCoreRowMode = _table$getCoreRowMode._getAllCellsByColumnId()[column.id]) == null ? void 0 : _table$getCoreRowMode.getValue();
|
|
1587
|
+
return typeof value === 'string' || typeof value === 'number';
|
|
1588
|
+
}
|
|
1589
|
+
};
|
|
1590
|
+
},
|
|
1591
|
+
createColumn: (column, table) => {
|
|
1592
|
+
column.getCanGlobalFilter = () => {
|
|
1593
|
+
var _column$columnDef$ena, _table$options$enable, _table$options$enable2, _table$options$getCol;
|
|
1594
|
+
return ((_column$columnDef$ena = column.columnDef.enableGlobalFilter) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableGlobalFilter) != null ? _table$options$enable : true) && ((_table$options$enable2 = table.options.enableFilters) != null ? _table$options$enable2 : true) && ((_table$options$getCol = table.options.getColumnCanGlobalFilter == null ? void 0 : table.options.getColumnCanGlobalFilter(column)) != null ? _table$options$getCol : true) && !!column.accessorFn;
|
|
1595
|
+
};
|
|
1596
|
+
},
|
|
1597
|
+
createTable: table => {
|
|
1598
|
+
table.getGlobalAutoFilterFn = () => {
|
|
1599
|
+
return filterFns.includesString;
|
|
1600
|
+
};
|
|
1601
|
+
table.getGlobalFilterFn = () => {
|
|
1602
|
+
var _table$options$filter, _table$options$filter2;
|
|
1603
|
+
const {
|
|
1604
|
+
globalFilterFn: globalFilterFn
|
|
1605
|
+
} = table.options;
|
|
1606
|
+
return isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === 'auto' ? table.getGlobalAutoFilterFn() : (_table$options$filter = (_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[globalFilterFn]) != null ? _table$options$filter : filterFns[globalFilterFn];
|
|
1607
|
+
};
|
|
1608
|
+
table.setGlobalFilter = updater => {
|
|
1609
|
+
table.options.onGlobalFilterChange == null || table.options.onGlobalFilterChange(updater);
|
|
1610
|
+
};
|
|
1611
|
+
table.resetGlobalFilter = defaultState => {
|
|
1612
|
+
table.setGlobalFilter(defaultState ? undefined : table.initialState.globalFilter);
|
|
1613
|
+
};
|
|
1614
|
+
}
|
|
1615
|
+
};
|
|
1616
|
+
|
|
1617
|
+
//
|
|
1618
|
+
|
|
1619
|
+
const RowExpanding = {
|
|
1620
|
+
getInitialState: state => {
|
|
1621
|
+
return {
|
|
1622
|
+
expanded: {},
|
|
1623
|
+
...state
|
|
1624
|
+
};
|
|
1625
|
+
},
|
|
1626
|
+
getDefaultOptions: table => {
|
|
1627
|
+
return {
|
|
1628
|
+
onExpandedChange: makeStateUpdater('expanded', table),
|
|
1629
|
+
paginateExpandedRows: true
|
|
1630
|
+
};
|
|
1631
|
+
},
|
|
1632
|
+
createTable: table => {
|
|
1633
|
+
let registered = false;
|
|
1634
|
+
let queued = false;
|
|
1635
|
+
table._autoResetExpanded = () => {
|
|
1636
|
+
var _ref, _table$options$autoRe;
|
|
1637
|
+
if (!registered) {
|
|
1638
|
+
table._queue(() => {
|
|
1639
|
+
registered = true;
|
|
1640
|
+
});
|
|
1641
|
+
return;
|
|
1642
|
+
}
|
|
1643
|
+
if ((_ref = (_table$options$autoRe = table.options.autoResetAll) != null ? _table$options$autoRe : table.options.autoResetExpanded) != null ? _ref : !table.options.manualExpanding) {
|
|
1644
|
+
if (queued) return;
|
|
1645
|
+
queued = true;
|
|
1646
|
+
table._queue(() => {
|
|
1647
|
+
table.resetExpanded();
|
|
1648
|
+
queued = false;
|
|
1649
|
+
});
|
|
1650
|
+
}
|
|
1651
|
+
};
|
|
1652
|
+
table.setExpanded = updater => table.options.onExpandedChange == null ? void 0 : table.options.onExpandedChange(updater);
|
|
1653
|
+
table.toggleAllRowsExpanded = expanded => {
|
|
1654
|
+
if (expanded != null ? expanded : !table.getIsAllRowsExpanded()) {
|
|
1655
|
+
table.setExpanded(true);
|
|
1656
|
+
} else {
|
|
1657
|
+
table.setExpanded({});
|
|
1658
|
+
}
|
|
1659
|
+
};
|
|
1660
|
+
table.resetExpanded = defaultState => {
|
|
1661
|
+
var _table$initialState$e, _table$initialState;
|
|
1662
|
+
table.setExpanded(defaultState ? {} : (_table$initialState$e = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.expanded) != null ? _table$initialState$e : {});
|
|
1663
|
+
};
|
|
1664
|
+
table.getCanSomeRowsExpand = () => {
|
|
1665
|
+
return table.getPrePaginationRowModel().flatRows.some(row => row.getCanExpand());
|
|
1666
|
+
};
|
|
1667
|
+
table.getToggleAllRowsExpandedHandler = () => {
|
|
1668
|
+
return e => {
|
|
1669
|
+
e.persist == null || e.persist();
|
|
1670
|
+
table.toggleAllRowsExpanded();
|
|
1671
|
+
};
|
|
1672
|
+
};
|
|
1673
|
+
table.getIsSomeRowsExpanded = () => {
|
|
1674
|
+
const expanded = table.getState().expanded;
|
|
1675
|
+
return expanded === true || Object.values(expanded).some(Boolean);
|
|
1676
|
+
};
|
|
1677
|
+
table.getIsAllRowsExpanded = () => {
|
|
1678
|
+
const expanded = table.getState().expanded;
|
|
1679
|
+
|
|
1680
|
+
// If expanded is true, save some cycles and return true
|
|
1681
|
+
if (typeof expanded === 'boolean') {
|
|
1682
|
+
return expanded === true;
|
|
1683
|
+
}
|
|
1684
|
+
if (!Object.keys(expanded).length) {
|
|
1685
|
+
return false;
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
// If any row is not expanded, return false
|
|
1689
|
+
if (table.getRowModel().flatRows.some(row => !row.getIsExpanded())) {
|
|
1690
|
+
return false;
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
// They must all be expanded :shrug:
|
|
1694
|
+
return true;
|
|
1695
|
+
};
|
|
1696
|
+
table.getExpandedDepth = () => {
|
|
1697
|
+
let maxDepth = 0;
|
|
1698
|
+
const rowIds = table.getState().expanded === true ? Object.keys(table.getRowModel().rowsById) : Object.keys(table.getState().expanded);
|
|
1699
|
+
rowIds.forEach(id => {
|
|
1700
|
+
const splitId = id.split('.');
|
|
1701
|
+
maxDepth = Math.max(maxDepth, splitId.length);
|
|
1702
|
+
});
|
|
1703
|
+
return maxDepth;
|
|
1704
|
+
};
|
|
1705
|
+
table.getPreExpandedRowModel = () => table.getSortedRowModel();
|
|
1706
|
+
table.getExpandedRowModel = () => {
|
|
1707
|
+
if (!table._getExpandedRowModel && table.options.getExpandedRowModel) {
|
|
1708
|
+
table._getExpandedRowModel = table.options.getExpandedRowModel(table);
|
|
1709
|
+
}
|
|
1710
|
+
if (table.options.manualExpanding || !table._getExpandedRowModel) {
|
|
1711
|
+
return table.getPreExpandedRowModel();
|
|
1712
|
+
}
|
|
1713
|
+
return table._getExpandedRowModel();
|
|
1714
|
+
};
|
|
1715
|
+
},
|
|
1716
|
+
createRow: (row, table) => {
|
|
1717
|
+
row.toggleExpanded = expanded => {
|
|
1718
|
+
table.setExpanded(old => {
|
|
1719
|
+
var _expanded;
|
|
1720
|
+
const exists = old === true ? true : !!(old != null && old[row.id]);
|
|
1721
|
+
let oldExpanded = {};
|
|
1722
|
+
if (old === true) {
|
|
1723
|
+
Object.keys(table.getRowModel().rowsById).forEach(rowId => {
|
|
1724
|
+
oldExpanded[rowId] = true;
|
|
1725
|
+
});
|
|
1726
|
+
} else {
|
|
1727
|
+
oldExpanded = old;
|
|
1728
|
+
}
|
|
1729
|
+
expanded = (_expanded = expanded) != null ? _expanded : !exists;
|
|
1730
|
+
if (!exists && expanded) {
|
|
1731
|
+
return {
|
|
1732
|
+
...oldExpanded,
|
|
1733
|
+
[row.id]: true
|
|
1734
|
+
};
|
|
1735
|
+
}
|
|
1736
|
+
if (exists && !expanded) {
|
|
1737
|
+
const {
|
|
1738
|
+
[row.id]: _,
|
|
1739
|
+
...rest
|
|
1740
|
+
} = oldExpanded;
|
|
1741
|
+
return rest;
|
|
1742
|
+
}
|
|
1743
|
+
return old;
|
|
1744
|
+
});
|
|
1745
|
+
};
|
|
1746
|
+
row.getIsExpanded = () => {
|
|
1747
|
+
var _table$options$getIsR;
|
|
1748
|
+
const expanded = table.getState().expanded;
|
|
1749
|
+
return !!((_table$options$getIsR = table.options.getIsRowExpanded == null ? void 0 : table.options.getIsRowExpanded(row)) != null ? _table$options$getIsR : expanded === true || (expanded == null ? void 0 : expanded[row.id]));
|
|
1750
|
+
};
|
|
1751
|
+
row.getCanExpand = () => {
|
|
1752
|
+
var _table$options$getRow, _table$options$enable, _row$subRows;
|
|
1753
|
+
return (_table$options$getRow = table.options.getRowCanExpand == null ? void 0 : table.options.getRowCanExpand(row)) != null ? _table$options$getRow : ((_table$options$enable = table.options.enableExpanding) != null ? _table$options$enable : true) && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
|
|
1754
|
+
};
|
|
1755
|
+
row.getIsAllParentsExpanded = () => {
|
|
1756
|
+
let isFullyExpanded = true;
|
|
1757
|
+
let currentRow = row;
|
|
1758
|
+
while (isFullyExpanded && currentRow.parentId) {
|
|
1759
|
+
currentRow = table.getRow(currentRow.parentId, true);
|
|
1760
|
+
isFullyExpanded = currentRow.getIsExpanded();
|
|
1761
|
+
}
|
|
1762
|
+
return isFullyExpanded;
|
|
1763
|
+
};
|
|
1764
|
+
row.getToggleExpandedHandler = () => {
|
|
1765
|
+
const canExpand = row.getCanExpand();
|
|
1766
|
+
return () => {
|
|
1767
|
+
if (!canExpand) return;
|
|
1768
|
+
row.toggleExpanded();
|
|
1769
|
+
};
|
|
1770
|
+
};
|
|
1771
|
+
}
|
|
1772
|
+
};
|
|
1773
|
+
|
|
1774
|
+
//
|
|
1775
|
+
|
|
1776
|
+
const defaultPageIndex = 0;
|
|
1777
|
+
const defaultPageSize = 10;
|
|
1778
|
+
const getDefaultPaginationState = () => ({
|
|
1779
|
+
pageIndex: defaultPageIndex,
|
|
1780
|
+
pageSize: defaultPageSize
|
|
1781
|
+
});
|
|
1782
|
+
const RowPagination = {
|
|
1783
|
+
getInitialState: state => {
|
|
1784
|
+
return {
|
|
1785
|
+
...state,
|
|
1786
|
+
pagination: {
|
|
1787
|
+
...getDefaultPaginationState(),
|
|
1788
|
+
...(state == null ? void 0 : state.pagination)
|
|
1789
|
+
}
|
|
1790
|
+
};
|
|
1791
|
+
},
|
|
1792
|
+
getDefaultOptions: table => {
|
|
1793
|
+
return {
|
|
1794
|
+
onPaginationChange: makeStateUpdater('pagination', table)
|
|
1795
|
+
};
|
|
1796
|
+
},
|
|
1797
|
+
createTable: table => {
|
|
1798
|
+
let registered = false;
|
|
1799
|
+
let queued = false;
|
|
1800
|
+
table._autoResetPageIndex = () => {
|
|
1801
|
+
var _ref, _table$options$autoRe;
|
|
1802
|
+
if (!registered) {
|
|
1803
|
+
table._queue(() => {
|
|
1804
|
+
registered = true;
|
|
1805
|
+
});
|
|
1806
|
+
return;
|
|
1807
|
+
}
|
|
1808
|
+
if ((_ref = (_table$options$autoRe = table.options.autoResetAll) != null ? _table$options$autoRe : table.options.autoResetPageIndex) != null ? _ref : !table.options.manualPagination) {
|
|
1809
|
+
if (queued) return;
|
|
1810
|
+
queued = true;
|
|
1811
|
+
table._queue(() => {
|
|
1812
|
+
table.resetPageIndex();
|
|
1813
|
+
queued = false;
|
|
1814
|
+
});
|
|
1815
|
+
}
|
|
1816
|
+
};
|
|
1817
|
+
table.setPagination = updater => {
|
|
1818
|
+
const safeUpdater = old => {
|
|
1819
|
+
let newState = functionalUpdate(updater, old);
|
|
1820
|
+
return newState;
|
|
1821
|
+
};
|
|
1822
|
+
return table.options.onPaginationChange == null ? void 0 : table.options.onPaginationChange(safeUpdater);
|
|
1823
|
+
};
|
|
1824
|
+
table.resetPagination = defaultState => {
|
|
1825
|
+
var _table$initialState$p;
|
|
1826
|
+
table.setPagination(defaultState ? getDefaultPaginationState() : (_table$initialState$p = table.initialState.pagination) != null ? _table$initialState$p : getDefaultPaginationState());
|
|
1827
|
+
};
|
|
1828
|
+
table.setPageIndex = updater => {
|
|
1829
|
+
table.setPagination(old => {
|
|
1830
|
+
let pageIndex = functionalUpdate(updater, old.pageIndex);
|
|
1831
|
+
const maxPageIndex = typeof table.options.pageCount === 'undefined' || table.options.pageCount === -1 ? Number.MAX_SAFE_INTEGER : table.options.pageCount - 1;
|
|
1832
|
+
pageIndex = Math.max(0, Math.min(pageIndex, maxPageIndex));
|
|
1833
|
+
return {
|
|
1834
|
+
...old,
|
|
1835
|
+
pageIndex
|
|
1836
|
+
};
|
|
1837
|
+
});
|
|
1838
|
+
};
|
|
1839
|
+
table.resetPageIndex = defaultState => {
|
|
1840
|
+
var _table$initialState$p2, _table$initialState;
|
|
1841
|
+
table.setPageIndex(defaultState ? defaultPageIndex : (_table$initialState$p2 = (_table$initialState = table.initialState) == null || (_table$initialState = _table$initialState.pagination) == null ? void 0 : _table$initialState.pageIndex) != null ? _table$initialState$p2 : defaultPageIndex);
|
|
1842
|
+
};
|
|
1843
|
+
table.resetPageSize = defaultState => {
|
|
1844
|
+
var _table$initialState$p3, _table$initialState2;
|
|
1845
|
+
table.setPageSize(defaultState ? defaultPageSize : (_table$initialState$p3 = (_table$initialState2 = table.initialState) == null || (_table$initialState2 = _table$initialState2.pagination) == null ? void 0 : _table$initialState2.pageSize) != null ? _table$initialState$p3 : defaultPageSize);
|
|
1846
|
+
};
|
|
1847
|
+
table.setPageSize = updater => {
|
|
1848
|
+
table.setPagination(old => {
|
|
1849
|
+
const pageSize = Math.max(1, functionalUpdate(updater, old.pageSize));
|
|
1850
|
+
const topRowIndex = old.pageSize * old.pageIndex;
|
|
1851
|
+
const pageIndex = Math.floor(topRowIndex / pageSize);
|
|
1852
|
+
return {
|
|
1853
|
+
...old,
|
|
1854
|
+
pageIndex,
|
|
1855
|
+
pageSize
|
|
1856
|
+
};
|
|
1857
|
+
});
|
|
1858
|
+
};
|
|
1859
|
+
//deprecated
|
|
1860
|
+
table.setPageCount = updater => table.setPagination(old => {
|
|
1861
|
+
var _table$options$pageCo;
|
|
1862
|
+
let newPageCount = functionalUpdate(updater, (_table$options$pageCo = table.options.pageCount) != null ? _table$options$pageCo : -1);
|
|
1863
|
+
if (typeof newPageCount === 'number') {
|
|
1864
|
+
newPageCount = Math.max(-1, newPageCount);
|
|
1865
|
+
}
|
|
1866
|
+
return {
|
|
1867
|
+
...old,
|
|
1868
|
+
pageCount: newPageCount
|
|
1869
|
+
};
|
|
1870
|
+
});
|
|
1871
|
+
table.getPageOptions = memo(() => [table.getPageCount()], pageCount => {
|
|
1872
|
+
let pageOptions = [];
|
|
1873
|
+
if (pageCount && pageCount > 0) {
|
|
1874
|
+
pageOptions = [...new Array(pageCount)].fill(null).map((_, i) => i);
|
|
1875
|
+
}
|
|
1876
|
+
return pageOptions;
|
|
1877
|
+
}, getMemoOptions(table.options, 'debugTable'));
|
|
1878
|
+
table.getCanPreviousPage = () => table.getState().pagination.pageIndex > 0;
|
|
1879
|
+
table.getCanNextPage = () => {
|
|
1880
|
+
const {
|
|
1881
|
+
pageIndex
|
|
1882
|
+
} = table.getState().pagination;
|
|
1883
|
+
const pageCount = table.getPageCount();
|
|
1884
|
+
if (pageCount === -1) {
|
|
1885
|
+
return true;
|
|
1886
|
+
}
|
|
1887
|
+
if (pageCount === 0) {
|
|
1888
|
+
return false;
|
|
1889
|
+
}
|
|
1890
|
+
return pageIndex < pageCount - 1;
|
|
1891
|
+
};
|
|
1892
|
+
table.previousPage = () => {
|
|
1893
|
+
return table.setPageIndex(old => old - 1);
|
|
1894
|
+
};
|
|
1895
|
+
table.nextPage = () => {
|
|
1896
|
+
return table.setPageIndex(old => {
|
|
1897
|
+
return old + 1;
|
|
1898
|
+
});
|
|
1899
|
+
};
|
|
1900
|
+
table.firstPage = () => {
|
|
1901
|
+
return table.setPageIndex(0);
|
|
1902
|
+
};
|
|
1903
|
+
table.lastPage = () => {
|
|
1904
|
+
return table.setPageIndex(table.getPageCount() - 1);
|
|
1905
|
+
};
|
|
1906
|
+
table.getPrePaginationRowModel = () => table.getExpandedRowModel();
|
|
1907
|
+
table.getPaginationRowModel = () => {
|
|
1908
|
+
if (!table._getPaginationRowModel && table.options.getPaginationRowModel) {
|
|
1909
|
+
table._getPaginationRowModel = table.options.getPaginationRowModel(table);
|
|
1910
|
+
}
|
|
1911
|
+
if (table.options.manualPagination || !table._getPaginationRowModel) {
|
|
1912
|
+
return table.getPrePaginationRowModel();
|
|
1913
|
+
}
|
|
1914
|
+
return table._getPaginationRowModel();
|
|
1915
|
+
};
|
|
1916
|
+
table.getPageCount = () => {
|
|
1917
|
+
var _table$options$pageCo2;
|
|
1918
|
+
return (_table$options$pageCo2 = table.options.pageCount) != null ? _table$options$pageCo2 : Math.ceil(table.getRowCount() / table.getState().pagination.pageSize);
|
|
1919
|
+
};
|
|
1920
|
+
table.getRowCount = () => {
|
|
1921
|
+
var _table$options$rowCou;
|
|
1922
|
+
return (_table$options$rowCou = table.options.rowCount) != null ? _table$options$rowCou : table.getPrePaginationRowModel().rows.length;
|
|
1923
|
+
};
|
|
1924
|
+
}
|
|
1925
|
+
};
|
|
1926
|
+
|
|
1927
|
+
//
|
|
1928
|
+
|
|
1929
|
+
const getDefaultRowPinningState = () => ({
|
|
1930
|
+
top: [],
|
|
1931
|
+
bottom: []
|
|
1932
|
+
});
|
|
1933
|
+
const RowPinning = {
|
|
1934
|
+
getInitialState: state => {
|
|
1935
|
+
return {
|
|
1936
|
+
rowPinning: getDefaultRowPinningState(),
|
|
1937
|
+
...state
|
|
1938
|
+
};
|
|
1939
|
+
},
|
|
1940
|
+
getDefaultOptions: table => {
|
|
1941
|
+
return {
|
|
1942
|
+
onRowPinningChange: makeStateUpdater('rowPinning', table)
|
|
1943
|
+
};
|
|
1944
|
+
},
|
|
1945
|
+
createRow: (row, table) => {
|
|
1946
|
+
row.pin = (position, includeLeafRows, includeParentRows) => {
|
|
1947
|
+
const leafRowIds = includeLeafRows ? row.getLeafRows().map(_ref => {
|
|
1948
|
+
let {
|
|
1949
|
+
id
|
|
1950
|
+
} = _ref;
|
|
1951
|
+
return id;
|
|
1952
|
+
}) : [];
|
|
1953
|
+
const parentRowIds = includeParentRows ? row.getParentRows().map(_ref2 => {
|
|
1954
|
+
let {
|
|
1955
|
+
id
|
|
1956
|
+
} = _ref2;
|
|
1957
|
+
return id;
|
|
1958
|
+
}) : [];
|
|
1959
|
+
const rowIds = new Set([...parentRowIds, row.id, ...leafRowIds]);
|
|
1960
|
+
table.setRowPinning(old => {
|
|
1961
|
+
var _old$top3, _old$bottom3;
|
|
1962
|
+
if (position === 'bottom') {
|
|
1963
|
+
var _old$top, _old$bottom;
|
|
1964
|
+
return {
|
|
1965
|
+
top: ((_old$top = old == null ? void 0 : old.top) != null ? _old$top : []).filter(d => !(rowIds != null && rowIds.has(d))),
|
|
1966
|
+
bottom: [...((_old$bottom = old == null ? void 0 : old.bottom) != null ? _old$bottom : []).filter(d => !(rowIds != null && rowIds.has(d))), ...Array.from(rowIds)]
|
|
1967
|
+
};
|
|
1968
|
+
}
|
|
1969
|
+
if (position === 'top') {
|
|
1970
|
+
var _old$top2, _old$bottom2;
|
|
1971
|
+
return {
|
|
1972
|
+
top: [...((_old$top2 = old == null ? void 0 : old.top) != null ? _old$top2 : []).filter(d => !(rowIds != null && rowIds.has(d))), ...Array.from(rowIds)],
|
|
1973
|
+
bottom: ((_old$bottom2 = old == null ? void 0 : old.bottom) != null ? _old$bottom2 : []).filter(d => !(rowIds != null && rowIds.has(d)))
|
|
1974
|
+
};
|
|
1975
|
+
}
|
|
1976
|
+
return {
|
|
1977
|
+
top: ((_old$top3 = old == null ? void 0 : old.top) != null ? _old$top3 : []).filter(d => !(rowIds != null && rowIds.has(d))),
|
|
1978
|
+
bottom: ((_old$bottom3 = old == null ? void 0 : old.bottom) != null ? _old$bottom3 : []).filter(d => !(rowIds != null && rowIds.has(d)))
|
|
1979
|
+
};
|
|
1980
|
+
});
|
|
1981
|
+
};
|
|
1982
|
+
row.getCanPin = () => {
|
|
1983
|
+
var _ref3;
|
|
1984
|
+
const {
|
|
1985
|
+
enableRowPinning,
|
|
1986
|
+
enablePinning
|
|
1987
|
+
} = table.options;
|
|
1988
|
+
if (typeof enableRowPinning === 'function') {
|
|
1989
|
+
return enableRowPinning(row);
|
|
1990
|
+
}
|
|
1991
|
+
return (_ref3 = enableRowPinning != null ? enableRowPinning : enablePinning) != null ? _ref3 : true;
|
|
1992
|
+
};
|
|
1993
|
+
row.getIsPinned = () => {
|
|
1994
|
+
const rowIds = [row.id];
|
|
1995
|
+
const {
|
|
1996
|
+
top,
|
|
1997
|
+
bottom
|
|
1998
|
+
} = table.getState().rowPinning;
|
|
1999
|
+
const isTop = rowIds.some(d => top == null ? void 0 : top.includes(d));
|
|
2000
|
+
const isBottom = rowIds.some(d => bottom == null ? void 0 : bottom.includes(d));
|
|
2001
|
+
return isTop ? 'top' : isBottom ? 'bottom' : false;
|
|
2002
|
+
};
|
|
2003
|
+
row.getPinnedIndex = () => {
|
|
2004
|
+
var _ref4, _visiblePinnedRowIds$;
|
|
2005
|
+
const position = row.getIsPinned();
|
|
2006
|
+
if (!position) return -1;
|
|
2007
|
+
const visiblePinnedRowIds = (_ref4 = position === 'top' ? table.getTopRows() : table.getBottomRows()) == null ? void 0 : _ref4.map(_ref5 => {
|
|
2008
|
+
let {
|
|
2009
|
+
id
|
|
2010
|
+
} = _ref5;
|
|
2011
|
+
return id;
|
|
2012
|
+
});
|
|
2013
|
+
return (_visiblePinnedRowIds$ = visiblePinnedRowIds == null ? void 0 : visiblePinnedRowIds.indexOf(row.id)) != null ? _visiblePinnedRowIds$ : -1;
|
|
2014
|
+
};
|
|
2015
|
+
},
|
|
2016
|
+
createTable: table => {
|
|
2017
|
+
table.setRowPinning = updater => table.options.onRowPinningChange == null ? void 0 : table.options.onRowPinningChange(updater);
|
|
2018
|
+
table.resetRowPinning = defaultState => {
|
|
2019
|
+
var _table$initialState$r, _table$initialState;
|
|
2020
|
+
return table.setRowPinning(defaultState ? getDefaultRowPinningState() : (_table$initialState$r = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.rowPinning) != null ? _table$initialState$r : getDefaultRowPinningState());
|
|
2021
|
+
};
|
|
2022
|
+
table.getIsSomeRowsPinned = position => {
|
|
2023
|
+
var _pinningState$positio;
|
|
2024
|
+
const pinningState = table.getState().rowPinning;
|
|
2025
|
+
if (!position) {
|
|
2026
|
+
var _pinningState$top, _pinningState$bottom;
|
|
2027
|
+
return Boolean(((_pinningState$top = pinningState.top) == null ? void 0 : _pinningState$top.length) || ((_pinningState$bottom = pinningState.bottom) == null ? void 0 : _pinningState$bottom.length));
|
|
2028
|
+
}
|
|
2029
|
+
return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
|
|
2030
|
+
};
|
|
2031
|
+
table._getPinnedRows = (visibleRows, pinnedRowIds, position) => {
|
|
2032
|
+
var _table$options$keepPi;
|
|
2033
|
+
const rows = ((_table$options$keepPi = table.options.keepPinnedRows) != null ? _table$options$keepPi : true) ?
|
|
2034
|
+
//get all rows that are pinned even if they would not be otherwise visible
|
|
2035
|
+
//account for expanded parent rows, but not pagination or filtering
|
|
2036
|
+
(pinnedRowIds != null ? pinnedRowIds : []).map(rowId => {
|
|
2037
|
+
const row = table.getRow(rowId, true);
|
|
2038
|
+
return row.getIsAllParentsExpanded() ? row : null;
|
|
2039
|
+
}) :
|
|
2040
|
+
//else get only visible rows that are pinned
|
|
2041
|
+
(pinnedRowIds != null ? pinnedRowIds : []).map(rowId => visibleRows.find(row => row.id === rowId));
|
|
2042
|
+
return rows.filter(Boolean).map(d => ({
|
|
2043
|
+
...d,
|
|
2044
|
+
position
|
|
2045
|
+
}));
|
|
2046
|
+
};
|
|
2047
|
+
table.getTopRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.top], (allRows, topPinnedRowIds) => table._getPinnedRows(allRows, topPinnedRowIds, 'top'), getMemoOptions(table.options, 'debugRows'));
|
|
2048
|
+
table.getBottomRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.bottom], (allRows, bottomPinnedRowIds) => table._getPinnedRows(allRows, bottomPinnedRowIds, 'bottom'), getMemoOptions(table.options, 'debugRows'));
|
|
2049
|
+
table.getCenterRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.top, table.getState().rowPinning.bottom], (allRows, top, bottom) => {
|
|
2050
|
+
const topAndBottom = new Set([...(top != null ? top : []), ...(bottom != null ? bottom : [])]);
|
|
2051
|
+
return allRows.filter(d => !topAndBottom.has(d.id));
|
|
2052
|
+
}, getMemoOptions(table.options, 'debugRows'));
|
|
2053
|
+
}
|
|
2054
|
+
};
|
|
2055
|
+
|
|
2056
|
+
//
|
|
2057
|
+
|
|
2058
|
+
const RowSelection = {
|
|
2059
|
+
getInitialState: state => {
|
|
2060
|
+
return {
|
|
2061
|
+
rowSelection: {},
|
|
2062
|
+
...state
|
|
2063
|
+
};
|
|
2064
|
+
},
|
|
2065
|
+
getDefaultOptions: table => {
|
|
2066
|
+
return {
|
|
2067
|
+
onRowSelectionChange: makeStateUpdater('rowSelection', table),
|
|
2068
|
+
enableRowSelection: true,
|
|
2069
|
+
enableMultiRowSelection: true,
|
|
2070
|
+
enableSubRowSelection: true
|
|
2071
|
+
// enableGroupingRowSelection: false,
|
|
2072
|
+
// isAdditiveSelectEvent: (e: unknown) => !!e.metaKey,
|
|
2073
|
+
// isInclusiveSelectEvent: (e: unknown) => !!e.shiftKey,
|
|
2074
|
+
};
|
|
2075
|
+
},
|
|
2076
|
+
createTable: table => {
|
|
2077
|
+
table.setRowSelection = updater => table.options.onRowSelectionChange == null ? void 0 : table.options.onRowSelectionChange(updater);
|
|
2078
|
+
table.resetRowSelection = defaultState => {
|
|
2079
|
+
var _table$initialState$r;
|
|
2080
|
+
return table.setRowSelection(defaultState ? {} : (_table$initialState$r = table.initialState.rowSelection) != null ? _table$initialState$r : {});
|
|
2081
|
+
};
|
|
2082
|
+
table.toggleAllRowsSelected = value => {
|
|
2083
|
+
table.setRowSelection(old => {
|
|
2084
|
+
value = typeof value !== 'undefined' ? value : !table.getIsAllRowsSelected();
|
|
2085
|
+
const rowSelection = {
|
|
2086
|
+
...old
|
|
2087
|
+
};
|
|
2088
|
+
const preGroupedFlatRows = table.getPreGroupedRowModel().flatRows;
|
|
2089
|
+
|
|
2090
|
+
// We don't use `mutateRowIsSelected` here for performance reasons.
|
|
2091
|
+
// All of the rows are flat already, so it wouldn't be worth it
|
|
2092
|
+
if (value) {
|
|
2093
|
+
preGroupedFlatRows.forEach(row => {
|
|
2094
|
+
if (!row.getCanSelect()) {
|
|
2095
|
+
return;
|
|
2096
|
+
}
|
|
2097
|
+
rowSelection[row.id] = true;
|
|
2098
|
+
});
|
|
2099
|
+
} else {
|
|
2100
|
+
preGroupedFlatRows.forEach(row => {
|
|
2101
|
+
delete rowSelection[row.id];
|
|
2102
|
+
});
|
|
2103
|
+
}
|
|
2104
|
+
return rowSelection;
|
|
2105
|
+
});
|
|
2106
|
+
};
|
|
2107
|
+
table.toggleAllPageRowsSelected = value => table.setRowSelection(old => {
|
|
2108
|
+
const resolvedValue = typeof value !== 'undefined' ? value : !table.getIsAllPageRowsSelected();
|
|
2109
|
+
const rowSelection = {
|
|
2110
|
+
...old
|
|
2111
|
+
};
|
|
2112
|
+
table.getRowModel().rows.forEach(row => {
|
|
2113
|
+
mutateRowIsSelected(rowSelection, row.id, resolvedValue, true, table);
|
|
2114
|
+
});
|
|
2115
|
+
return rowSelection;
|
|
2116
|
+
});
|
|
2117
|
+
|
|
2118
|
+
// addRowSelectionRange: rowId => {
|
|
2119
|
+
// const {
|
|
2120
|
+
// rows,
|
|
2121
|
+
// rowsById,
|
|
2122
|
+
// options: { selectGroupingRows, selectSubRows },
|
|
2123
|
+
// } = table
|
|
2124
|
+
|
|
2125
|
+
// const findSelectedRow = (rows: Row[]) => {
|
|
2126
|
+
// let found
|
|
2127
|
+
// rows.find(d => {
|
|
2128
|
+
// if (d.getIsSelected()) {
|
|
2129
|
+
// found = d
|
|
2130
|
+
// return true
|
|
2131
|
+
// }
|
|
2132
|
+
// const subFound = findSelectedRow(d.subRows || [])
|
|
2133
|
+
// if (subFound) {
|
|
2134
|
+
// found = subFound
|
|
2135
|
+
// return true
|
|
2136
|
+
// }
|
|
2137
|
+
// return false
|
|
2138
|
+
// })
|
|
2139
|
+
// return found
|
|
2140
|
+
// }
|
|
2141
|
+
|
|
2142
|
+
// const firstRow = findSelectedRow(rows) || rows[0]
|
|
2143
|
+
// const lastRow = rowsById[rowId]
|
|
2144
|
+
|
|
2145
|
+
// let include = false
|
|
2146
|
+
// const selectedRowIds = {}
|
|
2147
|
+
|
|
2148
|
+
// const addRow = (row: Row) => {
|
|
2149
|
+
// mutateRowIsSelected(selectedRowIds, row.id, true, {
|
|
2150
|
+
// rowsById,
|
|
2151
|
+
// selectGroupingRows: selectGroupingRows!,
|
|
2152
|
+
// selectSubRows: selectSubRows!,
|
|
2153
|
+
// })
|
|
2154
|
+
// }
|
|
2155
|
+
|
|
2156
|
+
// table.rows.forEach(row => {
|
|
2157
|
+
// const isFirstRow = row.id === firstRow.id
|
|
2158
|
+
// const isLastRow = row.id === lastRow.id
|
|
2159
|
+
|
|
2160
|
+
// if (isFirstRow || isLastRow) {
|
|
2161
|
+
// if (!include) {
|
|
2162
|
+
// include = true
|
|
2163
|
+
// } else if (include) {
|
|
2164
|
+
// addRow(row)
|
|
2165
|
+
// include = false
|
|
2166
|
+
// }
|
|
2167
|
+
// }
|
|
2168
|
+
|
|
2169
|
+
// if (include) {
|
|
2170
|
+
// addRow(row)
|
|
2171
|
+
// }
|
|
2172
|
+
// })
|
|
2173
|
+
|
|
2174
|
+
// table.setRowSelection(selectedRowIds)
|
|
2175
|
+
// },
|
|
2176
|
+
table.getPreSelectedRowModel = () => table.getCoreRowModel();
|
|
2177
|
+
table.getSelectedRowModel = memo(() => [table.getState().rowSelection, table.getCoreRowModel()], (rowSelection, rowModel) => {
|
|
2178
|
+
if (!Object.keys(rowSelection).length) {
|
|
2179
|
+
return {
|
|
2180
|
+
rows: [],
|
|
2181
|
+
flatRows: [],
|
|
2182
|
+
rowsById: {}
|
|
2183
|
+
};
|
|
2184
|
+
}
|
|
2185
|
+
return selectRowsFn(table, rowModel);
|
|
2186
|
+
}, getMemoOptions(table.options, 'debugTable'));
|
|
2187
|
+
table.getFilteredSelectedRowModel = memo(() => [table.getState().rowSelection, table.getFilteredRowModel()], (rowSelection, rowModel) => {
|
|
2188
|
+
if (!Object.keys(rowSelection).length) {
|
|
2189
|
+
return {
|
|
2190
|
+
rows: [],
|
|
2191
|
+
flatRows: [],
|
|
2192
|
+
rowsById: {}
|
|
2193
|
+
};
|
|
2194
|
+
}
|
|
2195
|
+
return selectRowsFn(table, rowModel);
|
|
2196
|
+
}, getMemoOptions(table.options, 'debugTable'));
|
|
2197
|
+
table.getGroupedSelectedRowModel = memo(() => [table.getState().rowSelection, table.getSortedRowModel()], (rowSelection, rowModel) => {
|
|
2198
|
+
if (!Object.keys(rowSelection).length) {
|
|
2199
|
+
return {
|
|
2200
|
+
rows: [],
|
|
2201
|
+
flatRows: [],
|
|
2202
|
+
rowsById: {}
|
|
2203
|
+
};
|
|
2204
|
+
}
|
|
2205
|
+
return selectRowsFn(table, rowModel);
|
|
2206
|
+
}, getMemoOptions(table.options, 'debugTable'));
|
|
2207
|
+
|
|
2208
|
+
///
|
|
2209
|
+
|
|
2210
|
+
// getGroupingRowCanSelect: rowId => {
|
|
2211
|
+
// const row = table.getRow(rowId)
|
|
2212
|
+
|
|
2213
|
+
// if (!row) {
|
|
2214
|
+
// throw new Error()
|
|
2215
|
+
// }
|
|
2216
|
+
|
|
2217
|
+
// if (typeof table.options.enableGroupingRowSelection === 'function') {
|
|
2218
|
+
// return table.options.enableGroupingRowSelection(row)
|
|
2219
|
+
// }
|
|
2220
|
+
|
|
2221
|
+
// return table.options.enableGroupingRowSelection ?? false
|
|
2222
|
+
// },
|
|
2223
|
+
|
|
2224
|
+
table.getIsAllRowsSelected = () => {
|
|
2225
|
+
const preGroupedFlatRows = table.getFilteredRowModel().flatRows;
|
|
2226
|
+
const {
|
|
2227
|
+
rowSelection
|
|
2228
|
+
} = table.getState();
|
|
2229
|
+
let isAllRowsSelected = Boolean(preGroupedFlatRows.length && Object.keys(rowSelection).length);
|
|
2230
|
+
if (isAllRowsSelected) {
|
|
2231
|
+
if (preGroupedFlatRows.some(row => row.getCanSelect() && !rowSelection[row.id])) {
|
|
2232
|
+
isAllRowsSelected = false;
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
return isAllRowsSelected;
|
|
2236
|
+
};
|
|
2237
|
+
table.getIsAllPageRowsSelected = () => {
|
|
2238
|
+
const paginationFlatRows = table.getPaginationRowModel().flatRows.filter(row => row.getCanSelect());
|
|
2239
|
+
const {
|
|
2240
|
+
rowSelection
|
|
2241
|
+
} = table.getState();
|
|
2242
|
+
let isAllPageRowsSelected = !!paginationFlatRows.length;
|
|
2243
|
+
if (isAllPageRowsSelected && paginationFlatRows.some(row => !rowSelection[row.id])) {
|
|
2244
|
+
isAllPageRowsSelected = false;
|
|
2245
|
+
}
|
|
2246
|
+
return isAllPageRowsSelected;
|
|
2247
|
+
};
|
|
2248
|
+
table.getIsSomeRowsSelected = () => {
|
|
2249
|
+
var _table$getState$rowSe;
|
|
2250
|
+
const totalSelected = Object.keys((_table$getState$rowSe = table.getState().rowSelection) != null ? _table$getState$rowSe : {}).length;
|
|
2251
|
+
return totalSelected > 0 && totalSelected < table.getFilteredRowModel().flatRows.length;
|
|
2252
|
+
};
|
|
2253
|
+
table.getIsSomePageRowsSelected = () => {
|
|
2254
|
+
const paginationFlatRows = table.getPaginationRowModel().flatRows;
|
|
2255
|
+
return table.getIsAllPageRowsSelected() ? false : paginationFlatRows.filter(row => row.getCanSelect()).some(d => d.getIsSelected() || d.getIsSomeSelected());
|
|
2256
|
+
};
|
|
2257
|
+
table.getToggleAllRowsSelectedHandler = () => {
|
|
2258
|
+
return e => {
|
|
2259
|
+
table.toggleAllRowsSelected(e.target.checked);
|
|
2260
|
+
};
|
|
2261
|
+
};
|
|
2262
|
+
table.getToggleAllPageRowsSelectedHandler = () => {
|
|
2263
|
+
return e => {
|
|
2264
|
+
table.toggleAllPageRowsSelected(e.target.checked);
|
|
2265
|
+
};
|
|
2266
|
+
};
|
|
2267
|
+
},
|
|
2268
|
+
createRow: (row, table) => {
|
|
2269
|
+
row.toggleSelected = (value, opts) => {
|
|
2270
|
+
const isSelected = row.getIsSelected();
|
|
2271
|
+
table.setRowSelection(old => {
|
|
2272
|
+
var _opts$selectChildren;
|
|
2273
|
+
value = typeof value !== 'undefined' ? value : !isSelected;
|
|
2274
|
+
if (row.getCanSelect() && isSelected === value) {
|
|
2275
|
+
return old;
|
|
2276
|
+
}
|
|
2277
|
+
const selectedRowIds = {
|
|
2278
|
+
...old
|
|
2279
|
+
};
|
|
2280
|
+
mutateRowIsSelected(selectedRowIds, row.id, value, (_opts$selectChildren = opts == null ? void 0 : opts.selectChildren) != null ? _opts$selectChildren : true, table);
|
|
2281
|
+
return selectedRowIds;
|
|
2282
|
+
});
|
|
2283
|
+
};
|
|
2284
|
+
row.getIsSelected = () => {
|
|
2285
|
+
const {
|
|
2286
|
+
rowSelection
|
|
2287
|
+
} = table.getState();
|
|
2288
|
+
return isRowSelected(row, rowSelection);
|
|
2289
|
+
};
|
|
2290
|
+
row.getIsSomeSelected = () => {
|
|
2291
|
+
const {
|
|
2292
|
+
rowSelection
|
|
2293
|
+
} = table.getState();
|
|
2294
|
+
return isSubRowSelected(row, rowSelection) === 'some';
|
|
2295
|
+
};
|
|
2296
|
+
row.getIsAllSubRowsSelected = () => {
|
|
2297
|
+
const {
|
|
2298
|
+
rowSelection
|
|
2299
|
+
} = table.getState();
|
|
2300
|
+
return isSubRowSelected(row, rowSelection) === 'all';
|
|
2301
|
+
};
|
|
2302
|
+
row.getCanSelect = () => {
|
|
2303
|
+
var _table$options$enable;
|
|
2304
|
+
if (typeof table.options.enableRowSelection === 'function') {
|
|
2305
|
+
return table.options.enableRowSelection(row);
|
|
2306
|
+
}
|
|
2307
|
+
return (_table$options$enable = table.options.enableRowSelection) != null ? _table$options$enable : true;
|
|
2308
|
+
};
|
|
2309
|
+
row.getCanSelectSubRows = () => {
|
|
2310
|
+
var _table$options$enable2;
|
|
2311
|
+
if (typeof table.options.enableSubRowSelection === 'function') {
|
|
2312
|
+
return table.options.enableSubRowSelection(row);
|
|
2313
|
+
}
|
|
2314
|
+
return (_table$options$enable2 = table.options.enableSubRowSelection) != null ? _table$options$enable2 : true;
|
|
2315
|
+
};
|
|
2316
|
+
row.getCanMultiSelect = () => {
|
|
2317
|
+
var _table$options$enable3;
|
|
2318
|
+
if (typeof table.options.enableMultiRowSelection === 'function') {
|
|
2319
|
+
return table.options.enableMultiRowSelection(row);
|
|
2320
|
+
}
|
|
2321
|
+
return (_table$options$enable3 = table.options.enableMultiRowSelection) != null ? _table$options$enable3 : true;
|
|
2322
|
+
};
|
|
2323
|
+
row.getToggleSelectedHandler = () => {
|
|
2324
|
+
const canSelect = row.getCanSelect();
|
|
2325
|
+
return e => {
|
|
2326
|
+
var _target;
|
|
2327
|
+
if (!canSelect) return;
|
|
2328
|
+
row.toggleSelected((_target = e.target) == null ? void 0 : _target.checked);
|
|
2329
|
+
};
|
|
2330
|
+
};
|
|
2331
|
+
}
|
|
2332
|
+
};
|
|
2333
|
+
const mutateRowIsSelected = (selectedRowIds, id, value, includeChildren, table) => {
|
|
2334
|
+
var _row$subRows;
|
|
2335
|
+
const row = table.getRow(id, true);
|
|
2336
|
+
|
|
2337
|
+
// const isGrouped = row.getIsGrouped()
|
|
2338
|
+
|
|
2339
|
+
// if ( // TODO: enforce grouping row selection rules
|
|
2340
|
+
// !isGrouped ||
|
|
2341
|
+
// (isGrouped && table.options.enableGroupingRowSelection)
|
|
2342
|
+
// ) {
|
|
2343
|
+
if (value) {
|
|
2344
|
+
if (!row.getCanMultiSelect()) {
|
|
2345
|
+
Object.keys(selectedRowIds).forEach(key => delete selectedRowIds[key]);
|
|
2346
|
+
}
|
|
2347
|
+
if (row.getCanSelect()) {
|
|
2348
|
+
selectedRowIds[id] = true;
|
|
2349
|
+
}
|
|
2350
|
+
} else {
|
|
2351
|
+
delete selectedRowIds[id];
|
|
2352
|
+
}
|
|
2353
|
+
// }
|
|
2354
|
+
|
|
2355
|
+
if (includeChildren && (_row$subRows = row.subRows) != null && _row$subRows.length && row.getCanSelectSubRows()) {
|
|
2356
|
+
row.subRows.forEach(row => mutateRowIsSelected(selectedRowIds, row.id, value, includeChildren, table));
|
|
2357
|
+
}
|
|
2358
|
+
};
|
|
2359
|
+
function selectRowsFn(table, rowModel) {
|
|
2360
|
+
const rowSelection = table.getState().rowSelection;
|
|
2361
|
+
const newSelectedFlatRows = [];
|
|
2362
|
+
const newSelectedRowsById = {};
|
|
2363
|
+
|
|
2364
|
+
// Filters top level and nested rows
|
|
2365
|
+
const recurseRows = function (rows, depth) {
|
|
2366
|
+
return rows.map(row => {
|
|
2367
|
+
var _row$subRows2;
|
|
2368
|
+
const isSelected = isRowSelected(row, rowSelection);
|
|
2369
|
+
if (isSelected) {
|
|
2370
|
+
newSelectedFlatRows.push(row);
|
|
2371
|
+
newSelectedRowsById[row.id] = row;
|
|
2372
|
+
}
|
|
2373
|
+
if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
|
|
2374
|
+
row = {
|
|
2375
|
+
...row,
|
|
2376
|
+
subRows: recurseRows(row.subRows)
|
|
2377
|
+
};
|
|
2378
|
+
}
|
|
2379
|
+
if (isSelected) {
|
|
2380
|
+
return row;
|
|
2381
|
+
}
|
|
2382
|
+
}).filter(Boolean);
|
|
2383
|
+
};
|
|
2384
|
+
return {
|
|
2385
|
+
rows: recurseRows(rowModel.rows),
|
|
2386
|
+
flatRows: newSelectedFlatRows,
|
|
2387
|
+
rowsById: newSelectedRowsById
|
|
2388
|
+
};
|
|
2389
|
+
}
|
|
2390
|
+
function isRowSelected(row, selection) {
|
|
2391
|
+
var _selection$row$id;
|
|
2392
|
+
return (_selection$row$id = selection[row.id]) != null ? _selection$row$id : false;
|
|
2393
|
+
}
|
|
2394
|
+
function isSubRowSelected(row, selection, table) {
|
|
2395
|
+
var _row$subRows3;
|
|
2396
|
+
if (!((_row$subRows3 = row.subRows) != null && _row$subRows3.length)) return false;
|
|
2397
|
+
let allChildrenSelected = true;
|
|
2398
|
+
let someSelected = false;
|
|
2399
|
+
row.subRows.forEach(subRow => {
|
|
2400
|
+
// Bail out early if we know both of these
|
|
2401
|
+
if (someSelected && !allChildrenSelected) {
|
|
2402
|
+
return;
|
|
2403
|
+
}
|
|
2404
|
+
if (subRow.getCanSelect()) {
|
|
2405
|
+
if (isRowSelected(subRow, selection)) {
|
|
2406
|
+
someSelected = true;
|
|
2407
|
+
} else {
|
|
2408
|
+
allChildrenSelected = false;
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2412
|
+
// Check row selection of nested subrows
|
|
2413
|
+
if (subRow.subRows && subRow.subRows.length) {
|
|
2414
|
+
const subRowChildrenSelected = isSubRowSelected(subRow, selection);
|
|
2415
|
+
if (subRowChildrenSelected === 'all') {
|
|
2416
|
+
someSelected = true;
|
|
2417
|
+
} else if (subRowChildrenSelected === 'some') {
|
|
2418
|
+
someSelected = true;
|
|
2419
|
+
allChildrenSelected = false;
|
|
2420
|
+
} else {
|
|
2421
|
+
allChildrenSelected = false;
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
});
|
|
2425
|
+
return allChildrenSelected ? 'all' : someSelected ? 'some' : false;
|
|
2426
|
+
}
|
|
2427
|
+
|
|
2428
|
+
const reSplitAlphaNumeric = /([0-9]+)/gm;
|
|
2429
|
+
const alphanumeric = (rowA, rowB, columnId) => {
|
|
2430
|
+
return compareAlphanumeric(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
|
2431
|
+
};
|
|
2432
|
+
const alphanumericCaseSensitive = (rowA, rowB, columnId) => {
|
|
2433
|
+
return compareAlphanumeric(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
|
|
2434
|
+
};
|
|
2435
|
+
|
|
2436
|
+
// The text filter is more basic (less numeric support)
|
|
2437
|
+
// but is much faster
|
|
2438
|
+
const text = (rowA, rowB, columnId) => {
|
|
2439
|
+
return compareBasic(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
|
2440
|
+
};
|
|
2441
|
+
|
|
2442
|
+
// The text filter is more basic (less numeric support)
|
|
2443
|
+
// but is much faster
|
|
2444
|
+
const textCaseSensitive = (rowA, rowB, columnId) => {
|
|
2445
|
+
return compareBasic(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
|
|
2446
|
+
};
|
|
2447
|
+
const datetime = (rowA, rowB, columnId) => {
|
|
2448
|
+
const a = rowA.getValue(columnId);
|
|
2449
|
+
const b = rowB.getValue(columnId);
|
|
2450
|
+
|
|
2451
|
+
// Can handle nullish values
|
|
2452
|
+
// Use > and < because == (and ===) doesn't work with
|
|
2453
|
+
// Date objects (would require calling getTime()).
|
|
2454
|
+
return a > b ? 1 : a < b ? -1 : 0;
|
|
2455
|
+
};
|
|
2456
|
+
const basic = (rowA, rowB, columnId) => {
|
|
2457
|
+
return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId));
|
|
2458
|
+
};
|
|
2459
|
+
|
|
2460
|
+
// Utils
|
|
2461
|
+
|
|
2462
|
+
function compareBasic(a, b) {
|
|
2463
|
+
return a === b ? 0 : a > b ? 1 : -1;
|
|
2464
|
+
}
|
|
2465
|
+
function toString(a) {
|
|
2466
|
+
if (typeof a === 'number') {
|
|
2467
|
+
if (isNaN(a) || a === Infinity || a === -Infinity) {
|
|
2468
|
+
return '';
|
|
2469
|
+
}
|
|
2470
|
+
return String(a);
|
|
2471
|
+
}
|
|
2472
|
+
if (typeof a === 'string') {
|
|
2473
|
+
return a;
|
|
2474
|
+
}
|
|
2475
|
+
return '';
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
// Mixed sorting is slow, but very inclusive of many edge cases.
|
|
2479
|
+
// It handles numbers, mixed alphanumeric combinations, and even
|
|
2480
|
+
// null, undefined, and Infinity
|
|
2481
|
+
function compareAlphanumeric(aStr, bStr) {
|
|
2482
|
+
// Split on number groups, but keep the delimiter
|
|
2483
|
+
// Then remove falsey split values
|
|
2484
|
+
const a = aStr.split(reSplitAlphaNumeric).filter(Boolean);
|
|
2485
|
+
const b = bStr.split(reSplitAlphaNumeric).filter(Boolean);
|
|
2486
|
+
|
|
2487
|
+
// While
|
|
2488
|
+
while (a.length && b.length) {
|
|
2489
|
+
const aa = a.shift();
|
|
2490
|
+
const bb = b.shift();
|
|
2491
|
+
const an = parseInt(aa, 10);
|
|
2492
|
+
const bn = parseInt(bb, 10);
|
|
2493
|
+
const combo = [an, bn].sort();
|
|
2494
|
+
|
|
2495
|
+
// Both are string
|
|
2496
|
+
if (isNaN(combo[0])) {
|
|
2497
|
+
if (aa > bb) {
|
|
2498
|
+
return 1;
|
|
2499
|
+
}
|
|
2500
|
+
if (bb > aa) {
|
|
2501
|
+
return -1;
|
|
2502
|
+
}
|
|
2503
|
+
continue;
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2506
|
+
// One is a string, one is a number
|
|
2507
|
+
if (isNaN(combo[1])) {
|
|
2508
|
+
return isNaN(an) ? -1 : 1;
|
|
2509
|
+
}
|
|
2510
|
+
|
|
2511
|
+
// Both are numbers
|
|
2512
|
+
if (an > bn) {
|
|
2513
|
+
return 1;
|
|
2514
|
+
}
|
|
2515
|
+
if (bn > an) {
|
|
2516
|
+
return -1;
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
return a.length - b.length;
|
|
2520
|
+
}
|
|
2521
|
+
|
|
2522
|
+
// Exports
|
|
2523
|
+
|
|
2524
|
+
const sortingFns = {
|
|
2525
|
+
alphanumeric,
|
|
2526
|
+
alphanumericCaseSensitive,
|
|
2527
|
+
text,
|
|
2528
|
+
textCaseSensitive,
|
|
2529
|
+
datetime,
|
|
2530
|
+
basic
|
|
2531
|
+
};
|
|
2532
|
+
|
|
2533
|
+
//
|
|
2534
|
+
|
|
2535
|
+
const RowSorting = {
|
|
2536
|
+
getInitialState: state => {
|
|
2537
|
+
return {
|
|
2538
|
+
sorting: [],
|
|
2539
|
+
...state
|
|
2540
|
+
};
|
|
2541
|
+
},
|
|
2542
|
+
getDefaultColumnDef: () => {
|
|
2543
|
+
return {
|
|
2544
|
+
sortingFn: 'auto',
|
|
2545
|
+
sortUndefined: 1
|
|
2546
|
+
};
|
|
2547
|
+
},
|
|
2548
|
+
getDefaultOptions: table => {
|
|
2549
|
+
return {
|
|
2550
|
+
onSortingChange: makeStateUpdater('sorting', table),
|
|
2551
|
+
isMultiSortEvent: e => {
|
|
2552
|
+
return e.shiftKey;
|
|
2553
|
+
}
|
|
2554
|
+
};
|
|
2555
|
+
},
|
|
2556
|
+
createColumn: (column, table) => {
|
|
2557
|
+
column.getAutoSortingFn = () => {
|
|
2558
|
+
const firstRows = table.getFilteredRowModel().flatRows.slice(10);
|
|
2559
|
+
let isString = false;
|
|
2560
|
+
for (const row of firstRows) {
|
|
2561
|
+
const value = row == null ? void 0 : row.getValue(column.id);
|
|
2562
|
+
if (Object.prototype.toString.call(value) === '[object Date]') {
|
|
2563
|
+
return sortingFns.datetime;
|
|
2564
|
+
}
|
|
2565
|
+
if (typeof value === 'string') {
|
|
2566
|
+
isString = true;
|
|
2567
|
+
if (value.split(reSplitAlphaNumeric).length > 1) {
|
|
2568
|
+
return sortingFns.alphanumeric;
|
|
2569
|
+
}
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
if (isString) {
|
|
2573
|
+
return sortingFns.text;
|
|
2574
|
+
}
|
|
2575
|
+
return sortingFns.basic;
|
|
2576
|
+
};
|
|
2577
|
+
column.getAutoSortDir = () => {
|
|
2578
|
+
const firstRow = table.getFilteredRowModel().flatRows[0];
|
|
2579
|
+
const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
|
|
2580
|
+
if (typeof value === 'string') {
|
|
2581
|
+
return 'asc';
|
|
2582
|
+
}
|
|
2583
|
+
return 'desc';
|
|
2584
|
+
};
|
|
2585
|
+
column.getSortingFn = () => {
|
|
2586
|
+
var _table$options$sortin, _table$options$sortin2;
|
|
2587
|
+
if (!column) {
|
|
2588
|
+
throw new Error();
|
|
2589
|
+
}
|
|
2590
|
+
return isFunction(column.columnDef.sortingFn) ? column.columnDef.sortingFn : column.columnDef.sortingFn === 'auto' ? column.getAutoSortingFn() : (_table$options$sortin = (_table$options$sortin2 = table.options.sortingFns) == null ? void 0 : _table$options$sortin2[column.columnDef.sortingFn]) != null ? _table$options$sortin : sortingFns[column.columnDef.sortingFn];
|
|
2591
|
+
};
|
|
2592
|
+
column.toggleSorting = (desc, multi) => {
|
|
2593
|
+
// if (column.columns.length) {
|
|
2594
|
+
// column.columns.forEach((c, i) => {
|
|
2595
|
+
// if (c.id) {
|
|
2596
|
+
// table.toggleColumnSorting(c.id, undefined, multi || !!i)
|
|
2597
|
+
// }
|
|
2598
|
+
// })
|
|
2599
|
+
// return
|
|
2600
|
+
// }
|
|
2601
|
+
|
|
2602
|
+
// this needs to be outside of table.setSorting to be in sync with rerender
|
|
2603
|
+
const nextSortingOrder = column.getNextSortingOrder();
|
|
2604
|
+
const hasManualValue = typeof desc !== 'undefined' && desc !== null;
|
|
2605
|
+
table.setSorting(old => {
|
|
2606
|
+
// Find any existing sorting for this column
|
|
2607
|
+
const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
|
|
2608
|
+
const existingIndex = old == null ? void 0 : old.findIndex(d => d.id === column.id);
|
|
2609
|
+
let newSorting = [];
|
|
2610
|
+
|
|
2611
|
+
// What should we do with this sort action?
|
|
2612
|
+
let sortAction;
|
|
2613
|
+
let nextDesc = hasManualValue ? desc : nextSortingOrder === 'desc';
|
|
2614
|
+
|
|
2615
|
+
// Multi-mode
|
|
2616
|
+
if (old != null && old.length && column.getCanMultiSort() && multi) {
|
|
2617
|
+
if (existingSorting) {
|
|
2618
|
+
sortAction = 'toggle';
|
|
2619
|
+
} else {
|
|
2620
|
+
sortAction = 'add';
|
|
2621
|
+
}
|
|
2622
|
+
} else {
|
|
2623
|
+
// Normal mode
|
|
2624
|
+
if (old != null && old.length && existingIndex !== old.length - 1) {
|
|
2625
|
+
sortAction = 'replace';
|
|
2626
|
+
} else if (existingSorting) {
|
|
2627
|
+
sortAction = 'toggle';
|
|
2628
|
+
} else {
|
|
2629
|
+
sortAction = 'replace';
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2633
|
+
// Handle toggle states that will remove the sorting
|
|
2634
|
+
if (sortAction === 'toggle') {
|
|
2635
|
+
// If we are "actually" toggling (not a manual set value), should we remove the sorting?
|
|
2636
|
+
if (!hasManualValue) {
|
|
2637
|
+
// Is our intention to remove?
|
|
2638
|
+
if (!nextSortingOrder) {
|
|
2639
|
+
sortAction = 'remove';
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
if (sortAction === 'add') {
|
|
2644
|
+
var _table$options$maxMul;
|
|
2645
|
+
newSorting = [...old, {
|
|
2646
|
+
id: column.id,
|
|
2647
|
+
desc: nextDesc
|
|
2648
|
+
}];
|
|
2649
|
+
// Take latest n columns
|
|
2650
|
+
newSorting.splice(0, newSorting.length - ((_table$options$maxMul = table.options.maxMultiSortColCount) != null ? _table$options$maxMul : Number.MAX_SAFE_INTEGER));
|
|
2651
|
+
} else if (sortAction === 'toggle') {
|
|
2652
|
+
// This flips (or sets) the
|
|
2653
|
+
newSorting = old.map(d => {
|
|
2654
|
+
if (d.id === column.id) {
|
|
2655
|
+
return {
|
|
2656
|
+
...d,
|
|
2657
|
+
desc: nextDesc
|
|
2658
|
+
};
|
|
2659
|
+
}
|
|
2660
|
+
return d;
|
|
2661
|
+
});
|
|
2662
|
+
} else if (sortAction === 'remove') {
|
|
2663
|
+
newSorting = old.filter(d => d.id !== column.id);
|
|
2664
|
+
} else {
|
|
2665
|
+
newSorting = [{
|
|
2666
|
+
id: column.id,
|
|
2667
|
+
desc: nextDesc
|
|
2668
|
+
}];
|
|
2669
|
+
}
|
|
2670
|
+
return newSorting;
|
|
2671
|
+
});
|
|
2672
|
+
};
|
|
2673
|
+
column.getFirstSortDir = () => {
|
|
2674
|
+
var _ref, _column$columnDef$sor;
|
|
2675
|
+
const sortDescFirst = (_ref = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : table.options.sortDescFirst) != null ? _ref : column.getAutoSortDir() === 'desc';
|
|
2676
|
+
return sortDescFirst ? 'desc' : 'asc';
|
|
2677
|
+
};
|
|
2678
|
+
column.getNextSortingOrder = multi => {
|
|
2679
|
+
var _table$options$enable, _table$options$enable2;
|
|
2680
|
+
const firstSortDirection = column.getFirstSortDir();
|
|
2681
|
+
const isSorted = column.getIsSorted();
|
|
2682
|
+
if (!isSorted) {
|
|
2683
|
+
return firstSortDirection;
|
|
2684
|
+
}
|
|
2685
|
+
if (isSorted !== firstSortDirection && ((_table$options$enable = table.options.enableSortingRemoval) != null ? _table$options$enable : true) && (
|
|
2686
|
+
// If enableSortRemove, enable in general
|
|
2687
|
+
multi ? (_table$options$enable2 = table.options.enableMultiRemove) != null ? _table$options$enable2 : true : true) // If multi, don't allow if enableMultiRemove))
|
|
2688
|
+
) {
|
|
2689
|
+
return false;
|
|
2690
|
+
}
|
|
2691
|
+
return isSorted === 'desc' ? 'asc' : 'desc';
|
|
2692
|
+
};
|
|
2693
|
+
column.getCanSort = () => {
|
|
2694
|
+
var _column$columnDef$ena, _table$options$enable3;
|
|
2695
|
+
return ((_column$columnDef$ena = column.columnDef.enableSorting) != null ? _column$columnDef$ena : true) && ((_table$options$enable3 = table.options.enableSorting) != null ? _table$options$enable3 : true) && !!column.accessorFn;
|
|
2696
|
+
};
|
|
2697
|
+
column.getCanMultiSort = () => {
|
|
2698
|
+
var _ref2, _column$columnDef$ena2;
|
|
2699
|
+
return (_ref2 = (_column$columnDef$ena2 = column.columnDef.enableMultiSort) != null ? _column$columnDef$ena2 : table.options.enableMultiSort) != null ? _ref2 : !!column.accessorFn;
|
|
2700
|
+
};
|
|
2701
|
+
column.getIsSorted = () => {
|
|
2702
|
+
var _table$getState$sorti;
|
|
2703
|
+
const columnSort = (_table$getState$sorti = table.getState().sorting) == null ? void 0 : _table$getState$sorti.find(d => d.id === column.id);
|
|
2704
|
+
return !columnSort ? false : columnSort.desc ? 'desc' : 'asc';
|
|
2705
|
+
};
|
|
2706
|
+
column.getSortIndex = () => {
|
|
2707
|
+
var _table$getState$sorti2, _table$getState$sorti3;
|
|
2708
|
+
return (_table$getState$sorti2 = (_table$getState$sorti3 = table.getState().sorting) == null ? void 0 : _table$getState$sorti3.findIndex(d => d.id === column.id)) != null ? _table$getState$sorti2 : -1;
|
|
2709
|
+
};
|
|
2710
|
+
column.clearSorting = () => {
|
|
2711
|
+
//clear sorting for just 1 column
|
|
2712
|
+
table.setSorting(old => old != null && old.length ? old.filter(d => d.id !== column.id) : []);
|
|
2713
|
+
};
|
|
2714
|
+
column.getToggleSortingHandler = () => {
|
|
2715
|
+
const canSort = column.getCanSort();
|
|
2716
|
+
return e => {
|
|
2717
|
+
if (!canSort) return;
|
|
2718
|
+
e.persist == null || e.persist();
|
|
2719
|
+
column.toggleSorting == null || column.toggleSorting(undefined, column.getCanMultiSort() ? table.options.isMultiSortEvent == null ? void 0 : table.options.isMultiSortEvent(e) : false);
|
|
2720
|
+
};
|
|
2721
|
+
};
|
|
2722
|
+
},
|
|
2723
|
+
createTable: table => {
|
|
2724
|
+
table.setSorting = updater => table.options.onSortingChange == null ? void 0 : table.options.onSortingChange(updater);
|
|
2725
|
+
table.resetSorting = defaultState => {
|
|
2726
|
+
var _table$initialState$s, _table$initialState;
|
|
2727
|
+
table.setSorting(defaultState ? [] : (_table$initialState$s = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.sorting) != null ? _table$initialState$s : []);
|
|
2728
|
+
};
|
|
2729
|
+
table.getPreSortedRowModel = () => table.getGroupedRowModel();
|
|
2730
|
+
table.getSortedRowModel = () => {
|
|
2731
|
+
if (!table._getSortedRowModel && table.options.getSortedRowModel) {
|
|
2732
|
+
table._getSortedRowModel = table.options.getSortedRowModel(table);
|
|
2733
|
+
}
|
|
2734
|
+
if (table.options.manualSorting || !table._getSortedRowModel) {
|
|
2735
|
+
return table.getPreSortedRowModel();
|
|
2736
|
+
}
|
|
2737
|
+
return table._getSortedRowModel();
|
|
2738
|
+
};
|
|
2739
|
+
}
|
|
2740
|
+
};
|
|
2741
|
+
|
|
2742
|
+
const builtInFeatures = [Headers, ColumnVisibility, ColumnOrdering, ColumnPinning, ColumnFaceting, ColumnFiltering, GlobalFaceting,
|
|
2743
|
+
//depends on ColumnFaceting
|
|
2744
|
+
GlobalFiltering,
|
|
2745
|
+
//depends on ColumnFiltering
|
|
2746
|
+
RowSorting, ColumnGrouping,
|
|
2747
|
+
//depends on RowSorting
|
|
2748
|
+
RowExpanding, RowPagination, RowPinning, RowSelection, ColumnSizing];
|
|
2749
|
+
|
|
2750
|
+
//
|
|
2751
|
+
|
|
2752
|
+
function createTable(options) {
|
|
2753
|
+
var _options$_features, _options$initialState;
|
|
2754
|
+
const _features = [...builtInFeatures, ...((_options$_features = options._features) != null ? _options$_features : [])];
|
|
2755
|
+
let table = {
|
|
2756
|
+
_features
|
|
2757
|
+
};
|
|
2758
|
+
const defaultOptions = table._features.reduce((obj, feature) => {
|
|
2759
|
+
return Object.assign(obj, feature.getDefaultOptions == null ? void 0 : feature.getDefaultOptions(table));
|
|
2760
|
+
}, {});
|
|
2761
|
+
const mergeOptions = options => {
|
|
2762
|
+
if (table.options.mergeOptions) {
|
|
2763
|
+
return table.options.mergeOptions(defaultOptions, options);
|
|
2764
|
+
}
|
|
2765
|
+
return {
|
|
2766
|
+
...defaultOptions,
|
|
2767
|
+
...options
|
|
2768
|
+
};
|
|
2769
|
+
};
|
|
2770
|
+
const coreInitialState = {};
|
|
2771
|
+
let initialState = {
|
|
2772
|
+
...coreInitialState,
|
|
2773
|
+
...((_options$initialState = options.initialState) != null ? _options$initialState : {})
|
|
2774
|
+
};
|
|
2775
|
+
table._features.forEach(feature => {
|
|
2776
|
+
var _feature$getInitialSt;
|
|
2777
|
+
initialState = (_feature$getInitialSt = feature.getInitialState == null ? void 0 : feature.getInitialState(initialState)) != null ? _feature$getInitialSt : initialState;
|
|
2778
|
+
});
|
|
2779
|
+
const queued = [];
|
|
2780
|
+
let queuedTimeout = false;
|
|
2781
|
+
const coreInstance = {
|
|
2782
|
+
_features,
|
|
2783
|
+
options: {
|
|
2784
|
+
...defaultOptions,
|
|
2785
|
+
...options
|
|
2786
|
+
},
|
|
2787
|
+
initialState,
|
|
2788
|
+
_queue: cb => {
|
|
2789
|
+
queued.push(cb);
|
|
2790
|
+
if (!queuedTimeout) {
|
|
2791
|
+
queuedTimeout = true;
|
|
2792
|
+
|
|
2793
|
+
// Schedule a microtask to run the queued callbacks after
|
|
2794
|
+
// the current call stack (render, etc) has finished.
|
|
2795
|
+
Promise.resolve().then(() => {
|
|
2796
|
+
while (queued.length) {
|
|
2797
|
+
queued.shift()();
|
|
2798
|
+
}
|
|
2799
|
+
queuedTimeout = false;
|
|
2800
|
+
}).catch(error => setTimeout(() => {
|
|
2801
|
+
throw error;
|
|
2802
|
+
}));
|
|
2803
|
+
}
|
|
2804
|
+
},
|
|
2805
|
+
reset: () => {
|
|
2806
|
+
table.setState(table.initialState);
|
|
2807
|
+
},
|
|
2808
|
+
setOptions: updater => {
|
|
2809
|
+
const newOptions = functionalUpdate(updater, table.options);
|
|
2810
|
+
table.options = mergeOptions(newOptions);
|
|
2811
|
+
},
|
|
2812
|
+
getState: () => {
|
|
2813
|
+
return table.options.state;
|
|
2814
|
+
},
|
|
2815
|
+
setState: updater => {
|
|
2816
|
+
table.options.onStateChange == null || table.options.onStateChange(updater);
|
|
2817
|
+
},
|
|
2818
|
+
_getRowId: (row, index, parent) => {
|
|
2819
|
+
var _table$options$getRow;
|
|
2820
|
+
return (_table$options$getRow = table.options.getRowId == null ? void 0 : table.options.getRowId(row, index, parent)) != null ? _table$options$getRow : `${parent ? [parent.id, index].join('.') : index}`;
|
|
2821
|
+
},
|
|
2822
|
+
getCoreRowModel: () => {
|
|
2823
|
+
if (!table._getCoreRowModel) {
|
|
2824
|
+
table._getCoreRowModel = table.options.getCoreRowModel(table);
|
|
2825
|
+
}
|
|
2826
|
+
return table._getCoreRowModel();
|
|
2827
|
+
},
|
|
2828
|
+
// The final calls start at the bottom of the model,
|
|
2829
|
+
// expanded rows, which then work their way up
|
|
2830
|
+
|
|
2831
|
+
getRowModel: () => {
|
|
2832
|
+
return table.getPaginationRowModel();
|
|
2833
|
+
},
|
|
2834
|
+
//in next version, we should just pass in the row model as the optional 2nd arg
|
|
2835
|
+
getRow: (id, searchAll) => {
|
|
2836
|
+
let row = (searchAll ? table.getPrePaginationRowModel() : table.getRowModel()).rowsById[id];
|
|
2837
|
+
if (!row) {
|
|
2838
|
+
row = table.getCoreRowModel().rowsById[id];
|
|
2839
|
+
if (!row) {
|
|
2840
|
+
throw new Error();
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
return row;
|
|
2844
|
+
},
|
|
2845
|
+
_getDefaultColumnDef: memo(() => [table.options.defaultColumn], defaultColumn => {
|
|
2846
|
+
var _defaultColumn;
|
|
2847
|
+
defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
|
|
2848
|
+
return {
|
|
2849
|
+
header: props => {
|
|
2850
|
+
const resolvedColumnDef = props.header.column.columnDef;
|
|
2851
|
+
if (resolvedColumnDef.accessorKey) {
|
|
2852
|
+
return resolvedColumnDef.accessorKey;
|
|
2853
|
+
}
|
|
2854
|
+
if (resolvedColumnDef.accessorFn) {
|
|
2855
|
+
return resolvedColumnDef.id;
|
|
2856
|
+
}
|
|
2857
|
+
return null;
|
|
2858
|
+
},
|
|
2859
|
+
// footer: props => props.header.column.id,
|
|
2860
|
+
cell: props => {
|
|
2861
|
+
var _props$renderValue$to, _props$renderValue;
|
|
2862
|
+
return (_props$renderValue$to = (_props$renderValue = props.renderValue()) == null || _props$renderValue.toString == null ? void 0 : _props$renderValue.toString()) != null ? _props$renderValue$to : null;
|
|
2863
|
+
},
|
|
2864
|
+
...table._features.reduce((obj, feature) => {
|
|
2865
|
+
return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
|
|
2866
|
+
}, {}),
|
|
2867
|
+
...defaultColumn
|
|
2868
|
+
};
|
|
2869
|
+
}, getMemoOptions(options, 'debugColumns')),
|
|
2870
|
+
_getColumnDefs: () => table.options.columns,
|
|
2871
|
+
getAllColumns: memo(() => [table._getColumnDefs()], columnDefs => {
|
|
2872
|
+
const recurseColumns = function (columnDefs, parent, depth) {
|
|
2873
|
+
if (depth === void 0) {
|
|
2874
|
+
depth = 0;
|
|
2875
|
+
}
|
|
2876
|
+
return columnDefs.map(columnDef => {
|
|
2877
|
+
const column = createColumn(table, columnDef, depth, parent);
|
|
2878
|
+
const groupingColumnDef = columnDef;
|
|
2879
|
+
column.columns = groupingColumnDef.columns ? recurseColumns(groupingColumnDef.columns, column, depth + 1) : [];
|
|
2880
|
+
return column;
|
|
2881
|
+
});
|
|
2882
|
+
};
|
|
2883
|
+
return recurseColumns(columnDefs);
|
|
2884
|
+
}, getMemoOptions(options, 'debugColumns')),
|
|
2885
|
+
getAllFlatColumns: memo(() => [table.getAllColumns()], allColumns => {
|
|
2886
|
+
return allColumns.flatMap(column => {
|
|
2887
|
+
return column.getFlatColumns();
|
|
2888
|
+
});
|
|
2889
|
+
}, getMemoOptions(options, 'debugColumns')),
|
|
2890
|
+
_getAllFlatColumnsById: memo(() => [table.getAllFlatColumns()], flatColumns => {
|
|
2891
|
+
return flatColumns.reduce((acc, column) => {
|
|
2892
|
+
acc[column.id] = column;
|
|
2893
|
+
return acc;
|
|
2894
|
+
}, {});
|
|
2895
|
+
}, getMemoOptions(options, 'debugColumns')),
|
|
2896
|
+
getAllLeafColumns: memo(() => [table.getAllColumns(), table._getOrderColumnsFn()], (allColumns, orderColumns) => {
|
|
2897
|
+
let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
|
|
2898
|
+
return orderColumns(leafColumns);
|
|
2899
|
+
}, getMemoOptions(options, 'debugColumns')),
|
|
2900
|
+
getColumn: columnId => {
|
|
2901
|
+
const column = table._getAllFlatColumnsById()[columnId];
|
|
2902
|
+
return column;
|
|
2903
|
+
}
|
|
2904
|
+
};
|
|
2905
|
+
Object.assign(table, coreInstance);
|
|
2906
|
+
for (let index = 0; index < table._features.length; index++) {
|
|
2907
|
+
const feature = table._features[index];
|
|
2908
|
+
feature == null || feature.createTable == null || feature.createTable(table);
|
|
2909
|
+
}
|
|
2910
|
+
return table;
|
|
2911
|
+
}
|
|
2912
|
+
|
|
2913
|
+
function getCoreRowModel() {
|
|
2914
|
+
return table => memo(() => [table.options.data], data => {
|
|
2915
|
+
const rowModel = {
|
|
2916
|
+
rows: [],
|
|
2917
|
+
flatRows: [],
|
|
2918
|
+
rowsById: {}
|
|
2919
|
+
};
|
|
2920
|
+
const accessRows = function (originalRows, depth, parentRow) {
|
|
2921
|
+
if (depth === void 0) {
|
|
2922
|
+
depth = 0;
|
|
2923
|
+
}
|
|
2924
|
+
const rows = [];
|
|
2925
|
+
for (let i = 0; i < originalRows.length; i++) {
|
|
2926
|
+
// This could be an expensive check at scale, so we should move it somewhere else, but where?
|
|
2927
|
+
// if (!id) {
|
|
2928
|
+
// if ("production" !== 'production') {
|
|
2929
|
+
// throw new Error(`getRowId expected an ID, but got ${id}`)
|
|
2930
|
+
// }
|
|
2931
|
+
// }
|
|
2932
|
+
|
|
2933
|
+
// Make the row
|
|
2934
|
+
const row = createRow(table, table._getRowId(originalRows[i], i, parentRow), originalRows[i], i, depth, undefined, parentRow == null ? void 0 : parentRow.id);
|
|
2935
|
+
|
|
2936
|
+
// Keep track of every row in a flat array
|
|
2937
|
+
rowModel.flatRows.push(row);
|
|
2938
|
+
// Also keep track of every row by its ID
|
|
2939
|
+
rowModel.rowsById[row.id] = row;
|
|
2940
|
+
// Push table row into parent
|
|
2941
|
+
rows.push(row);
|
|
2942
|
+
|
|
2943
|
+
// Get the original subrows
|
|
2944
|
+
if (table.options.getSubRows) {
|
|
2945
|
+
var _row$originalSubRows;
|
|
2946
|
+
row.originalSubRows = table.options.getSubRows(originalRows[i], i);
|
|
2947
|
+
|
|
2948
|
+
// Then recursively access them
|
|
2949
|
+
if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) {
|
|
2950
|
+
row.subRows = accessRows(row.originalSubRows, depth + 1, row);
|
|
2951
|
+
}
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
return rows;
|
|
2955
|
+
};
|
|
2956
|
+
rowModel.rows = accessRows(data);
|
|
2957
|
+
return rowModel;
|
|
2958
|
+
}, getMemoOptions(table.options, 'debugTable', 'getRowModel', () => table._autoResetPageIndex()));
|
|
2959
|
+
}
|
|
2960
|
+
|
|
2961
|
+
/**
|
|
2962
|
+
* react-table
|
|
2963
|
+
*
|
|
2964
|
+
* Copyright (c) TanStack
|
|
2965
|
+
*
|
|
2966
|
+
* This source code is licensed under the MIT license found in the
|
|
2967
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
2968
|
+
*
|
|
2969
|
+
* @license MIT
|
|
2970
|
+
*/
|
|
2971
|
+
|
|
2972
|
+
//
|
|
2973
|
+
|
|
2974
|
+
/**
|
|
2975
|
+
* If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
|
|
2976
|
+
*/
|
|
2977
|
+
function flexRender(Comp, props) {
|
|
2978
|
+
return !Comp ? null : isReactComponent(Comp) ? /*#__PURE__*/React__namespace.createElement(Comp, props) : Comp;
|
|
2979
|
+
}
|
|
2980
|
+
function isReactComponent(component) {
|
|
2981
|
+
return isClassComponent(component) || typeof component === 'function' || isExoticComponent(component);
|
|
2982
|
+
}
|
|
2983
|
+
function isClassComponent(component) {
|
|
2984
|
+
return typeof component === 'function' && (() => {
|
|
2985
|
+
const proto = Object.getPrototypeOf(component);
|
|
2986
|
+
return proto.prototype && proto.prototype.isReactComponent;
|
|
2987
|
+
})();
|
|
2988
|
+
}
|
|
2989
|
+
function isExoticComponent(component) {
|
|
2990
|
+
return typeof component === 'object' && typeof component.$$typeof === 'symbol' && ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description);
|
|
2991
|
+
}
|
|
2992
|
+
function useReactTable(options) {
|
|
2993
|
+
// Compose in the generic options to the user options
|
|
2994
|
+
const resolvedOptions = {
|
|
2995
|
+
state: {},
|
|
2996
|
+
// Dummy state
|
|
2997
|
+
onStateChange: () => {},
|
|
2998
|
+
// noop
|
|
2999
|
+
renderFallbackValue: null,
|
|
3000
|
+
...options
|
|
3001
|
+
};
|
|
3002
|
+
|
|
3003
|
+
// Create a new table and store it in state
|
|
3004
|
+
const [tableRef] = React__namespace.useState(() => ({
|
|
3005
|
+
current: createTable(resolvedOptions)
|
|
3006
|
+
}));
|
|
3007
|
+
|
|
3008
|
+
// By default, manage table state here using the table's initial state
|
|
3009
|
+
const [state, setState] = React__namespace.useState(() => tableRef.current.initialState);
|
|
3010
|
+
|
|
3011
|
+
// Compose the default state above with any user state. This will allow the user
|
|
3012
|
+
// to only control a subset of the state if desired.
|
|
3013
|
+
tableRef.current.setOptions(prev => ({
|
|
3014
|
+
...prev,
|
|
3015
|
+
...options,
|
|
3016
|
+
state: {
|
|
3017
|
+
...state,
|
|
3018
|
+
...options.state
|
|
3019
|
+
},
|
|
3020
|
+
// Similarly, we'll maintain both our internal state and any user-provided
|
|
3021
|
+
// state.
|
|
3022
|
+
onStateChange: updater => {
|
|
3023
|
+
setState(updater);
|
|
3024
|
+
options.onStateChange == null || options.onStateChange(updater);
|
|
3025
|
+
}
|
|
3026
|
+
}));
|
|
3027
|
+
return tableRef.current;
|
|
3028
|
+
}
|
|
3029
|
+
|
|
3030
|
+
const DEFAULT_PAGE_SIZE = 30;
|
|
3031
|
+
const URL_SORT_PARAMS = {
|
|
3032
|
+
SORT_BY: "sort_by",
|
|
3033
|
+
ORDER_BY: "order_by",
|
|
3034
|
+
};
|
|
3035
|
+
const URL_PAGE_PARAM = "page";
|
|
3036
|
+
const SORT_DIRECTIONS = {
|
|
3037
|
+
ASC: "asc",
|
|
3038
|
+
DESC: "desc",
|
|
3039
|
+
};
|
|
3040
|
+
const STORAGE_KEY_PREFIX = "NEETOUI";
|
|
3041
|
+
const STORAGE_KEY_SUFFIX = "FIXED_COLUMNS";
|
|
3042
|
+
|
|
3043
|
+
const getSearchParams = () => new URLSearchParams(window.location.search);
|
|
3044
|
+
const readSortFromURL = () => {
|
|
3045
|
+
const params = getSearchParams();
|
|
3046
|
+
const sortBy = params.get(URL_SORT_PARAMS.SORT_BY);
|
|
3047
|
+
const orderBy = params.get(URL_SORT_PARAMS.ORDER_BY);
|
|
3048
|
+
if (!sortBy)
|
|
3049
|
+
return [];
|
|
3050
|
+
return [{ id: sortBy, desc: orderBy === SORT_DIRECTIONS.DESC }];
|
|
3051
|
+
};
|
|
3052
|
+
const writeSortToURL = (sorting) => {
|
|
3053
|
+
const url = new URL(window.location.href);
|
|
3054
|
+
if (sorting.length === 0) {
|
|
3055
|
+
url.searchParams.delete(URL_SORT_PARAMS.SORT_BY);
|
|
3056
|
+
url.searchParams.delete(URL_SORT_PARAMS.ORDER_BY);
|
|
3057
|
+
}
|
|
3058
|
+
else {
|
|
3059
|
+
const { id, desc } = sorting[0];
|
|
3060
|
+
url.searchParams.set(URL_SORT_PARAMS.SORT_BY, id);
|
|
3061
|
+
url.searchParams.set(URL_SORT_PARAMS.ORDER_BY, desc ? SORT_DIRECTIONS.DESC : SORT_DIRECTIONS.ASC);
|
|
3062
|
+
}
|
|
3063
|
+
window.history.pushState({}, "", url.toString());
|
|
3064
|
+
};
|
|
3065
|
+
const readPageFromURL = () => {
|
|
3066
|
+
const params = new URLSearchParams(window.location.search);
|
|
3067
|
+
const page = params.get(URL_PAGE_PARAM);
|
|
3068
|
+
return page ? Math.max(1, parseInt(page, 10)) : 1;
|
|
3069
|
+
};
|
|
3070
|
+
const writePageToURL = (page) => {
|
|
3071
|
+
const url = new URL(window.location.href);
|
|
3072
|
+
if (page <= 1) {
|
|
3073
|
+
url.searchParams.delete(URL_PAGE_PARAM);
|
|
3074
|
+
}
|
|
3075
|
+
else {
|
|
3076
|
+
url.searchParams.set(URL_PAGE_PARAM, String(page));
|
|
3077
|
+
}
|
|
3078
|
+
window.history.pushState({}, "", url.toString());
|
|
3079
|
+
};
|
|
3080
|
+
const keysToRowSelection = (keys) => Object.fromEntries(keys.map(key => [key, true]));
|
|
3081
|
+
const rowSelectionToKeys = (selection) => Object.keys(selection).filter(key => selection[key]);
|
|
3082
|
+
const hashPathname = () => {
|
|
3083
|
+
const pathname = decodeURIComponent(window.location.pathname).replace(/^\//, "");
|
|
3084
|
+
let hash = 0;
|
|
3085
|
+
for (let i = 0; i < pathname.length; i++) {
|
|
3086
|
+
const char = pathname.charCodeAt(i);
|
|
3087
|
+
hash = (hash << 5) - hash + char;
|
|
3088
|
+
hash = hash & hash;
|
|
3089
|
+
}
|
|
3090
|
+
return Math.abs(hash).toString(16).toUpperCase();
|
|
3091
|
+
};
|
|
3092
|
+
const getStorageKey = (prefix) => {
|
|
3093
|
+
const resolvedPrefix = prefix || hashPathname();
|
|
3094
|
+
return `${STORAGE_KEY_PREFIX}-${resolvedPrefix}-${STORAGE_KEY_SUFFIX}`;
|
|
3095
|
+
};
|
|
3096
|
+
const readFromLocalStorage = (key) => {
|
|
3097
|
+
try {
|
|
3098
|
+
const stored = localStorage.getItem(key);
|
|
3099
|
+
return stored ? JSON.parse(stored) : [];
|
|
3100
|
+
}
|
|
3101
|
+
catch {
|
|
3102
|
+
return [];
|
|
3103
|
+
}
|
|
3104
|
+
};
|
|
3105
|
+
const writeToLocalStorage = (key, value) => {
|
|
3106
|
+
try {
|
|
3107
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
3108
|
+
}
|
|
3109
|
+
catch {
|
|
3110
|
+
// Silently fail if storage is full
|
|
3111
|
+
}
|
|
3112
|
+
};
|
|
3113
|
+
const getPageNumbers = (current, total) => {
|
|
3114
|
+
if (total <= 7) {
|
|
3115
|
+
return Array.from({ length: total }, (_, i) => i + 1);
|
|
3116
|
+
}
|
|
3117
|
+
const pages = [1];
|
|
3118
|
+
if (current > 3)
|
|
3119
|
+
pages.push("ellipsis");
|
|
3120
|
+
const start = Math.max(2, current - 1);
|
|
3121
|
+
const end = Math.min(total - 1, current + 1);
|
|
3122
|
+
for (let i = start; i <= end; i++) {
|
|
3123
|
+
pages.push(i);
|
|
3124
|
+
}
|
|
3125
|
+
if (current < total - 2)
|
|
3126
|
+
pages.push("ellipsis");
|
|
3127
|
+
pages.push(total);
|
|
3128
|
+
return pages;
|
|
3129
|
+
};
|
|
3130
|
+
|
|
3131
|
+
const useTableSort = ({ sorting: controlledSorting, onSortingChange: controlledOnSortingChange, enableURLSort = true, }) => {
|
|
3132
|
+
const isControlled = controlledSorting !== undefined;
|
|
3133
|
+
const [internalSorting, setInternalSorting] = React.useState(() => enableURLSort ? readSortFromURL() : []);
|
|
3134
|
+
const sorting = isControlled ? controlledSorting : internalSorting;
|
|
3135
|
+
const onSortingChange = React.useCallback(updaterOrValue => {
|
|
3136
|
+
const newSorting = typeof updaterOrValue === "function"
|
|
3137
|
+
? updaterOrValue(sorting)
|
|
3138
|
+
: updaterOrValue;
|
|
3139
|
+
if (!isControlled) {
|
|
3140
|
+
setInternalSorting(newSorting);
|
|
3141
|
+
}
|
|
3142
|
+
controlledOnSortingChange?.(updaterOrValue);
|
|
3143
|
+
if (enableURLSort) {
|
|
3144
|
+
writeSortToURL(newSorting);
|
|
3145
|
+
}
|
|
3146
|
+
}, [sorting, isControlled, controlledOnSortingChange, enableURLSort]);
|
|
3147
|
+
React.useEffect(() => {
|
|
3148
|
+
if (enableURLSort && !isControlled) {
|
|
3149
|
+
const urlSorting = readSortFromURL();
|
|
3150
|
+
setInternalSorting(urlSorting);
|
|
3151
|
+
}
|
|
3152
|
+
}, [enableURLSort, isControlled]);
|
|
3153
|
+
return { sorting, onSortingChange };
|
|
3154
|
+
};
|
|
3155
|
+
|
|
3156
|
+
const useTablePagination = ({ totalCount = 0, pageSize = DEFAULT_PAGE_SIZE, currentPage: controlledPage, onPageChange: controlledOnPageChange, enableURLPagination = true, }) => {
|
|
3157
|
+
const isControlled = controlledPage !== undefined;
|
|
3158
|
+
const [internalPage, setInternalPage] = React.useState(() => enableURLPagination ? readPageFromURL() : 1);
|
|
3159
|
+
const currentPage = isControlled ? controlledPage : internalPage;
|
|
3160
|
+
const pageCount = Math.max(1, Math.ceil(totalCount / pageSize));
|
|
3161
|
+
const onPageChange = React.useCallback((page) => {
|
|
3162
|
+
const clampedPage = Math.min(Math.max(1, page), pageCount);
|
|
3163
|
+
if (!isControlled) {
|
|
3164
|
+
setInternalPage(clampedPage);
|
|
3165
|
+
}
|
|
3166
|
+
controlledOnPageChange?.(clampedPage);
|
|
3167
|
+
if (enableURLPagination) {
|
|
3168
|
+
writePageToURL(clampedPage);
|
|
3169
|
+
}
|
|
3170
|
+
}, [pageCount, isControlled, controlledOnPageChange, enableURLPagination]);
|
|
3171
|
+
React.useEffect(() => {
|
|
3172
|
+
if (currentPage > pageCount && pageCount > 0) {
|
|
3173
|
+
onPageChange(pageCount);
|
|
3174
|
+
}
|
|
3175
|
+
}, [currentPage, pageCount, onPageChange]);
|
|
3176
|
+
const paginationState = React.useMemo(() => ({
|
|
3177
|
+
pageIndex: currentPage - 1,
|
|
3178
|
+
pageSize,
|
|
3179
|
+
}), [currentPage, pageSize]);
|
|
3180
|
+
return {
|
|
3181
|
+
currentPage,
|
|
3182
|
+
pageCount,
|
|
3183
|
+
pageSize,
|
|
3184
|
+
paginationState,
|
|
3185
|
+
onPageChange,
|
|
3186
|
+
};
|
|
3187
|
+
};
|
|
3188
|
+
|
|
3189
|
+
/**
|
|
3190
|
+
* @license lucide-react v0.577.0 - ISC
|
|
3191
|
+
*
|
|
3192
|
+
* This source code is licensed under the ISC license.
|
|
3193
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
3194
|
+
*/
|
|
3195
|
+
|
|
3196
|
+
|
|
3197
|
+
const __iconNode$7 = [
|
|
3198
|
+
["path", { d: "M12 5v14", key: "s699le" }],
|
|
3199
|
+
["path", { d: "m19 12-7 7-7-7", key: "1idqje" }]
|
|
3200
|
+
];
|
|
3201
|
+
const ArrowDown = createLucideIcon.createLucideIcon("arrow-down", __iconNode$7);
|
|
3202
|
+
|
|
3203
|
+
/**
|
|
3204
|
+
* @license lucide-react v0.577.0 - ISC
|
|
3205
|
+
*
|
|
3206
|
+
* This source code is licensed under the ISC license.
|
|
3207
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
3208
|
+
*/
|
|
3209
|
+
|
|
3210
|
+
|
|
3211
|
+
const __iconNode$6 = [
|
|
3212
|
+
["path", { d: "m5 12 7-7 7 7", key: "hav0vg" }],
|
|
3213
|
+
["path", { d: "M12 19V5", key: "x0mq9r" }]
|
|
3214
|
+
];
|
|
3215
|
+
const ArrowUp = createLucideIcon.createLucideIcon("arrow-up", __iconNode$6);
|
|
3216
|
+
|
|
3217
|
+
/**
|
|
3218
|
+
* @license lucide-react v0.577.0 - ISC
|
|
3219
|
+
*
|
|
3220
|
+
* This source code is licensed under the ISC license.
|
|
3221
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
3222
|
+
*/
|
|
3223
|
+
|
|
3224
|
+
|
|
3225
|
+
const __iconNode$5 = [
|
|
3226
|
+
[
|
|
3227
|
+
"path",
|
|
3228
|
+
{
|
|
3229
|
+
d: "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",
|
|
3230
|
+
key: "ct8e1f"
|
|
3231
|
+
}
|
|
3232
|
+
],
|
|
3233
|
+
["path", { d: "M14.084 14.158a3 3 0 0 1-4.242-4.242", key: "151rxh" }],
|
|
3234
|
+
[
|
|
3235
|
+
"path",
|
|
3236
|
+
{
|
|
3237
|
+
d: "M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",
|
|
3238
|
+
key: "13bj9a"
|
|
3239
|
+
}
|
|
3240
|
+
],
|
|
3241
|
+
["path", { d: "m2 2 20 20", key: "1ooewy" }]
|
|
3242
|
+
];
|
|
3243
|
+
const EyeOff = createLucideIcon.createLucideIcon("eye-off", __iconNode$5);
|
|
3244
|
+
|
|
3245
|
+
/**
|
|
3246
|
+
* @license lucide-react v0.577.0 - ISC
|
|
3247
|
+
*
|
|
3248
|
+
* This source code is licensed under the ISC license.
|
|
3249
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
3250
|
+
*/
|
|
3251
|
+
|
|
3252
|
+
|
|
3253
|
+
const __iconNode$4 = [
|
|
3254
|
+
["path", { d: "M6 8L2 12L6 16", key: "kyvwex" }],
|
|
3255
|
+
["path", { d: "M2 12H22", key: "1m8cig" }]
|
|
3256
|
+
];
|
|
3257
|
+
const MoveLeft = createLucideIcon.createLucideIcon("move-left", __iconNode$4);
|
|
3258
|
+
|
|
3259
|
+
/**
|
|
3260
|
+
* @license lucide-react v0.577.0 - ISC
|
|
3261
|
+
*
|
|
3262
|
+
* This source code is licensed under the ISC license.
|
|
3263
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
3264
|
+
*/
|
|
3265
|
+
|
|
3266
|
+
|
|
3267
|
+
const __iconNode$3 = [
|
|
3268
|
+
["path", { d: "M18 8L22 12L18 16", key: "1r0oui" }],
|
|
3269
|
+
["path", { d: "M2 12H22", key: "1m8cig" }]
|
|
3270
|
+
];
|
|
3271
|
+
const MoveRight = createLucideIcon.createLucideIcon("move-right", __iconNode$3);
|
|
3272
|
+
|
|
3273
|
+
/**
|
|
3274
|
+
* @license lucide-react v0.577.0 - ISC
|
|
3275
|
+
*
|
|
3276
|
+
* This source code is licensed under the ISC license.
|
|
3277
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
3278
|
+
*/
|
|
3279
|
+
|
|
3280
|
+
|
|
3281
|
+
const __iconNode$2 = [
|
|
3282
|
+
["path", { d: "M12 17v5", key: "bb1du9" }],
|
|
3283
|
+
[
|
|
3284
|
+
"path",
|
|
3285
|
+
{
|
|
3286
|
+
d: "M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",
|
|
3287
|
+
key: "1nkz8b"
|
|
3288
|
+
}
|
|
3289
|
+
]
|
|
3290
|
+
];
|
|
3291
|
+
const Pin = createLucideIcon.createLucideIcon("pin", __iconNode$2);
|
|
3292
|
+
|
|
3293
|
+
/**
|
|
3294
|
+
* @license lucide-react v0.577.0 - ISC
|
|
3295
|
+
*
|
|
3296
|
+
* This source code is licensed under the ISC license.
|
|
3297
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
3298
|
+
*/
|
|
3299
|
+
|
|
3300
|
+
|
|
3301
|
+
const __iconNode$1 = [
|
|
3302
|
+
["path", { d: "M5 12h14", key: "1ays0h" }],
|
|
3303
|
+
["path", { d: "M12 5v14", key: "s699le" }]
|
|
3304
|
+
];
|
|
3305
|
+
const Plus = createLucideIcon.createLucideIcon("plus", __iconNode$1);
|
|
3306
|
+
|
|
3307
|
+
/**
|
|
3308
|
+
* @license lucide-react v0.577.0 - ISC
|
|
3309
|
+
*
|
|
3310
|
+
* This source code is licensed under the ISC license.
|
|
3311
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
3312
|
+
*/
|
|
3313
|
+
|
|
3314
|
+
|
|
3315
|
+
const __iconNode = [
|
|
3316
|
+
["path", { d: "M10 11v6", key: "nco0om" }],
|
|
3317
|
+
["path", { d: "M14 11v6", key: "outv1u" }],
|
|
3318
|
+
["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6", key: "miytrc" }],
|
|
3319
|
+
["path", { d: "M3 6h18", key: "d0wm0j" }],
|
|
3320
|
+
["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2", key: "e791ji" }]
|
|
3321
|
+
];
|
|
3322
|
+
const Trash2 = createLucideIcon.createLucideIcon("trash-2", __iconNode);
|
|
3323
|
+
|
|
3324
|
+
const SelectionCheckbox = ({ checked, onCheckedChange, ariaLabel, }) => (jsxRuntime.jsx("div", { className: "flex items-center justify-center", children: jsxRuntime.jsx(primitives_Checkbox.Checkbox, { checked: checked, onCheckedChange: onCheckedChange, "aria-label": ariaLabel ?? "Select row" }) }));
|
|
3325
|
+
|
|
3326
|
+
const useTableSelection = ({ enableRowSelection, selectedRowKeys, onRowSelect, data, getRowId, }) => {
|
|
3327
|
+
const isControlled = selectedRowKeys !== undefined;
|
|
3328
|
+
const isFirstRender = React.useRef(true);
|
|
3329
|
+
const [internalSelection, setInternalSelection] = React.useState(() => (isControlled ? keysToRowSelection(selectedRowKeys) : {}));
|
|
3330
|
+
const rowSelection = isControlled
|
|
3331
|
+
? keysToRowSelection(selectedRowKeys)
|
|
3332
|
+
: internalSelection;
|
|
3333
|
+
React.useEffect(() => {
|
|
3334
|
+
if (isControlled) {
|
|
3335
|
+
setInternalSelection(keysToRowSelection(selectedRowKeys));
|
|
3336
|
+
}
|
|
3337
|
+
}, [isControlled, selectedRowKeys]);
|
|
3338
|
+
const onRowSelectionChange = React.useCallback((updaterOrValue) => {
|
|
3339
|
+
const newSelection = typeof updaterOrValue === "function"
|
|
3340
|
+
? updaterOrValue(rowSelection)
|
|
3341
|
+
: updaterOrValue;
|
|
3342
|
+
if (!isControlled) {
|
|
3343
|
+
setInternalSelection(newSelection);
|
|
3344
|
+
}
|
|
3345
|
+
if (onRowSelect) {
|
|
3346
|
+
const keys = rowSelectionToKeys(newSelection);
|
|
3347
|
+
const selectedRows = data.filter(row => keys.includes(getRowId(row)));
|
|
3348
|
+
onRowSelect(keys, selectedRows);
|
|
3349
|
+
}
|
|
3350
|
+
}, [rowSelection, isControlled, onRowSelect, data, getRowId]);
|
|
3351
|
+
React.useEffect(() => {
|
|
3352
|
+
if (isFirstRender.current) {
|
|
3353
|
+
isFirstRender.current = false;
|
|
3354
|
+
return;
|
|
3355
|
+
}
|
|
3356
|
+
}, []);
|
|
3357
|
+
const selectionColumn = React.useMemo(() => {
|
|
3358
|
+
if (!enableRowSelection)
|
|
3359
|
+
return null;
|
|
3360
|
+
return {
|
|
3361
|
+
id: "_selection",
|
|
3362
|
+
header: ({ table }) => SelectionCheckbox({
|
|
3363
|
+
checked: table.getIsAllPageRowsSelected() ||
|
|
3364
|
+
(table.getIsSomePageRowsSelected() && "indeterminate"),
|
|
3365
|
+
onCheckedChange: value => table.toggleAllPageRowsSelected(!!value),
|
|
3366
|
+
ariaLabel: "Select all",
|
|
3367
|
+
}),
|
|
3368
|
+
cell: ({ row }) => SelectionCheckbox({
|
|
3369
|
+
checked: row.getIsSelected(),
|
|
3370
|
+
onCheckedChange: value => row.toggleSelected(!!value),
|
|
3371
|
+
ariaLabel: "Select row",
|
|
3372
|
+
}),
|
|
3373
|
+
size: 40,
|
|
3374
|
+
enableSorting: false,
|
|
3375
|
+
enableResizing: false,
|
|
3376
|
+
};
|
|
3377
|
+
}, [enableRowSelection]);
|
|
3378
|
+
return {
|
|
3379
|
+
rowSelection,
|
|
3380
|
+
onRowSelectionChange,
|
|
3381
|
+
selectionColumn,
|
|
3382
|
+
enableRowSelection: typeof enableRowSelection === "function"
|
|
3383
|
+
? enableRowSelection
|
|
3384
|
+
: !!enableRowSelection,
|
|
3385
|
+
};
|
|
3386
|
+
};
|
|
3387
|
+
|
|
3388
|
+
const useColumnPinning = ({ enabled = true, columnPinning: controlledPinning, onColumnPinningChange: controlledOnChange, localStorageKeyPrefix, initialPinnedColumns = [], }) => {
|
|
3389
|
+
const isControlled = controlledPinning !== undefined;
|
|
3390
|
+
const storageKey = getStorageKey(localStorageKeyPrefix);
|
|
3391
|
+
const [internalPinning, setInternalPinning] = React.useState(() => {
|
|
3392
|
+
if (!enabled)
|
|
3393
|
+
return { left: [], right: [] };
|
|
3394
|
+
const stored = readFromLocalStorage(storageKey);
|
|
3395
|
+
const left = stored.length > 0 ? stored : initialPinnedColumns;
|
|
3396
|
+
return { left, right: [] };
|
|
3397
|
+
});
|
|
3398
|
+
const pinning = isControlled ? controlledPinning : internalPinning;
|
|
3399
|
+
const onColumnPinningChange = React.useCallback(updaterOrValue => {
|
|
3400
|
+
const newPinning = typeof updaterOrValue === "function"
|
|
3401
|
+
? updaterOrValue(pinning)
|
|
3402
|
+
: updaterOrValue;
|
|
3403
|
+
if (!isControlled) {
|
|
3404
|
+
setInternalPinning(newPinning);
|
|
3405
|
+
}
|
|
3406
|
+
controlledOnChange?.(updaterOrValue);
|
|
3407
|
+
if (enabled) {
|
|
3408
|
+
writeToLocalStorage(storageKey, newPinning.left ?? []);
|
|
3409
|
+
}
|
|
3410
|
+
}, [pinning, isControlled, controlledOnChange, enabled, storageKey]);
|
|
3411
|
+
const toggleColumnPin = React.useCallback((columnId) => {
|
|
3412
|
+
onColumnPinningChange(old => {
|
|
3413
|
+
const leftPins = old.left ?? [];
|
|
3414
|
+
const isPinned = leftPins.includes(columnId);
|
|
3415
|
+
const newLeft = isPinned
|
|
3416
|
+
? leftPins.filter(id => id !== columnId)
|
|
3417
|
+
: [...leftPins, columnId];
|
|
3418
|
+
return { ...old, left: newLeft };
|
|
3419
|
+
});
|
|
3420
|
+
}, [onColumnPinningChange]);
|
|
3421
|
+
const isColumnPinned = React.useCallback((columnId) => {
|
|
3422
|
+
return (pinning.left ?? []).includes(columnId);
|
|
3423
|
+
}, [pinning]);
|
|
3424
|
+
React.useEffect(() => {
|
|
3425
|
+
if (!enabled || isControlled)
|
|
3426
|
+
return;
|
|
3427
|
+
const stored = readFromLocalStorage(storageKey);
|
|
3428
|
+
if (stored.length > 0) {
|
|
3429
|
+
setInternalPinning({ left: stored, right: [] });
|
|
3430
|
+
}
|
|
3431
|
+
}, [enabled, isControlled, storageKey]);
|
|
3432
|
+
return {
|
|
3433
|
+
columnPinning: enabled ? pinning : { left: [], right: [] },
|
|
3434
|
+
onColumnPinningChange,
|
|
3435
|
+
toggleColumnPin,
|
|
3436
|
+
isColumnPinned,
|
|
3437
|
+
};
|
|
3438
|
+
};
|
|
3439
|
+
|
|
3440
|
+
const useColumnVisibility = ({ columnVisibility: controlledVisibility, onColumnVisibilityChange: controlledOnChange, onColumnHide, }) => {
|
|
3441
|
+
const isControlled = controlledVisibility !== undefined;
|
|
3442
|
+
const [internalVisibility, setInternalVisibility] = React.useState({});
|
|
3443
|
+
const visibility = isControlled ? controlledVisibility : internalVisibility;
|
|
3444
|
+
const onColumnVisibilityChange = React.useCallback(updaterOrValue => {
|
|
3445
|
+
const newVisibility = typeof updaterOrValue === "function"
|
|
3446
|
+
? updaterOrValue(visibility)
|
|
3447
|
+
: updaterOrValue;
|
|
3448
|
+
if (!isControlled) {
|
|
3449
|
+
setInternalVisibility(newVisibility);
|
|
3450
|
+
}
|
|
3451
|
+
controlledOnChange?.(updaterOrValue);
|
|
3452
|
+
}, [visibility, isControlled, controlledOnChange]);
|
|
3453
|
+
const hideColumn = React.useCallback((columnId) => {
|
|
3454
|
+
onColumnVisibilityChange(old => ({ ...old, [columnId]: false }));
|
|
3455
|
+
onColumnHide?.(columnId);
|
|
3456
|
+
}, [onColumnVisibilityChange, onColumnHide]);
|
|
3457
|
+
const showColumn = React.useCallback((columnId) => {
|
|
3458
|
+
onColumnVisibilityChange(old => ({ ...old, [columnId]: true }));
|
|
3459
|
+
}, [onColumnVisibilityChange]);
|
|
3460
|
+
const toggleColumnVisibility = React.useCallback((columnId) => {
|
|
3461
|
+
const isVisible = visibility[columnId] !== false;
|
|
3462
|
+
if (isVisible) {
|
|
3463
|
+
hideColumn(columnId);
|
|
3464
|
+
}
|
|
3465
|
+
else {
|
|
3466
|
+
showColumn(columnId);
|
|
3467
|
+
}
|
|
3468
|
+
}, [visibility, hideColumn, showColumn]);
|
|
3469
|
+
return {
|
|
3470
|
+
columnVisibility: visibility,
|
|
3471
|
+
onColumnVisibilityChange,
|
|
3472
|
+
hideColumn,
|
|
3473
|
+
showColumn,
|
|
3474
|
+
toggleColumnVisibility,
|
|
3475
|
+
};
|
|
3476
|
+
};
|
|
3477
|
+
|
|
3478
|
+
const useColumnOrdering = ({ enabled = false, columnOrder: controlledOrder, onColumnOrderChange: controlledOnChange, }) => {
|
|
3479
|
+
const isControlled = controlledOrder !== undefined;
|
|
3480
|
+
const [internalOrder, setInternalOrder] = React.useState([]);
|
|
3481
|
+
const columnOrder = isControlled ? controlledOrder : internalOrder;
|
|
3482
|
+
const onColumnOrderChange = React.useCallback(updaterOrValue => {
|
|
3483
|
+
const newOrder = typeof updaterOrValue === "function"
|
|
3484
|
+
? updaterOrValue(columnOrder)
|
|
3485
|
+
: updaterOrValue;
|
|
3486
|
+
if (!isControlled) {
|
|
3487
|
+
setInternalOrder(newOrder);
|
|
3488
|
+
}
|
|
3489
|
+
controlledOnChange?.(updaterOrValue);
|
|
3490
|
+
}, [columnOrder, isControlled, controlledOnChange]);
|
|
3491
|
+
const moveColumn = React.useCallback((columnId, direction) => {
|
|
3492
|
+
onColumnOrderChange(oldOrder => {
|
|
3493
|
+
const order = [...oldOrder];
|
|
3494
|
+
const currentIndex = order.indexOf(columnId);
|
|
3495
|
+
if (currentIndex === -1)
|
|
3496
|
+
return oldOrder;
|
|
3497
|
+
const newIndex = currentIndex + direction;
|
|
3498
|
+
if (newIndex < 0 || newIndex >= order.length)
|
|
3499
|
+
return oldOrder;
|
|
3500
|
+
order.splice(currentIndex, 1);
|
|
3501
|
+
order.splice(newIndex, 0, columnId);
|
|
3502
|
+
return order;
|
|
3503
|
+
});
|
|
3504
|
+
}, [onColumnOrderChange]);
|
|
3505
|
+
const reorderColumn = React.useCallback((fromId, toId) => {
|
|
3506
|
+
onColumnOrderChange(oldOrder => {
|
|
3507
|
+
const order = [...oldOrder];
|
|
3508
|
+
const fromIndex = order.indexOf(fromId);
|
|
3509
|
+
const toIndex = order.indexOf(toId);
|
|
3510
|
+
if (fromIndex === -1 || toIndex === -1)
|
|
3511
|
+
return oldOrder;
|
|
3512
|
+
order.splice(fromIndex, 1);
|
|
3513
|
+
order.splice(toIndex, 0, fromId);
|
|
3514
|
+
return order;
|
|
3515
|
+
});
|
|
3516
|
+
}, [onColumnOrderChange]);
|
|
3517
|
+
return {
|
|
3518
|
+
columnOrder: enabled ? columnOrder : [],
|
|
3519
|
+
onColumnOrderChange: enabled
|
|
3520
|
+
? onColumnOrderChange
|
|
3521
|
+
: (() => { }),
|
|
3522
|
+
moveColumn,
|
|
3523
|
+
reorderColumn,
|
|
3524
|
+
};
|
|
3525
|
+
};
|
|
3526
|
+
|
|
3527
|
+
const LoadingOverlay = () => (jsxRuntime.jsx("div", { className: "absolute inset-0 z-10 flex items-center justify-center bg-background/50", children: jsxRuntime.jsx(primitives_Spinner.Spinner, { className: "size-6" }) }));
|
|
3528
|
+
|
|
3529
|
+
const EmptyState = ({ colSpan, message = "No results.", }) => (jsxRuntime.jsx(primitives_Table.TableRow, { children: jsxRuntime.jsx(primitives_Table.TableCell, { colSpan: colSpan, className: "min-h-24 text-center text-muted-foreground", children: message }) }));
|
|
3530
|
+
|
|
3531
|
+
const SortIndicator = ({ column, }) => {
|
|
3532
|
+
if (!column.getCanSort())
|
|
3533
|
+
return null;
|
|
3534
|
+
const sorted = column.getIsSorted();
|
|
3535
|
+
if (sorted === "asc")
|
|
3536
|
+
return jsxRuntime.jsx(ArrowUp, { className: "ml-1 inline size-4" });
|
|
3537
|
+
if (sorted === "desc")
|
|
3538
|
+
return jsxRuntime.jsx(ArrowDown, { className: "ml-1 inline size-4" });
|
|
3539
|
+
return null;
|
|
3540
|
+
};
|
|
3541
|
+
|
|
3542
|
+
const ResizeHandle = ({ header }) => {
|
|
3543
|
+
if (!header.column.getCanResize())
|
|
3544
|
+
return null;
|
|
3545
|
+
return (jsxRuntime.jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), onDoubleClick: () => header.column.resetSize(), className: utils.cn("absolute top-0 end-0 h-full w-1 cursor-col-resize select-none touch-none", header.column.getIsResizing()
|
|
3546
|
+
? "bg-primary"
|
|
3547
|
+
: "bg-border opacity-0 group-hover/head:opacity-100") }));
|
|
3548
|
+
};
|
|
3549
|
+
|
|
3550
|
+
const BulkSelectCallout = ({ bulkSelectAllRowsProps, isAllPageRowsSelected, isBulkAllSelected, }) => {
|
|
3551
|
+
if (!isAllPageRowsSelected)
|
|
3552
|
+
return null;
|
|
3553
|
+
const { selectAllRowMessage, selectAllRowButtonLabel, setBulkSelectedAllRows, allRowsSelectedMessage, clearSelectionButtonLabel, } = bulkSelectAllRowsProps;
|
|
3554
|
+
return (jsxRuntime.jsx("div", { className: "mb-2 flex items-center justify-center gap-1 rounded-lg bg-primary/10 px-4 py-1.5 text-sm text-primary", children: isBulkAllSelected ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("span", { children: allRowsSelectedMessage ?? selectAllRowMessage }), clearSelectionButtonLabel && (jsxRuntime.jsx(primitives_Button.Button, { variant: "link", onClick: () => setBulkSelectedAllRows(false), children: clearSelectionButtonLabel }))] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("span", { children: selectAllRowMessage }), jsxRuntime.jsx(primitives_Button.Button, { variant: "link", onClick: () => setBulkSelectedAllRows(true), children: selectAllRowButtonLabel })] })) }));
|
|
3555
|
+
};
|
|
3556
|
+
|
|
3557
|
+
const DataTablePagination = ({ currentPage, pageCount, onPageChange, }) => {
|
|
3558
|
+
if (pageCount <= 1)
|
|
3559
|
+
return null;
|
|
3560
|
+
const pages = getPageNumbers(currentPage, pageCount);
|
|
3561
|
+
return (jsxRuntime.jsx("div", { className: "flex items-center justify-end py-4", children: jsxRuntime.jsx(primitives_Pagination.Pagination, { className: "mx-0 w-auto justify-end", children: jsxRuntime.jsxs(primitives_Pagination.PaginationContent, { children: [jsxRuntime.jsx(primitives_Pagination.PaginationItem, { children: jsxRuntime.jsx(primitives_Pagination.PaginationPrevious, { onClick: e => {
|
|
3562
|
+
e.preventDefault();
|
|
3563
|
+
if (currentPage > 1)
|
|
3564
|
+
onPageChange(currentPage - 1);
|
|
3565
|
+
}, className: currentPage <= 1
|
|
3566
|
+
? "pointer-events-none opacity-50"
|
|
3567
|
+
: "cursor-pointer" }) }), pages.map((page, index) => page === "ellipsis" ? (jsxRuntime.jsx(primitives_Pagination.PaginationItem, { children: jsxRuntime.jsx(primitives_Pagination.PaginationEllipsis, {}) }, `ellipsis-${index}`)) : (jsxRuntime.jsx(primitives_Pagination.PaginationItem, { children: jsxRuntime.jsx(primitives_Pagination.PaginationLink, { isActive: page === currentPage, onClick: e => {
|
|
3568
|
+
e.preventDefault();
|
|
3569
|
+
onPageChange(page);
|
|
3570
|
+
}, className: "cursor-pointer", children: page }) }, page))), jsxRuntime.jsx(primitives_Pagination.PaginationItem, { children: jsxRuntime.jsx(primitives_Pagination.PaginationNext, { onClick: e => {
|
|
3571
|
+
e.preventDefault();
|
|
3572
|
+
if (currentPage < pageCount)
|
|
3573
|
+
onPageChange(currentPage + 1);
|
|
3574
|
+
}, className: currentPage >= pageCount
|
|
3575
|
+
? "pointer-events-none opacity-50"
|
|
3576
|
+
: "cursor-pointer" }) })] }) }) }));
|
|
3577
|
+
};
|
|
3578
|
+
|
|
3579
|
+
const HeaderCellMenu = ({ column, enableAddColumn, enableColumnFreeze, isColumnPinned, canMoveLeft, canMoveRight, onSort, onHideColumn, onTogglePin, onAddColumn, onDeleteColumn, onMoveColumn, onMoreActionClick, columnIndex, }) => {
|
|
3580
|
+
const meta = column.columnDef.meta;
|
|
3581
|
+
const isSortable = column.getCanSort();
|
|
3582
|
+
const isHidable = meta?.isHidable !== false;
|
|
3583
|
+
const isDeletable = meta?.isDeletable === true;
|
|
3584
|
+
const moreActions = meta?.moreActions ?? [];
|
|
3585
|
+
const currentSort = column.getIsSorted();
|
|
3586
|
+
const hasAnyAction = isSortable ||
|
|
3587
|
+
isHidable ||
|
|
3588
|
+
enableAddColumn ||
|
|
3589
|
+
enableColumnFreeze ||
|
|
3590
|
+
isDeletable ||
|
|
3591
|
+
canMoveLeft ||
|
|
3592
|
+
canMoveRight ||
|
|
3593
|
+
moreActions.length > 0;
|
|
3594
|
+
if (!hasAnyAction)
|
|
3595
|
+
return null;
|
|
3596
|
+
return (jsxRuntime.jsx("div", { onClick: e => e.stopPropagation(), children: jsxRuntime.jsxs(primitives_DropdownMenu.DropdownMenu, { children: [jsxRuntime.jsx(primitives_DropdownMenu.DropdownMenuTrigger, { asChild: true, children: jsxRuntime.jsx(primitives_Button.Button, { variant: "ghost", size: "icon", className: "ml-1 size-7 shrink-0 text-muted-foreground data-[state=open]:bg-muted", "data-testid": "column-menu-button", children: jsxRuntime.jsx(ellipsis.Ellipsis, { className: "size-4" }) }) }), jsxRuntime.jsxs(primitives_DropdownMenu.DropdownMenuContent, { align: "start", className: "w-48", children: [isSortable && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(primitives_DropdownMenu.DropdownMenuItem, { "data-testid": "ascending-column-menu-button", onClick: () => onSort?.(column.id, false), children: [jsxRuntime.jsx(ArrowUp, { className: "mr-2 size-4" }), "Ascending", currentSort === "asc" && (jsxRuntime.jsx(check.Check, { className: "ml-auto size-4 text-primary" }))] }), jsxRuntime.jsxs(primitives_DropdownMenu.DropdownMenuItem, { "data-testid": "descending-column-menu-button", onClick: () => onSort?.(column.id, true), children: [jsxRuntime.jsx(ArrowDown, { className: "mr-2 size-4" }), "Descending", currentSort === "desc" && (jsxRuntime.jsx(check.Check, { className: "ml-auto size-4 text-primary" }))] })] })), enableAddColumn && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(primitives_DropdownMenu.DropdownMenuItem, { "data-testid": "insert-right-column-menu-button", onClick: () => onAddColumn?.(columnIndex + 1), children: [jsxRuntime.jsx(Plus, { className: "mr-2 size-4" }), "Insert column right"] }), jsxRuntime.jsxs(primitives_DropdownMenu.DropdownMenuItem, { "data-testid": "insert-left-column-menu-button", onClick: () => onAddColumn?.(columnIndex), children: [jsxRuntime.jsx(Plus, { className: "mr-2 size-4" }), "Insert column left"] })] })), isHidable && onHideColumn && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(primitives_DropdownMenu.DropdownMenuItem, { "data-testid": "hide-column-menu-button", onClick: () => onHideColumn(column.id), children: [jsxRuntime.jsx(EyeOff, { className: "mr-2 size-4" }), "Hide column"] }) })), isDeletable && onDeleteColumn && (jsxRuntime.jsxs(primitives_DropdownMenu.DropdownMenuItem, { "data-testid": "delete-column-menu-button", onClick: () => onDeleteColumn(column.id), children: [jsxRuntime.jsx(Trash2, { className: "mr-2 size-4" }), "Delete column"] })), enableColumnFreeze && onTogglePin && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(primitives_DropdownMenu.DropdownMenuItem, { "data-testid": "freeze-unfreeze-column-menu-button", onClick: () => onTogglePin(column.id), children: [jsxRuntime.jsx(Pin, { className: "mr-2 size-4" }), isColumnPinned ? "Unfreeze column" : "Freeze column"] }) })), onMoveColumn && (canMoveLeft || canMoveRight) && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [canMoveLeft && (jsxRuntime.jsxs(primitives_DropdownMenu.DropdownMenuItem, { "data-testid": "move-column-left-menu-button", onClick: () => onMoveColumn(column.id, -1), children: [jsxRuntime.jsx(MoveLeft, { className: "mr-2 size-4" }), "Move column left"] })), canMoveRight && (jsxRuntime.jsxs(primitives_DropdownMenu.DropdownMenuItem, { "data-testid": "move-column-right-menu-button", onClick: () => onMoveColumn(column.id, 1), children: [jsxRuntime.jsx(MoveRight, { className: "mr-2 size-4" }), "Move column right"] }))] })), moreActions.length > 0 && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: moreActions.map(action => {
|
|
3597
|
+
const ActionIcon = action.icon;
|
|
3598
|
+
return (jsxRuntime.jsxs(primitives_DropdownMenu.DropdownMenuItem, { "data-testid": `${action.type}-column-menu-button`, onClick: () => onMoreActionClick?.(action.type, column.id), children: [ActionIcon && jsxRuntime.jsx(ActionIcon, { className: "mr-2 size-4" }), action.label] }, action.type));
|
|
3599
|
+
}) }))] })] }) }));
|
|
3600
|
+
};
|
|
3601
|
+
|
|
3602
|
+
const DataTable = ({ columns, data, getRowId: getRowIdProp, sorting: sortingProp, onSortingChange: onSortingChangeProp, enableSorting = true, enableURLSort = true, totalCount, pageSize = DEFAULT_PAGE_SIZE, currentPage: currentPageProp, onPageChange: onPageChangeProp, enableURLPagination = true, enableRowSelection: enableRowSelectionProp, selectedRowKeys, onRowSelect, bulkSelectAllRowsProps, enableColumnResize = true, enableColumnFreeze = true, columnPinning: columnPinningProp, onColumnPinningChange: onColumnPinningChangeProp, localStorageKeyPrefix, columnVisibility: columnVisibilityProp, onColumnVisibilityChange: onColumnVisibilityChangeProp, onColumnHide: onColumnHideProp, enableColumnReorder = false, columnOrder: columnOrderProp, onColumnOrderChange: onColumnOrderChangeProp, enableAddColumn = false, onColumnAdd, onColumnDelete, onColumnUpdate, onMoreActionClick, enableHeaderMenu, loading = false, bordered = true, className, emptyMessage, onRowClick, allowRowClick = true, }) => {
|
|
3603
|
+
const getRowId = React.useMemo(() => getRowIdProp ??
|
|
3604
|
+
((row) => row.id), [getRowIdProp]);
|
|
3605
|
+
const { sorting, onSortingChange } = useTableSort({
|
|
3606
|
+
sorting: sortingProp,
|
|
3607
|
+
onSortingChange: onSortingChangeProp,
|
|
3608
|
+
enableURLSort,
|
|
3609
|
+
});
|
|
3610
|
+
const { currentPage, pageCount, paginationState, onPageChange } = useTablePagination({
|
|
3611
|
+
totalCount,
|
|
3612
|
+
pageSize,
|
|
3613
|
+
currentPage: currentPageProp,
|
|
3614
|
+
onPageChange: onPageChangeProp,
|
|
3615
|
+
enableURLPagination,
|
|
3616
|
+
});
|
|
3617
|
+
const { rowSelection, onRowSelectionChange, selectionColumn, enableRowSelection, } = useTableSelection({
|
|
3618
|
+
enableRowSelection: enableRowSelectionProp,
|
|
3619
|
+
selectedRowKeys,
|
|
3620
|
+
onRowSelect,
|
|
3621
|
+
data,
|
|
3622
|
+
getRowId,
|
|
3623
|
+
});
|
|
3624
|
+
const { columnPinning, onColumnPinningChange, toggleColumnPin, isColumnPinned, } = useColumnPinning({
|
|
3625
|
+
enabled: enableColumnFreeze,
|
|
3626
|
+
columnPinning: columnPinningProp,
|
|
3627
|
+
onColumnPinningChange: onColumnPinningChangeProp,
|
|
3628
|
+
localStorageKeyPrefix,
|
|
3629
|
+
});
|
|
3630
|
+
const { columnVisibility, onColumnVisibilityChange, hideColumn } = useColumnVisibility({
|
|
3631
|
+
columnVisibility: columnVisibilityProp,
|
|
3632
|
+
onColumnVisibilityChange: onColumnVisibilityChangeProp,
|
|
3633
|
+
onColumnHide: onColumnHideProp,
|
|
3634
|
+
});
|
|
3635
|
+
const { columnOrder, onColumnOrderChange, moveColumn } = useColumnOrdering({
|
|
3636
|
+
enabled: enableColumnReorder,
|
|
3637
|
+
columnOrder: columnOrderProp,
|
|
3638
|
+
onColumnOrderChange: onColumnOrderChangeProp,
|
|
3639
|
+
});
|
|
3640
|
+
const showHeaderMenu = enableHeaderMenu ??
|
|
3641
|
+
(enableColumnFreeze ||
|
|
3642
|
+
enableAddColumn ||
|
|
3643
|
+
!!onColumnHideProp ||
|
|
3644
|
+
!!onColumnDelete ||
|
|
3645
|
+
!!onColumnUpdate ||
|
|
3646
|
+
!!onMoreActionClick);
|
|
3647
|
+
const allColumns = React.useMemo(() => {
|
|
3648
|
+
if (selectionColumn) {
|
|
3649
|
+
return [selectionColumn, ...columns];
|
|
3650
|
+
}
|
|
3651
|
+
return columns;
|
|
3652
|
+
}, [columns, selectionColumn]);
|
|
3653
|
+
const resolvedColumnOrder = React.useMemo(() => {
|
|
3654
|
+
if (columnOrder.length === 0)
|
|
3655
|
+
return [];
|
|
3656
|
+
if (selectionColumn && !columnOrder.includes("_selection")) {
|
|
3657
|
+
return ["_selection", ...columnOrder];
|
|
3658
|
+
}
|
|
3659
|
+
return columnOrder;
|
|
3660
|
+
}, [columnOrder, selectionColumn]);
|
|
3661
|
+
const resolvedColumnPinning = React.useMemo(() => {
|
|
3662
|
+
if (!selectionColumn || !enableColumnFreeze)
|
|
3663
|
+
return columnPinning;
|
|
3664
|
+
const left = columnPinning.left ?? [];
|
|
3665
|
+
if (left.includes("_selection"))
|
|
3666
|
+
return columnPinning;
|
|
3667
|
+
return { ...columnPinning, left: ["_selection", ...left] };
|
|
3668
|
+
}, [columnPinning, selectionColumn, enableColumnFreeze]);
|
|
3669
|
+
const table = useReactTable({
|
|
3670
|
+
data,
|
|
3671
|
+
columns: allColumns,
|
|
3672
|
+
getCoreRowModel: getCoreRowModel(),
|
|
3673
|
+
getRowId,
|
|
3674
|
+
manualSorting: true,
|
|
3675
|
+
enableSorting,
|
|
3676
|
+
state: {
|
|
3677
|
+
sorting,
|
|
3678
|
+
pagination: paginationState,
|
|
3679
|
+
rowSelection,
|
|
3680
|
+
columnPinning: resolvedColumnPinning,
|
|
3681
|
+
columnVisibility,
|
|
3682
|
+
columnOrder: resolvedColumnOrder,
|
|
3683
|
+
},
|
|
3684
|
+
onSortingChange,
|
|
3685
|
+
manualPagination: true,
|
|
3686
|
+
pageCount,
|
|
3687
|
+
onPaginationChange: () => { },
|
|
3688
|
+
enableRowSelection,
|
|
3689
|
+
onRowSelectionChange,
|
|
3690
|
+
enableColumnResizing: enableColumnResize,
|
|
3691
|
+
columnResizeMode: "onChange",
|
|
3692
|
+
onColumnPinningChange,
|
|
3693
|
+
onColumnVisibilityChange,
|
|
3694
|
+
onColumnOrderChange,
|
|
3695
|
+
});
|
|
3696
|
+
const isBulkAllSelected = !!bulkSelectAllRowsProps && table.getIsAllPageRowsSelected();
|
|
3697
|
+
const handleSort = (columnId, desc) => {
|
|
3698
|
+
const isSameSort = sorting.length > 0 &&
|
|
3699
|
+
sorting[0].id === columnId &&
|
|
3700
|
+
sorting[0].desc === desc;
|
|
3701
|
+
if (isSameSort) {
|
|
3702
|
+
onSortingChange([]);
|
|
3703
|
+
}
|
|
3704
|
+
else {
|
|
3705
|
+
onSortingChange([{ id: columnId, desc }]);
|
|
3706
|
+
}
|
|
3707
|
+
};
|
|
3708
|
+
return (jsxRuntime.jsxs("div", { className: utils.cn("relative flex min-h-0 w-full flex-col", className), children: [loading && jsxRuntime.jsx(LoadingOverlay, {}), bulkSelectAllRowsProps && (jsxRuntime.jsx(BulkSelectCallout, { bulkSelectAllRowsProps: bulkSelectAllRowsProps, isAllPageRowsSelected: table.getIsAllPageRowsSelected(), isBulkAllSelected: isBulkAllSelected })), jsxRuntime.jsx("div", { className: utils.cn("min-h-0 flex-1 overflow-auto", bordered && "rounded-lg border"), children: jsxRuntime.jsxs(primitives_Table.Table, { children: [jsxRuntime.jsx(primitives_Table.TableHeader, { className: "sticky top-0 z-20 bg-muted", children: table.getHeaderGroups().map(headerGroup => (jsxRuntime.jsx(primitives_Table.TableRow, { className: "hover:bg-muted", children: headerGroup.headers.map((header, headerIndex) => {
|
|
3709
|
+
const isPinned = header.column.getIsPinned();
|
|
3710
|
+
const isSelectionCol = header.column.id === "_selection";
|
|
3711
|
+
const visibleHeaders = headerGroup.headers.filter(h => h.column.id !== "_selection");
|
|
3712
|
+
const columnIndexInData = visibleHeaders.findIndex(h => h.id === header.id);
|
|
3713
|
+
return (jsxRuntime.jsxs(primitives_Table.TableHead, { className: utils.cn("group/head relative", header.column.getCanSort() &&
|
|
3714
|
+
"cursor-pointer select-none", isPinned && "sticky z-10 bg-muted"), style: {
|
|
3715
|
+
width: header.getSize(),
|
|
3716
|
+
minWidth: enableColumnResize
|
|
3717
|
+
? header.getSize()
|
|
3718
|
+
: undefined,
|
|
3719
|
+
...(isPinned === "left"
|
|
3720
|
+
? {
|
|
3721
|
+
left: header.column.getStart("left"),
|
|
3722
|
+
}
|
|
3723
|
+
: {}),
|
|
3724
|
+
...(isPinned === "right"
|
|
3725
|
+
? {
|
|
3726
|
+
right: header.column.getAfter("right"),
|
|
3727
|
+
}
|
|
3728
|
+
: {}),
|
|
3729
|
+
}, onClick: header.column.getCanSort()
|
|
3730
|
+
? header.column.getToggleSortingHandler()
|
|
3731
|
+
: undefined, children: [header.isPlaceholder ? null : (jsxRuntime.jsxs("div", { className: "flex items-center", children: [jsxRuntime.jsx("div", { className: "flex-1 truncate", children: flexRender(header.column.columnDef.header, header.getContext()) }), jsxRuntime.jsx(SortIndicator, { column: header.column }), showHeaderMenu && !isSelectionCol && (jsxRuntime.jsx(HeaderCellMenu, { column: header.column, columnIndex: columnIndexInData, enableAddColumn: enableAddColumn, enableColumnFreeze: enableColumnFreeze, isColumnPinned: isColumnPinned(header.column.id), canMoveLeft: headerIndex > (selectionColumn ? 1 : 0), canMoveRight: headerIndex < headerGroup.headers.length - 1, onSort: handleSort, onHideColumn: onColumnHideProp ? hideColumn : undefined, onTogglePin: toggleColumnPin, onAddColumn: onColumnAdd, onDeleteColumn: onColumnDelete, onMoveColumn: onColumnUpdate
|
|
3732
|
+
? (colId, dir) => moveColumn(colId, dir)
|
|
3733
|
+
: undefined, onMoreActionClick: onMoreActionClick }))] })), enableColumnResize && jsxRuntime.jsx(ResizeHandle, { header: header })] }, header.id));
|
|
3734
|
+
}) }, headerGroup.id))) }), jsxRuntime.jsx(primitives_Table.TableBody, { className: loading ? "opacity-50" : undefined, children: table.getRowModel().rows.length > 0 ? (table.getRowModel().rows.map(row => (jsxRuntime.jsx(primitives_Table.TableRow, { "data-state": row.getIsSelected() ? "selected" : undefined, className: utils.cn(allowRowClick && onRowClick && "cursor-pointer"), onClick: allowRowClick && onRowClick
|
|
3735
|
+
? event => onRowClick(event, row.original, row.index)
|
|
3736
|
+
: undefined, children: row.getVisibleCells().map(cell => {
|
|
3737
|
+
const isPinned = cell.column.getIsPinned();
|
|
3738
|
+
return (jsxRuntime.jsx(primitives_Table.TableCell, { className: utils.cn(isPinned && "sticky z-10 bg-background"), style: {
|
|
3739
|
+
width: cell.column.getSize(),
|
|
3740
|
+
minWidth: enableColumnResize
|
|
3741
|
+
? cell.column.getSize()
|
|
3742
|
+
: undefined,
|
|
3743
|
+
...(isPinned === "left"
|
|
3744
|
+
? {
|
|
3745
|
+
left: cell.column.getStart("left"),
|
|
3746
|
+
}
|
|
3747
|
+
: {}),
|
|
3748
|
+
...(isPinned === "right"
|
|
3749
|
+
? {
|
|
3750
|
+
right: cell.column.getAfter("right"),
|
|
3751
|
+
}
|
|
3752
|
+
: {}),
|
|
3753
|
+
}, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
|
|
3754
|
+
}) }, row.id)))) : (jsxRuntime.jsx(EmptyState, { colSpan: allColumns.length, message: emptyMessage })) })] }) }), totalCount !== undefined && totalCount > 0 && (jsxRuntime.jsx(DataTablePagination, { currentPage: currentPage, pageCount: pageCount, onPageChange: onPageChange }))] }));
|
|
3755
|
+
};
|
|
3756
|
+
|
|
3757
|
+
exports.DataTable = DataTable;
|
|
3758
|
+
exports.useColumnOrdering = useColumnOrdering;
|
|
3759
|
+
exports.useColumnPinning = useColumnPinning;
|
|
3760
|
+
exports.useColumnVisibility = useColumnVisibility;
|
|
3761
|
+
exports.useTablePagination = useTablePagination;
|
|
3762
|
+
exports.useTableSelection = useTableSelection;
|
|
3763
|
+
exports.useTableSort = useTableSort;
|
|
3764
|
+
//# sourceMappingURL=DataTable-DJw2SZ7b.js.map
|