@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,389 @@
|
|
|
1
|
+
# useSorting
|
|
2
|
+
|
|
3
|
+
*Category:* Utilities
|
|
4
|
+
*Section:* Table & data hooks
|
|
5
|
+
*Source:* https://uikit.developers.rio.cloud/#utilities/useSorting
|
|
6
|
+
*Captured:* 2025-12-12T12:39:50.836Z
|
|
7
|
+
|
|
8
|
+
The useSorting hook provides an easy way to sort any list by a specified key using natural sort order. It offers flexible control over sorting direction and key selection, making it ideal for dynamic sorting use cases.
|
|
9
|
+
|
|
10
|
+
## useSorting
|
|
11
|
+
|
|
12
|
+
### Example: Example 1
|
|
13
|
+
|
|
14
|
+
NameQuantity
|
|
15
|
+
|
|
16
|
+
Box20
|
|
17
|
+
Container1
|
|
18
|
+
Crate15
|
|
19
|
+
Drum12
|
|
20
|
+
Pallet10
|
|
21
|
+
Parcel8
|
|
22
|
+
|
|
23
|
+
#### Summary
|
|
24
|
+
|
|
25
|
+
NameQuantity
|
|
26
|
+
|
|
27
|
+
Box20
|
|
28
|
+
Container1
|
|
29
|
+
Crate15
|
|
30
|
+
Drum12
|
|
31
|
+
Pallet10
|
|
32
|
+
Parcel8
|
|
33
|
+
|
|
34
|
+
#### React (tsx)
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import SortArrows from '@rio-cloud/rio-uikit/SortArrows';
|
|
38
|
+
import useSorting from '@rio-cloud/rio-uikit/useSorting';
|
|
39
|
+
|
|
40
|
+
type Item = {
|
|
41
|
+
name: string;
|
|
42
|
+
quantity: number;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const items: Item[] = [
|
|
46
|
+
{ name: 'Pallet', quantity: 10 },
|
|
47
|
+
{ name: 'Container', quantity: 1 },
|
|
48
|
+
{ name: 'Crate', quantity: 15 },
|
|
49
|
+
{ name: 'Parcel', quantity: 8 },
|
|
50
|
+
{ name: 'Drum', quantity: 12 },
|
|
51
|
+
{ name: 'Box', quantity: 20 },
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
export default () => {
|
|
55
|
+
const { sortedItems, sortKey, sortDirection, setSortKey, toggleDirection } = useSorting(items, 'name');
|
|
56
|
+
|
|
57
|
+
const handleSortByColumn = (column: keyof Item) => {
|
|
58
|
+
setSortKey(column);
|
|
59
|
+
if (column === sortKey) {
|
|
60
|
+
toggleDirection();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<div className='table-responsive'>
|
|
66
|
+
<table className='table table-head-filled'>
|
|
67
|
+
<thead>
|
|
68
|
+
<tr>
|
|
69
|
+
<th className='user-select-none sort-column' onClick={() => handleSortByColumn('name')}>
|
|
70
|
+
<span>
|
|
71
|
+
{sortKey === 'name' ? <SortArrows direction={sortDirection} /> : <SortArrows />}
|
|
72
|
+
<span>Name</span>
|
|
73
|
+
</span>
|
|
74
|
+
</th>
|
|
75
|
+
<th className='user-select-none sort-column' onClick={() => handleSortByColumn('quantity')}>
|
|
76
|
+
<span>
|
|
77
|
+
{sortKey === 'quantity' ? <SortArrows direction={sortDirection} /> : <SortArrows />}
|
|
78
|
+
<span>Quantity</span>
|
|
79
|
+
</span>
|
|
80
|
+
</th>
|
|
81
|
+
</tr>
|
|
82
|
+
</thead>
|
|
83
|
+
<tbody>
|
|
84
|
+
{sortedItems.map(({ name, quantity }) => (
|
|
85
|
+
<tr key={name}>
|
|
86
|
+
<td key={name}>{name}</td>
|
|
87
|
+
<td key={quantity}>{quantity}</td>
|
|
88
|
+
</tr>
|
|
89
|
+
))}
|
|
90
|
+
</tbody>
|
|
91
|
+
</table>
|
|
92
|
+
</div>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### HTML (html)
|
|
98
|
+
|
|
99
|
+
```html
|
|
100
|
+
<div class="table-responsive">
|
|
101
|
+
<table class="table table-head-filled">
|
|
102
|
+
<thead>
|
|
103
|
+
<tr>
|
|
104
|
+
<th class="user-select-none sort-column">
|
|
105
|
+
<span>
|
|
106
|
+
<span class="sort-arrows sort-asc">
|
|
107
|
+
</span>
|
|
108
|
+
<span>Name</span>
|
|
109
|
+
</span>
|
|
110
|
+
</th>
|
|
111
|
+
<th class="user-select-none sort-column">
|
|
112
|
+
<span>
|
|
113
|
+
<span class="sort-arrows ">
|
|
114
|
+
</span>
|
|
115
|
+
<span>Quantity</span>
|
|
116
|
+
</span>
|
|
117
|
+
</th>
|
|
118
|
+
</tr>
|
|
119
|
+
</thead>
|
|
120
|
+
<tbody>
|
|
121
|
+
<tr>
|
|
122
|
+
<td>Box</td>
|
|
123
|
+
<td>20</td>
|
|
124
|
+
</tr>
|
|
125
|
+
<tr>
|
|
126
|
+
<td>Container</td>
|
|
127
|
+
<td>1</td>
|
|
128
|
+
</tr>
|
|
129
|
+
<tr>
|
|
130
|
+
<td>Crate</td>
|
|
131
|
+
<td>15</td>
|
|
132
|
+
</tr>
|
|
133
|
+
<tr>
|
|
134
|
+
<td>Drum</td>
|
|
135
|
+
<td>12</td>
|
|
136
|
+
</tr>
|
|
137
|
+
<tr>
|
|
138
|
+
<td>Pallet</td>
|
|
139
|
+
<td>10</td>
|
|
140
|
+
</tr>
|
|
141
|
+
<tr>
|
|
142
|
+
<td>Parcel</td>
|
|
143
|
+
<td>8</td>
|
|
144
|
+
</tr>
|
|
145
|
+
</tbody>
|
|
146
|
+
</table>
|
|
147
|
+
</div>
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
#### Props
|
|
151
|
+
|
|
152
|
+
| Name | Type | Default | Description |
|
|
153
|
+
| --- | --- | --- | --- |
|
|
154
|
+
| items | T[] | — | The array of items to be sorted. |
|
|
155
|
+
| initialKey | SortKey<T> = keyof T \| [keyof T, keyof T] | — | The initial key or keys to sort by. Must be a property of the items in the array. It can be either a single string or a tuple like ['name', 'date'] |
|
|
156
|
+
| initialDirection | SortDirectionType | SortDirection.ASCENDING | The initial sort direction. Can be SortDirection.ASCENDING or SortDirection.DESCENDING. |
|
|
157
|
+
| enableNaturalSort | boolean | true | Whether to use natural sort order. Defaults to false. |
|
|
158
|
+
| { sortedItems, sortKey, sortDirection, setSortKey, setSortDirection, toggleDirection } | Object | — | Returns an object containing: "sortedItems" - the sorted array "sortKey" - the key(s) to sort the data for "sortDirection" - the current direction that the data is sorted "setSortKey" - function to change the sorting key(s) afterwards "setSortDirection" - function to change the sorting order afterwards "toggleDirection" - function to toggle sort direction |
|
|
159
|
+
|
|
160
|
+
### Example: Example 2
|
|
161
|
+
|
|
162
|
+
Sort by a primary column. Hold shift key to sort by a secondary column
|
|
163
|
+
CategoryNameQuantity
|
|
164
|
+
|
|
165
|
+
ShippingParcel8
|
|
166
|
+
ShippingBox20
|
|
167
|
+
ShippingEnvelope50
|
|
168
|
+
ShippingBag30
|
|
169
|
+
StoragePallet10
|
|
170
|
+
StorageContainer1
|
|
171
|
+
StorageCrate15
|
|
172
|
+
StorageDrum12
|
|
173
|
+
|
|
174
|
+
#### Summary
|
|
175
|
+
|
|
176
|
+
Sort by a primary column. Hold shift key to sort by a secondary column
|
|
177
|
+
CategoryNameQuantity
|
|
178
|
+
|
|
179
|
+
ShippingParcel8
|
|
180
|
+
ShippingBox20
|
|
181
|
+
ShippingEnvelope50
|
|
182
|
+
ShippingBag30
|
|
183
|
+
StoragePallet10
|
|
184
|
+
StorageContainer1
|
|
185
|
+
StorageCrate15
|
|
186
|
+
StorageDrum12
|
|
187
|
+
|
|
188
|
+
#### React (tsx)
|
|
189
|
+
|
|
190
|
+
```tsx
|
|
191
|
+
import SortArrows from '@rio-cloud/rio-uikit/SortArrows';
|
|
192
|
+
import useSorting from '@rio-cloud/rio-uikit/useSorting';
|
|
193
|
+
|
|
194
|
+
type Item = {
|
|
195
|
+
name: string;
|
|
196
|
+
category: string;
|
|
197
|
+
quantity: number;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const items: Item[] = [
|
|
201
|
+
{ name: 'Pallet', category: 'Storage', quantity: 10 },
|
|
202
|
+
{ name: 'Container', category: 'Storage', quantity: 1 },
|
|
203
|
+
{ name: 'Crate', category: 'Storage', quantity: 15 },
|
|
204
|
+
{ name: 'Parcel', category: 'Shipping', quantity: 8 },
|
|
205
|
+
{ name: 'Drum', category: 'Storage', quantity: 12 },
|
|
206
|
+
{ name: 'Box', category: 'Shipping', quantity: 20 },
|
|
207
|
+
{ name: 'Envelope', category: 'Shipping', quantity: 50 },
|
|
208
|
+
{ name: 'Bag', category: 'Shipping', quantity: 30 },
|
|
209
|
+
];
|
|
210
|
+
|
|
211
|
+
export default () => {
|
|
212
|
+
const { sortedItems, sortKey, sortDirection, setSortKey, toggleDirection } = useSorting(items, 'category');
|
|
213
|
+
|
|
214
|
+
const handleSortByColumn = (column: keyof Item, event: React.MouseEvent) => {
|
|
215
|
+
if (event.shiftKey) {
|
|
216
|
+
// Secondary sort
|
|
217
|
+
if (Array.isArray(sortKey) && sortKey[1] === column) {
|
|
218
|
+
// If already secondary, toggle direction
|
|
219
|
+
toggleDirection();
|
|
220
|
+
} else if (Array.isArray(sortKey)) {
|
|
221
|
+
// If already using secondary sort, update secondary key
|
|
222
|
+
setSortKey([sortKey[0], column]);
|
|
223
|
+
} else {
|
|
224
|
+
// If not using secondary sort, add secondary key
|
|
225
|
+
setSortKey([sortKey, column]);
|
|
226
|
+
}
|
|
227
|
+
} else {
|
|
228
|
+
// Primary sort
|
|
229
|
+
if (sortKey === column || (Array.isArray(sortKey) && sortKey[0] === column)) {
|
|
230
|
+
// If already primary, toggle direction
|
|
231
|
+
toggleDirection();
|
|
232
|
+
} else {
|
|
233
|
+
// Set new primary key
|
|
234
|
+
setSortKey(column);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
const renderSortArrows = (column: keyof Item) => {
|
|
240
|
+
if (sortKey === column || (Array.isArray(sortKey) && sortKey[0] === column)) {
|
|
241
|
+
return <SortArrows direction={sortDirection} />;
|
|
242
|
+
}
|
|
243
|
+
if (Array.isArray(sortKey) && sortKey[1] === column) {
|
|
244
|
+
return <SortArrows direction={sortDirection} />;
|
|
245
|
+
}
|
|
246
|
+
return <SortArrows />;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
return (
|
|
250
|
+
<>
|
|
251
|
+
<p>
|
|
252
|
+
Sort by a primary column. Hold <kbd className='text-normal'>shift</kbd> key to sort by a secondary
|
|
253
|
+
column
|
|
254
|
+
</p>
|
|
255
|
+
<div className='table-responsive'>
|
|
256
|
+
<table className='table table-head-filled'>
|
|
257
|
+
<thead>
|
|
258
|
+
<tr>
|
|
259
|
+
<th
|
|
260
|
+
className='user-select-none sort-column'
|
|
261
|
+
onClick={event => handleSortByColumn('category', event)}
|
|
262
|
+
>
|
|
263
|
+
<span>
|
|
264
|
+
{renderSortArrows('category')}
|
|
265
|
+
<span>Category</span>
|
|
266
|
+
</span>
|
|
267
|
+
</th>
|
|
268
|
+
<th
|
|
269
|
+
className='user-select-none sort-column'
|
|
270
|
+
onClick={event => handleSortByColumn('name', event)}
|
|
271
|
+
>
|
|
272
|
+
<span>
|
|
273
|
+
{renderSortArrows('name')}
|
|
274
|
+
<span>Name</span>
|
|
275
|
+
</span>
|
|
276
|
+
</th>
|
|
277
|
+
<th
|
|
278
|
+
className='user-select-none sort-column'
|
|
279
|
+
onClick={event => handleSortByColumn('quantity', event)}
|
|
280
|
+
>
|
|
281
|
+
<span>
|
|
282
|
+
{renderSortArrows('quantity')}
|
|
283
|
+
<span>Quantity</span>
|
|
284
|
+
</span>
|
|
285
|
+
</th>
|
|
286
|
+
</tr>
|
|
287
|
+
</thead>
|
|
288
|
+
<tbody>
|
|
289
|
+
{sortedItems.map(item => (
|
|
290
|
+
<tr key={item.name}>
|
|
291
|
+
<td>{item.category}</td>
|
|
292
|
+
<td>{item.name}</td>
|
|
293
|
+
<td>{item.quantity}</td>
|
|
294
|
+
</tr>
|
|
295
|
+
))}
|
|
296
|
+
</tbody>
|
|
297
|
+
</table>
|
|
298
|
+
</div>
|
|
299
|
+
</>
|
|
300
|
+
);
|
|
301
|
+
};
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
#### HTML (html)
|
|
305
|
+
|
|
306
|
+
```html
|
|
307
|
+
<p>Sort by a primary column. Hold <kbd class="text-normal">shift</kbd> key to sort by a secondary column</p>
|
|
308
|
+
<div class="table-responsive">
|
|
309
|
+
<table class="table table-head-filled">
|
|
310
|
+
<thead>
|
|
311
|
+
<tr>
|
|
312
|
+
<th class="user-select-none sort-column">
|
|
313
|
+
<span>
|
|
314
|
+
<span class="sort-arrows sort-asc">
|
|
315
|
+
</span>
|
|
316
|
+
<span>Category</span>
|
|
317
|
+
</span>
|
|
318
|
+
</th>
|
|
319
|
+
<th class="user-select-none sort-column">
|
|
320
|
+
<span>
|
|
321
|
+
<span class="sort-arrows ">
|
|
322
|
+
</span>
|
|
323
|
+
<span>Name</span>
|
|
324
|
+
</span>
|
|
325
|
+
</th>
|
|
326
|
+
<th class="user-select-none sort-column">
|
|
327
|
+
<span>
|
|
328
|
+
<span class="sort-arrows ">
|
|
329
|
+
</span>
|
|
330
|
+
<span>Quantity</span>
|
|
331
|
+
</span>
|
|
332
|
+
</th>
|
|
333
|
+
</tr>
|
|
334
|
+
</thead>
|
|
335
|
+
<tbody>
|
|
336
|
+
<tr>
|
|
337
|
+
<td>Shipping</td>
|
|
338
|
+
<td>Parcel</td>
|
|
339
|
+
<td>8</td>
|
|
340
|
+
</tr>
|
|
341
|
+
<tr>
|
|
342
|
+
<td>Shipping</td>
|
|
343
|
+
<td>Box</td>
|
|
344
|
+
<td>20</td>
|
|
345
|
+
</tr>
|
|
346
|
+
<tr>
|
|
347
|
+
<td>Shipping</td>
|
|
348
|
+
<td>Envelope</td>
|
|
349
|
+
<td>50</td>
|
|
350
|
+
</tr>
|
|
351
|
+
<tr>
|
|
352
|
+
<td>Shipping</td>
|
|
353
|
+
<td>Bag</td>
|
|
354
|
+
<td>30</td>
|
|
355
|
+
</tr>
|
|
356
|
+
<tr>
|
|
357
|
+
<td>Storage</td>
|
|
358
|
+
<td>Pallet</td>
|
|
359
|
+
<td>10</td>
|
|
360
|
+
</tr>
|
|
361
|
+
<tr>
|
|
362
|
+
<td>Storage</td>
|
|
363
|
+
<td>Container</td>
|
|
364
|
+
<td>1</td>
|
|
365
|
+
</tr>
|
|
366
|
+
<tr>
|
|
367
|
+
<td>Storage</td>
|
|
368
|
+
<td>Crate</td>
|
|
369
|
+
<td>15</td>
|
|
370
|
+
</tr>
|
|
371
|
+
<tr>
|
|
372
|
+
<td>Storage</td>
|
|
373
|
+
<td>Drum</td>
|
|
374
|
+
<td>12</td>
|
|
375
|
+
</tr>
|
|
376
|
+
</tbody>
|
|
377
|
+
</table>
|
|
378
|
+
</div>
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
#### Props
|
|
382
|
+
|
|
383
|
+
| Name | Type | Default | Description |
|
|
384
|
+
| --- | --- | --- | --- |
|
|
385
|
+
| items | T[] | — | The array of items to be sorted. |
|
|
386
|
+
| initialKey | SortKey<T> = keyof T \| [keyof T, keyof T] | — | The initial key or keys to sort by. Must be a property of the items in the array. It can be either a single string or a tuple like ['name', 'date'] |
|
|
387
|
+
| initialDirection | SortDirectionType | SortDirection.ASCENDING | The initial sort direction. Can be SortDirection.ASCENDING or SortDirection.DESCENDING. |
|
|
388
|
+
| enableNaturalSort | boolean | true | Whether to use natural sort order. Defaults to false. |
|
|
389
|
+
| { sortedItems, sortKey, sortDirection, setSortKey, setSortDirection, toggleDirection } | Object | — | Returns an object containing: "sortedItems" - the sorted array "sortKey" - the key(s) to sort the data for "sortDirection" - the current direction that the data is sorted "setSortKey" - function to change the sorting key(s) afterwards "setSortDirection" - function to change the sorting order afterwards "toggleDirection" - function to toggle sort direction |
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# useStateWithValidation
|
|
2
|
+
|
|
3
|
+
*Category:* Utilities
|
|
4
|
+
*Section:* UI state & input hooks
|
|
5
|
+
*Source:* https://uikit.developers.rio.cloud/#utilities/useStateWithValidation
|
|
6
|
+
*Captured:* 2025-12-12T12:39:47.737Z
|
|
7
|
+
|
|
8
|
+
The useStateWithValidation hook allows to easily validate state. This comes in handy when validating form inputs.
|
|
9
|
+
|
|
10
|
+
## useStateWithValidation
|
|
11
|
+
|
|
12
|
+
### Example: Example 1
|
|
13
|
+
|
|
14
|
+
Username
|
|
15
|
+
|
|
16
|
+
#### Summary
|
|
17
|
+
|
|
18
|
+
Username
|
|
19
|
+
|
|
20
|
+
#### React (tsx)
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import useStateWithValidation from '@rio-cloud/rio-uikit/useStateWithValidation';
|
|
24
|
+
|
|
25
|
+
export default () => {
|
|
26
|
+
const validationFn = (name: string) => name.length > 5;
|
|
27
|
+
|
|
28
|
+
const [username, setUsername, isValid] = useStateWithValidation<string>(validationFn, '');
|
|
29
|
+
|
|
30
|
+
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
31
|
+
setUsername(event.target.value);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const showError = username.length > 0 && !isValid;
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div className='display-flex flex-column max-width-400'>
|
|
38
|
+
<div className={`form-group ${showError ? 'has-error has-feedback' : ''}`}>
|
|
39
|
+
<label htmlFor='inputUsername'>Username</label>
|
|
40
|
+
<div className='form-control-feedback-wrapper'>
|
|
41
|
+
<input
|
|
42
|
+
id='inputUsername'
|
|
43
|
+
type='text'
|
|
44
|
+
className='form-control'
|
|
45
|
+
placeholder='Please enter your username'
|
|
46
|
+
value={username}
|
|
47
|
+
onChange={handleInputChange}
|
|
48
|
+
/>
|
|
49
|
+
{showError && (
|
|
50
|
+
<>
|
|
51
|
+
<span className='form-control-feedback rioglyph rioglyph-error-sign' />
|
|
52
|
+
<span className='help-block'>
|
|
53
|
+
<span>Username is to short. Please enter at least 5 characters.</span>
|
|
54
|
+
</span>
|
|
55
|
+
</>
|
|
56
|
+
)}
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
#### HTML (html)
|
|
65
|
+
|
|
66
|
+
```html
|
|
67
|
+
<div class="display-flex flex-column max-width-400">
|
|
68
|
+
<div class="form-group ">
|
|
69
|
+
<label for="inputUsername">Username</label>
|
|
70
|
+
<div class="form-control-feedback-wrapper">
|
|
71
|
+
<input id="inputUsername" type="text" class="form-control" placeholder="Please enter your username" value="">
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### Props
|
|
78
|
+
|
|
79
|
+
| Name | Type | Default | Description |
|
|
80
|
+
| --- | --- | --- | --- |
|
|
81
|
+
| validationFn | Function | — | The validation function that gets invoked when the passed state changes. |
|
|
82
|
+
| initialValue | Any | — | The initial state value. |
|
|
83
|
+
| [state, onChange, isValid] | Array | — | Returns the actual "state", the "onChange" function that will be invoked when the state changes, and the "isValid" flag. |
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# useSum
|
|
2
|
+
|
|
3
|
+
*Category:* Utilities
|
|
4
|
+
*Section:* Data aggregation hooks
|
|
5
|
+
*Source:* https://uikit.developers.rio.cloud/#utilities/useSum
|
|
6
|
+
*Captured:* 2025-12-12T12:39:49.571Z
|
|
7
|
+
|
|
8
|
+
The useSum hook is a versatile utility for calculating the total of numeric, localized values within a list of objects—particularly useful for rendering totals in table footers, dashboards, or KPIs.
|
|
9
|
+
|
|
10
|
+
## useSum
|
|
11
|
+
|
|
12
|
+
It supports locale-aware number parsing (e.g. 1.234,50 € or 2 500,75 kg)
|
|
13
|
+
|
|
14
|
+
### Example: Example 1
|
|
15
|
+
|
|
16
|
+
3.930,75 km
|
|
17
|
+
5.197 €
|
|
18
|
+
1860min
|
|
19
|
+
31h
|
|
20
|
+
185 km
|
|
21
|
+
|
|
22
|
+
#### Summary
|
|
23
|
+
|
|
24
|
+
3.930,75 km
|
|
25
|
+
5.197 €
|
|
26
|
+
1860min
|
|
27
|
+
31h
|
|
28
|
+
185 km
|
|
29
|
+
|
|
30
|
+
#### React (tsx)
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import { FormattedNumber, IntlProvider } from 'react-intl';
|
|
34
|
+
|
|
35
|
+
import useSum from '@rio-cloud/rio-uikit/useSum';
|
|
36
|
+
|
|
37
|
+
export default () => {
|
|
38
|
+
const weightSum = useSum(deliveries, 'shipment.weight', { locale: 'de-DE' });
|
|
39
|
+
const valueSum = useSum(deliveries, 'shipment.value', { locale: 'de-DE' });
|
|
40
|
+
|
|
41
|
+
const durationSum = useSum(deliveries, 'shipment.duration');
|
|
42
|
+
|
|
43
|
+
const mileage = useSum(deliveries, 'vehicle.mileage');
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<IntlProvider locale='de-DE'>
|
|
47
|
+
<ul>
|
|
48
|
+
<li>
|
|
49
|
+
<FormattedNumber
|
|
50
|
+
value={weightSum}
|
|
51
|
+
minimumFractionDigits={0}
|
|
52
|
+
maximumFractionDigits={2}
|
|
53
|
+
style='unit'
|
|
54
|
+
unit='kilometer'
|
|
55
|
+
/>
|
|
56
|
+
</li>
|
|
57
|
+
<li>
|
|
58
|
+
<FormattedNumber
|
|
59
|
+
value={valueSum}
|
|
60
|
+
style='currency'
|
|
61
|
+
currency='EUR'
|
|
62
|
+
minimumFractionDigits={0}
|
|
63
|
+
maximumFractionDigits={0}
|
|
64
|
+
/>
|
|
65
|
+
</li>
|
|
66
|
+
<li>{durationSum}min</li>
|
|
67
|
+
<li>
|
|
68
|
+
<FormattedNumber value={durationSum / 60} maximumFractionDigits={1} />h
|
|
69
|
+
</li>
|
|
70
|
+
<li>
|
|
71
|
+
<FormattedNumber value={mileage} maximumFractionDigits={0} style='unit' unit='kilometer' />
|
|
72
|
+
</li>
|
|
73
|
+
</ul>
|
|
74
|
+
</IntlProvider>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const deliveries = [
|
|
79
|
+
{
|
|
80
|
+
id: 'D-1001',
|
|
81
|
+
vehicle: {
|
|
82
|
+
mileage: 97.5,
|
|
83
|
+
},
|
|
84
|
+
shipment: {
|
|
85
|
+
weight: '1.200,5 kg',
|
|
86
|
+
value: '2.345,50 €',
|
|
87
|
+
duration: 90, // raw minutes
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: 'D-1002',
|
|
92
|
+
vehicle: {
|
|
93
|
+
mileage: 10,
|
|
94
|
+
},
|
|
95
|
+
shipment: {
|
|
96
|
+
weight: '980,25 kg',
|
|
97
|
+
value: '1,000.75€',
|
|
98
|
+
duration: 150, // raw minutes
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
id: 'D-1003',
|
|
103
|
+
vehicle: {
|
|
104
|
+
mileage: 56,
|
|
105
|
+
},
|
|
106
|
+
shipment: {
|
|
107
|
+
weight: '750kg',
|
|
108
|
+
value: 850,
|
|
109
|
+
duration: 1440, // raw minutes
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
id: 'D-1004',
|
|
114
|
+
vehicle: {
|
|
115
|
+
mileage: 21,
|
|
116
|
+
},
|
|
117
|
+
shipment: {
|
|
118
|
+
weight: '1.000 kg',
|
|
119
|
+
value: '2.000,00 €',
|
|
120
|
+
duration: 180, // raw minutes
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
];
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
#### HTML (html)
|
|
127
|
+
|
|
128
|
+
```html
|
|
129
|
+
<ul>
|
|
130
|
+
<li>3.930,75 km</li>
|
|
131
|
+
<li>5.197 €</li>
|
|
132
|
+
<li>1860min</li>
|
|
133
|
+
<li>31h</li>
|
|
134
|
+
<li>185 km</li>
|
|
135
|
+
</ul>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
#### Props: Options for the `useSum` hook
|
|
139
|
+
|
|
140
|
+
### Options for the `useSum` hook
|
|
141
|
+
|
|
142
|
+
| Name | Type | Default | Description |
|
|
143
|
+
| --- | --- | --- | --- |
|
|
144
|
+
| items | unknown[] | — | The array of objects to aggregate values from. |
|
|
145
|
+
| path | string | — | Dot-separated path to the numeric value in each object. |
|
|
146
|
+
| options | object | — | Optional configuration for parsing behavior. |
|
|
147
|
+
| └locale | string | "en-GB" | Locale string used to parse localized number formats. Affects how grouping and decimal separators are interpreted. |
|
|
148
|
+
|
|
149
|
+
#### Props: Return value of the `useSum` hook
|
|
150
|
+
|
|
151
|
+
### Return value of the `useSum` hook
|
|
152
|
+
|
|
153
|
+
| Name | Type | Default | Description |
|
|
154
|
+
| --- | --- | --- | --- |
|
|
155
|
+
| sum | number | — | The total sum of all parsed values from the provided path in the given item list. |
|