@rio-cloud/uikit-mcp 1.0.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/LICENSE +202 -0
- package/README.md +91 -0
- package/bin/uikit-mcp.mjs +23 -0
- package/data/pages/Components/components/accentbar.json +207 -0
- package/data/pages/Components/components/activity.json +87 -0
- package/data/pages/Components/components/animatednumber.json +99 -0
- package/data/pages/Components/components/animations.json +87 -0
- package/data/pages/Components/components/appheader.json +291 -0
- package/data/pages/Components/components/applayout.json +1198 -0
- package/data/pages/Components/components/appnavigationbar.json +327 -0
- package/data/pages/Components/components/areacharts.json +563 -0
- package/data/pages/Components/components/aspectratioplaceholder.json +75 -0
- package/data/pages/Components/components/assettree.json +3080 -0
- package/data/pages/Components/components/autosuggests.json +710 -0
- package/data/pages/Components/components/avatar.json +157 -0
- package/data/pages/Components/components/banner.json +599 -0
- package/data/pages/Components/components/barcharts.json +1507 -0
- package/data/pages/Components/components/barlist.json +223 -0
- package/data/pages/Components/components/basicmap.json +68 -0
- package/data/pages/Components/components/bottomsheet.json +601 -0
- package/data/pages/Components/components/button.json +583 -0
- package/data/pages/Components/components/buttontoolbar.json +63 -0
- package/data/pages/Components/components/calendarstripe.json +235 -0
- package/data/pages/Components/components/card.json +69 -0
- package/data/pages/Components/components/carousel.json +39 -0
- package/data/pages/Components/components/chartcolors.json +34 -0
- package/data/pages/Components/components/chartsgettingstarted.json +32 -0
- package/data/pages/Components/components/chat.json +39 -0
- package/data/pages/Components/components/checkbox.json +847 -0
- package/data/pages/Components/components/clearableinput.json +789 -0
- package/data/pages/Components/components/collapse.json +175 -0
- package/data/pages/Components/components/composedcharts.json +159 -0
- package/data/pages/Components/components/contentloader.json +233 -0
- package/data/pages/Components/components/datatabs.json +680 -0
- package/data/pages/Components/components/datepickers.json +287 -0
- package/data/pages/Components/components/dialogs.json +1492 -0
- package/data/pages/Components/components/divider.json +93 -0
- package/data/pages/Components/components/dropdowns.json +936 -0
- package/data/pages/Components/components/editablecontent.json +1117 -0
- package/data/pages/Components/components/expander.json +377 -0
- package/data/pages/Components/components/fade.json +403 -0
- package/data/pages/Components/components/fadeexpander.json +75 -0
- package/data/pages/Components/components/fadeup.json +127 -0
- package/data/pages/Components/components/feedback.json +269 -0
- package/data/pages/Components/components/filepickers.json +269 -0
- package/data/pages/Components/components/formlabel.json +115 -0
- package/data/pages/Components/components/fullscreenmap.json +22 -0
- package/data/pages/Components/components/groupeditemlist.json +323 -0
- package/data/pages/Components/components/iconlist.json +45 -0
- package/data/pages/Components/components/imagepreloader.json +81 -0
- package/data/pages/Components/components/labeledelement.json +75 -0
- package/data/pages/Components/components/licenseplate.json +69 -0
- package/data/pages/Components/components/linecharts.json +987 -0
- package/data/pages/Components/components/listmenu.json +313 -0
- package/data/pages/Components/components/loadmore.json +175 -0
- package/data/pages/Components/components/mainnavigation.json +39 -0
- package/data/pages/Components/components/mapcircle.json +34 -0
- package/data/pages/Components/components/mapcluster.json +51 -0
- package/data/pages/Components/components/mapcontext.json +105 -0
- package/data/pages/Components/components/mapdraggablemarker.json +34 -0
- package/data/pages/Components/components/mapgettingstarted.json +27 -0
- package/data/pages/Components/components/mapgroup.json +1198 -0
- package/data/pages/Components/components/mapinfobubble.json +34 -0
- package/data/pages/Components/components/maplayergroup.json +34 -0
- package/data/pages/Components/components/mapmarker.json +700 -0
- package/data/pages/Components/components/mappolygon.json +45 -0
- package/data/pages/Components/components/maproute.json +623 -0
- package/data/pages/Components/components/maproutegenerator.json +16 -0
- package/data/pages/Components/components/mapsettings.json +51 -0
- package/data/pages/Components/components/maputils.json +34 -0
- package/data/pages/Components/components/multiselects.json +1451 -0
- package/data/pages/Components/components/nodata.json +139 -0
- package/data/pages/Components/components/notifications.json +65 -0
- package/data/pages/Components/components/numbercontrol.json +301 -0
- package/data/pages/Components/components/onboarding.json +302 -0
- package/data/pages/Components/components/page.json +197 -0
- package/data/pages/Components/components/pager.json +93 -0
- package/data/pages/Components/components/piecharts.json +731 -0
- package/data/pages/Components/components/popover.json +251 -0
- package/data/pages/Components/components/position.json +69 -0
- package/data/pages/Components/components/radialbarcharts.json +1304 -0
- package/data/pages/Components/components/radiobutton.json +1105 -0
- package/data/pages/Components/components/releasenotes.json +44 -0
- package/data/pages/Components/components/resizer.json +93 -0
- package/data/pages/Components/components/responsivecolumnstripe.json +123 -0
- package/data/pages/Components/components/responsivevideo.json +75 -0
- package/data/pages/Components/components/rioglyph.json +93 -0
- package/data/pages/Components/components/rules.json +410 -0
- package/data/pages/Components/components/saveableinput.json +703 -0
- package/data/pages/Components/components/selects.json +701 -0
- package/data/pages/Components/components/sidebar.json +243 -0
- package/data/pages/Components/components/sliders.json +235 -0
- package/data/pages/Components/components/smoothscrollbars.json +335 -0
- package/data/pages/Components/components/spinners.json +343 -0
- package/data/pages/Components/components/states.json +1705 -0
- package/data/pages/Components/components/statswidgets.json +314 -0
- package/data/pages/Components/components/statusbar.json +177 -0
- package/data/pages/Components/components/stepbutton.json +57 -0
- package/data/pages/Components/components/steppedprogressbars.json +417 -0
- package/data/pages/Components/components/subnavigation.json +107 -0
- package/data/pages/Components/components/supportmarker.json +45 -0
- package/data/pages/Components/components/svgimage.json +81 -0
- package/data/pages/Components/components/switch.json +111 -0
- package/data/pages/Components/components/tables.json +144 -0
- package/data/pages/Components/components/tagmanager.json +86 -0
- package/data/pages/Components/components/tags.json +146 -0
- package/data/pages/Components/components/teaser.json +188 -0
- package/data/pages/Components/components/timeline.json +45 -0
- package/data/pages/Components/components/timepicker.json +163 -0
- package/data/pages/Components/components/togglebutton.json +247 -0
- package/data/pages/Components/components/tooltip.json +270 -0
- package/data/pages/Components/components/virtuallist.json +175 -0
- package/data/pages/Foundations/foundations.json +2475 -0
- package/data/pages/Getting-started/start/changelog.json +22 -0
- package/data/pages/Getting-started/start/goodtoknow.json +32 -0
- package/data/pages/Getting-started/start/guidelines/color-combinations.json +58 -0
- package/data/pages/Getting-started/start/guidelines/custom-css.json +27 -0
- package/data/pages/Getting-started/start/guidelines/custom-rioglyph.json +22 -0
- package/data/pages/Getting-started/start/guidelines/formatting.json +97 -0
- package/data/pages/Getting-started/start/guidelines/iframe.json +93 -0
- package/data/pages/Getting-started/start/guidelines/obfuscate-data.json +22 -0
- package/data/pages/Getting-started/start/guidelines/print-css.json +37 -0
- package/data/pages/Getting-started/start/guidelines/spinner.json +144 -0
- package/data/pages/Getting-started/start/guidelines/supported-browsers.json +22 -0
- package/data/pages/Getting-started/start/guidelines/writing.json +242 -0
- package/data/pages/Getting-started/start/howto.json +72 -0
- package/data/pages/Getting-started/start/intro.json +37 -0
- package/data/pages/Getting-started/start/responsiveness.json +52 -0
- package/data/pages/Templates/templates/common-table.json +39 -0
- package/data/pages/Templates/templates/detail-views.json +71 -0
- package/data/pages/Templates/templates/expandable-details.json +39 -0
- package/data/pages/Templates/templates/feature-cards.json +103 -0
- package/data/pages/Templates/templates/form-summary.json +39 -0
- package/data/pages/Templates/templates/form-toggle.json +39 -0
- package/data/pages/Templates/templates/list-blocks.json +119 -0
- package/data/pages/Templates/templates/loading-progress.json +39 -0
- package/data/pages/Templates/templates/options-panel.json +39 -0
- package/data/pages/Templates/templates/panel-variants.json +39 -0
- package/data/pages/Templates/templates/progress-cards.json +71 -0
- package/data/pages/Templates/templates/progress-success.json +39 -0
- package/data/pages/Templates/templates/settings-form.json +39 -0
- package/data/pages/Templates/templates/stats-blocks.json +135 -0
- package/data/pages/Templates/templates/table-panel.json +39 -0
- package/data/pages/Templates/templates/table-row-animation.json +39 -0
- package/data/pages/Templates/templates/usage-cards.json +39 -0
- package/data/pages/Utilities/utilities/deviceutils.json +39 -0
- package/data/pages/Utilities/utilities/featuretoggles.json +42 -0
- package/data/pages/Utilities/utilities/fueltypeutils.json +118 -0
- package/data/pages/Utilities/utilities/routeutils.json +34 -0
- package/data/pages/Utilities/utilities/useaftermount.json +63 -0
- package/data/pages/Utilities/utilities/useaverage.json +86 -0
- package/data/pages/Utilities/utilities/useclickoutside.json +69 -0
- package/data/pages/Utilities/utilities/useclipboard.json +57 -0
- package/data/pages/Utilities/utilities/usecount.json +92 -0
- package/data/pages/Utilities/utilities/usedarkmode.json +50 -0
- package/data/pages/Utilities/utilities/usedebuginfo.json +63 -0
- package/data/pages/Utilities/utilities/useeffectonce.json +57 -0
- package/data/pages/Utilities/utilities/useelapsedtime.json +57 -0
- package/data/pages/Utilities/utilities/useelementsize.json +63 -0
- package/data/pages/Utilities/utilities/useesc.json +57 -0
- package/data/pages/Utilities/utilities/useevent.json +75 -0
- package/data/pages/Utilities/utilities/usefocustrap.json +57 -0
- package/data/pages/Utilities/utilities/usefullscreen.json +197 -0
- package/data/pages/Utilities/utilities/usehover.json +57 -0
- package/data/pages/Utilities/utilities/useinterval.json +63 -0
- package/data/pages/Utilities/utilities/useisfocuswithin.json +75 -0
- package/data/pages/Utilities/utilities/usekey.json +75 -0
- package/data/pages/Utilities/utilities/uselocalstorage.json +69 -0
- package/data/pages/Utilities/utilities/uselocationsuggestions.json +110 -0
- package/data/pages/Utilities/utilities/usemax.json +86 -0
- package/data/pages/Utilities/utilities/usemin.json +86 -0
- package/data/pages/Utilities/utilities/usemutationobserver.json +69 -0
- package/data/pages/Utilities/utilities/useonlinestatus.json +39 -0
- package/data/pages/Utilities/utilities/useonscreen.json +63 -0
- package/data/pages/Utilities/utilities/usepostmessage.json +80 -0
- package/data/pages/Utilities/utilities/useprevious.json +63 -0
- package/data/pages/Utilities/utilities/useresizeobserver.json +65 -0
- package/data/pages/Utilities/utilities/usescrollposition.json +103 -0
- package/data/pages/Utilities/utilities/usesearch.json +197 -0
- package/data/pages/Utilities/utilities/usesorting.json +139 -0
- package/data/pages/Utilities/utilities/usestatewithvalidation.json +69 -0
- package/data/pages/Utilities/utilities/usesum.json +86 -0
- package/data/pages/Utilities/utilities/usetableexport.json +87 -0
- package/data/pages/Utilities/utilities/usetableselection.json +311 -0
- package/data/pages/Utilities/utilities/usetimeout.json +63 -0
- package/data/pages/Utilities/utilities/usetoggle.json +75 -0
- package/data/pages/Utilities/utilities/usewindowresize.json +63 -0
- package/data/version.json +4 -0
- package/docs/content-schema.md +147 -0
- package/docs/navigation-inventory.json +1310 -0
- package/docs/search-synonyms.json +43 -0
- package/package.json +38 -0
- package/server/index.mjs +268 -0
- package/server/lib/load-docs.mjs +48 -0
- package/server/lib/normalise-doc.mjs +220 -0
- package/server/lib/render-markdown.mjs +82 -0
- package/server/lib/search-index.mjs +49 -0
- package/server/lib/types.js +99 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
{
|
|
2
|
+
"metadata": {
|
|
3
|
+
"captured_at": "2025-11-21T12:08:48.955Z",
|
|
4
|
+
"source": "https://uikit.developers.rio.cloud/#utilities/useSorting",
|
|
5
|
+
"category": "Utilities",
|
|
6
|
+
"section": "Table & data hooks",
|
|
7
|
+
"slug": "utilities/usesorting",
|
|
8
|
+
"version": "v1.13.2",
|
|
9
|
+
"hash_algorithm": "sha256",
|
|
10
|
+
"hash": "ea7009a45e751b3f14290f1360cb5ec0da7536efff17f26f6fc0b40bd56e912b"
|
|
11
|
+
},
|
|
12
|
+
"title": "useSorting",
|
|
13
|
+
"lead": "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.",
|
|
14
|
+
"content": [
|
|
15
|
+
{
|
|
16
|
+
"heading": "useSorting",
|
|
17
|
+
"body": "",
|
|
18
|
+
"examples": [
|
|
19
|
+
{
|
|
20
|
+
"caption": "Example 1",
|
|
21
|
+
"rendered_html": "<div class=\"playground-content bg-white padding-20 padding-bottom-25\" style=\"width: 100%;\"><div class=\"table-responsive\"><table class=\"table table-head-filled\"><thead><tr><th class=\"user-select-none sort-column\"><span><span class=\"sort-arrows sort-asc\"></span><span>Name</span></span></th><th class=\"user-select-none sort-column\"><span><span class=\"sort-arrows \"></span><span>Quantity</span></span></th></tr></thead><tbody><tr><td>Box</td><td>20</td></tr><tr><td>Container</td><td>1</td></tr><tr><td>Crate</td><td>15</td></tr><tr><td>Drum</td><td>12</td></tr><tr><td>Pallet</td><td>10</td></tr><tr><td>Parcel</td><td>8</td></tr></tbody></table></div></div>",
|
|
22
|
+
"tabs": [
|
|
23
|
+
{
|
|
24
|
+
"label": "React",
|
|
25
|
+
"language": "tsx",
|
|
26
|
+
"code": "import SortArrows from '@rio-cloud/rio-uikit/SortArrows';\nimport useSorting from '@rio-cloud/rio-uikit/useSorting';\n\ntype Item = {\n name: string;\n quantity: number;\n};\n\nconst items: Item[] = [\n { name: 'Pallet', quantity: 10 },\n { name: 'Container', quantity: 1 },\n { name: 'Crate', quantity: 15 },\n { name: 'Parcel', quantity: 8 },\n { name: 'Drum', quantity: 12 },\n { name: 'Box', quantity: 20 },\n];\n\nexport default () => {\n const { sortedItems, sortKey, sortDirection, setSortKey, toggleDirection } = useSorting(items, 'name');\n\n const handleSortByColumn = (column: keyof Item) => {\n setSortKey(column);\n if (column === sortKey) {\n toggleDirection();\n }\n };\n\n return (\n <div className='table-responsive'>\n <table className='table table-head-filled'>\n <thead>\n <tr>\n <th className='user-select-none sort-column' onClick={() => handleSortByColumn('name')}>\n <span>\n {sortKey === 'name' ? <SortArrows direction={sortDirection} /> : <SortArrows />}\n <span>Name</span>\n </span>\n </th>\n <th className='user-select-none sort-column' onClick={() => handleSortByColumn('quantity')}>\n <span>\n {sortKey === 'quantity' ? <SortArrows direction={sortDirection} /> : <SortArrows />}\n <span>Quantity</span>\n </span>\n </th>\n </tr>\n </thead>\n <tbody>\n {sortedItems.map(({ name, quantity }) => (\n <tr key={name}>\n <td key={name}>{name}</td>\n <td key={quantity}>{quantity}</td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n};"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"label": "HTML",
|
|
30
|
+
"language": "html",
|
|
31
|
+
"code": "<div class=\"table-responsive\">\n <table class=\"table table-head-filled\">\n <thead>\n <tr>\n <th class=\"user-select-none sort-column\">\n <span>\n <span class=\"sort-arrows sort-asc\">\n </span>\n <span>Name</span>\n </span>\n </th>\n <th class=\"user-select-none sort-column\">\n <span>\n <span class=\"sort-arrows \">\n </span>\n <span>Quantity</span>\n </span>\n </th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>Box</td>\n <td>20</td>\n </tr>\n <tr>\n <td>Container</td>\n <td>1</td>\n </tr>\n <tr>\n <td>Crate</td>\n <td>15</td>\n </tr>\n <tr>\n <td>Drum</td>\n <td>12</td>\n </tr>\n <tr>\n <td>Pallet</td>\n <td>10</td>\n </tr>\n <tr>\n <td>Parcel</td>\n <td>8</td>\n </tr>\n </tbody>\n </table>\n</div>"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"label": "Props",
|
|
35
|
+
"language": "json",
|
|
36
|
+
"code": null,
|
|
37
|
+
"props": [
|
|
38
|
+
{
|
|
39
|
+
"heading": null,
|
|
40
|
+
"rows": [
|
|
41
|
+
{
|
|
42
|
+
"name": "items",
|
|
43
|
+
"type": "T[]",
|
|
44
|
+
"default": "",
|
|
45
|
+
"description": "The array of items to be sorted."
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"name": "initialKey",
|
|
49
|
+
"type": "SortKey<T> = keyof T | [keyof T, keyof T]",
|
|
50
|
+
"default": "",
|
|
51
|
+
"description": "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']"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "initialDirection",
|
|
55
|
+
"type": "SortDirectionType",
|
|
56
|
+
"default": "SortDirection.ASCENDING",
|
|
57
|
+
"description": "The initial sort direction. Can be SortDirection.ASCENDING or SortDirection.DESCENDING."
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "enableNaturalSort",
|
|
61
|
+
"type": "boolean",
|
|
62
|
+
"default": "true",
|
|
63
|
+
"description": "Whether to use natural sort order. Defaults to false."
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "{ sortedItems, sortKey, sortDirection, setSortKey, setSortDirection, toggleDirection }",
|
|
67
|
+
"type": "Object",
|
|
68
|
+
"default": "",
|
|
69
|
+
"description": "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"
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"caption": "Example 2",
|
|
79
|
+
"rendered_html": "<div class=\"playground-content bg-white padding-20 padding-bottom-25\" style=\"width: 100%;\"><p>Sort by a primary column. Hold <kbd class=\"text-normal\">shift</kbd> key to sort by a secondary column</p><div class=\"table-responsive\"><table class=\"table table-head-filled\"><thead><tr><th class=\"user-select-none sort-column\"><span><span class=\"sort-arrows sort-asc\"></span><span>Category</span></span></th><th class=\"user-select-none sort-column\"><span><span class=\"sort-arrows \"></span><span>Name</span></span></th><th class=\"user-select-none sort-column\"><span><span class=\"sort-arrows \"></span><span>Quantity</span></span></th></tr></thead><tbody><tr><td>Shipping</td><td>Parcel</td><td>8</td></tr><tr><td>Shipping</td><td>Box</td><td>20</td></tr><tr><td>Shipping</td><td>Envelope</td><td>50</td></tr><tr><td>Shipping</td><td>Bag</td><td>30</td></tr><tr><td>Storage</td><td>Pallet</td><td>10</td></tr><tr><td>Storage</td><td>Container</td><td>1</td></tr><tr><td>Storage</td><td>Crate</td><td>15</td></tr><tr><td>Storage</td><td>Drum</td><td>12</td></tr></tbody></table></div></div>",
|
|
80
|
+
"tabs": [
|
|
81
|
+
{
|
|
82
|
+
"label": "React",
|
|
83
|
+
"language": "tsx",
|
|
84
|
+
"code": "import SortArrows from '@rio-cloud/rio-uikit/SortArrows';\nimport useSorting from '@rio-cloud/rio-uikit/useSorting';\n\ntype Item = {\n name: string;\n category: string;\n quantity: number;\n};\n\nconst items: Item[] = [\n { name: 'Pallet', category: 'Storage', quantity: 10 },\n { name: 'Container', category: 'Storage', quantity: 1 },\n { name: 'Crate', category: 'Storage', quantity: 15 },\n { name: 'Parcel', category: 'Shipping', quantity: 8 },\n { name: 'Drum', category: 'Storage', quantity: 12 },\n { name: 'Box', category: 'Shipping', quantity: 20 },\n { name: 'Envelope', category: 'Shipping', quantity: 50 },\n { name: 'Bag', category: 'Shipping', quantity: 30 },\n];\n\nexport default () => {\n const { sortedItems, sortKey, sortDirection, setSortKey, toggleDirection } = useSorting(items, 'category');\n\n const handleSortByColumn = (column: keyof Item, event: React.MouseEvent) => {\n if (event.shiftKey) {\n // Secondary sort\n if (Array.isArray(sortKey) && sortKey[1] === column) {\n // If already secondary, toggle direction\n toggleDirection();\n } else if (Array.isArray(sortKey)) {\n // If already using secondary sort, update secondary key\n setSortKey([sortKey[0], column]);\n } else {\n // If not using secondary sort, add secondary key\n setSortKey([sortKey, column]);\n }\n } else {\n // Primary sort\n if (sortKey === column || (Array.isArray(sortKey) && sortKey[0] === column)) {\n // If already primary, toggle direction\n toggleDirection();\n } else {\n // Set new primary key\n setSortKey(column);\n }\n }\n };\n\n const renderSortArrows = (column: keyof Item) => {\n if (sortKey === column || (Array.isArray(sortKey) && sortKey[0] === column)) {\n return <SortArrows direction={sortDirection} />;\n }\n if (Array.isArray(sortKey) && sortKey[1] === column) {\n return <SortArrows direction={sortDirection} />;\n }\n return <SortArrows />;\n };\n\n return (\n <>\n <p>\n Sort by a primary column. Hold <kbd className='text-normal'>shift</kbd> key to sort by a secondary\n column\n </p>\n <div className='table-responsive'>\n <table className='table table-head-filled'>\n <thead>\n <tr>\n <th\n className='user-select-none sort-column'\n onClick={event => handleSortByColumn('category', event)}\n >\n <span>\n {renderSortArrows('category')}\n <span>Category</span>\n </span>\n </th>\n <th\n className='user-select-none sort-column'\n onClick={event => handleSortByColumn('name', event)}\n >\n <span>\n {renderSortArrows('name')}\n <span>Name</span>\n </span>\n </th>\n <th\n className='user-select-none sort-column'\n onClick={event => handleSortByColumn('quantity', event)}\n >\n <span>\n {renderSortArrows('quantity')}\n <span>Quantity</span>\n </span>\n </th>\n </tr>\n </thead>\n <tbody>\n {sortedItems.map(item => (\n <tr key={item.name}>\n <td>{item.category}</td>\n <td>{item.name}</td>\n <td>{item.quantity}</td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n </>\n );\n};"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"label": "HTML",
|
|
88
|
+
"language": "html",
|
|
89
|
+
"code": "<p>Sort by a primary column. Hold <kbd class=\"text-normal\">shift</kbd> key to sort by a secondary column</p>\n<div class=\"table-responsive\">\n <table class=\"table table-head-filled\">\n <thead>\n <tr>\n <th class=\"user-select-none sort-column\">\n <span>\n <span class=\"sort-arrows sort-asc\">\n </span>\n <span>Category</span>\n </span>\n </th>\n <th class=\"user-select-none sort-column\">\n <span>\n <span class=\"sort-arrows \">\n </span>\n <span>Name</span>\n </span>\n </th>\n <th class=\"user-select-none sort-column\">\n <span>\n <span class=\"sort-arrows \">\n </span>\n <span>Quantity</span>\n </span>\n </th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>Shipping</td>\n <td>Parcel</td>\n <td>8</td>\n </tr>\n <tr>\n <td>Shipping</td>\n <td>Box</td>\n <td>20</td>\n </tr>\n <tr>\n <td>Shipping</td>\n <td>Envelope</td>\n <td>50</td>\n </tr>\n <tr>\n <td>Shipping</td>\n <td>Bag</td>\n <td>30</td>\n </tr>\n <tr>\n <td>Storage</td>\n <td>Pallet</td>\n <td>10</td>\n </tr>\n <tr>\n <td>Storage</td>\n <td>Container</td>\n <td>1</td>\n </tr>\n <tr>\n <td>Storage</td>\n <td>Crate</td>\n <td>15</td>\n </tr>\n <tr>\n <td>Storage</td>\n <td>Drum</td>\n <td>12</td>\n </tr>\n </tbody>\n </table>\n</div>"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"label": "Props",
|
|
93
|
+
"language": "json",
|
|
94
|
+
"code": null,
|
|
95
|
+
"props": [
|
|
96
|
+
{
|
|
97
|
+
"heading": null,
|
|
98
|
+
"rows": [
|
|
99
|
+
{
|
|
100
|
+
"name": "items",
|
|
101
|
+
"type": "T[]",
|
|
102
|
+
"default": "",
|
|
103
|
+
"description": "The array of items to be sorted."
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"name": "initialKey",
|
|
107
|
+
"type": "SortKey<T> = keyof T | [keyof T, keyof T]",
|
|
108
|
+
"default": "",
|
|
109
|
+
"description": "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']"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"name": "initialDirection",
|
|
113
|
+
"type": "SortDirectionType",
|
|
114
|
+
"default": "SortDirection.ASCENDING",
|
|
115
|
+
"description": "The initial sort direction. Can be SortDirection.ASCENDING or SortDirection.DESCENDING."
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"name": "enableNaturalSort",
|
|
119
|
+
"type": "boolean",
|
|
120
|
+
"default": "true",
|
|
121
|
+
"description": "Whether to use natural sort order. Defaults to false."
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"name": "{ sortedItems, sortKey, sortDirection, setSortKey, setSortDirection, toggleDirection }",
|
|
125
|
+
"type": "Object",
|
|
126
|
+
"default": "",
|
|
127
|
+
"description": "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"
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
"see_also": []
|
|
139
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"metadata": {
|
|
3
|
+
"captured_at": "2025-11-21T12:08:46.703Z",
|
|
4
|
+
"source": "https://uikit.developers.rio.cloud/#utilities/useStateWithValidation",
|
|
5
|
+
"category": "Utilities",
|
|
6
|
+
"section": "UI state & input hooks",
|
|
7
|
+
"slug": "utilities/usestatewithvalidation",
|
|
8
|
+
"version": "v1.13.2",
|
|
9
|
+
"hash_algorithm": "sha256",
|
|
10
|
+
"hash": "77e612c9f88d56aa90c328f41234b4f5544ae865f7b4322aee5b67788acc7e9b"
|
|
11
|
+
},
|
|
12
|
+
"title": "useStateWithValidation",
|
|
13
|
+
"lead": "The useStateWithValidation hook allows to easily validate state. This comes in handy when validating form inputs.",
|
|
14
|
+
"content": [
|
|
15
|
+
{
|
|
16
|
+
"heading": "useStateWithValidation",
|
|
17
|
+
"body": "",
|
|
18
|
+
"examples": [
|
|
19
|
+
{
|
|
20
|
+
"caption": "Example 1",
|
|
21
|
+
"rendered_html": "<div class=\"playground-content bg-white padding-20 padding-bottom-25\" style=\"width: 100%;\"><div class=\"display-flex flex-column max-width-400\"><div class=\"form-group \"><label for=\"inputUsername\">Username</label><div class=\"form-control-feedback-wrapper\"><input id=\"inputUsername\" type=\"text\" class=\"form-control\" placeholder=\"Please enter your username\" value=\"\"></div></div></div></div>",
|
|
22
|
+
"tabs": [
|
|
23
|
+
{
|
|
24
|
+
"label": "React",
|
|
25
|
+
"language": "tsx",
|
|
26
|
+
"code": "import useStateWithValidation from '@rio-cloud/rio-uikit/useStateWithValidation';\n\nexport default () => {\n const validationFn = (name: string) => name.length > 5;\n\n const [username, setUsername, isValid] = useStateWithValidation<string>(validationFn, '');\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n setUsername(event.target.value);\n };\n\n const showError = username.length > 0 && !isValid;\n\n return (\n <div className='display-flex flex-column max-width-400'>\n <div className={`form-group ${showError ? 'has-error has-feedback' : ''}`}>\n <label htmlFor='inputUsername'>Username</label>\n <div className='form-control-feedback-wrapper'>\n <input\n id='inputUsername'\n type='text'\n className='form-control'\n placeholder='Please enter your username'\n value={username}\n onChange={handleInputChange}\n />\n {showError && (\n <>\n <span className='form-control-feedback rioglyph rioglyph-error-sign' />\n <span className='help-block'>\n <span>Username is to short. Please enter at least 5 characters.</span>\n </span>\n </>\n )}\n </div>\n </div>\n </div>\n );\n};"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"label": "HTML",
|
|
30
|
+
"language": "html",
|
|
31
|
+
"code": "<div class=\"display-flex flex-column max-width-400\">\n <div class=\"form-group \">\n <label for=\"inputUsername\">Username</label>\n <div class=\"form-control-feedback-wrapper\">\n <input id=\"inputUsername\" type=\"text\" class=\"form-control\" placeholder=\"Please enter your username\" value=\"\">\n </div>\n </div>\n</div>"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"label": "Props",
|
|
35
|
+
"language": "json",
|
|
36
|
+
"code": null,
|
|
37
|
+
"props": [
|
|
38
|
+
{
|
|
39
|
+
"heading": null,
|
|
40
|
+
"rows": [
|
|
41
|
+
{
|
|
42
|
+
"name": "validationFn",
|
|
43
|
+
"type": "Function",
|
|
44
|
+
"default": "",
|
|
45
|
+
"description": "The validation function that gets invoked when the passed state changes."
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"name": "initialValue",
|
|
49
|
+
"type": "Any",
|
|
50
|
+
"default": "",
|
|
51
|
+
"description": "The initial state value."
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "[state, onChange, isValid]",
|
|
55
|
+
"type": "Array",
|
|
56
|
+
"default": "",
|
|
57
|
+
"description": "Returns the actual \"state\", the \"onChange\" function that will be invoked when the state changes, and the \"isValid\" flag."
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"see_also": []
|
|
69
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"metadata": {
|
|
3
|
+
"captured_at": "2025-11-21T12:08:47.989Z",
|
|
4
|
+
"source": "https://uikit.developers.rio.cloud/#utilities/useSum",
|
|
5
|
+
"category": "Utilities",
|
|
6
|
+
"section": "Data aggregation hooks",
|
|
7
|
+
"slug": "utilities/usesum",
|
|
8
|
+
"version": "v1.13.2",
|
|
9
|
+
"hash_algorithm": "sha256",
|
|
10
|
+
"hash": "3e33967495c84f3cb1348ac254d23b0aba0e2edfe8d2f40e1b08e54392fa2c84"
|
|
11
|
+
},
|
|
12
|
+
"title": "useSum",
|
|
13
|
+
"lead": "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.",
|
|
14
|
+
"content": [
|
|
15
|
+
{
|
|
16
|
+
"heading": "useSum",
|
|
17
|
+
"body": "It supports locale-aware number parsing (e.g. 1.234,50 € or 2 500,75 kg)",
|
|
18
|
+
"examples": [
|
|
19
|
+
{
|
|
20
|
+
"caption": "Example 1",
|
|
21
|
+
"rendered_html": "<div class=\"playground-content bg-white padding-20 padding-bottom-25\" style=\"width: 100%;\"><ul><li>3.930,75 km</li><li>5.197 €</li><li>1860min</li><li>31h</li><li>185 km</li></ul></div>",
|
|
22
|
+
"tabs": [
|
|
23
|
+
{
|
|
24
|
+
"label": "React",
|
|
25
|
+
"language": "tsx",
|
|
26
|
+
"code": "import { FormattedNumber, IntlProvider } from 'react-intl';\n\nimport useSum from '@rio-cloud/rio-uikit/useSum';\n\nexport default () => {\n const weightSum = useSum(deliveries, 'shipment.weight', { locale: 'de-DE' });\n const valueSum = useSum(deliveries, 'shipment.value', { locale: 'de-DE' });\n\n const durationSum = useSum(deliveries, 'shipment.duration');\n\n const mileage = useSum(deliveries, 'vehicle.mileage');\n\n return (\n <IntlProvider locale='de-DE'>\n <ul>\n <li>\n <FormattedNumber\n value={weightSum}\n minimumFractionDigits={0}\n maximumFractionDigits={2}\n style='unit'\n unit='kilometer'\n />\n </li>\n <li>\n <FormattedNumber\n value={valueSum}\n style='currency'\n currency='EUR'\n minimumFractionDigits={0}\n maximumFractionDigits={0}\n />\n </li>\n <li>{durationSum}min</li>\n <li>\n <FormattedNumber value={durationSum / 60} maximumFractionDigits={1} />h\n </li>\n <li>\n <FormattedNumber value={mileage} maximumFractionDigits={0} style='unit' unit='kilometer' />\n </li>\n </ul>\n </IntlProvider>\n );\n};\n\nconst deliveries = [\n {\n id: 'D-1001',\n vehicle: {\n mileage: 97.5,\n },\n shipment: {\n weight: '1.200,5 kg',\n value: '2.345,50 €',\n duration: 90, // raw minutes\n },\n },\n {\n id: 'D-1002',\n vehicle: {\n mileage: 10,\n },\n shipment: {\n weight: '980,25 kg',\n value: '1,000.75€',\n duration: 150, // raw minutes\n },\n },\n {\n id: 'D-1003',\n vehicle: {\n mileage: 56,\n },\n shipment: {\n weight: '750kg',\n value: 850,\n duration: 1440, // raw minutes\n },\n },\n {\n id: 'D-1004',\n vehicle: {\n mileage: 21,\n },\n shipment: {\n weight: '1.000 kg',\n value: '2.000,00 €',\n duration: 180, // raw minutes\n },\n },\n];"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"label": "HTML",
|
|
30
|
+
"language": "html",
|
|
31
|
+
"code": "<ul>\n <li>3.930,75 km</li>\n <li>5.197 €</li>\n <li>1860min</li>\n <li>31h</li>\n <li>185 km</li>\n</ul>"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"label": "Props",
|
|
35
|
+
"language": "json",
|
|
36
|
+
"code": null,
|
|
37
|
+
"props": [
|
|
38
|
+
{
|
|
39
|
+
"heading": "Options for the `useSum` hook",
|
|
40
|
+
"rows": [
|
|
41
|
+
{
|
|
42
|
+
"name": "items",
|
|
43
|
+
"type": "unknown[]",
|
|
44
|
+
"default": "",
|
|
45
|
+
"description": "The array of objects to aggregate values from."
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"name": "path",
|
|
49
|
+
"type": "string",
|
|
50
|
+
"default": "",
|
|
51
|
+
"description": "Dot-separated path to the numeric value in each object."
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "options",
|
|
55
|
+
"type": "object",
|
|
56
|
+
"default": "",
|
|
57
|
+
"description": "Optional configuration for parsing behavior."
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "└locale",
|
|
61
|
+
"type": "string",
|
|
62
|
+
"default": "\"en-GB\"",
|
|
63
|
+
"description": "Locale string used to parse localized number formats. Affects how grouping and decimal separators are interpreted."
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"heading": "Return value of the `useSum` hook",
|
|
69
|
+
"rows": [
|
|
70
|
+
{
|
|
71
|
+
"name": "sum",
|
|
72
|
+
"type": "number",
|
|
73
|
+
"default": "",
|
|
74
|
+
"description": "The total sum of all parsed values from the provided path in the given item list."
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
"see_also": []
|
|
86
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"metadata": {
|
|
3
|
+
"captured_at": "2025-11-21T12:08:48.453Z",
|
|
4
|
+
"source": "https://uikit.developers.rio.cloud/#utilities/useTableExport",
|
|
5
|
+
"category": "Utilities",
|
|
6
|
+
"section": "Table & data hooks",
|
|
7
|
+
"slug": "utilities/usetableexport",
|
|
8
|
+
"version": "v1.13.2",
|
|
9
|
+
"hash_algorithm": "sha256",
|
|
10
|
+
"hash": "06bc73eccf7c068c3d801e0cd591181440cea0187f99cf7e009173016573a69c"
|
|
11
|
+
},
|
|
12
|
+
"title": "useTableExport",
|
|
13
|
+
"lead": "The useTableExport hook provides a simple and reusable way to export tabular data as a downloadable CSV file in React applications. It supports custom delimiters, UTF-8 BOM for Excel compatibility, and column header mapping for more readable exports. This is especially useful for tables with user-facing data that may need to be downloaded for offline analysis or reporting.",
|
|
14
|
+
"content": [
|
|
15
|
+
{
|
|
16
|
+
"heading": "useTableExport",
|
|
17
|
+
"body": "",
|
|
18
|
+
"examples": [
|
|
19
|
+
{
|
|
20
|
+
"caption": "Example 1",
|
|
21
|
+
"rendered_html": "<div class=\"playground-content bg-lighter padding-20 padding-bottom-25\" style=\"width: 100%;\"><div><div class=\"table-toolbar\"><div class=\"table-toolbar-container\"><div class=\"table-toolbar-group-right\"><div class=\"table-toolbar-column\"><button type=\"button\" class=\"btn btn-default btn-component\" tabindex=\"0\"><span class=\"rioglyph rioglyph-download\"></span>Export data</button></div></div></div></div><div class=\"table-responsive\"><table class=\"table table-layout-fixed table-column-overflow-hidden table-bordered table-sticky table-hover table-head-filled\"><colgroup><col class=\"\" style=\"min-width: 100px; width: 100px;\"><col class=\"\" style=\"min-width: 200px; width: 200px;\"><col class=\"\"><col class=\"\"></colgroup><thead><tr><th class=\"user-select-none sort-column\" data-field=\"driverId\" data-sortby=\"driverId\" title=\"Id\"><span><span class=\"sort-arrows sort-asc\"></span><span>Id</span></span></th><th class=\"user-select-none sort-column\" data-field=\"firstName\" data-sortby=\"firstName\" title=\"First name\"><span><span class=\"sort-arrows \"></span><span>First name</span></span></th><th class=\"user-select-none sort-column\" data-field=\"lastName\" data-sortby=\"lastName\" title=\"Last name\"><span><span class=\"sort-arrows \"></span><span>Last name</span></span></th><th class=\"user-select-none sort-column\" data-field=\"email\" data-sortby=\"email\" title=\"E-mail\"><span><span class=\"sort-arrows \"></span><span>E-mail</span></span></th></tr></thead><tbody><tr data-id=\"1\" class=\"cursor-pointer\"><td data-field=\"Id\"><span>1</span></td><td data-field=\"First name\"><span>Christa</span></td><td data-field=\"Last name\"><span>O'Connell</span></td><td data-field=\"E-mail\"><span>Elizabeth_McCullough@hotmail.com</span></td></tr><tr data-id=\"2\" class=\"cursor-pointer\"><td data-field=\"Id\"><span>2</span></td><td data-field=\"First name\"><span>Sandrine</span></td><td data-field=\"Last name\"><span>Cartwright</span></td><td data-field=\"E-mail\"><span>Clint55@gmail.com</span></td></tr><tr data-id=\"3\" class=\"cursor-pointer\"><td data-field=\"Id\"><span>3</span></td><td data-field=\"First name\"><span>Jennie</span></td><td data-field=\"Last name\"><span>Lubowitz</span></td><td data-field=\"E-mail\"><span>Arnold.Gusikowski68@gmail.com</span></td></tr><tr data-id=\"4\" class=\"cursor-pointer\"><td data-field=\"Id\"><span>4</span></td><td data-field=\"First name\"><span>Roman</span></td><td data-field=\"Last name\"><span>Davis</span></td><td data-field=\"E-mail\"><span>Rosetta_Johns@hotmail.com</span></td></tr><tr data-id=\"5\" class=\"cursor-pointer\"><td data-field=\"Id\"><span>5</span></td><td data-field=\"First name\"><span>Oren</span></td><td data-field=\"Last name\"><span>Jacobi</span></td><td data-field=\"E-mail\"><span>Sabryna.Lebsack69@gmail.com</span></td></tr><tr data-id=\"6\" class=\"cursor-pointer\"><td data-field=\"Id\"><span>6</span></td><td data-field=\"First name\"><span>Jedediah</span></td><td data-field=\"Last name\"><span>Russel</span></td><td data-field=\"E-mail\"><span>Kennedi_Kerluke@hotmail.com</span></td></tr><tr data-id=\"7\" class=\"cursor-pointer\"><td data-field=\"Id\"><span>7</span></td><td data-field=\"First name\"><span>Brianne</span></td><td data-field=\"Last name\"><span>Heller</span></td><td data-field=\"E-mail\"><span>Jarvis76@yahoo.com</span></td></tr><tr data-id=\"8\" class=\"cursor-pointer\"><td data-field=\"Id\"><span>8</span></td><td data-field=\"First name\"><span>Rosario</span></td><td data-field=\"Last name\"><span>Gleichner</span></td><td data-field=\"E-mail\"><span>Larry.Durgan50@hotmail.com</span></td></tr><tr data-id=\"9\" class=\"cursor-pointer\"><td data-field=\"Id\"><span>9</span></td><td data-field=\"First name\"><span>Crystal</span></td><td data-field=\"Last name\"><span>Carter</span></td><td data-field=\"E-mail\"><span>Elsie63@yahoo.com</span></td></tr><tr data-id=\"10\" class=\"cursor-pointer\"><td data-field=\"Id\"><span>10</span></td><td data-field=\"First name\"><span>Beatrice</span></td><td data-field=\"Last name\"><span>Bashirian</span></td><td data-field=\"E-mail\"><span>Johnpaul71@yahoo.com</span></td></tr></tbody></table></div></div></div>",
|
|
22
|
+
"tabs": [
|
|
23
|
+
{
|
|
24
|
+
"label": "React",
|
|
25
|
+
"language": "tsx",
|
|
26
|
+
"code": "import classNames from 'classnames';\nimport faker from 'faker';\n\nimport TableHead from '@rio-cloud/rio-uikit/TableHead';\nimport TableCol, { type ColumnDetailsMap } from '@rio-cloud/rio-uikit/TableCol';\nimport TableToolbar from '@rio-cloud/rio-uikit/TableToolbar';\nimport useTableExport from '@rio-cloud/rio-uikit/useTableExport';\nimport useSorting from '@rio-cloud/rio-uikit/useSorting';\nimport Button from '@rio-cloud/rio-uikit/Button';\n\ntype Driver = {\n driverId: string;\n firstName: string;\n lastName: string;\n email: string;\n};\n\ntype ColumnLabel = { [key in keyof Driver]: string };\n\nconst columnLabels: ColumnLabel = {\n driverId: 'Id',\n firstName: 'First name',\n lastName: 'Last name',\n email: 'E-mail',\n};\n\nconst defaultColumnOrder = ['driverId', 'firstName', 'lastName', 'email'];\n\nconst demoColumnsDetails: ColumnDetailsMap = {\n driverId: {\n width: 100,\n defaultWidth: 200,\n maxWidth: 300,\n },\n firstName: {\n width: 200,\n defaultWidth: 200,\n maxWidth: 200,\n },\n lastName: {\n width: 0, // Note: 0 means auto width\n defaultWidth: 0,\n maxWidth: 350,\n },\n};\n\n// Function to generate random entries to work with.\n// Increase length to generate more items.\nconst driverList: Driver[] = Array.from({ length: 10 }, (_, index) => ({\n driverId: `${index + 1}`,\n firstName: faker.name.firstName(),\n lastName: faker.name.lastName(),\n email: faker.internet.email(),\n}));\n\nexport default () => {\n const { sortedItems, sortKey, sortDirection, setSortKey, toggleDirection } = useSorting(driverList, 'driverId');\n\n // Hook to export the Table data\n const { exportToCSV } = useTableExport<Driver>();\n\n const handleTableExport = () => {\n exportToCSV({\n data: sortedItems,\n fileName: 'drivers.csv',\n headers: columnLabels,\n });\n };\n\n const handleSortChange = (event: React.MouseEvent<HTMLTableCellElement>) => {\n const newSortBy = event.currentTarget.getAttribute('data-sortby');\n if (newSortBy) {\n setSortKey(newSortBy as keyof Driver);\n }\n if (newSortBy === sortKey) {\n toggleDirection();\n }\n };\n\n const tableClassNames = classNames(\n 'table',\n 'table-layout-fixed',\n 'table-column-overflow-hidden',\n 'table-bordered',\n 'table-sticky',\n 'table-hover',\n 'table-head-filled'\n );\n\n return (\n <div>\n <TableToolbar>\n <div className='table-toolbar-container'>\n <div className='table-toolbar-group-right'>\n <div className='table-toolbar-column'>\n <Button iconName='rioglyph-download' onClick={handleTableExport}>\n Export data\n </Button>\n </div>\n </div>\n </div>\n </TableToolbar>\n\n <div className='table-responsive'>\n <table className={tableClassNames}>\n <colgroup>\n {defaultColumnOrder.map(column => (\n <TableCol key={column} columnDetails={demoColumnsDetails[column]} />\n ))}\n </colgroup>\n <thead>\n <tr>\n {defaultColumnOrder.map(column => (\n <TableHead\n key={column}\n column={column}\n label={columnLabels[column as keyof ColumnLabel]}\n sortBy={sortKey as string}\n sortDir={sortDirection}\n onClick={handleSortChange}\n />\n ))}\n </tr>\n </thead>\n <tbody>\n {sortedItems.map(row => (\n <tr key={row.driverId} data-id={row.driverId} className='cursor-pointer'>\n {defaultColumnOrder.map(col => (\n <td key={col} data-field={columnLabels[col as keyof Driver]}>\n <span>{row[col as keyof Driver]}</span>\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n </div>\n );\n};"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"label": "HTML",
|
|
30
|
+
"language": "html",
|
|
31
|
+
"code": "<div>\n <div class=\"table-toolbar\">\n <div class=\"table-toolbar-container\">\n <div class=\"table-toolbar-group-right\">\n <div class=\"table-toolbar-column\">\n <button type=\"button\" class=\"btn btn-default btn-component\" tabindex=\"0\">\n <span class=\"rioglyph rioglyph-download\">\n </span>Export data</button>\n </div>\n </div>\n </div>\n </div>\n <div class=\"table-responsive\">\n <table class=\"table table-layout-fixed table-column-overflow-hidden table-bordered table-sticky table-hover table-head-filled\">\n <colgroup>\n <col class=\"\" style=\"min-width: 100px; width: 100px;\">\n <col class=\"\" style=\"min-width: 200px; width: 200px;\">\n <col class=\"\">\n <col class=\"\">\n </colgroup>\n <thead>\n <tr>\n <th class=\"user-select-none sort-column\" data-field=\"driverId\" data-sortby=\"driverId\" title=\"Id\">\n <span>\n <span class=\"sort-arrows sort-asc\">\n </span>\n <span>Id</span>\n </span>\n </th>\n <th class=\"user-select-none sort-column\" data-field=\"firstName\" data-sortby=\"firstName\" title=\"First name\">\n <span>\n <span class=\"sort-arrows \">\n </span>\n <span>First name</span>\n </span>\n </th>\n <th class=\"user-select-none sort-column\" data-field=\"lastName\" data-sortby=\"lastName\" title=\"Last name\">\n <span>\n <span class=\"sort-arrows \">\n </span>\n <span>Last name</span>\n </span>\n </th>\n <th class=\"user-select-none sort-column\" data-field=\"email\" data-sortby=\"email\" title=\"E-mail\">\n <span>\n <span class=\"sort-arrows \">\n </span>\n <span>E-mail</span>\n </span>\n </th>\n </tr>\n </thead>\n <tbody>\n <tr data-id=\"1\" class=\"cursor-pointer\">\n <td data-field=\"Id\">\n <span>1</span>\n </td>\n <td data-field=\"First name\">\n <span>Christa</span>\n </td>\n <td data-field=\"Last name\">\n <span>O'Connell</span>\n </td>\n <td data-field=\"E-mail\">\n <span>Elizabeth_McCullough@hotmail.com</span>\n </td>\n </tr>\n <tr data-id=\"2\" class=\"cursor-pointer\">\n <td data-field=\"Id\">\n <span>2</span>\n </td>\n <td data-field=\"First name\">\n <span>Sandrine</span>\n </td>\n <td data-field=\"Last name\">\n <span>Cartwright</span>\n </td>\n <td data-field=\"E-mail\">\n <span>Clint55@gmail.com</span>\n </td>\n </tr>\n <tr data-id=\"3\" class=\"cursor-pointer\">\n <td data-field=\"Id\">\n <span>3</span>\n </td>\n <td data-field=\"First name\">\n <span>Jennie</span>\n </td>\n <td data-field=\"Last name\">\n <span>Lubowitz</span>\n </td>\n <td data-field=\"E-mail\">\n <span>Arnold.Gusikowski68@gmail.com</span>\n </td>\n </tr>\n <tr data-id=\"4\" class=\"cursor-pointer\">\n <td data-field=\"Id\">\n <span>4</span>\n </td>\n <td data-field=\"First name\">\n <span>Roman</span>\n </td>\n <td data-field=\"Last name\">\n <span>Davis</span>\n </td>\n <td data-field=\"E-mail\">\n <span>Rosetta_Johns@hotmail.com</span>\n </td>\n </tr>\n <tr data-id=\"5\" class=\"cursor-pointer\">\n <td data-field=\"Id\">\n <span>5</span>\n </td>\n <td data-field=\"First name\">\n <span>Oren</span>\n </td>\n <td data-field=\"Last name\">\n <span>Jacobi</span>\n </td>\n <td data-field=\"E-mail\">\n <span>Sabryna.Lebsack69@gmail.com</span>\n </td>\n </tr>\n <tr data-id=\"6\" class=\"cursor-pointer\">\n <td data-field=\"Id\">\n <span>6</span>\n </td>\n <td data-field=\"First name\">\n <span>Jedediah</span>\n </td>\n <td data-field=\"Last name\">\n <span>Russel</span>\n </td>\n <td data-field=\"E-mail\">\n <span>Kennedi_Kerluke@hotmail.com</span>\n </td>\n </tr>\n <tr data-id=\"7\" class=\"cursor-pointer\">\n <td data-field=\"Id\">\n <span>7</span>\n </td>\n <td data-field=\"First name\">\n <span>Brianne</span>\n </td>\n <td data-field=\"Last name\">\n <span>Heller</span>\n </td>\n <td data-field=\"E-mail\">\n <span>Jarvis76@yahoo.com</span>\n </td>\n </tr>\n <tr data-id=\"8\" class=\"cursor-pointer\">\n <td data-field=\"Id\">\n <span>8</span>\n </td>\n <td data-field=\"First name\">\n <span>Rosario</span>\n </td>\n <td data-field=\"Last name\">\n <span>Gleichner</span>\n </td>\n <td data-field=\"E-mail\">\n <span>Larry.Durgan50@hotmail.com</span>\n </td>\n </tr>\n <tr data-id=\"9\" class=\"cursor-pointer\">\n <td data-field=\"Id\">\n <span>9</span>\n </td>\n <td data-field=\"First name\">\n <span>Crystal</span>\n </td>\n <td data-field=\"Last name\">\n <span>Carter</span>\n </td>\n <td data-field=\"E-mail\">\n <span>Elsie63@yahoo.com</span>\n </td>\n </tr>\n <tr data-id=\"10\" class=\"cursor-pointer\">\n <td data-field=\"Id\">\n <span>10</span>\n </td>\n <td data-field=\"First name\">\n <span>Beatrice</span>\n </td>\n <td data-field=\"Last name\">\n <span>Bashirian</span>\n </td>\n <td data-field=\"E-mail\">\n <span>Johnpaul71@yahoo.com</span>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n</div>"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"label": "Props",
|
|
35
|
+
"language": "json",
|
|
36
|
+
"code": null,
|
|
37
|
+
"props": [
|
|
38
|
+
{
|
|
39
|
+
"heading": "Options of the returned `exportToCSV` function",
|
|
40
|
+
"rows": [
|
|
41
|
+
{
|
|
42
|
+
"name": "data",
|
|
43
|
+
"type": "T[]",
|
|
44
|
+
"default": "",
|
|
45
|
+
"description": "Array of data objects to export. Each object represents one row in the table."
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"name": "fileName",
|
|
49
|
+
"type": "string",
|
|
50
|
+
"default": "export.csv",
|
|
51
|
+
"description": "Optional name for the exported file."
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "columns",
|
|
55
|
+
"type": "(keyof T)[]",
|
|
56
|
+
"default": "",
|
|
57
|
+
"description": "Optional list of object keys to export as columns. If omitted, all keys from the first row will be used."
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "headers",
|
|
61
|
+
"type": "Partial<Record<keyof T, string>>",
|
|
62
|
+
"default": "",
|
|
63
|
+
"description": "Optional map of column keys to custom header labels. Example: { firstName: 'First Name' }"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "delimiter",
|
|
67
|
+
"type": "string",
|
|
68
|
+
"default": ",",
|
|
69
|
+
"description": "Optional delimiter to use between values in the CSV. You can use `\";\"` or `\"\\t\"` for other formats."
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"name": "withBom",
|
|
73
|
+
"type": "boolean",
|
|
74
|
+
"default": "true",
|
|
75
|
+
"description": "Whether to include UTF-8 BOM (useful for Excel)."
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
"see_also": []
|
|
87
|
+
}
|