@dashforge/tw 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -1
- package/dist/index.esm.js +1 -1
- package/dist/src/index.d.ts +1 -1
- package/package.json +8 -3
- 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,145 +0,0 @@
|
|
|
1
|
-
// @vitest-environment jsdom
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { describe, it, expect, afterEach } from 'vitest';
|
|
4
|
-
import { render, screen, fireEvent, cleanup } from '@testing-library/react';
|
|
5
|
-
import { Tabs } from './Tabs.js';
|
|
6
|
-
|
|
7
|
-
void React;
|
|
8
|
-
afterEach(() => cleanup());
|
|
9
|
-
|
|
10
|
-
const items = [
|
|
11
|
-
{ value: 'overview', label: 'Overview', content: <p>Overview body</p> },
|
|
12
|
-
{ value: 'details', label: 'Details', content: <p>Details body</p> },
|
|
13
|
-
{ value: 'history', label: 'History', content: <p>History body</p> },
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
describe('Tabs — rendering', () => {
|
|
17
|
-
it('renders all triggers and the default-active content', () => {
|
|
18
|
-
render(<Tabs items={items} />);
|
|
19
|
-
expect(screen.queryByRole('tab', { name: 'Overview' })).not.toBeNull();
|
|
20
|
-
expect(screen.queryByRole('tab', { name: 'Details' })).not.toBeNull();
|
|
21
|
-
expect(screen.queryByRole('tab', { name: 'History' })).not.toBeNull();
|
|
22
|
-
expect(screen.queryByText('Overview body')).not.toBeNull();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('honors `defaultValue`', () => {
|
|
26
|
-
render(<Tabs items={items} defaultValue="history" />);
|
|
27
|
-
expect(screen.queryByText('History body')).not.toBeNull();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('switches active panel via controlled `value` rerender', () => {
|
|
31
|
-
const { rerender } = render(
|
|
32
|
-
<Tabs items={items} value="overview" onValueChange={() => {}} />,
|
|
33
|
-
);
|
|
34
|
-
expect(screen.queryByText('Overview body')).not.toBeNull();
|
|
35
|
-
rerender(<Tabs items={items} value="details" onValueChange={() => {}} />);
|
|
36
|
-
expect(screen.queryByText('Details body')).not.toBeNull();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('marks the active tab via aria-selected', () => {
|
|
40
|
-
render(<Tabs items={items} defaultValue="details" />);
|
|
41
|
-
expect(
|
|
42
|
-
screen.getByRole('tab', { name: 'Details' }).getAttribute('aria-selected'),
|
|
43
|
-
).toBe('true');
|
|
44
|
-
expect(
|
|
45
|
-
screen.getByRole('tab', { name: 'Overview' }).getAttribute('aria-selected'),
|
|
46
|
-
).toBe('false');
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('selects a tab on click', () => {
|
|
50
|
-
render(<Tabs items={items} />);
|
|
51
|
-
fireEvent.click(screen.getByRole('tab', { name: 'Details' }));
|
|
52
|
-
expect(screen.queryByText('Details body')).not.toBeNull();
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
describe('Tabs — variants', () => {
|
|
57
|
-
it.each(['underline', 'pill'] as const)('renders variant=%s', (variant) => {
|
|
58
|
-
render(<Tabs items={items} variant={variant} />);
|
|
59
|
-
expect(screen.queryByRole('tablist')).not.toBeNull();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it.each(['horizontal', 'vertical'] as const)('renders orientation=%s', (o) => {
|
|
63
|
-
render(<Tabs items={items} orientation={o} />);
|
|
64
|
-
expect(screen.getByRole('tablist').getAttribute('aria-orientation')).toBe(o);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
describe('Tabs — disabled items', () => {
|
|
69
|
-
it('marks disabled triggers as disabled', () => {
|
|
70
|
-
const disabledItems = [...items.slice(0, 2), { ...items[2]!, disabled: true }];
|
|
71
|
-
render(<Tabs items={disabledItems} />);
|
|
72
|
-
const trigger = screen.getByRole('tab', {
|
|
73
|
-
name: 'History',
|
|
74
|
-
}) as HTMLButtonElement;
|
|
75
|
-
expect(trigger.disabled).toBe(true);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('skips disabled tabs during keyboard navigation', () => {
|
|
79
|
-
const disabledItems = [
|
|
80
|
-
items[0]!,
|
|
81
|
-
{ ...items[1]!, disabled: true },
|
|
82
|
-
items[2]!,
|
|
83
|
-
];
|
|
84
|
-
render(<Tabs items={disabledItems} />);
|
|
85
|
-
fireEvent.keyDown(screen.getByRole('tablist'), { key: 'ArrowRight' });
|
|
86
|
-
// Overview → (skip disabled Details) → History
|
|
87
|
-
expect(
|
|
88
|
-
screen.getByRole('tab', { name: 'History' }).getAttribute('aria-selected'),
|
|
89
|
-
).toBe('true');
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
describe('Tabs — keyboard', () => {
|
|
94
|
-
it('ArrowRight activates the next tab', () => {
|
|
95
|
-
render(<Tabs items={items} />);
|
|
96
|
-
fireEvent.keyDown(screen.getByRole('tablist'), { key: 'ArrowRight' });
|
|
97
|
-
expect(
|
|
98
|
-
screen.getByRole('tab', { name: 'Details' }).getAttribute('aria-selected'),
|
|
99
|
-
).toBe('true');
|
|
100
|
-
expect(screen.queryByText('Details body')).not.toBeNull();
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('ArrowRight wraps at the end', () => {
|
|
104
|
-
render(<Tabs items={items} defaultValue="history" />);
|
|
105
|
-
fireEvent.keyDown(screen.getByRole('tablist'), { key: 'ArrowRight' });
|
|
106
|
-
expect(
|
|
107
|
-
screen.getByRole('tab', { name: 'Overview' }).getAttribute('aria-selected'),
|
|
108
|
-
).toBe('true');
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('Home / End jump to the first / last tab', () => {
|
|
112
|
-
render(<Tabs items={items} defaultValue="details" />);
|
|
113
|
-
const list = screen.getByRole('tablist');
|
|
114
|
-
fireEvent.keyDown(list, { key: 'End' });
|
|
115
|
-
expect(
|
|
116
|
-
screen.getByRole('tab', { name: 'History' }).getAttribute('aria-selected'),
|
|
117
|
-
).toBe('true');
|
|
118
|
-
fireEvent.keyDown(list, { key: 'Home' });
|
|
119
|
-
expect(
|
|
120
|
-
screen.getByRole('tab', { name: 'Overview' }).getAttribute('aria-selected'),
|
|
121
|
-
).toBe('true');
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('ArrowDown drives a vertical tablist', () => {
|
|
125
|
-
render(<Tabs items={items} orientation="vertical" />);
|
|
126
|
-
fireEvent.keyDown(screen.getByRole('tablist'), { key: 'ArrowDown' });
|
|
127
|
-
expect(
|
|
128
|
-
screen.getByRole('tab', { name: 'Details' }).getAttribute('aria-selected'),
|
|
129
|
-
).toBe('true');
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
describe('Tabs — keepMounted', () => {
|
|
134
|
-
it('mounts only the active panel by default', () => {
|
|
135
|
-
render(<Tabs items={items} defaultValue="overview" />);
|
|
136
|
-
expect(screen.queryByText('Overview body')).not.toBeNull();
|
|
137
|
-
expect(screen.queryByText('History body')).toBeNull();
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it('keeps every panel mounted when keepMounted is set', () => {
|
|
141
|
-
render(<Tabs items={items} defaultValue="overview" keepMounted />);
|
|
142
|
-
expect(screen.queryByText('Overview body')).not.toBeNull();
|
|
143
|
-
expect(screen.queryByText('History body')).not.toBeNull();
|
|
144
|
-
});
|
|
145
|
-
});
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { cn } from '../../utils/cn.js';
|
|
2
|
-
import { tabsVariants } from './tabs.variants.js';
|
|
3
|
-
import { useTabs } from './useTabs.js';
|
|
4
|
-
import type { TabsProps } from './tabs.types.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Dashforge TW `<Tabs>` — declarative tab navigation.
|
|
8
|
-
*
|
|
9
|
-
* Custom clean-room implementation on the headless `useTabs` engine — no
|
|
10
|
-
* runtime UI dependency. Implements the WAI-ARIA APG tabs pattern: arrow-key
|
|
11
|
-
* navigation, automatic activation, roving tabindex, `role="tablist"` +
|
|
12
|
-
* `role="tab"` + `role="tabpanel"`.
|
|
13
|
-
*
|
|
14
|
-
* Two variant axes:
|
|
15
|
-
* - `variant` — `underline` (default) | `pill`
|
|
16
|
-
* - `orientation` — `horizontal` (default) | `vertical`
|
|
17
|
-
*
|
|
18
|
-
* Controlled (`value` + `onValueChange`) or uncontrolled (`defaultValue`).
|
|
19
|
-
* `keepMounted` keeps inactive panels in the DOM (default: only the active
|
|
20
|
-
* panel is mounted).
|
|
21
|
-
*/
|
|
22
|
-
export function Tabs(props: TabsProps) {
|
|
23
|
-
const {
|
|
24
|
-
items,
|
|
25
|
-
value,
|
|
26
|
-
defaultValue,
|
|
27
|
-
onValueChange,
|
|
28
|
-
variant = 'underline',
|
|
29
|
-
orientation = 'horizontal',
|
|
30
|
-
keepMounted = false,
|
|
31
|
-
sx,
|
|
32
|
-
slotProps,
|
|
33
|
-
} = props;
|
|
34
|
-
|
|
35
|
-
const v = tabsVariants({ variant, orientation });
|
|
36
|
-
const tabs = useTabs({
|
|
37
|
-
items,
|
|
38
|
-
value,
|
|
39
|
-
defaultValue,
|
|
40
|
-
onValueChange,
|
|
41
|
-
orientation,
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
// Either all panels (hidden when inactive) or just the active one.
|
|
45
|
-
const panels = keepMounted
|
|
46
|
-
? items
|
|
47
|
-
: items.filter((item) => item.value === tabs.activeValue);
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<div className={cn(v.root(), sx, slotProps?.root?.className)}>
|
|
51
|
-
<div
|
|
52
|
-
{...tabs.getTabListProps()}
|
|
53
|
-
className={cn(v.list(), slotProps?.list?.className)}
|
|
54
|
-
>
|
|
55
|
-
{items.map((item) => (
|
|
56
|
-
<button
|
|
57
|
-
key={item.value}
|
|
58
|
-
type="button"
|
|
59
|
-
{...tabs.getTabProps(item)}
|
|
60
|
-
className={cn(v.trigger(), slotProps?.trigger?.className)}
|
|
61
|
-
>
|
|
62
|
-
{item.label}
|
|
63
|
-
</button>
|
|
64
|
-
))}
|
|
65
|
-
</div>
|
|
66
|
-
{panels.map((item) => (
|
|
67
|
-
<div
|
|
68
|
-
key={item.value}
|
|
69
|
-
{...tabs.getPanelProps(item)}
|
|
70
|
-
className={cn(v.content(), slotProps?.content?.className)}
|
|
71
|
-
>
|
|
72
|
-
{item.content}
|
|
73
|
-
</div>
|
|
74
|
-
))}
|
|
75
|
-
</div>
|
|
76
|
-
);
|
|
77
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import type { TabsVariants } from './tabs.variants.js';
|
|
3
|
-
|
|
4
|
-
export interface TabsSlotProps {
|
|
5
|
-
root?: { className?: string };
|
|
6
|
-
list?: { className?: string };
|
|
7
|
-
trigger?: { className?: string };
|
|
8
|
-
content?: { className?: string };
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Single tab item — paired `{ value, label, content }`. The `value`
|
|
13
|
-
* is the canonical id (selected via the `value` / `defaultValue`
|
|
14
|
-
* props on the root); the `label` is the trigger button text, and
|
|
15
|
-
* `content` is what renders in the panel when this tab is active.
|
|
16
|
-
*/
|
|
17
|
-
export interface TabItem {
|
|
18
|
-
value: string;
|
|
19
|
-
label: ReactNode;
|
|
20
|
-
/** Tab panel content. */
|
|
21
|
-
content: ReactNode;
|
|
22
|
-
/** Per-tab disabled flag. */
|
|
23
|
-
disabled?: boolean;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Props for `<Tabs>`.
|
|
28
|
-
*
|
|
29
|
-
* Custom clean-room implementation — the headless `useTabs` engine, no Radix.
|
|
30
|
-
* Two variant axes:
|
|
31
|
-
* - `variant` — `underline` (default) | `pill`
|
|
32
|
-
* - `orientation` — `horizontal` (default) | `vertical`
|
|
33
|
-
*
|
|
34
|
-
* Supports controlled (`value` + `onValueChange`) and uncontrolled
|
|
35
|
-
* (`defaultValue`) modes — the `value` prop wins when both are set.
|
|
36
|
-
*/
|
|
37
|
-
export interface TabsProps extends TabsVariants {
|
|
38
|
-
/** Tab items array. */
|
|
39
|
-
items: TabItem[];
|
|
40
|
-
/** Controlled active value. */
|
|
41
|
-
value?: string;
|
|
42
|
-
/** Default active value (uncontrolled). Defaults to first item's value. */
|
|
43
|
-
defaultValue?: string;
|
|
44
|
-
/** Fires when the active tab changes. */
|
|
45
|
-
onValueChange?: (value: string) => void;
|
|
46
|
-
/**
|
|
47
|
-
* Keep inactive panels mounted (hidden via the `hidden` attribute).
|
|
48
|
-
* Default `false` — only the active panel is in the DOM.
|
|
49
|
-
*/
|
|
50
|
-
keepMounted?: boolean;
|
|
51
|
-
/** Root className shortcut. */
|
|
52
|
-
sx?: string;
|
|
53
|
-
/** Per-slot overrides. */
|
|
54
|
-
slotProps?: TabsSlotProps;
|
|
55
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { tv, type VariantProps } from 'tailwind-variants';
|
|
2
|
-
|
|
3
|
-
export const tabsVariants = tv({
|
|
4
|
-
slots: {
|
|
5
|
-
root: 'flex',
|
|
6
|
-
list: 'inline-flex items-center gap-1',
|
|
7
|
-
trigger: [
|
|
8
|
-
'inline-flex items-center justify-center whitespace-nowrap',
|
|
9
|
-
'text-sm font-medium transition-colors',
|
|
10
|
-
'focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500',
|
|
11
|
-
'disabled:opacity-50 disabled:pointer-events-none',
|
|
12
|
-
'motion-reduce:transition-none',
|
|
13
|
-
],
|
|
14
|
-
content: [
|
|
15
|
-
'mt-3 focus:outline-none',
|
|
16
|
-
'data-[state=inactive]:hidden',
|
|
17
|
-
],
|
|
18
|
-
},
|
|
19
|
-
variants: {
|
|
20
|
-
variant: {
|
|
21
|
-
underline: {
|
|
22
|
-
// Neutral palette auto-inverts via CSS-var swap.
|
|
23
|
-
list: 'border-b border-neutral-200',
|
|
24
|
-
trigger: [
|
|
25
|
-
'px-3 py-2 border-b-2 border-transparent text-neutral-600',
|
|
26
|
-
'hover:text-neutral-900',
|
|
27
|
-
// Primary palette does NOT auto-invert — `dark:` shift is
|
|
28
|
-
// an intentional tone refinement (kept).
|
|
29
|
-
'data-[state=active]:border-primary-500 data-[state=active]:text-primary-700',
|
|
30
|
-
'dark:data-[state=active]:text-primary-400',
|
|
31
|
-
],
|
|
32
|
-
},
|
|
33
|
-
pill: {
|
|
34
|
-
// Pill list bg uses the elevation tier — auto-inverts.
|
|
35
|
-
list: 'rounded-lg bg-neutral-100 p-1',
|
|
36
|
-
trigger: [
|
|
37
|
-
'px-3 py-1.5 rounded-md text-neutral-600',
|
|
38
|
-
'hover:text-neutral-900',
|
|
39
|
-
// Active pill is one tier above the list bg
|
|
40
|
-
// (`bg-neutral-100`-inverted = #171717 in dark).
|
|
41
|
-
// `bg-white` is hardcoded so a `dark:` is required —
|
|
42
|
-
// target `dark:bg-neutral-200` (= #262626 in dark) sits
|
|
43
|
-
// ONE TIER above the list bg, preserving the elevation
|
|
44
|
-
// semantic from light mode (where `bg-white` sits above
|
|
45
|
-
// `bg-neutral-100` = #f5f5f5).
|
|
46
|
-
'data-[state=active]:bg-white dark:data-[state=active]:bg-neutral-200',
|
|
47
|
-
'data-[state=active]:text-neutral-900',
|
|
48
|
-
'data-[state=active]:shadow-sm',
|
|
49
|
-
],
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
orientation: {
|
|
53
|
-
horizontal: {
|
|
54
|
-
root: 'flex-col',
|
|
55
|
-
list: 'flex-row',
|
|
56
|
-
},
|
|
57
|
-
vertical: {
|
|
58
|
-
root: 'flex-row gap-4',
|
|
59
|
-
list: 'flex-col items-stretch',
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
defaultVariants: {
|
|
64
|
-
variant: 'underline',
|
|
65
|
-
orientation: 'horizontal',
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
export type TabsVariants = VariantProps<typeof tabsVariants>;
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import { useCallback, useId, useRef, useState } from 'react';
|
|
2
|
-
import type { KeyboardEvent } from 'react';
|
|
3
|
-
import type { TabItem } from './tabs.types.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* `useTabs` — the headless tab engine for the Tailwind `<Tabs>`.
|
|
7
|
-
*
|
|
8
|
-
* Pure logic, zero UI: active-value state (controlled / uncontrolled) plus
|
|
9
|
-
* the WAI-ARIA APG keyboard model (arrow keys, Home/End, roving tabindex,
|
|
10
|
-
* automatic activation, disabled-skip, edge wrap). Returns attribute bundles
|
|
11
|
-
* for the `tablist` / `tab` / `tabpanel` roles.
|
|
12
|
-
*
|
|
13
|
-
* Deliberately NOT a shared package: the tab logic is ~90 lines — too thin
|
|
14
|
-
* to justify a published `tabs-core`. The MUI skin keeps its own near-identical
|
|
15
|
-
* copy. Only the public API contract is shared.
|
|
16
|
-
*/
|
|
17
|
-
interface UseTabsOptions {
|
|
18
|
-
items: TabItem[];
|
|
19
|
-
value: string | undefined;
|
|
20
|
-
defaultValue: string | undefined;
|
|
21
|
-
onValueChange: ((value: string) => void) | undefined;
|
|
22
|
-
orientation: 'horizontal' | 'vertical';
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
interface TabListAttributes {
|
|
26
|
-
role: 'tablist';
|
|
27
|
-
'aria-orientation': 'horizontal' | 'vertical';
|
|
28
|
-
onKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface TabAttributes {
|
|
32
|
-
role: 'tab';
|
|
33
|
-
id: string;
|
|
34
|
-
'aria-selected': boolean;
|
|
35
|
-
'aria-controls': string;
|
|
36
|
-
tabIndex: number;
|
|
37
|
-
disabled: boolean | undefined;
|
|
38
|
-
'data-state': 'active' | 'inactive';
|
|
39
|
-
onClick: () => void;
|
|
40
|
-
ref: (el: HTMLButtonElement | null) => void;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
interface PanelAttributes {
|
|
44
|
-
role: 'tabpanel';
|
|
45
|
-
id: string;
|
|
46
|
-
'aria-labelledby': string;
|
|
47
|
-
tabIndex: number;
|
|
48
|
-
hidden: boolean;
|
|
49
|
-
'data-state': 'active' | 'inactive';
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface UseTabsResult {
|
|
53
|
-
/** The currently active tab value. */
|
|
54
|
-
activeValue: string;
|
|
55
|
-
getTabListProps: () => TabListAttributes;
|
|
56
|
-
getTabProps: (item: TabItem) => TabAttributes;
|
|
57
|
-
getPanelProps: (item: TabItem) => PanelAttributes;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function useTabs(options: UseTabsOptions): UseTabsResult {
|
|
61
|
-
const { items, value, defaultValue, onValueChange, orientation } = options;
|
|
62
|
-
|
|
63
|
-
const baseId = useId();
|
|
64
|
-
const firstValue = items[0]?.value ?? '';
|
|
65
|
-
const [internalValue, setInternalValue] = useState<string>(
|
|
66
|
-
defaultValue ?? firstValue,
|
|
67
|
-
);
|
|
68
|
-
const isControlled = value !== undefined;
|
|
69
|
-
const activeValue = isControlled ? value : internalValue;
|
|
70
|
-
|
|
71
|
-
// Tab buttons, keyed by value — used to move DOM focus on keyboard nav.
|
|
72
|
-
const tabRefs = useRef(new Map<string, HTMLButtonElement>());
|
|
73
|
-
|
|
74
|
-
const select = useCallback(
|
|
75
|
-
(next: string) => {
|
|
76
|
-
if (!isControlled) {
|
|
77
|
-
setInternalValue(next);
|
|
78
|
-
}
|
|
79
|
-
onValueChange?.(next);
|
|
80
|
-
},
|
|
81
|
-
[isControlled, onValueChange],
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
const handleKeyDown = useCallback(
|
|
85
|
-
(event: KeyboardEvent<HTMLDivElement>) => {
|
|
86
|
-
const nextKey = orientation === 'vertical' ? 'ArrowDown' : 'ArrowRight';
|
|
87
|
-
const prevKey = orientation === 'vertical' ? 'ArrowUp' : 'ArrowLeft';
|
|
88
|
-
const enabled = items.filter((item) => item.disabled !== true);
|
|
89
|
-
if (enabled.length === 0) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
const currentIndex = enabled.findIndex(
|
|
93
|
-
(item) => item.value === activeValue,
|
|
94
|
-
);
|
|
95
|
-
let targetIndex: number | null = null;
|
|
96
|
-
if (event.key === nextKey) {
|
|
97
|
-
targetIndex =
|
|
98
|
-
currentIndex < 0 ? 0 : (currentIndex + 1) % enabled.length;
|
|
99
|
-
} else if (event.key === prevKey) {
|
|
100
|
-
targetIndex =
|
|
101
|
-
currentIndex < 0
|
|
102
|
-
? enabled.length - 1
|
|
103
|
-
: (currentIndex - 1 + enabled.length) % enabled.length;
|
|
104
|
-
} else if (event.key === 'Home') {
|
|
105
|
-
targetIndex = 0;
|
|
106
|
-
} else if (event.key === 'End') {
|
|
107
|
-
targetIndex = enabled.length - 1;
|
|
108
|
-
}
|
|
109
|
-
if (targetIndex === null) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
event.preventDefault();
|
|
113
|
-
const target = enabled[targetIndex];
|
|
114
|
-
if (target === undefined) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
select(target.value);
|
|
118
|
-
tabRefs.current.get(target.value)?.focus();
|
|
119
|
-
},
|
|
120
|
-
[items, orientation, activeValue, select],
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
const getTabListProps = (): TabListAttributes => ({
|
|
124
|
-
role: 'tablist',
|
|
125
|
-
'aria-orientation': orientation,
|
|
126
|
-
onKeyDown: handleKeyDown,
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
const getTabProps = (item: TabItem): TabAttributes => {
|
|
130
|
-
const active = item.value === activeValue;
|
|
131
|
-
return {
|
|
132
|
-
role: 'tab',
|
|
133
|
-
id: `${baseId}-tab-${item.value}`,
|
|
134
|
-
'aria-selected': active,
|
|
135
|
-
'aria-controls': `${baseId}-panel-${item.value}`,
|
|
136
|
-
tabIndex: active ? 0 : -1,
|
|
137
|
-
disabled: item.disabled,
|
|
138
|
-
'data-state': active ? 'active' : 'inactive',
|
|
139
|
-
onClick: () => {
|
|
140
|
-
if (item.disabled !== true) {
|
|
141
|
-
select(item.value);
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
ref: (el: HTMLButtonElement | null) => {
|
|
145
|
-
if (el) {
|
|
146
|
-
tabRefs.current.set(item.value, el);
|
|
147
|
-
} else {
|
|
148
|
-
tabRefs.current.delete(item.value);
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
const getPanelProps = (item: TabItem): PanelAttributes => {
|
|
155
|
-
const active = item.value === activeValue;
|
|
156
|
-
return {
|
|
157
|
-
role: 'tabpanel',
|
|
158
|
-
id: `${baseId}-panel-${item.value}`,
|
|
159
|
-
'aria-labelledby': `${baseId}-tab-${item.value}`,
|
|
160
|
-
tabIndex: 0,
|
|
161
|
-
hidden: !active,
|
|
162
|
-
'data-state': active ? 'active' : 'inactive',
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
return { activeValue, getTabListProps, getTabProps, getPanelProps };
|
|
167
|
-
}
|