@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,131 +0,0 @@
|
|
|
1
|
-
// @vitest-environment jsdom
|
|
2
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
3
|
-
import { render, fireEvent } from '@testing-library/react';
|
|
4
|
-
import { RbacProvider } from '@dashforge/rbac';
|
|
5
|
-
import type { RbacPolicy, Subject } from '@dashforge/rbac';
|
|
6
|
-
import { DashFormProvider } from '@dashforge/forms';
|
|
7
|
-
import { Switch } from './Switch.js';
|
|
8
|
-
|
|
9
|
-
const READ_ONLY: RbacPolicy = {
|
|
10
|
-
roles: [
|
|
11
|
-
{
|
|
12
|
-
name: 'viewer',
|
|
13
|
-
permissions: [{ resource: 'doc', action: 'update', effect: 'deny' }],
|
|
14
|
-
},
|
|
15
|
-
],
|
|
16
|
-
};
|
|
17
|
-
const viewer: Subject = { id: 'v', roles: ['viewer'] };
|
|
18
|
-
|
|
19
|
-
function withForm(children: React.ReactNode, defaultValues: Record<string, unknown> = {}) {
|
|
20
|
-
return <DashFormProvider defaultValues={defaultValues}>{children}</DashFormProvider>;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
describe('Switch — standalone', () => {
|
|
24
|
-
it('renders the Radix root with role="switch"', () => {
|
|
25
|
-
const { getByRole } = render(<Switch name="notif" label="Notifications" />);
|
|
26
|
-
expect(getByRole('switch')).toBeTruthy();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('label is associated with the control via htmlFor', () => {
|
|
30
|
-
const { getByText, getByRole } = render(<Switch name="x" label="On" />);
|
|
31
|
-
const label = getByText('On') as HTMLLabelElement;
|
|
32
|
-
const ctrl = getByRole('switch');
|
|
33
|
-
expect(label.htmlFor).toBe(ctrl.id);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('fires onCheckedChange', () => {
|
|
37
|
-
const fn = vi.fn();
|
|
38
|
-
const { getByRole } = render(<Switch name="x" onCheckedChange={fn} />);
|
|
39
|
-
fireEvent.click(getByRole('switch'));
|
|
40
|
-
expect(fn).toHaveBeenCalledWith(true);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('respects defaultChecked when uncontrolled', () => {
|
|
44
|
-
const { getByRole } = render(<Switch name="x" defaultChecked label="X" />);
|
|
45
|
-
expect(getByRole('switch').getAttribute('data-state')).toBe('checked');
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('thumb sits in unchecked position by default', () => {
|
|
49
|
-
const { container } = render(<Switch name="x" label="X" />);
|
|
50
|
-
const thumb = container.querySelector('[data-state]')?.children[0];
|
|
51
|
-
expect(thumb?.className).toContain('data-[state=unchecked]:translate-x-0');
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('size variants change control + thumb dimensions', () => {
|
|
55
|
-
const { container, rerender } = render(<Switch name="x" size="sm" label="X" />);
|
|
56
|
-
expect(container.querySelector('button[role="switch"]')?.className).toContain('h-4');
|
|
57
|
-
rerender(<Switch name="x" size="lg" label="X" />);
|
|
58
|
-
expect(container.querySelector('button[role="switch"]')?.className).toContain('h-7');
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('shows danger styling on error=true', () => {
|
|
62
|
-
const { container } = render(<Switch name="x" error label="X" helperText="bad" />);
|
|
63
|
-
const ctrl = container.querySelector('button[role="switch"]');
|
|
64
|
-
expect(ctrl?.className).toContain('bg-danger-200');
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
describe('Switch — override (sx + slotProps)', () => {
|
|
69
|
-
it('sx applies to root', () => {
|
|
70
|
-
const { container } = render(<Switch name="x" sx="ml-8" />);
|
|
71
|
-
expect((container.firstChild as HTMLElement).className).toContain('ml-8');
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('slotProps.thumb decorates the thumb', () => {
|
|
75
|
-
const { container } = render(
|
|
76
|
-
<Switch name="x" slotProps={{ thumb: { className: 'ring-2 ring-purple-500' } }} />
|
|
77
|
-
);
|
|
78
|
-
const thumb = container.querySelector('button[role="switch"]')?.children[0];
|
|
79
|
-
expect(thumb?.className).toContain('ring-purple-500');
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
describe('Switch — RBAC', () => {
|
|
84
|
-
it('hides when access denies with onUnauthorized=hide', () => {
|
|
85
|
-
const { queryByRole } = render(
|
|
86
|
-
<RbacProvider policy={READ_ONLY} subject={viewer}>
|
|
87
|
-
<Switch
|
|
88
|
-
name="x"
|
|
89
|
-
label="X"
|
|
90
|
-
access={{ resource: 'doc', action: 'update', onUnauthorized: 'hide' }}
|
|
91
|
-
/>
|
|
92
|
-
</RbacProvider>
|
|
93
|
-
);
|
|
94
|
-
expect(queryByRole('switch')).toBeNull();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('disables when access denies with onUnauthorized=disable', () => {
|
|
98
|
-
const { getByRole } = render(
|
|
99
|
-
<RbacProvider policy={READ_ONLY} subject={viewer}>
|
|
100
|
-
<Switch
|
|
101
|
-
name="x"
|
|
102
|
-
label="X"
|
|
103
|
-
access={{ resource: 'doc', action: 'update', onUnauthorized: 'disable' }}
|
|
104
|
-
/>
|
|
105
|
-
</RbacProvider>
|
|
106
|
-
);
|
|
107
|
-
expect((getByRole('switch') as HTMLButtonElement).disabled).toBe(true);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
describe('Switch — DashFormProvider integration', () => {
|
|
112
|
-
it('renders inside DashFormProvider', () => {
|
|
113
|
-
const { getByRole } = render(withForm(<Switch name="newsletter" label="Subscribe" />));
|
|
114
|
-
expect(getByRole('switch')).toBeTruthy();
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it('flips state on click (bridge.setValue + onChange)', () => {
|
|
118
|
-
const { getByRole } = render(withForm(<Switch name="x" />, { x: false }));
|
|
119
|
-
const sw = getByRole('switch');
|
|
120
|
-
expect(sw.getAttribute('data-state')).toBe('unchecked');
|
|
121
|
-
fireEvent.click(sw);
|
|
122
|
-
expect(sw.getAttribute('data-state')).toBe('checked');
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('respects explicit `checked` (controlled wins over bridge)', () => {
|
|
126
|
-
const { getByRole } = render(
|
|
127
|
-
withForm(<Switch name="x" checked />, { x: false })
|
|
128
|
-
);
|
|
129
|
-
expect(getByRole('switch').getAttribute('data-state')).toBe('checked');
|
|
130
|
-
});
|
|
131
|
-
});
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { useContext, useEffect, useId, useRef } from 'react';
|
|
2
|
-
import * as RadixSwitch from '@radix-ui/react-switch';
|
|
3
|
-
import { DashFormContext, useEngineVisibility } from '@dashforge/ui-core';
|
|
4
|
-
import type { DashFormBridge, FieldRegistration } from '@dashforge/ui-core';
|
|
5
|
-
import { useDashFieldMeta } from '@dashforge/forms';
|
|
6
|
-
import { cn } from '../../utils/cn.js';
|
|
7
|
-
import { useAccessState } from '../../hooks/useAccessState.js';
|
|
8
|
-
import { resolveValidationState } from '../_shared/resolveValidationState.js';
|
|
9
|
-
import { switchVariants } from './switch.variants.js';
|
|
10
|
-
import type { SwitchProps } from './switch.types.js';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Dashforge TW Switch — bridge-integrated toggle.
|
|
14
|
-
*
|
|
15
|
-
* Implementation mirrors `<Checkbox>` (same 8-step bridge integration
|
|
16
|
-
* pattern, same StrictMode-safe unregister, same controlled-vs-
|
|
17
|
-
* uncontrolled Radix props logic) — the only differences are:
|
|
18
|
-
*
|
|
19
|
-
* - Renders Radix `Switch.Root` + `Switch.Thumb` instead of `Checkbox`.
|
|
20
|
-
* - No indicator icon (the thumb position is the visual state).
|
|
21
|
-
* - Variants drive both control track dimensions AND the thumb
|
|
22
|
-
* translate-x distance so the knob lands flush at each end.
|
|
23
|
-
*/
|
|
24
|
-
export function Switch(props: SwitchProps) {
|
|
25
|
-
const {
|
|
26
|
-
name,
|
|
27
|
-
rules,
|
|
28
|
-
visibleWhen,
|
|
29
|
-
label,
|
|
30
|
-
helperText,
|
|
31
|
-
error,
|
|
32
|
-
access,
|
|
33
|
-
size,
|
|
34
|
-
disabled,
|
|
35
|
-
checked,
|
|
36
|
-
defaultChecked,
|
|
37
|
-
onCheckedChange,
|
|
38
|
-
sx,
|
|
39
|
-
slotProps,
|
|
40
|
-
} = props;
|
|
41
|
-
|
|
42
|
-
const bridge = useContext(DashFormContext) as DashFormBridge | null;
|
|
43
|
-
const isVisible = useEngineVisibility(bridge?.engine, visibleWhen);
|
|
44
|
-
// Reactive snapshot — see Checkbox.tsx for the same rationale.
|
|
45
|
-
const fieldMeta = useDashFieldMeta(name);
|
|
46
|
-
const accessState = useAccessState(access);
|
|
47
|
-
|
|
48
|
-
const controlId = useId();
|
|
49
|
-
|
|
50
|
-
// StrictMode-safe unregister-on-unmount
|
|
51
|
-
const unregisterRef = useRef({ bridge, name });
|
|
52
|
-
unregisterRef.current = { bridge, name };
|
|
53
|
-
const isMountedRef = useRef(false);
|
|
54
|
-
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
isMountedRef.current = true;
|
|
57
|
-
return () => {
|
|
58
|
-
isMountedRef.current = false;
|
|
59
|
-
const { bridge: cap, name: capName } = unregisterRef.current;
|
|
60
|
-
queueMicrotask(() => {
|
|
61
|
-
if (!isMountedRef.current) cap?.unregister?.(capName);
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
}, []);
|
|
65
|
-
|
|
66
|
-
if (!isVisible) return null;
|
|
67
|
-
if (!accessState.visible) return null;
|
|
68
|
-
|
|
69
|
-
const effectiveDisabled =
|
|
70
|
-
Boolean(disabled) || accessState.disabled || accessState.readonly;
|
|
71
|
-
|
|
72
|
-
const isFormMode = Boolean(bridge?.register);
|
|
73
|
-
|
|
74
|
-
let resolvedChecked = checked ?? defaultChecked ?? false;
|
|
75
|
-
let resolvedError = error;
|
|
76
|
-
let resolvedHelperText: typeof helperText = helperText;
|
|
77
|
-
let registration: FieldRegistration | null = null;
|
|
78
|
-
|
|
79
|
-
if (isFormMode && bridge) {
|
|
80
|
-
registration = bridge.register(name, rules);
|
|
81
|
-
const validation = resolveValidationState(name, bridge, error, helperText);
|
|
82
|
-
resolvedError = validation.error;
|
|
83
|
-
resolvedHelperText = validation.helperText;
|
|
84
|
-
resolvedChecked =
|
|
85
|
-
checked !== undefined ? checked : Boolean(fieldMeta.value);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const handleCheckedChange = (next: boolean) => {
|
|
89
|
-
if (isFormMode && bridge) {
|
|
90
|
-
bridge.setValue?.(name, next);
|
|
91
|
-
const syntheticEvent = {
|
|
92
|
-
target: { name, checked: next, value: next },
|
|
93
|
-
type: 'change',
|
|
94
|
-
};
|
|
95
|
-
void registration?.onChange?.(syntheticEvent);
|
|
96
|
-
}
|
|
97
|
-
onCheckedChange?.(next);
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const handleBlur = () => {
|
|
101
|
-
if (!isFormMode || !bridge) return;
|
|
102
|
-
const currentChecked = bridge.getValue(name) === true;
|
|
103
|
-
const syntheticEvent = {
|
|
104
|
-
target: { name, checked: currentChecked, value: currentChecked },
|
|
105
|
-
type: 'blur',
|
|
106
|
-
};
|
|
107
|
-
registration?.onBlur?.(syntheticEvent);
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const v = switchVariants({ size, error: resolvedError });
|
|
111
|
-
|
|
112
|
-
// Controlled vs uncontrolled (same logic as Checkbox).
|
|
113
|
-
const radixStateProps: { checked?: boolean; defaultChecked?: boolean } = isFormMode
|
|
114
|
-
? { checked: resolvedChecked }
|
|
115
|
-
: checked !== undefined
|
|
116
|
-
? { checked }
|
|
117
|
-
: { defaultChecked: defaultChecked ?? false };
|
|
118
|
-
|
|
119
|
-
return (
|
|
120
|
-
<div className={cn(v.root(), sx, slotProps?.root?.className)}>
|
|
121
|
-
<RadixSwitch.Root
|
|
122
|
-
id={controlId}
|
|
123
|
-
name={name}
|
|
124
|
-
{...radixStateProps}
|
|
125
|
-
disabled={effectiveDisabled}
|
|
126
|
-
onCheckedChange={handleCheckedChange}
|
|
127
|
-
onBlur={handleBlur}
|
|
128
|
-
ref={registration?.ref as React.Ref<HTMLButtonElement> | undefined}
|
|
129
|
-
className={cn(v.control(), slotProps?.control?.className)}
|
|
130
|
-
>
|
|
131
|
-
<RadixSwitch.Thumb className={cn(v.thumb(), slotProps?.thumb?.className)} />
|
|
132
|
-
</RadixSwitch.Root>
|
|
133
|
-
|
|
134
|
-
<div className="flex flex-col">
|
|
135
|
-
{label && (
|
|
136
|
-
<label
|
|
137
|
-
htmlFor={controlId}
|
|
138
|
-
className={cn(v.label(), slotProps?.label?.className)}
|
|
139
|
-
>
|
|
140
|
-
{label}
|
|
141
|
-
</label>
|
|
142
|
-
)}
|
|
143
|
-
{resolvedHelperText && (
|
|
144
|
-
<p
|
|
145
|
-
className={cn(
|
|
146
|
-
resolvedError ? v.errorText() : v.helperText(),
|
|
147
|
-
resolvedError
|
|
148
|
-
? slotProps?.errorText?.className
|
|
149
|
-
: slotProps?.helperText?.className
|
|
150
|
-
)}
|
|
151
|
-
>
|
|
152
|
-
{resolvedHelperText}
|
|
153
|
-
</p>
|
|
154
|
-
)}
|
|
155
|
-
</div>
|
|
156
|
-
</div>
|
|
157
|
-
);
|
|
158
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import type { AccessRequirement } from '@dashforge/rbac';
|
|
3
|
-
import type { Engine } from '@dashforge/ui-core';
|
|
4
|
-
import type { SwitchVariants } from './switch.variants.js';
|
|
5
|
-
|
|
6
|
-
export interface SwitchSlotProps {
|
|
7
|
-
root?: { className?: string };
|
|
8
|
-
control?: { className?: string };
|
|
9
|
-
thumb?: { className?: string };
|
|
10
|
-
label?: { className?: string };
|
|
11
|
-
helperText?: { className?: string };
|
|
12
|
-
errorText?: { className?: string };
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Props for the Dashforge TW `<Switch>` component.
|
|
17
|
-
*
|
|
18
|
-
* Mirrors the bridge contract of `@dashforge/ui/Switch` (MUI). Same
|
|
19
|
-
* `name` / `rules` / `visibleWhen` / `access` semantics, same
|
|
20
|
-
* validation gating. Renders through Radix `Switch.Root` + `Switch.Thumb`.
|
|
21
|
-
*/
|
|
22
|
-
export interface SwitchProps extends Pick<SwitchVariants, 'size'> {
|
|
23
|
-
name: string;
|
|
24
|
-
label?: ReactNode;
|
|
25
|
-
rules?: unknown;
|
|
26
|
-
visibleWhen?: (engine: Engine) => boolean;
|
|
27
|
-
checked?: boolean;
|
|
28
|
-
defaultChecked?: boolean;
|
|
29
|
-
disabled?: boolean;
|
|
30
|
-
helperText?: ReactNode;
|
|
31
|
-
error?: boolean;
|
|
32
|
-
access?: AccessRequirement;
|
|
33
|
-
sx?: string;
|
|
34
|
-
slotProps?: SwitchSlotProps;
|
|
35
|
-
onCheckedChange?: (checked: boolean) => void;
|
|
36
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { tv, type VariantProps } from 'tailwind-variants';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Tailwind-variants recipe for `<Switch>` with slots.
|
|
5
|
-
*
|
|
6
|
-
* Slots:
|
|
7
|
-
* - `root` — outer flex wrapper (control + label)
|
|
8
|
-
* - `control` — the visible track (Radix `Switch.Root`)
|
|
9
|
-
* - `thumb` — the moving knob (Radix `Switch.Thumb`); animated
|
|
10
|
-
* via translate-x on data-state="checked"
|
|
11
|
-
* - `label` — text next to the control
|
|
12
|
-
* - `helperText` / `errorText` — informational lines below
|
|
13
|
-
*/
|
|
14
|
-
export const switchVariants = tv({
|
|
15
|
-
slots: {
|
|
16
|
-
root: 'inline-flex items-start gap-3',
|
|
17
|
-
control: [
|
|
18
|
-
'relative inline-flex shrink-0 cursor-pointer items-center',
|
|
19
|
-
'rounded-full border-2 border-transparent',
|
|
20
|
-
'transition-colors',
|
|
21
|
-
'bg-neutral-300',
|
|
22
|
-
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-primary-500',
|
|
23
|
-
'data-[state=checked]:bg-primary-500',
|
|
24
|
-
'data-[disabled]:opacity-50 data-[disabled]:cursor-not-allowed',
|
|
25
|
-
],
|
|
26
|
-
thumb: [
|
|
27
|
-
'pointer-events-none inline-block rounded-full bg-white shadow ring-0',
|
|
28
|
-
// Slide animation gated on `prefers-reduced-motion: no-preference`
|
|
29
|
-
// (WCAG 2.3.3). The thumb still moves between positions instantly
|
|
30
|
-
// for users who request reduced motion — the data-state change
|
|
31
|
-
// applies the translate-x rule unconditionally, only the smooth
|
|
32
|
-
// transition between the two is suppressed.
|
|
33
|
-
'transition-transform motion-reduce:transition-none',
|
|
34
|
-
'data-[state=unchecked]:translate-x-0',
|
|
35
|
-
],
|
|
36
|
-
label: 'select-none cursor-pointer text-neutral-900',
|
|
37
|
-
helperText: 'text-sm text-neutral-600 mt-1',
|
|
38
|
-
errorText: 'text-sm text-danger-600 mt-1',
|
|
39
|
-
},
|
|
40
|
-
variants: {
|
|
41
|
-
size: {
|
|
42
|
-
sm: {
|
|
43
|
-
control: 'h-4 w-7',
|
|
44
|
-
thumb: 'h-3 w-3 data-[state=checked]:translate-x-3',
|
|
45
|
-
label: 'text-sm',
|
|
46
|
-
},
|
|
47
|
-
md: {
|
|
48
|
-
control: 'h-6 w-11',
|
|
49
|
-
thumb: 'h-5 w-5 data-[state=checked]:translate-x-5',
|
|
50
|
-
label: 'text-base',
|
|
51
|
-
},
|
|
52
|
-
lg: {
|
|
53
|
-
control: 'h-7 w-14',
|
|
54
|
-
thumb: 'h-6 w-6 data-[state=checked]:translate-x-7',
|
|
55
|
-
label: 'text-lg',
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
error: {
|
|
59
|
-
true: {
|
|
60
|
-
control: 'bg-danger-200 data-[state=checked]:bg-danger-500 focus-visible:ring-danger-500',
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
defaultVariants: {
|
|
65
|
-
size: 'md',
|
|
66
|
-
error: false,
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
export type SwitchVariants = VariantProps<typeof switchVariants>;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
// @vitest-environment jsdom
|
|
2
|
-
/**
|
|
3
|
-
* Performance guardrails for `<Table>` (non-virtualized).
|
|
4
|
-
*
|
|
5
|
-
* Table renders EVERY row in the DOM — its design ceiling is ~500
|
|
6
|
-
* rows (past that, the consumer should switch to `<DataGrid>`). These
|
|
7
|
-
* tests pin the mount cost at that ceiling so a regression in the
|
|
8
|
-
* render path (e.g. an accidental O(n²) in the sort / search pipeline)
|
|
9
|
-
* surfaces in CI.
|
|
10
|
-
*
|
|
11
|
-
* Budgets are deliberately generous — they catch order-of-magnitude
|
|
12
|
-
* regressions under a cold workspace-wide test run, not micro-jitter.
|
|
13
|
-
*/
|
|
14
|
-
import * as React from 'react';
|
|
15
|
-
import { describe, it, expect, afterEach } from 'vitest';
|
|
16
|
-
import { render, cleanup } from '@testing-library/react';
|
|
17
|
-
import { Table } from './Table.js';
|
|
18
|
-
import type { TableColumn } from './table.types.js';
|
|
19
|
-
|
|
20
|
-
void React;
|
|
21
|
-
afterEach(() => cleanup());
|
|
22
|
-
|
|
23
|
-
interface Row {
|
|
24
|
-
id: string;
|
|
25
|
-
name: string;
|
|
26
|
-
email: string;
|
|
27
|
-
age: number;
|
|
28
|
-
city: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const COLS: TableColumn<Row>[] = [
|
|
32
|
-
{ field: 'name', header: 'Name', sortable: true, searchable: true },
|
|
33
|
-
{ field: 'email', header: 'Email', searchable: true },
|
|
34
|
-
{ field: 'age', header: 'Age', sortable: true },
|
|
35
|
-
{ field: 'city', header: 'City' },
|
|
36
|
-
];
|
|
37
|
-
|
|
38
|
-
function makeRows(n: number): Row[] {
|
|
39
|
-
const cities = ['Roma', 'Milano', 'Berlin'];
|
|
40
|
-
return Array.from({ length: n }).map((_, i) => ({
|
|
41
|
-
id: `r${i}`,
|
|
42
|
-
name: `User ${i}`,
|
|
43
|
-
email: `user${i}@example.com`,
|
|
44
|
-
age: 20 + (i % 50),
|
|
45
|
-
city: cities[i % 3] as string,
|
|
46
|
-
}));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
describe('<Table> performance', () => {
|
|
50
|
-
it("mounts 500 rows (Table's row-count ceiling) under 800ms", () => {
|
|
51
|
-
const rows = makeRows(500);
|
|
52
|
-
const t0 = performance.now();
|
|
53
|
-
render(<Table rows={rows} cols={COLS} getRowId={(r) => r.id} />);
|
|
54
|
-
const t1 = performance.now();
|
|
55
|
-
expect(t1 - t0).toBeLessThan(800);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('renders every row in the DOM (non-virtualized contract)', () => {
|
|
59
|
-
const rows = makeRows(500);
|
|
60
|
-
const { container } = render(
|
|
61
|
-
<Table rows={rows} cols={COLS} getRowId={(r) => r.id} />,
|
|
62
|
-
);
|
|
63
|
-
// Non-virtualized: all 500 data rows are mounted.
|
|
64
|
-
expect(container.querySelectorAll('tbody tr').length).toBe(500);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('applies a default sort over 500 rows within the mount budget', () => {
|
|
68
|
-
const rows = makeRows(500);
|
|
69
|
-
const t0 = performance.now();
|
|
70
|
-
render(
|
|
71
|
-
<Table
|
|
72
|
-
rows={rows}
|
|
73
|
-
cols={COLS}
|
|
74
|
-
getRowId={(r) => r.id}
|
|
75
|
-
defaultSortModel={[{ field: 'name', direction: 'asc' }]}
|
|
76
|
-
/>,
|
|
77
|
-
);
|
|
78
|
-
const t1 = performance.now();
|
|
79
|
-
expect(t1 - t0).toBeLessThan(800);
|
|
80
|
-
});
|
|
81
|
-
});
|