@zonsh/ui 0.0.0 → 0.4.1
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 +43 -0
- package/README.md +81 -1
- package/assets/illustrations/drawing/bracket-construction-dark.svg +77 -0
- package/assets/illustrations/drawing/bracket-construction-filled-dark.svg +50 -0
- package/assets/illustrations/drawing/bracket-construction-filled.svg +50 -0
- package/assets/illustrations/drawing/bracket-construction.svg +77 -0
- package/assets/illustrations/drawing/crescent-dark.svg +28 -0
- package/assets/illustrations/drawing/crescent-guides-dark.svg +33 -0
- package/assets/illustrations/drawing/crescent-guides.svg +33 -0
- package/assets/illustrations/drawing/crescent.svg +28 -0
- package/assets/illustrations/drawing/eclipse-dark.svg +187 -0
- package/assets/illustrations/drawing/eclipse-guides-dark.svg +191 -0
- package/assets/illustrations/drawing/eclipse-guides.svg +191 -0
- package/assets/illustrations/drawing/eclipse.svg +187 -0
- package/assets/illustrations/drawing/elevation-guides-dark.svg +31 -0
- package/assets/illustrations/drawing/elevation-guides-plain-dark.svg +9 -0
- package/assets/illustrations/drawing/elevation-guides-plain.svg +9 -0
- package/assets/illustrations/drawing/elevation-guides.svg +31 -0
- package/assets/illustrations/drawing/horizon-dark.svg +30 -0
- package/assets/illustrations/drawing/horizon.svg +30 -0
- package/assets/illustrations/drawing/nib-study-dark.svg +107 -0
- package/assets/illustrations/drawing/nib-study-plain-dark.svg +93 -0
- package/assets/illustrations/drawing/nib-study-plain.svg +93 -0
- package/assets/illustrations/drawing/nib-study.svg +107 -0
- package/assets/illustrations/editorial/assistant-640.webp +0 -0
- package/assets/illustrations/editorial/assistant.webp +0 -0
- package/assets/illustrations/editorial/automation-640.webp +0 -0
- package/assets/illustrations/editorial/automation.webp +0 -0
- package/assets/illustrations/editorial/bracket-left-640.webp +0 -0
- package/assets/illustrations/editorial/bracket-left.webp +0 -0
- package/assets/illustrations/editorial/bracket-right-640.webp +0 -0
- package/assets/illustrations/editorial/bracket-right.webp +0 -0
- package/assets/illustrations/editorial/custom-software-640.webp +0 -0
- package/assets/illustrations/editorial/custom-software.webp +0 -0
- package/assets/illustrations/editorial/digitalization-640.webp +0 -0
- package/assets/illustrations/editorial/digitalization.webp +0 -0
- package/assets/illustrations/editorial/integration-640.webp +0 -0
- package/assets/illustrations/editorial/integration.webp +0 -0
- package/assets/illustrations/editorial/problem-640.webp +0 -0
- package/assets/illustrations/editorial/problem.webp +0 -0
- package/assets/illustrations/editorial/process-analysis-640.webp +0 -0
- package/assets/illustrations/editorial/process-analysis.webp +0 -0
- package/assets/illustrations/editorial/process-concept-640.webp +0 -0
- package/assets/illustrations/editorial/process-concept.webp +0 -0
- package/assets/illustrations/editorial/process-development-640.webp +0 -0
- package/assets/illustrations/editorial/process-development.webp +0 -0
- package/assets/illustrations/editorial/process-discovery-640.webp +0 -0
- package/assets/illustrations/editorial/process-discovery.webp +0 -0
- package/assets/illustrations/editorial/process-maintenance-640.webp +0 -0
- package/assets/illustrations/editorial/process-maintenance.webp +0 -0
- package/assets/illustrations/editorial/process-prototype-640.webp +0 -0
- package/assets/illustrations/editorial/process-prototype.webp +0 -0
- package/assets/illustrations/editorial/process-testing-640.webp +0 -0
- package/assets/illustrations/editorial/process-testing.webp +0 -0
- package/assets/illustrations/iso/automation-dark.svg +6 -0
- package/assets/illustrations/iso/automation.svg +6 -0
- package/assets/illustrations/iso/bar-chart-dark.svg +6 -0
- package/assets/illustrations/iso/bar-chart.svg +6 -0
- package/assets/illustrations/iso/brackets-classic-dark.svg +6 -0
- package/assets/illustrations/iso/brackets-classic.svg +6 -0
- package/assets/illustrations/iso/brackets-dark.svg +6 -0
- package/assets/illustrations/iso/brackets.svg +6 -0
- package/assets/illustrations/iso/city-dark.svg +6 -0
- package/assets/illustrations/iso/city.svg +6 -0
- package/assets/illustrations/iso/conveyor-dark.svg +6 -0
- package/assets/illustrations/iso/conveyor.svg +6 -0
- package/assets/illustrations/iso/database-dark.svg +6 -0
- package/assets/illustrations/iso/database.svg +6 -0
- package/assets/illustrations/iso/documents-dark.svg +6 -0
- package/assets/illustrations/iso/documents.svg +6 -0
- package/assets/illustrations/iso/inbox-dark.svg +6 -0
- package/assets/illustrations/iso/inbox.svg +6 -0
- package/assets/illustrations/iso/laptop-dark.svg +6 -0
- package/assets/illustrations/iso/laptop.svg +6 -0
- package/assets/illustrations/iso/monitor-dark.svg +6 -0
- package/assets/illustrations/iso/monitor.svg +6 -0
- package/assets/illustrations/iso/pipeline-dark.svg +6 -0
- package/assets/illustrations/iso/pipeline.svg +6 -0
- package/assets/illustrations/iso/platform-dark.svg +6 -0
- package/assets/illustrations/iso/platform.svg +6 -0
- package/assets/illustrations/iso/server-dark.svg +6 -0
- package/assets/illustrations/iso/server.svg +6 -0
- package/assets/illustrations/iso/spreadsheet-dark.svg +6 -0
- package/assets/illustrations/iso/spreadsheet.svg +6 -0
- package/assets/illustrations/iso/timeline-dark.svg +6 -0
- package/assets/illustrations/iso/timeline.svg +6 -0
- package/assets/illustrations/sheet/construction.svg +115 -0
- package/assets/illustrations/sheet/crescent.svg +40 -0
- package/assets/illustrations/sheet/limb.svg +42 -0
- package/assets/illustrations/sheet/stress-axis.svg +119 -0
- package/assets/illustrations/sheet/totality.svg +215 -0
- package/assets/illustrations/sheet/vertical-metrics.svg +43 -0
- package/assets/logo-left.svg +1 -0
- package/assets/logo-right.svg +1 -0
- package/assets/logo.svg +1 -0
- package/dist/components/_overlay.d.ts +47 -0
- package/dist/components/_overlay.js +59 -0
- package/dist/components/accordion.d.ts +32 -0
- package/dist/components/accordion.js +39 -0
- package/dist/components/alert-dialog.d.ts +45 -0
- package/dist/components/alert-dialog.js +56 -0
- package/dist/components/alert.d.ts +35 -0
- package/dist/components/alert.js +42 -0
- package/dist/components/ascii-field.d.ts +34 -0
- package/dist/components/ascii-field.js +410 -0
- package/dist/components/aspect-ratio.d.ts +14 -0
- package/dist/components/aspect-ratio.js +17 -0
- package/dist/components/avatar.d.ts +42 -0
- package/dist/components/avatar.js +55 -0
- package/dist/components/badge.d.ts +70 -0
- package/dist/components/badge.js +62 -0
- package/dist/components/bottom-nav.d.ts +86 -0
- package/dist/components/bottom-nav.js +175 -0
- package/dist/components/breadcrumb.d.ts +31 -0
- package/dist/components/breadcrumb.js +37 -0
- package/dist/components/button-group.d.ts +30 -0
- package/dist/components/button-group.js +47 -0
- package/dist/components/button.d.ts +53 -0
- package/dist/components/button.js +130 -0
- package/dist/components/calendar.d.ts +26 -0
- package/dist/components/calendar.js +179 -0
- package/dist/components/card.d.ts +42 -0
- package/dist/components/card.js +76 -0
- package/dist/components/carousel.d.ts +109 -0
- package/dist/components/carousel.js +231 -0
- package/dist/components/chart.d.ts +189 -0
- package/dist/components/chart.js +323 -0
- package/dist/components/checkbox.d.ts +23 -0
- package/dist/components/checkbox.js +43 -0
- package/dist/components/code-block.d.ts +55 -0
- package/dist/components/code-block.js +100 -0
- package/dist/components/collapsible.d.ts +20 -0
- package/dist/components/collapsible.js +32 -0
- package/dist/components/color-picker.d.ts +107 -0
- package/dist/components/color-picker.js +428 -0
- package/dist/components/combobox.d.ts +99 -0
- package/dist/components/combobox.js +172 -0
- package/dist/components/command.d.ts +132 -0
- package/dist/components/command.js +257 -0
- package/dist/components/context-menu.d.ts +29 -0
- package/dist/components/context-menu.js +35 -0
- package/dist/components/conversation.d.ts +36 -0
- package/dist/components/conversation.js +303 -0
- package/dist/components/copy-button.d.ts +55 -0
- package/dist/components/copy-button.js +133 -0
- package/dist/components/data-table.d.ts +235 -0
- package/dist/components/data-table.js +655 -0
- package/dist/components/date-picker.d.ts +160 -0
- package/dist/components/date-picker.js +338 -0
- package/dist/components/dialog.d.ts +57 -0
- package/dist/components/dialog.js +95 -0
- package/dist/components/direction.d.ts +16 -0
- package/dist/components/direction.js +18 -0
- package/dist/components/drawer.d.ts +69 -0
- package/dist/components/drawer.js +79 -0
- package/dist/components/empty.d.ts +31 -0
- package/dist/components/empty.js +50 -0
- package/dist/components/feature-list.d.ts +54 -0
- package/dist/components/feature-list.js +43 -0
- package/dist/components/field.d.ts +34 -0
- package/dist/components/field.js +81 -0
- package/dist/components/file-drop.d.ts +77 -0
- package/dist/components/file-drop.js +258 -0
- package/dist/components/filter-bar.d.ts +153 -0
- package/dist/components/filter-bar.js +334 -0
- package/dist/components/form.d.ts +35 -0
- package/dist/components/form.js +56 -0
- package/dist/components/graph.d.ts +146 -0
- package/dist/components/graph.js +825 -0
- package/dist/components/illustration.d.ts +85 -0
- package/dist/components/illustration.js +165 -0
- package/dist/components/input-group.d.ts +138 -0
- package/dist/components/input-group.js +312 -0
- package/dist/components/input.d.ts +16 -0
- package/dist/components/input.js +25 -0
- package/dist/components/item.d.ts +64 -0
- package/dist/components/item.js +116 -0
- package/dist/components/kbd.d.ts +50 -0
- package/dist/components/kbd.js +45 -0
- package/dist/components/label.d.ts +12 -0
- package/dist/components/label.js +24 -0
- package/dist/components/layout.d.ts +136 -0
- package/dist/components/layout.js +162 -0
- package/dist/components/lightbox.d.ts +100 -0
- package/dist/components/lightbox.js +439 -0
- package/dist/components/locale.d.ts +44 -0
- package/dist/components/locale.js +37 -0
- package/dist/components/logo.d.ts +54 -0
- package/dist/components/logo.js +96 -0
- package/dist/components/menu.d.ts +60 -0
- package/dist/components/menu.js +140 -0
- package/dist/components/menubar.d.ts +62 -0
- package/dist/components/menubar.js +223 -0
- package/dist/components/message.d.ts +42 -0
- package/dist/components/message.js +59 -0
- package/dist/components/meter.d.ts +31 -0
- package/dist/components/meter.js +27 -0
- package/dist/components/money-input.d.ts +80 -0
- package/dist/components/money-input.js +253 -0
- package/dist/components/native-select.d.ts +26 -0
- package/dist/components/native-select.js +35 -0
- package/dist/components/navigation-menu.d.ts +42 -0
- package/dist/components/navigation-menu.js +97 -0
- package/dist/components/number-field.d.ts +55 -0
- package/dist/components/number-field.js +164 -0
- package/dist/components/otp-field.d.ts +48 -0
- package/dist/components/otp-field.js +102 -0
- package/dist/components/pagination.d.ts +37 -0
- package/dist/components/pagination.js +81 -0
- package/dist/components/pdf-viewer.d.ts +134 -0
- package/dist/components/pdf-viewer.js +996 -0
- package/dist/components/phone-input.d.ts +79 -0
- package/dist/components/phone-input.js +282 -0
- package/dist/components/popover.d.ts +33 -0
- package/dist/components/popover.js +48 -0
- package/dist/components/preview-card.d.ts +25 -0
- package/dist/components/preview-card.js +22 -0
- package/dist/components/progress.d.ts +27 -0
- package/dist/components/progress.js +25 -0
- package/dist/components/prompt-input.d.ts +156 -0
- package/dist/components/prompt-input.js +415 -0
- package/dist/components/quote.d.ts +22 -0
- package/dist/components/quote.js +15 -0
- package/dist/components/radio-group.d.ts +18 -0
- package/dist/components/radio-group.js +34 -0
- package/dist/components/rating.d.ts +73 -0
- package/dist/components/rating.js +124 -0
- package/dist/components/reasoning.d.ts +46 -0
- package/dist/components/reasoning.js +73 -0
- package/dist/components/resizable.d.ts +47 -0
- package/dist/components/resizable.js +44 -0
- package/dist/components/response.d.ts +41 -0
- package/dist/components/response.js +566 -0
- package/dist/components/scroll-area.d.ts +33 -0
- package/dist/components/scroll-area.js +31 -0
- package/dist/components/select.d.ts +35 -0
- package/dist/components/select.js +71 -0
- package/dist/components/separator.d.ts +14 -0
- package/dist/components/separator.js +17 -0
- package/dist/components/sidebar.d.ts +163 -0
- package/dist/components/sidebar.js +505 -0
- package/dist/components/site-header.d.ts +93 -0
- package/dist/components/site-header.js +121 -0
- package/dist/components/skeleton.d.ts +31 -0
- package/dist/components/skeleton.js +29 -0
- package/dist/components/slider.d.ts +24 -0
- package/dist/components/slider.js +131 -0
- package/dist/components/sortable.d.ts +178 -0
- package/dist/components/sortable.js +1258 -0
- package/dist/components/sources.d.ts +40 -0
- package/dist/components/sources.js +42 -0
- package/dist/components/spinner.d.ts +48 -0
- package/dist/components/spinner.js +75 -0
- package/dist/components/stat.d.ts +91 -0
- package/dist/components/stat.js +141 -0
- package/dist/components/stepper.d.ts +71 -0
- package/dist/components/stepper.js +101 -0
- package/dist/components/suggestions.d.ts +20 -0
- package/dist/components/suggestions.js +18 -0
- package/dist/components/switch.d.ts +14 -0
- package/dist/components/switch.js +26 -0
- package/dist/components/table.d.ts +172 -0
- package/dist/components/table.js +895 -0
- package/dist/components/tabs.d.ts +25 -0
- package/dist/components/tabs.js +162 -0
- package/dist/components/tag.d.ts +41 -0
- package/dist/components/tag.js +88 -0
- package/dist/components/tags-input.d.ts +56 -0
- package/dist/components/tags-input.js +271 -0
- package/dist/components/textarea.d.ts +13 -0
- package/dist/components/textarea.js +16 -0
- package/dist/components/theme.d.ts +55 -0
- package/dist/components/theme.js +120 -0
- package/dist/components/time-field.d.ts +70 -0
- package/dist/components/time-field.js +450 -0
- package/dist/components/timeline.d.ts +92 -0
- package/dist/components/timeline.js +108 -0
- package/dist/components/tippy.d.ts +48 -0
- package/dist/components/tippy.js +648 -0
- package/dist/components/toast.d.ts +88 -0
- package/dist/components/toast.js +205 -0
- package/dist/components/toggle-group.d.ts +41 -0
- package/dist/components/toggle-group.js +140 -0
- package/dist/components/toggle.d.ts +23 -0
- package/dist/components/toggle.js +35 -0
- package/dist/components/tool-call.d.ts +63 -0
- package/dist/components/tool-call.js +68 -0
- package/dist/components/toolbar.d.ts +17 -0
- package/dist/components/toolbar.js +39 -0
- package/dist/components/tooltip.d.ts +42 -0
- package/dist/components/tooltip.js +47 -0
- package/dist/components/tour.d.ts +127 -0
- package/dist/components/tour.js +648 -0
- package/dist/components/tree.d.ts +75 -0
- package/dist/components/tree.js +649 -0
- package/dist/components/typography.d.ts +134 -0
- package/dist/components/typography.js +176 -0
- package/dist/components/video-player.d.ts +284 -0
- package/dist/components/video-player.js +1392 -0
- package/dist/illustration.d.ts +2 -0
- package/dist/illustration.js +7 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.js +94 -0
- package/dist/lib/cn.d.ts +20 -0
- package/dist/lib/cn.js +38 -0
- package/dist/lib/code-highlight.d.ts +18 -0
- package/dist/lib/code-highlight.js +174 -0
- package/dist/lib/code-theme.d.ts +19 -0
- package/dist/lib/code-theme.js +140 -0
- package/dist/lib/collapse-row.d.ts +9 -0
- package/dist/lib/collapse-row.js +129 -0
- package/dist/lib/digit-roll.d.ts +21 -0
- package/dist/lib/digit-roll.js +31 -0
- package/dist/lib/editorial-assets.d.ts +16 -0
- package/dist/lib/editorial-assets.js +56 -0
- package/dist/lib/field-errors.d.ts +28 -0
- package/dist/lib/field-errors.js +24 -0
- package/dist/lib/field-value.d.ts +13 -0
- package/dist/lib/field-value.js +44 -0
- package/dist/lib/figure/catalog.d.ts +127 -0
- package/dist/lib/figure/catalog.js +130 -0
- package/dist/lib/figure/figures/automation.d.ts +7 -0
- package/dist/lib/figure/figures/automation.js +143 -0
- package/dist/lib/figure/figures/bar-chart.d.ts +7 -0
- package/dist/lib/figure/figures/bar-chart.js +99 -0
- package/dist/lib/figure/figures/brackets-classic.d.ts +11 -0
- package/dist/lib/figure/figures/brackets-classic.js +170 -0
- package/dist/lib/figure/figures/brackets.d.ts +8 -0
- package/dist/lib/figure/figures/brackets.js +84 -0
- package/dist/lib/figure/figures/city.d.ts +7 -0
- package/dist/lib/figure/figures/city.js +93 -0
- package/dist/lib/figure/figures/conveyor.d.ts +7 -0
- package/dist/lib/figure/figures/conveyor.js +97 -0
- package/dist/lib/figure/figures/database.d.ts +7 -0
- package/dist/lib/figure/figures/database.js +65 -0
- package/dist/lib/figure/figures/documents.d.ts +7 -0
- package/dist/lib/figure/figures/documents.js +83 -0
- package/dist/lib/figure/figures/inbox.d.ts +7 -0
- package/dist/lib/figure/figures/inbox.js +92 -0
- package/dist/lib/figure/figures/laptop.d.ts +7 -0
- package/dist/lib/figure/figures/laptop.js +67 -0
- package/dist/lib/figure/figures/monitor.d.ts +7 -0
- package/dist/lib/figure/figures/monitor.js +59 -0
- package/dist/lib/figure/figures/pipeline.d.ts +8 -0
- package/dist/lib/figure/figures/pipeline.js +117 -0
- package/dist/lib/figure/figures/platform.d.ts +7 -0
- package/dist/lib/figure/figures/platform.js +117 -0
- package/dist/lib/figure/figures/server.d.ts +7 -0
- package/dist/lib/figure/figures/server.js +115 -0
- package/dist/lib/figure/figures/spreadsheet.d.ts +7 -0
- package/dist/lib/figure/figures/spreadsheet.js +87 -0
- package/dist/lib/figure/figures/timeline.d.ts +7 -0
- package/dist/lib/figure/figures/timeline.js +65 -0
- package/dist/lib/figure/kernel.d.ts +152 -0
- package/dist/lib/figure/kernel.js +576 -0
- package/dist/lib/figure/parts.d.ts +42 -0
- package/dist/lib/figure/parts.js +126 -0
- package/dist/lib/form-reset.d.ts +11 -0
- package/dist/lib/form-reset.js +22 -0
- package/dist/lib/glide.d.ts +53 -0
- package/dist/lib/glide.js +138 -0
- package/dist/lib/graph-layout.d.ts +58 -0
- package/dist/lib/graph-layout.js +209 -0
- package/dist/lib/illustration-drawings.d.ts +89 -0
- package/dist/lib/illustration-drawings.js +539 -0
- package/dist/lib/illustration-info.d.ts +37 -0
- package/dist/lib/illustration-info.js +22 -0
- package/dist/lib/illustration-library.d.ts +87 -0
- package/dist/lib/illustration-library.js +352 -0
- package/dist/lib/logo-geometry.d.ts +29 -0
- package/dist/lib/logo-geometry.js +67 -0
- package/dist/lib/markdown-guard.d.ts +16 -0
- package/dist/lib/markdown-guard.js +123 -0
- package/dist/lib/merge-refs.d.ts +10 -0
- package/dist/lib/merge-refs.js +26 -0
- package/dist/lib/money.d.ts +73 -0
- package/dist/lib/money.js +343 -0
- package/dist/lib/motion.d.ts +6 -0
- package/dist/lib/motion.js +12 -0
- package/dist/lib/pdf-worker.d.ts +1 -0
- package/dist/lib/pdf-worker.js +6 -0
- package/dist/lib/pdf.d.ts +19 -0
- package/dist/lib/pdf.js +58 -0
- package/dist/lib/phone-countries.d.ts +1 -0
- package/dist/lib/phone-countries.js +281 -0
- package/dist/lib/phone.d.ts +90 -0
- package/dist/lib/phone.js +286 -0
- package/dist/lib/platform.d.ts +38 -0
- package/dist/lib/platform.js +75 -0
- package/dist/lib/room.d.ts +25 -0
- package/dist/lib/room.js +46 -0
- package/dist/lib/row-index.d.ts +15 -0
- package/dist/lib/row-index.js +136 -0
- package/dist/lib/table-fit.d.ts +143 -0
- package/dist/lib/table-fit.js +596 -0
- package/dist/lib/theme-script.d.ts +31 -0
- package/dist/lib/theme-script.js +49 -0
- package/dist/lib/tippy/pixels.d.ts +47 -0
- package/dist/lib/tippy/pixels.js +187 -0
- package/dist/lib/tippy/sprite.d.ts +86 -0
- package/dist/lib/tippy/sprite.js +753 -0
- package/dist/messages/de.d.ts +12 -0
- package/dist/messages/de.js +326 -0
- package/dist/styles/expressive.css +203 -0
- package/dist/styles/fonts.css +145 -0
- package/dist/styles/index.css +207 -0
- package/dist/styles/material.css +317 -0
- package/dist/styles/parts/ai.css +361 -0
- package/dist/styles/parts/brand.css +75 -0
- package/dist/styles/parts/controls.css +774 -0
- package/dist/styles/parts/data.css +222 -0
- package/dist/styles/parts/editorial.css +120 -0
- package/dist/styles/parts/feedback.css +340 -0
- package/dist/styles/parts/foundations.css +166 -0
- package/dist/styles/parts/graph.css +214 -0
- package/dist/styles/parts/inputs.css +261 -0
- package/dist/styles/parts/isometric.css +124 -0
- package/dist/styles/parts/navigation.css +424 -0
- package/dist/styles/parts/overlays.css +250 -0
- package/dist/styles/parts/pdf.css +154 -0
- package/dist/styles/parts/react-flow.css +519 -0
- package/dist/styles/tokens.css +299 -0
- package/dist/vite.d.ts +66 -0
- package/dist/vite.js +29 -0
- package/package.json +183 -5
|
@@ -0,0 +1,655 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { columnFilteringFeature, columnGroupingFeature, columnVisibilityFeature, constructRow, createColumnHelper, createFilteredRowModel, createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, filterFn_includesString, functionalUpdate, globalFilteringFeature, metaHelper, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, sortFn_alphanumeric, sortFn_basic, sortFn_datetime, sortFn_text, tableFeatures, useTable, } from "@tanstack/react-table";
|
|
4
|
+
import { ArrowDownIcon, ArrowUpIcon, ChevronLeftIcon, ChevronRightIcon, ChevronsUpDownIcon, Columns3Icon, SearchIcon, } from "lucide-react";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { cn } from "../lib/cn.js";
|
|
7
|
+
import { columnRanks, matching, searchLines, sortedOrder } from "../lib/row-index.js";
|
|
8
|
+
import { widestRows } from "../lib/table-fit.js";
|
|
9
|
+
import { Button } from "./button.js";
|
|
10
|
+
import { Checkbox } from "./checkbox.js";
|
|
11
|
+
import { Input } from "./input.js";
|
|
12
|
+
import { useLocale, useMessages } from "./locale.js";
|
|
13
|
+
import { Menu, MenuCheckboxItem, MenuContent, MenuGroup, MenuGroupLabel, MenuTrigger } from "./menu.js";
|
|
14
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./select.js";
|
|
15
|
+
import { Skeleton } from "./skeleton.js";
|
|
16
|
+
import { Table, TableBody, TableCaption, TableCell, TableGroup, TableGroupHeader, TableHead, TableHeader, TableRow, TableVirtualBody, } from "./table.js";
|
|
17
|
+
const defaultMessages = {
|
|
18
|
+
search: "Search…",
|
|
19
|
+
columns: "Columns",
|
|
20
|
+
showColumns: "Show columns",
|
|
21
|
+
selectAll: "Select all rows",
|
|
22
|
+
selectPage: "Select all rows on this page",
|
|
23
|
+
selectRow: "Select row",
|
|
24
|
+
empty: "No results.",
|
|
25
|
+
loadError: "Couldn't load the rows.",
|
|
26
|
+
retry: "Try again",
|
|
27
|
+
selected: (count, total) => `${count} of ${total} selected`,
|
|
28
|
+
groupCount: (rows, groups) => `${rows} ${rows === 1 ? "row" : "rows"} in ${groups} ${groups === 1 ? "group" : "groups"}`,
|
|
29
|
+
rowsPerPage: "Rows",
|
|
30
|
+
range: (first, last, total) => `${first}–${last} of ${total}`,
|
|
31
|
+
previous: "Previous page",
|
|
32
|
+
next: "Next page",
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* The TanStack Table v9 features `DataTable` registers: global and column filtering, sorting,
|
|
36
|
+
* column visibility, row selection, grouping and pagination, all processed on the client.
|
|
37
|
+
*/
|
|
38
|
+
export const dataTableFeatures = tableFeatures({
|
|
39
|
+
columnFilteringFeature,
|
|
40
|
+
globalFilteringFeature,
|
|
41
|
+
filteredRowModel: createFilteredRowModel(),
|
|
42
|
+
filterFns: { includesString: filterFn_includesString },
|
|
43
|
+
rowSortingFeature,
|
|
44
|
+
sortedRowModel: createSortedRowModel(),
|
|
45
|
+
sortFns: {
|
|
46
|
+
alphanumeric: sortFn_alphanumeric,
|
|
47
|
+
basic: sortFn_basic,
|
|
48
|
+
datetime: sortFn_datetime,
|
|
49
|
+
text: sortFn_text,
|
|
50
|
+
},
|
|
51
|
+
columnVisibilityFeature,
|
|
52
|
+
columnGroupingFeature,
|
|
53
|
+
groupedRowModel: createGroupedRowModel(),
|
|
54
|
+
rowSelectionFeature,
|
|
55
|
+
rowPaginationFeature,
|
|
56
|
+
paginatedRowModel: createPaginatedRowModel(),
|
|
57
|
+
columnMeta: metaHelper(),
|
|
58
|
+
});
|
|
59
|
+
/**
|
|
60
|
+
* Typed helpers for `DataTable` columns: `accessor(key, def)`, `display(def)` and
|
|
61
|
+
* `columns([...])`. Create one per row type at module scope.
|
|
62
|
+
*
|
|
63
|
+
* const column = createDataTableColumnHelper<Deploy>();
|
|
64
|
+
* const columns = column.columns([column.accessor("name", { header: "Name" })]);
|
|
65
|
+
*/
|
|
66
|
+
export function createDataTableColumnHelper() {
|
|
67
|
+
return createColumnHelper();
|
|
68
|
+
}
|
|
69
|
+
/** null, undefined, NaN and "": a cell with nothing in it. */
|
|
70
|
+
const isBlank = (value) => value == null || value === "" || (typeof value === "number" && Number.isNaN(value));
|
|
71
|
+
/**
|
|
72
|
+
* Text in the order of the Unicode collation (CLDR root): accented letters beside their base letter
|
|
73
|
+
* ("Édimbourg" with the e's, "Århus" with the a's, "Łódź" after the l's), lower case just before
|
|
74
|
+
* upper case, digits before letters and runs of digits by value ("item2" before "item10"). "en"
|
|
75
|
+
* uses exactly that order and is in every runtime; "und" would fall back to the runtime's own
|
|
76
|
+
* locale, which differs between a server and a browser.
|
|
77
|
+
*/
|
|
78
|
+
const rootCollator = new Intl.Collator("en", { numeric: true });
|
|
79
|
+
/** The table's `locale` as a collator: `rootCollator` without one, or for a tag that isn't valid. */
|
|
80
|
+
function collatorFor(locale) {
|
|
81
|
+
if (!locale)
|
|
82
|
+
return rootCollator;
|
|
83
|
+
try {
|
|
84
|
+
return new Intl.Collator(locale, { numeric: true });
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return rootCollator;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Every column's sort unless it names its own: dates by time, text by `collator`, anything else by
|
|
92
|
+
* value — with empty cells (null, undefined, NaN, "") below every value, the way an empty text
|
|
93
|
+
* sorts: first going up, last going down. TanStack's own compares a null as 0, which put the empty
|
|
94
|
+
* amounts between the negative and the positive ones, and text by code point, which put every
|
|
95
|
+
* accented initial after "z".
|
|
96
|
+
*/
|
|
97
|
+
function sortByValue(collator, rowA, rowB, columnId) {
|
|
98
|
+
const a = rowA.getValue(columnId);
|
|
99
|
+
const b = rowB.getValue(columnId);
|
|
100
|
+
if (isBlank(a) || isBlank(b))
|
|
101
|
+
return isBlank(a) === isBlank(b) ? 0 : isBlank(a) ? -1 : 1;
|
|
102
|
+
if (a instanceof Date || b instanceof Date)
|
|
103
|
+
return sortFn_datetime(rowA, rowB, columnId);
|
|
104
|
+
if (typeof a === "string" || typeof b === "string")
|
|
105
|
+
return collator.compare(String(a), String(b));
|
|
106
|
+
return sortFn_basic(rowA, rowB, columnId);
|
|
107
|
+
}
|
|
108
|
+
/** Every column with data in `columns` (groups opened), by id — the ids and values TanStack gives them. */
|
|
109
|
+
function leafReaders(columns) {
|
|
110
|
+
const out = new Map();
|
|
111
|
+
const walk = (defs) => {
|
|
112
|
+
for (const def of defs) {
|
|
113
|
+
const d = def;
|
|
114
|
+
if (d.columns)
|
|
115
|
+
walk(d.columns);
|
|
116
|
+
const key = d.accessorKey === undefined ? undefined : String(d.accessorKey);
|
|
117
|
+
const id = d.id ?? key?.replaceAll(".", "_") ?? (typeof d.header === "string" ? d.header : undefined);
|
|
118
|
+
const read = d.accessorFn ??
|
|
119
|
+
(key === undefined
|
|
120
|
+
? undefined
|
|
121
|
+
: key.includes(".")
|
|
122
|
+
? (row) => key
|
|
123
|
+
.split(".")
|
|
124
|
+
.reduce((value, part) => value?.[part], row)
|
|
125
|
+
: (row) => row[key]);
|
|
126
|
+
if (id && read)
|
|
127
|
+
out.set(id, { id, def, read });
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
walk(columns);
|
|
131
|
+
return out;
|
|
132
|
+
}
|
|
133
|
+
/* ── Header ────────────────────────────────────────────────────────────────── */
|
|
134
|
+
function columnLabel(column) {
|
|
135
|
+
const header = column.columnDef.header;
|
|
136
|
+
return column.columnDef.meta?.label ?? (typeof header === "string" ? header : column.id);
|
|
137
|
+
}
|
|
138
|
+
function SortIcon({ direction }) {
|
|
139
|
+
if (direction === "asc")
|
|
140
|
+
return _jsx(ArrowUpIcon, { "aria-hidden": true, className: "size-3.5 text-foreground" });
|
|
141
|
+
if (direction === "desc")
|
|
142
|
+
return _jsx(ArrowDownIcon, { "aria-hidden": true, className: "size-3.5 text-foreground" });
|
|
143
|
+
return _jsx(ChevronsUpDownIcon, { "aria-hidden": true, className: "size-3.5 opacity-60" });
|
|
144
|
+
}
|
|
145
|
+
/** More rows than this could show at once: the table renders only those in view. */
|
|
146
|
+
const VIRTUAL_FROM = 100;
|
|
147
|
+
/**
|
|
148
|
+
* From this many rows (not grouped), the table sorts, searches and pages them itself, with one
|
|
149
|
+
* number per row, and TanStack builds a row only for those drawn: a million rows sort in a fraction
|
|
150
|
+
* of a second, in a fraction of the memory.
|
|
151
|
+
*/
|
|
152
|
+
const LARGE_FROM = 50_000;
|
|
153
|
+
/** Rows a server table asks for at a time. */
|
|
154
|
+
const CHUNK = 100;
|
|
155
|
+
const NO_ROWS = [];
|
|
156
|
+
/** From this many rows, a search waits for typing to pause (SEARCH_WAIT ms). */
|
|
157
|
+
const SEARCH_WAIT_FROM = 20_000;
|
|
158
|
+
const SEARCH_WAIT = 250;
|
|
159
|
+
const rowKeyOf = (row) => row.id;
|
|
160
|
+
/**
|
|
161
|
+
* DataTable — a `Table` with the controls people expect from a data grid: sortable mono
|
|
162
|
+
* headers, a search field, a "Columns" visibility menu, row selection with `Checkbox`, grouped
|
|
163
|
+
* rows (`groupBy`) and a compact pager with a mono "1–10 of 48" count and a rows-per-page
|
|
164
|
+
* select. Powered by TanStack Table v9; define columns with `createDataTableColumnHelper` and you never touch
|
|
165
|
+
* the TanStack table instance.
|
|
166
|
+
*
|
|
167
|
+
* Use it for lists people search, sort and act on: deploys, orders, members. The rule people
|
|
168
|
+
* break: reaching for it for a handful of rows. Under ~10 rows with nothing to sort, use a
|
|
169
|
+
* plain `Table`.
|
|
170
|
+
*/
|
|
171
|
+
export function DataTable({ columns, data = NO_ROWS, fetchRows, searchKey, searchPlaceholder: searchPlaceholderProp, searchable = true, pageSize = 10, pageSizeOptions = [10, 20, 50], selectable, onRowSelectionChange, getRowId, columnToggle = true, dense = false, variant = "card", fit = false, initialSorting = [], locale: localeProp, initialColumnVisibility = {}, emptyMessage: emptyMessageProp, labels, toolbar, caption, label, groupBy, groupSummary, stickyGroupHeaders = false, tableContainerProps, virtualize, className, ...props }) {
|
|
172
|
+
const text = useMessages("dataTable", defaultMessages, labels);
|
|
173
|
+
// The header's checkbox reads its name here: the columns are built once, not at every render.
|
|
174
|
+
const textRef = React.useRef(text);
|
|
175
|
+
textRef.current = text;
|
|
176
|
+
const providedLocale = useLocale();
|
|
177
|
+
const locale = localeProp ?? providedLocale;
|
|
178
|
+
const searchPlaceholder = searchPlaceholderProp ?? text.search;
|
|
179
|
+
const emptyMessage = emptyMessageProp === undefined ? text.empty : emptyMessageProp;
|
|
180
|
+
const server = fetchRows != null;
|
|
181
|
+
if (process.env.NODE_ENV !== "production" && server && groupBy != null)
|
|
182
|
+
console.warn("DataTable: `groupBy` is not available with `fetchRows`; the rows are not grouped.");
|
|
183
|
+
const grouped = groupBy != null && !server;
|
|
184
|
+
// Rows the table sorts, searches and pages itself (many of them), or that come from a server:
|
|
185
|
+
// TanStack only knows the columns and builds rows for those drawn.
|
|
186
|
+
const large = !server && !grouped && data.length >= LARGE_FROM;
|
|
187
|
+
const outside = server || large;
|
|
188
|
+
const withSelection = selectable ?? onRowSelectionChange != null;
|
|
189
|
+
const size = dense ? "sm" : "default";
|
|
190
|
+
const searchId = React.useId();
|
|
191
|
+
// Every row checkbox is named by one hidden label. Named by `aria-label` alone, Base UI looks for
|
|
192
|
+
// a <label> of its own on every render, a search of the whole page per checkbox.
|
|
193
|
+
const selectRowLabelId = `${searchId}-select-row`;
|
|
194
|
+
// Which groups are closed. TanStack's order of rows holds only the groups, not the rows in them,
|
|
195
|
+
// so a Shift-click range in a grouped table runs here: from the last row toggled to this one,
|
|
196
|
+
// through the rows of the open groups.
|
|
197
|
+
const [closedGroups, setClosedGroups] = React.useState(() => new Set());
|
|
198
|
+
const setGroupOpen = (id, open) => setClosedGroups((closed) => {
|
|
199
|
+
const next = new Set(closed);
|
|
200
|
+
if (open)
|
|
201
|
+
next.delete(id);
|
|
202
|
+
else
|
|
203
|
+
next.add(id);
|
|
204
|
+
return next;
|
|
205
|
+
});
|
|
206
|
+
const groupedAnchor = React.useRef(null);
|
|
207
|
+
/** Selection in the large and server modes, set at each render for the checkbox column. */
|
|
208
|
+
const outsideSelect = React.useRef(null);
|
|
209
|
+
const groupedRange = React.useRef(() => null);
|
|
210
|
+
// Every column's sort, in the locale's order. It reads the collator as it runs: TanStack copies the
|
|
211
|
+
// default column into a column only when it builds it.
|
|
212
|
+
const collator = React.useMemo(() => collatorFor(locale), [locale]);
|
|
213
|
+
const collatorRef = React.useRef(collator);
|
|
214
|
+
collatorRef.current = collator;
|
|
215
|
+
const sortFn = React.useCallback((rowA, rowB, columnId) => sortByValue(collatorRef.current, rowA, rowB, columnId), []);
|
|
216
|
+
const allColumns = React.useMemo(() => {
|
|
217
|
+
if (!withSelection)
|
|
218
|
+
return [...columns];
|
|
219
|
+
const select = {
|
|
220
|
+
id: "select",
|
|
221
|
+
enableSorting: false,
|
|
222
|
+
enableHiding: false,
|
|
223
|
+
enableGlobalFilter: false,
|
|
224
|
+
header: ({ table }) => grouped ? (_jsx(Checkbox, { "aria-label": textRef.current.selectAll, checked: table.getIsAllRowsSelected(), indeterminate: table.getIsSomeRowsSelected() && !table.getIsAllRowsSelected(), onCheckedChange: (checked) => {
|
|
225
|
+
groupedAnchor.current = null;
|
|
226
|
+
table.toggleAllRowsSelected(checked);
|
|
227
|
+
}, className: "align-middle" })) : outsideSelect.current ? (
|
|
228
|
+
// A server's rows aren't all here to select; many rows are, every one that matches.
|
|
229
|
+
outsideSelect.current.toggleAll ? (_jsx(Checkbox, { "aria-label": textRef.current.selectAll, checked: outsideSelect.current.all, indeterminate: outsideSelect.current.some, onCheckedChange: (checked) => outsideSelect.current?.toggleAll?.(checked), className: "align-middle" })) : null) : (_jsx(Checkbox, { "aria-label": textRef.current.selectPage, checked: table.getIsAllPageRowsSelected(), indeterminate: table.getIsSomePageRowsSelected() && !table.getIsAllPageRowsSelected(), onCheckedChange: (checked) => table.toggleAllPageRowsSelected(checked), className: "align-middle" })),
|
|
230
|
+
cell: ({ row }) => (_jsx(Checkbox, { "aria-labelledby": selectRowLabelId, checked: row.getIsSelected(), disabled: !row.getCanSelect(), onCheckedChange: (checked, details) => {
|
|
231
|
+
const shiftKey = details.event?.shiftKey ?? false;
|
|
232
|
+
if (outsideSelect.current)
|
|
233
|
+
return outsideSelect.current.toggle(row, checked, shiftKey);
|
|
234
|
+
const range = shiftKey && grouped ? groupedRange.current(row.id) : null;
|
|
235
|
+
groupedAnchor.current = row.id;
|
|
236
|
+
if (range)
|
|
237
|
+
table.setRowSelection((old) => {
|
|
238
|
+
const next = { ...old };
|
|
239
|
+
for (const r of range) {
|
|
240
|
+
if (!r.getCanSelect())
|
|
241
|
+
continue;
|
|
242
|
+
if (checked)
|
|
243
|
+
next[r.id] = true;
|
|
244
|
+
else
|
|
245
|
+
delete next[r.id];
|
|
246
|
+
}
|
|
247
|
+
return next;
|
|
248
|
+
});
|
|
249
|
+
else
|
|
250
|
+
row.getToggleSelectedHandler()({ target: { checked }, shiftKey });
|
|
251
|
+
}, className: "align-middle" })),
|
|
252
|
+
// A fitting table sizes the column to the checkbox by itself.
|
|
253
|
+
meta: fit ? {} : { className: "w-0 pe-0" },
|
|
254
|
+
};
|
|
255
|
+
return [select, ...columns];
|
|
256
|
+
}, [columns, withSelection, grouped, fit, selectRowLabelId]);
|
|
257
|
+
const [rowSelection, setRowSelection] = React.useState({});
|
|
258
|
+
const [search, setSearch] = React.useState("");
|
|
259
|
+
// What is typed shows at once; with many rows, the search runs once typing pauses, so each key
|
|
260
|
+
// doesn't filter every row again.
|
|
261
|
+
const [typed, setTyped] = React.useState("");
|
|
262
|
+
React.useEffect(() => {
|
|
263
|
+
if (typed === search)
|
|
264
|
+
return;
|
|
265
|
+
if (!server && data.length < SEARCH_WAIT_FROM)
|
|
266
|
+
return setSearch(typed);
|
|
267
|
+
const id = setTimeout(() => setSearch(typed), SEARCH_WAIT);
|
|
268
|
+
return () => clearTimeout(id);
|
|
269
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- only a new text starts a search.
|
|
270
|
+
}, [typed]);
|
|
271
|
+
const [sorting, setSorting] = React.useState(initialSorting);
|
|
272
|
+
const [pagination, setPagination] = React.useState({ pageIndex: 0, pageSize });
|
|
273
|
+
/* Many rows: an order of row indices, sorted by each sorted column's ranks, then searched. */
|
|
274
|
+
const readers = React.useMemo(() => (outside ? leafReaders(columns) : new Map()), [outside, columns]);
|
|
275
|
+
const ranks = React.useMemo(() => new Map(), [data, readers, collator]);
|
|
276
|
+
const order = React.useMemo(() => {
|
|
277
|
+
if (!large)
|
|
278
|
+
return null;
|
|
279
|
+
// A column with its own `sortFn` is sorted by it, row against row: slower, but its order.
|
|
280
|
+
const own = sorting.find(({ id }) => typeof readers.get(id)?.def.sortFn === "function");
|
|
281
|
+
if (own) {
|
|
282
|
+
const rowOf = (i) => ({
|
|
283
|
+
id: String(i),
|
|
284
|
+
index: i,
|
|
285
|
+
original: data[i],
|
|
286
|
+
getValue: (columnId) => readers.get(columnId)?.read(data[i], i),
|
|
287
|
+
});
|
|
288
|
+
const order = Uint32Array.from(data, (_, i) => i);
|
|
289
|
+
return order.sort((a, b) => {
|
|
290
|
+
for (const { id, desc } of sorting) {
|
|
291
|
+
const reader = readers.get(id);
|
|
292
|
+
if (!reader)
|
|
293
|
+
continue;
|
|
294
|
+
const fn = reader.def.sortFn;
|
|
295
|
+
const result = typeof fn === "function"
|
|
296
|
+
? fn(rowOf(a), rowOf(b), id)
|
|
297
|
+
: collator.compare(String(reader.read(data[a], a) ?? ""), String(reader.read(data[b], b) ?? ""));
|
|
298
|
+
if (result)
|
|
299
|
+
return desc ? -result : result;
|
|
300
|
+
}
|
|
301
|
+
return a - b;
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
const keys = sorting.flatMap(({ id, desc }) => {
|
|
305
|
+
const reader = readers.get(id);
|
|
306
|
+
if (!reader)
|
|
307
|
+
return [];
|
|
308
|
+
let r = ranks.get(id);
|
|
309
|
+
if (!r)
|
|
310
|
+
ranks.set(id, (r = columnRanks(data.length, (i) => reader.read(data[i], i), collator)));
|
|
311
|
+
return [{ ranks: r, desc }];
|
|
312
|
+
});
|
|
313
|
+
return sortedOrder(data.length, keys);
|
|
314
|
+
}, [large, data, sorting, readers, ranks, collator]);
|
|
315
|
+
// Each row's searchable text, read once, the first time something is searched.
|
|
316
|
+
const lines = React.useRef(null);
|
|
317
|
+
const found = React.useMemo(() => {
|
|
318
|
+
if (!order)
|
|
319
|
+
return null;
|
|
320
|
+
if (!search)
|
|
321
|
+
return order;
|
|
322
|
+
const key = [data, readers, searchKey];
|
|
323
|
+
if (!lines.current || lines.current.key.some((k, i) => k !== key[i])) {
|
|
324
|
+
const sample = data[0];
|
|
325
|
+
const searched = [...readers.values()].filter((reader) => searchKey
|
|
326
|
+
? reader.id === searchKey
|
|
327
|
+
: reader.def.enableGlobalFilter !== false &&
|
|
328
|
+
sample !== undefined &&
|
|
329
|
+
["string", "number"].includes(typeof reader.read(sample, 0)));
|
|
330
|
+
lines.current = {
|
|
331
|
+
key,
|
|
332
|
+
lines: searchLines(data.length, searched.map((reader) => (i) => reader.read(data[i], i))),
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
return matching(order, lines.current.lines, search);
|
|
336
|
+
}, [order, search, data, readers, searchKey]);
|
|
337
|
+
/* Rows from a server, a CHUNK at a time, cached until the sorting or the search change. */
|
|
338
|
+
const [served, setServed] = React.useState({
|
|
339
|
+
total: null,
|
|
340
|
+
error: null,
|
|
341
|
+
version: 0,
|
|
342
|
+
});
|
|
343
|
+
const queryKey = server ? JSON.stringify([sorting, search, searchKey]) : "";
|
|
344
|
+
const cache = React.useMemo(() => ({ chunks: new Map(), pending: new Map() }),
|
|
345
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- a new query starts an empty cache.
|
|
346
|
+
[queryKey, fetchRows]);
|
|
347
|
+
// Cleared as well as aborted: StrictMode's second mount, or a remount, asks for those rows again.
|
|
348
|
+
React.useEffect(() => () => {
|
|
349
|
+
cache.pending.forEach((controller) => controller.abort());
|
|
350
|
+
cache.pending.clear();
|
|
351
|
+
}, [cache]);
|
|
352
|
+
const fetchRef = React.useRef(fetchRows);
|
|
353
|
+
fetchRef.current = fetchRows;
|
|
354
|
+
const lastRange = React.useRef([0, CHUNK]);
|
|
355
|
+
const load = React.useCallback((from, to) => {
|
|
356
|
+
lastRange.current = [from, to];
|
|
357
|
+
const fetcher = fetchRef.current;
|
|
358
|
+
if (!fetcher)
|
|
359
|
+
return;
|
|
360
|
+
// Never past the end of the result, once it is known.
|
|
361
|
+
const end = totalRef.current == null ? to : Math.min(to, totalRef.current);
|
|
362
|
+
for (let c = Math.floor(from / CHUNK); c * CHUNK < Math.max(end, from + 1); c++) {
|
|
363
|
+
if (cache.chunks.has(c) || cache.pending.has(c))
|
|
364
|
+
continue;
|
|
365
|
+
const controller = new AbortController();
|
|
366
|
+
cache.pending.set(c, controller);
|
|
367
|
+
fetcher({
|
|
368
|
+
start: c * CHUNK,
|
|
369
|
+
end: (c + 1) * CHUNK,
|
|
370
|
+
sorting,
|
|
371
|
+
search,
|
|
372
|
+
searchKey,
|
|
373
|
+
signal: controller.signal,
|
|
374
|
+
})
|
|
375
|
+
.then((result) => {
|
|
376
|
+
if (controller.signal.aborted)
|
|
377
|
+
return;
|
|
378
|
+
cache.chunks.set(c, result.rows);
|
|
379
|
+
setServed((old) => ({ total: result.total, error: null, version: old.version + 1 }));
|
|
380
|
+
})
|
|
381
|
+
.catch((error) => {
|
|
382
|
+
if (!controller.signal.aborted)
|
|
383
|
+
setServed((old) => ({ ...old, error, version: old.version + 1 }));
|
|
384
|
+
})
|
|
385
|
+
.finally(() => {
|
|
386
|
+
if (cache.pending.get(c) === controller)
|
|
387
|
+
cache.pending.delete(c);
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
}, [cache, sorting, search, searchKey]);
|
|
391
|
+
// TanStack sorts again only when the sorting or the rows change, so a new locale hands it the rows
|
|
392
|
+
// as a new array.
|
|
393
|
+
const stableData = React.useMemo(() => (outside ? NO_ROWS : [...data]), [data, collator, outside]);
|
|
394
|
+
const outsideCount = server ? (served.total ?? 0) : (found?.length ?? 0);
|
|
395
|
+
const grouping = React.useMemo(() => (grouped ? [groupBy] : []), [grouped, groupBy]);
|
|
396
|
+
const columnFilters = React.useMemo(() => (searchKey && search ? [{ id: searchKey, value: search }] : []), [searchKey, search]);
|
|
397
|
+
const globalFilter = searchKey ? "" : search;
|
|
398
|
+
const table = useTable({
|
|
399
|
+
features: dataTableFeatures,
|
|
400
|
+
columns: allColumns,
|
|
401
|
+
data: stableData,
|
|
402
|
+
getRowId,
|
|
403
|
+
// Empty cells sort as one block (sortByValue), undefined ones too.
|
|
404
|
+
defaultColumn: { sortFn, sortUndefined: false },
|
|
405
|
+
globalFilterFn: "includesString",
|
|
406
|
+
enableMultiSort: true,
|
|
407
|
+
initialState: {
|
|
408
|
+
// The grouping column repeats the group header in every row, so it starts hidden.
|
|
409
|
+
columnVisibility: grouped ? { [groupBy]: false, ...initialColumnVisibility } : initialColumnVisibility,
|
|
410
|
+
},
|
|
411
|
+
groupedColumnMode: false,
|
|
412
|
+
// Many rows, or a server's: sorted, searched and paged here (above), not by TanStack.
|
|
413
|
+
manualSorting: outside,
|
|
414
|
+
manualFiltering: outside,
|
|
415
|
+
manualPagination: outside,
|
|
416
|
+
rowCount: outside ? outsideCount : undefined,
|
|
417
|
+
state: { rowSelection, globalFilter, columnFilters, grouping, sorting, pagination },
|
|
418
|
+
onSortingChange: (updater) => setSorting((prev) => functionalUpdate(updater, prev)),
|
|
419
|
+
onPaginationChange: (updater) => setPagination((prev) => functionalUpdate(updater, prev)),
|
|
420
|
+
onRowSelectionChange: (updater) => setRowSelection((prev) => functionalUpdate(updater, prev)),
|
|
421
|
+
onGlobalFilterChange: (updater) => {
|
|
422
|
+
const next = String(functionalUpdate(updater, search) ?? "");
|
|
423
|
+
setTyped(next);
|
|
424
|
+
setSearch(next);
|
|
425
|
+
},
|
|
426
|
+
onColumnFiltersChange: (updater) => {
|
|
427
|
+
const next = functionalUpdate(updater, columnFilters);
|
|
428
|
+
const value = next.find((filter) => filter.id === searchKey)?.value;
|
|
429
|
+
setTyped(typeof value === "string" ? value : "");
|
|
430
|
+
setSearch(typeof value === "string" ? value : "");
|
|
431
|
+
},
|
|
432
|
+
});
|
|
433
|
+
/* Many rows, or a server's: this page's rows (all of them, in a virtual table) — as data, with
|
|
434
|
+
`undefined` for a server's rows on their way — and TanStack rows built only for those drawn. */
|
|
435
|
+
const pageStart = pagination.pageIndex * pagination.pageSize;
|
|
436
|
+
const pageEnd = pageStart + pagination.pageSize;
|
|
437
|
+
// A server's rows are one array per query and size, filled in where they belong as they arrive,
|
|
438
|
+
// so a virtual body reads each new run without going over all the others.
|
|
439
|
+
const serverRows = React.useMemo(() => {
|
|
440
|
+
if (!server)
|
|
441
|
+
return null;
|
|
442
|
+
const count = served.total == null
|
|
443
|
+
? Math.min(pagination.pageSize, 10)
|
|
444
|
+
: Math.max(0, Math.min(pageEnd, served.total) - pageStart);
|
|
445
|
+
return { rows: new Array(count), filled: new Set() };
|
|
446
|
+
}, [server, served.total, cache, pageStart, pageEnd, pagination.pageSize]);
|
|
447
|
+
if (serverRows)
|
|
448
|
+
for (const [c, chunk] of cache.chunks) {
|
|
449
|
+
if (serverRows.filled.has(c))
|
|
450
|
+
continue;
|
|
451
|
+
serverRows.filled.add(c);
|
|
452
|
+
chunk.forEach((row, j) => {
|
|
453
|
+
const k = c * CHUNK + j - pageStart;
|
|
454
|
+
if (k >= 0 && k < serverRows.rows.length)
|
|
455
|
+
serverRows.rows[k] = row;
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
const outsideRows = React.useMemo(() => found
|
|
459
|
+
? Array.from(found.subarray(pageStart, Math.min(pageEnd, found.length)), (i) => data[i])
|
|
460
|
+
: (serverRows?.rows ?? NO_ROWS), [found, data, serverRows, pageStart, pageEnd]);
|
|
461
|
+
/** The row's index: in `data` (many rows) or in the server's result. */
|
|
462
|
+
const indexAt = (k) => (found ? found[pageStart + k] : pageStart + k);
|
|
463
|
+
const idAt = (k, original) => {
|
|
464
|
+
const index = indexAt(k);
|
|
465
|
+
return getRowId ? getRowId(original, index) : String(index);
|
|
466
|
+
};
|
|
467
|
+
const built = React.useMemo(() => new Map(), [table, allColumns, data, cache]);
|
|
468
|
+
const positions = React.useRef(new WeakMap());
|
|
469
|
+
/** A server's rows seen so far, by id: what a selection reports. */
|
|
470
|
+
const seen = React.useRef(new Map());
|
|
471
|
+
const rowAt = (k, original) => {
|
|
472
|
+
const id = idAt(k, original);
|
|
473
|
+
let row = built.get(id);
|
|
474
|
+
if (!row || row.original !== original) {
|
|
475
|
+
row = constructRow(table, id, original, indexAt(k), 0);
|
|
476
|
+
built.set(id, row);
|
|
477
|
+
}
|
|
478
|
+
positions.current.set(row, k);
|
|
479
|
+
if (server)
|
|
480
|
+
seen.current.set(id, original);
|
|
481
|
+
return row;
|
|
482
|
+
};
|
|
483
|
+
// A server table loads the page it shows; a virtual one, the rows as they come into view.
|
|
484
|
+
const totalRef = React.useRef(served.total);
|
|
485
|
+
totalRef.current = served.total;
|
|
486
|
+
React.useEffect(() => {
|
|
487
|
+
if (server)
|
|
488
|
+
load(pageStart, Math.min(pageEnd, pageStart + Math.min(pagination.pageSize, CHUNK * 2)));
|
|
489
|
+
}, [server, load, pageStart, pageEnd, pagination.pageSize]);
|
|
490
|
+
// Data indices by id, for reporting a selection of many rows by their data.
|
|
491
|
+
const indexById = React.useRef(null);
|
|
492
|
+
const originalOf = (id) => {
|
|
493
|
+
if (server)
|
|
494
|
+
return seen.current.get(id);
|
|
495
|
+
if (!getRowId)
|
|
496
|
+
return data[Number(id)];
|
|
497
|
+
if (indexById.current?.data !== data)
|
|
498
|
+
indexById.current = { data, ids: new Map(data.map((row, i) => [getRowId(row, i), i])) };
|
|
499
|
+
const i = indexById.current.ids.get(id);
|
|
500
|
+
return i === undefined ? undefined : data[i];
|
|
501
|
+
};
|
|
502
|
+
const selectedIds = Object.keys(rowSelection).filter((id) => rowSelection[id]);
|
|
503
|
+
const anchor = React.useRef(null);
|
|
504
|
+
if (outside && withSelection) {
|
|
505
|
+
const all = !!found &&
|
|
506
|
+
found.length > 0 &&
|
|
507
|
+
selectedIds.length >= found.length &&
|
|
508
|
+
Array.prototype.every.call(found, (i) => rowSelection[getRowId ? getRowId(data[i], i) : String(i)]);
|
|
509
|
+
outsideSelect.current = {
|
|
510
|
+
all,
|
|
511
|
+
some: selectedIds.length > 0 && !all,
|
|
512
|
+
toggleAll: found
|
|
513
|
+
? (checked) => setRowSelection((old) => {
|
|
514
|
+
const next = { ...old };
|
|
515
|
+
for (const i of found) {
|
|
516
|
+
const id = getRowId ? getRowId(data[i], i) : String(i);
|
|
517
|
+
if (checked)
|
|
518
|
+
next[id] = true;
|
|
519
|
+
else
|
|
520
|
+
delete next[id];
|
|
521
|
+
}
|
|
522
|
+
return next;
|
|
523
|
+
})
|
|
524
|
+
: undefined,
|
|
525
|
+
// Shift-click selects the run of rows from the last one toggled, in the order shown.
|
|
526
|
+
toggle: (row, checked, shiftKey) => {
|
|
527
|
+
const at = positions.current.get(row) ?? -1;
|
|
528
|
+
const from = shiftKey && anchor.current?.rows === outsideRows ? anchor.current.at : at;
|
|
529
|
+
anchor.current = { at, rows: outsideRows };
|
|
530
|
+
setRowSelection((old) => {
|
|
531
|
+
const next = { ...old };
|
|
532
|
+
for (let k = Math.min(from, at); k <= Math.max(from, at); k++) {
|
|
533
|
+
const original = outsideRows[k];
|
|
534
|
+
if (original === undefined)
|
|
535
|
+
continue;
|
|
536
|
+
const id = idAt(k, original);
|
|
537
|
+
if (checked)
|
|
538
|
+
next[id] = true;
|
|
539
|
+
else
|
|
540
|
+
delete next[id];
|
|
541
|
+
}
|
|
542
|
+
return next;
|
|
543
|
+
});
|
|
544
|
+
},
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
else
|
|
548
|
+
outsideSelect.current = null;
|
|
549
|
+
// Report selection changes (not the initial empty selection).
|
|
550
|
+
const onSelectionRef = React.useRef(onRowSelectionChange);
|
|
551
|
+
onSelectionRef.current = onRowSelectionChange;
|
|
552
|
+
const firstSelection = React.useRef(true);
|
|
553
|
+
React.useEffect(() => {
|
|
554
|
+
if (firstSelection.current) {
|
|
555
|
+
firstSelection.current = false;
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
onSelectionRef.current?.(outside
|
|
559
|
+
? selectedIds.flatMap((id) => {
|
|
560
|
+
const original = originalOf(id);
|
|
561
|
+
return original === undefined ? [] : [original];
|
|
562
|
+
})
|
|
563
|
+
: table.getSelectedRowModel().rows.map((row) => row.original));
|
|
564
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
565
|
+
}, [rowSelection]);
|
|
566
|
+
const { pageIndex, pageSize: currentPageSize } = table.state.pagination;
|
|
567
|
+
const total = table.getRowCount();
|
|
568
|
+
const first = total === 0 ? 0 : pageIndex * currentPageSize + 1;
|
|
569
|
+
const last = Math.min(total, (pageIndex + 1) * currentPageSize);
|
|
570
|
+
// Grouped tables show every group in full; pagination would split groups across pages.
|
|
571
|
+
const rows = grouped ? table.getPrePaginatedRowModel().rows : table.getRowModel().rows;
|
|
572
|
+
groupedRange.current = (to) => {
|
|
573
|
+
const from = groupedAnchor.current;
|
|
574
|
+
if (!grouped || from == null)
|
|
575
|
+
return null;
|
|
576
|
+
const order = rows.flatMap((group) => (closedGroups.has(group.id) ? [] : group.subRows));
|
|
577
|
+
const a = order.findIndex((row) => row.id === from);
|
|
578
|
+
const b = order.findIndex((row) => row.id === to);
|
|
579
|
+
return a < 0 || b < 0 ? null : order.slice(Math.min(a, b), Math.max(a, b) + 1);
|
|
580
|
+
};
|
|
581
|
+
const leafRowCount = grouped ? rows.reduce((sum, row) => sum + row.subRows.length, 0) : 0;
|
|
582
|
+
const visibleColumns = table.getVisibleLeafColumns();
|
|
583
|
+
const visibleColumnCount = visibleColumns.length;
|
|
584
|
+
// The title names each row in a fitting table: the column marked `title`, or the first one
|
|
585
|
+
// with data (not the checkbox).
|
|
586
|
+
const titleColumnId = fit
|
|
587
|
+
? (visibleColumns.find((column) => column.columnDef.meta?.title) ??
|
|
588
|
+
visibleColumns.find((column) => column.id !== "select"))?.id
|
|
589
|
+
: undefined;
|
|
590
|
+
const hideableColumns = table.getAllLeafColumns().filter((column) => column.getCanHide());
|
|
591
|
+
const selectedCount = withSelection ? selectedIds.length : 0;
|
|
592
|
+
const pageSizes = pageSizeOptions.includes(currentPageSize)
|
|
593
|
+
? pageSizeOptions
|
|
594
|
+
: [...pageSizeOptions, currentPageSize].sort((a, b) => a - b);
|
|
595
|
+
// Decided by how many rows could show, not by how many match the search, so a search never
|
|
596
|
+
// switches it on and off.
|
|
597
|
+
const virtual = virtualize ??
|
|
598
|
+
(grouped ? data.length : Math.min(currentPageSize, outside ? outsideCount : data.length)) > VIRTUAL_FROM;
|
|
599
|
+
// The rows that size the columns of a virtual table: the longest values of all the data, so the
|
|
600
|
+
// columns hold still while it scrolls, sorts and is searched.
|
|
601
|
+
const visibleIds = visibleColumns.map((column) => column.id).join("\n");
|
|
602
|
+
const sizeRows = React.useMemo(() => {
|
|
603
|
+
if (!virtual || outside)
|
|
604
|
+
return undefined;
|
|
605
|
+
const all = table.getCoreRowModel().rows;
|
|
606
|
+
const ids = visibleIds.split("\n").filter((id) => table.getColumn(id)?.accessorFn);
|
|
607
|
+
return widestRows(all, (row) => ids.map((id) => row.getValue(id))).map((i) => all[i]);
|
|
608
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- `data` and `visibleIds` stand for the rows and columns.
|
|
609
|
+
}, [virtual, outside, data, visibleIds]);
|
|
610
|
+
const renderRow = (row) => (_jsx(TableRow, { "data-selected": row.getIsSelected() ? "" : undefined, "data-state": row.getIsSelected() ? "selected" : undefined, children: row.getVisibleCells().map((cell) => {
|
|
611
|
+
const meta = cell.column.columnDef.meta;
|
|
612
|
+
return (_jsx(TableCell, { numeric: meta?.numeric, className: meta?.className, children: _jsx(table.FlexRender, { cell: cell }) }, cell.id));
|
|
613
|
+
}) }, row.id));
|
|
614
|
+
/** A row on its way from the server: a placeholder bar in each cell. */
|
|
615
|
+
const loadingRow = (k) => (_jsx(TableRow, { "data-slot": "data-table-loading", "aria-busy": "true", children: visibleColumns.map((column) => (_jsx(TableCell, { children: _jsx(Skeleton, { className: "h-3.5 w-3/5 max-w-40 rounded-checkbox" }) }, column.id))) }, `loading-${k}`));
|
|
616
|
+
const renderOutside = (original, k) => original === undefined ? loadingRow(k) : renderRow(rowAt(k, original));
|
|
617
|
+
const outsideKey = (original, k) => original === undefined ? `loading-${k}` : idAt(k, original);
|
|
618
|
+
const empty = outside ? outsideRows.length === 0 : !rows.length;
|
|
619
|
+
const groupHeader = (group) => {
|
|
620
|
+
const groupCell = groupBy ? group.getAllCellsByColumnId()[groupBy] : undefined;
|
|
621
|
+
return (_jsx(TableGroupHeader, { colSpan: visibleColumnCount, count: group.subRows.length, sticky: stickyGroupHeaders, summary: groupSummary?.({
|
|
622
|
+
value: group.groupingValue,
|
|
623
|
+
rows: group.subRows.map((row) => row.original),
|
|
624
|
+
}), children: groupCell ? _jsx(table.FlexRender, { cell: groupCell }) : String(group.groupingValue) }));
|
|
625
|
+
};
|
|
626
|
+
return (_jsxs("div", { "data-slot": "data-table", "data-dense": dense ? "" : undefined, "aria-busy": (server && cache.pending.size > 0) || undefined, "data-variant": variant, className: cn("flex w-full min-w-0 flex-col", dense ? "gap-3" : "gap-4", className), ...props, children: [withSelection ? (_jsx("span", { id: selectRowLabelId, hidden: true, children: text.selectRow })) : null, searchable || columnToggle || toolbar ? (_jsxs("div", { "data-slot": "data-table-toolbar", "data-collapse-row": "", className: cn("flex flex-wrap items-center gap-2", variant === "plain" && "px-6"), children: [searchable ? (_jsxs("div", { "data-slot": "data-table-search",
|
|
627
|
+
// Its real minimum, for the collapse row (data.css lets it lend room while a fold runs).
|
|
628
|
+
className: "relative w-full max-w-72 min-w-40 flex-1 [--collapse-min:10rem]", children: [_jsx("label", { htmlFor: searchId, className: "sr-only", children: searchPlaceholder.replace(/\s*…$/, "") }), _jsx(SearchIcon, { "aria-hidden": true, className: cn("pointer-events-none absolute top-1/2 size-4 -translate-y-1/2 text-muted-foreground", dense ? "start-2.5" : "start-3") }), _jsx(Input, { id: searchId, type: "search", size: size, value: typed, placeholder: searchPlaceholder, onChange: (event) => {
|
|
629
|
+
setTyped(event.currentTarget.value);
|
|
630
|
+
table.setPageIndex(0);
|
|
631
|
+
}, className: dense ? "ps-8" : "ps-9" })] })) : null, _jsxs("div", { className: "ms-auto flex items-center gap-2", children: [toolbar, columnToggle && hideableColumns.length > 0 ? (_jsxs(Menu, { children: [_jsxs(MenuTrigger, { render: _jsx(Button, { variant: "secondary", size: size, collapsible: true }), children: [_jsx(Columns3Icon, {}), text.columns] }), _jsx(MenuContent, { align: "end", className: "min-w-48", children: _jsxs(MenuGroup, { children: [_jsx(MenuGroupLabel, { children: text.showColumns }), hideableColumns.map((column) => (_jsx(MenuCheckboxItem, { checked: column.getIsVisible(), onCheckedChange: (checked) => column.toggleVisibility(checked), children: columnLabel(column) }, column.id)))] }) })] })) : null] })] })) : null, _jsxs(Table, { dense: dense, variant: variant, fit: fit, "aria-label": caption ? undefined : label, containerProps: tableContainerProps, children: [caption ? _jsx(TableCaption, { children: caption }) : null, _jsx(TableHeader, { children: table.getHeaderGroups().map((group) => (_jsx(TableRow, { children: group.headers.map((header) => {
|
|
632
|
+
const column = header.column;
|
|
633
|
+
const meta = column.columnDef.meta;
|
|
634
|
+
const sorted = column.getIsSorted();
|
|
635
|
+
const canSort = column.getCanSort();
|
|
636
|
+
return (_jsx(TableHead, { colSpan: header.colSpan, numeric: meta?.numeric, align: meta?.align, priority: meta?.priority, inline: meta?.inline, minWidth: meta?.minWidth, width: meta?.width, titleColumn: column.id === titleColumnId, "aria-sort": sorted === "asc" ? "ascending" : sorted === "desc" ? "descending" : undefined, className: meta?.className, children: header.isPlaceholder ? null : canSort ? (_jsxs("button", { type: "button", "data-slot": "data-table-sort", "data-sorted": sorted || undefined, onClick: column.getToggleSortingHandler(), className: cn("group/sort inline-flex min-h-(--control-h-sm) cursor-pointer items-center gap-1.5 rounded-item material-row px-2 font-mono text-[12px] tracking-[0.18em] uppercase focus-ring select-none", meta?.numeric ? "-me-2 flex-row-reverse" : "-ms-2"), children: [_jsx("span", { className: cn("transition-colors duration-(--duration) ease-(--ease)", sorted
|
|
637
|
+
? "text-foreground"
|
|
638
|
+
: "text-muted-foreground group-hover/sort:text-foreground"), children: _jsx(table.FlexRender, { header: header }) }), _jsx(SortIcon, { direction: sorted })] })) : (_jsx(table.FlexRender, { header: header })) }, header.id));
|
|
639
|
+
}) }, group.id))) }), empty ? (_jsx(TableBody, { children: _jsx(TableRow, { "data-slot": "data-table-empty", className: "hover:bg-transparent", children: _jsx(TableCell, { colSpan: visibleColumnCount, className: "h-24 text-center text-sm text-muted-foreground", children: emptyMessage }) }) })) : virtual && outside ? (_jsx(TableVirtualBody, { rows: outsideRows, getRowKey: outsideKey, renderRow: renderOutside, scrollResetKey: search, onRangeChange: server ? (from, to) => load(pageStart + from, pageStart + to) : undefined })) : outside ? (_jsx(TableBody, { children: outsideRows.map(renderOutside) })) : virtual ? (_jsx(TableVirtualBody, { ...(grouped
|
|
640
|
+
? {
|
|
641
|
+
groups: rows.map((group) => ({
|
|
642
|
+
key: group.id,
|
|
643
|
+
header: groupHeader(group),
|
|
644
|
+
rows: group.subRows,
|
|
645
|
+
open: !closedGroups.has(group.id),
|
|
646
|
+
onOpenChange: (open) => setGroupOpen(group.id, open),
|
|
647
|
+
})),
|
|
648
|
+
}
|
|
649
|
+
: { rows }), getRowKey: rowKeyOf, renderRow: renderRow, sizeRows: sizeRows, scrollResetKey: search })) : grouped ? (rows.map((group) => (_jsxs(TableGroup, { open: !closedGroups.has(group.id), onOpenChange: (open) => setGroupOpen(group.id, open), children: [groupHeader(group), group.subRows.map(renderRow)] }, group.id)))) : (_jsx(TableBody, { children: rows.map(renderRow) }))] }), _jsxs("div", { "data-slot": "data-table-footer", className: cn("flex flex-wrap items-center justify-between gap-x-6 gap-y-3 font-mono text-xs text-muted-foreground tabular-nums", variant === "plain" && "px-6"), children: [_jsx("div", { "aria-live": "polite", children: server && served.error ? (_jsxs("span", { "data-slot": "data-table-error", className: "flex items-center gap-2", children: [text.loadError, _jsx(Button, { variant: "link", size: "sm", onClick: () => {
|
|
650
|
+
setServed((old) => ({ ...old, error: null }));
|
|
651
|
+
load(...lastRange.current);
|
|
652
|
+
}, children: text.retry })] })) : withSelection ? (text.selected(selectedCount, server ? (served.total ?? 0) : data.length)) : null }), grouped ? (_jsx("span", { "data-slot": "data-table-count", "aria-live": "polite", children: text.groupCount(leafRowCount, rows.length) })) : (_jsxs("div", { className: "flex flex-wrap items-center gap-x-5 gap-y-2", children: [pageSizes.length > 1 ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { id: `${searchId}-rows`, children: text.rowsPerPage }), _jsxs(Select, { value: currentPageSize, onValueChange: (value) => value != null && table.setPageSize(Number(value)), items: pageSizes.map((n) => ({ value: n, label: String(n) })), children: [_jsx(SelectTrigger, { size: "sm", "aria-labelledby": `${searchId}-rows`, className: "w-auto min-w-0 gap-2 font-mono tabular-nums", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: pageSizes.map((n) => (_jsx(SelectItem, { value: n, className: "font-mono tabular-nums", children: n }, n))) })] })] })) : null, _jsx("span", { "data-slot": "data-table-count", "aria-live": "polite", children: text.range(first, last, total) }), _jsxs("div", { className: "flex items-center gap-1.5", children: [_jsx(Button, { variant: "secondary", size: size, "aria-label": text.previous, disabled: !table.getCanPreviousPage(),
|
|
653
|
+
// Keeps focus on the button at the first and last page, as Pagination does.
|
|
654
|
+
focusableWhenDisabled: true, onClick: () => table.previousPage(), className: dense ? "min-w-(--control-h-sm) px-2" : "min-w-(--control-h) px-2.5", children: _jsx(ChevronLeftIcon, { className: "rtl:-scale-x-100" }) }), _jsx(Button, { variant: "secondary", size: size, "aria-label": text.next, disabled: !table.getCanNextPage(), focusableWhenDisabled: true, onClick: () => table.nextPage(), className: dense ? "min-w-(--control-h-sm) px-2" : "min-w-(--control-h) px-2.5", children: _jsx(ChevronRightIcon, { className: "rtl:-scale-x-100" }) })] })] }))] })] }));
|
|
655
|
+
}
|