@dashforge/tw 1.1.0 → 1.2.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/CHANGELOG.md +134 -1
- package/README.md +45 -0
- package/dist/index.esm.js +3986 -477
- package/dist/src/components/Accordion/Accordion.d.ts.map +1 -1
- package/dist/src/components/Accordion/accordion.types.d.ts +7 -0
- package/dist/src/components/Accordion/accordion.types.d.ts.map +1 -1
- package/dist/src/components/Alert/Alert.d.ts +1 -1
- package/dist/src/components/Alert/Alert.d.ts.map +1 -1
- package/dist/src/components/Alert/alert.types.d.ts +17 -0
- package/dist/src/components/Alert/alert.types.d.ts.map +1 -1
- package/dist/src/components/AppShell/AppShell.d.ts.map +1 -1
- package/dist/src/components/AppShell/appShell.types.d.ts +7 -0
- package/dist/src/components/AppShell/appShell.types.d.ts.map +1 -1
- package/dist/src/components/Autocomplete/Autocomplete.d.ts.map +1 -1
- package/dist/src/components/Autocomplete/autocomplete.types.d.ts +47 -1
- package/dist/src/components/Autocomplete/autocomplete.types.d.ts.map +1 -1
- package/dist/src/components/Avatar/Avatar.d.ts.map +1 -1
- package/dist/src/components/Avatar/avatar.types.d.ts +17 -1
- package/dist/src/components/Avatar/avatar.types.d.ts.map +1 -1
- package/dist/src/components/Badge/Badge.d.ts.map +1 -1
- package/dist/src/components/Badge/badge.types.d.ts +27 -2
- package/dist/src/components/Badge/badge.types.d.ts.map +1 -1
- package/dist/src/components/Box/Box.d.ts.map +1 -1
- package/dist/src/components/Box/box.types.d.ts +64 -1
- package/dist/src/components/Box/box.types.d.ts.map +1 -1
- package/dist/src/components/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
- package/dist/src/components/Breadcrumbs/breadcrumbs.types.d.ts +26 -1
- package/dist/src/components/Breadcrumbs/breadcrumbs.types.d.ts.map +1 -1
- package/dist/src/components/Button/Button.d.ts.map +1 -1
- package/dist/src/components/Button/button.types.d.ts +53 -1
- package/dist/src/components/Button/button.types.d.ts.map +1 -1
- package/dist/src/components/Calendar/Calendar.d.ts.map +1 -1
- package/dist/src/components/Calendar/calendar.types.d.ts +16 -0
- package/dist/src/components/Calendar/calendar.types.d.ts.map +1 -1
- package/dist/src/components/Card/Card.d.ts.map +1 -1
- package/dist/src/components/Card/card.types.d.ts +17 -0
- package/dist/src/components/Card/card.types.d.ts.map +1 -1
- package/dist/src/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/src/components/Checkbox/checkbox.types.d.ts +19 -1
- package/dist/src/components/Checkbox/checkbox.types.d.ts.map +1 -1
- package/dist/src/components/Chip/Chip.d.ts.map +1 -1
- package/dist/src/components/Chip/chip.types.d.ts +40 -1
- package/dist/src/components/Chip/chip.types.d.ts.map +1 -1
- package/dist/src/components/ConfirmDialog/ConfirmDialog.d.ts.map +1 -1
- package/dist/src/components/ConfirmDialog/confirmDialog.types.d.ts +30 -2
- package/dist/src/components/ConfirmDialog/confirmDialog.types.d.ts.map +1 -1
- package/dist/src/components/Container/Container.d.ts.map +1 -1
- package/dist/src/components/Container/container.types.d.ts +29 -1
- package/dist/src/components/Container/container.types.d.ts.map +1 -1
- package/dist/src/components/DataGrid/DataGrid.d.ts +1 -1
- package/dist/src/components/DataGrid/DataGrid.d.ts.map +1 -1
- package/dist/src/components/DataGrid/dataGrid.types.d.ts +124 -10
- package/dist/src/components/DataGrid/dataGrid.types.d.ts.map +1 -1
- package/dist/src/components/DatePicker/DatePicker.d.ts +1 -1
- package/dist/src/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/src/components/DatePicker/datePicker.types.d.ts +18 -0
- package/dist/src/components/DatePicker/datePicker.types.d.ts.map +1 -1
- package/dist/src/components/DateRangePicker/DateRangePicker.d.ts +1 -1
- package/dist/src/components/DateRangePicker/DateRangePicker.d.ts.map +1 -1
- package/dist/src/components/DateRangePicker/dateRangePicker.types.d.ts +18 -0
- package/dist/src/components/DateRangePicker/dateRangePicker.types.d.ts.map +1 -1
- package/dist/src/components/DateTimePicker/DateTimePicker.d.ts +1 -1
- package/dist/src/components/DateTimePicker/DateTimePicker.d.ts.map +1 -1
- package/dist/src/components/DateTimePicker/dateTimePicker.types.d.ts +20 -0
- package/dist/src/components/DateTimePicker/dateTimePicker.types.d.ts.map +1 -1
- package/dist/src/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/src/components/Dialog/dialog.types.d.ts +25 -1
- package/dist/src/components/Dialog/dialog.types.d.ts.map +1 -1
- package/dist/src/components/Divider/Divider.d.ts.map +1 -1
- package/dist/src/components/Divider/divider.types.d.ts +37 -1
- package/dist/src/components/Divider/divider.types.d.ts.map +1 -1
- package/dist/src/components/Drawer/Drawer.d.ts +21 -0
- package/dist/src/components/Drawer/Drawer.d.ts.map +1 -0
- package/dist/src/components/Drawer/drawer.types.d.ts +311 -0
- package/dist/src/components/Drawer/drawer.types.d.ts.map +1 -0
- package/dist/src/components/Drawer/drawer.variants.d.ts +177 -0
- package/dist/src/components/Drawer/drawer.variants.d.ts.map +1 -0
- package/dist/src/components/Grid/Grid.d.ts.map +1 -1
- package/dist/src/components/Grid/grid.types.d.ts +16 -0
- package/dist/src/components/Grid/grid.types.d.ts.map +1 -1
- package/dist/src/components/IconButton/IconButton.d.ts.map +1 -1
- package/dist/src/components/IconButton/iconButton.types.d.ts +40 -1
- package/dist/src/components/IconButton/iconButton.types.d.ts.map +1 -1
- package/dist/src/components/LeftNav/LeftNav.d.ts.map +1 -1
- package/dist/src/components/LeftNav/leftNav.types.d.ts +26 -6
- package/dist/src/components/LeftNav/leftNav.types.d.ts.map +1 -1
- package/dist/src/components/Link/Link.d.ts +15 -0
- package/dist/src/components/Link/Link.d.ts.map +1 -0
- package/dist/src/components/Link/link.types.d.ts +169 -0
- package/dist/src/components/Link/link.types.d.ts.map +1 -0
- package/dist/src/components/Link/link.variants.d.ts +107 -0
- package/dist/src/components/Link/link.variants.d.ts.map +1 -0
- package/dist/src/components/Menu/Menu.d.ts +1 -1
- package/dist/src/components/Menu/Menu.d.ts.map +1 -1
- package/dist/src/components/Menu/menu.types.d.ts +20 -0
- package/dist/src/components/Menu/menu.types.d.ts.map +1 -1
- package/dist/src/components/NumberField/NumberField.d.ts.map +1 -1
- package/dist/src/components/NumberField/numberField.types.d.ts +47 -1
- package/dist/src/components/NumberField/numberField.types.d.ts.map +1 -1
- package/dist/src/components/OTPField/OTPField.d.ts.map +1 -1
- package/dist/src/components/OTPField/otpField.types.d.ts +35 -1
- package/dist/src/components/OTPField/otpField.types.d.ts.map +1 -1
- package/dist/src/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/src/components/Pagination/pagination.types.d.ts +26 -1
- package/dist/src/components/Pagination/pagination.types.d.ts.map +1 -1
- package/dist/src/components/Popover/Popover.d.ts.map +1 -1
- package/dist/src/components/Popover/popover.types.d.ts +29 -0
- package/dist/src/components/Popover/popover.types.d.ts.map +1 -1
- package/dist/src/components/Progress/Progress.d.ts +20 -0
- package/dist/src/components/Progress/Progress.d.ts.map +1 -0
- package/dist/src/components/Progress/progress.types.d.ts +200 -0
- package/dist/src/components/Progress/progress.types.d.ts.map +1 -0
- package/dist/src/components/Progress/progress.variants.d.ts +224 -0
- package/dist/src/components/Progress/progress.variants.d.ts.map +1 -0
- package/dist/src/components/RadioGroup/RadioGroup.d.ts.map +1 -1
- package/dist/src/components/RadioGroup/radioGroup.types.d.ts +25 -1
- package/dist/src/components/RadioGroup/radioGroup.types.d.ts.map +1 -1
- package/dist/src/components/Select/Select.d.ts +14 -0
- package/dist/src/components/Select/Select.d.ts.map +1 -0
- package/dist/src/components/Select/select.types.d.ts +272 -0
- package/dist/src/components/Select/select.types.d.ts.map +1 -0
- package/dist/src/components/Select/select.variants.d.ts +204 -0
- package/dist/src/components/Select/select.variants.d.ts.map +1 -0
- package/dist/src/components/Skeleton/Skeleton.d.ts.map +1 -1
- package/dist/src/components/Skeleton/skeleton.types.d.ts +25 -1
- package/dist/src/components/Skeleton/skeleton.types.d.ts.map +1 -1
- package/dist/src/components/Slider/Slider.d.ts +15 -0
- package/dist/src/components/Slider/Slider.d.ts.map +1 -0
- package/dist/src/components/Slider/slider.types.d.ts +268 -0
- package/dist/src/components/Slider/slider.types.d.ts.map +1 -0
- package/dist/src/components/Slider/slider.variants.d.ts +313 -0
- package/dist/src/components/Slider/slider.variants.d.ts.map +1 -0
- package/dist/src/components/Snackbar/Snackbar.d.ts.map +1 -1
- package/dist/src/components/Snackbar/snackbar.types.d.ts +29 -5
- package/dist/src/components/Snackbar/snackbar.types.d.ts.map +1 -1
- package/dist/src/components/Spinner/Spinner.d.ts.map +1 -1
- package/dist/src/components/Spinner/spinner.types.d.ts +22 -2
- package/dist/src/components/Spinner/spinner.types.d.ts.map +1 -1
- package/dist/src/components/Stack/Stack.d.ts.map +1 -1
- package/dist/src/components/Stack/stack.types.d.ts +53 -2
- package/dist/src/components/Stack/stack.types.d.ts.map +1 -1
- package/dist/src/components/Stack/stack.variants.d.ts +23 -0
- package/dist/src/components/Stack/stack.variants.d.ts.map +1 -1
- package/dist/src/components/Stepper/Step.d.ts +30 -0
- package/dist/src/components/Stepper/Step.d.ts.map +1 -0
- package/dist/src/components/Stepper/Stepper.d.ts +15 -0
- package/dist/src/components/Stepper/Stepper.d.ts.map +1 -0
- package/dist/src/components/Stepper/StepperContext.d.ts +8 -0
- package/dist/src/components/Stepper/StepperContext.d.ts.map +1 -0
- package/dist/src/components/Stepper/stepper.types.d.ts +358 -0
- package/dist/src/components/Stepper/stepper.types.d.ts.map +1 -0
- package/dist/src/components/Stepper/stepper.variants.d.ts +253 -0
- package/dist/src/components/Stepper/stepper.variants.d.ts.map +1 -0
- package/dist/src/components/Stepper/useStep.d.ts +53 -0
- package/dist/src/components/Stepper/useStep.d.ts.map +1 -0
- package/dist/src/components/Switch/Switch.d.ts.map +1 -1
- package/dist/src/components/Switch/switch.types.d.ts +44 -1
- package/dist/src/components/Switch/switch.types.d.ts.map +1 -1
- package/dist/src/components/Table/Table.d.ts +1 -1
- package/dist/src/components/Table/Table.d.ts.map +1 -1
- package/dist/src/components/Table/table.types.d.ts +103 -8
- package/dist/src/components/Table/table.types.d.ts.map +1 -1
- package/dist/src/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/src/components/Tabs/tabs.types.d.ts +26 -1
- package/dist/src/components/Tabs/tabs.types.d.ts.map +1 -1
- package/dist/src/components/TextField/TextField.d.ts.map +1 -1
- package/dist/src/components/TextField/textField.types.d.ts +30 -1
- package/dist/src/components/TextField/textField.types.d.ts.map +1 -1
- package/dist/src/components/Textarea/Textarea.d.ts.map +1 -1
- package/dist/src/components/Textarea/textarea.types.d.ts +51 -1
- package/dist/src/components/Textarea/textarea.types.d.ts.map +1 -1
- package/dist/src/components/TimePicker/TimePicker.d.ts +1 -1
- package/dist/src/components/TimePicker/TimePicker.d.ts.map +1 -1
- package/dist/src/components/TimePicker/timePicker.types.d.ts +18 -0
- package/dist/src/components/TimePicker/timePicker.types.d.ts.map +1 -1
- package/dist/src/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/src/components/Tooltip/tooltip.types.d.ts +30 -0
- package/dist/src/components/Tooltip/tooltip.types.d.ts.map +1 -1
- package/dist/src/components/TopBar/TopBar.d.ts.map +1 -1
- package/dist/src/components/TopBar/topBar.types.d.ts +25 -1
- package/dist/src/components/TopBar/topBar.types.d.ts.map +1 -1
- package/dist/src/components/Typography/Typography.d.ts.map +1 -1
- package/dist/src/components/Typography/typography.types.d.ts +47 -1
- package/dist/src/components/Typography/typography.types.d.ts.map +1 -1
- package/dist/src/components/Typography/typography.variants.d.ts +2 -2
- package/dist/src/components/Typography/typography.variants.d.ts.map +1 -1
- package/dist/src/hooks/useStandaloneFieldWarning.d.ts +38 -0
- package/dist/src/hooks/useStandaloneFieldWarning.d.ts.map +1 -0
- package/dist/src/index.d.ts +62 -42
- package/dist/src/index.d.ts.map +1 -1
- package/package.json +11 -5
- package/.swcrc +0 -29
- package/A11Y.md +0 -130
- package/CONSUMER-VALIDATION.md +0 -130
- package/COVERAGE.md +0 -63
- package/PARITY.md +0 -481
- package/PERFORMANCE.md +0 -227
- package/REFINEMENT-NOTES.md +0 -50
- package/THEME-AUDIT.md +0 -174
- package/dashforge-tw-1.0.0.tgz +0 -0
- package/eslint.config.mjs +0 -62
- package/project.json +0 -15
- package/rollup.config.cjs +0 -16
- package/src/components/Accordion/Accordion.test.tsx +0 -95
- package/src/components/Accordion/Accordion.tsx +0 -97
- package/src/components/Accordion/accordion.types.ts +0 -66
- package/src/components/Accordion/accordion.variants.ts +0 -32
- package/src/components/Alert/Alert.test.tsx +0 -302
- package/src/components/Alert/Alert.tsx +0 -186
- package/src/components/Alert/alert.types.ts +0 -144
- package/src/components/Alert/alert.variants.ts +0 -71
- package/src/components/AppShell/AppShell.test.tsx +0 -223
- package/src/components/AppShell/AppShell.tsx +0 -239
- package/src/components/AppShell/appShell.types.ts +0 -49
- package/src/components/AppShell/appShell.variants.ts +0 -54
- package/src/components/AspectRatio/AspectRatio.test.tsx +0 -173
- package/src/components/AspectRatio/AspectRatio.tsx +0 -73
- package/src/components/AspectRatio/aspectRatio.types.ts +0 -54
- package/src/components/Autocomplete/Autocomplete.perf.test.tsx +0 -225
- package/src/components/Autocomplete/Autocomplete.test.tsx +0 -556
- package/src/components/Autocomplete/Autocomplete.tsx +0 -1069
- package/src/components/Autocomplete/autocomplete.types.ts +0 -198
- package/src/components/Autocomplete/autocomplete.variants.ts +0 -141
- package/src/components/Avatar/Avatar.test.tsx +0 -287
- package/src/components/Avatar/Avatar.tsx +0 -304
- package/src/components/Avatar/avatar.types.ts +0 -205
- package/src/components/Avatar/avatar.variants.ts +0 -194
- package/src/components/Badge/Badge.test.tsx +0 -385
- package/src/components/Badge/Badge.tsx +0 -174
- package/src/components/Badge/badge.types.ts +0 -154
- package/src/components/Badge/badge.variants.ts +0 -161
- package/src/components/Box/Box.test.tsx +0 -391
- package/src/components/Box/Box.tsx +0 -112
- package/src/components/Box/box.types.ts +0 -116
- package/src/components/Box/box.variants.ts +0 -230
- package/src/components/Breadcrumbs/Breadcrumbs.perf.test.tsx +0 -128
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +0 -231
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +0 -203
- package/src/components/Breadcrumbs/breadcrumbs.types.ts +0 -87
- package/src/components/Breadcrumbs/breadcrumbs.variants.ts +0 -54
- package/src/components/Button/Button.test.tsx +0 -204
- package/src/components/Button/Button.tsx +0 -151
- package/src/components/Button/button.types.ts +0 -110
- package/src/components/Button/button.variants.ts +0 -159
- package/src/components/Calendar/Calendar.test.tsx +0 -75
- package/src/components/Calendar/Calendar.tsx +0 -264
- package/src/components/Calendar/calendar.types.ts +0 -65
- package/src/components/Calendar/calendar.variants.ts +0 -64
- package/src/components/Card/Card.test.tsx +0 -291
- package/src/components/Card/Card.tsx +0 -241
- package/src/components/Card/card.types.ts +0 -132
- package/src/components/Checkbox/Checkbox.test.tsx +0 -146
- package/src/components/Checkbox/Checkbox.tsx +0 -286
- package/src/components/Checkbox/checkbox.types.ts +0 -88
- package/src/components/Checkbox/checkbox.variants.ts +0 -68
- package/src/components/Chip/Chip.test.tsx +0 -316
- package/src/components/Chip/Chip.tsx +0 -224
- package/src/components/Chip/chip.types.ts +0 -128
- package/src/components/Chip/chip.variants.ts +0 -173
- package/src/components/ConfirmDialog/ConfirmDialog.perf.test.tsx +0 -172
- package/src/components/ConfirmDialog/ConfirmDialog.test.tsx +0 -311
- package/src/components/ConfirmDialog/ConfirmDialog.tsx +0 -252
- package/src/components/ConfirmDialog/confirmDialog.types.ts +0 -70
- package/src/components/ConfirmDialog/confirmDialog.variants.ts +0 -76
- package/src/components/Container/Container.test.tsx +0 -209
- package/src/components/Container/Container.tsx +0 -74
- package/src/components/Container/container.types.ts +0 -45
- package/src/components/Container/container.variants.ts +0 -81
- package/src/components/DataGrid/DataGrid.perf.test.tsx +0 -114
- package/src/components/DataGrid/DataGrid.test.tsx +0 -1153
- package/src/components/DataGrid/DataGrid.tsx +0 -1282
- package/src/components/DataGrid/dataGrid.types.ts +0 -238
- package/src/components/DataGrid/dataGrid.variants.ts +0 -152
- package/src/components/DataGrid/filters/ColumnFilters.test.tsx +0 -330
- package/src/components/DataGrid/filters/ColumnFilters.tsx +0 -456
- package/src/components/DataGrid/reorder/useColumnReorder.test.ts +0 -130
- package/src/components/DataGrid/reorder/useColumnReorder.ts +0 -144
- package/src/components/DataGrid/resize/useColumnResize.test.ts +0 -144
- package/src/components/DataGrid/resize/useColumnResize.ts +0 -135
- package/src/components/DataGrid/visibility/ColumnVisibilityMenu.tsx +0 -186
- package/src/components/DatePicker/DatePicker.test.tsx +0 -76
- package/src/components/DatePicker/DatePicker.tsx +0 -305
- package/src/components/DatePicker/datePicker.types.ts +0 -77
- package/src/components/DatePicker/datePicker.variants.ts +0 -50
- package/src/components/DateRangePicker/DateRangePicker.test.tsx +0 -92
- package/src/components/DateRangePicker/DateRangePicker.tsx +0 -510
- package/src/components/DateRangePicker/dateRangePicker.types.ts +0 -74
- package/src/components/DateRangePicker/dateRangePicker.variants.ts +0 -101
- package/src/components/DateTimePicker/DateTimePicker.test.tsx +0 -78
- package/src/components/DateTimePicker/DateTimePicker.tsx +0 -347
- package/src/components/DateTimePicker/dateTimePicker.types.ts +0 -79
- package/src/components/DateTimePicker/dateTimePicker.variants.ts +0 -55
- package/src/components/Dialog/Dialog.test.tsx +0 -96
- package/src/components/Dialog/Dialog.tsx +0 -102
- package/src/components/Dialog/dialog.types.ts +0 -62
- package/src/components/Dialog/dialog.variants.ts +0 -66
- package/src/components/Divider/Divider.test.tsx +0 -243
- package/src/components/Divider/Divider.tsx +0 -140
- package/src/components/Divider/divider.types.ts +0 -52
- package/src/components/Divider/divider.variants.ts +0 -116
- package/src/components/Grid/Grid.test.tsx +0 -321
- package/src/components/Grid/Grid.tsx +0 -148
- package/src/components/Grid/grid.types.ts +0 -112
- package/src/components/Grid/grid.variants.ts +0 -133
- package/src/components/IconButton/IconButton.test.tsx +0 -367
- package/src/components/IconButton/IconButton.tsx +0 -159
- package/src/components/IconButton/iconButton.types.ts +0 -106
- package/src/components/IconButton/iconButton.variants.ts +0 -31
- package/src/components/LeftNav/LeftNav.perf.test.tsx +0 -172
- package/src/components/LeftNav/LeftNav.test.tsx +0 -302
- package/src/components/LeftNav/LeftNav.tsx +0 -330
- package/src/components/LeftNav/leftNav.types.ts +0 -120
- package/src/components/LeftNav/leftNav.variants.ts +0 -107
- package/src/components/Menu/Menu.test.tsx +0 -408
- package/src/components/Menu/Menu.tsx +0 -335
- package/src/components/Menu/menu.types.ts +0 -221
- package/src/components/Menu/menu.variants.ts +0 -132
- package/src/components/NumberField/NumberField.test.tsx +0 -83
- package/src/components/NumberField/NumberField.tsx +0 -321
- package/src/components/NumberField/numberField.types.ts +0 -72
- package/src/components/NumberField/numberField.variants.ts +0 -94
- package/src/components/OTPField/OTPField.test.tsx +0 -121
- package/src/components/OTPField/OTPField.tsx +0 -250
- package/src/components/OTPField/otpField.types.ts +0 -58
- package/src/components/OTPField/otpField.variants.ts +0 -72
- package/src/components/Pagination/Pagination.test.tsx +0 -314
- package/src/components/Pagination/Pagination.tsx +0 -277
- package/src/components/Pagination/pagination.helpers.ts +0 -102
- package/src/components/Pagination/pagination.types.ts +0 -117
- package/src/components/Pagination/pagination.variants.ts +0 -117
- package/src/components/Popover/Popover.test.tsx +0 -72
- package/src/components/Popover/Popover.tsx +0 -55
- package/src/components/Popover/popover.types.ts +0 -42
- package/src/components/Popover/popover.variants.ts +0 -24
- package/src/components/RadioGroup/RadioGroup.test.tsx +0 -140
- package/src/components/RadioGroup/RadioGroup.tsx +0 -283
- package/src/components/RadioGroup/radioGroup.types.ts +0 -85
- package/src/components/RadioGroup/radioGroup.variants.ts +0 -87
- package/src/components/Skeleton/Skeleton.test.tsx +0 -127
- package/src/components/Skeleton/Skeleton.tsx +0 -49
- package/src/components/Skeleton/skeleton.types.ts +0 -59
- package/src/components/Skeleton/skeleton.variants.ts +0 -87
- package/src/components/Snackbar/Snackbar.perf.test.tsx +0 -144
- package/src/components/Snackbar/Snackbar.test.tsx +0 -327
- package/src/components/Snackbar/Snackbar.tsx +0 -316
- package/src/components/Snackbar/snackbar.types.ts +0 -127
- package/src/components/Snackbar/snackbar.variants.ts +0 -81
- package/src/components/Spinner/Spinner.test.tsx +0 -199
- package/src/components/Spinner/Spinner.tsx +0 -158
- package/src/components/Spinner/spinner.types.ts +0 -113
- package/src/components/Spinner/spinner.variants.ts +0 -83
- package/src/components/Stack/Stack.test.tsx +0 -309
- package/src/components/Stack/Stack.tsx +0 -115
- package/src/components/Stack/stack.types.ts +0 -68
- package/src/components/Stack/stack.variants.ts +0 -80
- package/src/components/Switch/Switch.test.tsx +0 -131
- package/src/components/Switch/Switch.tsx +0 -158
- package/src/components/Switch/switch.types.ts +0 -36
- package/src/components/Switch/switch.variants.ts +0 -70
- package/src/components/Table/Table.perf.test.tsx +0 -81
- package/src/components/Table/Table.test.tsx +0 -674
- package/src/components/Table/Table.tsx +0 -863
- package/src/components/Table/cells/RenderButton.tsx +0 -23
- package/src/components/Table/cells/RenderChip.tsx +0 -37
- package/src/components/Table/cells/RenderText.tsx +0 -37
- package/src/components/Table/cells/RenderTwoLine.tsx +0 -34
- package/src/components/Table/cells/RowActionsMenu.tsx +0 -147
- package/src/components/Table/cells/cells.test.tsx +0 -247
- package/src/components/Table/cells/index.ts +0 -14
- package/src/components/Table/table.types.ts +0 -438
- package/src/components/Table/table.variants.ts +0 -207
- package/src/components/Tabs/Tabs.test.tsx +0 -145
- package/src/components/Tabs/Tabs.tsx +0 -77
- package/src/components/Tabs/tabs.types.ts +0 -55
- package/src/components/Tabs/tabs.variants.ts +0 -69
- package/src/components/Tabs/useTabs.ts +0 -167
- package/src/components/TextField/TextField.test.tsx +0 -198
- package/src/components/TextField/TextField.tsx +0 -245
- package/src/components/TextField/textField.types.ts +0 -90
- package/src/components/TextField/textField.variants.ts +0 -105
- package/src/components/Textarea/Textarea.test.tsx +0 -75
- package/src/components/Textarea/Textarea.tsx +0 -190
- package/src/components/Textarea/textarea.types.ts +0 -60
- package/src/components/Textarea/textarea.variants.ts +0 -85
- package/src/components/TimePicker/TimePicker.test.tsx +0 -65
- package/src/components/TimePicker/TimePicker.tsx +0 -274
- package/src/components/TimePicker/timePicker.types.ts +0 -69
- package/src/components/TimePicker/timePicker.variants.ts +0 -53
- package/src/components/Tooltip/Tooltip.test.tsx +0 -73
- package/src/components/Tooltip/Tooltip.tsx +0 -70
- package/src/components/Tooltip/tooltip.types.ts +0 -44
- package/src/components/Tooltip/tooltip.variants.ts +0 -28
- package/src/components/TopBar/TopBar.test.tsx +0 -129
- package/src/components/TopBar/TopBar.tsx +0 -66
- package/src/components/TopBar/topBar.types.ts +0 -42
- package/src/components/TopBar/topBar.variants.ts +0 -38
- package/src/components/Typography/Typography.test.tsx +0 -247
- package/src/components/Typography/Typography.tsx +0 -112
- package/src/components/Typography/typography.types.ts +0 -65
- package/src/components/Typography/typography.variants.ts +0 -130
- package/src/components/VisuallyHidden/VisuallyHidden.test.tsx +0 -86
- package/src/components/VisuallyHidden/VisuallyHidden.tsx +0 -59
- package/src/components/VisuallyHidden/visuallyHidden.types.ts +0 -45
- package/src/components/_shared/data/getNestedValue.test.ts +0 -50
- package/src/components/_shared/data/getNestedValue.ts +0 -32
- package/src/components/_shared/data/useColumnAutoDetect.test.ts +0 -123
- package/src/components/_shared/data/useColumnAutoDetect.ts +0 -100
- package/src/components/_shared/data/useControllableState.ts +0 -48
- package/src/components/_shared/data/useDebouncedValue.ts +0 -24
- package/src/components/_shared/data/useTableFilter.test.ts +0 -166
- package/src/components/_shared/data/useTableFilter.ts +0 -118
- package/src/components/_shared/data/useTableSearch.test.ts +0 -115
- package/src/components/_shared/data/useTableSearch.ts +0 -66
- package/src/components/_shared/data/useTableSelection.test.ts +0 -100
- package/src/components/_shared/data/useTableSelection.ts +0 -100
- package/src/components/_shared/data/useTableSort.test.ts +0 -150
- package/src/components/_shared/data/useTableSort.ts +0 -141
- package/src/components/_shared/data/useVirtualizer.test.ts +0 -158
- package/src/components/_shared/data/useVirtualizer.ts +0 -199
- package/src/components/_shared/resolveValidationState.ts +0 -60
- package/src/components/_shared/severity/index.ts +0 -33
- package/src/components/_shared/severity/severity.types.ts +0 -50
- package/src/components/_shared/severity/severityIcons.tsx +0 -104
- package/src/components/_shared/severity/severityVariants.test.ts +0 -136
- package/src/components/_shared/severity/severityVariants.ts +0 -115
- package/src/components/_shared/themeIdentity.test.ts +0 -113
- package/src/hooks/useAccessState.spec.tsx +0 -161
- package/src/hooks/useAccessState.ts +0 -81
- package/src/index.ts +0 -550
- package/src/utils/cn.spec.ts +0 -16
- package/src/utils/cn.ts +0 -29
- package/test-output/vitest/coverage/base.css +0 -224
- package/test-output/vitest/coverage/block-navigation.js +0 -87
- package/test-output/vitest/coverage/clover.xml +0 -2418
- package/test-output/vitest/coverage/coverage-final.json +0 -89
- package/test-output/vitest/coverage/favicon.png +0 -0
- package/test-output/vitest/coverage/index.html +0 -746
- package/test-output/vitest/coverage/prettify.css +0 -1
- package/test-output/vitest/coverage/prettify.js +0 -2
- package/test-output/vitest/coverage/sort-arrow-sprite.png +0 -0
- package/test-output/vitest/coverage/sorter.js +0 -210
- package/test-output/vitest/coverage/src/components/Accordion/Accordion.tsx.html +0 -376
- package/test-output/vitest/coverage/src/components/Accordion/accordion.variants.ts.html +0 -181
- package/test-output/vitest/coverage/src/components/Accordion/index.html +0 -131
- package/test-output/vitest/coverage/src/components/AppShell/AppShell.tsx.html +0 -802
- package/test-output/vitest/coverage/src/components/AppShell/appShell.variants.ts.html +0 -247
- package/test-output/vitest/coverage/src/components/AppShell/index.html +0 -131
- package/test-output/vitest/coverage/src/components/AspectRatio/AspectRatio.tsx.html +0 -304
- package/test-output/vitest/coverage/src/components/AspectRatio/index.html +0 -116
- package/test-output/vitest/coverage/src/components/Autocomplete/Autocomplete.tsx.html +0 -3292
- package/test-output/vitest/coverage/src/components/Autocomplete/autocomplete.variants.ts.html +0 -508
- package/test-output/vitest/coverage/src/components/Autocomplete/index.html +0 -131
- package/test-output/vitest/coverage/src/components/Box/Box.tsx.html +0 -334
- package/test-output/vitest/coverage/src/components/Box/box.variants.ts.html +0 -775
- package/test-output/vitest/coverage/src/components/Box/index.html +0 -131
- package/test-output/vitest/coverage/src/components/Breadcrumbs/Breadcrumbs.tsx.html +0 -694
- package/test-output/vitest/coverage/src/components/Breadcrumbs/breadcrumbs.variants.ts.html +0 -247
- package/test-output/vitest/coverage/src/components/Breadcrumbs/index.html +0 -131
- package/test-output/vitest/coverage/src/components/Button/Button.tsx.html +0 -535
- package/test-output/vitest/coverage/src/components/Button/button.variants.ts.html +0 -562
- package/test-output/vitest/coverage/src/components/Button/index.html +0 -131
- package/test-output/vitest/coverage/src/components/Checkbox/Checkbox.tsx.html +0 -943
- package/test-output/vitest/coverage/src/components/Checkbox/checkbox.variants.ts.html +0 -289
- package/test-output/vitest/coverage/src/components/Checkbox/index.html +0 -131
- package/test-output/vitest/coverage/src/components/ConfirmDialog/ConfirmDialog.tsx.html +0 -841
- package/test-output/vitest/coverage/src/components/ConfirmDialog/confirmDialog.variants.ts.html +0 -313
- package/test-output/vitest/coverage/src/components/ConfirmDialog/index.html +0 -131
- package/test-output/vitest/coverage/src/components/Container/Container.tsx.html +0 -307
- package/test-output/vitest/coverage/src/components/Container/container.variants.ts.html +0 -328
- package/test-output/vitest/coverage/src/components/Container/index.html +0 -131
- package/test-output/vitest/coverage/src/components/DataGrid/DataGrid.tsx.html +0 -3937
- package/test-output/vitest/coverage/src/components/DataGrid/dataGrid.variants.ts.html +0 -541
- package/test-output/vitest/coverage/src/components/DataGrid/filters/ColumnFilters.tsx.html +0 -1453
- package/test-output/vitest/coverage/src/components/DataGrid/filters/index.html +0 -116
- package/test-output/vitest/coverage/src/components/DataGrid/index.html +0 -131
- package/test-output/vitest/coverage/src/components/DataGrid/reorder/index.html +0 -116
- package/test-output/vitest/coverage/src/components/DataGrid/reorder/useColumnReorder.ts.html +0 -517
- package/test-output/vitest/coverage/src/components/DataGrid/resize/index.html +0 -116
- package/test-output/vitest/coverage/src/components/DataGrid/resize/useColumnResize.ts.html +0 -490
- package/test-output/vitest/coverage/src/components/DataGrid/visibility/ColumnVisibilityMenu.tsx.html +0 -592
- package/test-output/vitest/coverage/src/components/DataGrid/visibility/index.html +0 -116
- package/test-output/vitest/coverage/src/components/DateTimePicker/DateTimePicker.tsx.html +0 -1042
- package/test-output/vitest/coverage/src/components/DateTimePicker/dateTimePicker.variants.ts.html +0 -337
- package/test-output/vitest/coverage/src/components/DateTimePicker/index.html +0 -131
- package/test-output/vitest/coverage/src/components/Dialog/Dialog.tsx.html +0 -391
- package/test-output/vitest/coverage/src/components/Dialog/dialog.variants.ts.html +0 -283
- package/test-output/vitest/coverage/src/components/Dialog/index.html +0 -131
- package/test-output/vitest/coverage/src/components/Divider/Divider.tsx.html +0 -505
- package/test-output/vitest/coverage/src/components/Divider/divider.variants.ts.html +0 -433
- package/test-output/vitest/coverage/src/components/Divider/index.html +0 -131
- package/test-output/vitest/coverage/src/components/Grid/Grid.tsx.html +0 -529
- package/test-output/vitest/coverage/src/components/Grid/grid.variants.ts.html +0 -484
- package/test-output/vitest/coverage/src/components/Grid/index.html +0 -131
- package/test-output/vitest/coverage/src/components/LeftNav/LeftNav.tsx.html +0 -1075
- package/test-output/vitest/coverage/src/components/LeftNav/index.html +0 -131
- package/test-output/vitest/coverage/src/components/LeftNav/leftNav.variants.ts.html +0 -406
- package/test-output/vitest/coverage/src/components/NumberField/NumberField.tsx.html +0 -1048
- package/test-output/vitest/coverage/src/components/NumberField/index.html +0 -131
- package/test-output/vitest/coverage/src/components/NumberField/numberField.variants.ts.html +0 -367
- package/test-output/vitest/coverage/src/components/OTPField/OTPField.tsx.html +0 -835
- package/test-output/vitest/coverage/src/components/OTPField/index.html +0 -131
- package/test-output/vitest/coverage/src/components/OTPField/otpField.variants.ts.html +0 -301
- package/test-output/vitest/coverage/src/components/Pagination/Pagination.tsx.html +0 -916
- package/test-output/vitest/coverage/src/components/Pagination/index.html +0 -146
- package/test-output/vitest/coverage/src/components/Pagination/pagination.helpers.ts.html +0 -391
- package/test-output/vitest/coverage/src/components/Pagination/pagination.variants.ts.html +0 -436
- package/test-output/vitest/coverage/src/components/Popover/Popover.tsx.html +0 -250
- package/test-output/vitest/coverage/src/components/Popover/index.html +0 -131
- package/test-output/vitest/coverage/src/components/Popover/popover.variants.ts.html +0 -157
- package/test-output/vitest/coverage/src/components/RadioGroup/RadioGroup.tsx.html +0 -934
- package/test-output/vitest/coverage/src/components/RadioGroup/index.html +0 -131
- package/test-output/vitest/coverage/src/components/RadioGroup/radioGroup.variants.ts.html +0 -346
- package/test-output/vitest/coverage/src/components/Skeleton/Skeleton.tsx.html +0 -232
- package/test-output/vitest/coverage/src/components/Skeleton/index.html +0 -131
- package/test-output/vitest/coverage/src/components/Skeleton/skeleton.variants.ts.html +0 -346
- package/test-output/vitest/coverage/src/components/Snackbar/Snackbar.tsx.html +0 -979
- package/test-output/vitest/coverage/src/components/Snackbar/index.html +0 -131
- package/test-output/vitest/coverage/src/components/Snackbar/snackbar.variants.ts.html +0 -307
- package/test-output/vitest/coverage/src/components/Stack/Stack.tsx.html +0 -430
- package/test-output/vitest/coverage/src/components/Stack/index.html +0 -131
- package/test-output/vitest/coverage/src/components/Stack/stack.variants.ts.html +0 -325
- package/test-output/vitest/coverage/src/components/Switch/Switch.tsx.html +0 -559
- package/test-output/vitest/coverage/src/components/Switch/index.html +0 -131
- package/test-output/vitest/coverage/src/components/Switch/switch.variants.ts.html +0 -295
- package/test-output/vitest/coverage/src/components/Table/Table.tsx.html +0 -2677
- package/test-output/vitest/coverage/src/components/Table/cells/RenderButton.tsx.html +0 -154
- package/test-output/vitest/coverage/src/components/Table/cells/RenderChip.tsx.html +0 -385
- package/test-output/vitest/coverage/src/components/Table/cells/RenderText.tsx.html +0 -196
- package/test-output/vitest/coverage/src/components/Table/cells/RenderTwoLine.tsx.html +0 -187
- package/test-output/vitest/coverage/src/components/Table/cells/RowActionsMenu.tsx.html +0 -526
- package/test-output/vitest/coverage/src/components/Table/cells/index.html +0 -191
- package/test-output/vitest/coverage/src/components/Table/cells/index.ts.html +0 -127
- package/test-output/vitest/coverage/src/components/Table/index.html +0 -131
- package/test-output/vitest/coverage/src/components/Table/table.variants.ts.html +0 -706
- package/test-output/vitest/coverage/src/components/Tabs/Tabs.tsx.html +0 -283
- package/test-output/vitest/coverage/src/components/Tabs/index.html +0 -131
- package/test-output/vitest/coverage/src/components/Tabs/tabs.variants.ts.html +0 -292
- package/test-output/vitest/coverage/src/components/TextField/TextField.tsx.html +0 -820
- package/test-output/vitest/coverage/src/components/TextField/index.html +0 -131
- package/test-output/vitest/coverage/src/components/TextField/textField.variants.ts.html +0 -400
- package/test-output/vitest/coverage/src/components/Textarea/Textarea.tsx.html +0 -655
- package/test-output/vitest/coverage/src/components/Textarea/index.html +0 -131
- package/test-output/vitest/coverage/src/components/Textarea/textarea.variants.ts.html +0 -340
- package/test-output/vitest/coverage/src/components/Tooltip/Tooltip.tsx.html +0 -295
- package/test-output/vitest/coverage/src/components/Tooltip/index.html +0 -131
- package/test-output/vitest/coverage/src/components/Tooltip/tooltip.variants.ts.html +0 -169
- package/test-output/vitest/coverage/src/components/TopBar/TopBar.tsx.html +0 -283
- package/test-output/vitest/coverage/src/components/TopBar/index.html +0 -131
- package/test-output/vitest/coverage/src/components/TopBar/topBar.variants.ts.html +0 -199
- package/test-output/vitest/coverage/src/components/Typography/Typography.tsx.html +0 -421
- package/test-output/vitest/coverage/src/components/Typography/index.html +0 -131
- package/test-output/vitest/coverage/src/components/Typography/typography.variants.ts.html +0 -436
- package/test-output/vitest/coverage/src/components/VisuallyHidden/VisuallyHidden.tsx.html +0 -262
- package/test-output/vitest/coverage/src/components/VisuallyHidden/index.html +0 -116
- package/test-output/vitest/coverage/src/components/_shared/data/getNestedValue.ts.html +0 -181
- package/test-output/vitest/coverage/src/components/_shared/data/index.html +0 -236
- package/test-output/vitest/coverage/src/components/_shared/data/useColumnAutoDetect.ts.html +0 -385
- package/test-output/vitest/coverage/src/components/_shared/data/useControllableState.ts.html +0 -229
- package/test-output/vitest/coverage/src/components/_shared/data/useDebouncedValue.ts.html +0 -157
- package/test-output/vitest/coverage/src/components/_shared/data/useTableFilter.ts.html +0 -439
- package/test-output/vitest/coverage/src/components/_shared/data/useTableSearch.ts.html +0 -283
- package/test-output/vitest/coverage/src/components/_shared/data/useTableSelection.ts.html +0 -385
- package/test-output/vitest/coverage/src/components/_shared/data/useTableSort.ts.html +0 -508
- package/test-output/vitest/coverage/src/components/_shared/data/useVirtualizer.ts.html +0 -682
- package/test-output/vitest/coverage/src/components/_shared/index.html +0 -116
- package/test-output/vitest/coverage/src/components/_shared/resolveValidationState.ts.html +0 -265
- package/test-output/vitest/coverage/src/hooks/index.html +0 -116
- package/test-output/vitest/coverage/src/hooks/useAccessState.ts.html +0 -328
- package/test-output/vitest/coverage/src/index.html +0 -116
- package/test-output/vitest/coverage/src/index.ts.html +0 -1153
- package/test-output/vitest/coverage/src/utils/cn.ts.html +0 -172
- package/test-output/vitest/coverage/src/utils/index.html +0 -116
- package/tsconfig.json +0 -13
- package/tsconfig.lib.json +0 -58
- package/tsconfig.spec.json +0 -34
- package/vite.config.ts +0 -33
- package/vitest.config.mts +0 -29
|
@@ -1,1282 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useMemo,
|
|
3
|
-
useState,
|
|
4
|
-
useEffect,
|
|
5
|
-
type ReactNode,
|
|
6
|
-
type MouseEvent,
|
|
7
|
-
type PointerEvent as RPointerEvent,
|
|
8
|
-
} from 'react';
|
|
9
|
-
import { cn } from '../../utils/cn.js';
|
|
10
|
-
import { useAccessState } from '../../hooks/useAccessState.js';
|
|
11
|
-
import { Skeleton } from '../Skeleton/Skeleton.js';
|
|
12
|
-
import { Pagination } from '../Pagination/Pagination.js';
|
|
13
|
-
import { dataGridVariants } from './dataGrid.variants.js';
|
|
14
|
-
import { useControllableState } from '../_shared/data/useControllableState.js';
|
|
15
|
-
import { useDebouncedValue } from '../_shared/data/useDebouncedValue.js';
|
|
16
|
-
import { useTableSearch } from '../_shared/data/useTableSearch.js';
|
|
17
|
-
import { useTableFilter } from '../_shared/data/useTableFilter.js';
|
|
18
|
-
import { useTableSort, cycleSortFor } from '../_shared/data/useTableSort.js';
|
|
19
|
-
import { useTableSelection } from '../_shared/data/useTableSelection.js';
|
|
20
|
-
import { getNestedValue } from '../_shared/data/getNestedValue.js';
|
|
21
|
-
import { useVirtualizer } from '../_shared/data/useVirtualizer.js';
|
|
22
|
-
import {
|
|
23
|
-
useColumnAutoDetect,
|
|
24
|
-
resolveAlign,
|
|
25
|
-
resolveMonospace,
|
|
26
|
-
resolveTabularNums,
|
|
27
|
-
} from '../_shared/data/useColumnAutoDetect.js';
|
|
28
|
-
import type {
|
|
29
|
-
TableColumn,
|
|
30
|
-
TableColumnInferredType,
|
|
31
|
-
TableFilterType,
|
|
32
|
-
TableSortModel,
|
|
33
|
-
TableFilterModel,
|
|
34
|
-
TableLabels,
|
|
35
|
-
} from '../Table/table.types.js';
|
|
36
|
-
import type { DataGridProps } from './dataGrid.types.js';
|
|
37
|
-
import { ColumnFilterTrigger } from './filters/ColumnFilters.js';
|
|
38
|
-
import { ColumnVisibilityTrigger } from './visibility/ColumnVisibilityMenu.js';
|
|
39
|
-
import { useColumnResize } from './resize/useColumnResize.js';
|
|
40
|
-
import {
|
|
41
|
-
useColumnReorder,
|
|
42
|
-
type ColumnReorderHandlers,
|
|
43
|
-
} from './reorder/useColumnReorder.js';
|
|
44
|
-
|
|
45
|
-
const DEFAULT_LABELS: Required<TableLabels> = {
|
|
46
|
-
searchPlaceholder: 'Search...',
|
|
47
|
-
noData: 'No data',
|
|
48
|
-
noResults: 'No matching results',
|
|
49
|
-
loading: 'Loading…',
|
|
50
|
-
ariaSortNone: 'Not sorted. Click to sort ascending.',
|
|
51
|
-
ariaSortAscending: 'Sorted ascending. Click to sort descending.',
|
|
52
|
-
ariaSortDescending: 'Sorted descending. Click to clear sort.',
|
|
53
|
-
ariaSelectRow: 'Select row',
|
|
54
|
-
ariaSelectAllRows: 'Select all rows',
|
|
55
|
-
ariaExpandRow: 'Expand row',
|
|
56
|
-
ariaCollapseRow: 'Collapse row',
|
|
57
|
-
selectedCount: '{count} selected',
|
|
58
|
-
clearSelection: 'Clear selection',
|
|
59
|
-
filterColumn: 'Filter',
|
|
60
|
-
filterApply: 'Apply',
|
|
61
|
-
filterClear: 'Clear',
|
|
62
|
-
filterMin: 'Min',
|
|
63
|
-
filterMax: 'Max',
|
|
64
|
-
filterFrom: 'From',
|
|
65
|
-
filterTo: 'To',
|
|
66
|
-
filterAll: 'All',
|
|
67
|
-
filterTrue: 'True',
|
|
68
|
-
filterFalse: 'False',
|
|
69
|
-
density: 'Density',
|
|
70
|
-
densityCompact: 'Compact',
|
|
71
|
-
densityComfortable: 'Comfortable',
|
|
72
|
-
densitySpacious: 'Spacious',
|
|
73
|
-
columnsButton: 'Columns',
|
|
74
|
-
columnsTitle: 'Toggle columns',
|
|
75
|
-
columnsToggleAll: 'Toggle all columns',
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Dashforge TW `<DataGrid>` — virtualized data table.
|
|
80
|
-
*
|
|
81
|
-
* Companion to `<Table>` for large data sets (~500+ rows up to
|
|
82
|
-
* millions via virtualization). Same column model, sort/search/
|
|
83
|
-
* filter/selection logic (shared via `_shared/data/` helpers) —
|
|
84
|
-
* differs in render path: only the visible window of rows is mounted
|
|
85
|
-
* in DOM, with spacer `<tr>` above and below to preserve scrollbar
|
|
86
|
-
* size.
|
|
87
|
-
*
|
|
88
|
-
* Virtualization: hand-rolled (`useVirtualizer`) using
|
|
89
|
-
* `IntersectionObserver` + scroll-event + `requestAnimationFrame`
|
|
90
|
-
* debounce + `ResizeObserver`. Zero new runtime deps.
|
|
91
|
-
*
|
|
92
|
-
* Server-side mode (4 independent opt-in flags):
|
|
93
|
-
* - `serverSideSort` — emits `onSortChange` but does NOT sort locally
|
|
94
|
-
* - `serverSideFilter` — emits `onFilterChange` but does NOT filter
|
|
95
|
-
* - `serverSideSearch` — emits `onSearchQueryChange` (debounced)
|
|
96
|
-
* - `serverSidePagination` — `totalCount` prop sizes the virtual
|
|
97
|
-
* scrollbar; `rows` is the page slice from the server
|
|
98
|
-
*
|
|
99
|
-
* Selection at scale: `selectAllScope`:
|
|
100
|
-
* - `'allLoaded'` (default) — header checkbox toggles all rows in
|
|
101
|
-
* `rows` prop
|
|
102
|
-
* - `'visible'` — toggles only the current viewport window
|
|
103
|
-
*/
|
|
104
|
-
export function DataGrid<T extends object>(props: DataGridProps<T>) {
|
|
105
|
-
const {
|
|
106
|
-
rows,
|
|
107
|
-
cols,
|
|
108
|
-
getRowId,
|
|
109
|
-
totalCount: totalCountProp,
|
|
110
|
-
|
|
111
|
-
rowHeight,
|
|
112
|
-
overscan = 5,
|
|
113
|
-
height,
|
|
114
|
-
|
|
115
|
-
sortModel: sortModelProp,
|
|
116
|
-
onSortChange,
|
|
117
|
-
defaultSortModel,
|
|
118
|
-
serverSideSort = false,
|
|
119
|
-
|
|
120
|
-
enableSearch = false,
|
|
121
|
-
searchQuery: searchQueryProp,
|
|
122
|
-
onSearchQueryChange,
|
|
123
|
-
searchPlaceholder,
|
|
124
|
-
searchDebounceMs = 200,
|
|
125
|
-
serverSideSearch = false,
|
|
126
|
-
|
|
127
|
-
filterModel: filterModelProp,
|
|
128
|
-
onFilterChange,
|
|
129
|
-
serverSideFilter = false,
|
|
130
|
-
|
|
131
|
-
hiddenColumns: hiddenColumnsProp,
|
|
132
|
-
onHiddenColumnsChange,
|
|
133
|
-
enableColumnVisibility = true,
|
|
134
|
-
|
|
135
|
-
columnWidths: columnWidthsProp,
|
|
136
|
-
onColumnWidthsChange,
|
|
137
|
-
enableColumnResize = true,
|
|
138
|
-
|
|
139
|
-
columnOrder: columnOrderProp,
|
|
140
|
-
onColumnOrderChange,
|
|
141
|
-
enableColumnReorder = true,
|
|
142
|
-
|
|
143
|
-
rowSelection = 'none',
|
|
144
|
-
selectedRowIds: selectedRowIdsProp,
|
|
145
|
-
onSelectionChange,
|
|
146
|
-
bulkActions,
|
|
147
|
-
selectAllScope = 'allLoaded',
|
|
148
|
-
|
|
149
|
-
pagination,
|
|
150
|
-
serverSidePagination = false,
|
|
151
|
-
|
|
152
|
-
rowActions,
|
|
153
|
-
|
|
154
|
-
loading = false,
|
|
155
|
-
loadingRowCount = 8,
|
|
156
|
-
emptyState,
|
|
157
|
-
|
|
158
|
-
stickyHeader = true,
|
|
159
|
-
caption,
|
|
160
|
-
showCaption = false,
|
|
161
|
-
|
|
162
|
-
access: gridAccess,
|
|
163
|
-
|
|
164
|
-
labels: labelsProp,
|
|
165
|
-
|
|
166
|
-
variant,
|
|
167
|
-
size,
|
|
168
|
-
density,
|
|
169
|
-
|
|
170
|
-
sx,
|
|
171
|
-
slotProps,
|
|
172
|
-
} = props;
|
|
173
|
-
|
|
174
|
-
const labels = { ...DEFAULT_LABELS, ...labelsProp };
|
|
175
|
-
const gridAccessState = useAccessState(gridAccess);
|
|
176
|
-
|
|
177
|
-
// ───── Controllable state ─────
|
|
178
|
-
|
|
179
|
-
const [sortModel, setSortModel] = useControllableState<TableSortModel>({
|
|
180
|
-
controlledValue: sortModelProp,
|
|
181
|
-
defaultValue: defaultSortModel ?? [],
|
|
182
|
-
onChange: onSortChange,
|
|
183
|
-
});
|
|
184
|
-
const [searchQuery, setSearchQuery] = useControllableState<string>({
|
|
185
|
-
controlledValue: searchQueryProp,
|
|
186
|
-
defaultValue: '',
|
|
187
|
-
onChange: onSearchQueryChange,
|
|
188
|
-
});
|
|
189
|
-
// filterModel: in v1-bis the per-column header UI commits filter
|
|
190
|
-
// items to this controllable state. Consumer can lift it via
|
|
191
|
-
// filterModelProp + onFilterChange to drive server-side filtering.
|
|
192
|
-
const [filterModel, setFilterModel] = useControllableState<TableFilterModel>({
|
|
193
|
-
controlledValue: filterModelProp,
|
|
194
|
-
defaultValue: [],
|
|
195
|
-
onChange: onFilterChange,
|
|
196
|
-
});
|
|
197
|
-
const [selectedRowIds, setSelectedRowIds] = useControllableState<string[]>({
|
|
198
|
-
controlledValue: selectedRowIdsProp,
|
|
199
|
-
defaultValue: [],
|
|
200
|
-
onChange: onSelectionChange,
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
// ───── Column visibility ─────
|
|
204
|
-
// Seed default hidden set from `defaultHidden` flag on columns.
|
|
205
|
-
// Memoized to avoid the seed shifting on every render — the
|
|
206
|
-
// controllable state keeps internal state stable thereafter.
|
|
207
|
-
const defaultHiddenColumns = useMemo(
|
|
208
|
-
() =>
|
|
209
|
-
cols
|
|
210
|
-
.filter((c) => c.defaultHidden === true)
|
|
211
|
-
.map((c) => c.field as string),
|
|
212
|
-
[cols],
|
|
213
|
-
);
|
|
214
|
-
const [hiddenColumns, setHiddenColumns] = useControllableState<string[]>({
|
|
215
|
-
controlledValue: hiddenColumnsProp,
|
|
216
|
-
defaultValue: defaultHiddenColumns,
|
|
217
|
-
onChange: onHiddenColumnsChange,
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
// ───── Column widths (resize state) ─────
|
|
221
|
-
// Seed from any `col.width` declared statically. Internal state is
|
|
222
|
-
// applied only when the user actually starts dragging; until then
|
|
223
|
-
// we fall back to the static width from the column def.
|
|
224
|
-
const defaultColumnWidths = useMemo(() => {
|
|
225
|
-
const map: Record<string, number> = {};
|
|
226
|
-
for (const c of cols) {
|
|
227
|
-
if (typeof c.width === 'number') {
|
|
228
|
-
map[c.field as string] = c.width;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return map;
|
|
232
|
-
}, [cols]);
|
|
233
|
-
const [columnWidths, setColumnWidths] = useControllableState<
|
|
234
|
-
Record<string, number>
|
|
235
|
-
>({
|
|
236
|
-
controlledValue: columnWidthsProp,
|
|
237
|
-
defaultValue: defaultColumnWidths,
|
|
238
|
-
onChange: onColumnWidthsChange,
|
|
239
|
-
});
|
|
240
|
-
const { startResize, nudge: nudgeColumnWidth } = useColumnResize({
|
|
241
|
-
widths: columnWidths,
|
|
242
|
-
onChange: setColumnWidths,
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
// ───── Column order (reorder state) ─────
|
|
246
|
-
const defaultColumnOrder = useMemo(
|
|
247
|
-
() => cols.map((c) => c.field as string),
|
|
248
|
-
[cols],
|
|
249
|
-
);
|
|
250
|
-
const [columnOrder, setColumnOrder] = useControllableState<string[]>({
|
|
251
|
-
controlledValue: columnOrderProp,
|
|
252
|
-
defaultValue: defaultColumnOrder,
|
|
253
|
-
onChange: onColumnOrderChange,
|
|
254
|
-
});
|
|
255
|
-
const reorderHandlers = useColumnReorder({
|
|
256
|
-
order: columnOrder,
|
|
257
|
-
onChange: setColumnOrder,
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
// Column reorder rides on native HTML5 drag-and-drop, whose
|
|
261
|
-
// `dragstart` / `drop` events DO NOT fire for touch input. On a
|
|
262
|
-
// coarse-pointer device the drag would be a dead affordance — so
|
|
263
|
-
// we detect the primary pointer and gate reorder off there. Mouse
|
|
264
|
-
// / trackpad / pen (fine pointer) keep the feature. A pointer-event
|
|
265
|
-
// based reorder that also covers touch is tracked as a follow-up
|
|
266
|
-
// in REFINEMENT-NOTES.md.
|
|
267
|
-
const [coarsePointer, setCoarsePointer] = useState(false);
|
|
268
|
-
useEffect(() => {
|
|
269
|
-
if (typeof window === 'undefined' || !window.matchMedia) return;
|
|
270
|
-
const mq = window.matchMedia('(pointer: coarse)');
|
|
271
|
-
setCoarsePointer(mq.matches);
|
|
272
|
-
const onChange = (e: MediaQueryListEvent) => setCoarsePointer(e.matches);
|
|
273
|
-
mq.addEventListener('change', onChange);
|
|
274
|
-
return () => mq.removeEventListener('change', onChange);
|
|
275
|
-
}, []);
|
|
276
|
-
|
|
277
|
-
// Apply the active order to the columns list. Cols not in the
|
|
278
|
-
// order array (e.g. newly-added columns at runtime) are appended
|
|
279
|
-
// in their original position from `cols`.
|
|
280
|
-
const orderedCols = useMemo(() => {
|
|
281
|
-
if (!columnOrder || columnOrder.length === 0) return cols;
|
|
282
|
-
const byField = new Map(
|
|
283
|
-
cols.map((c) => [c.field as string, c] as const),
|
|
284
|
-
);
|
|
285
|
-
const seen = new Set<string>();
|
|
286
|
-
const result: typeof cols = [];
|
|
287
|
-
for (const field of columnOrder) {
|
|
288
|
-
const c = byField.get(field);
|
|
289
|
-
if (c) {
|
|
290
|
-
result.push(c);
|
|
291
|
-
seen.add(field);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
for (const c of cols) {
|
|
295
|
-
if (!seen.has(c.field as string)) result.push(c);
|
|
296
|
-
}
|
|
297
|
-
return result;
|
|
298
|
-
}, [cols, columnOrder]);
|
|
299
|
-
|
|
300
|
-
// ───── RBAC + visibility + reorder: derive final column list ─────
|
|
301
|
-
// - `access.onUnauthorized === 'hide'` removes a column entirely.
|
|
302
|
-
// - `hiddenColumns` is the user-toggled hidden set from the
|
|
303
|
-
// column-visibility dialog.
|
|
304
|
-
// - `orderedCols` is the user-reordered version of `cols`.
|
|
305
|
-
// NOTE: filtering happens on `orderedCols` so the active order is
|
|
306
|
-
// preserved through visibility changes.
|
|
307
|
-
const visibleCols = useMemo(
|
|
308
|
-
() =>
|
|
309
|
-
orderedCols.filter((col) => {
|
|
310
|
-
if (col.access && col.access.onUnauthorized === 'hide') return false;
|
|
311
|
-
if (hiddenColumns.includes(col.field as string)) return false;
|
|
312
|
-
return true;
|
|
313
|
-
}),
|
|
314
|
-
[orderedCols, hiddenColumns],
|
|
315
|
-
);
|
|
316
|
-
|
|
317
|
-
// ───── Smart-default column types ─────
|
|
318
|
-
const columnTypes = useColumnAutoDetect(rows, visibleCols);
|
|
319
|
-
|
|
320
|
-
// ───── Pipeline: search → filter → sort (skip when server-side) ─────
|
|
321
|
-
//
|
|
322
|
-
// Each pipeline hook is ALWAYS called (React hooks rules). The
|
|
323
|
-
// server-side flags decide whether to use the local-computed result
|
|
324
|
-
// or pass the upstream rows through unchanged. The hooks are
|
|
325
|
-
// `useMemo`-based internally so they're cheap when their inputs
|
|
326
|
-
// are unchanged.
|
|
327
|
-
|
|
328
|
-
const debouncedSearchQuery = useDebouncedValue(searchQuery, searchDebounceMs);
|
|
329
|
-
const localSearched = useTableSearch(rows, visibleCols, debouncedSearchQuery);
|
|
330
|
-
const searchedRows = serverSideSearch ? rows : localSearched;
|
|
331
|
-
|
|
332
|
-
const localFiltered = useTableFilter(searchedRows, filterModel);
|
|
333
|
-
const filteredRows = serverSideFilter ? searchedRows : localFiltered;
|
|
334
|
-
|
|
335
|
-
const localSorted = useTableSort(filteredRows, visibleCols, sortModel);
|
|
336
|
-
const sortedRows = serverSideSort ? filteredRows : localSorted;
|
|
337
|
-
|
|
338
|
-
// ───── Virtualization ─────
|
|
339
|
-
|
|
340
|
-
// Effective row count for the virtual scrollbar:
|
|
341
|
-
// - Client-side: actual sorted rows count
|
|
342
|
-
// - Server-side pagination: caller-provided totalCount
|
|
343
|
-
const effectiveTotalCount = serverSidePagination
|
|
344
|
-
? totalCountProp ?? sortedRows.length
|
|
345
|
-
: sortedRows.length;
|
|
346
|
-
|
|
347
|
-
const initialViewportHeight = height ? parseInt(height, 10) || 400 : 400;
|
|
348
|
-
const { scrollRef, window: vWindow } = useVirtualizer({
|
|
349
|
-
totalCount: effectiveTotalCount,
|
|
350
|
-
rowHeight,
|
|
351
|
-
overscan,
|
|
352
|
-
initialViewportHeight,
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
// The rows actually mounted in DOM.
|
|
356
|
-
const renderedRows = useMemo(() => {
|
|
357
|
-
if (serverSidePagination) {
|
|
358
|
-
// In server-side pagination, `rows` IS the page slice; we
|
|
359
|
-
// render all of it (virtualization within the page is still
|
|
360
|
-
// useful for very large page sizes).
|
|
361
|
-
return rows.slice(vWindow.startIndex, vWindow.endIndex + 1);
|
|
362
|
-
}
|
|
363
|
-
return sortedRows.slice(vWindow.startIndex, vWindow.endIndex + 1);
|
|
364
|
-
}, [serverSidePagination, rows, sortedRows, vWindow.startIndex, vWindow.endIndex]);
|
|
365
|
-
|
|
366
|
-
// ───── Selection helpers ─────
|
|
367
|
-
|
|
368
|
-
// For `selectAllScope='visible'`, the select-all scope is the
|
|
369
|
-
// current window. For `'allLoaded'`, it's the whole sorted set.
|
|
370
|
-
const selectAllPool = useMemo(() => {
|
|
371
|
-
if (selectAllScope === 'visible') {
|
|
372
|
-
return renderedRows.map((row, idx) =>
|
|
373
|
-
getRowId(row, vWindow.startIndex + idx),
|
|
374
|
-
);
|
|
375
|
-
}
|
|
376
|
-
return sortedRows.map((row, idx) => getRowId(row, idx));
|
|
377
|
-
}, [selectAllScope, renderedRows, sortedRows, getRowId, vWindow.startIndex]);
|
|
378
|
-
|
|
379
|
-
const selection = useTableSelection(rowSelection, selectedRowIds, setSelectedRowIds);
|
|
380
|
-
|
|
381
|
-
const selectedRows = useMemo(
|
|
382
|
-
() => sortedRows.filter((row, idx) => selection.isSelected(getRowId(row, idx))),
|
|
383
|
-
[sortedRows, selection, getRowId],
|
|
384
|
-
);
|
|
385
|
-
|
|
386
|
-
// ───── Variant recipe ─────
|
|
387
|
-
const v = dataGridVariants({ variant, size, density });
|
|
388
|
-
|
|
389
|
-
// ───── Render ─────
|
|
390
|
-
|
|
391
|
-
if (!gridAccessState.visible) return null;
|
|
392
|
-
|
|
393
|
-
const isInteractive = !gridAccessState.disabled;
|
|
394
|
-
const showSelectionColumn = rowSelection !== 'none';
|
|
395
|
-
const showRowActionsColumn = rowActions != null;
|
|
396
|
-
|
|
397
|
-
const totalColumnCount =
|
|
398
|
-
visibleCols.length +
|
|
399
|
-
(showSelectionColumn ? 1 : 0) +
|
|
400
|
-
(showRowActionsColumn ? 1 : 0);
|
|
401
|
-
|
|
402
|
-
return (
|
|
403
|
-
<div
|
|
404
|
-
className={cn(v.root(), sx, slotProps?.root?.className)}
|
|
405
|
-
data-disabled={!isInteractive ? 'true' : undefined}
|
|
406
|
-
>
|
|
407
|
-
{/* ───── Toolbar ───── */}
|
|
408
|
-
{(enableSearch || enableColumnVisibility) && (
|
|
409
|
-
<div className={cn(v.toolbar(), slotProps?.toolbar?.className)}>
|
|
410
|
-
{enableSearch && (
|
|
411
|
-
<label className={cn(v.search(), slotProps?.search?.className)}>
|
|
412
|
-
<span className="sr-only">{labels.searchPlaceholder}</span>
|
|
413
|
-
<SearchIcon className="ml-2 shrink-0 text-neutral-500" />
|
|
414
|
-
<input
|
|
415
|
-
type="text"
|
|
416
|
-
value={searchQuery}
|
|
417
|
-
onChange={(e) => setSearchQuery(e.target.value)}
|
|
418
|
-
placeholder={searchPlaceholder ?? labels.searchPlaceholder}
|
|
419
|
-
disabled={!isInteractive}
|
|
420
|
-
className={cn(
|
|
421
|
-
'flex-1 bg-transparent border-0 outline-none',
|
|
422
|
-
'px-2 py-1.5',
|
|
423
|
-
'placeholder:text-neutral-400',
|
|
424
|
-
'disabled:opacity-50 disabled:cursor-not-allowed',
|
|
425
|
-
)}
|
|
426
|
-
/>
|
|
427
|
-
</label>
|
|
428
|
-
)}
|
|
429
|
-
{enableColumnVisibility && (
|
|
430
|
-
<ColumnVisibilityTrigger
|
|
431
|
-
cols={cols.filter(
|
|
432
|
-
(c) =>
|
|
433
|
-
// RBAC-hidden columns are never offered in the menu.
|
|
434
|
-
!c.access || c.access.onUnauthorized !== 'hide',
|
|
435
|
-
)}
|
|
436
|
-
hiddenColumns={hiddenColumns}
|
|
437
|
-
onChange={setHiddenColumns}
|
|
438
|
-
disabled={!isInteractive}
|
|
439
|
-
labels={{
|
|
440
|
-
columnsButton: labels.columnsButton,
|
|
441
|
-
columnsTitle: labels.columnsTitle,
|
|
442
|
-
columnsToggleAll: labels.columnsToggleAll,
|
|
443
|
-
}}
|
|
444
|
-
/>
|
|
445
|
-
)}
|
|
446
|
-
</div>
|
|
447
|
-
)}
|
|
448
|
-
|
|
449
|
-
{/* ───── Scroll wrapper (bounded height — required for virt) ───── */}
|
|
450
|
-
<div
|
|
451
|
-
ref={scrollRef}
|
|
452
|
-
className={cn(v.scroll(), slotProps?.scroll?.className)}
|
|
453
|
-
style={height ? { height, maxHeight: height } : undefined}
|
|
454
|
-
>
|
|
455
|
-
{/*
|
|
456
|
-
`aria-rowcount` announces the TRUE total to assistive tech —
|
|
457
|
-
the virtualized DOM only holds the ~visible window, so without
|
|
458
|
-
it a screen reader reports "row N of <window size>" instead of
|
|
459
|
-
"row N of <dataset size>". `+ 1` accounts for the header row.
|
|
460
|
-
Each `<tr>` carries a 1-based `aria-rowindex` (header = 1,
|
|
461
|
-
data rows = absoluteIndex + 2). `-1` when the effective count
|
|
462
|
-
is unknown/zero keeps it a valid (ignored) value.
|
|
463
|
-
*/}
|
|
464
|
-
<table
|
|
465
|
-
className={cn(v.table(), slotProps?.table?.className)}
|
|
466
|
-
aria-rowcount={effectiveTotalCount > 0 ? effectiveTotalCount + 1 : -1}
|
|
467
|
-
>
|
|
468
|
-
{caption != null && (
|
|
469
|
-
<caption className={cn(!showCaption && 'sr-only', 'py-2 text-sm text-neutral-500')}>
|
|
470
|
-
{caption}
|
|
471
|
-
</caption>
|
|
472
|
-
)}
|
|
473
|
-
|
|
474
|
-
<thead
|
|
475
|
-
className={cn(
|
|
476
|
-
stickyHeader ? v.thead() : 'bg-neutral-50',
|
|
477
|
-
slotProps?.thead?.className,
|
|
478
|
-
)}
|
|
479
|
-
>
|
|
480
|
-
<tr
|
|
481
|
-
aria-rowindex={1}
|
|
482
|
-
className={cn(v.headerRow(), slotProps?.headerRow?.className)}
|
|
483
|
-
>
|
|
484
|
-
{showSelectionColumn && (
|
|
485
|
-
<th
|
|
486
|
-
scope="col"
|
|
487
|
-
className={cn(
|
|
488
|
-
v.headerCell(),
|
|
489
|
-
v.selectionCell(),
|
|
490
|
-
v.stickyLeftHeaderCell(),
|
|
491
|
-
slotProps?.headerCell?.className,
|
|
492
|
-
slotProps?.selectionCell?.className,
|
|
493
|
-
)}
|
|
494
|
-
>
|
|
495
|
-
{rowSelection === 'multiple' && (
|
|
496
|
-
<input
|
|
497
|
-
type="checkbox"
|
|
498
|
-
aria-label={labels.ariaSelectAllRows}
|
|
499
|
-
checked={selection.isAllSelected(selectAllPool)}
|
|
500
|
-
ref={(el) => {
|
|
501
|
-
if (el)
|
|
502
|
-
el.indeterminate = selection.isIndeterminate(selectAllPool);
|
|
503
|
-
}}
|
|
504
|
-
onChange={() => selection.toggleAll(selectAllPool)}
|
|
505
|
-
disabled={!isInteractive}
|
|
506
|
-
className="cursor-pointer"
|
|
507
|
-
/>
|
|
508
|
-
)}
|
|
509
|
-
</th>
|
|
510
|
-
)}
|
|
511
|
-
|
|
512
|
-
{visibleCols.map((col) => (
|
|
513
|
-
<HeaderCell
|
|
514
|
-
key={col.field as string}
|
|
515
|
-
col={col}
|
|
516
|
-
sortModel={sortModel}
|
|
517
|
-
onSortClick={(e) =>
|
|
518
|
-
handleSortClick(col, e, sortModel, setSortModel)
|
|
519
|
-
}
|
|
520
|
-
inferredType={columnTypes.get(col.field as string)}
|
|
521
|
-
filterModel={filterModel}
|
|
522
|
-
onFilterChange={setFilterModel}
|
|
523
|
-
effectiveWidth={resolveColumnWidth(col, columnWidths)}
|
|
524
|
-
resizable={
|
|
525
|
-
enableColumnResize && col.resizable !== false
|
|
526
|
-
}
|
|
527
|
-
startResize={startResize}
|
|
528
|
-
nudgeColumnWidth={nudgeColumnWidth}
|
|
529
|
-
reorderable={
|
|
530
|
-
enableColumnReorder &&
|
|
531
|
-
col.reorderable !== false &&
|
|
532
|
-
!coarsePointer
|
|
533
|
-
}
|
|
534
|
-
reorderHandlers={reorderHandlers}
|
|
535
|
-
labels={labels}
|
|
536
|
-
className={cn(
|
|
537
|
-
v.headerCell(),
|
|
538
|
-
col.sticky === 'left' && v.stickyLeftHeaderCell(),
|
|
539
|
-
col.sticky === 'right' && v.stickyRightHeaderCell(),
|
|
540
|
-
slotProps?.headerCell?.className,
|
|
541
|
-
)}
|
|
542
|
-
buttonClassName={v.headerCellButton()}
|
|
543
|
-
disabled={!isInteractive}
|
|
544
|
-
/>
|
|
545
|
-
))}
|
|
546
|
-
|
|
547
|
-
{showRowActionsColumn && (
|
|
548
|
-
<th
|
|
549
|
-
scope="col"
|
|
550
|
-
aria-hidden="true"
|
|
551
|
-
className={cn(
|
|
552
|
-
v.headerCell(),
|
|
553
|
-
'w-12',
|
|
554
|
-
slotProps?.headerCell?.className,
|
|
555
|
-
)}
|
|
556
|
-
/>
|
|
557
|
-
)}
|
|
558
|
-
</tr>
|
|
559
|
-
</thead>
|
|
560
|
-
|
|
561
|
-
<tbody className={cn(v.tbody(), slotProps?.tbody?.className)}>
|
|
562
|
-
{loading
|
|
563
|
-
? renderLoadingRows({
|
|
564
|
-
count: loadingRowCount,
|
|
565
|
-
visibleCols,
|
|
566
|
-
showSelectionColumn,
|
|
567
|
-
showRowActionsColumn,
|
|
568
|
-
rowHeight,
|
|
569
|
-
rowClass: cn(v.row(), slotProps?.row?.className),
|
|
570
|
-
cellClass: cn(v.cell(), slotProps?.cell?.className),
|
|
571
|
-
})
|
|
572
|
-
: sortedRows.length === 0
|
|
573
|
-
? renderEmptyState({
|
|
574
|
-
totalColumnCount,
|
|
575
|
-
emptyState,
|
|
576
|
-
// Distinguish a genuinely empty dataset from one
|
|
577
|
-
// emptied by an active search / filter (works for
|
|
578
|
-
// server-side mode too — a query that returns 0
|
|
579
|
-
// rows still reads as "no matching results").
|
|
580
|
-
fallback:
|
|
581
|
-
rows.length > 0 &&
|
|
582
|
-
(debouncedSearchQuery.trim().length > 0 ||
|
|
583
|
-
filterModel.length > 0)
|
|
584
|
-
? labels.noResults
|
|
585
|
-
: labels.noData,
|
|
586
|
-
cellClass: cn(
|
|
587
|
-
v.cell(),
|
|
588
|
-
v.emptyState(),
|
|
589
|
-
slotProps?.emptyState?.className,
|
|
590
|
-
),
|
|
591
|
-
})
|
|
592
|
-
: renderVirtualizedBody({
|
|
593
|
-
vWindow,
|
|
594
|
-
rowHeight,
|
|
595
|
-
renderedRows,
|
|
596
|
-
visibleCols,
|
|
597
|
-
columnTypes,
|
|
598
|
-
columnWidths,
|
|
599
|
-
selection,
|
|
600
|
-
rowSelection,
|
|
601
|
-
showSelectionColumn,
|
|
602
|
-
showRowActionsColumn,
|
|
603
|
-
rowActions,
|
|
604
|
-
getRowId,
|
|
605
|
-
isInteractive,
|
|
606
|
-
labels,
|
|
607
|
-
serverSidePagination,
|
|
608
|
-
classes: {
|
|
609
|
-
row: cn(v.row(), slotProps?.row?.className),
|
|
610
|
-
cell: cn(v.cell(), slotProps?.cell?.className),
|
|
611
|
-
selectionCell: cn(
|
|
612
|
-
v.cell(),
|
|
613
|
-
v.selectionCell(),
|
|
614
|
-
v.stickyLeftCell(),
|
|
615
|
-
slotProps?.cell?.className,
|
|
616
|
-
slotProps?.selectionCell?.className,
|
|
617
|
-
),
|
|
618
|
-
stickyLeftCell: v.stickyLeftCell(),
|
|
619
|
-
stickyRightCell: v.stickyRightCell(),
|
|
620
|
-
rowActionsCell: cn(
|
|
621
|
-
v.cell(),
|
|
622
|
-
v.rowActionsCell(),
|
|
623
|
-
slotProps?.cell?.className,
|
|
624
|
-
slotProps?.rowActionsCell?.className,
|
|
625
|
-
),
|
|
626
|
-
},
|
|
627
|
-
})}
|
|
628
|
-
</tbody>
|
|
629
|
-
</table>
|
|
630
|
-
</div>
|
|
631
|
-
|
|
632
|
-
{/* ───── Bulk action footer ───── */}
|
|
633
|
-
{bulkActions && selectedRows.length > 0 && (
|
|
634
|
-
<div
|
|
635
|
-
className={cn(v.bulkActionFooter(), slotProps?.bulkActionFooter?.className)}
|
|
636
|
-
role="region"
|
|
637
|
-
aria-label={labels.selectedCount.replace(
|
|
638
|
-
'{count}',
|
|
639
|
-
String(selectedRows.length),
|
|
640
|
-
)}
|
|
641
|
-
>
|
|
642
|
-
<span className="text-sm text-neutral-700">
|
|
643
|
-
{labels.selectedCount.replace('{count}', String(selectedRows.length))}
|
|
644
|
-
</span>
|
|
645
|
-
<div className="flex items-center gap-2">
|
|
646
|
-
{bulkActions(selectedRows)}
|
|
647
|
-
<button
|
|
648
|
-
type="button"
|
|
649
|
-
onClick={selection.clearSelection}
|
|
650
|
-
className={cn(
|
|
651
|
-
'text-sm text-neutral-500 hover:text-neutral-900',
|
|
652
|
-
'underline-offset-2 hover:underline',
|
|
653
|
-
'focus:outline-none focus-visible:underline',
|
|
654
|
-
)}
|
|
655
|
-
>
|
|
656
|
-
{labels.clearSelection}
|
|
657
|
-
</button>
|
|
658
|
-
</div>
|
|
659
|
-
</div>
|
|
660
|
-
)}
|
|
661
|
-
|
|
662
|
-
{/* ───── Optional pagination footer ───── */}
|
|
663
|
-
{pagination && (
|
|
664
|
-
<div className={cn(v.paginationFooter(), slotProps?.pagination?.className)}>
|
|
665
|
-
<Pagination
|
|
666
|
-
page={pagination.page}
|
|
667
|
-
pageSize={pagination.pageSize}
|
|
668
|
-
totalCount={totalCountProp ?? sortedRows.length}
|
|
669
|
-
onPageChange={pagination.onPageChange}
|
|
670
|
-
onPageSizeChange={pagination.onPageSizeChange}
|
|
671
|
-
pageSizeOptions={pagination.pageSizeOptions}
|
|
672
|
-
/>
|
|
673
|
-
</div>
|
|
674
|
-
)}
|
|
675
|
-
</div>
|
|
676
|
-
);
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
// ───── Header cell ─────
|
|
680
|
-
|
|
681
|
-
function HeaderCell<T extends object>(props: {
|
|
682
|
-
col: TableColumn<T>;
|
|
683
|
-
sortModel: TableSortModel;
|
|
684
|
-
onSortClick: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
685
|
-
inferredType: string | undefined;
|
|
686
|
-
filterModel: TableFilterModel;
|
|
687
|
-
onFilterChange: (model: TableFilterModel) => void;
|
|
688
|
-
effectiveWidth: number | undefined;
|
|
689
|
-
resizable: boolean;
|
|
690
|
-
startResize: (
|
|
691
|
-
field: string,
|
|
692
|
-
startWidth: number,
|
|
693
|
-
clampMin: number,
|
|
694
|
-
clampMax: number,
|
|
695
|
-
) => (e: RPointerEvent<HTMLElement>) => void;
|
|
696
|
-
nudgeColumnWidth: (
|
|
697
|
-
field: string,
|
|
698
|
-
currentWidth: number,
|
|
699
|
-
delta: number,
|
|
700
|
-
clampMin: number,
|
|
701
|
-
clampMax: number,
|
|
702
|
-
) => void;
|
|
703
|
-
reorderable: boolean;
|
|
704
|
-
reorderHandlers: ColumnReorderHandlers;
|
|
705
|
-
labels: Required<TableLabels>;
|
|
706
|
-
className: string;
|
|
707
|
-
buttonClassName: string;
|
|
708
|
-
disabled: boolean;
|
|
709
|
-
}) {
|
|
710
|
-
const {
|
|
711
|
-
col,
|
|
712
|
-
sortModel,
|
|
713
|
-
onSortClick,
|
|
714
|
-
inferredType,
|
|
715
|
-
filterModel,
|
|
716
|
-
onFilterChange,
|
|
717
|
-
effectiveWidth,
|
|
718
|
-
resizable,
|
|
719
|
-
startResize,
|
|
720
|
-
nudgeColumnWidth,
|
|
721
|
-
reorderable,
|
|
722
|
-
reorderHandlers,
|
|
723
|
-
labels,
|
|
724
|
-
className,
|
|
725
|
-
buttonClassName,
|
|
726
|
-
disabled,
|
|
727
|
-
} = props;
|
|
728
|
-
|
|
729
|
-
const align = resolveAlign(col, inferredType as never);
|
|
730
|
-
const alignClass =
|
|
731
|
-
align === 'right' ? 'text-right' : align === 'center' ? 'text-center' : 'text-left';
|
|
732
|
-
|
|
733
|
-
const sortEntry = sortModel.find((s) => s.field === col.field);
|
|
734
|
-
const ariaSort: 'ascending' | 'descending' | 'none' =
|
|
735
|
-
sortEntry?.direction === 'asc'
|
|
736
|
-
? 'ascending'
|
|
737
|
-
: sortEntry?.direction === 'desc'
|
|
738
|
-
? 'descending'
|
|
739
|
-
: 'none';
|
|
740
|
-
|
|
741
|
-
const headerContent =
|
|
742
|
-
typeof col.header === 'function' ? col.header() : col.header;
|
|
743
|
-
|
|
744
|
-
const cellStyle = {
|
|
745
|
-
width: effectiveWidth != null ? `${effectiveWidth}px` : undefined,
|
|
746
|
-
minWidth: col.minWidth != null ? `${col.minWidth}px` : undefined,
|
|
747
|
-
flex: effectiveWidth != null ? undefined : col.flex,
|
|
748
|
-
position: resizable || reorderable ? ('relative' as const) : undefined,
|
|
749
|
-
};
|
|
750
|
-
|
|
751
|
-
// Drop indicator for reorder: a 2px vertical bar at the LEFT or
|
|
752
|
-
// RIGHT edge of this th when it's the active drop target.
|
|
753
|
-
const dropTarget = reorderHandlers.dropTarget;
|
|
754
|
-
const dropIndicatorClass =
|
|
755
|
-
dropTarget != null && dropTarget.field === (col.field as string)
|
|
756
|
-
? dropTarget.side === 'left'
|
|
757
|
-
? 'before:absolute before:top-0 before:bottom-0 before:left-0 before:w-0.5 before:bg-primary-500'
|
|
758
|
-
: 'after:absolute after:top-0 after:bottom-0 after:right-0 after:w-0.5 after:bg-primary-500'
|
|
759
|
-
: '';
|
|
760
|
-
|
|
761
|
-
const isDragging = reorderHandlers.draggingField === (col.field as string);
|
|
762
|
-
|
|
763
|
-
// Drag attributes only attach when reorderable; we DO NOT make the
|
|
764
|
-
// entire th `draggable` if it isn't — keeps the keyboard focus
|
|
765
|
-
// behavior unchanged.
|
|
766
|
-
const dragAttrs = reorderable
|
|
767
|
-
? {
|
|
768
|
-
draggable: true,
|
|
769
|
-
onDragStart: reorderHandlers.dragStart(col.field as string),
|
|
770
|
-
onDragOver: reorderHandlers.dragOver(col.field as string),
|
|
771
|
-
onDrop: reorderHandlers.drop(col.field as string),
|
|
772
|
-
onDragEnd: reorderHandlers.dragEnd,
|
|
773
|
-
}
|
|
774
|
-
: {};
|
|
775
|
-
|
|
776
|
-
// Resize bounds — shared by the pointer-drag and keyboard paths.
|
|
777
|
-
const resizeMin = col.minWidth ?? 40;
|
|
778
|
-
const resizeMax = col.maxWidth ?? 1200;
|
|
779
|
-
// Keyboard nudge step: 16px, or 64px with Shift held (coarse).
|
|
780
|
-
const measureWidth = (handle: HTMLElement): number =>
|
|
781
|
-
effectiveWidth ??
|
|
782
|
-
(handle.parentElement as HTMLElement | null)?.getBoundingClientRect()
|
|
783
|
-
.width ??
|
|
784
|
-
120;
|
|
785
|
-
|
|
786
|
-
const resizeHandle = resizable ? (
|
|
787
|
-
<span
|
|
788
|
-
role="separator"
|
|
789
|
-
aria-orientation="vertical"
|
|
790
|
-
aria-label={`Resize ${typeof col.header === 'string' ? col.header : col.field}`}
|
|
791
|
-
// Width bounds announced to assistive tech on the separator.
|
|
792
|
-
aria-valuemin={resizeMin}
|
|
793
|
-
aria-valuemax={resizeMax}
|
|
794
|
-
aria-valuenow={effectiveWidth ?? undefined}
|
|
795
|
-
// Keyboard-operable: focusable + ArrowLeft/Right resize. WCAG 2.1
|
|
796
|
-
// keyboard operability — the drag is no longer the only path.
|
|
797
|
-
tabIndex={disabled ? -1 : 0}
|
|
798
|
-
// D6 guard: the parent `<th>` is `draggable` when reorderable;
|
|
799
|
-
// marking the handle non-draggable means grabbing the handle
|
|
800
|
-
// starts a RESIZE, never a column-reorder drag.
|
|
801
|
-
draggable={false}
|
|
802
|
-
onPointerDown={(e) => {
|
|
803
|
-
const startWidth = measureWidth(e.currentTarget);
|
|
804
|
-
startResize(col.field as string, startWidth, resizeMin, resizeMax)(e);
|
|
805
|
-
}}
|
|
806
|
-
onKeyDown={(e) => {
|
|
807
|
-
if (disabled) return;
|
|
808
|
-
if (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight') return;
|
|
809
|
-
e.preventDefault();
|
|
810
|
-
const step = (e.shiftKey ? 64 : 16) * (e.key === 'ArrowLeft' ? -1 : 1);
|
|
811
|
-
const current = measureWidth(e.currentTarget);
|
|
812
|
-
nudgeColumnWidth(
|
|
813
|
-
col.field as string,
|
|
814
|
-
current,
|
|
815
|
-
step,
|
|
816
|
-
resizeMin,
|
|
817
|
-
resizeMax,
|
|
818
|
-
);
|
|
819
|
-
}}
|
|
820
|
-
className={cn(
|
|
821
|
-
'absolute top-0 bottom-0 right-0 w-1.5',
|
|
822
|
-
'cursor-col-resize select-none touch-none',
|
|
823
|
-
'hover:bg-primary-300 active:bg-primary-400',
|
|
824
|
-
'focus:outline-none focus-visible:bg-primary-400',
|
|
825
|
-
'transition-colors motion-reduce:transition-none',
|
|
826
|
-
)}
|
|
827
|
-
/>
|
|
828
|
-
) : null;
|
|
829
|
-
|
|
830
|
-
const filterType = col.filterable
|
|
831
|
-
? resolveFilterType(col, inferredType as TableColumnInferredType | undefined)
|
|
832
|
-
: null;
|
|
833
|
-
|
|
834
|
-
const filterTrigger =
|
|
835
|
-
col.filterable && filterType ? (
|
|
836
|
-
<ColumnFilterTrigger
|
|
837
|
-
field={col.field as string}
|
|
838
|
-
filterType={filterType}
|
|
839
|
-
filterModel={filterModel}
|
|
840
|
-
onFilterChange={onFilterChange}
|
|
841
|
-
disabled={disabled}
|
|
842
|
-
labels={{
|
|
843
|
-
filterColumn: labels.filterColumn,
|
|
844
|
-
filterApply: labels.filterApply,
|
|
845
|
-
filterClear: labels.filterClear,
|
|
846
|
-
filterMin: labels.filterMin,
|
|
847
|
-
filterMax: labels.filterMax,
|
|
848
|
-
filterFrom: labels.filterFrom,
|
|
849
|
-
filterTo: labels.filterTo,
|
|
850
|
-
filterAll: labels.filterAll,
|
|
851
|
-
filterTrue: labels.filterTrue,
|
|
852
|
-
filterFalse: labels.filterFalse,
|
|
853
|
-
}}
|
|
854
|
-
/>
|
|
855
|
-
) : null;
|
|
856
|
-
|
|
857
|
-
// Layout strategy:
|
|
858
|
-
// - sortable only → sort button is the cell content
|
|
859
|
-
// - filterable only → header text + filter trigger in a flex row
|
|
860
|
-
// - both → sort button + filter trigger in a flex row
|
|
861
|
-
// - neither → plain header text
|
|
862
|
-
const wrapperJustify =
|
|
863
|
-
align === 'right'
|
|
864
|
-
? 'justify-end'
|
|
865
|
-
: align === 'center'
|
|
866
|
-
? 'justify-center'
|
|
867
|
-
: 'justify-start';
|
|
868
|
-
|
|
869
|
-
if (col.sortable) {
|
|
870
|
-
const sortButton = (
|
|
871
|
-
<button
|
|
872
|
-
type="button"
|
|
873
|
-
onClick={onSortClick}
|
|
874
|
-
disabled={disabled}
|
|
875
|
-
aria-label={
|
|
876
|
-
ariaSort === 'ascending'
|
|
877
|
-
? labels.ariaSortAscending
|
|
878
|
-
: ariaSort === 'descending'
|
|
879
|
-
? labels.ariaSortDescending
|
|
880
|
-
: labels.ariaSortNone
|
|
881
|
-
}
|
|
882
|
-
className={cn(
|
|
883
|
-
buttonClassName,
|
|
884
|
-
align === 'right' && 'flex-row-reverse',
|
|
885
|
-
'disabled:cursor-not-allowed disabled:opacity-50',
|
|
886
|
-
)}
|
|
887
|
-
>
|
|
888
|
-
<span>{headerContent}</span>
|
|
889
|
-
<SortIcon direction={sortEntry?.direction} />
|
|
890
|
-
</button>
|
|
891
|
-
);
|
|
892
|
-
return (
|
|
893
|
-
<th
|
|
894
|
-
scope="col"
|
|
895
|
-
aria-sort={ariaSort}
|
|
896
|
-
className={cn(
|
|
897
|
-
className,
|
|
898
|
-
alignClass,
|
|
899
|
-
dropIndicatorClass,
|
|
900
|
-
isDragging && 'opacity-50',
|
|
901
|
-
)}
|
|
902
|
-
style={cellStyle}
|
|
903
|
-
{...dragAttrs}
|
|
904
|
-
>
|
|
905
|
-
{filterTrigger ? (
|
|
906
|
-
<div className={cn('flex items-center gap-1', wrapperJustify)}>
|
|
907
|
-
{sortButton}
|
|
908
|
-
{filterTrigger}
|
|
909
|
-
</div>
|
|
910
|
-
) : (
|
|
911
|
-
sortButton
|
|
912
|
-
)}
|
|
913
|
-
{resizeHandle}
|
|
914
|
-
</th>
|
|
915
|
-
);
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
return (
|
|
919
|
-
<th
|
|
920
|
-
scope="col"
|
|
921
|
-
className={cn(
|
|
922
|
-
className,
|
|
923
|
-
alignClass,
|
|
924
|
-
dropIndicatorClass,
|
|
925
|
-
isDragging && 'opacity-50',
|
|
926
|
-
)}
|
|
927
|
-
style={cellStyle}
|
|
928
|
-
{...dragAttrs}
|
|
929
|
-
>
|
|
930
|
-
{filterTrigger ? (
|
|
931
|
-
<div className={cn('flex items-center gap-1', wrapperJustify)}>
|
|
932
|
-
<span>{headerContent}</span>
|
|
933
|
-
{filterTrigger}
|
|
934
|
-
</div>
|
|
935
|
-
) : (
|
|
936
|
-
headerContent
|
|
937
|
-
)}
|
|
938
|
-
{resizeHandle}
|
|
939
|
-
</th>
|
|
940
|
-
);
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
/**
|
|
944
|
-
* Resolve the effective width (px) for a column. User-driven resize
|
|
945
|
-
* (`columnWidths[field]`) wins over the static `col.width`. Returns
|
|
946
|
-
* `undefined` if neither source has a width set — the consumer falls
|
|
947
|
-
* back to the column's `flex` value or browser auto-layout.
|
|
948
|
-
*/
|
|
949
|
-
function resolveColumnWidth<T extends object>(
|
|
950
|
-
col: TableColumn<T>,
|
|
951
|
-
columnWidths: Record<string, number>,
|
|
952
|
-
): number | undefined {
|
|
953
|
-
const resized = columnWidths[col.field as string];
|
|
954
|
-
if (resized != null) return resized;
|
|
955
|
-
return col.width;
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
/**
|
|
959
|
-
* Resolve the filter UI type for a column. Explicit `col.filterType`
|
|
960
|
-
* wins; otherwise we map the auto-detected primitive type:
|
|
961
|
-
* - `number` → number range
|
|
962
|
-
* - `boolean` → true/false/all select
|
|
963
|
-
* - `date` → date range
|
|
964
|
-
* - anything else (string / unknown) → text contains
|
|
965
|
-
*/
|
|
966
|
-
function resolveFilterType<T extends object>(
|
|
967
|
-
col: TableColumn<T>,
|
|
968
|
-
inferred: TableColumnInferredType | undefined,
|
|
969
|
-
): TableFilterType {
|
|
970
|
-
if (col.filterType) return col.filterType;
|
|
971
|
-
switch (inferred) {
|
|
972
|
-
case 'number':
|
|
973
|
-
return 'number';
|
|
974
|
-
case 'boolean':
|
|
975
|
-
return 'boolean';
|
|
976
|
-
case 'date':
|
|
977
|
-
return 'date';
|
|
978
|
-
default:
|
|
979
|
-
return 'text';
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
// ───── Virtualized body ─────
|
|
984
|
-
|
|
985
|
-
function renderVirtualizedBody<T extends object>(args: {
|
|
986
|
-
vWindow: { startIndex: number; endIndex: number; paddingTop: number; paddingBottom: number };
|
|
987
|
-
rowHeight: number;
|
|
988
|
-
renderedRows: T[];
|
|
989
|
-
visibleCols: TableColumn<T>[];
|
|
990
|
-
columnTypes: Map<string, string>;
|
|
991
|
-
columnWidths: Record<string, number>;
|
|
992
|
-
selection: ReturnType<typeof useTableSelection>;
|
|
993
|
-
rowSelection: 'none' | 'single' | 'multiple';
|
|
994
|
-
showSelectionColumn: boolean;
|
|
995
|
-
showRowActionsColumn: boolean;
|
|
996
|
-
rowActions: ((row: T) => ReactNode) | undefined;
|
|
997
|
-
getRowId: (row: T, index: number) => string;
|
|
998
|
-
isInteractive: boolean;
|
|
999
|
-
labels: Required<TableLabels>;
|
|
1000
|
-
serverSidePagination: boolean;
|
|
1001
|
-
classes: {
|
|
1002
|
-
row: string;
|
|
1003
|
-
cell: string;
|
|
1004
|
-
selectionCell: string;
|
|
1005
|
-
stickyLeftCell: string;
|
|
1006
|
-
stickyRightCell: string;
|
|
1007
|
-
rowActionsCell: string;
|
|
1008
|
-
};
|
|
1009
|
-
}): ReactNode {
|
|
1010
|
-
const {
|
|
1011
|
-
vWindow,
|
|
1012
|
-
renderedRows,
|
|
1013
|
-
visibleCols,
|
|
1014
|
-
columnTypes,
|
|
1015
|
-
columnWidths,
|
|
1016
|
-
selection,
|
|
1017
|
-
rowSelection,
|
|
1018
|
-
showSelectionColumn,
|
|
1019
|
-
showRowActionsColumn,
|
|
1020
|
-
rowActions,
|
|
1021
|
-
getRowId,
|
|
1022
|
-
isInteractive,
|
|
1023
|
-
labels,
|
|
1024
|
-
classes,
|
|
1025
|
-
} = args;
|
|
1026
|
-
|
|
1027
|
-
return (
|
|
1028
|
-
<>
|
|
1029
|
-
{vWindow.paddingTop > 0 && (
|
|
1030
|
-
<tr aria-hidden="true" style={{ height: vWindow.paddingTop }} />
|
|
1031
|
-
)}
|
|
1032
|
-
{renderedRows.map((row, localIdx) => {
|
|
1033
|
-
const absoluteIdx = vWindow.startIndex + localIdx;
|
|
1034
|
-
const rowId = getRowId(row, absoluteIdx);
|
|
1035
|
-
const isSelected = selection.isSelected(rowId);
|
|
1036
|
-
return (
|
|
1037
|
-
<tr
|
|
1038
|
-
key={rowId}
|
|
1039
|
-
// 1-based row index in the FULL dataset (header row is 1,
|
|
1040
|
-
// so data rows start at 2). Lets a screen reader announce
|
|
1041
|
-
// the true position despite virtualization windowing.
|
|
1042
|
-
aria-rowindex={absoluteIdx + 2}
|
|
1043
|
-
data-selected={isSelected ? 'true' : 'false'}
|
|
1044
|
-
aria-selected={rowSelection !== 'none' ? isSelected : undefined}
|
|
1045
|
-
className={classes.row}
|
|
1046
|
-
>
|
|
1047
|
-
{showSelectionColumn && (
|
|
1048
|
-
<td className={classes.selectionCell}>
|
|
1049
|
-
<input
|
|
1050
|
-
type="checkbox"
|
|
1051
|
-
aria-label={labels.ariaSelectRow}
|
|
1052
|
-
checked={isSelected}
|
|
1053
|
-
onChange={() => selection.toggleRow(rowId)}
|
|
1054
|
-
disabled={!isInteractive}
|
|
1055
|
-
className="cursor-pointer"
|
|
1056
|
-
/>
|
|
1057
|
-
</td>
|
|
1058
|
-
)}
|
|
1059
|
-
{visibleCols.map((col) => (
|
|
1060
|
-
<DataCell
|
|
1061
|
-
key={col.field as string}
|
|
1062
|
-
col={col}
|
|
1063
|
-
row={row}
|
|
1064
|
-
rowIndex={absoluteIdx}
|
|
1065
|
-
isSelected={isSelected}
|
|
1066
|
-
inferredType={columnTypes.get(col.field as string)}
|
|
1067
|
-
effectiveWidth={resolveColumnWidth(col, columnWidths)}
|
|
1068
|
-
cellClass={classes.cell}
|
|
1069
|
-
stickyLeftClass={classes.stickyLeftCell}
|
|
1070
|
-
stickyRightClass={classes.stickyRightCell}
|
|
1071
|
-
/>
|
|
1072
|
-
))}
|
|
1073
|
-
{showRowActionsColumn && rowActions && (
|
|
1074
|
-
<td className={classes.rowActionsCell}>{rowActions(row)}</td>
|
|
1075
|
-
)}
|
|
1076
|
-
</tr>
|
|
1077
|
-
);
|
|
1078
|
-
})}
|
|
1079
|
-
{vWindow.paddingBottom > 0 && (
|
|
1080
|
-
<tr aria-hidden="true" style={{ height: vWindow.paddingBottom }} />
|
|
1081
|
-
)}
|
|
1082
|
-
</>
|
|
1083
|
-
);
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
// ───── Data cell ─────
|
|
1087
|
-
|
|
1088
|
-
function DataCell<T extends object>(props: {
|
|
1089
|
-
col: TableColumn<T>;
|
|
1090
|
-
row: T;
|
|
1091
|
-
rowIndex: number;
|
|
1092
|
-
isSelected: boolean;
|
|
1093
|
-
inferredType: string | undefined;
|
|
1094
|
-
effectiveWidth: number | undefined;
|
|
1095
|
-
cellClass: string;
|
|
1096
|
-
stickyLeftClass: string;
|
|
1097
|
-
stickyRightClass: string;
|
|
1098
|
-
}) {
|
|
1099
|
-
const {
|
|
1100
|
-
col,
|
|
1101
|
-
row,
|
|
1102
|
-
rowIndex,
|
|
1103
|
-
isSelected,
|
|
1104
|
-
inferredType,
|
|
1105
|
-
effectiveWidth,
|
|
1106
|
-
cellClass,
|
|
1107
|
-
stickyLeftClass,
|
|
1108
|
-
stickyRightClass,
|
|
1109
|
-
} = props;
|
|
1110
|
-
const value = getNestedValue(row, col.field as string);
|
|
1111
|
-
const align = resolveAlign(col, inferredType as never);
|
|
1112
|
-
const tabularNums = resolveTabularNums(col, inferredType as never);
|
|
1113
|
-
const monospace = resolveMonospace(col);
|
|
1114
|
-
const alignClass =
|
|
1115
|
-
align === 'right' ? 'text-right' : align === 'center' ? 'text-center' : 'text-left';
|
|
1116
|
-
|
|
1117
|
-
const columnAccessState = col.access
|
|
1118
|
-
? {
|
|
1119
|
-
hidden: col.access.onUnauthorized === 'hide',
|
|
1120
|
-
disabled: col.access.onUnauthorized === 'disable',
|
|
1121
|
-
readonly: col.access.onUnauthorized === 'readonly',
|
|
1122
|
-
}
|
|
1123
|
-
: null;
|
|
1124
|
-
|
|
1125
|
-
const content = col.cellRenderer
|
|
1126
|
-
? col.cellRenderer({
|
|
1127
|
-
row,
|
|
1128
|
-
value,
|
|
1129
|
-
rowIndex,
|
|
1130
|
-
isSelected,
|
|
1131
|
-
isExpanded: false, // DataGrid v1 doesn't support expansion (defer)
|
|
1132
|
-
access: columnAccessState,
|
|
1133
|
-
})
|
|
1134
|
-
: renderDefaultCell(value);
|
|
1135
|
-
|
|
1136
|
-
return (
|
|
1137
|
-
<td
|
|
1138
|
-
className={cn(
|
|
1139
|
-
cellClass,
|
|
1140
|
-
alignClass,
|
|
1141
|
-
tabularNums && 'tabular-nums',
|
|
1142
|
-
monospace && 'font-mono',
|
|
1143
|
-
col.sticky === 'left' && stickyLeftClass,
|
|
1144
|
-
col.sticky === 'right' && stickyRightClass,
|
|
1145
|
-
)}
|
|
1146
|
-
style={{
|
|
1147
|
-
width: effectiveWidth != null ? `${effectiveWidth}px` : undefined,
|
|
1148
|
-
minWidth: col.minWidth != null ? `${col.minWidth}px` : undefined,
|
|
1149
|
-
}}
|
|
1150
|
-
>
|
|
1151
|
-
{content}
|
|
1152
|
-
</td>
|
|
1153
|
-
);
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
// ───── Helpers ─────
|
|
1157
|
-
|
|
1158
|
-
function renderDefaultCell(value: unknown): ReactNode {
|
|
1159
|
-
if (value == null) return null;
|
|
1160
|
-
if (typeof value === 'boolean') return value ? '✓' : '✗';
|
|
1161
|
-
if (value instanceof Date) return value.toISOString().slice(0, 10);
|
|
1162
|
-
if (typeof value === 'object') return JSON.stringify(value);
|
|
1163
|
-
return value as ReactNode;
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
|
-
function handleSortClick<T extends object>(
|
|
1167
|
-
col: TableColumn<T>,
|
|
1168
|
-
event: MouseEvent<HTMLButtonElement>,
|
|
1169
|
-
current: TableSortModel,
|
|
1170
|
-
setSortModel: (
|
|
1171
|
-
next: TableSortModel | ((prev: TableSortModel) => TableSortModel),
|
|
1172
|
-
) => void,
|
|
1173
|
-
) {
|
|
1174
|
-
if (!col.sortable) return;
|
|
1175
|
-
const multi = event.shiftKey;
|
|
1176
|
-
setSortModel((prev) => cycleSortFor(prev, col.field as string, multi));
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
function renderLoadingRows<T extends object>(args: {
|
|
1180
|
-
count: number;
|
|
1181
|
-
visibleCols: TableColumn<T>[];
|
|
1182
|
-
showSelectionColumn: boolean;
|
|
1183
|
-
showRowActionsColumn: boolean;
|
|
1184
|
-
rowHeight: number;
|
|
1185
|
-
rowClass: string;
|
|
1186
|
-
cellClass: string;
|
|
1187
|
-
}): ReactNode {
|
|
1188
|
-
const {
|
|
1189
|
-
count,
|
|
1190
|
-
visibleCols,
|
|
1191
|
-
showSelectionColumn,
|
|
1192
|
-
showRowActionsColumn,
|
|
1193
|
-
rowHeight,
|
|
1194
|
-
rowClass,
|
|
1195
|
-
cellClass,
|
|
1196
|
-
} = args;
|
|
1197
|
-
return Array.from({ length: count }).map((_, i) => (
|
|
1198
|
-
<tr
|
|
1199
|
-
key={`loading-${i}`}
|
|
1200
|
-
className={rowClass}
|
|
1201
|
-
aria-busy="true"
|
|
1202
|
-
style={{ height: rowHeight }}
|
|
1203
|
-
>
|
|
1204
|
-
{showSelectionColumn && (
|
|
1205
|
-
<td className={cellClass}>
|
|
1206
|
-
<Skeleton variant="rectangle" width="16px" height="16px" />
|
|
1207
|
-
</td>
|
|
1208
|
-
)}
|
|
1209
|
-
{visibleCols.map((col) => (
|
|
1210
|
-
<td key={col.field as string} className={cellClass}>
|
|
1211
|
-
<Skeleton variant="text" width="80%" />
|
|
1212
|
-
</td>
|
|
1213
|
-
))}
|
|
1214
|
-
{showRowActionsColumn && (
|
|
1215
|
-
<td className={cellClass}>
|
|
1216
|
-
<Skeleton variant="rectangle" width="24px" height="24px" />
|
|
1217
|
-
</td>
|
|
1218
|
-
)}
|
|
1219
|
-
</tr>
|
|
1220
|
-
));
|
|
1221
|
-
}
|
|
1222
|
-
|
|
1223
|
-
function renderEmptyState(args: {
|
|
1224
|
-
totalColumnCount: number;
|
|
1225
|
-
emptyState: ReactNode;
|
|
1226
|
-
fallback: string;
|
|
1227
|
-
cellClass: string;
|
|
1228
|
-
}): ReactNode {
|
|
1229
|
-
return (
|
|
1230
|
-
<tr>
|
|
1231
|
-
<td colSpan={args.totalColumnCount} className={args.cellClass}>
|
|
1232
|
-
{args.emptyState ?? args.fallback}
|
|
1233
|
-
</td>
|
|
1234
|
-
</tr>
|
|
1235
|
-
);
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
// ───── Icons ─────
|
|
1239
|
-
|
|
1240
|
-
function SortIcon(props: { direction?: 'asc' | 'desc' }) {
|
|
1241
|
-
return (
|
|
1242
|
-
<svg
|
|
1243
|
-
width="0.75em"
|
|
1244
|
-
height="0.75em"
|
|
1245
|
-
viewBox="0 0 16 16"
|
|
1246
|
-
fill="currentColor"
|
|
1247
|
-
aria-hidden="true"
|
|
1248
|
-
className="shrink-0 opacity-60 group-hover:opacity-100"
|
|
1249
|
-
>
|
|
1250
|
-
{props.direction === 'asc' ? (
|
|
1251
|
-
<path d="M8 4l4 6H4z" />
|
|
1252
|
-
) : props.direction === 'desc' ? (
|
|
1253
|
-
<path d="M8 12L4 6h8z" />
|
|
1254
|
-
) : (
|
|
1255
|
-
<>
|
|
1256
|
-
<path d="M8 3l3 4H5z" opacity="0.5" />
|
|
1257
|
-
<path d="M8 13l-3-4h6z" opacity="0.5" />
|
|
1258
|
-
</>
|
|
1259
|
-
)}
|
|
1260
|
-
</svg>
|
|
1261
|
-
);
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
function SearchIcon(props: { className?: string }) {
|
|
1265
|
-
return (
|
|
1266
|
-
<svg
|
|
1267
|
-
width="0.875em"
|
|
1268
|
-
height="0.875em"
|
|
1269
|
-
viewBox="0 0 16 16"
|
|
1270
|
-
fill="none"
|
|
1271
|
-
stroke="currentColor"
|
|
1272
|
-
strokeWidth="1.5"
|
|
1273
|
-
strokeLinecap="round"
|
|
1274
|
-
strokeLinejoin="round"
|
|
1275
|
-
aria-hidden="true"
|
|
1276
|
-
className={props.className}
|
|
1277
|
-
>
|
|
1278
|
-
<circle cx="7" cy="7" r="4.5" />
|
|
1279
|
-
<path d="M11 11l3 3" />
|
|
1280
|
-
</svg>
|
|
1281
|
-
);
|
|
1282
|
-
}
|