@rio-cloud/uikit-mcp 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -40
- package/dist/doc-metadata.json +1872 -0
- package/dist/docs/components/accentBar.md +582 -0
- package/dist/docs/components/activity.md +330 -0
- package/dist/docs/components/animatedNumber.md +88 -0
- package/dist/docs/components/animatedTextReveal.md +381 -0
- package/dist/docs/components/animations.md +459 -0
- package/dist/docs/components/appHeader.md +737 -0
- package/dist/docs/components/appLayout.md +2016 -0
- package/dist/docs/components/appNavigationBar.md +274 -0
- package/dist/docs/components/areaCharts.md +828 -0
- package/dist/docs/components/aspectRatioPlaceholder.md +106 -0
- package/dist/docs/components/assetTree.md +3223 -0
- package/dist/docs/components/autosuggests.md +1177 -0
- package/dist/docs/components/avatar.md +206 -0
- package/dist/docs/components/banner.md +668 -0
- package/dist/docs/components/barCharts.md +2785 -0
- package/dist/docs/components/barList.md +517 -0
- package/dist/docs/components/basicMap.md +167 -0
- package/dist/docs/components/bottomSheet.md +721 -0
- package/dist/docs/components/button.md +775 -0
- package/dist/docs/components/buttonToolbar.md +134 -0
- package/dist/docs/components/calendarStripe.md +525 -0
- package/dist/docs/components/card.md +86 -0
- package/dist/docs/components/carousel.md +128 -0
- package/dist/docs/components/chartColors.md +716 -0
- package/dist/docs/components/chartsGettingStarted.md +28 -0
- package/dist/docs/components/chat.md +932 -0
- package/dist/docs/components/checkbox.md +996 -0
- package/dist/docs/components/clearableInput.md +806 -0
- package/dist/docs/components/collapse.md +189 -0
- package/dist/docs/components/composedCharts.md +424 -0
- package/dist/docs/components/contentLoader.md +674 -0
- package/dist/docs/components/dataTabs.md +1251 -0
- package/dist/docs/components/datepickers.md +2543 -0
- package/dist/docs/components/dialogs.md +2244 -0
- package/dist/docs/components/divider.md +219 -0
- package/dist/docs/components/dropdowns.md +17550 -0
- package/dist/docs/components/editableContent.md +1127 -0
- package/dist/docs/components/expander.md +970 -0
- package/dist/docs/components/fade.md +836 -0
- package/dist/docs/components/fadeExpander.md +180 -0
- package/dist/docs/components/fadeUp.md +396 -0
- package/dist/docs/components/feedback.md +758 -0
- package/dist/docs/components/filePickers.md +370 -0
- package/dist/docs/components/formLabel.md +251 -0
- package/dist/docs/components/fullscreenMap.md +10 -0
- package/dist/docs/components/groupedItemList.md +1001 -0
- package/dist/docs/components/iconList.md +306 -0
- package/dist/docs/components/imagePreloader.md +167 -0
- package/dist/docs/components/labeledElement.md +115 -0
- package/dist/docs/components/licensePlate.md +412 -0
- package/dist/docs/components/lineCharts.md +2014 -0
- package/dist/docs/components/listMenu.md +392 -0
- package/dist/docs/components/loadMore.md +219 -0
- package/dist/docs/components/mainNavigation.md +129 -0
- package/dist/docs/components/mapCircle.md +93 -0
- package/dist/docs/components/mapCluster.md +337 -0
- package/dist/docs/components/mapContext.md +284 -0
- package/dist/docs/components/mapDraggableMarker.md +150 -0
- package/dist/docs/components/mapGettingStarted.md +39 -0
- package/dist/docs/components/mapInfoBubble.md +135 -0
- package/dist/docs/components/mapLayerGroup.md +94 -0
- package/dist/docs/components/mapMarker.md +1814 -0
- package/dist/docs/components/mapPolygon.md +959 -0
- package/dist/docs/components/mapRoute.md +3816 -0
- package/dist/docs/components/mapRouteGenerator.md +6 -0
- package/dist/docs/components/mapSettings.md +1040 -0
- package/dist/docs/components/mapUtils.md +132 -0
- package/dist/docs/components/multiselects.md +1921 -0
- package/dist/docs/components/noData.md +210 -0
- package/dist/docs/components/notifications.md +314 -0
- package/dist/docs/components/numbercontrol.md +706 -0
- package/dist/docs/components/onboarding.md +297 -0
- package/dist/docs/components/page.md +241 -0
- package/dist/docs/components/pager.md +133 -0
- package/dist/docs/components/pieCharts.md +1284 -0
- package/dist/docs/components/popover.md +222 -0
- package/dist/docs/components/position.md +50 -0
- package/dist/docs/components/radialBarCharts.md +3663 -0
- package/dist/docs/components/radiobutton.md +1271 -0
- package/dist/docs/components/releaseNotes.md +135 -0
- package/dist/docs/components/resizer.md +162 -0
- package/dist/docs/components/responsiveColumnStripe.md +435 -0
- package/dist/docs/components/responsiveVideo.md +71 -0
- package/dist/docs/components/rioglyph.md +331 -0
- package/dist/docs/components/rules.md +965 -0
- package/dist/docs/components/saveableInput.md +1721 -0
- package/dist/docs/components/selects.md +1993 -0
- package/dist/docs/components/sidebar.md +332 -0
- package/dist/docs/components/sliders.md +376 -0
- package/dist/docs/components/smoothScrollbars.md +1180 -0
- package/dist/docs/components/spinners.md +506 -0
- package/dist/docs/components/states.md +1176 -0
- package/dist/docs/components/statsWidgets.md +636 -0
- package/dist/docs/components/statusBar.md +644 -0
- package/dist/docs/components/stepButton.md +61 -0
- package/dist/docs/components/steppedProgressBars.md +1064 -0
- package/dist/docs/components/subNavigation.md +470 -0
- package/dist/docs/components/supportMarker.md +115 -0
- package/dist/docs/components/svgImage.md +248 -0
- package/dist/docs/components/switch.md +554 -0
- package/dist/docs/components/tables.md +8 -0
- package/dist/docs/components/tagManager.md +476 -0
- package/dist/docs/components/tags.md +785 -0
- package/dist/docs/components/teaser.md +925 -0
- package/dist/docs/components/timeline.md +514 -0
- package/dist/docs/components/timepicker.md +262 -0
- package/dist/docs/components/toggleButton.md +178 -0
- package/dist/docs/components/tooltip.md +454 -0
- package/dist/docs/components/virtualList.md +483 -0
- package/dist/docs/foundations.md +20901 -0
- package/dist/docs/start/changelog.md +439 -0
- package/dist/docs/start/goodtoknow.md +14 -0
- package/dist/docs/start/guidelines/color-combinations.md +678 -0
- package/dist/docs/start/guidelines/custom-css.md +42 -0
- package/dist/docs/start/guidelines/custom-rioglyph.md +35 -0
- package/dist/docs/start/guidelines/formatting.md +587 -0
- package/dist/docs/start/guidelines/iframe.md +323 -0
- package/dist/docs/start/guidelines/obfuscate-data.md +30 -0
- package/dist/docs/start/guidelines/print-css.md +36 -0
- package/dist/docs/start/guidelines/spinner.md +710 -0
- package/dist/docs/start/guidelines/supported-browsers.md +10 -0
- package/dist/docs/start/guidelines/writing.md +635 -0
- package/dist/docs/start/howto.md +187 -0
- package/dist/docs/start/intro.md +43 -0
- package/dist/docs/start/responsiveness.md +98 -0
- package/dist/docs/templates/common-table.md +1111 -0
- package/dist/docs/templates/detail-views.md +942 -0
- package/dist/docs/templates/expandable-details.md +228 -0
- package/dist/docs/templates/feature-cards.md +549 -0
- package/dist/docs/templates/form-summary.md +199 -0
- package/dist/docs/templates/form-toggle.md +367 -0
- package/dist/docs/templates/list-blocks.md +1021 -0
- package/dist/docs/templates/loading-progress.md +109 -0
- package/dist/docs/templates/options-panel.md +152 -0
- package/dist/docs/templates/panel-variants.md +164 -0
- package/dist/docs/templates/progress-cards.md +607 -0
- package/dist/docs/templates/progress-success.md +142 -0
- package/dist/docs/templates/settings-form.md +434 -0
- package/dist/docs/templates/stats-blocks.md +1381 -0
- package/dist/docs/templates/table-panel.md +184 -0
- package/dist/docs/templates/table-row-animation.md +317 -0
- package/dist/docs/templates/usage-cards.md +227 -0
- package/dist/docs/utilities/deviceUtils.md +123 -0
- package/dist/docs/utilities/featureToggles.md +90 -0
- package/dist/docs/utilities/fuelTypeUtils.md +186 -0
- package/dist/docs/utilities/routeUtils.md +138 -0
- package/dist/docs/utilities/useAfterMount.md +66 -0
- package/dist/docs/utilities/useAutoAnimate.md +193 -0
- package/dist/docs/utilities/useAverage.md +95 -0
- package/dist/docs/utilities/useClickOutside.md +61 -0
- package/dist/docs/utilities/useClipboard.md +93 -0
- package/dist/docs/utilities/useCount.md +178 -0
- package/dist/docs/utilities/useDarkMode.md +49 -0
- package/dist/docs/utilities/useDebugInfo.md +126 -0
- package/dist/docs/utilities/useEffectOnce.md +58 -0
- package/dist/docs/utilities/useElapsedTime.md +58 -0
- package/dist/docs/utilities/useElementSize.md +71 -0
- package/dist/docs/utilities/useEsc.md +58 -0
- package/dist/docs/utilities/useEvent.md +64 -0
- package/dist/docs/utilities/useFocusTrap.md +85 -0
- package/dist/docs/utilities/useFullscreen.md +198 -0
- package/dist/docs/utilities/useHover.md +55 -0
- package/dist/docs/utilities/useIncomingPostMessages.md +237 -0
- package/dist/docs/utilities/useInterval.md +85 -0
- package/dist/docs/utilities/useIsFocusWithin.md +114 -0
- package/dist/docs/utilities/useKey.md +151 -0
- package/dist/docs/utilities/useLocalStorage.md +91 -0
- package/dist/docs/utilities/useLocationSuggestions.md +114 -0
- package/dist/docs/utilities/useMax.md +62 -0
- package/dist/docs/utilities/useMin.md +78 -0
- package/dist/docs/utilities/useMutationObserver.md +113 -0
- package/dist/docs/utilities/useOnScreen.md +138 -0
- package/dist/docs/utilities/useOnlineStatus.md +49 -0
- package/dist/docs/utilities/usePostMessage.md +117 -0
- package/dist/docs/utilities/usePostMessageSender.md +257 -0
- package/dist/docs/utilities/usePrevious.md +101 -0
- package/dist/docs/utilities/useResizeObserver.md +151 -0
- package/dist/docs/utilities/useScrollPosition.md +252 -0
- package/dist/docs/utilities/useSearch.md +228 -0
- package/dist/docs/utilities/useSorting.md +389 -0
- package/dist/docs/utilities/useStateWithValidation.md +83 -0
- package/dist/docs/utilities/useSum.md +155 -0
- package/dist/docs/utilities/useTableExport.md +404 -0
- package/dist/docs/utilities/useTableSelection.md +1120 -0
- package/dist/docs/utilities/useTimeout.md +55 -0
- package/dist/docs/utilities/useToggle.md +115 -0
- package/dist/docs/utilities/useWindowResize.md +70 -0
- package/dist/index.mjs +271 -0
- package/dist/search-synonyms.json +134 -0
- package/dist/version.json +4 -0
- package/package.json +23 -19
- package/bin/uikit-mcp.mjs +0 -23
- package/data/pages/Components/components/accentbar.json +0 -207
- package/data/pages/Components/components/activity.json +0 -87
- package/data/pages/Components/components/animatednumber.json +0 -99
- package/data/pages/Components/components/animations.json +0 -87
- package/data/pages/Components/components/appheader.json +0 -291
- package/data/pages/Components/components/applayout.json +0 -1198
- package/data/pages/Components/components/appnavigationbar.json +0 -327
- package/data/pages/Components/components/areacharts.json +0 -563
- package/data/pages/Components/components/aspectratioplaceholder.json +0 -75
- package/data/pages/Components/components/assettree.json +0 -3080
- package/data/pages/Components/components/autosuggests.json +0 -710
- package/data/pages/Components/components/avatar.json +0 -157
- package/data/pages/Components/components/banner.json +0 -599
- package/data/pages/Components/components/barcharts.json +0 -1507
- package/data/pages/Components/components/barlist.json +0 -223
- package/data/pages/Components/components/basicmap.json +0 -68
- package/data/pages/Components/components/bottomsheet.json +0 -601
- package/data/pages/Components/components/button.json +0 -583
- package/data/pages/Components/components/buttontoolbar.json +0 -63
- package/data/pages/Components/components/calendarstripe.json +0 -235
- package/data/pages/Components/components/card.json +0 -69
- package/data/pages/Components/components/carousel.json +0 -39
- package/data/pages/Components/components/chartcolors.json +0 -34
- package/data/pages/Components/components/chartsgettingstarted.json +0 -32
- package/data/pages/Components/components/chat.json +0 -39
- package/data/pages/Components/components/checkbox.json +0 -847
- package/data/pages/Components/components/clearableinput.json +0 -789
- package/data/pages/Components/components/collapse.json +0 -175
- package/data/pages/Components/components/composedcharts.json +0 -159
- package/data/pages/Components/components/contentloader.json +0 -233
- package/data/pages/Components/components/datatabs.json +0 -680
- package/data/pages/Components/components/datepickers.json +0 -287
- package/data/pages/Components/components/dialogs.json +0 -1492
- package/data/pages/Components/components/divider.json +0 -93
- package/data/pages/Components/components/dropdowns.json +0 -936
- package/data/pages/Components/components/editablecontent.json +0 -1117
- package/data/pages/Components/components/expander.json +0 -377
- package/data/pages/Components/components/fade.json +0 -403
- package/data/pages/Components/components/fadeexpander.json +0 -75
- package/data/pages/Components/components/fadeup.json +0 -127
- package/data/pages/Components/components/feedback.json +0 -269
- package/data/pages/Components/components/filepickers.json +0 -269
- package/data/pages/Components/components/formlabel.json +0 -115
- package/data/pages/Components/components/fullscreenmap.json +0 -22
- package/data/pages/Components/components/groupeditemlist.json +0 -323
- package/data/pages/Components/components/iconlist.json +0 -45
- package/data/pages/Components/components/imagepreloader.json +0 -81
- package/data/pages/Components/components/labeledelement.json +0 -75
- package/data/pages/Components/components/licenseplate.json +0 -69
- package/data/pages/Components/components/linecharts.json +0 -987
- package/data/pages/Components/components/listmenu.json +0 -313
- package/data/pages/Components/components/loadmore.json +0 -175
- package/data/pages/Components/components/mainnavigation.json +0 -39
- package/data/pages/Components/components/mapcircle.json +0 -34
- package/data/pages/Components/components/mapcluster.json +0 -51
- package/data/pages/Components/components/mapcontext.json +0 -105
- package/data/pages/Components/components/mapdraggablemarker.json +0 -34
- package/data/pages/Components/components/mapgettingstarted.json +0 -27
- package/data/pages/Components/components/mapgroup.json +0 -1198
- package/data/pages/Components/components/mapinfobubble.json +0 -34
- package/data/pages/Components/components/maplayergroup.json +0 -34
- package/data/pages/Components/components/mapmarker.json +0 -700
- package/data/pages/Components/components/mappolygon.json +0 -45
- package/data/pages/Components/components/maproute.json +0 -623
- package/data/pages/Components/components/maproutegenerator.json +0 -16
- package/data/pages/Components/components/mapsettings.json +0 -51
- package/data/pages/Components/components/maputils.json +0 -34
- package/data/pages/Components/components/multiselects.json +0 -1451
- package/data/pages/Components/components/nodata.json +0 -139
- package/data/pages/Components/components/notifications.json +0 -65
- package/data/pages/Components/components/numbercontrol.json +0 -301
- package/data/pages/Components/components/onboarding.json +0 -302
- package/data/pages/Components/components/page.json +0 -197
- package/data/pages/Components/components/pager.json +0 -93
- package/data/pages/Components/components/piecharts.json +0 -731
- package/data/pages/Components/components/popover.json +0 -251
- package/data/pages/Components/components/position.json +0 -69
- package/data/pages/Components/components/radialbarcharts.json +0 -1304
- package/data/pages/Components/components/radiobutton.json +0 -1105
- package/data/pages/Components/components/releasenotes.json +0 -44
- package/data/pages/Components/components/resizer.json +0 -93
- package/data/pages/Components/components/responsivecolumnstripe.json +0 -123
- package/data/pages/Components/components/responsivevideo.json +0 -75
- package/data/pages/Components/components/rioglyph.json +0 -93
- package/data/pages/Components/components/rules.json +0 -410
- package/data/pages/Components/components/saveableinput.json +0 -703
- package/data/pages/Components/components/selects.json +0 -701
- package/data/pages/Components/components/sidebar.json +0 -243
- package/data/pages/Components/components/sliders.json +0 -235
- package/data/pages/Components/components/smoothscrollbars.json +0 -335
- package/data/pages/Components/components/spinners.json +0 -343
- package/data/pages/Components/components/states.json +0 -1705
- package/data/pages/Components/components/statswidgets.json +0 -314
- package/data/pages/Components/components/statusbar.json +0 -177
- package/data/pages/Components/components/stepbutton.json +0 -57
- package/data/pages/Components/components/steppedprogressbars.json +0 -417
- package/data/pages/Components/components/subnavigation.json +0 -107
- package/data/pages/Components/components/supportmarker.json +0 -45
- package/data/pages/Components/components/svgimage.json +0 -81
- package/data/pages/Components/components/switch.json +0 -111
- package/data/pages/Components/components/tables.json +0 -144
- package/data/pages/Components/components/tagmanager.json +0 -86
- package/data/pages/Components/components/tags.json +0 -146
- package/data/pages/Components/components/teaser.json +0 -188
- package/data/pages/Components/components/timeline.json +0 -45
- package/data/pages/Components/components/timepicker.json +0 -163
- package/data/pages/Components/components/togglebutton.json +0 -247
- package/data/pages/Components/components/tooltip.json +0 -270
- package/data/pages/Components/components/virtuallist.json +0 -175
- package/data/pages/Foundations/foundations.json +0 -2475
- package/data/pages/Getting-started/start/changelog.json +0 -22
- package/data/pages/Getting-started/start/goodtoknow.json +0 -32
- package/data/pages/Getting-started/start/guidelines/color-combinations.json +0 -58
- package/data/pages/Getting-started/start/guidelines/custom-css.json +0 -27
- package/data/pages/Getting-started/start/guidelines/custom-rioglyph.json +0 -22
- package/data/pages/Getting-started/start/guidelines/formatting.json +0 -97
- package/data/pages/Getting-started/start/guidelines/iframe.json +0 -93
- package/data/pages/Getting-started/start/guidelines/obfuscate-data.json +0 -22
- package/data/pages/Getting-started/start/guidelines/print-css.json +0 -37
- package/data/pages/Getting-started/start/guidelines/spinner.json +0 -144
- package/data/pages/Getting-started/start/guidelines/supported-browsers.json +0 -22
- package/data/pages/Getting-started/start/guidelines/writing.json +0 -242
- package/data/pages/Getting-started/start/howto.json +0 -72
- package/data/pages/Getting-started/start/intro.json +0 -37
- package/data/pages/Getting-started/start/responsiveness.json +0 -52
- package/data/pages/Templates/templates/common-table.json +0 -39
- package/data/pages/Templates/templates/detail-views.json +0 -71
- package/data/pages/Templates/templates/expandable-details.json +0 -39
- package/data/pages/Templates/templates/feature-cards.json +0 -103
- package/data/pages/Templates/templates/form-summary.json +0 -39
- package/data/pages/Templates/templates/form-toggle.json +0 -39
- package/data/pages/Templates/templates/list-blocks.json +0 -119
- package/data/pages/Templates/templates/loading-progress.json +0 -39
- package/data/pages/Templates/templates/options-panel.json +0 -39
- package/data/pages/Templates/templates/panel-variants.json +0 -39
- package/data/pages/Templates/templates/progress-cards.json +0 -71
- package/data/pages/Templates/templates/progress-success.json +0 -39
- package/data/pages/Templates/templates/settings-form.json +0 -39
- package/data/pages/Templates/templates/stats-blocks.json +0 -135
- package/data/pages/Templates/templates/table-panel.json +0 -39
- package/data/pages/Templates/templates/table-row-animation.json +0 -39
- package/data/pages/Templates/templates/usage-cards.json +0 -39
- package/data/pages/Utilities/utilities/deviceutils.json +0 -39
- package/data/pages/Utilities/utilities/featuretoggles.json +0 -42
- package/data/pages/Utilities/utilities/fueltypeutils.json +0 -118
- package/data/pages/Utilities/utilities/routeutils.json +0 -34
- package/data/pages/Utilities/utilities/useaftermount.json +0 -63
- package/data/pages/Utilities/utilities/useaverage.json +0 -86
- package/data/pages/Utilities/utilities/useclickoutside.json +0 -69
- package/data/pages/Utilities/utilities/useclipboard.json +0 -57
- package/data/pages/Utilities/utilities/usecount.json +0 -92
- package/data/pages/Utilities/utilities/usedarkmode.json +0 -50
- package/data/pages/Utilities/utilities/usedebuginfo.json +0 -63
- package/data/pages/Utilities/utilities/useeffectonce.json +0 -57
- package/data/pages/Utilities/utilities/useelapsedtime.json +0 -57
- package/data/pages/Utilities/utilities/useelementsize.json +0 -63
- package/data/pages/Utilities/utilities/useesc.json +0 -57
- package/data/pages/Utilities/utilities/useevent.json +0 -75
- package/data/pages/Utilities/utilities/usefocustrap.json +0 -57
- package/data/pages/Utilities/utilities/usefullscreen.json +0 -197
- package/data/pages/Utilities/utilities/usehover.json +0 -57
- package/data/pages/Utilities/utilities/useinterval.json +0 -63
- package/data/pages/Utilities/utilities/useisfocuswithin.json +0 -75
- package/data/pages/Utilities/utilities/usekey.json +0 -75
- package/data/pages/Utilities/utilities/uselocalstorage.json +0 -69
- package/data/pages/Utilities/utilities/uselocationsuggestions.json +0 -110
- package/data/pages/Utilities/utilities/usemax.json +0 -86
- package/data/pages/Utilities/utilities/usemin.json +0 -86
- package/data/pages/Utilities/utilities/usemutationobserver.json +0 -69
- package/data/pages/Utilities/utilities/useonlinestatus.json +0 -39
- package/data/pages/Utilities/utilities/useonscreen.json +0 -63
- package/data/pages/Utilities/utilities/usepostmessage.json +0 -80
- package/data/pages/Utilities/utilities/useprevious.json +0 -63
- package/data/pages/Utilities/utilities/useresizeobserver.json +0 -65
- package/data/pages/Utilities/utilities/usescrollposition.json +0 -103
- package/data/pages/Utilities/utilities/usesearch.json +0 -197
- package/data/pages/Utilities/utilities/usesorting.json +0 -139
- package/data/pages/Utilities/utilities/usestatewithvalidation.json +0 -69
- package/data/pages/Utilities/utilities/usesum.json +0 -86
- package/data/pages/Utilities/utilities/usetableexport.json +0 -87
- package/data/pages/Utilities/utilities/usetableselection.json +0 -311
- package/data/pages/Utilities/utilities/usetimeout.json +0 -63
- package/data/pages/Utilities/utilities/usetoggle.json +0 -75
- package/data/pages/Utilities/utilities/usewindowresize.json +0 -63
- package/data/version.json +0 -4
- package/docs/content-schema.md +0 -147
- package/docs/navigation-inventory.json +0 -1310
- package/docs/search-synonyms.json +0 -43
- package/server/index.mjs +0 -268
- package/server/lib/load-docs.mjs +0 -48
- package/server/lib/normalise-doc.mjs +0 -220
- package/server/lib/render-markdown.mjs +0 -82
- package/server/lib/search-index.mjs +0 -49
- package/server/lib/types.js +0 -99
|
@@ -0,0 +1,1120 @@
|
|
|
1
|
+
# useTableSelection
|
|
2
|
+
|
|
3
|
+
*Category:* Utilities
|
|
4
|
+
*Section:* Table & data hooks
|
|
5
|
+
*Source:* https://uikit.developers.rio.cloud/#utilities/useTableSelection
|
|
6
|
+
*Captured:* 2025-12-12T12:39:51.762Z
|
|
7
|
+
|
|
8
|
+
The useTableSelection hook simplifies the implementation of selection behavior in tables for single selection and multi-selection use cases. It’s especially useful for large datasets, as it optimizes performance by preventing unnecessary re-renders of all rows.
|
|
9
|
+
|
|
10
|
+
## useTableSelection
|
|
11
|
+
|
|
12
|
+
> Note: , when using a checkbox column for multi-selection and a column for some action buttons, make sure to apply the classes "table-checkbox" and "table-action" to the respective row "td" elements. The latter class automatically stops event propagation, preventing the row from being selected when an action button is clicked.
|
|
13
|
+
|
|
14
|
+
### Example: Active row
|
|
15
|
+
|
|
16
|
+
Active row
|
|
17
|
+
-
|
|
18
|
+
|
|
19
|
+
IdFirst nameLast nameE-mail
|
|
20
|
+
|
|
21
|
+
1MaiaWildermanDemarcus.Rogahn@yahoo.com
|
|
22
|
+
2MaeveWiegandBrandy_Abernathy77@yahoo.com
|
|
23
|
+
3StephaniaShieldsDoris11@hotmail.com
|
|
24
|
+
4TyrellParkerAmara.Pollich@gmail.com
|
|
25
|
+
5JuniorDoyleAgnes.Lakin56@yahoo.com
|
|
26
|
+
|
|
27
|
+
#### Summary
|
|
28
|
+
|
|
29
|
+
Active row
|
|
30
|
+
-
|
|
31
|
+
|
|
32
|
+
IdFirst nameLast nameE-mail
|
|
33
|
+
|
|
34
|
+
1MaiaWildermanDemarcus.Rogahn@yahoo.com
|
|
35
|
+
2MaeveWiegandBrandy_Abernathy77@yahoo.com
|
|
36
|
+
3StephaniaShieldsDoris11@hotmail.com
|
|
37
|
+
4TyrellParkerAmara.Pollich@gmail.com
|
|
38
|
+
5JuniorDoyleAgnes.Lakin56@yahoo.com
|
|
39
|
+
|
|
40
|
+
#### React (tsx)
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import React from 'react';
|
|
44
|
+
import classNames from 'classnames';
|
|
45
|
+
import faker from 'faker';
|
|
46
|
+
|
|
47
|
+
import TableHead from '@rio-cloud/rio-uikit/TableHead';
|
|
48
|
+
import TableCol, { type ColumnDetailsMap } from '@rio-cloud/rio-uikit/TableCol';
|
|
49
|
+
import useTableSelection from '@rio-cloud/rio-uikit/useTableSelection';
|
|
50
|
+
import useSorting from '@rio-cloud/rio-uikit/useSorting';
|
|
51
|
+
import FormLabel from '@rio-cloud/rio-uikit/FormLabel';
|
|
52
|
+
import Card from '@rio-cloud/rio-uikit/Card';
|
|
53
|
+
import Button from '@rio-cloud/rio-uikit/Button';
|
|
54
|
+
|
|
55
|
+
type Driver = {
|
|
56
|
+
driverId: string;
|
|
57
|
+
firstName: string;
|
|
58
|
+
lastName: string;
|
|
59
|
+
email: string;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
type ColumnLabel = { [key in keyof Driver]: string };
|
|
63
|
+
|
|
64
|
+
const columnLabels: ColumnLabel = {
|
|
65
|
+
driverId: 'Id',
|
|
66
|
+
firstName: 'First name',
|
|
67
|
+
lastName: 'Last name',
|
|
68
|
+
email: 'E-mail',
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const defaultColumnOrder = ['driverId', 'firstName', 'lastName', 'email'];
|
|
72
|
+
|
|
73
|
+
const demoColumnsDetails: ColumnDetailsMap = {
|
|
74
|
+
driverId: {
|
|
75
|
+
width: 100,
|
|
76
|
+
defaultWidth: 200,
|
|
77
|
+
maxWidth: 300,
|
|
78
|
+
},
|
|
79
|
+
firstName: {
|
|
80
|
+
width: 200,
|
|
81
|
+
defaultWidth: 200,
|
|
82
|
+
maxWidth: 200,
|
|
83
|
+
},
|
|
84
|
+
lastName: {
|
|
85
|
+
width: 0, // Note: 0 means auto width
|
|
86
|
+
defaultWidth: 0,
|
|
87
|
+
maxWidth: 350,
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// Function to generate random entries to work with.
|
|
92
|
+
// Increase length to generate more items.
|
|
93
|
+
const driverList: Driver[] = Array.from({ length: 5 }, (_, index) => ({
|
|
94
|
+
driverId: `${index + 1}`,
|
|
95
|
+
firstName: faker.name.firstName(),
|
|
96
|
+
lastName: faker.name.lastName(),
|
|
97
|
+
email: faker.internet.email(),
|
|
98
|
+
}));
|
|
99
|
+
|
|
100
|
+
export default () => {
|
|
101
|
+
const { sortedItems, sortKey, sortDirection, setSortKey, toggleDirection } = useSorting(driverList, 'driverId');
|
|
102
|
+
|
|
103
|
+
// Use the headless table selection hook
|
|
104
|
+
const { tableRef, onActiveRowChange, activeRowId, setActiveRowId } = useTableSelection<Driver>({
|
|
105
|
+
tableData: driverList,
|
|
106
|
+
idKey: 'driverId' as keyof Driver, // Specify the unique identifier key
|
|
107
|
+
// dataAttributeName: 'data-id', // Specify the "data-id" key where the idKey is stored on a table row
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const handleSortChange = (event: React.MouseEvent<HTMLTableCellElement>) => {
|
|
111
|
+
const newSortBy = event.currentTarget.getAttribute('data-sortby');
|
|
112
|
+
if (newSortBy) {
|
|
113
|
+
setSortKey(newSortBy as keyof Driver);
|
|
114
|
+
}
|
|
115
|
+
if (newSortBy === sortKey) {
|
|
116
|
+
toggleDirection();
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const tableClassNames = classNames(
|
|
121
|
+
'table',
|
|
122
|
+
'table-layout-fixed',
|
|
123
|
+
'table-column-overflow-hidden',
|
|
124
|
+
'table-bordered',
|
|
125
|
+
'table-sticky',
|
|
126
|
+
'table-hover',
|
|
127
|
+
'table-head-filled'
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<div>
|
|
132
|
+
<Card className='margin-bottom-15 display-flex justify-content-between' shadow='none'>
|
|
133
|
+
<div>
|
|
134
|
+
<FormLabel>Active row</FormLabel>
|
|
135
|
+
<div>{activeRowId || '-'}</div>
|
|
136
|
+
</div>
|
|
137
|
+
<div className='align-self-center'>
|
|
138
|
+
{activeRowId && <Button onClick={() => setActiveRowId(undefined)}>Clear active row</Button>}
|
|
139
|
+
</div>
|
|
140
|
+
</Card>
|
|
141
|
+
|
|
142
|
+
<div className='table-responsive'>
|
|
143
|
+
<table ref={tableRef} className={tableClassNames}>
|
|
144
|
+
<colgroup>
|
|
145
|
+
{defaultColumnOrder.map(column => (
|
|
146
|
+
<TableCol key={column} columnDetails={demoColumnsDetails[column]} />
|
|
147
|
+
))}
|
|
148
|
+
</colgroup>
|
|
149
|
+
<thead>
|
|
150
|
+
<tr>
|
|
151
|
+
{defaultColumnOrder.map(column => (
|
|
152
|
+
<TableHead
|
|
153
|
+
key={column}
|
|
154
|
+
column={column}
|
|
155
|
+
label={columnLabels[column as keyof ColumnLabel]}
|
|
156
|
+
sortBy={sortKey as string}
|
|
157
|
+
sortDir={sortDirection}
|
|
158
|
+
onClick={handleSortChange}
|
|
159
|
+
/>
|
|
160
|
+
))}
|
|
161
|
+
</tr>
|
|
162
|
+
</thead>
|
|
163
|
+
<tbody>
|
|
164
|
+
{sortedItems.map(row => (
|
|
165
|
+
<TableRow
|
|
166
|
+
key={row.driverId}
|
|
167
|
+
row={row}
|
|
168
|
+
columns={defaultColumnOrder}
|
|
169
|
+
colLabels={columnLabels}
|
|
170
|
+
onRowClick={onActiveRowChange}
|
|
171
|
+
/>
|
|
172
|
+
))}
|
|
173
|
+
</tbody>
|
|
174
|
+
</table>
|
|
175
|
+
</div>
|
|
176
|
+
</div>
|
|
177
|
+
);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
type TableRowProps = {
|
|
181
|
+
row: Driver;
|
|
182
|
+
columns: string[];
|
|
183
|
+
colLabels: ColumnLabel;
|
|
184
|
+
onRowClick: (event: React.MouseEvent<HTMLTableRowElement>) => void;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
// A custom table row component used to prevent re-rendering the individual row.
|
|
188
|
+
// Usually, this would be placed into it's own file but for demo purposes it's listed here.
|
|
189
|
+
const TableRow = React.memo(
|
|
190
|
+
(props: TableRowProps) => {
|
|
191
|
+
const { row, columns, colLabels, onRowClick } = props;
|
|
192
|
+
|
|
193
|
+
// Make sure to store the unique "idKey" as data attribute as specified for the useTableMultiSelection hook
|
|
194
|
+
// In this example the driverId is used as identifier stored as "data-id".
|
|
195
|
+
return (
|
|
196
|
+
<tr key={row.driverId} data-id={row.driverId} onClick={onRowClick} className='cursor-pointer'>
|
|
197
|
+
{columns.map(col => (
|
|
198
|
+
<td key={col} data-field={colLabels[col as keyof Driver]}>
|
|
199
|
+
<span>{row[col as keyof Driver]}</span>
|
|
200
|
+
</td>
|
|
201
|
+
))}
|
|
202
|
+
</tr>
|
|
203
|
+
);
|
|
204
|
+
},
|
|
205
|
+
(prevProps, nextProps) => {
|
|
206
|
+
return JSON.stringify(prevProps) === JSON.stringify(nextProps);
|
|
207
|
+
}
|
|
208
|
+
);
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
#### HTML (html)
|
|
212
|
+
|
|
213
|
+
```html
|
|
214
|
+
<div>
|
|
215
|
+
<div class="bg-white rounded border shadow-none padding-15 margin-bottom-15 display-flex justify-content-between">
|
|
216
|
+
<div>
|
|
217
|
+
<div class="text-color-dark max-width-100pct text-size-12 display-inline-block margin-bottom-5">Active row</div>
|
|
218
|
+
<div>-</div>
|
|
219
|
+
</div>
|
|
220
|
+
<div class="align-self-center">
|
|
221
|
+
</div>
|
|
222
|
+
</div>
|
|
223
|
+
<div class="table-responsive">
|
|
224
|
+
<table class="table table-layout-fixed table-column-overflow-hidden table-bordered table-sticky table-hover table-head-filled">
|
|
225
|
+
<colgroup>
|
|
226
|
+
<col class="" style="min-width: 100px; width: 100px;">
|
|
227
|
+
<col class="" style="min-width: 200px; width: 200px;">
|
|
228
|
+
<col class="">
|
|
229
|
+
<col class="">
|
|
230
|
+
</colgroup>
|
|
231
|
+
<thead>
|
|
232
|
+
<tr>
|
|
233
|
+
<th class="user-select-none sort-column" data-field="driverId" data-sortby="driverId" title="Id">
|
|
234
|
+
<span>
|
|
235
|
+
<span class="sort-arrows sort-asc">
|
|
236
|
+
</span>
|
|
237
|
+
<span>Id</span>
|
|
238
|
+
</span>
|
|
239
|
+
</th>
|
|
240
|
+
<th class="user-select-none sort-column" data-field="firstName" data-sortby="firstName" title="First name">
|
|
241
|
+
<span>
|
|
242
|
+
<span class="sort-arrows ">
|
|
243
|
+
</span>
|
|
244
|
+
<span>First name</span>
|
|
245
|
+
</span>
|
|
246
|
+
</th>
|
|
247
|
+
<th class="user-select-none sort-column" data-field="lastName" data-sortby="lastName" title="Last name">
|
|
248
|
+
<span>
|
|
249
|
+
<span class="sort-arrows ">
|
|
250
|
+
</span>
|
|
251
|
+
<span>Last name</span>
|
|
252
|
+
</span>
|
|
253
|
+
</th>
|
|
254
|
+
<th class="user-select-none sort-column" data-field="email" data-sortby="email" title="E-mail">
|
|
255
|
+
<span>
|
|
256
|
+
<span class="sort-arrows ">
|
|
257
|
+
</span>
|
|
258
|
+
<span>E-mail</span>
|
|
259
|
+
</span>
|
|
260
|
+
</th>
|
|
261
|
+
</tr>
|
|
262
|
+
</thead>
|
|
263
|
+
<tbody>
|
|
264
|
+
<tr data-id="1" class="cursor-pointer">
|
|
265
|
+
<td data-field="Id">
|
|
266
|
+
<span>1</span>
|
|
267
|
+
</td>
|
|
268
|
+
<td data-field="First name">
|
|
269
|
+
<span>Maia</span>
|
|
270
|
+
</td>
|
|
271
|
+
<td data-field="Last name">
|
|
272
|
+
<span>Wilderman</span>
|
|
273
|
+
</td>
|
|
274
|
+
<td data-field="E-mail">
|
|
275
|
+
<span>Demarcus.Rogahn@yahoo.com</span>
|
|
276
|
+
</td>
|
|
277
|
+
</tr>
|
|
278
|
+
<tr data-id="2" class="cursor-pointer">
|
|
279
|
+
<td data-field="Id">
|
|
280
|
+
<span>2</span>
|
|
281
|
+
</td>
|
|
282
|
+
<td data-field="First name">
|
|
283
|
+
<span>Maeve</span>
|
|
284
|
+
</td>
|
|
285
|
+
<td data-field="Last name">
|
|
286
|
+
<span>Wiegand</span>
|
|
287
|
+
</td>
|
|
288
|
+
<td data-field="E-mail">
|
|
289
|
+
<span>Brandy_Abernathy77@yahoo.com</span>
|
|
290
|
+
</td>
|
|
291
|
+
</tr>
|
|
292
|
+
<tr data-id="3" class="cursor-pointer">
|
|
293
|
+
<td data-field="Id">
|
|
294
|
+
<span>3</span>
|
|
295
|
+
</td>
|
|
296
|
+
<td data-field="First name">
|
|
297
|
+
<span>Stephania</span>
|
|
298
|
+
</td>
|
|
299
|
+
<td data-field="Last name">
|
|
300
|
+
<span>Shields</span>
|
|
301
|
+
</td>
|
|
302
|
+
<td data-field="E-mail">
|
|
303
|
+
<span>Doris11@hotmail.com</span>
|
|
304
|
+
</td>
|
|
305
|
+
</tr>
|
|
306
|
+
<tr data-id="4" class="cursor-pointer">
|
|
307
|
+
<td data-field="Id">
|
|
308
|
+
<span>4</span>
|
|
309
|
+
</td>
|
|
310
|
+
<td data-field="First name">
|
|
311
|
+
<span>Tyrell</span>
|
|
312
|
+
</td>
|
|
313
|
+
<td data-field="Last name">
|
|
314
|
+
<span>Parker</span>
|
|
315
|
+
</td>
|
|
316
|
+
<td data-field="E-mail">
|
|
317
|
+
<span>Amara.Pollich@gmail.com</span>
|
|
318
|
+
</td>
|
|
319
|
+
</tr>
|
|
320
|
+
<tr data-id="5" class="cursor-pointer">
|
|
321
|
+
<td data-field="Id">
|
|
322
|
+
<span>5</span>
|
|
323
|
+
</td>
|
|
324
|
+
<td data-field="First name">
|
|
325
|
+
<span>Junior</span>
|
|
326
|
+
</td>
|
|
327
|
+
<td data-field="Last name">
|
|
328
|
+
<span>Doyle</span>
|
|
329
|
+
</td>
|
|
330
|
+
<td data-field="E-mail">
|
|
331
|
+
<span>Agnes.Lakin56@yahoo.com</span>
|
|
332
|
+
</td>
|
|
333
|
+
</tr>
|
|
334
|
+
</tbody>
|
|
335
|
+
</table>
|
|
336
|
+
</div>
|
|
337
|
+
</div>
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
#### Props: Options for the `useTableSelection` hook
|
|
341
|
+
|
|
342
|
+
### Options for the `useTableSelection` hook
|
|
343
|
+
|
|
344
|
+
| Name | Type | Default | Description |
|
|
345
|
+
| --- | --- | --- | --- |
|
|
346
|
+
| tableData | TData[] | — | The array of data items to be displayed in the table. The hook uses this to determine all possible row IDs for "select all" functionality. |
|
|
347
|
+
| idKey | keyof TData | — | The key in `TData` objects that serves as the unique identifier for each row. |
|
|
348
|
+
| initialSelectedRowIds | string[] | — | Optional array of row IDs that should be initially selected. |
|
|
349
|
+
| initialActiveRowId | string | — | Optional ID of the row that should be initially marked as active. |
|
|
350
|
+
| checkboxQuerySelector | string | '.table-checkbox input[type="checkbox"]' | Optional CSS query selector to find the checkbox input element within each table row. |
|
|
351
|
+
| dataAttributeName | string | data-id | Optional name of the HTML data attribute on `<tr>` elements that holds the unique row ID. |
|
|
352
|
+
| ref | RefObject<HTMLTableElement> | — | Optional external ref for the table element. If not provided, the hook creates its own. Useful if the parent component needs direct access to the table DOM element for other purposes. |
|
|
353
|
+
|
|
354
|
+
#### Props: Return value of the `useTableSelection` hook
|
|
355
|
+
|
|
356
|
+
### Return value of the `useTableSelection` hook
|
|
357
|
+
|
|
358
|
+
| Name | Type | Default | Description |
|
|
359
|
+
| --- | --- | --- | --- |
|
|
360
|
+
| tableRef | RefObject<HTMLTableElement> | — | React ref attached to the `<table>` HTML element. Ensure this ref is assigned to your table element to enable DOM manipulations. |
|
|
361
|
+
| selectedRowIds | string[] | — | An array of strings, where each string is the ID of a currently selected row. |
|
|
362
|
+
| setSelectedRowIds | (rowIds: string[]) => void | — | Setter function to change selected rows from the outside in a controlled manner. |
|
|
363
|
+
| activeRowId | string | — | The ID of the currently active row. An empty string signifies no row is active. |
|
|
364
|
+
| setActiveRowId | (activeRowId: string \| undefined) => void | — | Setter function to change the active row from the outside in a controlled manner. Use this to deselect an active row. |
|
|
365
|
+
| onSelection | (event: React.MouseEvent<HTMLElement>) => void | — | Callback handler to be attached to the click/change event of individual row selection UI elements (e.g., checkboxes). It expects the clicked element to be within a `<tr>` that has the specified `dataAttributeName`. Manages the selection state of a single row. |
|
|
366
|
+
| onActiveRowChange | (event: React.MouseEvent<HTMLTableRowElement>) => void | — | Callback handler to be attached to the click event of table row (`<tr>`) elements.Manages the active row state. |
|
|
367
|
+
| onToggleAll | (shouldSelect: boolean) => void | — | Callback handler to select or deselect all rows. If "shouldSelect" is set to true, all rows in `tableData` will be selected; otherwise, all selections will be cleared. |
|
|
368
|
+
| updateRowSelection | () => void | — | Function to update row selection and active highlighting. This is useful when the row data changes due to a search value or any other filter. |
|
|
369
|
+
| hasSelection | boolean | — | A boolean indicating whether at least one row is currently selected. |
|
|
370
|
+
| isAllSelected | boolean | — | A boolean indicating whether all rows in the current `tableData` are selected. |
|
|
371
|
+
|
|
372
|
+
## Multi-selection
|
|
373
|
+
|
|
374
|
+
### Example: Active row
|
|
375
|
+
|
|
376
|
+
Active row
|
|
377
|
+
-
|
|
378
|
+
|
|
379
|
+
Selected rows
|
|
380
|
+
4
|
|
381
|
+
|
|
382
|
+
Deselect all ItemsSelect some rows
|
|
383
|
+
|
|
384
|
+
IdFirst nameLast nameE-mail
|
|
385
|
+
|
|
386
|
+
1MalikaWittingEttie.Rempel61@gmail.com
|
|
387
|
+
|
|
388
|
+
2MariahConsidineDayna_Schowalter33@hotmail.com
|
|
389
|
+
|
|
390
|
+
3DorthaConnellyCarey5@hotmail.com
|
|
391
|
+
|
|
392
|
+
4JamarJohnsonKaya42@gmail.com
|
|
393
|
+
|
|
394
|
+
5RutheReynoldsLila.Jakubowski@hotmail.com
|
|
395
|
+
|
|
396
|
+
6MadisonLegrosAileen.Hills75@hotmail.com
|
|
397
|
+
|
|
398
|
+
7EricaKesslerSilas70@yahoo.com
|
|
399
|
+
|
|
400
|
+
8MontanaOkunevaNikki_Hagenes@gmail.com
|
|
401
|
+
|
|
402
|
+
9RubyeSteuberAlessandra.Feest70@yahoo.com
|
|
403
|
+
|
|
404
|
+
10WinifredO'KonSebastian.Wuckert25@hotmail.com
|
|
405
|
+
|
|
406
|
+
#### Summary
|
|
407
|
+
|
|
408
|
+
Active row
|
|
409
|
+
-
|
|
410
|
+
|
|
411
|
+
Selected rows
|
|
412
|
+
4
|
|
413
|
+
|
|
414
|
+
Deselect all ItemsSelect some rows
|
|
415
|
+
|
|
416
|
+
IdFirst nameLast nameE-mail
|
|
417
|
+
|
|
418
|
+
1MalikaWittingEttie.Rempel61@gmail.com
|
|
419
|
+
|
|
420
|
+
2MariahConsidineDayna_Schowalter33@hotmail.com
|
|
421
|
+
|
|
422
|
+
3DorthaConnellyCarey5@hotmail.com
|
|
423
|
+
|
|
424
|
+
4JamarJohnsonKaya42@gmail.com
|
|
425
|
+
|
|
426
|
+
5RutheReynoldsLila.Jakubowski@hotmail.com
|
|
427
|
+
|
|
428
|
+
6MadisonLegrosAileen.Hills75@hotmail.com
|
|
429
|
+
|
|
430
|
+
7EricaKesslerSilas70@yahoo.com
|
|
431
|
+
|
|
432
|
+
8MontanaOkunevaNikki_Hagenes@gmail.com
|
|
433
|
+
|
|
434
|
+
9RubyeSteuberAlessandra.Feest70@yahoo.com
|
|
435
|
+
|
|
436
|
+
10WinifredO'KonSebastian.Wuckert25@hotmail.com
|
|
437
|
+
|
|
438
|
+
#### React (tsx)
|
|
439
|
+
|
|
440
|
+
```tsx
|
|
441
|
+
import React from 'react';
|
|
442
|
+
import classNames from 'classnames';
|
|
443
|
+
import faker from 'faker';
|
|
444
|
+
import { isEmpty } from 'es-toolkit/compat';
|
|
445
|
+
|
|
446
|
+
import TableHead from '@rio-cloud/rio-uikit/TableHead';
|
|
447
|
+
import TableCol, { type ColumnDetailsMap } from '@rio-cloud/rio-uikit/TableCol';
|
|
448
|
+
import ButtonDropdown from '@rio-cloud/rio-uikit/ButtonDropdown';
|
|
449
|
+
import Checkbox from '@rio-cloud/rio-uikit/Checkbox';
|
|
450
|
+
import useTableSelection from '@rio-cloud/rio-uikit/useTableSelection';
|
|
451
|
+
import useSorting from '@rio-cloud/rio-uikit/useSorting';
|
|
452
|
+
import FormLabel from '@rio-cloud/rio-uikit/FormLabel';
|
|
453
|
+
import Card from '@rio-cloud/rio-uikit/Card';
|
|
454
|
+
import ButtonToolbar from '@rio-cloud/rio-uikit/ButtonToolbar';
|
|
455
|
+
import Button from '@rio-cloud/rio-uikit/Button';
|
|
456
|
+
|
|
457
|
+
type Driver = {
|
|
458
|
+
driverId: string;
|
|
459
|
+
firstName: string;
|
|
460
|
+
lastName: string;
|
|
461
|
+
email: string;
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
type ColumnLabel = { [key in keyof Driver]: string };
|
|
465
|
+
|
|
466
|
+
const defaultColumnOrder = ['driverId', 'firstName', 'lastName', 'email'];
|
|
467
|
+
|
|
468
|
+
const columnLabels: ColumnLabel = {
|
|
469
|
+
driverId: 'Id',
|
|
470
|
+
firstName: 'First name',
|
|
471
|
+
lastName: 'Last name',
|
|
472
|
+
email: 'E-mail',
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
const demoColumnsDetails: ColumnDetailsMap = {
|
|
476
|
+
driverId: {
|
|
477
|
+
width: 100,
|
|
478
|
+
defaultWidth: 200,
|
|
479
|
+
maxWidth: 300,
|
|
480
|
+
},
|
|
481
|
+
firstName: {
|
|
482
|
+
width: 200,
|
|
483
|
+
defaultWidth: 200,
|
|
484
|
+
maxWidth: 200,
|
|
485
|
+
},
|
|
486
|
+
lastName: {
|
|
487
|
+
width: 0, // Note: 0 means auto width
|
|
488
|
+
defaultWidth: 0,
|
|
489
|
+
maxWidth: 350,
|
|
490
|
+
},
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
// Function to generate random entries to work with.
|
|
494
|
+
// Increase length to generate more items.
|
|
495
|
+
const driverList: Driver[] = Array.from({ length: 10 }, (_, index) => ({
|
|
496
|
+
driverId: `${index + 1}`,
|
|
497
|
+
firstName: faker.name.firstName(),
|
|
498
|
+
lastName: faker.name.lastName(),
|
|
499
|
+
email: faker.internet.email(),
|
|
500
|
+
}));
|
|
501
|
+
|
|
502
|
+
export default () => {
|
|
503
|
+
const { sortedItems, sortKey, sortDirection, setSortKey, toggleDirection } = useSorting(driverList, 'driverId');
|
|
504
|
+
|
|
505
|
+
// Use the headless table selection hook
|
|
506
|
+
const {
|
|
507
|
+
tableRef,
|
|
508
|
+
onSelection,
|
|
509
|
+
onActiveRowChange,
|
|
510
|
+
onToggleAll,
|
|
511
|
+
activeRowId,
|
|
512
|
+
setActiveRowId,
|
|
513
|
+
selectedRowIds,
|
|
514
|
+
setSelectedRowIds,
|
|
515
|
+
hasSelection,
|
|
516
|
+
isAllSelected,
|
|
517
|
+
} = useTableSelection<Driver>({
|
|
518
|
+
tableData: driverList,
|
|
519
|
+
idKey: 'driverId' as keyof Driver, // Specify the unique identifier key
|
|
520
|
+
initialSelectedRowIds: [`${driverList[3]?.driverId}`].filter(Boolean),
|
|
521
|
+
initialActiveRowId: '',
|
|
522
|
+
// dataAttributeName: 'data-id', // Specify the "data-id" key where the idKey is stored on a table row
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
const handleSortChange = (event: React.MouseEvent<HTMLTableCellElement>) => {
|
|
526
|
+
const newSortBy = event.currentTarget.getAttribute('data-sortby');
|
|
527
|
+
if (newSortBy) {
|
|
528
|
+
setSortKey(newSortBy as keyof Driver);
|
|
529
|
+
}
|
|
530
|
+
if (newSortBy === sortKey) {
|
|
531
|
+
toggleDirection();
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
const tableClassNames = classNames(
|
|
536
|
+
'table',
|
|
537
|
+
'table-layout-fixed',
|
|
538
|
+
'table-column-overflow-hidden',
|
|
539
|
+
'table-bordered',
|
|
540
|
+
'table-sticky',
|
|
541
|
+
'table-hover',
|
|
542
|
+
'table-head-filled'
|
|
543
|
+
);
|
|
544
|
+
|
|
545
|
+
const batchButton = (
|
|
546
|
+
<ButtonDropdown
|
|
547
|
+
title={<span className='rioglyph rioglyph-checkboxes' />}
|
|
548
|
+
variant='outline'
|
|
549
|
+
bsSize='sm'
|
|
550
|
+
iconOnly
|
|
551
|
+
items={[
|
|
552
|
+
{
|
|
553
|
+
value: (
|
|
554
|
+
<div>
|
|
555
|
+
<span>Select all Items</span>
|
|
556
|
+
</div>
|
|
557
|
+
),
|
|
558
|
+
onSelect: () => onToggleAll(true),
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
value: (
|
|
562
|
+
<div>
|
|
563
|
+
<span>Deselect all Items</span>
|
|
564
|
+
</div>
|
|
565
|
+
),
|
|
566
|
+
onSelect: () => onToggleAll(false),
|
|
567
|
+
},
|
|
568
|
+
]}
|
|
569
|
+
/>
|
|
570
|
+
);
|
|
571
|
+
|
|
572
|
+
return (
|
|
573
|
+
<div>
|
|
574
|
+
<Card className='margin-bottom-15 display-flex justify-content-between' shadow='none'>
|
|
575
|
+
<div className='display-flex gap-25'>
|
|
576
|
+
<div>
|
|
577
|
+
<FormLabel>Active row</FormLabel>
|
|
578
|
+
<div>{activeRowId || '-'}</div>
|
|
579
|
+
</div>
|
|
580
|
+
<div>
|
|
581
|
+
<FormLabel>Selected rows</FormLabel>
|
|
582
|
+
<div>{selectedRowIds.join(', ')}</div>
|
|
583
|
+
</div>
|
|
584
|
+
</div>
|
|
585
|
+
<ButtonToolbar className='align-self-center'>
|
|
586
|
+
{activeRowId && <Button onClick={() => setActiveRowId(undefined)}>Clear active row</Button>}
|
|
587
|
+
{!isEmpty(selectedRowIds) && <Button onClick={() => onToggleAll(false)}>Deselect all Items</Button>}
|
|
588
|
+
<Button
|
|
589
|
+
onClick={() => setSelectedRowIds([`${driverList[2]?.driverId}`, `${driverList[5]?.driverId}`])}
|
|
590
|
+
>
|
|
591
|
+
Select some rows
|
|
592
|
+
</Button>
|
|
593
|
+
</ButtonToolbar>
|
|
594
|
+
</Card>
|
|
595
|
+
<div className='table-responsive'>
|
|
596
|
+
<table ref={tableRef} className={tableClassNames}>
|
|
597
|
+
{/* Colgroups are required to work with column widths */}
|
|
598
|
+
<colgroup>
|
|
599
|
+
<TableCol />
|
|
600
|
+
{defaultColumnOrder.map(column => (
|
|
601
|
+
<TableCol key={column} columnDetails={demoColumnsDetails[column]} />
|
|
602
|
+
))}
|
|
603
|
+
<TableCol />
|
|
604
|
+
</colgroup>
|
|
605
|
+
<thead>
|
|
606
|
+
<tr>
|
|
607
|
+
<TableHead className='table-checkbox'>{batchButton}</TableHead>
|
|
608
|
+
{defaultColumnOrder.map(column => (
|
|
609
|
+
<TableHead
|
|
610
|
+
key={column}
|
|
611
|
+
column={column}
|
|
612
|
+
label={columnLabels[column as keyof ColumnLabel]}
|
|
613
|
+
sortBy={sortKey as string}
|
|
614
|
+
sortDir={sortDirection}
|
|
615
|
+
onClick={handleSortChange}
|
|
616
|
+
/>
|
|
617
|
+
))}
|
|
618
|
+
<TableHead className='table-action' />
|
|
619
|
+
</tr>
|
|
620
|
+
</thead>
|
|
621
|
+
<tbody>
|
|
622
|
+
{sortedItems.map(row => (
|
|
623
|
+
<TableRow
|
|
624
|
+
key={row.driverId}
|
|
625
|
+
row={row}
|
|
626
|
+
columns={defaultColumnOrder}
|
|
627
|
+
colLabels={columnLabels}
|
|
628
|
+
onRowClick={onActiveRowChange}
|
|
629
|
+
onSelectCheckbox={onSelection}
|
|
630
|
+
/>
|
|
631
|
+
))}
|
|
632
|
+
</tbody>
|
|
633
|
+
</table>
|
|
634
|
+
</div>
|
|
635
|
+
</div>
|
|
636
|
+
);
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
type TableRowProps = {
|
|
640
|
+
row: Driver;
|
|
641
|
+
columns: string[];
|
|
642
|
+
colLabels: ColumnLabel;
|
|
643
|
+
onRowClick: (event: React.MouseEvent<HTMLTableRowElement>) => void;
|
|
644
|
+
onSelectCheckbox: (event: React.MouseEvent<HTMLElement>) => void;
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
// A custom table row component used to prevent re-rendering the individual row.
|
|
648
|
+
// Usually, this would be placed into it's own file but for demo purposes it's listed here.
|
|
649
|
+
const TableRow = React.memo(
|
|
650
|
+
(props: TableRowProps) => {
|
|
651
|
+
const { row, columns, colLabels, onRowClick, onSelectCheckbox } = props;
|
|
652
|
+
|
|
653
|
+
// Make sure to store the unique "idKey" as data attribute as specified for the useTableMultiSelection hook
|
|
654
|
+
// In this example the driverId is used as identifier stored as "data-id".
|
|
655
|
+
return (
|
|
656
|
+
<tr key={row.driverId} data-id={row.driverId} onClick={onRowClick} className='cursor-pointer'>
|
|
657
|
+
<td className='table-checkbox' onClick={onSelectCheckbox}>
|
|
658
|
+
<Checkbox />
|
|
659
|
+
</td>
|
|
660
|
+
{columns.map(col => (
|
|
661
|
+
<td key={col} data-field={colLabels[col as keyof Driver]}>
|
|
662
|
+
<span>{row[col as keyof Driver]}</span>
|
|
663
|
+
</td>
|
|
664
|
+
))}
|
|
665
|
+
<td className='table-action'>
|
|
666
|
+
<span>
|
|
667
|
+
<ButtonDropdown
|
|
668
|
+
title={<span className='rioglyph rioglyph-option-vertical' />}
|
|
669
|
+
variant='link'
|
|
670
|
+
iconOnly
|
|
671
|
+
items={[
|
|
672
|
+
{
|
|
673
|
+
value: (
|
|
674
|
+
<div className='display-flex align-items-center gap-10'>
|
|
675
|
+
<span className='rioglyph rioglyph-pencil' />
|
|
676
|
+
<span>Edit Me</span>
|
|
677
|
+
</div>
|
|
678
|
+
),
|
|
679
|
+
},
|
|
680
|
+
{
|
|
681
|
+
value: (
|
|
682
|
+
<div className='display-flex align-items-center gap-10'>
|
|
683
|
+
<span className='rioglyph rioglyph-trash' />
|
|
684
|
+
<span>Delete me</span>
|
|
685
|
+
</div>
|
|
686
|
+
),
|
|
687
|
+
},
|
|
688
|
+
]}
|
|
689
|
+
/>
|
|
690
|
+
</span>
|
|
691
|
+
</td>
|
|
692
|
+
</tr>
|
|
693
|
+
);
|
|
694
|
+
},
|
|
695
|
+
(prevProps, nextProps) => {
|
|
696
|
+
return JSON.stringify(prevProps) === JSON.stringify(nextProps);
|
|
697
|
+
}
|
|
698
|
+
);
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
#### HTML (html)
|
|
702
|
+
|
|
703
|
+
```html
|
|
704
|
+
<div>
|
|
705
|
+
<div class="bg-white rounded border shadow-none padding-15 margin-bottom-15 display-flex justify-content-between">
|
|
706
|
+
<div class="display-flex gap-25">
|
|
707
|
+
<div>
|
|
708
|
+
<div class="text-color-dark max-width-100pct text-size-12 display-inline-block margin-bottom-5">Active row</div>
|
|
709
|
+
<div>-</div>
|
|
710
|
+
</div>
|
|
711
|
+
<div>
|
|
712
|
+
<div class="text-color-dark max-width-100pct text-size-12 display-inline-block margin-bottom-5">Selected rows</div>
|
|
713
|
+
<div>4</div>
|
|
714
|
+
</div>
|
|
715
|
+
</div>
|
|
716
|
+
<div class="align-self-center btn-toolbar">
|
|
717
|
+
<button type="button" class="btn btn-default btn-component" tabindex="0">Deselect all Items</button>
|
|
718
|
+
<button type="button" class="btn btn-default btn-component" tabindex="0">Select some rows</button>
|
|
719
|
+
</div>
|
|
720
|
+
</div>
|
|
721
|
+
<div class="table-responsive">
|
|
722
|
+
<table class="table table-layout-fixed table-column-overflow-hidden table-bordered table-sticky table-hover table-head-filled">
|
|
723
|
+
<colgroup>
|
|
724
|
+
<col class="">
|
|
725
|
+
<col class="" style="min-width: 100px; width: 100px;">
|
|
726
|
+
<col class="" style="min-width: 200px; width: 200px;">
|
|
727
|
+
<col class="">
|
|
728
|
+
<col class="">
|
|
729
|
+
<col class="">
|
|
730
|
+
</colgroup>
|
|
731
|
+
<thead>
|
|
732
|
+
<tr>
|
|
733
|
+
<th class="user-select-none sort-column table-checkbox" title="">
|
|
734
|
+
<div class="dropdown btn-group">
|
|
735
|
+
<button type="button" id="zekw2l2iy4c" class="btn btn-default btn-outline btn-sm btn-icon-only btn-component dropdown-toggle" tabindex="0">
|
|
736
|
+
<span class="rioglyph rioglyph-checkboxes">
|
|
737
|
+
</span>
|
|
738
|
+
</button>
|
|
739
|
+
</div>
|
|
740
|
+
</th>
|
|
741
|
+
<th class="user-select-none sort-column" data-field="driverId" data-sortby="driverId" title="Id">
|
|
742
|
+
<span>
|
|
743
|
+
<span class="sort-arrows sort-asc">
|
|
744
|
+
</span>
|
|
745
|
+
<span>Id</span>
|
|
746
|
+
</span>
|
|
747
|
+
</th>
|
|
748
|
+
<th class="user-select-none sort-column" data-field="firstName" data-sortby="firstName" title="First name">
|
|
749
|
+
<span>
|
|
750
|
+
<span class="sort-arrows ">
|
|
751
|
+
</span>
|
|
752
|
+
<span>First name</span>
|
|
753
|
+
</span>
|
|
754
|
+
</th>
|
|
755
|
+
<th class="user-select-none sort-column" data-field="lastName" data-sortby="lastName" title="Last name">
|
|
756
|
+
<span>
|
|
757
|
+
<span class="sort-arrows ">
|
|
758
|
+
</span>
|
|
759
|
+
<span>Last name</span>
|
|
760
|
+
</span>
|
|
761
|
+
</th>
|
|
762
|
+
<th class="user-select-none sort-column" data-field="email" data-sortby="email" title="E-mail">
|
|
763
|
+
<span>
|
|
764
|
+
<span class="sort-arrows ">
|
|
765
|
+
</span>
|
|
766
|
+
<span>E-mail</span>
|
|
767
|
+
</span>
|
|
768
|
+
</th>
|
|
769
|
+
<th class="user-select-none sort-column table-action" title="">
|
|
770
|
+
</th>
|
|
771
|
+
</tr>
|
|
772
|
+
</thead>
|
|
773
|
+
<tbody>
|
|
774
|
+
<tr data-id="1" class="cursor-pointer">
|
|
775
|
+
<td class="table-checkbox">
|
|
776
|
+
<label class="checkbox" tabindex="0">
|
|
777
|
+
<input type="checkbox" class="">
|
|
778
|
+
<span class="checkbox-text">
|
|
779
|
+
</span>
|
|
780
|
+
</label>
|
|
781
|
+
</td>
|
|
782
|
+
<td data-field="Id">
|
|
783
|
+
<span>1</span>
|
|
784
|
+
</td>
|
|
785
|
+
<td data-field="First name">
|
|
786
|
+
<span>Malika</span>
|
|
787
|
+
</td>
|
|
788
|
+
<td data-field="Last name">
|
|
789
|
+
<span>Witting</span>
|
|
790
|
+
</td>
|
|
791
|
+
<td data-field="E-mail">
|
|
792
|
+
<span>Ettie.Rempel61@gmail.com</span>
|
|
793
|
+
</td>
|
|
794
|
+
<td class="table-action">
|
|
795
|
+
<span>
|
|
796
|
+
<div class="dropdown btn-group">
|
|
797
|
+
<button type="button" id="0hgjg90v8jpv" class="btn btn-default btn-link btn-md btn-icon-only btn-component dropdown-toggle" tabindex="0">
|
|
798
|
+
<span class="rioglyph rioglyph-option-vertical">
|
|
799
|
+
</span>
|
|
800
|
+
</button>
|
|
801
|
+
</div>
|
|
802
|
+
</span>
|
|
803
|
+
</td>
|
|
804
|
+
</tr>
|
|
805
|
+
<tr data-id="2" class="cursor-pointer">
|
|
806
|
+
<td class="table-checkbox">
|
|
807
|
+
<label class="checkbox" tabindex="0">
|
|
808
|
+
<input type="checkbox" class="">
|
|
809
|
+
<span class="checkbox-text">
|
|
810
|
+
</span>
|
|
811
|
+
</label>
|
|
812
|
+
</td>
|
|
813
|
+
<td data-field="Id">
|
|
814
|
+
<span>2</span>
|
|
815
|
+
</td>
|
|
816
|
+
<td data-field="First name">
|
|
817
|
+
<span>Mariah</span>
|
|
818
|
+
</td>
|
|
819
|
+
<td data-field="Last name">
|
|
820
|
+
<span>Considine</span>
|
|
821
|
+
</td>
|
|
822
|
+
<td data-field="E-mail">
|
|
823
|
+
<span>Dayna_Schowalter33@hotmail.com</span>
|
|
824
|
+
</td>
|
|
825
|
+
<td class="table-action">
|
|
826
|
+
<span>
|
|
827
|
+
<div class="dropdown btn-group">
|
|
828
|
+
<button type="button" id="28r9fs5sa8n" class="btn btn-default btn-link btn-md btn-icon-only btn-component dropdown-toggle" tabindex="0">
|
|
829
|
+
<span class="rioglyph rioglyph-option-vertical">
|
|
830
|
+
</span>
|
|
831
|
+
</button>
|
|
832
|
+
</div>
|
|
833
|
+
</span>
|
|
834
|
+
</td>
|
|
835
|
+
</tr>
|
|
836
|
+
<tr data-id="3" class="cursor-pointer">
|
|
837
|
+
<td class="table-checkbox">
|
|
838
|
+
<label class="checkbox" tabindex="0">
|
|
839
|
+
<input type="checkbox" class="">
|
|
840
|
+
<span class="checkbox-text">
|
|
841
|
+
</span>
|
|
842
|
+
</label>
|
|
843
|
+
</td>
|
|
844
|
+
<td data-field="Id">
|
|
845
|
+
<span>3</span>
|
|
846
|
+
</td>
|
|
847
|
+
<td data-field="First name">
|
|
848
|
+
<span>Dortha</span>
|
|
849
|
+
</td>
|
|
850
|
+
<td data-field="Last name">
|
|
851
|
+
<span>Connelly</span>
|
|
852
|
+
</td>
|
|
853
|
+
<td data-field="E-mail">
|
|
854
|
+
<span>Carey5@hotmail.com</span>
|
|
855
|
+
</td>
|
|
856
|
+
<td class="table-action">
|
|
857
|
+
<span>
|
|
858
|
+
<div class="dropdown btn-group">
|
|
859
|
+
<button type="button" id="csuvx15jcbm" class="btn btn-default btn-link btn-md btn-icon-only btn-component dropdown-toggle" tabindex="0">
|
|
860
|
+
<span class="rioglyph rioglyph-option-vertical">
|
|
861
|
+
</span>
|
|
862
|
+
</button>
|
|
863
|
+
</div>
|
|
864
|
+
</span>
|
|
865
|
+
</td>
|
|
866
|
+
</tr>
|
|
867
|
+
<tr data-id="4" class="cursor-pointer">
|
|
868
|
+
<td class="table-checkbox">
|
|
869
|
+
<label class="checkbox" tabindex="0">
|
|
870
|
+
<input type="checkbox" class="">
|
|
871
|
+
<span class="checkbox-text">
|
|
872
|
+
</span>
|
|
873
|
+
</label>
|
|
874
|
+
</td>
|
|
875
|
+
<td data-field="Id">
|
|
876
|
+
<span>4</span>
|
|
877
|
+
</td>
|
|
878
|
+
<td data-field="First name">
|
|
879
|
+
<span>Jamar</span>
|
|
880
|
+
</td>
|
|
881
|
+
<td data-field="Last name">
|
|
882
|
+
<span>Johnson</span>
|
|
883
|
+
</td>
|
|
884
|
+
<td data-field="E-mail">
|
|
885
|
+
<span>Kaya42@gmail.com</span>
|
|
886
|
+
</td>
|
|
887
|
+
<td class="table-action">
|
|
888
|
+
<span>
|
|
889
|
+
<div class="dropdown btn-group">
|
|
890
|
+
<button type="button" id="rgtlia8p40g" class="btn btn-default btn-link btn-md btn-icon-only btn-component dropdown-toggle" tabindex="0">
|
|
891
|
+
<span class="rioglyph rioglyph-option-vertical">
|
|
892
|
+
</span>
|
|
893
|
+
</button>
|
|
894
|
+
</div>
|
|
895
|
+
</span>
|
|
896
|
+
</td>
|
|
897
|
+
</tr>
|
|
898
|
+
<tr data-id="5" class="cursor-pointer">
|
|
899
|
+
<td class="table-checkbox">
|
|
900
|
+
<label class="checkbox" tabindex="0">
|
|
901
|
+
<input type="checkbox" class="">
|
|
902
|
+
<span class="checkbox-text">
|
|
903
|
+
</span>
|
|
904
|
+
</label>
|
|
905
|
+
</td>
|
|
906
|
+
<td data-field="Id">
|
|
907
|
+
<span>5</span>
|
|
908
|
+
</td>
|
|
909
|
+
<td data-field="First name">
|
|
910
|
+
<span>Ruthe</span>
|
|
911
|
+
</td>
|
|
912
|
+
<td data-field="Last name">
|
|
913
|
+
<span>Reynolds</span>
|
|
914
|
+
</td>
|
|
915
|
+
<td data-field="E-mail">
|
|
916
|
+
<span>Lila.Jakubowski@hotmail.com</span>
|
|
917
|
+
</td>
|
|
918
|
+
<td class="table-action">
|
|
919
|
+
<span>
|
|
920
|
+
<div class="dropdown btn-group">
|
|
921
|
+
<button type="button" id="btv0uqk3ek" class="btn btn-default btn-link btn-md btn-icon-only btn-component dropdown-toggle" tabindex="0">
|
|
922
|
+
<span class="rioglyph rioglyph-option-vertical">
|
|
923
|
+
</span>
|
|
924
|
+
</button>
|
|
925
|
+
</div>
|
|
926
|
+
</span>
|
|
927
|
+
</td>
|
|
928
|
+
</tr>
|
|
929
|
+
<tr data-id="6" class="cursor-pointer">
|
|
930
|
+
<td class="table-checkbox">
|
|
931
|
+
<label class="checkbox" tabindex="0">
|
|
932
|
+
<input type="checkbox" class="">
|
|
933
|
+
<span class="checkbox-text">
|
|
934
|
+
</span>
|
|
935
|
+
</label>
|
|
936
|
+
</td>
|
|
937
|
+
<td data-field="Id">
|
|
938
|
+
<span>6</span>
|
|
939
|
+
</td>
|
|
940
|
+
<td data-field="First name">
|
|
941
|
+
<span>Madison</span>
|
|
942
|
+
</td>
|
|
943
|
+
<td data-field="Last name">
|
|
944
|
+
<span>Legros</span>
|
|
945
|
+
</td>
|
|
946
|
+
<td data-field="E-mail">
|
|
947
|
+
<span>Aileen.Hills75@hotmail.com</span>
|
|
948
|
+
</td>
|
|
949
|
+
<td class="table-action">
|
|
950
|
+
<span>
|
|
951
|
+
<div class="dropdown btn-group">
|
|
952
|
+
<button type="button" id="gte9wfn7bzg" class="btn btn-default btn-link btn-md btn-icon-only btn-component dropdown-toggle" tabindex="0">
|
|
953
|
+
<span class="rioglyph rioglyph-option-vertical">
|
|
954
|
+
</span>
|
|
955
|
+
</button>
|
|
956
|
+
</div>
|
|
957
|
+
</span>
|
|
958
|
+
</td>
|
|
959
|
+
</tr>
|
|
960
|
+
<tr data-id="7" class="cursor-pointer">
|
|
961
|
+
<td class="table-checkbox">
|
|
962
|
+
<label class="checkbox" tabindex="0">
|
|
963
|
+
<input type="checkbox" class="">
|
|
964
|
+
<span class="checkbox-text">
|
|
965
|
+
</span>
|
|
966
|
+
</label>
|
|
967
|
+
</td>
|
|
968
|
+
<td data-field="Id">
|
|
969
|
+
<span>7</span>
|
|
970
|
+
</td>
|
|
971
|
+
<td data-field="First name">
|
|
972
|
+
<span>Erica</span>
|
|
973
|
+
</td>
|
|
974
|
+
<td data-field="Last name">
|
|
975
|
+
<span>Kessler</span>
|
|
976
|
+
</td>
|
|
977
|
+
<td data-field="E-mail">
|
|
978
|
+
<span>Silas70@yahoo.com</span>
|
|
979
|
+
</td>
|
|
980
|
+
<td class="table-action">
|
|
981
|
+
<span>
|
|
982
|
+
<div class="dropdown btn-group">
|
|
983
|
+
<button type="button" id="owixzq4ow" class="btn btn-default btn-link btn-md btn-icon-only btn-component dropdown-toggle" tabindex="0">
|
|
984
|
+
<span class="rioglyph rioglyph-option-vertical">
|
|
985
|
+
</span>
|
|
986
|
+
</button>
|
|
987
|
+
</div>
|
|
988
|
+
</span>
|
|
989
|
+
</td>
|
|
990
|
+
</tr>
|
|
991
|
+
<tr data-id="8" class="cursor-pointer">
|
|
992
|
+
<td class="table-checkbox">
|
|
993
|
+
<label class="checkbox" tabindex="0">
|
|
994
|
+
<input type="checkbox" class="">
|
|
995
|
+
<span class="checkbox-text">
|
|
996
|
+
</span>
|
|
997
|
+
</label>
|
|
998
|
+
</td>
|
|
999
|
+
<td data-field="Id">
|
|
1000
|
+
<span>8</span>
|
|
1001
|
+
</td>
|
|
1002
|
+
<td data-field="First name">
|
|
1003
|
+
<span>Montana</span>
|
|
1004
|
+
</td>
|
|
1005
|
+
<td data-field="Last name">
|
|
1006
|
+
<span>Okuneva</span>
|
|
1007
|
+
</td>
|
|
1008
|
+
<td data-field="E-mail">
|
|
1009
|
+
<span>Nikki_Hagenes@gmail.com</span>
|
|
1010
|
+
</td>
|
|
1011
|
+
<td class="table-action">
|
|
1012
|
+
<span>
|
|
1013
|
+
<div class="dropdown btn-group">
|
|
1014
|
+
<button type="button" id="72ktik8sm85" class="btn btn-default btn-link btn-md btn-icon-only btn-component dropdown-toggle" tabindex="0">
|
|
1015
|
+
<span class="rioglyph rioglyph-option-vertical">
|
|
1016
|
+
</span>
|
|
1017
|
+
</button>
|
|
1018
|
+
</div>
|
|
1019
|
+
</span>
|
|
1020
|
+
</td>
|
|
1021
|
+
</tr>
|
|
1022
|
+
<tr data-id="9" class="cursor-pointer">
|
|
1023
|
+
<td class="table-checkbox">
|
|
1024
|
+
<label class="checkbox" tabindex="0">
|
|
1025
|
+
<input type="checkbox" class="">
|
|
1026
|
+
<span class="checkbox-text">
|
|
1027
|
+
</span>
|
|
1028
|
+
</label>
|
|
1029
|
+
</td>
|
|
1030
|
+
<td data-field="Id">
|
|
1031
|
+
<span>9</span>
|
|
1032
|
+
</td>
|
|
1033
|
+
<td data-field="First name">
|
|
1034
|
+
<span>Rubye</span>
|
|
1035
|
+
</td>
|
|
1036
|
+
<td data-field="Last name">
|
|
1037
|
+
<span>Steuber</span>
|
|
1038
|
+
</td>
|
|
1039
|
+
<td data-field="E-mail">
|
|
1040
|
+
<span>Alessandra.Feest70@yahoo.com</span>
|
|
1041
|
+
</td>
|
|
1042
|
+
<td class="table-action">
|
|
1043
|
+
<span>
|
|
1044
|
+
<div class="dropdown btn-group">
|
|
1045
|
+
<button type="button" id="f2jsn496wnp" class="btn btn-default btn-link btn-md btn-icon-only btn-component dropdown-toggle" tabindex="0">
|
|
1046
|
+
<span class="rioglyph rioglyph-option-vertical">
|
|
1047
|
+
</span>
|
|
1048
|
+
</button>
|
|
1049
|
+
</div>
|
|
1050
|
+
</span>
|
|
1051
|
+
</td>
|
|
1052
|
+
</tr>
|
|
1053
|
+
<tr data-id="10" class="cursor-pointer">
|
|
1054
|
+
<td class="table-checkbox">
|
|
1055
|
+
<label class="checkbox" tabindex="0">
|
|
1056
|
+
<input type="checkbox" class="">
|
|
1057
|
+
<span class="checkbox-text">
|
|
1058
|
+
</span>
|
|
1059
|
+
</label>
|
|
1060
|
+
</td>
|
|
1061
|
+
<td data-field="Id">
|
|
1062
|
+
<span>10</span>
|
|
1063
|
+
</td>
|
|
1064
|
+
<td data-field="First name">
|
|
1065
|
+
<span>Winifred</span>
|
|
1066
|
+
</td>
|
|
1067
|
+
<td data-field="Last name">
|
|
1068
|
+
<span>O'Kon</span>
|
|
1069
|
+
</td>
|
|
1070
|
+
<td data-field="E-mail">
|
|
1071
|
+
<span>Sebastian.Wuckert25@hotmail.com</span>
|
|
1072
|
+
</td>
|
|
1073
|
+
<td class="table-action">
|
|
1074
|
+
<span>
|
|
1075
|
+
<div class="dropdown btn-group">
|
|
1076
|
+
<button type="button" id="lgba9i71qv" class="btn btn-default btn-link btn-md btn-icon-only btn-component dropdown-toggle" tabindex="0">
|
|
1077
|
+
<span class="rioglyph rioglyph-option-vertical">
|
|
1078
|
+
</span>
|
|
1079
|
+
</button>
|
|
1080
|
+
</div>
|
|
1081
|
+
</span>
|
|
1082
|
+
</td>
|
|
1083
|
+
</tr>
|
|
1084
|
+
</tbody>
|
|
1085
|
+
</table>
|
|
1086
|
+
</div>
|
|
1087
|
+
</div>
|
|
1088
|
+
```
|
|
1089
|
+
|
|
1090
|
+
#### Props: Options for the `useTableSelection` hook
|
|
1091
|
+
|
|
1092
|
+
### Options for the `useTableSelection` hook
|
|
1093
|
+
|
|
1094
|
+
| Name | Type | Default | Description |
|
|
1095
|
+
| --- | --- | --- | --- |
|
|
1096
|
+
| tableData | TData[] | — | The array of data items to be displayed in the table. The hook uses this to determine all possible row IDs for "select all" functionality. |
|
|
1097
|
+
| idKey | keyof TData | — | The key in `TData` objects that serves as the unique identifier for each row. |
|
|
1098
|
+
| initialSelectedRowIds | string[] | — | Optional array of row IDs that should be initially selected. |
|
|
1099
|
+
| initialActiveRowId | string | — | Optional ID of the row that should be initially marked as active. |
|
|
1100
|
+
| checkboxQuerySelector | string | '.table-checkbox input[type="checkbox"]' | Optional CSS query selector to find the checkbox input element within each table row. |
|
|
1101
|
+
| dataAttributeName | string | data-id | Optional name of the HTML data attribute on `<tr>` elements that holds the unique row ID. |
|
|
1102
|
+
| ref | RefObject<HTMLTableElement> | — | Optional external ref for the table element. If not provided, the hook creates its own. Useful if the parent component needs direct access to the table DOM element for other purposes. |
|
|
1103
|
+
|
|
1104
|
+
#### Props: Return value of the `useTableSelection` hook
|
|
1105
|
+
|
|
1106
|
+
### Return value of the `useTableSelection` hook
|
|
1107
|
+
|
|
1108
|
+
| Name | Type | Default | Description |
|
|
1109
|
+
| --- | --- | --- | --- |
|
|
1110
|
+
| tableRef | RefObject<HTMLTableElement> | — | React ref attached to the `<table>` HTML element. Ensure this ref is assigned to your table element to enable DOM manipulations. |
|
|
1111
|
+
| selectedRowIds | string[] | — | An array of strings, where each string is the ID of a currently selected row. |
|
|
1112
|
+
| setSelectedRowIds | (rowIds: string[]) => void | — | Setter function to change selected rows from the outside in a controlled manner. |
|
|
1113
|
+
| activeRowId | string | — | The ID of the currently active row. An empty string signifies no row is active. |
|
|
1114
|
+
| setActiveRowId | (activeRowId: string \| undefined) => void | — | Setter function to change the active row from the outside in a controlled manner. Use this to deselect an active row. |
|
|
1115
|
+
| onSelection | (event: React.MouseEvent<HTMLElement>) => void | — | Callback handler to be attached to the click/change event of individual row selection UI elements (e.g., checkboxes). It expects the clicked element to be within a `<tr>` that has the specified `dataAttributeName`. Manages the selection state of a single row. |
|
|
1116
|
+
| onActiveRowChange | (event: React.MouseEvent<HTMLTableRowElement>) => void | — | Callback handler to be attached to the click event of table row (`<tr>`) elements.Manages the active row state. |
|
|
1117
|
+
| onToggleAll | (shouldSelect: boolean) => void | — | Callback handler to select or deselect all rows. If "shouldSelect" is set to true, all rows in `tableData` will be selected; otherwise, all selections will be cleared. |
|
|
1118
|
+
| updateRowSelection | () => void | — | Function to update row selection and active highlighting. This is useful when the row data changes due to a search value or any other filter. |
|
|
1119
|
+
| hasSelection | boolean | — | A boolean indicating whether at least one row is currently selected. |
|
|
1120
|
+
| isAllSelected | boolean | — | A boolean indicating whether all rows in the current `tableData` are selected. |
|