@techsio/ui-kit 0.56.1 → 0.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +128 -133
- package/dist/atoms/action-icon.js +9 -8
- package/dist/atoms/button.js +78 -18
- package/dist/atoms/checkbox.js +77 -17
- package/dist/atoms/hotkeys.js +26 -7
- package/dist/atoms/icon.js +5 -5
- package/dist/atoms/image.js +107 -2
- package/dist/atoms/input.js +57 -9
- package/dist/atoms/label.js +13 -4
- package/dist/atoms/link-button.js +14 -12
- package/dist/atoms/link.js +18 -4
- package/dist/atoms/numeric-input.js +293 -76
- package/dist/atoms/rating.js +306 -73
- package/dist/atoms/skeleton.js +18 -14
- package/dist/atoms/status-text.js +31 -18
- package/dist/atoms/textarea.js +59 -12
- package/dist/atoms/tooltip.js +64 -43
- package/dist/hotkeys.js +1 -0
- package/dist/internal/choice-control.js +173 -0
- package/dist/internal/combobox-query-sync.js +11 -0
- package/dist/internal/date-picker-coordinator.js +56 -40
- package/dist/internal/date-picker-dom.js +44 -0
- package/dist/internal/date-picker-input.js +30 -0
- package/dist/internal/described-by.js +23 -18
- package/dist/internal/form-control-lifecycle.js +122 -0
- package/dist/internal/molecules/command.context.js +1 -0
- package/dist/internal/molecules/drawer.context.js +1 -0
- package/dist/internal/molecules/vertical-navigation.context.js +1 -0
- package/dist/internal/molecules/vertical-navigation.styles.js +9 -2
- package/dist/internal/numeric-input-editing.js +87 -0
- package/dist/internal/organisms/sidebar.context.js +1 -0
- package/dist/internal/organisms/sidebar.focus.js +1 -0
- package/dist/internal/overlay-portal.js +72 -0
- package/dist/internal/reduced-motion.js +1 -0
- package/dist/internal/use-effective-disabled.js +8 -0
- package/dist/molecules/accordion.js +44 -30
- package/dist/molecules/availability-status.js +1 -0
- package/dist/molecules/breadcrumb.js +11 -11
- package/dist/molecules/carousel.js +279 -97
- package/dist/molecules/cascade-select.js +327 -81
- package/dist/molecules/chart.js +276 -38
- package/dist/molecules/color-select.js +181 -62
- package/dist/molecules/combobox.js +535 -182
- package/dist/molecules/command.js +2 -1
- package/dist/molecules/date-picker.js +571 -119
- package/dist/molecules/dialog.js +81 -47
- package/dist/molecules/drawer.js +54 -5
- package/dist/molecules/file-upload.js +373 -37
- package/dist/molecules/form-checkbox.js +65 -22
- package/dist/molecules/form-error-summary.js +29 -5
- package/dist/molecules/form-input.js +26 -30
- package/dist/molecules/form-numeric-input.js +11 -9
- package/dist/molecules/form-textarea.js +26 -23
- package/dist/molecules/menu.js +170 -47
- package/dist/molecules/pagination.js +100 -28
- package/dist/molecules/phone-input.js +172 -37
- package/dist/molecules/popover.js +53 -26
- package/dist/molecules/price-block.js +1 -0
- package/dist/molecules/product-card.js +23 -18
- package/dist/molecules/quantity-field.js +4 -2
- package/dist/molecules/radio-card.js +102 -30
- package/dist/molecules/radio-group.js +108 -31
- package/dist/molecules/search-form.js +116 -13
- package/dist/molecules/select.js +226 -81
- package/dist/molecules/slider.js +141 -30
- package/dist/molecules/steps.js +181 -50
- package/dist/molecules/switch.js +85 -20
- package/dist/molecules/tabs.js +227 -31
- package/dist/molecules/toast.js +146 -51
- package/dist/molecules/totals-summary.js +2 -1
- package/dist/molecules/tour.js +9 -5
- package/dist/molecules/tree-view.js +255 -109
- package/dist/molecules/vertical-navigation.js +8 -4
- package/dist/organisms/data-table.fields.js +25 -5
- package/dist/organisms/data-table.helpers.js +6 -2
- package/dist/organisms/data-table.js +580 -151
- package/dist/organisms/footer.js +18 -11
- package/dist/organisms/gallery.js +61 -24
- package/dist/organisms/header.js +106 -32
- package/dist/organisms/line-item.js +1 -0
- package/dist/organisms/sidebar.js +1 -0
- package/dist/organisms/table.js +22 -7
- package/dist/src/atoms/action-icon.d.ts +10 -10
- package/dist/src/atoms/action-icon.d.ts.map +1 -1
- package/dist/src/atoms/badge.d.ts +3 -3
- package/dist/src/atoms/badge.d.ts.map +1 -1
- package/dist/src/atoms/button.d.ts +35 -24
- package/dist/src/atoms/button.d.ts.map +1 -1
- package/dist/src/atoms/checkbox.d.ts +6 -5
- package/dist/src/atoms/checkbox.d.ts.map +1 -1
- package/dist/src/atoms/hotkeys.d.ts +3 -2
- package/dist/src/atoms/hotkeys.d.ts.map +1 -1
- package/dist/src/atoms/icon.d.ts +18 -17
- package/dist/src/atoms/icon.d.ts.map +1 -1
- package/dist/src/atoms/image.d.ts +14 -6
- package/dist/src/atoms/image.d.ts.map +1 -1
- package/dist/src/atoms/input.d.ts +23 -14
- package/dist/src/atoms/input.d.ts.map +1 -1
- package/dist/src/atoms/label.d.ts +4 -4
- package/dist/src/atoms/label.d.ts.map +1 -1
- package/dist/src/atoms/link-button.d.ts +54 -31
- package/dist/src/atoms/link-button.d.ts.map +1 -1
- package/dist/src/atoms/link.d.ts +30 -9
- package/dist/src/atoms/link.d.ts.map +1 -1
- package/dist/src/atoms/numeric-input.d.ts +23 -19
- package/dist/src/atoms/numeric-input.d.ts.map +1 -1
- package/dist/src/atoms/rating.d.ts +54 -26
- package/dist/src/atoms/rating.d.ts.map +1 -1
- package/dist/src/atoms/skeleton.d.ts +9 -9
- package/dist/src/atoms/skeleton.d.ts.map +1 -1
- package/dist/src/atoms/status-text.d.ts +21 -13
- package/dist/src/atoms/status-text.d.ts.map +1 -1
- package/dist/src/atoms/textarea.d.ts +22 -20
- package/dist/src/atoms/textarea.d.ts.map +1 -1
- package/dist/src/atoms/tooltip.d.ts +5 -5
- package/dist/src/atoms/tooltip.d.ts.map +1 -1
- package/dist/src/hotkeys.d.ts +1 -1
- package/dist/src/hotkeys.d.ts.map +1 -1
- package/dist/src/internal/choice-control.d.ts +18 -0
- package/dist/src/internal/choice-control.d.ts.map +1 -0
- package/dist/src/internal/combobox-query-sync.d.ts +4 -0
- package/dist/src/internal/combobox-query-sync.d.ts.map +1 -0
- package/dist/src/internal/date-picker-coordinator.d.ts +7 -1
- package/dist/src/internal/date-picker-coordinator.d.ts.map +1 -1
- package/dist/src/internal/date-picker-dom.d.ts +10 -0
- package/dist/src/internal/date-picker-dom.d.ts.map +1 -0
- package/dist/src/internal/date-picker-input.d.ts +7 -0
- package/dist/src/internal/date-picker-input.d.ts.map +1 -0
- package/dist/src/internal/described-by.d.ts +7 -1
- package/dist/src/internal/described-by.d.ts.map +1 -1
- package/dist/src/internal/form-control-lifecycle.d.ts +22 -0
- package/dist/src/internal/form-control-lifecycle.d.ts.map +1 -0
- package/dist/src/internal/molecules/vertical-navigation.context.d.ts +1 -1
- package/dist/src/internal/molecules/vertical-navigation.context.d.ts.map +1 -1
- package/dist/src/internal/molecules/vertical-navigation.styles.d.ts +21 -0
- package/dist/src/internal/molecules/vertical-navigation.styles.d.ts.map +1 -1
- package/dist/src/internal/numeric-input-editing.d.ts +13 -0
- package/dist/src/internal/numeric-input-editing.d.ts.map +1 -0
- package/dist/src/internal/overlay-portal.d.ts +18 -0
- package/dist/src/internal/overlay-portal.d.ts.map +1 -0
- package/dist/src/internal/use-effective-disabled.d.ts +4 -0
- package/dist/src/internal/use-effective-disabled.d.ts.map +1 -0
- package/dist/src/molecules/accordion.d.ts +25 -19
- package/dist/src/molecules/accordion.d.ts.map +1 -1
- package/dist/src/molecules/availability-status.d.ts +4 -1
- package/dist/src/molecules/availability-status.d.ts.map +1 -1
- package/dist/src/molecules/breadcrumb.d.ts +2 -2
- package/dist/src/molecules/breadcrumb.d.ts.map +1 -1
- package/dist/src/molecules/carousel.d.ts +51 -52
- package/dist/src/molecules/carousel.d.ts.map +1 -1
- package/dist/src/molecules/cascade-select.d.ts +23 -8
- package/dist/src/molecules/cascade-select.d.ts.map +1 -1
- package/dist/src/molecules/chart.d.ts +7 -1
- package/dist/src/molecules/chart.d.ts.map +1 -1
- package/dist/src/molecules/color-select.d.ts +19 -3
- package/dist/src/molecules/color-select.d.ts.map +1 -1
- package/dist/src/molecules/combobox.d.ts +23 -5
- package/dist/src/molecules/combobox.d.ts.map +1 -1
- package/dist/src/molecules/command.d.ts +1 -1
- package/dist/src/molecules/date-picker.d.ts +7 -3
- package/dist/src/molecules/date-picker.d.ts.map +1 -1
- package/dist/src/molecules/dialog.d.ts +7 -3
- package/dist/src/molecules/dialog.d.ts.map +1 -1
- package/dist/src/molecules/drawer.d.ts +4 -4
- package/dist/src/molecules/drawer.d.ts.map +1 -1
- package/dist/src/molecules/file-upload.d.ts +11 -6
- package/dist/src/molecules/file-upload.d.ts.map +1 -1
- package/dist/src/molecules/form-checkbox.d.ts +7 -2
- package/dist/src/molecules/form-checkbox.d.ts.map +1 -1
- package/dist/src/molecules/form-error-summary.d.ts +4 -3
- package/dist/src/molecules/form-error-summary.d.ts.map +1 -1
- package/dist/src/molecules/form-input.d.ts +5 -6
- package/dist/src/molecules/form-input.d.ts.map +1 -1
- package/dist/src/molecules/form-numeric-input.d.ts +5 -5
- package/dist/src/molecules/form-numeric-input.d.ts.map +1 -1
- package/dist/src/molecules/form-textarea.d.ts +5 -6
- package/dist/src/molecules/form-textarea.d.ts.map +1 -1
- package/dist/src/molecules/menu.d.ts +17 -3
- package/dist/src/molecules/menu.d.ts.map +1 -1
- package/dist/src/molecules/pagination.d.ts +1 -1
- package/dist/src/molecules/pagination.d.ts.map +1 -1
- package/dist/src/molecules/phone-input.d.ts +4 -1
- package/dist/src/molecules/phone-input.d.ts.map +1 -1
- package/dist/src/molecules/popover.d.ts +7 -1
- package/dist/src/molecules/popover.d.ts.map +1 -1
- package/dist/src/molecules/price-block.d.ts +1 -1
- package/dist/src/molecules/price-block.d.ts.map +1 -1
- package/dist/src/molecules/product-card.d.ts +20 -25
- package/dist/src/molecules/product-card.d.ts.map +1 -1
- package/dist/src/molecules/quantity-field.d.ts +1 -1
- package/dist/src/molecules/quantity-field.d.ts.map +1 -1
- package/dist/src/molecules/radio-card.d.ts +10 -3
- package/dist/src/molecules/radio-card.d.ts.map +1 -1
- package/dist/src/molecules/radio-group.d.ts +15 -6
- package/dist/src/molecules/radio-group.d.ts.map +1 -1
- package/dist/src/molecules/search-form.d.ts +37 -12
- package/dist/src/molecules/search-form.d.ts.map +1 -1
- package/dist/src/molecules/select.d.ts +34 -29
- package/dist/src/molecules/select.d.ts.map +1 -1
- package/dist/src/molecules/slider.d.ts +23 -2
- package/dist/src/molecules/slider.d.ts.map +1 -1
- package/dist/src/molecules/steps.d.ts +30 -10
- package/dist/src/molecules/steps.d.ts.map +1 -1
- package/dist/src/molecules/switch.d.ts +54 -33
- package/dist/src/molecules/switch.d.ts.map +1 -1
- package/dist/src/molecules/tabs.d.ts +11 -11
- package/dist/src/molecules/tabs.d.ts.map +1 -1
- package/dist/src/molecules/toast.d.ts +25 -13
- package/dist/src/molecules/toast.d.ts.map +1 -1
- package/dist/src/molecules/totals-summary.d.ts +1 -1
- package/dist/src/molecules/totals-summary.d.ts.map +1 -1
- package/dist/src/molecules/tour.d.ts +1 -1
- package/dist/src/molecules/tour.d.ts.map +1 -1
- package/dist/src/molecules/tree-view.d.ts +16 -20
- package/dist/src/molecules/tree-view.d.ts.map +1 -1
- package/dist/src/molecules/vertical-navigation.d.ts +2 -2
- package/dist/src/molecules/vertical-navigation.d.ts.map +1 -1
- package/dist/src/organisms/data-table.d.ts +24 -3
- package/dist/src/organisms/data-table.d.ts.map +1 -1
- package/dist/src/organisms/data-table.fields.d.ts +4 -1
- package/dist/src/organisms/data-table.fields.d.ts.map +1 -1
- package/dist/src/organisms/data-table.helpers.d.ts +5 -12
- package/dist/src/organisms/data-table.helpers.d.ts.map +1 -1
- package/dist/src/organisms/footer.d.ts +5 -5
- package/dist/src/organisms/footer.d.ts.map +1 -1
- package/dist/src/organisms/gallery.d.ts +11 -9
- package/dist/src/organisms/gallery.d.ts.map +1 -1
- package/dist/src/organisms/header.d.ts +24 -22
- package/dist/src/organisms/header.d.ts.map +1 -1
- package/dist/src/organisms/table.d.ts +14 -14
- package/dist/src/organisms/table.d.ts.map +1 -1
- package/dist/src/templates/accordion.d.ts +8 -6
- package/dist/src/templates/accordion.d.ts.map +1 -1
- package/dist/src/templates/breadcrumb.d.ts +1 -1
- package/dist/src/templates/breadcrumb.d.ts.map +1 -1
- package/dist/src/templates/carousel.d.ts +3 -3
- package/dist/src/templates/carousel.d.ts.map +1 -1
- package/dist/src/templates/facet-filter-panel.d.ts +9 -3
- package/dist/src/templates/facet-filter-panel.d.ts.map +1 -1
- package/dist/src/templates/gallery.d.ts +2 -2
- package/dist/src/templates/gallery.d.ts.map +1 -1
- package/dist/src/templates/numeric-input.d.ts +1 -1
- package/dist/src/templates/numeric-input.d.ts.map +1 -1
- package/dist/src/templates/popover.d.ts +4 -2
- package/dist/src/templates/popover.d.ts.map +1 -1
- package/dist/src/templates/product-card.d.ts +12 -4
- package/dist/src/templates/product-card.d.ts.map +1 -1
- package/dist/src/templates/search-suggestions.d.ts +1 -1
- package/dist/src/templates/select.d.ts +7 -2
- package/dist/src/templates/select.d.ts.map +1 -1
- package/dist/src/templates/tabs.d.ts +8 -7
- package/dist/src/templates/tabs.d.ts.map +1 -1
- package/dist/src/theme/theme-config.d.ts +9 -16
- package/dist/src/theme/theme-config.d.ts.map +1 -1
- package/dist/src/theme/theme-provider.d.ts +16 -21
- package/dist/src/theme/theme-provider.d.ts.map +1 -1
- package/dist/src/theme/theme-toggle.d.ts.map +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/templates/accordion.js +3 -1
- package/dist/templates/breadcrumb.js +11 -4
- package/dist/templates/carousel.js +3 -6
- package/dist/templates/facet-filter-panel.js +121 -52
- package/dist/templates/gallery.js +6 -2
- package/dist/templates/numeric-input.js +6 -1
- package/dist/templates/popover.js +6 -1
- package/dist/templates/product-card.js +52 -26
- package/dist/templates/select.js +6 -1
- package/dist/templates/tabs.js +4 -2
- package/dist/theme/theme-config.js +8 -16
- package/dist/theme/theme-provider.js +89 -63
- package/dist/theme/theme-toggle.js +17 -9
- package/dist/utils.js +11 -1
- package/package.json +9 -5
- package/src/tokens/_base.css +4 -3
- package/src/tokens/_business-atoms.css +103 -0
- package/src/tokens/_foundation-overrides.css +251 -0
- package/src/tokens/_reset.css +10 -10
- package/src/tokens/_scheme-scopes.css +4144 -0
- package/src/tokens/_semantic.css +1 -23
- package/src/tokens/_tokens-base.css +36 -32
- package/src/tokens/_typography.css +2 -1
- package/src/tokens/components/_form-control.css +149 -6
- package/src/tokens/components/_popup-surface.css +15 -29
- package/src/tokens/components/atoms/_action-icon.css +49 -0
- package/src/tokens/components/atoms/_button.css +67 -0
- package/src/tokens/components/atoms/_checkbox.css +47 -4
- package/src/tokens/components/atoms/_hotkeys.css +2 -0
- package/src/tokens/components/atoms/_icon.css +60 -7
- package/src/tokens/components/atoms/_image.css +18 -0
- package/src/tokens/components/atoms/_input.css +20 -0
- package/src/tokens/components/atoms/_label.css +3 -7
- package/src/tokens/components/atoms/_link.css +47 -5
- package/src/tokens/components/atoms/_numeric-input.css +111 -2
- package/src/tokens/components/atoms/_rating.css +55 -6
- package/src/tokens/components/atoms/_skeleton.css +12 -2
- package/src/tokens/components/atoms/_status-text.css +35 -5
- package/src/tokens/components/atoms/_textarea.css +32 -3
- package/src/tokens/components/atoms/_tooltip.css +25 -0
- package/src/tokens/components/molecules/_accordion.css +46 -5
- package/src/tokens/components/molecules/_breadcrumb.css +15 -4
- package/src/tokens/components/molecules/_carousel.css +67 -0
- package/src/tokens/components/molecules/_cascade-select.css +104 -0
- package/src/tokens/components/molecules/_chart.css +12 -14
- package/src/tokens/components/molecules/_color-select.css +21 -0
- package/src/tokens/components/molecules/_combobox.css +81 -0
- package/src/tokens/components/molecules/_command.css +1 -0
- package/src/tokens/components/molecules/_date-picker.css +66 -10
- package/src/tokens/components/molecules/_dialog.css +36 -4
- package/src/tokens/components/molecules/_drawer.css +39 -3
- package/src/tokens/components/molecules/_file-upload.css +16 -1
- package/src/tokens/components/molecules/_menu.css +17 -0
- package/src/tokens/components/molecules/_pagination.css +19 -0
- package/src/tokens/components/molecules/_phone-input.css +20 -5
- package/src/tokens/components/molecules/_popover.css +34 -0
- package/src/tokens/components/molecules/_product-card.css +49 -0
- package/src/tokens/components/molecules/_radio-card.css +35 -0
- package/src/tokens/components/molecules/_radio-group.css +8 -0
- package/src/tokens/components/molecules/_select.css +33 -0
- package/src/tokens/components/molecules/_slider.css +5 -0
- package/src/tokens/components/molecules/_steps.css +52 -0
- package/src/tokens/components/molecules/_switch.css +59 -10
- package/src/tokens/components/molecules/_tabs.css +61 -3
- package/src/tokens/components/molecules/_toast.css +60 -0
- package/src/tokens/components/molecules/_totals-summary.css +22 -22
- package/src/tokens/components/molecules/_tour.css +16 -1
- package/src/tokens/components/molecules/_tree-view.css +27 -3
- package/src/tokens/components/molecules/_vertical-navigation.css +21 -3
- package/src/tokens/components/organisms/_data-table.css +97 -0
- package/src/tokens/components/organisms/_footer.css +9 -0
- package/src/tokens/components/organisms/_gallery.css +11 -0
- package/src/tokens/components/organisms/_header.css +22 -0
- package/src/tokens/components/organisms/_sidebar.css +1 -1
- package/src/tokens/components/organisms/_table.css +31 -0
- package/src/tokens/components/templates/_facet-filter-panel.css +11 -1
- package/src/tokens/figma/akros/variables.css +6 -6
- package/src/tokens/figma/brand-overrides.css +162 -57
- package/src/tokens/figma/business/variables.css +6 -6
- package/src/tokens/figma/cyber/variables.css +115 -38
- package/src/tokens/figma/cyber-dark/variables.css +115 -38
- package/src/tokens/figma/dark/variables.css +4 -4
- package/src/tokens/figma/light/variables.css +43 -40
- package/src/tokens/figma/{neo → n1}/variables.css +114 -114
- package/src/tokens/figma/variables.css +639 -240
- package/src/tokens/theme.css +24 -4
- package/src/tokens/_colors.css +0 -5
- package/src/tokens/figma/neo-dark/variables.css +0 -457
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { CollisionPriority, CollisionType } from "@dnd-kit/abstract";
|
|
3
4
|
import { RestrictToHorizontalAxis, RestrictToVerticalAxis } from "@dnd-kit/abstract/modifiers";
|
|
@@ -16,6 +17,7 @@ import { Button } from "../atoms/button.js";
|
|
|
16
17
|
import { Checkbox } from "../atoms/checkbox.js";
|
|
17
18
|
import { Icon } from "../atoms/icon.js";
|
|
18
19
|
import { Skeleton } from "../atoms/skeleton.js";
|
|
20
|
+
import { StatusText } from "../atoms/status-text.js";
|
|
19
21
|
import { Menu } from "../molecules/menu.js";
|
|
20
22
|
import { Pagination } from "../molecules/pagination.js";
|
|
21
23
|
import { SearchForm } from "../molecules/search-form.js";
|
|
@@ -26,27 +28,34 @@ import { Table } from "./table.js";
|
|
|
26
28
|
const dataTableVariants = tv({
|
|
27
29
|
slots: {
|
|
28
30
|
wrapper: [
|
|
29
|
-
"flex w-full flex-col overflow-hidden rounded-data-table",
|
|
31
|
+
"isolate flex w-full flex-col overflow-hidden rounded-data-table",
|
|
30
32
|
"border-(length:--border-width-data-table) border-data-table-border"
|
|
31
33
|
],
|
|
32
34
|
toolbar: [
|
|
33
|
-
"flex items-center justify-between gap-data-table-toolbar",
|
|
35
|
+
"flex flex-wrap items-center justify-between gap-data-table-toolbar",
|
|
34
36
|
"bg-data-table-toolbar-bg text-data-table-toolbar-fg",
|
|
35
37
|
"p-data-table-toolbar",
|
|
36
38
|
"border-b-(length:--border-width-data-table) border-data-table-border"
|
|
37
39
|
],
|
|
38
40
|
toolbarSearch: [
|
|
39
|
-
"min-w-0 flex-1"
|
|
41
|
+
"min-w-0 flex-1 basis-data-table-search"
|
|
40
42
|
],
|
|
41
43
|
toolbarActions: [
|
|
42
|
-
"flex
|
|
44
|
+
"flex min-w-0 max-w-full flex-wrap items-center justify-end gap-data-table-toolbar"
|
|
43
45
|
],
|
|
44
46
|
scroll: [
|
|
45
|
-
"relative w-full overflow-auto"
|
|
47
|
+
"@container/data-table relative w-full overflow-auto"
|
|
46
48
|
],
|
|
47
49
|
headerLabel: [
|
|
48
50
|
"inline-flex items-center gap-100 whitespace-nowrap"
|
|
49
51
|
],
|
|
52
|
+
cellContent: [
|
|
53
|
+
"min-w-0 max-w-full"
|
|
54
|
+
],
|
|
55
|
+
columnDropIndicator: [
|
|
56
|
+
"after:pointer-events-none after:absolute after:inset-y-0 after:border-data-table-sort-icon-fg-active after:border-s-2",
|
|
57
|
+
"data-[drop-side=end]:after:inset-e-0 data-[drop-side=start]:after:inset-s-0"
|
|
58
|
+
],
|
|
50
59
|
sortButton: [
|
|
51
60
|
"inline-flex items-center gap-100 whitespace-nowrap",
|
|
52
61
|
"cursor-pointer select-none bg-transparent text-start",
|
|
@@ -76,17 +85,19 @@ const dataTableVariants = tv({
|
|
|
76
85
|
],
|
|
77
86
|
filterCell: [
|
|
78
87
|
"p-data-table-filter-cell",
|
|
79
|
-
"min-w-fit",
|
|
80
88
|
"border-b-(length:--border-width-data-table) border-data-table-border"
|
|
81
89
|
],
|
|
90
|
+
filterViewport: [
|
|
91
|
+
"data-table-filter-viewport"
|
|
92
|
+
],
|
|
82
93
|
filterControl: [
|
|
83
|
-
"
|
|
94
|
+
"data-table-filter-control flex items-center gap-data-table-filter-control"
|
|
84
95
|
],
|
|
85
96
|
editorControl: [
|
|
86
|
-
"flex flex-col gap-data-table-editor"
|
|
97
|
+
"data-table-editor flex min-w-0 max-w-full flex-col gap-data-table-editor"
|
|
87
98
|
],
|
|
88
|
-
|
|
89
|
-
"
|
|
99
|
+
emptyViewport: [
|
|
100
|
+
"data-table-empty-viewport wrap-anywhere min-w-0"
|
|
90
101
|
],
|
|
91
102
|
actionsCell: [
|
|
92
103
|
"flex items-center justify-end gap-100"
|
|
@@ -116,6 +127,14 @@ const dataTableVariants = tv({
|
|
|
116
127
|
true: {
|
|
117
128
|
wrapper: "shadow-data-table-outline"
|
|
118
129
|
}
|
|
130
|
+
},
|
|
131
|
+
fixedLayout: {
|
|
132
|
+
true: {
|
|
133
|
+
headerLabel: "min-w-0 max-w-full whitespace-normal",
|
|
134
|
+
sortButton: "wrap-anywhere min-w-0 max-w-full whitespace-normal",
|
|
135
|
+
sortIcon: "shrink-0",
|
|
136
|
+
cellContent: "wrap-anywhere"
|
|
137
|
+
}
|
|
119
138
|
}
|
|
120
139
|
}
|
|
121
140
|
});
|
|
@@ -332,6 +351,7 @@ function useDataTableContext() {
|
|
|
332
351
|
return ctx;
|
|
333
352
|
}
|
|
334
353
|
const DEFAULT_TRANSLATIONS = {
|
|
354
|
+
scrollLabel: "Scrollable records",
|
|
335
355
|
searchPlaceholder: "Search…",
|
|
336
356
|
searchLabel: "Search",
|
|
337
357
|
clearSearchLabel: "Clear search",
|
|
@@ -349,7 +369,14 @@ const DEFAULT_TRANSLATIONS = {
|
|
|
349
369
|
operatorLabels: {},
|
|
350
370
|
editingLabel: "Editing a row — other table controls are locked",
|
|
351
371
|
rangeLabel: ({ start, end, total })=>`${start}–${end} of ${total}`,
|
|
352
|
-
requiredLabel: "
|
|
372
|
+
requiredLabel: "Enter a value before saving this row.",
|
|
373
|
+
pageLabel: ({ page, pageCount })=>null == pageCount ? `Page ${page}` : `Page ${page} of ${pageCount}`,
|
|
374
|
+
previousPageLabel: "Previous page",
|
|
375
|
+
nextPageLabel: "Next page",
|
|
376
|
+
paginationPendingLabel: "Page unavailable — requesting an available page.",
|
|
377
|
+
invalidRangeLabel: "Enter valid dates with the start on or before the end.",
|
|
378
|
+
savePendingLabel: "Saving row…",
|
|
379
|
+
saveErrorLabel: "Could not save this row. Your changes are kept; try Save again."
|
|
353
380
|
};
|
|
354
381
|
const SELECTION_COLUMN_ID = "__select";
|
|
355
382
|
const EMPTY_COLUMN_PINNING = {
|
|
@@ -387,7 +414,7 @@ function HeaderSortLabel({ header, styles, enableSorting, locked }) {
|
|
|
387
414
|
const canSort = enableSorting && column.getCanSort();
|
|
388
415
|
const sortDir = column.getIsSorted();
|
|
389
416
|
const label = header.isPlaceholder ? null : flexRender(column.columnDef.header, header.getContext());
|
|
390
|
-
if (!canSort) return /*#__PURE__*/ jsx(Fragment, {
|
|
417
|
+
if (header.isPlaceholder || !canSort) return /*#__PURE__*/ jsx(Fragment, {
|
|
391
418
|
children: label
|
|
392
419
|
});
|
|
393
420
|
let sortIconName = "icon-[mdi--unfold-more-horizontal]";
|
|
@@ -410,7 +437,7 @@ function HeaderSortLabel({ header, styles, enableSorting, locked }) {
|
|
|
410
437
|
]
|
|
411
438
|
});
|
|
412
439
|
}
|
|
413
|
-
function renderCellContent({ cell, column, styles, enableRowReorder, dnd, editor, editorError, editorErrorId, isDragCol, rowLabel }) {
|
|
440
|
+
function renderCellContent({ cell, column, styles, enableRowReorder, dnd, editor, editorError, editorErrorId, size, tableLayout, isDragCol, rowLabel }) {
|
|
414
441
|
if (isDragCol && enableRowReorder && dnd) return /*#__PURE__*/ jsx("button", {
|
|
415
442
|
"aria-label": `Drag to reorder ${rowLabel}`,
|
|
416
443
|
className: styles.dragHandle(),
|
|
@@ -425,17 +452,27 @@ function renderCellContent({ cell, column, styles, enableRowReorder, dnd, editor
|
|
|
425
452
|
if (editor) return /*#__PURE__*/ jsxs("div", {
|
|
426
453
|
className: styles.editorControl(),
|
|
427
454
|
"data-editor-control": "",
|
|
455
|
+
"data-layout": tableLayout,
|
|
456
|
+
"data-type": resolveColumnType(column.columnDef.meta),
|
|
428
457
|
children: [
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
458
|
+
/*#__PURE__*/ jsx("div", {
|
|
459
|
+
className: "data-table-editor-value",
|
|
460
|
+
"data-size": size,
|
|
461
|
+
children: editor
|
|
462
|
+
}),
|
|
463
|
+
editorError ? /*#__PURE__*/ jsx(StatusText, {
|
|
432
464
|
id: editorErrorId,
|
|
433
|
-
|
|
465
|
+
size: size,
|
|
466
|
+
status: "error",
|
|
434
467
|
children: editorError
|
|
435
468
|
}) : null
|
|
436
469
|
]
|
|
437
470
|
});
|
|
438
|
-
|
|
471
|
+
const content = flexRender(column.columnDef.cell, cell.getContext());
|
|
472
|
+
return "fixed" === tableLayout ? /*#__PURE__*/ jsx("div", {
|
|
473
|
+
className: styles.cellContent(),
|
|
474
|
+
children: content
|
|
475
|
+
}) : content;
|
|
439
476
|
}
|
|
440
477
|
function stickyRowOffset(stickyHeader, offsets, groupIndex) {
|
|
441
478
|
if (!stickyHeader) return;
|
|
@@ -443,7 +480,8 @@ function stickyRowOffset(stickyHeader, offsets, groupIndex) {
|
|
|
443
480
|
top: offsets[groupIndex] ?? 0
|
|
444
481
|
};
|
|
445
482
|
}
|
|
446
|
-
function DataTableBodyCell({ cell, span, row, styles, columnSizing, enableColumnResizing, enableRowReorder, dnd, editor, editorError, editorErrorId, indentColumnId, rowLabel }) {
|
|
483
|
+
function DataTableBodyCell({ cell, span, row, styles, columnSizing, enableColumnResizing, enableRowReorder, dnd, editor, editorError, editorErrorId, size, indentColumnId, rowLabel, pinningStyle }) {
|
|
484
|
+
const tableLayout = useContext(FieldTableLayoutContext);
|
|
447
485
|
const column = cell.column;
|
|
448
486
|
const pinned = column.getIsPinned();
|
|
449
487
|
const isDragCol = column.id === DRAG_COLUMN_ID;
|
|
@@ -458,6 +496,7 @@ function DataTableBodyCell({ cell, span, row, styles, columnSizing, enableColumn
|
|
|
458
496
|
rowSpan: span?.rowSpan,
|
|
459
497
|
style: {
|
|
460
498
|
...getPinningStyles(column),
|
|
499
|
+
...pinningStyle,
|
|
461
500
|
...getColumnSizeStyles(column, enableColumnResizing, columnSizing),
|
|
462
501
|
...indent
|
|
463
502
|
},
|
|
@@ -470,31 +509,46 @@ function DataTableBodyCell({ cell, span, row, styles, columnSizing, enableColumn
|
|
|
470
509
|
editor,
|
|
471
510
|
editorError,
|
|
472
511
|
editorErrorId,
|
|
512
|
+
size,
|
|
513
|
+
tableLayout,
|
|
473
514
|
isDragCol,
|
|
474
515
|
rowLabel
|
|
475
516
|
})
|
|
476
517
|
});
|
|
477
518
|
}
|
|
478
|
-
|
|
519
|
+
const DATE_RANGE_BOUND_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
520
|
+
function validDateRange(value) {
|
|
521
|
+
const validDate = (raw)=>!raw || DATE_RANGE_BOUND_RE.test(raw) && Number.isFinite(Date.parse(`${raw}T00:00:00Z`)) && new Date(`${raw}T00:00:00Z`).toISOString().slice(0, 10) === raw;
|
|
522
|
+
return validDate(value.from) && validDate(value.to) && !(value.from && value.to && value.from > value.to);
|
|
523
|
+
}
|
|
524
|
+
function validateDraft(columns, draft, requiredLabel, invalidRangeLabel) {
|
|
479
525
|
const errors = {};
|
|
480
526
|
for (const column of columns){
|
|
481
527
|
const meta = column.columnDef.meta;
|
|
482
528
|
if (!meta?.editable) continue;
|
|
483
529
|
const value = draft[column.id];
|
|
484
|
-
const
|
|
530
|
+
const dateRange = "dateRange" === resolveColumnType(meta) ? value : void 0;
|
|
531
|
+
const empty = "dateRange" === resolveColumnType(meta) && isBlank(dateRange?.from) && isBlank(dateRange?.to) || isBlank(value) || "number" == typeof value && Number.isNaN(value) || Array.isArray(value) && 0 === value.length;
|
|
485
532
|
if (meta.required && empty) {
|
|
486
533
|
errors[column.id] = requiredLabel;
|
|
487
534
|
continue;
|
|
488
535
|
}
|
|
536
|
+
if (dateRange && !validDateRange(dateRange)) {
|
|
537
|
+
errors[column.id] = invalidRangeLabel;
|
|
538
|
+
continue;
|
|
539
|
+
}
|
|
489
540
|
const message = meta.validate?.(value, draft);
|
|
490
541
|
if (message) errors[column.id] = message;
|
|
491
542
|
}
|
|
492
543
|
return errors;
|
|
493
544
|
}
|
|
494
|
-
function renderExpandedDetailRow({ row, renderExpandedRow, colSpan, instanceId, styles, tintNestedRows }) {
|
|
545
|
+
function renderExpandedDetailRow({ row, renderExpandedRow, colSpan, instanceId, styles, tintNestedRows, rowIndex, virtualIndex, measureElement }) {
|
|
495
546
|
return /*#__PURE__*/ jsx(Table.Row, {
|
|
547
|
+
"aria-rowindex": rowIndex,
|
|
496
548
|
className: tintNestedRows ? "data-table-row-nested-tint" : void 0,
|
|
497
549
|
"data-depth": row.depth + 1,
|
|
550
|
+
"data-index": virtualIndex,
|
|
551
|
+
ref: measureElement,
|
|
498
552
|
children: /*#__PURE__*/ jsx(Table.Cell, {
|
|
499
553
|
colSpan: colSpan,
|
|
500
554
|
children: /*#__PURE__*/ jsx("div", {
|
|
@@ -566,6 +620,8 @@ function buildRowKeyDownHandler(row, onRowClick, blocked) {
|
|
|
566
620
|
function buildRowClickHandler(row, rowOnClick, onRowClick, blocked) {
|
|
567
621
|
return (event)=>{
|
|
568
622
|
rowOnClick?.(event);
|
|
623
|
+
const interactive = event.target.closest?.('button, a[href], input, select, textarea, summary, [contenteditable]:not([contenteditable="false"]), [role="button"], [role="link"], [role="checkbox"], [role="switch"], [role="combobox"], [tabindex]');
|
|
624
|
+
if (event.defaultPrevented || interactive && interactive !== event.currentTarget) return;
|
|
569
625
|
if (onRowClick && !blocked("rowClick")) onRowClick(row, event);
|
|
570
626
|
};
|
|
571
627
|
}
|
|
@@ -588,7 +644,7 @@ function DataTable(props) {
|
|
|
588
644
|
25,
|
|
589
645
|
50,
|
|
590
646
|
100
|
|
591
|
-
], manualSorting, manualFiltering, manualPagination, rowCount, pageCount, onRowClick, onReachEnd, onColumnReorder, onRowReorder, onCellEditCommit, onReady, renderToolbar, toolbarActions, renderEmpty, renderRowActions, renderHeaderFilter, renderExpandedRow, slotProps, translations: translationsProp, estimateRowHeight = 44, reachEndThreshold = 240, enableInlineEdit = false, editingRowId: editingRowIdProp, onEditingRowIdChange, onEditStart, onEditChange, onEditCommit, onEditCancel, onEditValidationError, lockInteractionsWhileEditing = true, onInteractionBlocked, filterRenderers, editorRenderers, stickyActions = true, paginationProps, canEditRow, rowActions, getRowLabel, striped = false, tintNestedRows = false, loading = false, loadingRowCount = 5, loadingMore = false, selectionMode = "multiple", maxSelectedRows, canSelectRow, onSelectionLimitReached } = props;
|
|
647
|
+
], manualSorting, manualFiltering, manualPagination, rowCount, pageCount, hasNextPage, onRowClick, onReachEnd, onColumnReorder, onRowReorder, onCellEditCommit, onReady, renderToolbar, toolbarActions, renderEmpty, renderRowActions, renderHeaderFilter, renderExpandedRow, slotProps, translations: translationsProp, estimateRowHeight = 44, reachEndThreshold = 240, enableInlineEdit = false, editingRowId: editingRowIdProp, onEditingRowIdChange, onEditStart, onEditChange, onEditCommit, onEditCancel, onEditValidationError, lockInteractionsWhileEditing = true, onInteractionBlocked, filterRenderers, editorRenderers, stickyActions = true, paginationProps, canEditRow, rowActions, getRowLabel, striped = false, tintNestedRows = false, loading = false, loadingRowCount = 5, loadingMore = false, selectionMode = "multiple", maxSelectedRows, canSelectRow, onSelectionLimitReached } = props;
|
|
592
648
|
const translations = {
|
|
593
649
|
...DEFAULT_TRANSLATIONS
|
|
594
650
|
};
|
|
@@ -598,11 +654,29 @@ function DataTable(props) {
|
|
|
598
654
|
const outlined = "outline" === variant;
|
|
599
655
|
const effectiveStriped = striped || "striped" === variant;
|
|
600
656
|
const styles = dataTableVariants({
|
|
601
|
-
outlined
|
|
657
|
+
outlined,
|
|
658
|
+
fixedLayout: "fixed" === tableLayout
|
|
602
659
|
});
|
|
603
660
|
const generatedId = useId();
|
|
604
661
|
const instanceId = idProp ?? generatedId;
|
|
605
662
|
const scrollRef = useRef(null);
|
|
663
|
+
const [direction, setDirection] = useState("ltr");
|
|
664
|
+
useIsomorphicLayoutEffect(()=>{
|
|
665
|
+
const element = scrollRef.current;
|
|
666
|
+
if (!element) return;
|
|
667
|
+
const update = ()=>setDirection("rtl" === getComputedStyle(element).direction ? "rtl" : "ltr");
|
|
668
|
+
const observer = new MutationObserver(update);
|
|
669
|
+
for(let ancestor = element; ancestor; ancestor = ancestor.parentElement)observer.observe(ancestor, {
|
|
670
|
+
attributes: true,
|
|
671
|
+
attributeFilter: [
|
|
672
|
+
"dir",
|
|
673
|
+
"class",
|
|
674
|
+
"style"
|
|
675
|
+
]
|
|
676
|
+
});
|
|
677
|
+
update();
|
|
678
|
+
return ()=>observer.disconnect();
|
|
679
|
+
}, []);
|
|
606
680
|
const reachedEndRef = useRef(false);
|
|
607
681
|
const lastReachEndCountRef = useRef(-1);
|
|
608
682
|
const reportedSelectionLimitRef = useRef(null);
|
|
@@ -687,6 +761,15 @@ function DataTable(props) {
|
|
|
687
761
|
draftRef.current = draft;
|
|
688
762
|
const [editErrors, setEditErrors] = useState({});
|
|
689
763
|
const [dirty, setDirty] = useState(false);
|
|
764
|
+
const [savePending, setSavePending] = useState(false);
|
|
765
|
+
const [saveError, setSaveError] = useState();
|
|
766
|
+
const savingRef = useRef(false);
|
|
767
|
+
useEffect(()=>{
|
|
768
|
+
if (savePending || saveError) scrollRef.current?.querySelector('[aria-label="Save row"]')?.focus();
|
|
769
|
+
}, [
|
|
770
|
+
saveError,
|
|
771
|
+
savePending
|
|
772
|
+
]);
|
|
690
773
|
const isEditing = null != editingRowId;
|
|
691
774
|
const locked = isEditing && lockInteractionsWhileEditing;
|
|
692
775
|
const blocked = (action)=>{
|
|
@@ -702,6 +785,7 @@ function DataTable(props) {
|
|
|
702
785
|
const selectionLimitReached = null != maxSelectedRows && selectedCount >= maxSelectedRows;
|
|
703
786
|
const rowSelectionPredicate = (row)=>{
|
|
704
787
|
const isSelected = true === rowSelection[row.id];
|
|
788
|
+
if (isSelected) return true;
|
|
705
789
|
if (canSelectRow && !canSelectRow(row, {
|
|
706
790
|
selectedCount,
|
|
707
791
|
isSelected
|
|
@@ -769,6 +853,7 @@ function DataTable(props) {
|
|
|
769
853
|
enableColumnPinning,
|
|
770
854
|
enableColumnResizing,
|
|
771
855
|
columnResizeMode: "onChange",
|
|
856
|
+
columnResizeDirection: direction,
|
|
772
857
|
manualSorting,
|
|
773
858
|
manualFiltering,
|
|
774
859
|
manualPagination: manualPagination || !enablePagination,
|
|
@@ -848,12 +933,19 @@ function DataTable(props) {
|
|
|
848
933
|
0
|
|
849
934
|
];
|
|
850
935
|
for (const node of nodes)offsets.push((offsets.at(-1) ?? 0) + node.getBoundingClientRect().height);
|
|
851
|
-
setHeaderOffsets(offsets);
|
|
936
|
+
setHeaderOffsets((old)=>old.length === offsets.length && offsets.every((offset, index)=>offset === old[index]) ? old : offsets);
|
|
852
937
|
};
|
|
853
|
-
|
|
854
|
-
|
|
938
|
+
let frame = 0;
|
|
939
|
+
const observer = "u" < typeof ResizeObserver ? void 0 : new ResizeObserver(()=>{
|
|
940
|
+
cancelAnimationFrame(frame);
|
|
941
|
+
frame = requestAnimationFrame(measure);
|
|
942
|
+
});
|
|
943
|
+
for (const node of nodes)observer?.observe(node);
|
|
855
944
|
measure();
|
|
856
|
-
return ()=>
|
|
945
|
+
return ()=>{
|
|
946
|
+
observer?.disconnect();
|
|
947
|
+
cancelAnimationFrame(frame);
|
|
948
|
+
};
|
|
857
949
|
}, [
|
|
858
950
|
stickyHeader,
|
|
859
951
|
headerGroupCount
|
|
@@ -864,6 +956,7 @@ function DataTable(props) {
|
|
|
864
956
|
draftRowIdRef.current = row.id;
|
|
865
957
|
setDraft(initial);
|
|
866
958
|
setEditErrors({});
|
|
959
|
+
setSaveError(void 0);
|
|
867
960
|
setDirty(false);
|
|
868
961
|
};
|
|
869
962
|
const startEdit = (row)=>{
|
|
@@ -877,6 +970,7 @@ function DataTable(props) {
|
|
|
877
970
|
});
|
|
878
971
|
};
|
|
879
972
|
const setDraftValue = (rowId, columnId, value)=>{
|
|
973
|
+
if (savingRef.current) return;
|
|
880
974
|
const next = {
|
|
881
975
|
...draftRef.current,
|
|
882
976
|
[columnId]: value
|
|
@@ -896,16 +990,17 @@ function DataTable(props) {
|
|
|
896
990
|
} : old);
|
|
897
991
|
};
|
|
898
992
|
const cancelEdit = ()=>{
|
|
899
|
-
if (!isEditing) return;
|
|
993
|
+
if (!isEditing || savingRef.current) return;
|
|
900
994
|
const rowId = editingRowId;
|
|
901
995
|
setEditingRowId(null);
|
|
996
|
+
setSaveError(void 0);
|
|
902
997
|
onEditCancel?.({
|
|
903
998
|
rowId,
|
|
904
999
|
dirty
|
|
905
1000
|
});
|
|
906
1001
|
};
|
|
907
|
-
const commitEdit = ()=>{
|
|
908
|
-
if (!isEditing) return;
|
|
1002
|
+
const commitEdit = async ()=>{
|
|
1003
|
+
if (!isEditing || savingRef.current) return;
|
|
909
1004
|
const rowId = editingRowId;
|
|
910
1005
|
const row = table.getCoreRowModel().rowsById[rowId];
|
|
911
1006
|
if (!row) return void cancelEdit();
|
|
@@ -916,7 +1011,7 @@ function DataTable(props) {
|
|
|
916
1011
|
return Boolean(meta.renderEditor || editorRenderers?.custom);
|
|
917
1012
|
});
|
|
918
1013
|
const committed = draftRef.current;
|
|
919
|
-
const errors = validateDraft(editableColumns, committed, translations.requiredLabel);
|
|
1014
|
+
const errors = validateDraft(editableColumns, committed, translations.requiredLabel, translations.invalidRangeLabel);
|
|
920
1015
|
if (Object.keys(errors).length > 0) {
|
|
921
1016
|
setEditErrors(errors);
|
|
922
1017
|
onEditValidationError?.({
|
|
@@ -925,13 +1020,48 @@ function DataTable(props) {
|
|
|
925
1020
|
});
|
|
926
1021
|
return;
|
|
927
1022
|
}
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
1023
|
+
savingRef.current = true;
|
|
1024
|
+
setSavePending(true);
|
|
1025
|
+
setSaveError(void 0);
|
|
1026
|
+
try {
|
|
1027
|
+
await onEditCommit?.({
|
|
1028
|
+
rowId,
|
|
1029
|
+
draft: committed,
|
|
1030
|
+
row: row.original
|
|
1031
|
+
});
|
|
1032
|
+
if (draftRowIdRef.current === rowId) setEditingRowId(null);
|
|
1033
|
+
} catch {
|
|
1034
|
+
if (draftRowIdRef.current === rowId) setSaveError(translations.saveErrorLabel);
|
|
1035
|
+
} finally{
|
|
1036
|
+
savingRef.current = false;
|
|
1037
|
+
setSavePending(false);
|
|
1038
|
+
}
|
|
934
1039
|
};
|
|
1040
|
+
const lastCorrection = useRef(void 0);
|
|
1041
|
+
const settledPageCount = null == rowCount ? pageCount : Math.ceil(rowCount / pagination.pageSize);
|
|
1042
|
+
const invalidPage = enablePagination && null != settledPageCount && settledPageCount >= 0 && pagination.pageIndex > Math.max(0, settledPageCount - 1);
|
|
1043
|
+
useEffect(()=>{
|
|
1044
|
+
if (loading || loadingMore || !invalidPage) {
|
|
1045
|
+
if (!invalidPage) lastCorrection.current = void 0;
|
|
1046
|
+
return;
|
|
1047
|
+
}
|
|
1048
|
+
const corrected = Math.max(0, (settledPageCount ?? 0) - 1);
|
|
1049
|
+
const key = `${pagination.pageIndex}:${pagination.pageSize}:${corrected}`;
|
|
1050
|
+
if (lastCorrection.current === key) return;
|
|
1051
|
+
lastCorrection.current = key;
|
|
1052
|
+
setPagination({
|
|
1053
|
+
pageSize: pagination.pageSize,
|
|
1054
|
+
pageIndex: corrected
|
|
1055
|
+
});
|
|
1056
|
+
}, [
|
|
1057
|
+
invalidPage,
|
|
1058
|
+
loading,
|
|
1059
|
+
loadingMore,
|
|
1060
|
+
pagination.pageIndex,
|
|
1061
|
+
pagination.pageSize,
|
|
1062
|
+
settledPageCount,
|
|
1063
|
+
setPagination
|
|
1064
|
+
]);
|
|
935
1065
|
const rows = table.getRowModel().rows;
|
|
936
1066
|
const rootRowIds = useMemo(()=>rows.filter((r)=>0 === r.depth).map((r)=>r.id), [
|
|
937
1067
|
rows
|
|
@@ -941,6 +1071,24 @@ function DataTable(props) {
|
|
|
941
1071
|
headerGroups
|
|
942
1072
|
]);
|
|
943
1073
|
const columnCount = leafColumns.length;
|
|
1074
|
+
const logicalRows = rows.flatMap((row, index)=>[
|
|
1075
|
+
{
|
|
1076
|
+
row,
|
|
1077
|
+
index,
|
|
1078
|
+
detail: false
|
|
1079
|
+
},
|
|
1080
|
+
...renderExpandedRow && row.getIsExpanded() ? [
|
|
1081
|
+
{
|
|
1082
|
+
row,
|
|
1083
|
+
index,
|
|
1084
|
+
detail: true
|
|
1085
|
+
}
|
|
1086
|
+
] : []
|
|
1087
|
+
]);
|
|
1088
|
+
const logicalRowPosition = new Map();
|
|
1089
|
+
logicalRows.forEach((item, index)=>{
|
|
1090
|
+
if (!item.detail) logicalRowPosition.set(item.row.id, index);
|
|
1091
|
+
});
|
|
944
1092
|
const virtualizationUsable = enableVirtualization && !!maxHeight;
|
|
945
1093
|
const hasWarnedAboutUnboundedVirtualization = useRef(false);
|
|
946
1094
|
const hasWarnedAboutVirtualizedCellSpan = useRef(false);
|
|
@@ -974,10 +1122,12 @@ function DataTable(props) {
|
|
|
974
1122
|
maxHeight
|
|
975
1123
|
]);
|
|
976
1124
|
const rowVirtualizer = useVirtualizer({
|
|
977
|
-
count:
|
|
1125
|
+
count: logicalRows.length,
|
|
1126
|
+
getItemKey: (index)=>`${logicalRows[index]?.row.id}:${logicalRows[index]?.detail ? "detail" : "record"}`,
|
|
978
1127
|
getScrollElement: ()=>scrollRef.current,
|
|
979
1128
|
estimateSize: ()=>estimateRowHeight,
|
|
980
1129
|
overscan: 12,
|
|
1130
|
+
useAnimationFrameWithResizeObserver: true,
|
|
981
1131
|
enabled: virtualizationUsable
|
|
982
1132
|
});
|
|
983
1133
|
const virtualItems = virtualizationUsable ? rowVirtualizer.getVirtualItems() : [];
|
|
@@ -986,17 +1136,11 @@ function DataTable(props) {
|
|
|
986
1136
|
const paddingTop = firstVirtual ? firstVirtual.start : 0;
|
|
987
1137
|
const paddingBottom = lastVirtual ? rowVirtualizer.getTotalSize() - lastVirtual.end : 0;
|
|
988
1138
|
const renderRows = virtualizationUsable ? virtualItems.flatMap((vi)=>{
|
|
989
|
-
const
|
|
990
|
-
return
|
|
991
|
-
|
|
992
|
-
row,
|
|
993
|
-
index: vi.index
|
|
994
|
-
}
|
|
1139
|
+
const item = logicalRows[vi.index];
|
|
1140
|
+
return item ? [
|
|
1141
|
+
item
|
|
995
1142
|
] : [];
|
|
996
|
-
}) :
|
|
997
|
-
row,
|
|
998
|
-
index
|
|
999
|
-
}));
|
|
1143
|
+
}) : logicalRows;
|
|
1000
1144
|
useEffect(()=>{
|
|
1001
1145
|
if (!onReachEnd || maxHeight) return;
|
|
1002
1146
|
const onWindowScroll = ()=>{
|
|
@@ -1109,28 +1253,90 @@ function DataTable(props) {
|
|
|
1109
1253
|
const width = Math.ceil(widest + Number.parseFloat(cellStyle.paddingLeft) + Number.parseFloat(cellStyle.paddingRight));
|
|
1110
1254
|
if (width !== fixedActionsWidth) setFixedActionsWidth(width);
|
|
1111
1255
|
});
|
|
1112
|
-
const
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1256
|
+
const [renderedWidths, setRenderedWidths] = useState({});
|
|
1257
|
+
const [renderedActionsWidth, setRenderedActionsWidth] = useState(0);
|
|
1258
|
+
const [viewportWidth, setViewportWidth] = useState(0);
|
|
1259
|
+
useIsomorphicLayoutEffect(()=>{
|
|
1260
|
+
const host = scrollRef.current;
|
|
1261
|
+
if (!host) return;
|
|
1262
|
+
const cells = host.querySelectorAll("thead [data-leaf-column], thead [data-actions-column]");
|
|
1263
|
+
const measure = ()=>{
|
|
1264
|
+
setViewportWidth(host.clientWidth);
|
|
1265
|
+
const widths = {};
|
|
1266
|
+
for (const cell of cells){
|
|
1267
|
+
const width = cell.getBoundingClientRect().width;
|
|
1268
|
+
const id = cell.dataset.leafColumn;
|
|
1269
|
+
if (null == id) {
|
|
1270
|
+
const offsetWidth = "auto" === getComputedStyle(cell).insetInlineEnd ? 0 : width;
|
|
1271
|
+
setRenderedActionsWidth((old)=>Math.abs(old - offsetWidth) < 0.5 ? old : offsetWidth);
|
|
1272
|
+
} else widths[id] = width;
|
|
1273
|
+
}
|
|
1274
|
+
setRenderedWidths((old)=>Object.keys(widths).length === Object.keys(old).length && Object.entries(widths).every(([id, width])=>Math.abs((old[id] ?? 0) - width) < 0.5) ? old : widths);
|
|
1275
|
+
};
|
|
1276
|
+
let frame = 0;
|
|
1277
|
+
const observer = "u" < typeof ResizeObserver ? void 0 : new ResizeObserver(()=>{
|
|
1278
|
+
cancelAnimationFrame(frame);
|
|
1279
|
+
frame = requestAnimationFrame(measure);
|
|
1280
|
+
});
|
|
1281
|
+
observer?.observe(host);
|
|
1282
|
+
for (const cell of cells)observer?.observe(cell);
|
|
1283
|
+
measure();
|
|
1284
|
+
return ()=>{
|
|
1285
|
+
observer?.disconnect();
|
|
1286
|
+
cancelAnimationFrame(frame);
|
|
1287
|
+
};
|
|
1118
1288
|
}, [
|
|
1119
|
-
|
|
1120
|
-
|
|
1289
|
+
leafColumns,
|
|
1290
|
+
headerGroupCount,
|
|
1121
1291
|
hasActionsColumn,
|
|
1122
|
-
|
|
1123
|
-
]);
|
|
1124
|
-
const hasWarnedAboutPinnedStringWidth = useRef(false);
|
|
1125
|
-
useEffect(()=>{
|
|
1126
|
-
const offender = enableColumnPinning && table.getAllLeafColumns().find((c)=>c.getIsPinned() && "string" == typeof c.columnDef.meta?.width);
|
|
1127
|
-
if (!offender || hasWarnedAboutPinnedStringWidth.current || "u" < typeof process || process.env?.NODE_ENV === "production") return;
|
|
1128
|
-
hasWarnedAboutPinnedStringWidth.current = true;
|
|
1129
|
-
console.warn(`DataTable: pinned column "${offender.id}" declares a string meta.width, which cannot be mirrored into TanStack's numeric \`size\`. Frozen offsets are computed from \`size\`, so this column will be positioned as if it were the default width and overlap its neighbours. Give pinned columns a numeric meta.width.`);
|
|
1130
|
-
}, [
|
|
1131
|
-
enableColumnPinning,
|
|
1132
|
-
table
|
|
1292
|
+
stickyActions
|
|
1133
1293
|
]);
|
|
1294
|
+
const renderedTableWidth = leafColumns.reduce((sum, leaf)=>sum + (renderedWidths[leaf.id] ?? leaf.getSize()), renderedActionsWidth);
|
|
1295
|
+
const scrollableBudget = renderedTableWidth > viewportWidth ? 0.4 * viewportWidth : 0;
|
|
1296
|
+
const fittingPins = new Set();
|
|
1297
|
+
let pinnedWidth = renderedActionsWidth;
|
|
1298
|
+
const pinCandidates = [
|
|
1299
|
+
...leafColumns.filter((leaf)=>"start" === leaf.getIsPinned()),
|
|
1300
|
+
...leafColumns.filter((leaf)=>"end" === leaf.getIsPinned()).reverse()
|
|
1301
|
+
];
|
|
1302
|
+
for (const leaf of pinCandidates){
|
|
1303
|
+
const width = renderedWidths[leaf.id] ?? leaf.getSize();
|
|
1304
|
+
if (0 === viewportWidth || pinnedWidth + width + scrollableBudget < viewportWidth) {
|
|
1305
|
+
fittingPins.add(leaf.id);
|
|
1306
|
+
pinnedWidth += width;
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
const unpinnedPosition = {
|
|
1310
|
+
header: stickyHeader ? "sticky" : "relative",
|
|
1311
|
+
body: "static"
|
|
1312
|
+
};
|
|
1313
|
+
const pinningStyles = (column, kind = "body")=>{
|
|
1314
|
+
const pinned = column.getIsPinned();
|
|
1315
|
+
if (!pinned) return {};
|
|
1316
|
+
const descendants = column.columns.length > 0 ? column.getLeafColumns() : [
|
|
1317
|
+
column
|
|
1318
|
+
];
|
|
1319
|
+
if (!descendants.every((leaf)=>fittingPins.has(leaf.id))) return {
|
|
1320
|
+
position: unpinnedPosition[kind],
|
|
1321
|
+
insetInlineStart: "auto",
|
|
1322
|
+
insetInlineEnd: "auto",
|
|
1323
|
+
zIndex: void 0
|
|
1324
|
+
};
|
|
1325
|
+
const siblings = leafColumns.filter((leaf)=>leaf.getIsPinned() === pinned && fittingPins.has(leaf.id));
|
|
1326
|
+
const target = "start" === pinned ? descendants[0] : descendants.at(-1);
|
|
1327
|
+
const index = siblings.findIndex((leaf)=>leaf.id === target?.id);
|
|
1328
|
+
const preceding = "start" === pinned ? siblings.slice(0, index) : siblings.slice(index + 1);
|
|
1329
|
+
const offset = preceding.reduce((sum, leaf)=>sum + (renderedWidths[leaf.id] ?? leaf.getSize()), 0);
|
|
1330
|
+
const actionsOffset = stickyActions && hasActionsColumn ? renderedActionsWidth : 0;
|
|
1331
|
+
return {
|
|
1332
|
+
...getPinningStyles(column, kind),
|
|
1333
|
+
..."start" === pinned ? {
|
|
1334
|
+
insetInlineStart: offset
|
|
1335
|
+
} : {
|
|
1336
|
+
insetInlineEnd: offset + actionsOffset
|
|
1337
|
+
}
|
|
1338
|
+
};
|
|
1339
|
+
};
|
|
1134
1340
|
const renderColumnFilter = (column)=>{
|
|
1135
1341
|
const meta = column.columnDef.meta;
|
|
1136
1342
|
const type = resolveColumnType(meta);
|
|
@@ -1150,26 +1356,67 @@ function DataTable(props) {
|
|
|
1150
1356
|
const renderer = filterRenderers?.[type] ?? DEFAULT_FILTER_RENDERERS[type];
|
|
1151
1357
|
return renderer?.(ctx) ?? null;
|
|
1152
1358
|
};
|
|
1359
|
+
const handleColumnResizeKeyDown = (event, column)=>{
|
|
1360
|
+
if ([
|
|
1361
|
+
"Enter",
|
|
1362
|
+
"Home"
|
|
1363
|
+
].includes(event.key)) {
|
|
1364
|
+
event.preventDefault();
|
|
1365
|
+
column.resetSize();
|
|
1366
|
+
return;
|
|
1367
|
+
}
|
|
1368
|
+
const arrowDirection = {
|
|
1369
|
+
ArrowLeft: -1,
|
|
1370
|
+
ArrowRight: 1
|
|
1371
|
+
}[event.key];
|
|
1372
|
+
if (!arrowDirection) return;
|
|
1373
|
+
event.preventDefault();
|
|
1374
|
+
const delta = (event.shiftKey ? 50 : 10) * arrowDirection * ("rtl" === table.options.columnResizeDirection ? -1 : 1);
|
|
1375
|
+
const min = column.columnDef.minSize ?? 20;
|
|
1376
|
+
const max = column.columnDef.maxSize ?? Number.MAX_SAFE_INTEGER;
|
|
1377
|
+
const renderedSize = event.currentTarget.closest("th")?.getBoundingClientRect().width;
|
|
1378
|
+
const currentSize = columnSizing[column.id] ?? renderedSize ?? column.getSize();
|
|
1379
|
+
const nextSize = Math.min(max, Math.max(min, currentSize + delta));
|
|
1380
|
+
table.setColumnSizing((current)=>({
|
|
1381
|
+
...current,
|
|
1382
|
+
[column.id]: nextSize
|
|
1383
|
+
}));
|
|
1384
|
+
};
|
|
1385
|
+
const handleColumnResizeStart = (event, header)=>{
|
|
1386
|
+
const renderedSize = event.currentTarget.closest("th")?.getBoundingClientRect().width;
|
|
1387
|
+
header.getResizeHandler()(event);
|
|
1388
|
+
if (null == renderedSize || renderedSize <= 0) return;
|
|
1389
|
+
table.setColumnResizing((current)=>current.isResizingColumn === header.column.id ? {
|
|
1390
|
+
...current,
|
|
1391
|
+
startSize: renderedSize,
|
|
1392
|
+
columnSizingStart: [
|
|
1393
|
+
[
|
|
1394
|
+
header.column.id,
|
|
1395
|
+
renderedSize
|
|
1396
|
+
]
|
|
1397
|
+
]
|
|
1398
|
+
} : current);
|
|
1399
|
+
};
|
|
1153
1400
|
const renderHeaderCell = (header, groupIndex, dnd)=>{
|
|
1154
1401
|
const column = header.column;
|
|
1155
|
-
const ariaSort = sortState(column, enableSorting);
|
|
1156
|
-
|
|
1157
|
-
if (dnd?.dropSide === "start") dropClass = "border-primary border-s-2";
|
|
1158
|
-
else if (dnd?.dropSide === "end") dropClass = "border-primary border-e-2";
|
|
1402
|
+
const ariaSort = header.isPlaceholder ? void 0 : sortState(column, enableSorting);
|
|
1403
|
+
const dropClass = dnd?.dropSide ? styles.columnDropIndicator() : "";
|
|
1159
1404
|
return /*#__PURE__*/ jsxs(Table.ColumnHeader, {
|
|
1160
1405
|
align: column.columnDef.meta?.align,
|
|
1161
1406
|
"aria-sort": ariaSort,
|
|
1162
1407
|
className: `group/header ${stickyHeader ? "" : "relative"} ${pinClass(column, "header") ?? ""} ${dropClass}`,
|
|
1163
1408
|
colSpan: header.colSpan,
|
|
1164
1409
|
"data-dragging": dnd?.isDragging || void 0,
|
|
1410
|
+
"data-drop-side": dnd?.dropSide,
|
|
1411
|
+
"data-leaf-column": 0 === column.columns.length ? column.id : void 0,
|
|
1165
1412
|
"data-pinned": column.getIsPinned() || void 0,
|
|
1166
1413
|
ref: dnd?.nodeRef,
|
|
1167
1414
|
style: {
|
|
1168
1415
|
...OPAQUE_HEADER_BG,
|
|
1169
1416
|
...stickyRowOffset(stickyHeader, headerOffsets, groupIndex),
|
|
1170
|
-
...
|
|
1417
|
+
...pinningStyles(column, "header"),
|
|
1171
1418
|
...dnd?.style,
|
|
1172
|
-
...getColumnSizeStyles(column, enableColumnResizing, columnSizing)
|
|
1419
|
+
...0 === column.columns.length ? getColumnSizeStyles(column, enableColumnResizing, columnSizing) : void 0
|
|
1173
1420
|
},
|
|
1174
1421
|
children: [
|
|
1175
1422
|
/*#__PURE__*/ jsxs("div", {
|
|
@@ -1188,12 +1435,14 @@ function DataTable(props) {
|
|
|
1188
1435
|
})
|
|
1189
1436
|
]
|
|
1190
1437
|
}),
|
|
1191
|
-
enableColumnResizing && column.getCanResize() ? /*#__PURE__*/ jsx("button", {
|
|
1438
|
+
enableColumnResizing && !header.isPlaceholder && 0 === column.columns.length && column.getCanResize() ? /*#__PURE__*/ jsx("button", {
|
|
1439
|
+
"aria-description": "Use Left and Right arrows to resize; Shift changes by 50 pixels. Enter resets the width.",
|
|
1192
1440
|
"aria-label": `Resize ${columnLabel(column)}`,
|
|
1193
1441
|
className: styles.resizeHandle(),
|
|
1194
1442
|
onDoubleClick: ()=>column.resetSize(),
|
|
1195
|
-
|
|
1196
|
-
|
|
1443
|
+
onKeyDown: (event)=>handleColumnResizeKeyDown(event, column),
|
|
1444
|
+
onMouseDown: (event)=>handleColumnResizeStart(event, header),
|
|
1445
|
+
onTouchStart: (event)=>handleColumnResizeStart(event, header),
|
|
1197
1446
|
type: "button"
|
|
1198
1447
|
}) : null
|
|
1199
1448
|
]
|
|
@@ -1218,7 +1467,8 @@ function DataTable(props) {
|
|
|
1218
1467
|
}, header.id) : renderHeaderCell(header, groupIndex);
|
|
1219
1468
|
}),
|
|
1220
1469
|
hasActionsColumn && 0 === groupIndex && /*#__PURE__*/ jsx(Table.ColumnHeader, {
|
|
1221
|
-
className: stickyActions ? "sticky
|
|
1470
|
+
className: stickyActions ? "data-table-actions-sticky sticky" : void 0,
|
|
1471
|
+
"data-actions-column": "",
|
|
1222
1472
|
numeric: true,
|
|
1223
1473
|
rowSpan: table.getHeaderGroups().length,
|
|
1224
1474
|
style: {
|
|
@@ -1243,7 +1493,7 @@ function DataTable(props) {
|
|
|
1243
1493
|
"data-pinned": column.getIsPinned() || void 0,
|
|
1244
1494
|
style: {
|
|
1245
1495
|
...OPAQUE_FILTER_ROW_BG,
|
|
1246
|
-
...
|
|
1496
|
+
...pinningStyles(column, "header"),
|
|
1247
1497
|
...stickyHeader ? {
|
|
1248
1498
|
position: "sticky",
|
|
1249
1499
|
top: headerHeight,
|
|
@@ -1253,13 +1503,18 @@ function DataTable(props) {
|
|
|
1253
1503
|
zIndex: DATA_TABLE_Z.pinnedHeaderCell
|
|
1254
1504
|
} : void 0
|
|
1255
1505
|
},
|
|
1256
|
-
children: /*#__PURE__*/ jsx("div", {
|
|
1257
|
-
className: styles.
|
|
1258
|
-
|
|
1259
|
-
|
|
1506
|
+
children: column.getCanFilter() ? /*#__PURE__*/ jsx("div", {
|
|
1507
|
+
className: styles.filterViewport(),
|
|
1508
|
+
"data-layout": tableLayout,
|
|
1509
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
1510
|
+
className: styles.filterControl(),
|
|
1511
|
+
"data-size": size,
|
|
1512
|
+
children: renderColumnFilter(column)
|
|
1513
|
+
})
|
|
1514
|
+
}) : null
|
|
1260
1515
|
}, column.id)),
|
|
1261
1516
|
hasActionsColumn && /*#__PURE__*/ jsx("td", {
|
|
1262
|
-
className: stickyActions ? `${styles.filterCell()}
|
|
1517
|
+
className: stickyActions ? `${styles.filterCell()} data-table-actions-sticky sticky bg-data-table-filter-row-bg` : styles.filterCell(),
|
|
1263
1518
|
style: {
|
|
1264
1519
|
...OPAQUE_FILTER_ROW_BG,
|
|
1265
1520
|
...stickyHeader ? {
|
|
@@ -1285,7 +1540,7 @@ function DataTable(props) {
|
|
|
1285
1540
|
type,
|
|
1286
1541
|
value: draft[column.id],
|
|
1287
1542
|
setValue: (next)=>setDraftValue(row.id, column.id, next),
|
|
1288
|
-
disabled:
|
|
1543
|
+
disabled: savePending,
|
|
1289
1544
|
size,
|
|
1290
1545
|
options: meta.options ?? meta.filterOptions ?? [],
|
|
1291
1546
|
error: editErrors[column.id] || void 0,
|
|
@@ -1301,27 +1556,29 @@ function DataTable(props) {
|
|
|
1301
1556
|
if (!enableInlineEdit) return null;
|
|
1302
1557
|
if (editingRowId === row.id) return /*#__PURE__*/ jsxs(Fragment, {
|
|
1303
1558
|
children: [
|
|
1304
|
-
/*#__PURE__*/ jsx(Button, {
|
|
1305
|
-
"aria-label": "Save row",
|
|
1306
|
-
icon: "token-icon-check",
|
|
1307
|
-
onClick: (e)=>{
|
|
1308
|
-
e.stopPropagation();
|
|
1309
|
-
commitEdit();
|
|
1310
|
-
},
|
|
1311
|
-
size: "sm",
|
|
1312
|
-
theme: "borderless",
|
|
1313
|
-
variant: "primary"
|
|
1314
|
-
}),
|
|
1315
1559
|
/*#__PURE__*/ jsx(Button, {
|
|
1316
1560
|
"aria-label": "Cancel edit",
|
|
1561
|
+
disabled: savePending,
|
|
1317
1562
|
icon: "token-icon-close",
|
|
1318
|
-
onClick: (
|
|
1319
|
-
|
|
1563
|
+
onClick: (event)=>{
|
|
1564
|
+
event.stopPropagation();
|
|
1320
1565
|
cancelEdit();
|
|
1321
1566
|
},
|
|
1322
|
-
size:
|
|
1323
|
-
theme: "
|
|
1567
|
+
size: size,
|
|
1568
|
+
theme: "outlined",
|
|
1324
1569
|
variant: "secondary"
|
|
1570
|
+
}),
|
|
1571
|
+
/*#__PURE__*/ jsx(Button, {
|
|
1572
|
+
"aria-describedby": saveError ? `${instanceId}-save-error` : void 0,
|
|
1573
|
+
"aria-label": "Save row",
|
|
1574
|
+
icon: "token-icon-check",
|
|
1575
|
+
isLoading: savePending,
|
|
1576
|
+
onClick: (event)=>{
|
|
1577
|
+
event.stopPropagation();
|
|
1578
|
+
commitEdit();
|
|
1579
|
+
},
|
|
1580
|
+
size: size,
|
|
1581
|
+
variant: "primary"
|
|
1325
1582
|
})
|
|
1326
1583
|
]
|
|
1327
1584
|
});
|
|
@@ -1343,6 +1600,8 @@ function DataTable(props) {
|
|
|
1343
1600
|
isEditing: editingRowId === row.id,
|
|
1344
1601
|
startEdit: ()=>startEdit(row),
|
|
1345
1602
|
commitEdit,
|
|
1603
|
+
pending: savePending,
|
|
1604
|
+
error: saveError,
|
|
1346
1605
|
cancelEdit,
|
|
1347
1606
|
disabled: locked && editingRowId !== row.id
|
|
1348
1607
|
});
|
|
@@ -1350,7 +1609,7 @@ function DataTable(props) {
|
|
|
1350
1609
|
};
|
|
1351
1610
|
const expandAriaControls = (rowId)=>renderExpandedRow ? `${instanceId}-detail-${rowId}` : void 0;
|
|
1352
1611
|
const renderActionsCell = (row)=>/*#__PURE__*/ jsx(Table.Cell, {
|
|
1353
|
-
className: stickyActions ? "data-table-frozen-cell sticky
|
|
1612
|
+
className: stickyActions ? "data-table-frozen-cell data-table-actions-sticky sticky" : void 0,
|
|
1354
1613
|
numeric: true,
|
|
1355
1614
|
style: stickyActions ? {
|
|
1356
1615
|
zIndex: DATA_TABLE_Z.stickyActionsCell
|
|
@@ -1386,7 +1645,18 @@ function DataTable(props) {
|
|
|
1386
1645
|
theme: "borderless",
|
|
1387
1646
|
variant: "danger" === action.tone ? "danger" : "secondary"
|
|
1388
1647
|
}, action.id)),
|
|
1389
|
-
rowActionsContent(row)
|
|
1648
|
+
rowActionsContent(row),
|
|
1649
|
+
editingRowId === row.id && savePending && /*#__PURE__*/ jsx(StatusText, {
|
|
1650
|
+
role: "status",
|
|
1651
|
+
size: size,
|
|
1652
|
+
children: translations.savePendingLabel
|
|
1653
|
+
}),
|
|
1654
|
+
editingRowId === row.id && saveError && /*#__PURE__*/ jsx(StatusText, {
|
|
1655
|
+
id: `${instanceId}-save-error`,
|
|
1656
|
+
size: size,
|
|
1657
|
+
status: "error",
|
|
1658
|
+
children: saveError
|
|
1659
|
+
})
|
|
1390
1660
|
]
|
|
1391
1661
|
})
|
|
1392
1662
|
});
|
|
@@ -1401,28 +1671,44 @@ function DataTable(props) {
|
|
|
1401
1671
|
});
|
|
1402
1672
|
if (span?.hidden) return null;
|
|
1403
1673
|
const column = cell.column;
|
|
1674
|
+
const meta = column.columnDef.meta;
|
|
1675
|
+
const type = resolveColumnType(meta);
|
|
1676
|
+
const ownsFeedback = !(meta?.renderEditor || editorRenderers?.[type]) && ("boolean" === type || "enum" === type || "multiEnum" === type);
|
|
1404
1677
|
return /*#__PURE__*/ jsx(DataTableBodyCell, {
|
|
1405
1678
|
cell: cell,
|
|
1406
1679
|
columnSizing: columnSizing,
|
|
1407
1680
|
dnd: dnd,
|
|
1408
1681
|
editor: renderCellEditor(row, column),
|
|
1409
|
-
editorError: editingRowId
|
|
1682
|
+
editorError: editingRowId !== row.id || ownsFeedback ? void 0 : editErrors[column.id] || void 0,
|
|
1410
1683
|
editorErrorId: `${instanceId}-err-${row.id}-${column.id}`,
|
|
1411
1684
|
enableColumnResizing: enableColumnResizing,
|
|
1412
1685
|
enableRowReorder: enableRowReorder,
|
|
1413
1686
|
indentColumnId: indentColumnId,
|
|
1687
|
+
pinningStyle: pinningStyles(column),
|
|
1414
1688
|
row: row,
|
|
1415
1689
|
rowLabel: rowLabel,
|
|
1690
|
+
size: size,
|
|
1416
1691
|
span: span,
|
|
1417
1692
|
styles: styles
|
|
1418
1693
|
}, cell.id);
|
|
1419
1694
|
});
|
|
1420
1695
|
};
|
|
1421
1696
|
const headerRowCount = table.getHeaderGroups().length + (enableColumnFilters ? 1 : 0);
|
|
1422
|
-
const
|
|
1697
|
+
const pageRecordOffset = enablePagination ? pagination.pageIndex * pagination.pageSize : 0;
|
|
1698
|
+
const allClientRows = table.getPrePaginatedRowModel().rows;
|
|
1699
|
+
const detailCount = (modelRows)=>renderExpandedRow ? modelRows.filter((row)=>row.getIsExpanded()).length : 0;
|
|
1700
|
+
const pageRowOffset = manualPagination && renderExpandedRow ? 0 : pageRecordOffset + detailCount(allClientRows.slice(0, pageRecordOffset));
|
|
1701
|
+
const footerRowCount = hasFooter ? table.getFooterGroups().length : 0;
|
|
1702
|
+
const knownRecordCount = manualPagination ? rowCount : table.getRowCount();
|
|
1703
|
+
let accessibleBodyCount = knownRecordCount;
|
|
1704
|
+
if (renderExpandedRow) accessibleBodyCount = manualPagination ? logicalRows.length : allClientRows.length + detailCount(allClientRows);
|
|
1705
|
+
if (null != accessibleBodyCount && pageRowOffset + logicalRows.length > accessibleBodyCount) accessibleBodyCount = void 0;
|
|
1706
|
+
const accessibleRowCount = null == accessibleBodyCount ? -1 : headerRowCount + accessibleBodyCount + footerRowCount;
|
|
1707
|
+
const footerRowOffset = accessibleBodyCount ?? pageRowOffset + logicalRows.length;
|
|
1423
1708
|
const buildMainRow = (row, rowIndex, dnd, opts)=>/*#__PURE__*/ jsxs(Table.Row, {
|
|
1424
1709
|
...restRowProps,
|
|
1425
|
-
"aria-
|
|
1710
|
+
"aria-busy": editingRowId === row.id && savePending || void 0,
|
|
1711
|
+
"aria-rowindex": headerRowCount + pageRowOffset + (logicalRowPosition.get(row.id) ?? rowIndex) + 1,
|
|
1426
1712
|
className: rowDragClass(dnd, {
|
|
1427
1713
|
className: restRowProps.className,
|
|
1428
1714
|
striped: effectiveStriped,
|
|
@@ -1431,13 +1717,17 @@ function DataTable(props) {
|
|
|
1431
1717
|
}),
|
|
1432
1718
|
"data-depth": row.depth || void 0,
|
|
1433
1719
|
"data-dragging": dnd?.isDragging || void 0,
|
|
1720
|
+
"data-index": logicalRowPosition.get(row.id),
|
|
1434
1721
|
id: opts.rowElementId ?? restRowProps.id,
|
|
1435
1722
|
onClick: buildRowClickHandler(row, rowOnClick, onRowClick, blocked),
|
|
1436
1723
|
onKeyDown: (event)=>{
|
|
1437
1724
|
restRowProps.onKeyDown?.(event);
|
|
1438
1725
|
opts.rowKeyDown?.(event);
|
|
1439
1726
|
},
|
|
1440
|
-
ref:
|
|
1727
|
+
ref: (node)=>{
|
|
1728
|
+
composeRowRef(dnd, rowRef)(node);
|
|
1729
|
+
if (virtualizationUsable) rowVirtualizer.measureElement(node);
|
|
1730
|
+
},
|
|
1441
1731
|
selected: enableRowSelection ? row.getIsSelected() : void 0,
|
|
1442
1732
|
style: {
|
|
1443
1733
|
...rowStyle,
|
|
@@ -1451,7 +1741,6 @@ function DataTable(props) {
|
|
|
1451
1741
|
});
|
|
1452
1742
|
const renderBodyRow = (row, rowIndex, dnd)=>{
|
|
1453
1743
|
const rowIsClickable = !!onRowClick && !locked;
|
|
1454
|
-
const actionsColumn = hasActionsColumn ? 1 : 0;
|
|
1455
1744
|
const rowElementId = editingRowElementId(editingRowId, instanceId, row.id);
|
|
1456
1745
|
const rowKeyDown = rowIsClickable ? buildRowKeyDownHandler(row, onRowClick, blocked) : void 0;
|
|
1457
1746
|
const mainRow = buildMainRow(row, rowIndex, dnd, {
|
|
@@ -1459,28 +1748,35 @@ function DataTable(props) {
|
|
|
1459
1748
|
rowElementId,
|
|
1460
1749
|
rowKeyDown
|
|
1461
1750
|
});
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
renderExpandedRow,
|
|
1465
|
-
colSpan: columnCount + actionsColumn,
|
|
1466
|
-
instanceId,
|
|
1467
|
-
styles,
|
|
1468
|
-
tintNestedRows
|
|
1469
|
-
}) : null;
|
|
1470
|
-
return /*#__PURE__*/ jsxs(external_react_Fragment, {
|
|
1471
|
-
children: [
|
|
1472
|
-
mainRow,
|
|
1473
|
-
expandedRow
|
|
1474
|
-
]
|
|
1751
|
+
return /*#__PURE__*/ jsx(external_react_Fragment, {
|
|
1752
|
+
children: mainRow
|
|
1475
1753
|
}, row.id);
|
|
1476
1754
|
};
|
|
1477
1755
|
const rowReorderActive = enableRowReorder && !locked && 0 === sorting.length && 0 === columnFilters.length && !globalFilter;
|
|
1478
|
-
const bodyRows = renderRows.map(({ row, index: rowIndex })=>
|
|
1756
|
+
const bodyRows = renderRows.map(({ row, index: rowIndex, detail })=>{
|
|
1757
|
+
if (detail && renderExpandedRow) {
|
|
1758
|
+
const index = (logicalRowPosition.get(row.id) ?? rowIndex) + 1;
|
|
1759
|
+
return /*#__PURE__*/ jsx(external_react_Fragment, {
|
|
1760
|
+
children: renderExpandedDetailRow({
|
|
1761
|
+
row,
|
|
1762
|
+
renderExpandedRow,
|
|
1763
|
+
colSpan: columnCount + (hasActionsColumn ? 1 : 0),
|
|
1764
|
+
instanceId,
|
|
1765
|
+
styles,
|
|
1766
|
+
tintNestedRows,
|
|
1767
|
+
rowIndex: headerRowCount + pageRowOffset + index + 1,
|
|
1768
|
+
virtualIndex: index,
|
|
1769
|
+
measureElement: virtualizationUsable ? rowVirtualizer.measureElement : void 0
|
|
1770
|
+
})
|
|
1771
|
+
}, `${row.id}-detail`);
|
|
1772
|
+
}
|
|
1773
|
+
return rowReorderActive && 0 === row.depth ? /*#__PURE__*/ jsx(SortableRow, {
|
|
1479
1774
|
index: rootRowIds.indexOf(row.id),
|
|
1480
1775
|
label: getRowLabel?.(row) ?? `row ${row.id}`,
|
|
1481
1776
|
row: row,
|
|
1482
1777
|
children: (dnd)=>renderBodyRow(row, rowIndex, dnd)
|
|
1483
|
-
}, row.id) : renderBodyRow(row, rowIndex)
|
|
1778
|
+
}, row.id) : renderBodyRow(row, rowIndex);
|
|
1779
|
+
});
|
|
1484
1780
|
const skeletonRows = (count, keyPrefix)=>Array.from({
|
|
1485
1781
|
length: count
|
|
1486
1782
|
}, (_, i)=>`${keyPrefix}-${i}`).map((rowKey)=>/*#__PURE__*/ jsxs(Table.Row, {
|
|
@@ -1488,24 +1784,26 @@ function DataTable(props) {
|
|
|
1488
1784
|
children: [
|
|
1489
1785
|
leafColumns.map((column)=>/*#__PURE__*/ jsx(Table.Cell, {
|
|
1490
1786
|
children: /*#__PURE__*/ jsx(Skeleton.Text, {
|
|
1787
|
+
className: "data-table-skeleton",
|
|
1491
1788
|
noOfLines: 1,
|
|
1492
1789
|
size: size
|
|
1493
1790
|
})
|
|
1494
1791
|
}, `${rowKey}-${column.id}`)),
|
|
1495
1792
|
hasActionsColumn && /*#__PURE__*/ jsx(Table.Cell, {
|
|
1496
|
-
className: stickyActions ? "data-table-frozen-cell sticky
|
|
1793
|
+
className: stickyActions ? "data-table-frozen-cell data-table-actions-sticky sticky" : void 0,
|
|
1497
1794
|
numeric: true,
|
|
1498
1795
|
style: stickyActions ? {
|
|
1499
1796
|
zIndex: DATA_TABLE_Z.stickyActionsCell
|
|
1500
1797
|
} : void 0,
|
|
1501
1798
|
children: /*#__PURE__*/ jsx(Skeleton.Text, {
|
|
1799
|
+
className: "data-table-skeleton",
|
|
1502
1800
|
noOfLines: 1,
|
|
1503
1801
|
size: size
|
|
1504
1802
|
})
|
|
1505
1803
|
})
|
|
1506
1804
|
]
|
|
1507
1805
|
}, rowKey));
|
|
1508
|
-
|
|
1806
|
+
let emptyState = /*#__PURE__*/ jsxs("div", {
|
|
1509
1807
|
className: styles.empty(),
|
|
1510
1808
|
children: [
|
|
1511
1809
|
/*#__PURE__*/ jsx(Icon, {
|
|
@@ -1525,14 +1823,23 @@ function DataTable(props) {
|
|
|
1525
1823
|
})
|
|
1526
1824
|
]
|
|
1527
1825
|
});
|
|
1826
|
+
if (invalidPage) emptyState = /*#__PURE__*/ jsx(StatusText, {
|
|
1827
|
+
children: translations.paginationPendingLabel
|
|
1828
|
+
});
|
|
1829
|
+
if (renderEmpty) emptyState = renderEmpty();
|
|
1528
1830
|
let statusMessage = "";
|
|
1529
|
-
if (loading) statusMessage = translations.loadingLabel;
|
|
1530
|
-
else if (
|
|
1831
|
+
if (loading || loadingMore) statusMessage = translations.loadingLabel;
|
|
1832
|
+
else if (invalidPage) statusMessage = translations.paginationPendingLabel;
|
|
1833
|
+
else if (0 === rows.length) statusMessage = renderEmpty ? "" : translations.emptyTitle;
|
|
1531
1834
|
else if (isEditing) statusMessage = translations.editingLabel;
|
|
1532
1835
|
const emptyRow = /*#__PURE__*/ jsx("tr", {
|
|
1533
1836
|
children: /*#__PURE__*/ jsx(Table.Cell, {
|
|
1837
|
+
className: "p-0!",
|
|
1534
1838
|
colSpan: columnCount + (hasActionsColumn ? 1 : 0),
|
|
1535
|
-
children:
|
|
1839
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
1840
|
+
className: styles.emptyViewport(),
|
|
1841
|
+
children: emptyState
|
|
1842
|
+
})
|
|
1536
1843
|
})
|
|
1537
1844
|
});
|
|
1538
1845
|
let bodyState = "rows";
|
|
@@ -1546,6 +1853,8 @@ function DataTable(props) {
|
|
|
1546
1853
|
"rows" === bodyState && /*#__PURE__*/ jsxs(Fragment, {
|
|
1547
1854
|
children: [
|
|
1548
1855
|
paddingTop > 0 && /*#__PURE__*/ jsx("tr", {
|
|
1856
|
+
"aria-hidden": "true",
|
|
1857
|
+
tabIndex: -1,
|
|
1549
1858
|
children: /*#__PURE__*/ jsx("td", {
|
|
1550
1859
|
colSpan: columnCount + (hasActionsColumn ? 1 : 0),
|
|
1551
1860
|
style: {
|
|
@@ -1556,6 +1865,8 @@ function DataTable(props) {
|
|
|
1556
1865
|
bodyRows,
|
|
1557
1866
|
loadingMore && skeletonRows(1, "skeleton-more"),
|
|
1558
1867
|
paddingBottom > 0 && /*#__PURE__*/ jsx("tr", {
|
|
1868
|
+
"aria-hidden": "true",
|
|
1869
|
+
tabIndex: -1,
|
|
1559
1870
|
children: /*#__PURE__*/ jsx("td", {
|
|
1560
1871
|
colSpan: columnCount + (hasActionsColumn ? 1 : 0),
|
|
1561
1872
|
style: {
|
|
@@ -1568,13 +1879,15 @@ function DataTable(props) {
|
|
|
1568
1879
|
]
|
|
1569
1880
|
});
|
|
1570
1881
|
const footerContent = hasFooter ? /*#__PURE__*/ jsx(Table.Footer, {
|
|
1571
|
-
children: table.getFooterGroups().map((footerGroup)=>/*#__PURE__*/ jsxs(Table.Row, {
|
|
1882
|
+
children: table.getFooterGroups().map((footerGroup, footerIndex)=>/*#__PURE__*/ jsxs(Table.Row, {
|
|
1883
|
+
"aria-rowindex": headerRowCount + footerRowOffset + footerIndex + 1,
|
|
1572
1884
|
children: [
|
|
1573
1885
|
footerGroup.headers.map((header)=>/*#__PURE__*/ jsx(Table.Cell, {
|
|
1886
|
+
colSpan: header.colSpan,
|
|
1574
1887
|
children: header.isPlaceholder ? null : flexRender(header.column.columnDef.footer, header.getContext())
|
|
1575
1888
|
}, header.id)),
|
|
1576
1889
|
hasActionsColumn && /*#__PURE__*/ jsx(Table.Cell, {
|
|
1577
|
-
className: stickyActions ? "
|
|
1890
|
+
className: stickyActions ? "data-table-actions-sticky sticky bg-data-table-footer-bg" : void 0,
|
|
1578
1891
|
numeric: true,
|
|
1579
1892
|
style: stickyActions ? {
|
|
1580
1893
|
zIndex: DATA_TABLE_Z.stickyActionsCell
|
|
@@ -1583,11 +1896,21 @@ function DataTable(props) {
|
|
|
1583
1896
|
]
|
|
1584
1897
|
}, footerGroup.id))
|
|
1585
1898
|
}) : null;
|
|
1899
|
+
const fixedTableMinWidth = "fixed" === tableLayout ? `calc(${[
|
|
1900
|
+
...leafColumns.map((column)=>{
|
|
1901
|
+
const sizing = getColumnSizeStyles(column, enableColumnResizing, columnSizing);
|
|
1902
|
+
const minimum = String(sizing.minWidth ?? `${column.getSize()}px`);
|
|
1903
|
+
return minimum.includes("%") ? `${column.getSize()}px` : minimum;
|
|
1904
|
+
}),
|
|
1905
|
+
...hasActionsColumn ? [
|
|
1906
|
+
`${fixedActionsWidth ?? 0}px`
|
|
1907
|
+
] : []
|
|
1908
|
+
].join(" + ")})` : void 0;
|
|
1586
1909
|
const tableEl = /*#__PURE__*/ jsx(FieldTableLayoutContext.Provider, {
|
|
1587
1910
|
value: tableLayout,
|
|
1588
1911
|
children: /*#__PURE__*/ jsxs(Table, {
|
|
1589
|
-
"aria-busy": loading || loadingMore || void 0,
|
|
1590
|
-
"aria-rowcount":
|
|
1912
|
+
"aria-busy": loading || loadingMore || invalidPage || void 0,
|
|
1913
|
+
"aria-rowcount": accessibleRowCount,
|
|
1591
1914
|
interactive: (interactive || !!onRowClick) && !locked,
|
|
1592
1915
|
showColumnBorder: showColumnBorder,
|
|
1593
1916
|
size: size,
|
|
@@ -1596,12 +1919,28 @@ function DataTable(props) {
|
|
|
1596
1919
|
...slotProps?.root,
|
|
1597
1920
|
style: {
|
|
1598
1921
|
tableLayout,
|
|
1922
|
+
minWidth: fixedTableMinWidth,
|
|
1599
1923
|
...slotProps?.root?.style
|
|
1600
1924
|
},
|
|
1601
1925
|
children: [
|
|
1602
1926
|
caption && /*#__PURE__*/ jsx(Table.Caption, {
|
|
1927
|
+
id: `${instanceId}-caption`,
|
|
1603
1928
|
children: caption
|
|
1604
1929
|
}),
|
|
1930
|
+
/*#__PURE__*/ jsxs("colgroup", {
|
|
1931
|
+
children: [
|
|
1932
|
+
leafColumns.map((column)=>/*#__PURE__*/ jsx("col", {
|
|
1933
|
+
style: {
|
|
1934
|
+
width: getColumnSizeStyles(column, enableColumnResizing, columnSizing).width
|
|
1935
|
+
}
|
|
1936
|
+
}, column.id)),
|
|
1937
|
+
hasActionsColumn && /*#__PURE__*/ jsx("col", {
|
|
1938
|
+
style: fixedActionsWidth ? {
|
|
1939
|
+
width: fixedActionsWidth
|
|
1940
|
+
} : void 0
|
|
1941
|
+
})
|
|
1942
|
+
]
|
|
1943
|
+
}),
|
|
1605
1944
|
headerContent,
|
|
1606
1945
|
bodyContent,
|
|
1607
1946
|
footerContent
|
|
@@ -1629,6 +1968,8 @@ function DataTable(props) {
|
|
|
1629
1968
|
blocked,
|
|
1630
1969
|
size,
|
|
1631
1970
|
paginationProps,
|
|
1971
|
+
hasNextPage,
|
|
1972
|
+
paginationBusy: loading || loadingMore || invalidPage,
|
|
1632
1973
|
toolbarActions
|
|
1633
1974
|
};
|
|
1634
1975
|
return /*#__PURE__*/ jsx(DataTableContext.Provider, {
|
|
@@ -1657,13 +1998,18 @@ function DataTable(props) {
|
|
|
1657
1998
|
})
|
|
1658
1999
|
]
|
|
1659
2000
|
})),
|
|
1660
|
-
/*#__PURE__*/ jsx("
|
|
1661
|
-
|
|
2001
|
+
/*#__PURE__*/ jsx("section", {
|
|
2002
|
+
"aria-label": caption ? void 0 : translations.scrollLabel,
|
|
2003
|
+
"aria-labelledby": caption ? `${instanceId}-caption` : void 0,
|
|
2004
|
+
className: styles.scroll({
|
|
2005
|
+
className: "focus-visible:data-table-scroll-focus"
|
|
2006
|
+
}),
|
|
1662
2007
|
onScroll: handleScroll,
|
|
1663
2008
|
ref: scrollRef,
|
|
1664
2009
|
style: maxHeight ? {
|
|
1665
2010
|
maxHeight
|
|
1666
2011
|
} : void 0,
|
|
2012
|
+
tabIndex: 0,
|
|
1667
2013
|
children: scrollBody
|
|
1668
2014
|
}),
|
|
1669
2015
|
enablePagination && /*#__PURE__*/ jsx(DataTable.Pagination, {})
|
|
@@ -1817,13 +2163,58 @@ DataTable.ColumnVisibility = function() {
|
|
|
1817
2163
|
size: size
|
|
1818
2164
|
});
|
|
1819
2165
|
};
|
|
1820
|
-
|
|
1821
|
-
const { table, pageSizeOptions, translations, locked, blocked, size, paginationProps } = useDataTableContext();
|
|
2166
|
+
function paginationSummary(table, translations) {
|
|
1822
2167
|
const state = table.state.pagination;
|
|
1823
2168
|
const declaredPageCount = table.options.pageCount;
|
|
1824
|
-
const
|
|
1825
|
-
const
|
|
1826
|
-
const
|
|
2169
|
+
const isManual = table.options.manualPagination;
|
|
2170
|
+
const manualEmptyTotal = 0 === declaredPageCount ? 0 : void 0;
|
|
2171
|
+
const exactTotal = table.options.rowCount ?? (isManual ? manualEmptyTotal : table.getRowCount());
|
|
2172
|
+
const unknownTotal = isManual && null == exactTotal && -1 === declaredPageCount;
|
|
2173
|
+
const total = exactTotal ?? (null != declaredPageCount && declaredPageCount >= 0 ? declaredPageCount * state.pageSize : table.getRowCount());
|
|
2174
|
+
const returnedCount = table.getRowModel().rows.length;
|
|
2175
|
+
const start = 0 === returnedCount ? 0 : state.pageIndex * state.pageSize + 1;
|
|
2176
|
+
const end = 0 === returnedCount ? 0 : Math.min(state.pageIndex * state.pageSize + returnedCount, exactTotal ?? 1 / 0);
|
|
2177
|
+
const rangeText = null == exactTotal ? translations.pageLabel({
|
|
2178
|
+
page: state.pageIndex + 1,
|
|
2179
|
+
pageCount: null != declaredPageCount && declaredPageCount >= 0 ? declaredPageCount : void 0
|
|
2180
|
+
}) : translations.rangeLabel({
|
|
2181
|
+
start: end < start ? 0 : start,
|
|
2182
|
+
end,
|
|
2183
|
+
total: exactTotal
|
|
2184
|
+
});
|
|
2185
|
+
return {
|
|
2186
|
+
total,
|
|
2187
|
+
unknownTotal,
|
|
2188
|
+
rangeText
|
|
2189
|
+
};
|
|
2190
|
+
}
|
|
2191
|
+
DataTable.Pagination = function() {
|
|
2192
|
+
const { table, pageSizeOptions, translations, locked, blocked, size, paginationProps, hasNextPage, paginationBusy } = useDataTableContext();
|
|
2193
|
+
const state = table.state.pagination;
|
|
2194
|
+
const summary = paginationSummary(table, translations);
|
|
2195
|
+
const settledPager = useRef({
|
|
2196
|
+
...summary,
|
|
2197
|
+
...state,
|
|
2198
|
+
canNext: hasNextPage ?? table.getCanNextPage()
|
|
2199
|
+
});
|
|
2200
|
+
const currentPager = {
|
|
2201
|
+
...summary,
|
|
2202
|
+
...state,
|
|
2203
|
+
canNext: hasNextPage ?? table.getCanNextPage()
|
|
2204
|
+
};
|
|
2205
|
+
const pager = paginationBusy ? settledPager.current : currentPager;
|
|
2206
|
+
const controlsRef = useRef(null);
|
|
2207
|
+
const focusedControl = useRef(null);
|
|
2208
|
+
useLayoutEffect(()=>{
|
|
2209
|
+
if (!paginationBusy) settledPager.current = currentPager;
|
|
2210
|
+
const previous = focusedControl.current;
|
|
2211
|
+
const controls = controlsRef.current;
|
|
2212
|
+
const doc = controls?.ownerDocument;
|
|
2213
|
+
if (previous && !previous.isConnected && doc && doc.activeElement === doc.body) {
|
|
2214
|
+
const successor = controls?.querySelector('[aria-current="page"][href]') ?? controls?.querySelector("a[href], button:not(:disabled)");
|
|
2215
|
+
successor?.focus();
|
|
2216
|
+
}
|
|
2217
|
+
});
|
|
1827
2218
|
const styles = dataTableVariants();
|
|
1828
2219
|
const pageSizeItems = pageSizeOptions.map((n)=>({
|
|
1829
2220
|
label: String(n),
|
|
@@ -1835,40 +2226,78 @@ DataTable.Pagination = function() {
|
|
|
1835
2226
|
children: [
|
|
1836
2227
|
/*#__PURE__*/ jsx("span", {
|
|
1837
2228
|
className: styles.paginationInfo(),
|
|
1838
|
-
children: translations.
|
|
1839
|
-
start,
|
|
1840
|
-
end,
|
|
1841
|
-
total
|
|
1842
|
-
})
|
|
2229
|
+
children: paginationBusy ? translations.loadingLabel : summary.rangeText
|
|
1843
2230
|
}),
|
|
1844
2231
|
/*#__PURE__*/ jsxs("div", {
|
|
2232
|
+
"aria-busy": paginationBusy || void 0,
|
|
1845
2233
|
className: styles.paginationControls(),
|
|
2234
|
+
onBlurCapture: (event)=>{
|
|
2235
|
+
if (event.relatedTarget && !event.currentTarget.contains(event.relatedTarget)) focusedControl.current = null;
|
|
2236
|
+
},
|
|
2237
|
+
onFocusCapture: (event)=>{
|
|
2238
|
+
focusedControl.current = event.target;
|
|
2239
|
+
},
|
|
2240
|
+
ref: controlsRef,
|
|
1846
2241
|
children: [
|
|
1847
|
-
/*#__PURE__*/
|
|
2242
|
+
pager.unknownTotal ? /*#__PURE__*/ jsxs(Fragment, {
|
|
2243
|
+
children: [
|
|
2244
|
+
/*#__PURE__*/ jsx(Button, {
|
|
2245
|
+
"aria-disabled": paginationBusy || void 0,
|
|
2246
|
+
disabled: locked || 0 === pager.pageIndex,
|
|
2247
|
+
onClick: ()=>{
|
|
2248
|
+
if (!(paginationBusy || blocked("paginate"))) table.previousPage();
|
|
2249
|
+
},
|
|
2250
|
+
size: size,
|
|
2251
|
+
theme: "outlined",
|
|
2252
|
+
variant: "secondary",
|
|
2253
|
+
children: translations.previousPageLabel
|
|
2254
|
+
}),
|
|
2255
|
+
/*#__PURE__*/ jsx(Button, {
|
|
2256
|
+
"aria-disabled": paginationBusy || void 0,
|
|
2257
|
+
disabled: locked || !pager.canNext,
|
|
2258
|
+
onClick: ()=>{
|
|
2259
|
+
if (!(paginationBusy || blocked("paginate"))) table.nextPage();
|
|
2260
|
+
},
|
|
2261
|
+
size: size,
|
|
2262
|
+
theme: "outlined",
|
|
2263
|
+
variant: "secondary",
|
|
2264
|
+
children: translations.nextPageLabel
|
|
2265
|
+
})
|
|
2266
|
+
]
|
|
2267
|
+
}) : /*#__PURE__*/ jsx(Pagination, {
|
|
1848
2268
|
size: size,
|
|
1849
2269
|
...paginationProps,
|
|
1850
|
-
|
|
2270
|
+
"aria-disabled": paginationBusy || locked || void 0,
|
|
2271
|
+
count: pager.total,
|
|
1851
2272
|
getPageUrl: ()=>"#",
|
|
1852
2273
|
linkProps: {
|
|
1853
2274
|
...paginationProps?.linkProps,
|
|
1854
2275
|
onClick: (event)=>{
|
|
1855
|
-
|
|
1856
|
-
event
|
|
2276
|
+
if (paginationBusy) event.preventDefault();
|
|
2277
|
+
else paginationProps?.linkProps?.onClick?.(event);
|
|
1857
2278
|
}
|
|
1858
2279
|
},
|
|
2280
|
+
onClick: (event)=>{
|
|
2281
|
+
paginationProps?.onClick?.(event);
|
|
2282
|
+
event.preventDefault();
|
|
2283
|
+
},
|
|
1859
2284
|
onPageChange: (page)=>{
|
|
1860
|
-
if (!blocked("paginate")) table.setPageIndex(page - 1);
|
|
2285
|
+
if (!(paginationBusy || blocked("paginate"))) table.setPageIndex(page - 1);
|
|
1861
2286
|
},
|
|
1862
|
-
page:
|
|
1863
|
-
pageSize:
|
|
2287
|
+
page: pager.pageIndex + 1,
|
|
2288
|
+
pageSize: pager.pageSize
|
|
1864
2289
|
}),
|
|
1865
2290
|
/*#__PURE__*/ jsx(FieldSelect, {
|
|
1866
2291
|
ariaLabel: translations.pageSizeLabel,
|
|
1867
2292
|
disabled: locked,
|
|
1868
2293
|
items: pageSizeItems,
|
|
1869
2294
|
onChange: (v)=>{
|
|
1870
|
-
if (!blocked("paginate")) table.
|
|
2295
|
+
if (!(paginationBusy || blocked("paginate"))) table.setPagination({
|
|
2296
|
+
pageIndex: 0,
|
|
2297
|
+
pageSize: Number(v)
|
|
2298
|
+
});
|
|
1871
2299
|
},
|
|
2300
|
+
readOnly: paginationBusy,
|
|
1872
2301
|
size: size,
|
|
1873
2302
|
value: String(state.pageSize)
|
|
1874
2303
|
})
|