@techsio/ui-kit 0.57.0 → 0.59.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 +114 -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 +118 -3
- package/dist/atoms/input.js +57 -9
- package/dist/atoms/label.js +13 -4
- package/dist/atoms/link-button.js +15 -12
- package/dist/atoms/link.js +18 -4
- package/dist/atoms/numeric-input.js +362 -84
- 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 +427 -78
- package/dist/molecules/color-select.js +181 -62
- package/dist/molecules/combobox.js +537 -182
- package/dist/molecules/command.js +2 -1
- package/dist/molecules/date-picker.js +629 -119
- package/dist/molecules/dialog.js +89 -48
- package/dist/molecules/drawer.js +63 -6
- 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 +85 -23
- 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 +86 -20
- package/dist/molecules/tabs.js +227 -31
- package/dist/molecules/toast.js +155 -53
- 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 +26 -5
- package/dist/organisms/data-table.helpers.js +6 -2
- package/dist/organisms/data-table.js +587 -154
- 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 +47 -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 +38 -7
- 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 +78 -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 +24 -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 +18 -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 +27 -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 +30 -4
- package/dist/src/molecules/date-picker.d.ts.map +1 -1
- package/dist/src/molecules/dialog.d.ts +17 -4
- 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 +127 -27
- 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 +38 -14
- 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 +28 -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 +96 -0
- package/src/tokens/_foundation-overrides.css +251 -0
- package/src/tokens/_reset.css +10 -10
- package/src/tokens/_scheme-scopes.css +4194 -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 +77 -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 +121 -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 +32 -16
- 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 +70 -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 +15 -6
- package/src/tokens/figma/brand-overrides.css +171 -57
- package/src/tokens/figma/business/variables.css +15 -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 +13 -4
- package/src/tokens/figma/light/variables.css +62 -49
- package/src/tokens/figma/{neo → n1}/variables.css +123 -114
- package/src/tokens/figma/variables.css +658 -249
- 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,16 @@ 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
|
+
selectRowLabel: (rowLabel)=>`Select ${rowLabel}`,
|
|
374
|
+
editRowLabel: (rowLabel)=>`Edit ${rowLabel}`,
|
|
375
|
+
pageLabel: ({ page, pageCount })=>null == pageCount ? `Page ${page}` : `Page ${page} of ${pageCount}`,
|
|
376
|
+
previousPageLabel: "Previous page",
|
|
377
|
+
nextPageLabel: "Next page",
|
|
378
|
+
paginationPendingLabel: "Page unavailable — requesting an available page.",
|
|
379
|
+
invalidRangeLabel: "Enter valid dates with the start on or before the end.",
|
|
380
|
+
savePendingLabel: "Saving row…",
|
|
381
|
+
saveErrorLabel: "Could not save this row. Your changes are kept; try Save again."
|
|
353
382
|
};
|
|
354
383
|
const SELECTION_COLUMN_ID = "__select";
|
|
355
384
|
const EMPTY_COLUMN_PINNING = {
|
|
@@ -387,7 +416,7 @@ function HeaderSortLabel({ header, styles, enableSorting, locked }) {
|
|
|
387
416
|
const canSort = enableSorting && column.getCanSort();
|
|
388
417
|
const sortDir = column.getIsSorted();
|
|
389
418
|
const label = header.isPlaceholder ? null : flexRender(column.columnDef.header, header.getContext());
|
|
390
|
-
if (!canSort) return /*#__PURE__*/ jsx(Fragment, {
|
|
419
|
+
if (header.isPlaceholder || !canSort) return /*#__PURE__*/ jsx(Fragment, {
|
|
391
420
|
children: label
|
|
392
421
|
});
|
|
393
422
|
let sortIconName = "icon-[mdi--unfold-more-horizontal]";
|
|
@@ -410,7 +439,7 @@ function HeaderSortLabel({ header, styles, enableSorting, locked }) {
|
|
|
410
439
|
]
|
|
411
440
|
});
|
|
412
441
|
}
|
|
413
|
-
function renderCellContent({ cell, column, styles, enableRowReorder, dnd, editor, editorError, editorErrorId, isDragCol, rowLabel }) {
|
|
442
|
+
function renderCellContent({ cell, column, styles, enableRowReorder, dnd, editor, editorError, editorErrorId, size, tableLayout, isDragCol, rowLabel }) {
|
|
414
443
|
if (isDragCol && enableRowReorder && dnd) return /*#__PURE__*/ jsx("button", {
|
|
415
444
|
"aria-label": `Drag to reorder ${rowLabel}`,
|
|
416
445
|
className: styles.dragHandle(),
|
|
@@ -425,17 +454,27 @@ function renderCellContent({ cell, column, styles, enableRowReorder, dnd, editor
|
|
|
425
454
|
if (editor) return /*#__PURE__*/ jsxs("div", {
|
|
426
455
|
className: styles.editorControl(),
|
|
427
456
|
"data-editor-control": "",
|
|
457
|
+
"data-layout": tableLayout,
|
|
458
|
+
"data-type": resolveColumnType(column.columnDef.meta),
|
|
428
459
|
children: [
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
460
|
+
/*#__PURE__*/ jsx("div", {
|
|
461
|
+
className: "data-table-editor-value",
|
|
462
|
+
"data-size": size,
|
|
463
|
+
children: editor
|
|
464
|
+
}),
|
|
465
|
+
editorError ? /*#__PURE__*/ jsx(StatusText, {
|
|
432
466
|
id: editorErrorId,
|
|
433
|
-
|
|
467
|
+
size: size,
|
|
468
|
+
status: "error",
|
|
434
469
|
children: editorError
|
|
435
470
|
}) : null
|
|
436
471
|
]
|
|
437
472
|
});
|
|
438
|
-
|
|
473
|
+
const content = flexRender(column.columnDef.cell, cell.getContext());
|
|
474
|
+
return "fixed" === tableLayout ? /*#__PURE__*/ jsx("div", {
|
|
475
|
+
className: styles.cellContent(),
|
|
476
|
+
children: content
|
|
477
|
+
}) : content;
|
|
439
478
|
}
|
|
440
479
|
function stickyRowOffset(stickyHeader, offsets, groupIndex) {
|
|
441
480
|
if (!stickyHeader) return;
|
|
@@ -443,7 +482,8 @@ function stickyRowOffset(stickyHeader, offsets, groupIndex) {
|
|
|
443
482
|
top: offsets[groupIndex] ?? 0
|
|
444
483
|
};
|
|
445
484
|
}
|
|
446
|
-
function DataTableBodyCell({ cell, span, row, styles, columnSizing, enableColumnResizing, enableRowReorder, dnd, editor, editorError, editorErrorId, indentColumnId, rowLabel }) {
|
|
485
|
+
function DataTableBodyCell({ cell, span, row, styles, columnSizing, enableColumnResizing, enableRowReorder, dnd, editor, editorError, editorErrorId, size, indentColumnId, rowLabel, pinningStyle }) {
|
|
486
|
+
const tableLayout = useContext(FieldTableLayoutContext);
|
|
447
487
|
const column = cell.column;
|
|
448
488
|
const pinned = column.getIsPinned();
|
|
449
489
|
const isDragCol = column.id === DRAG_COLUMN_ID;
|
|
@@ -458,6 +498,7 @@ function DataTableBodyCell({ cell, span, row, styles, columnSizing, enableColumn
|
|
|
458
498
|
rowSpan: span?.rowSpan,
|
|
459
499
|
style: {
|
|
460
500
|
...getPinningStyles(column),
|
|
501
|
+
...pinningStyle,
|
|
461
502
|
...getColumnSizeStyles(column, enableColumnResizing, columnSizing),
|
|
462
503
|
...indent
|
|
463
504
|
},
|
|
@@ -470,31 +511,46 @@ function DataTableBodyCell({ cell, span, row, styles, columnSizing, enableColumn
|
|
|
470
511
|
editor,
|
|
471
512
|
editorError,
|
|
472
513
|
editorErrorId,
|
|
514
|
+
size,
|
|
515
|
+
tableLayout,
|
|
473
516
|
isDragCol,
|
|
474
517
|
rowLabel
|
|
475
518
|
})
|
|
476
519
|
});
|
|
477
520
|
}
|
|
478
|
-
|
|
521
|
+
const DATE_RANGE_BOUND_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
522
|
+
function validDateRange(value) {
|
|
523
|
+
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;
|
|
524
|
+
return validDate(value.from) && validDate(value.to) && !(value.from && value.to && value.from > value.to);
|
|
525
|
+
}
|
|
526
|
+
function validateDraft(columns, draft, requiredLabel, invalidRangeLabel) {
|
|
479
527
|
const errors = {};
|
|
480
528
|
for (const column of columns){
|
|
481
529
|
const meta = column.columnDef.meta;
|
|
482
530
|
if (!meta?.editable) continue;
|
|
483
531
|
const value = draft[column.id];
|
|
484
|
-
const
|
|
532
|
+
const dateRange = "dateRange" === resolveColumnType(meta) ? value : void 0;
|
|
533
|
+
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
534
|
if (meta.required && empty) {
|
|
486
535
|
errors[column.id] = requiredLabel;
|
|
487
536
|
continue;
|
|
488
537
|
}
|
|
538
|
+
if (dateRange && !validDateRange(dateRange)) {
|
|
539
|
+
errors[column.id] = invalidRangeLabel;
|
|
540
|
+
continue;
|
|
541
|
+
}
|
|
489
542
|
const message = meta.validate?.(value, draft);
|
|
490
543
|
if (message) errors[column.id] = message;
|
|
491
544
|
}
|
|
492
545
|
return errors;
|
|
493
546
|
}
|
|
494
|
-
function renderExpandedDetailRow({ row, renderExpandedRow, colSpan, instanceId, styles, tintNestedRows }) {
|
|
547
|
+
function renderExpandedDetailRow({ row, renderExpandedRow, colSpan, instanceId, styles, tintNestedRows, rowIndex, virtualIndex, measureElement }) {
|
|
495
548
|
return /*#__PURE__*/ jsx(Table.Row, {
|
|
549
|
+
"aria-rowindex": rowIndex,
|
|
496
550
|
className: tintNestedRows ? "data-table-row-nested-tint" : void 0,
|
|
497
551
|
"data-depth": row.depth + 1,
|
|
552
|
+
"data-index": virtualIndex,
|
|
553
|
+
ref: measureElement,
|
|
498
554
|
children: /*#__PURE__*/ jsx(Table.Cell, {
|
|
499
555
|
colSpan: colSpan,
|
|
500
556
|
children: /*#__PURE__*/ jsx("div", {
|
|
@@ -566,6 +622,8 @@ function buildRowKeyDownHandler(row, onRowClick, blocked) {
|
|
|
566
622
|
function buildRowClickHandler(row, rowOnClick, onRowClick, blocked) {
|
|
567
623
|
return (event)=>{
|
|
568
624
|
rowOnClick?.(event);
|
|
625
|
+
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]');
|
|
626
|
+
if (event.defaultPrevented || interactive && interactive !== event.currentTarget) return;
|
|
569
627
|
if (onRowClick && !blocked("rowClick")) onRowClick(row, event);
|
|
570
628
|
};
|
|
571
629
|
}
|
|
@@ -588,7 +646,7 @@ function DataTable(props) {
|
|
|
588
646
|
25,
|
|
589
647
|
50,
|
|
590
648
|
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;
|
|
649
|
+
], 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
650
|
const translations = {
|
|
593
651
|
...DEFAULT_TRANSLATIONS
|
|
594
652
|
};
|
|
@@ -598,11 +656,29 @@ function DataTable(props) {
|
|
|
598
656
|
const outlined = "outline" === variant;
|
|
599
657
|
const effectiveStriped = striped || "striped" === variant;
|
|
600
658
|
const styles = dataTableVariants({
|
|
601
|
-
outlined
|
|
659
|
+
outlined,
|
|
660
|
+
fixedLayout: "fixed" === tableLayout
|
|
602
661
|
});
|
|
603
662
|
const generatedId = useId();
|
|
604
663
|
const instanceId = idProp ?? generatedId;
|
|
605
664
|
const scrollRef = useRef(null);
|
|
665
|
+
const [direction, setDirection] = useState("ltr");
|
|
666
|
+
useIsomorphicLayoutEffect(()=>{
|
|
667
|
+
const element = scrollRef.current;
|
|
668
|
+
if (!element) return;
|
|
669
|
+
const update = ()=>setDirection("rtl" === getComputedStyle(element).direction ? "rtl" : "ltr");
|
|
670
|
+
const observer = new MutationObserver(update);
|
|
671
|
+
for(let ancestor = element; ancestor; ancestor = ancestor.parentElement)observer.observe(ancestor, {
|
|
672
|
+
attributes: true,
|
|
673
|
+
attributeFilter: [
|
|
674
|
+
"dir",
|
|
675
|
+
"class",
|
|
676
|
+
"style"
|
|
677
|
+
]
|
|
678
|
+
});
|
|
679
|
+
update();
|
|
680
|
+
return ()=>observer.disconnect();
|
|
681
|
+
}, []);
|
|
606
682
|
const reachedEndRef = useRef(false);
|
|
607
683
|
const lastReachEndCountRef = useRef(-1);
|
|
608
684
|
const reportedSelectionLimitRef = useRef(null);
|
|
@@ -687,6 +763,15 @@ function DataTable(props) {
|
|
|
687
763
|
draftRef.current = draft;
|
|
688
764
|
const [editErrors, setEditErrors] = useState({});
|
|
689
765
|
const [dirty, setDirty] = useState(false);
|
|
766
|
+
const [savePending, setSavePending] = useState(false);
|
|
767
|
+
const [saveError, setSaveError] = useState();
|
|
768
|
+
const savingRef = useRef(false);
|
|
769
|
+
useEffect(()=>{
|
|
770
|
+
if (savePending || saveError) scrollRef.current?.querySelector('[aria-label="Save row"]')?.focus();
|
|
771
|
+
}, [
|
|
772
|
+
saveError,
|
|
773
|
+
savePending
|
|
774
|
+
]);
|
|
690
775
|
const isEditing = null != editingRowId;
|
|
691
776
|
const locked = isEditing && lockInteractionsWhileEditing;
|
|
692
777
|
const blocked = (action)=>{
|
|
@@ -702,6 +787,7 @@ function DataTable(props) {
|
|
|
702
787
|
const selectionLimitReached = null != maxSelectedRows && selectedCount >= maxSelectedRows;
|
|
703
788
|
const rowSelectionPredicate = (row)=>{
|
|
704
789
|
const isSelected = true === rowSelection[row.id];
|
|
790
|
+
if (isSelected) return true;
|
|
705
791
|
if (canSelectRow && !canSelectRow(row, {
|
|
706
792
|
selectedCount,
|
|
707
793
|
isSelected
|
|
@@ -718,6 +804,7 @@ function DataTable(props) {
|
|
|
718
804
|
selectAllLabel: translations.selectAllLabel,
|
|
719
805
|
selectionLabel: translations.selectionLabel,
|
|
720
806
|
reorderLabel: translations.reorderLabel,
|
|
807
|
+
selectRowLabel: translations.selectRowLabel,
|
|
721
808
|
showSelectAll: "multiple" === selectionMode && null == maxSelectedRows
|
|
722
809
|
}), [
|
|
723
810
|
userColumns,
|
|
@@ -728,6 +815,7 @@ function DataTable(props) {
|
|
|
728
815
|
translations.selectAllLabel,
|
|
729
816
|
translations.selectionLabel,
|
|
730
817
|
translations.reorderLabel,
|
|
818
|
+
translations.selectRowLabel,
|
|
731
819
|
selectionMode,
|
|
732
820
|
maxSelectedRows
|
|
733
821
|
]);
|
|
@@ -769,6 +857,7 @@ function DataTable(props) {
|
|
|
769
857
|
enableColumnPinning,
|
|
770
858
|
enableColumnResizing,
|
|
771
859
|
columnResizeMode: "onChange",
|
|
860
|
+
columnResizeDirection: direction,
|
|
772
861
|
manualSorting,
|
|
773
862
|
manualFiltering,
|
|
774
863
|
manualPagination: manualPagination || !enablePagination,
|
|
@@ -848,12 +937,19 @@ function DataTable(props) {
|
|
|
848
937
|
0
|
|
849
938
|
];
|
|
850
939
|
for (const node of nodes)offsets.push((offsets.at(-1) ?? 0) + node.getBoundingClientRect().height);
|
|
851
|
-
setHeaderOffsets(offsets);
|
|
940
|
+
setHeaderOffsets((old)=>old.length === offsets.length && offsets.every((offset, index)=>offset === old[index]) ? old : offsets);
|
|
852
941
|
};
|
|
853
|
-
|
|
854
|
-
|
|
942
|
+
let frame = 0;
|
|
943
|
+
const observer = "u" < typeof ResizeObserver ? void 0 : new ResizeObserver(()=>{
|
|
944
|
+
cancelAnimationFrame(frame);
|
|
945
|
+
frame = requestAnimationFrame(measure);
|
|
946
|
+
});
|
|
947
|
+
for (const node of nodes)observer?.observe(node);
|
|
855
948
|
measure();
|
|
856
|
-
return ()=>
|
|
949
|
+
return ()=>{
|
|
950
|
+
observer?.disconnect();
|
|
951
|
+
cancelAnimationFrame(frame);
|
|
952
|
+
};
|
|
857
953
|
}, [
|
|
858
954
|
stickyHeader,
|
|
859
955
|
headerGroupCount
|
|
@@ -864,6 +960,7 @@ function DataTable(props) {
|
|
|
864
960
|
draftRowIdRef.current = row.id;
|
|
865
961
|
setDraft(initial);
|
|
866
962
|
setEditErrors({});
|
|
963
|
+
setSaveError(void 0);
|
|
867
964
|
setDirty(false);
|
|
868
965
|
};
|
|
869
966
|
const startEdit = (row)=>{
|
|
@@ -877,6 +974,7 @@ function DataTable(props) {
|
|
|
877
974
|
});
|
|
878
975
|
};
|
|
879
976
|
const setDraftValue = (rowId, columnId, value)=>{
|
|
977
|
+
if (savingRef.current) return;
|
|
880
978
|
const next = {
|
|
881
979
|
...draftRef.current,
|
|
882
980
|
[columnId]: value
|
|
@@ -896,16 +994,17 @@ function DataTable(props) {
|
|
|
896
994
|
} : old);
|
|
897
995
|
};
|
|
898
996
|
const cancelEdit = ()=>{
|
|
899
|
-
if (!isEditing) return;
|
|
997
|
+
if (!isEditing || savingRef.current) return;
|
|
900
998
|
const rowId = editingRowId;
|
|
901
999
|
setEditingRowId(null);
|
|
1000
|
+
setSaveError(void 0);
|
|
902
1001
|
onEditCancel?.({
|
|
903
1002
|
rowId,
|
|
904
1003
|
dirty
|
|
905
1004
|
});
|
|
906
1005
|
};
|
|
907
|
-
const commitEdit = ()=>{
|
|
908
|
-
if (!isEditing) return;
|
|
1006
|
+
const commitEdit = async ()=>{
|
|
1007
|
+
if (!isEditing || savingRef.current) return;
|
|
909
1008
|
const rowId = editingRowId;
|
|
910
1009
|
const row = table.getCoreRowModel().rowsById[rowId];
|
|
911
1010
|
if (!row) return void cancelEdit();
|
|
@@ -916,7 +1015,7 @@ function DataTable(props) {
|
|
|
916
1015
|
return Boolean(meta.renderEditor || editorRenderers?.custom);
|
|
917
1016
|
});
|
|
918
1017
|
const committed = draftRef.current;
|
|
919
|
-
const errors = validateDraft(editableColumns, committed, translations.requiredLabel);
|
|
1018
|
+
const errors = validateDraft(editableColumns, committed, translations.requiredLabel, translations.invalidRangeLabel);
|
|
920
1019
|
if (Object.keys(errors).length > 0) {
|
|
921
1020
|
setEditErrors(errors);
|
|
922
1021
|
onEditValidationError?.({
|
|
@@ -925,13 +1024,48 @@ function DataTable(props) {
|
|
|
925
1024
|
});
|
|
926
1025
|
return;
|
|
927
1026
|
}
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
1027
|
+
savingRef.current = true;
|
|
1028
|
+
setSavePending(true);
|
|
1029
|
+
setSaveError(void 0);
|
|
1030
|
+
try {
|
|
1031
|
+
await onEditCommit?.({
|
|
1032
|
+
rowId,
|
|
1033
|
+
draft: committed,
|
|
1034
|
+
row: row.original
|
|
1035
|
+
});
|
|
1036
|
+
if (draftRowIdRef.current === rowId) setEditingRowId(null);
|
|
1037
|
+
} catch {
|
|
1038
|
+
if (draftRowIdRef.current === rowId) setSaveError(translations.saveErrorLabel);
|
|
1039
|
+
} finally{
|
|
1040
|
+
savingRef.current = false;
|
|
1041
|
+
setSavePending(false);
|
|
1042
|
+
}
|
|
934
1043
|
};
|
|
1044
|
+
const lastCorrection = useRef(void 0);
|
|
1045
|
+
const settledPageCount = null == rowCount ? pageCount : Math.ceil(rowCount / pagination.pageSize);
|
|
1046
|
+
const invalidPage = enablePagination && null != settledPageCount && settledPageCount >= 0 && pagination.pageIndex > Math.max(0, settledPageCount - 1);
|
|
1047
|
+
useEffect(()=>{
|
|
1048
|
+
if (loading || loadingMore || !invalidPage) {
|
|
1049
|
+
if (!invalidPage) lastCorrection.current = void 0;
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
1052
|
+
const corrected = Math.max(0, (settledPageCount ?? 0) - 1);
|
|
1053
|
+
const key = `${pagination.pageIndex}:${pagination.pageSize}:${corrected}`;
|
|
1054
|
+
if (lastCorrection.current === key) return;
|
|
1055
|
+
lastCorrection.current = key;
|
|
1056
|
+
setPagination({
|
|
1057
|
+
pageSize: pagination.pageSize,
|
|
1058
|
+
pageIndex: corrected
|
|
1059
|
+
});
|
|
1060
|
+
}, [
|
|
1061
|
+
invalidPage,
|
|
1062
|
+
loading,
|
|
1063
|
+
loadingMore,
|
|
1064
|
+
pagination.pageIndex,
|
|
1065
|
+
pagination.pageSize,
|
|
1066
|
+
settledPageCount,
|
|
1067
|
+
setPagination
|
|
1068
|
+
]);
|
|
935
1069
|
const rows = table.getRowModel().rows;
|
|
936
1070
|
const rootRowIds = useMemo(()=>rows.filter((r)=>0 === r.depth).map((r)=>r.id), [
|
|
937
1071
|
rows
|
|
@@ -941,6 +1075,24 @@ function DataTable(props) {
|
|
|
941
1075
|
headerGroups
|
|
942
1076
|
]);
|
|
943
1077
|
const columnCount = leafColumns.length;
|
|
1078
|
+
const logicalRows = rows.flatMap((row, index)=>[
|
|
1079
|
+
{
|
|
1080
|
+
row,
|
|
1081
|
+
index,
|
|
1082
|
+
detail: false
|
|
1083
|
+
},
|
|
1084
|
+
...renderExpandedRow && row.getIsExpanded() ? [
|
|
1085
|
+
{
|
|
1086
|
+
row,
|
|
1087
|
+
index,
|
|
1088
|
+
detail: true
|
|
1089
|
+
}
|
|
1090
|
+
] : []
|
|
1091
|
+
]);
|
|
1092
|
+
const logicalRowPosition = new Map();
|
|
1093
|
+
logicalRows.forEach((item, index)=>{
|
|
1094
|
+
if (!item.detail) logicalRowPosition.set(item.row.id, index);
|
|
1095
|
+
});
|
|
944
1096
|
const virtualizationUsable = enableVirtualization && !!maxHeight;
|
|
945
1097
|
const hasWarnedAboutUnboundedVirtualization = useRef(false);
|
|
946
1098
|
const hasWarnedAboutVirtualizedCellSpan = useRef(false);
|
|
@@ -974,10 +1126,12 @@ function DataTable(props) {
|
|
|
974
1126
|
maxHeight
|
|
975
1127
|
]);
|
|
976
1128
|
const rowVirtualizer = useVirtualizer({
|
|
977
|
-
count:
|
|
1129
|
+
count: logicalRows.length,
|
|
1130
|
+
getItemKey: (index)=>`${logicalRows[index]?.row.id}:${logicalRows[index]?.detail ? "detail" : "record"}`,
|
|
978
1131
|
getScrollElement: ()=>scrollRef.current,
|
|
979
1132
|
estimateSize: ()=>estimateRowHeight,
|
|
980
1133
|
overscan: 12,
|
|
1134
|
+
useAnimationFrameWithResizeObserver: true,
|
|
981
1135
|
enabled: virtualizationUsable
|
|
982
1136
|
});
|
|
983
1137
|
const virtualItems = virtualizationUsable ? rowVirtualizer.getVirtualItems() : [];
|
|
@@ -986,17 +1140,11 @@ function DataTable(props) {
|
|
|
986
1140
|
const paddingTop = firstVirtual ? firstVirtual.start : 0;
|
|
987
1141
|
const paddingBottom = lastVirtual ? rowVirtualizer.getTotalSize() - lastVirtual.end : 0;
|
|
988
1142
|
const renderRows = virtualizationUsable ? virtualItems.flatMap((vi)=>{
|
|
989
|
-
const
|
|
990
|
-
return
|
|
991
|
-
|
|
992
|
-
row,
|
|
993
|
-
index: vi.index
|
|
994
|
-
}
|
|
1143
|
+
const item = logicalRows[vi.index];
|
|
1144
|
+
return item ? [
|
|
1145
|
+
item
|
|
995
1146
|
] : [];
|
|
996
|
-
}) :
|
|
997
|
-
row,
|
|
998
|
-
index
|
|
999
|
-
}));
|
|
1147
|
+
}) : logicalRows;
|
|
1000
1148
|
useEffect(()=>{
|
|
1001
1149
|
if (!onReachEnd || maxHeight) return;
|
|
1002
1150
|
const onWindowScroll = ()=>{
|
|
@@ -1109,28 +1257,90 @@ function DataTable(props) {
|
|
|
1109
1257
|
const width = Math.ceil(widest + Number.parseFloat(cellStyle.paddingLeft) + Number.parseFloat(cellStyle.paddingRight));
|
|
1110
1258
|
if (width !== fixedActionsWidth) setFixedActionsWidth(width);
|
|
1111
1259
|
});
|
|
1112
|
-
const
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1260
|
+
const [renderedWidths, setRenderedWidths] = useState({});
|
|
1261
|
+
const [renderedActionsWidth, setRenderedActionsWidth] = useState(0);
|
|
1262
|
+
const [viewportWidth, setViewportWidth] = useState(0);
|
|
1263
|
+
useIsomorphicLayoutEffect(()=>{
|
|
1264
|
+
const host = scrollRef.current;
|
|
1265
|
+
if (!host) return;
|
|
1266
|
+
const cells = host.querySelectorAll("thead [data-leaf-column], thead [data-actions-column]");
|
|
1267
|
+
const measure = ()=>{
|
|
1268
|
+
setViewportWidth(host.clientWidth);
|
|
1269
|
+
const widths = {};
|
|
1270
|
+
for (const cell of cells){
|
|
1271
|
+
const width = cell.getBoundingClientRect().width;
|
|
1272
|
+
const id = cell.dataset.leafColumn;
|
|
1273
|
+
if (null == id) {
|
|
1274
|
+
const offsetWidth = "auto" === getComputedStyle(cell).insetInlineEnd ? 0 : width;
|
|
1275
|
+
setRenderedActionsWidth((old)=>Math.abs(old - offsetWidth) < 0.5 ? old : offsetWidth);
|
|
1276
|
+
} else widths[id] = width;
|
|
1277
|
+
}
|
|
1278
|
+
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);
|
|
1279
|
+
};
|
|
1280
|
+
let frame = 0;
|
|
1281
|
+
const observer = "u" < typeof ResizeObserver ? void 0 : new ResizeObserver(()=>{
|
|
1282
|
+
cancelAnimationFrame(frame);
|
|
1283
|
+
frame = requestAnimationFrame(measure);
|
|
1284
|
+
});
|
|
1285
|
+
observer?.observe(host);
|
|
1286
|
+
for (const cell of cells)observer?.observe(cell);
|
|
1287
|
+
measure();
|
|
1288
|
+
return ()=>{
|
|
1289
|
+
observer?.disconnect();
|
|
1290
|
+
cancelAnimationFrame(frame);
|
|
1291
|
+
};
|
|
1118
1292
|
}, [
|
|
1119
|
-
|
|
1120
|
-
|
|
1293
|
+
leafColumns,
|
|
1294
|
+
headerGroupCount,
|
|
1121
1295
|
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
|
|
1296
|
+
stickyActions
|
|
1133
1297
|
]);
|
|
1298
|
+
const renderedTableWidth = leafColumns.reduce((sum, leaf)=>sum + (renderedWidths[leaf.id] ?? leaf.getSize()), renderedActionsWidth);
|
|
1299
|
+
const scrollableBudget = renderedTableWidth > viewportWidth ? 0.4 * viewportWidth : 0;
|
|
1300
|
+
const fittingPins = new Set();
|
|
1301
|
+
let pinnedWidth = renderedActionsWidth;
|
|
1302
|
+
const pinCandidates = [
|
|
1303
|
+
...leafColumns.filter((leaf)=>"start" === leaf.getIsPinned()),
|
|
1304
|
+
...leafColumns.filter((leaf)=>"end" === leaf.getIsPinned()).reverse()
|
|
1305
|
+
];
|
|
1306
|
+
for (const leaf of pinCandidates){
|
|
1307
|
+
const width = renderedWidths[leaf.id] ?? leaf.getSize();
|
|
1308
|
+
if (0 === viewportWidth || pinnedWidth + width + scrollableBudget < viewportWidth) {
|
|
1309
|
+
fittingPins.add(leaf.id);
|
|
1310
|
+
pinnedWidth += width;
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
const unpinnedPosition = {
|
|
1314
|
+
header: stickyHeader ? "sticky" : "relative",
|
|
1315
|
+
body: "static"
|
|
1316
|
+
};
|
|
1317
|
+
const pinningStyles = (column, kind = "body")=>{
|
|
1318
|
+
const pinned = column.getIsPinned();
|
|
1319
|
+
if (!pinned) return {};
|
|
1320
|
+
const descendants = column.columns.length > 0 ? column.getLeafColumns() : [
|
|
1321
|
+
column
|
|
1322
|
+
];
|
|
1323
|
+
if (!descendants.every((leaf)=>fittingPins.has(leaf.id))) return {
|
|
1324
|
+
position: unpinnedPosition[kind],
|
|
1325
|
+
insetInlineStart: "auto",
|
|
1326
|
+
insetInlineEnd: "auto",
|
|
1327
|
+
zIndex: void 0
|
|
1328
|
+
};
|
|
1329
|
+
const siblings = leafColumns.filter((leaf)=>leaf.getIsPinned() === pinned && fittingPins.has(leaf.id));
|
|
1330
|
+
const target = "start" === pinned ? descendants[0] : descendants.at(-1);
|
|
1331
|
+
const index = siblings.findIndex((leaf)=>leaf.id === target?.id);
|
|
1332
|
+
const preceding = "start" === pinned ? siblings.slice(0, index) : siblings.slice(index + 1);
|
|
1333
|
+
const offset = preceding.reduce((sum, leaf)=>sum + (renderedWidths[leaf.id] ?? leaf.getSize()), 0);
|
|
1334
|
+
const actionsOffset = stickyActions && hasActionsColumn ? renderedActionsWidth : 0;
|
|
1335
|
+
return {
|
|
1336
|
+
...getPinningStyles(column, kind),
|
|
1337
|
+
..."start" === pinned ? {
|
|
1338
|
+
insetInlineStart: offset
|
|
1339
|
+
} : {
|
|
1340
|
+
insetInlineEnd: offset + actionsOffset
|
|
1341
|
+
}
|
|
1342
|
+
};
|
|
1343
|
+
};
|
|
1134
1344
|
const renderColumnFilter = (column)=>{
|
|
1135
1345
|
const meta = column.columnDef.meta;
|
|
1136
1346
|
const type = resolveColumnType(meta);
|
|
@@ -1150,26 +1360,67 @@ function DataTable(props) {
|
|
|
1150
1360
|
const renderer = filterRenderers?.[type] ?? DEFAULT_FILTER_RENDERERS[type];
|
|
1151
1361
|
return renderer?.(ctx) ?? null;
|
|
1152
1362
|
};
|
|
1363
|
+
const handleColumnResizeKeyDown = (event, column)=>{
|
|
1364
|
+
if ([
|
|
1365
|
+
"Enter",
|
|
1366
|
+
"Home"
|
|
1367
|
+
].includes(event.key)) {
|
|
1368
|
+
event.preventDefault();
|
|
1369
|
+
column.resetSize();
|
|
1370
|
+
return;
|
|
1371
|
+
}
|
|
1372
|
+
const arrowDirection = {
|
|
1373
|
+
ArrowLeft: -1,
|
|
1374
|
+
ArrowRight: 1
|
|
1375
|
+
}[event.key];
|
|
1376
|
+
if (!arrowDirection) return;
|
|
1377
|
+
event.preventDefault();
|
|
1378
|
+
const delta = (event.shiftKey ? 50 : 10) * arrowDirection * ("rtl" === table.options.columnResizeDirection ? -1 : 1);
|
|
1379
|
+
const min = column.columnDef.minSize ?? 20;
|
|
1380
|
+
const max = column.columnDef.maxSize ?? Number.MAX_SAFE_INTEGER;
|
|
1381
|
+
const renderedSize = event.currentTarget.closest("th")?.getBoundingClientRect().width;
|
|
1382
|
+
const currentSize = columnSizing[column.id] ?? renderedSize ?? column.getSize();
|
|
1383
|
+
const nextSize = Math.min(max, Math.max(min, currentSize + delta));
|
|
1384
|
+
table.setColumnSizing((current)=>({
|
|
1385
|
+
...current,
|
|
1386
|
+
[column.id]: nextSize
|
|
1387
|
+
}));
|
|
1388
|
+
};
|
|
1389
|
+
const handleColumnResizeStart = (event, header)=>{
|
|
1390
|
+
const renderedSize = event.currentTarget.closest("th")?.getBoundingClientRect().width;
|
|
1391
|
+
header.getResizeHandler()(event);
|
|
1392
|
+
if (null == renderedSize || renderedSize <= 0) return;
|
|
1393
|
+
table.setColumnResizing((current)=>current.isResizingColumn === header.column.id ? {
|
|
1394
|
+
...current,
|
|
1395
|
+
startSize: renderedSize,
|
|
1396
|
+
columnSizingStart: [
|
|
1397
|
+
[
|
|
1398
|
+
header.column.id,
|
|
1399
|
+
renderedSize
|
|
1400
|
+
]
|
|
1401
|
+
]
|
|
1402
|
+
} : current);
|
|
1403
|
+
};
|
|
1153
1404
|
const renderHeaderCell = (header, groupIndex, dnd)=>{
|
|
1154
1405
|
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";
|
|
1406
|
+
const ariaSort = header.isPlaceholder ? void 0 : sortState(column, enableSorting);
|
|
1407
|
+
const dropClass = dnd?.dropSide ? styles.columnDropIndicator() : "";
|
|
1159
1408
|
return /*#__PURE__*/ jsxs(Table.ColumnHeader, {
|
|
1160
1409
|
align: column.columnDef.meta?.align,
|
|
1161
1410
|
"aria-sort": ariaSort,
|
|
1162
1411
|
className: `group/header ${stickyHeader ? "" : "relative"} ${pinClass(column, "header") ?? ""} ${dropClass}`,
|
|
1163
1412
|
colSpan: header.colSpan,
|
|
1164
1413
|
"data-dragging": dnd?.isDragging || void 0,
|
|
1414
|
+
"data-drop-side": dnd?.dropSide,
|
|
1415
|
+
"data-leaf-column": 0 === column.columns.length ? column.id : void 0,
|
|
1165
1416
|
"data-pinned": column.getIsPinned() || void 0,
|
|
1166
1417
|
ref: dnd?.nodeRef,
|
|
1167
1418
|
style: {
|
|
1168
1419
|
...OPAQUE_HEADER_BG,
|
|
1169
1420
|
...stickyRowOffset(stickyHeader, headerOffsets, groupIndex),
|
|
1170
|
-
...
|
|
1421
|
+
...pinningStyles(column, "header"),
|
|
1171
1422
|
...dnd?.style,
|
|
1172
|
-
...getColumnSizeStyles(column, enableColumnResizing, columnSizing)
|
|
1423
|
+
...0 === column.columns.length ? getColumnSizeStyles(column, enableColumnResizing, columnSizing) : void 0
|
|
1173
1424
|
},
|
|
1174
1425
|
children: [
|
|
1175
1426
|
/*#__PURE__*/ jsxs("div", {
|
|
@@ -1188,12 +1439,14 @@ function DataTable(props) {
|
|
|
1188
1439
|
})
|
|
1189
1440
|
]
|
|
1190
1441
|
}),
|
|
1191
|
-
enableColumnResizing && column.getCanResize() ? /*#__PURE__*/ jsx("button", {
|
|
1442
|
+
enableColumnResizing && !header.isPlaceholder && 0 === column.columns.length && column.getCanResize() ? /*#__PURE__*/ jsx("button", {
|
|
1443
|
+
"aria-description": "Use Left and Right arrows to resize; Shift changes by 50 pixels. Enter resets the width.",
|
|
1192
1444
|
"aria-label": `Resize ${columnLabel(column)}`,
|
|
1193
1445
|
className: styles.resizeHandle(),
|
|
1194
1446
|
onDoubleClick: ()=>column.resetSize(),
|
|
1195
|
-
|
|
1196
|
-
|
|
1447
|
+
onKeyDown: (event)=>handleColumnResizeKeyDown(event, column),
|
|
1448
|
+
onMouseDown: (event)=>handleColumnResizeStart(event, header),
|
|
1449
|
+
onTouchStart: (event)=>handleColumnResizeStart(event, header),
|
|
1197
1450
|
type: "button"
|
|
1198
1451
|
}) : null
|
|
1199
1452
|
]
|
|
@@ -1218,7 +1471,8 @@ function DataTable(props) {
|
|
|
1218
1471
|
}, header.id) : renderHeaderCell(header, groupIndex);
|
|
1219
1472
|
}),
|
|
1220
1473
|
hasActionsColumn && 0 === groupIndex && /*#__PURE__*/ jsx(Table.ColumnHeader, {
|
|
1221
|
-
className: stickyActions ? "sticky
|
|
1474
|
+
className: stickyActions ? "data-table-actions-sticky sticky" : void 0,
|
|
1475
|
+
"data-actions-column": "",
|
|
1222
1476
|
numeric: true,
|
|
1223
1477
|
rowSpan: table.getHeaderGroups().length,
|
|
1224
1478
|
style: {
|
|
@@ -1243,7 +1497,7 @@ function DataTable(props) {
|
|
|
1243
1497
|
"data-pinned": column.getIsPinned() || void 0,
|
|
1244
1498
|
style: {
|
|
1245
1499
|
...OPAQUE_FILTER_ROW_BG,
|
|
1246
|
-
...
|
|
1500
|
+
...pinningStyles(column, "header"),
|
|
1247
1501
|
...stickyHeader ? {
|
|
1248
1502
|
position: "sticky",
|
|
1249
1503
|
top: headerHeight,
|
|
@@ -1253,13 +1507,18 @@ function DataTable(props) {
|
|
|
1253
1507
|
zIndex: DATA_TABLE_Z.pinnedHeaderCell
|
|
1254
1508
|
} : void 0
|
|
1255
1509
|
},
|
|
1256
|
-
children: /*#__PURE__*/ jsx("div", {
|
|
1257
|
-
className: styles.
|
|
1258
|
-
|
|
1259
|
-
|
|
1510
|
+
children: column.getCanFilter() ? /*#__PURE__*/ jsx("div", {
|
|
1511
|
+
className: styles.filterViewport(),
|
|
1512
|
+
"data-layout": tableLayout,
|
|
1513
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
1514
|
+
className: styles.filterControl(),
|
|
1515
|
+
"data-size": size,
|
|
1516
|
+
children: renderColumnFilter(column)
|
|
1517
|
+
})
|
|
1518
|
+
}) : null
|
|
1260
1519
|
}, column.id)),
|
|
1261
1520
|
hasActionsColumn && /*#__PURE__*/ jsx("td", {
|
|
1262
|
-
className: stickyActions ? `${styles.filterCell()}
|
|
1521
|
+
className: stickyActions ? `${styles.filterCell()} data-table-actions-sticky sticky bg-data-table-filter-row-bg` : styles.filterCell(),
|
|
1263
1522
|
style: {
|
|
1264
1523
|
...OPAQUE_FILTER_ROW_BG,
|
|
1265
1524
|
...stickyHeader ? {
|
|
@@ -1285,7 +1544,7 @@ function DataTable(props) {
|
|
|
1285
1544
|
type,
|
|
1286
1545
|
value: draft[column.id],
|
|
1287
1546
|
setValue: (next)=>setDraftValue(row.id, column.id, next),
|
|
1288
|
-
disabled:
|
|
1547
|
+
disabled: savePending,
|
|
1289
1548
|
size,
|
|
1290
1549
|
options: meta.options ?? meta.filterOptions ?? [],
|
|
1291
1550
|
error: editErrors[column.id] || void 0,
|
|
@@ -1301,32 +1560,34 @@ function DataTable(props) {
|
|
|
1301
1560
|
if (!enableInlineEdit) return null;
|
|
1302
1561
|
if (editingRowId === row.id) return /*#__PURE__*/ jsxs(Fragment, {
|
|
1303
1562
|
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
1563
|
/*#__PURE__*/ jsx(Button, {
|
|
1316
1564
|
"aria-label": "Cancel edit",
|
|
1565
|
+
disabled: savePending,
|
|
1317
1566
|
icon: "token-icon-close",
|
|
1318
|
-
onClick: (
|
|
1319
|
-
|
|
1567
|
+
onClick: (event)=>{
|
|
1568
|
+
event.stopPropagation();
|
|
1320
1569
|
cancelEdit();
|
|
1321
1570
|
},
|
|
1322
|
-
size:
|
|
1323
|
-
theme: "
|
|
1571
|
+
size: size,
|
|
1572
|
+
theme: "outlined",
|
|
1324
1573
|
variant: "secondary"
|
|
1574
|
+
}),
|
|
1575
|
+
/*#__PURE__*/ jsx(Button, {
|
|
1576
|
+
"aria-describedby": saveError ? `${instanceId}-save-error` : void 0,
|
|
1577
|
+
"aria-label": "Save row",
|
|
1578
|
+
icon: "token-icon-check",
|
|
1579
|
+
isLoading: savePending,
|
|
1580
|
+
onClick: (event)=>{
|
|
1581
|
+
event.stopPropagation();
|
|
1582
|
+
commitEdit();
|
|
1583
|
+
},
|
|
1584
|
+
size: size,
|
|
1585
|
+
variant: "primary"
|
|
1325
1586
|
})
|
|
1326
1587
|
]
|
|
1327
1588
|
});
|
|
1328
1589
|
return /*#__PURE__*/ jsx(ActionIcon, {
|
|
1329
|
-
"aria-label":
|
|
1590
|
+
"aria-label": translations.editRowLabel(getRowLabel?.(row) ?? `row ${row.id}`),
|
|
1330
1591
|
disabled: isEditing || (canEditRow ? !canEditRow(row) : false),
|
|
1331
1592
|
icon: "icon-[mdi--pencil-outline]",
|
|
1332
1593
|
id: `${instanceId}-edit-${row.id}`,
|
|
@@ -1343,6 +1604,8 @@ function DataTable(props) {
|
|
|
1343
1604
|
isEditing: editingRowId === row.id,
|
|
1344
1605
|
startEdit: ()=>startEdit(row),
|
|
1345
1606
|
commitEdit,
|
|
1607
|
+
pending: savePending,
|
|
1608
|
+
error: saveError,
|
|
1346
1609
|
cancelEdit,
|
|
1347
1610
|
disabled: locked && editingRowId !== row.id
|
|
1348
1611
|
});
|
|
@@ -1350,7 +1613,7 @@ function DataTable(props) {
|
|
|
1350
1613
|
};
|
|
1351
1614
|
const expandAriaControls = (rowId)=>renderExpandedRow ? `${instanceId}-detail-${rowId}` : void 0;
|
|
1352
1615
|
const renderActionsCell = (row)=>/*#__PURE__*/ jsx(Table.Cell, {
|
|
1353
|
-
className: stickyActions ? "data-table-frozen-cell sticky
|
|
1616
|
+
className: stickyActions ? "data-table-frozen-cell data-table-actions-sticky sticky" : void 0,
|
|
1354
1617
|
numeric: true,
|
|
1355
1618
|
style: stickyActions ? {
|
|
1356
1619
|
zIndex: DATA_TABLE_Z.stickyActionsCell
|
|
@@ -1386,7 +1649,18 @@ function DataTable(props) {
|
|
|
1386
1649
|
theme: "borderless",
|
|
1387
1650
|
variant: "danger" === action.tone ? "danger" : "secondary"
|
|
1388
1651
|
}, action.id)),
|
|
1389
|
-
rowActionsContent(row)
|
|
1652
|
+
rowActionsContent(row),
|
|
1653
|
+
editingRowId === row.id && savePending && /*#__PURE__*/ jsx(StatusText, {
|
|
1654
|
+
role: "status",
|
|
1655
|
+
size: size,
|
|
1656
|
+
children: translations.savePendingLabel
|
|
1657
|
+
}),
|
|
1658
|
+
editingRowId === row.id && saveError && /*#__PURE__*/ jsx(StatusText, {
|
|
1659
|
+
id: `${instanceId}-save-error`,
|
|
1660
|
+
size: size,
|
|
1661
|
+
status: "error",
|
|
1662
|
+
children: saveError
|
|
1663
|
+
})
|
|
1390
1664
|
]
|
|
1391
1665
|
})
|
|
1392
1666
|
});
|
|
@@ -1401,28 +1675,44 @@ function DataTable(props) {
|
|
|
1401
1675
|
});
|
|
1402
1676
|
if (span?.hidden) return null;
|
|
1403
1677
|
const column = cell.column;
|
|
1678
|
+
const meta = column.columnDef.meta;
|
|
1679
|
+
const type = resolveColumnType(meta);
|
|
1680
|
+
const ownsFeedback = !(meta?.renderEditor || editorRenderers?.[type]) && ("boolean" === type || "enum" === type || "multiEnum" === type);
|
|
1404
1681
|
return /*#__PURE__*/ jsx(DataTableBodyCell, {
|
|
1405
1682
|
cell: cell,
|
|
1406
1683
|
columnSizing: columnSizing,
|
|
1407
1684
|
dnd: dnd,
|
|
1408
1685
|
editor: renderCellEditor(row, column),
|
|
1409
|
-
editorError: editingRowId
|
|
1686
|
+
editorError: editingRowId !== row.id || ownsFeedback ? void 0 : editErrors[column.id] || void 0,
|
|
1410
1687
|
editorErrorId: `${instanceId}-err-${row.id}-${column.id}`,
|
|
1411
1688
|
enableColumnResizing: enableColumnResizing,
|
|
1412
1689
|
enableRowReorder: enableRowReorder,
|
|
1413
1690
|
indentColumnId: indentColumnId,
|
|
1691
|
+
pinningStyle: pinningStyles(column),
|
|
1414
1692
|
row: row,
|
|
1415
1693
|
rowLabel: rowLabel,
|
|
1694
|
+
size: size,
|
|
1416
1695
|
span: span,
|
|
1417
1696
|
styles: styles
|
|
1418
1697
|
}, cell.id);
|
|
1419
1698
|
});
|
|
1420
1699
|
};
|
|
1421
1700
|
const headerRowCount = table.getHeaderGroups().length + (enableColumnFilters ? 1 : 0);
|
|
1422
|
-
const
|
|
1701
|
+
const pageRecordOffset = enablePagination ? pagination.pageIndex * pagination.pageSize : 0;
|
|
1702
|
+
const allClientRows = table.getPrePaginatedRowModel().rows;
|
|
1703
|
+
const detailCount = (modelRows)=>renderExpandedRow ? modelRows.filter((row)=>row.getIsExpanded()).length : 0;
|
|
1704
|
+
const pageRowOffset = manualPagination && renderExpandedRow ? 0 : pageRecordOffset + detailCount(allClientRows.slice(0, pageRecordOffset));
|
|
1705
|
+
const footerRowCount = hasFooter ? table.getFooterGroups().length : 0;
|
|
1706
|
+
const knownRecordCount = manualPagination ? rowCount : table.getRowCount();
|
|
1707
|
+
let accessibleBodyCount = knownRecordCount;
|
|
1708
|
+
if (renderExpandedRow) accessibleBodyCount = manualPagination ? logicalRows.length : allClientRows.length + detailCount(allClientRows);
|
|
1709
|
+
if (null != accessibleBodyCount && pageRowOffset + logicalRows.length > accessibleBodyCount) accessibleBodyCount = void 0;
|
|
1710
|
+
const accessibleRowCount = null == accessibleBodyCount ? -1 : headerRowCount + accessibleBodyCount + footerRowCount;
|
|
1711
|
+
const footerRowOffset = accessibleBodyCount ?? pageRowOffset + logicalRows.length;
|
|
1423
1712
|
const buildMainRow = (row, rowIndex, dnd, opts)=>/*#__PURE__*/ jsxs(Table.Row, {
|
|
1424
1713
|
...restRowProps,
|
|
1425
|
-
"aria-
|
|
1714
|
+
"aria-busy": editingRowId === row.id && savePending || void 0,
|
|
1715
|
+
"aria-rowindex": headerRowCount + pageRowOffset + (logicalRowPosition.get(row.id) ?? rowIndex) + 1,
|
|
1426
1716
|
className: rowDragClass(dnd, {
|
|
1427
1717
|
className: restRowProps.className,
|
|
1428
1718
|
striped: effectiveStriped,
|
|
@@ -1431,13 +1721,17 @@ function DataTable(props) {
|
|
|
1431
1721
|
}),
|
|
1432
1722
|
"data-depth": row.depth || void 0,
|
|
1433
1723
|
"data-dragging": dnd?.isDragging || void 0,
|
|
1724
|
+
"data-index": logicalRowPosition.get(row.id),
|
|
1434
1725
|
id: opts.rowElementId ?? restRowProps.id,
|
|
1435
1726
|
onClick: buildRowClickHandler(row, rowOnClick, onRowClick, blocked),
|
|
1436
1727
|
onKeyDown: (event)=>{
|
|
1437
1728
|
restRowProps.onKeyDown?.(event);
|
|
1438
1729
|
opts.rowKeyDown?.(event);
|
|
1439
1730
|
},
|
|
1440
|
-
ref:
|
|
1731
|
+
ref: (node)=>{
|
|
1732
|
+
composeRowRef(dnd, rowRef)(node);
|
|
1733
|
+
if (virtualizationUsable) rowVirtualizer.measureElement(node);
|
|
1734
|
+
},
|
|
1441
1735
|
selected: enableRowSelection ? row.getIsSelected() : void 0,
|
|
1442
1736
|
style: {
|
|
1443
1737
|
...rowStyle,
|
|
@@ -1451,7 +1745,6 @@ function DataTable(props) {
|
|
|
1451
1745
|
});
|
|
1452
1746
|
const renderBodyRow = (row, rowIndex, dnd)=>{
|
|
1453
1747
|
const rowIsClickable = !!onRowClick && !locked;
|
|
1454
|
-
const actionsColumn = hasActionsColumn ? 1 : 0;
|
|
1455
1748
|
const rowElementId = editingRowElementId(editingRowId, instanceId, row.id);
|
|
1456
1749
|
const rowKeyDown = rowIsClickable ? buildRowKeyDownHandler(row, onRowClick, blocked) : void 0;
|
|
1457
1750
|
const mainRow = buildMainRow(row, rowIndex, dnd, {
|
|
@@ -1459,28 +1752,35 @@ function DataTable(props) {
|
|
|
1459
1752
|
rowElementId,
|
|
1460
1753
|
rowKeyDown
|
|
1461
1754
|
});
|
|
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
|
-
]
|
|
1755
|
+
return /*#__PURE__*/ jsx(external_react_Fragment, {
|
|
1756
|
+
children: mainRow
|
|
1475
1757
|
}, row.id);
|
|
1476
1758
|
};
|
|
1477
1759
|
const rowReorderActive = enableRowReorder && !locked && 0 === sorting.length && 0 === columnFilters.length && !globalFilter;
|
|
1478
|
-
const bodyRows = renderRows.map(({ row, index: rowIndex })=>
|
|
1760
|
+
const bodyRows = renderRows.map(({ row, index: rowIndex, detail })=>{
|
|
1761
|
+
if (detail && renderExpandedRow) {
|
|
1762
|
+
const index = (logicalRowPosition.get(row.id) ?? rowIndex) + 1;
|
|
1763
|
+
return /*#__PURE__*/ jsx(external_react_Fragment, {
|
|
1764
|
+
children: renderExpandedDetailRow({
|
|
1765
|
+
row,
|
|
1766
|
+
renderExpandedRow,
|
|
1767
|
+
colSpan: columnCount + (hasActionsColumn ? 1 : 0),
|
|
1768
|
+
instanceId,
|
|
1769
|
+
styles,
|
|
1770
|
+
tintNestedRows,
|
|
1771
|
+
rowIndex: headerRowCount + pageRowOffset + index + 1,
|
|
1772
|
+
virtualIndex: index,
|
|
1773
|
+
measureElement: virtualizationUsable ? rowVirtualizer.measureElement : void 0
|
|
1774
|
+
})
|
|
1775
|
+
}, `${row.id}-detail`);
|
|
1776
|
+
}
|
|
1777
|
+
return rowReorderActive && 0 === row.depth ? /*#__PURE__*/ jsx(SortableRow, {
|
|
1479
1778
|
index: rootRowIds.indexOf(row.id),
|
|
1480
1779
|
label: getRowLabel?.(row) ?? `row ${row.id}`,
|
|
1481
1780
|
row: row,
|
|
1482
1781
|
children: (dnd)=>renderBodyRow(row, rowIndex, dnd)
|
|
1483
|
-
}, row.id) : renderBodyRow(row, rowIndex)
|
|
1782
|
+
}, row.id) : renderBodyRow(row, rowIndex);
|
|
1783
|
+
});
|
|
1484
1784
|
const skeletonRows = (count, keyPrefix)=>Array.from({
|
|
1485
1785
|
length: count
|
|
1486
1786
|
}, (_, i)=>`${keyPrefix}-${i}`).map((rowKey)=>/*#__PURE__*/ jsxs(Table.Row, {
|
|
@@ -1488,24 +1788,26 @@ function DataTable(props) {
|
|
|
1488
1788
|
children: [
|
|
1489
1789
|
leafColumns.map((column)=>/*#__PURE__*/ jsx(Table.Cell, {
|
|
1490
1790
|
children: /*#__PURE__*/ jsx(Skeleton.Text, {
|
|
1791
|
+
className: "data-table-skeleton",
|
|
1491
1792
|
noOfLines: 1,
|
|
1492
1793
|
size: size
|
|
1493
1794
|
})
|
|
1494
1795
|
}, `${rowKey}-${column.id}`)),
|
|
1495
1796
|
hasActionsColumn && /*#__PURE__*/ jsx(Table.Cell, {
|
|
1496
|
-
className: stickyActions ? "data-table-frozen-cell sticky
|
|
1797
|
+
className: stickyActions ? "data-table-frozen-cell data-table-actions-sticky sticky" : void 0,
|
|
1497
1798
|
numeric: true,
|
|
1498
1799
|
style: stickyActions ? {
|
|
1499
1800
|
zIndex: DATA_TABLE_Z.stickyActionsCell
|
|
1500
1801
|
} : void 0,
|
|
1501
1802
|
children: /*#__PURE__*/ jsx(Skeleton.Text, {
|
|
1803
|
+
className: "data-table-skeleton",
|
|
1502
1804
|
noOfLines: 1,
|
|
1503
1805
|
size: size
|
|
1504
1806
|
})
|
|
1505
1807
|
})
|
|
1506
1808
|
]
|
|
1507
1809
|
}, rowKey));
|
|
1508
|
-
|
|
1810
|
+
let emptyState = /*#__PURE__*/ jsxs("div", {
|
|
1509
1811
|
className: styles.empty(),
|
|
1510
1812
|
children: [
|
|
1511
1813
|
/*#__PURE__*/ jsx(Icon, {
|
|
@@ -1525,14 +1827,23 @@ function DataTable(props) {
|
|
|
1525
1827
|
})
|
|
1526
1828
|
]
|
|
1527
1829
|
});
|
|
1830
|
+
if (invalidPage) emptyState = /*#__PURE__*/ jsx(StatusText, {
|
|
1831
|
+
children: translations.paginationPendingLabel
|
|
1832
|
+
});
|
|
1833
|
+
if (renderEmpty) emptyState = renderEmpty();
|
|
1528
1834
|
let statusMessage = "";
|
|
1529
|
-
if (loading) statusMessage = translations.loadingLabel;
|
|
1530
|
-
else if (
|
|
1835
|
+
if (loading || loadingMore) statusMessage = translations.loadingLabel;
|
|
1836
|
+
else if (invalidPage) statusMessage = translations.paginationPendingLabel;
|
|
1837
|
+
else if (0 === rows.length) statusMessage = renderEmpty ? "" : translations.emptyTitle;
|
|
1531
1838
|
else if (isEditing) statusMessage = translations.editingLabel;
|
|
1532
1839
|
const emptyRow = /*#__PURE__*/ jsx("tr", {
|
|
1533
1840
|
children: /*#__PURE__*/ jsx(Table.Cell, {
|
|
1841
|
+
className: "p-0!",
|
|
1534
1842
|
colSpan: columnCount + (hasActionsColumn ? 1 : 0),
|
|
1535
|
-
children:
|
|
1843
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
1844
|
+
className: styles.emptyViewport(),
|
|
1845
|
+
children: emptyState
|
|
1846
|
+
})
|
|
1536
1847
|
})
|
|
1537
1848
|
});
|
|
1538
1849
|
let bodyState = "rows";
|
|
@@ -1546,6 +1857,8 @@ function DataTable(props) {
|
|
|
1546
1857
|
"rows" === bodyState && /*#__PURE__*/ jsxs(Fragment, {
|
|
1547
1858
|
children: [
|
|
1548
1859
|
paddingTop > 0 && /*#__PURE__*/ jsx("tr", {
|
|
1860
|
+
"aria-hidden": "true",
|
|
1861
|
+
tabIndex: -1,
|
|
1549
1862
|
children: /*#__PURE__*/ jsx("td", {
|
|
1550
1863
|
colSpan: columnCount + (hasActionsColumn ? 1 : 0),
|
|
1551
1864
|
style: {
|
|
@@ -1556,6 +1869,8 @@ function DataTable(props) {
|
|
|
1556
1869
|
bodyRows,
|
|
1557
1870
|
loadingMore && skeletonRows(1, "skeleton-more"),
|
|
1558
1871
|
paddingBottom > 0 && /*#__PURE__*/ jsx("tr", {
|
|
1872
|
+
"aria-hidden": "true",
|
|
1873
|
+
tabIndex: -1,
|
|
1559
1874
|
children: /*#__PURE__*/ jsx("td", {
|
|
1560
1875
|
colSpan: columnCount + (hasActionsColumn ? 1 : 0),
|
|
1561
1876
|
style: {
|
|
@@ -1568,13 +1883,15 @@ function DataTable(props) {
|
|
|
1568
1883
|
]
|
|
1569
1884
|
});
|
|
1570
1885
|
const footerContent = hasFooter ? /*#__PURE__*/ jsx(Table.Footer, {
|
|
1571
|
-
children: table.getFooterGroups().map((footerGroup)=>/*#__PURE__*/ jsxs(Table.Row, {
|
|
1886
|
+
children: table.getFooterGroups().map((footerGroup, footerIndex)=>/*#__PURE__*/ jsxs(Table.Row, {
|
|
1887
|
+
"aria-rowindex": headerRowCount + footerRowOffset + footerIndex + 1,
|
|
1572
1888
|
children: [
|
|
1573
1889
|
footerGroup.headers.map((header)=>/*#__PURE__*/ jsx(Table.Cell, {
|
|
1890
|
+
colSpan: header.colSpan,
|
|
1574
1891
|
children: header.isPlaceholder ? null : flexRender(header.column.columnDef.footer, header.getContext())
|
|
1575
1892
|
}, header.id)),
|
|
1576
1893
|
hasActionsColumn && /*#__PURE__*/ jsx(Table.Cell, {
|
|
1577
|
-
className: stickyActions ? "
|
|
1894
|
+
className: stickyActions ? "data-table-actions-sticky sticky bg-data-table-footer-bg" : void 0,
|
|
1578
1895
|
numeric: true,
|
|
1579
1896
|
style: stickyActions ? {
|
|
1580
1897
|
zIndex: DATA_TABLE_Z.stickyActionsCell
|
|
@@ -1583,11 +1900,21 @@ function DataTable(props) {
|
|
|
1583
1900
|
]
|
|
1584
1901
|
}, footerGroup.id))
|
|
1585
1902
|
}) : null;
|
|
1903
|
+
const fixedTableMinWidth = "fixed" === tableLayout ? `calc(${[
|
|
1904
|
+
...leafColumns.map((column)=>{
|
|
1905
|
+
const sizing = getColumnSizeStyles(column, enableColumnResizing, columnSizing);
|
|
1906
|
+
const minimum = String(sizing.minWidth ?? `${column.getSize()}px`);
|
|
1907
|
+
return minimum.includes("%") ? `${column.getSize()}px` : minimum;
|
|
1908
|
+
}),
|
|
1909
|
+
...hasActionsColumn ? [
|
|
1910
|
+
`${fixedActionsWidth ?? 0}px`
|
|
1911
|
+
] : []
|
|
1912
|
+
].join(" + ")})` : void 0;
|
|
1586
1913
|
const tableEl = /*#__PURE__*/ jsx(FieldTableLayoutContext.Provider, {
|
|
1587
1914
|
value: tableLayout,
|
|
1588
1915
|
children: /*#__PURE__*/ jsxs(Table, {
|
|
1589
|
-
"aria-busy": loading || loadingMore || void 0,
|
|
1590
|
-
"aria-rowcount":
|
|
1916
|
+
"aria-busy": loading || loadingMore || invalidPage || void 0,
|
|
1917
|
+
"aria-rowcount": accessibleRowCount,
|
|
1591
1918
|
interactive: (interactive || !!onRowClick) && !locked,
|
|
1592
1919
|
showColumnBorder: showColumnBorder,
|
|
1593
1920
|
size: size,
|
|
@@ -1596,12 +1923,28 @@ function DataTable(props) {
|
|
|
1596
1923
|
...slotProps?.root,
|
|
1597
1924
|
style: {
|
|
1598
1925
|
tableLayout,
|
|
1926
|
+
minWidth: fixedTableMinWidth,
|
|
1599
1927
|
...slotProps?.root?.style
|
|
1600
1928
|
},
|
|
1601
1929
|
children: [
|
|
1602
1930
|
caption && /*#__PURE__*/ jsx(Table.Caption, {
|
|
1931
|
+
id: `${instanceId}-caption`,
|
|
1603
1932
|
children: caption
|
|
1604
1933
|
}),
|
|
1934
|
+
/*#__PURE__*/ jsxs("colgroup", {
|
|
1935
|
+
children: [
|
|
1936
|
+
leafColumns.map((column)=>/*#__PURE__*/ jsx("col", {
|
|
1937
|
+
style: {
|
|
1938
|
+
width: getColumnSizeStyles(column, enableColumnResizing, columnSizing).width
|
|
1939
|
+
}
|
|
1940
|
+
}, column.id)),
|
|
1941
|
+
hasActionsColumn && /*#__PURE__*/ jsx("col", {
|
|
1942
|
+
style: fixedActionsWidth ? {
|
|
1943
|
+
width: fixedActionsWidth
|
|
1944
|
+
} : void 0
|
|
1945
|
+
})
|
|
1946
|
+
]
|
|
1947
|
+
}),
|
|
1605
1948
|
headerContent,
|
|
1606
1949
|
bodyContent,
|
|
1607
1950
|
footerContent
|
|
@@ -1629,6 +1972,8 @@ function DataTable(props) {
|
|
|
1629
1972
|
blocked,
|
|
1630
1973
|
size,
|
|
1631
1974
|
paginationProps,
|
|
1975
|
+
hasNextPage,
|
|
1976
|
+
paginationBusy: loading || loadingMore || invalidPage,
|
|
1632
1977
|
toolbarActions
|
|
1633
1978
|
};
|
|
1634
1979
|
return /*#__PURE__*/ jsx(DataTableContext.Provider, {
|
|
@@ -1657,13 +2002,18 @@ function DataTable(props) {
|
|
|
1657
2002
|
})
|
|
1658
2003
|
]
|
|
1659
2004
|
})),
|
|
1660
|
-
/*#__PURE__*/ jsx("
|
|
1661
|
-
|
|
2005
|
+
/*#__PURE__*/ jsx("section", {
|
|
2006
|
+
"aria-label": caption ? void 0 : translations.scrollLabel,
|
|
2007
|
+
"aria-labelledby": caption ? `${instanceId}-caption` : void 0,
|
|
2008
|
+
className: styles.scroll({
|
|
2009
|
+
className: "focus-visible:data-table-scroll-focus"
|
|
2010
|
+
}),
|
|
1662
2011
|
onScroll: handleScroll,
|
|
1663
2012
|
ref: scrollRef,
|
|
1664
2013
|
style: maxHeight ? {
|
|
1665
2014
|
maxHeight
|
|
1666
2015
|
} : void 0,
|
|
2016
|
+
tabIndex: 0,
|
|
1667
2017
|
children: scrollBody
|
|
1668
2018
|
}),
|
|
1669
2019
|
enablePagination && /*#__PURE__*/ jsx(DataTable.Pagination, {})
|
|
@@ -1671,7 +2021,7 @@ function DataTable(props) {
|
|
|
1671
2021
|
})
|
|
1672
2022
|
});
|
|
1673
2023
|
}
|
|
1674
|
-
function buildColumns({ userColumns, enableRowReorder, enableRowSelection, locked, getRowLabel, selectAllLabel, selectionLabel, reorderLabel, showSelectAll }) {
|
|
2024
|
+
function buildColumns({ userColumns, enableRowReorder, enableRowSelection, locked, getRowLabel, selectAllLabel, selectionLabel, reorderLabel, selectRowLabel, showSelectAll }) {
|
|
1675
2025
|
const leading = [];
|
|
1676
2026
|
if (enableRowReorder) leading.push({
|
|
1677
2027
|
id: DRAG_COLUMN_ID,
|
|
@@ -1700,7 +2050,7 @@ function buildColumns({ userColumns, enableRowReorder, enableRowSelection, locke
|
|
|
1700
2050
|
children: selectionLabel
|
|
1701
2051
|
}),
|
|
1702
2052
|
cell: ({ row })=>/*#__PURE__*/ jsx(Checkbox, {
|
|
1703
|
-
"aria-label":
|
|
2053
|
+
"aria-label": selectRowLabel(getRowLabel?.(row) ?? `row ${row.id}`),
|
|
1704
2054
|
checked: row.getIsSelected(),
|
|
1705
2055
|
disabled: locked || !row.getCanSelect(),
|
|
1706
2056
|
indeterminate: row.getIsSomeSelected(),
|
|
@@ -1817,13 +2167,58 @@ DataTable.ColumnVisibility = function() {
|
|
|
1817
2167
|
size: size
|
|
1818
2168
|
});
|
|
1819
2169
|
};
|
|
1820
|
-
|
|
1821
|
-
const { table, pageSizeOptions, translations, locked, blocked, size, paginationProps } = useDataTableContext();
|
|
2170
|
+
function paginationSummary(table, translations) {
|
|
1822
2171
|
const state = table.state.pagination;
|
|
1823
2172
|
const declaredPageCount = table.options.pageCount;
|
|
1824
|
-
const
|
|
1825
|
-
const
|
|
1826
|
-
const
|
|
2173
|
+
const isManual = table.options.manualPagination;
|
|
2174
|
+
const manualEmptyTotal = 0 === declaredPageCount ? 0 : void 0;
|
|
2175
|
+
const exactTotal = table.options.rowCount ?? (isManual ? manualEmptyTotal : table.getRowCount());
|
|
2176
|
+
const unknownTotal = isManual && null == exactTotal && -1 === declaredPageCount;
|
|
2177
|
+
const total = exactTotal ?? (null != declaredPageCount && declaredPageCount >= 0 ? declaredPageCount * state.pageSize : table.getRowCount());
|
|
2178
|
+
const returnedCount = table.getRowModel().rows.length;
|
|
2179
|
+
const start = 0 === returnedCount ? 0 : state.pageIndex * state.pageSize + 1;
|
|
2180
|
+
const end = 0 === returnedCount ? 0 : Math.min(state.pageIndex * state.pageSize + returnedCount, exactTotal ?? 1 / 0);
|
|
2181
|
+
const rangeText = null == exactTotal ? translations.pageLabel({
|
|
2182
|
+
page: state.pageIndex + 1,
|
|
2183
|
+
pageCount: null != declaredPageCount && declaredPageCount >= 0 ? declaredPageCount : void 0
|
|
2184
|
+
}) : translations.rangeLabel({
|
|
2185
|
+
start: end < start ? 0 : start,
|
|
2186
|
+
end,
|
|
2187
|
+
total: exactTotal
|
|
2188
|
+
});
|
|
2189
|
+
return {
|
|
2190
|
+
total,
|
|
2191
|
+
unknownTotal,
|
|
2192
|
+
rangeText
|
|
2193
|
+
};
|
|
2194
|
+
}
|
|
2195
|
+
DataTable.Pagination = function() {
|
|
2196
|
+
const { table, pageSizeOptions, translations, locked, blocked, size, paginationProps, hasNextPage, paginationBusy } = useDataTableContext();
|
|
2197
|
+
const state = table.state.pagination;
|
|
2198
|
+
const summary = paginationSummary(table, translations);
|
|
2199
|
+
const settledPager = useRef({
|
|
2200
|
+
...summary,
|
|
2201
|
+
...state,
|
|
2202
|
+
canNext: hasNextPage ?? table.getCanNextPage()
|
|
2203
|
+
});
|
|
2204
|
+
const currentPager = {
|
|
2205
|
+
...summary,
|
|
2206
|
+
...state,
|
|
2207
|
+
canNext: hasNextPage ?? table.getCanNextPage()
|
|
2208
|
+
};
|
|
2209
|
+
const pager = paginationBusy ? settledPager.current : currentPager;
|
|
2210
|
+
const controlsRef = useRef(null);
|
|
2211
|
+
const focusedControl = useRef(null);
|
|
2212
|
+
useLayoutEffect(()=>{
|
|
2213
|
+
if (!paginationBusy) settledPager.current = currentPager;
|
|
2214
|
+
const previous = focusedControl.current;
|
|
2215
|
+
const controls = controlsRef.current;
|
|
2216
|
+
const doc = controls?.ownerDocument;
|
|
2217
|
+
if (previous && !previous.isConnected && doc && doc.activeElement === doc.body) {
|
|
2218
|
+
const successor = controls?.querySelector('[aria-current="page"][href]') ?? controls?.querySelector("a[href], button:not(:disabled)");
|
|
2219
|
+
successor?.focus();
|
|
2220
|
+
}
|
|
2221
|
+
});
|
|
1827
2222
|
const styles = dataTableVariants();
|
|
1828
2223
|
const pageSizeItems = pageSizeOptions.map((n)=>({
|
|
1829
2224
|
label: String(n),
|
|
@@ -1835,40 +2230,78 @@ DataTable.Pagination = function() {
|
|
|
1835
2230
|
children: [
|
|
1836
2231
|
/*#__PURE__*/ jsx("span", {
|
|
1837
2232
|
className: styles.paginationInfo(),
|
|
1838
|
-
children: translations.
|
|
1839
|
-
start,
|
|
1840
|
-
end,
|
|
1841
|
-
total
|
|
1842
|
-
})
|
|
2233
|
+
children: paginationBusy ? translations.loadingLabel : summary.rangeText
|
|
1843
2234
|
}),
|
|
1844
2235
|
/*#__PURE__*/ jsxs("div", {
|
|
2236
|
+
"aria-busy": paginationBusy || void 0,
|
|
1845
2237
|
className: styles.paginationControls(),
|
|
2238
|
+
onBlurCapture: (event)=>{
|
|
2239
|
+
if (event.relatedTarget && !event.currentTarget.contains(event.relatedTarget)) focusedControl.current = null;
|
|
2240
|
+
},
|
|
2241
|
+
onFocusCapture: (event)=>{
|
|
2242
|
+
focusedControl.current = event.target;
|
|
2243
|
+
},
|
|
2244
|
+
ref: controlsRef,
|
|
1846
2245
|
children: [
|
|
1847
|
-
/*#__PURE__*/
|
|
2246
|
+
pager.unknownTotal ? /*#__PURE__*/ jsxs(Fragment, {
|
|
2247
|
+
children: [
|
|
2248
|
+
/*#__PURE__*/ jsx(Button, {
|
|
2249
|
+
"aria-disabled": paginationBusy || void 0,
|
|
2250
|
+
disabled: locked || 0 === pager.pageIndex,
|
|
2251
|
+
onClick: ()=>{
|
|
2252
|
+
if (!(paginationBusy || blocked("paginate"))) table.previousPage();
|
|
2253
|
+
},
|
|
2254
|
+
size: size,
|
|
2255
|
+
theme: "outlined",
|
|
2256
|
+
variant: "secondary",
|
|
2257
|
+
children: translations.previousPageLabel
|
|
2258
|
+
}),
|
|
2259
|
+
/*#__PURE__*/ jsx(Button, {
|
|
2260
|
+
"aria-disabled": paginationBusy || void 0,
|
|
2261
|
+
disabled: locked || !pager.canNext,
|
|
2262
|
+
onClick: ()=>{
|
|
2263
|
+
if (!(paginationBusy || blocked("paginate"))) table.nextPage();
|
|
2264
|
+
},
|
|
2265
|
+
size: size,
|
|
2266
|
+
theme: "outlined",
|
|
2267
|
+
variant: "secondary",
|
|
2268
|
+
children: translations.nextPageLabel
|
|
2269
|
+
})
|
|
2270
|
+
]
|
|
2271
|
+
}) : /*#__PURE__*/ jsx(Pagination, {
|
|
1848
2272
|
size: size,
|
|
1849
2273
|
...paginationProps,
|
|
1850
|
-
|
|
2274
|
+
"aria-disabled": paginationBusy || locked || void 0,
|
|
2275
|
+
count: pager.total,
|
|
1851
2276
|
getPageUrl: ()=>"#",
|
|
1852
2277
|
linkProps: {
|
|
1853
2278
|
...paginationProps?.linkProps,
|
|
1854
2279
|
onClick: (event)=>{
|
|
1855
|
-
|
|
1856
|
-
event
|
|
2280
|
+
if (paginationBusy) event.preventDefault();
|
|
2281
|
+
else paginationProps?.linkProps?.onClick?.(event);
|
|
1857
2282
|
}
|
|
1858
2283
|
},
|
|
2284
|
+
onClick: (event)=>{
|
|
2285
|
+
paginationProps?.onClick?.(event);
|
|
2286
|
+
event.preventDefault();
|
|
2287
|
+
},
|
|
1859
2288
|
onPageChange: (page)=>{
|
|
1860
|
-
if (!blocked("paginate")) table.setPageIndex(page - 1);
|
|
2289
|
+
if (!(paginationBusy || blocked("paginate"))) table.setPageIndex(page - 1);
|
|
1861
2290
|
},
|
|
1862
|
-
page:
|
|
1863
|
-
pageSize:
|
|
2291
|
+
page: pager.pageIndex + 1,
|
|
2292
|
+
pageSize: pager.pageSize
|
|
1864
2293
|
}),
|
|
1865
2294
|
/*#__PURE__*/ jsx(FieldSelect, {
|
|
1866
2295
|
ariaLabel: translations.pageSizeLabel,
|
|
1867
2296
|
disabled: locked,
|
|
1868
2297
|
items: pageSizeItems,
|
|
1869
2298
|
onChange: (v)=>{
|
|
1870
|
-
if (!blocked("paginate")) table.
|
|
2299
|
+
if (!(paginationBusy || blocked("paginate"))) table.setPagination({
|
|
2300
|
+
pageIndex: 0,
|
|
2301
|
+
pageSize: Number(v)
|
|
2302
|
+
});
|
|
1871
2303
|
},
|
|
2304
|
+
readOnly: paginationBusy,
|
|
1872
2305
|
size: size,
|
|
1873
2306
|
value: String(state.pageSize)
|
|
1874
2307
|
})
|