@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,132 +0,0 @@
|
|
|
1
|
-
import type { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
-
import type { ClassValue } from 'tailwind-variants';
|
|
3
|
-
import type { Engine } from '@dashforge/ui-core';
|
|
4
|
-
import type { AccessRequirement } from '@dashforge/rbac';
|
|
5
|
-
import type { BoxProps } from '../Box/box.types.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* `<Card>` — opinionated surface preset over `<Box>`.
|
|
9
|
-
*
|
|
10
|
-
* Architectural note: `<Box>` already implements the full surface
|
|
11
|
-
* vocabulary (variant × color, elevation, rounded, spacing). `<Card>`
|
|
12
|
-
* exists for **two reasons** on top of Box:
|
|
13
|
-
*
|
|
14
|
-
* 1. **MUI mental model** — devs migrating from `@mui/material/Card`
|
|
15
|
-
* reach for `<Card>` reflexively. Having the component (as a
|
|
16
|
-
* thin Box alias with card-shaped defaults) removes adoption
|
|
17
|
-
* friction without duplicating the surface system.
|
|
18
|
-
* 2. **Restricted variant axis** — Card excludes `'soft'` and
|
|
19
|
-
* `'solid'` from Box's 5 variants. A "solid card" is semantically
|
|
20
|
-
* a banner; a "soft card" is a callout (use `<Alert>`). Restricting
|
|
21
|
-
* to `'outlined' | 'elevated' | 'plain'` is opinionated typing
|
|
22
|
-
* that catches misuse at compile time.
|
|
23
|
-
*
|
|
24
|
-
* Card inherits `access` + `visibleWhen` from Box (Sprint 4.4 surface
|
|
25
|
-
* alignment) automatically — no per-component wiring needed.
|
|
26
|
-
*
|
|
27
|
-
* Defaults set by Card (override at the call site):
|
|
28
|
-
* - `variant='outlined'` → soft border + bg tint (most card-like)
|
|
29
|
-
* - `rounded='lg'` → 8px radius
|
|
30
|
-
* - `elevation={1}` → faint shadow for visual weight
|
|
31
|
-
* - `p={0}` → no inner padding (use `<CardContent>`)
|
|
32
|
-
*/
|
|
33
|
-
export interface CardProps
|
|
34
|
-
extends Omit<BoxProps, 'variant'> {
|
|
35
|
-
/**
|
|
36
|
-
* Restricted variant — only the three card-appropriate Box variants.
|
|
37
|
-
* - `'outlined'` (default) — bordered surface with subtle tint.
|
|
38
|
-
* - `'elevated'` — surface with shadow, no border.
|
|
39
|
-
* - `'plain'` — bare surface (background + radius), no border, no
|
|
40
|
-
* shadow. Use when wrapping content that already provides chrome.
|
|
41
|
-
*
|
|
42
|
-
* @default 'outlined'
|
|
43
|
-
*/
|
|
44
|
-
variant?: 'outlined' | 'elevated' | 'plain';
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* `<CardContent>` — padded inner section of a Card.
|
|
49
|
-
*
|
|
50
|
-
* A semantic alias for `<Box p={4}>` (or the equivalent spacing
|
|
51
|
-
* step). Reads better in starter-kit code than the equivalent Box
|
|
52
|
-
* call — the consumer expresses "this is the content area of the
|
|
53
|
-
* card" rather than "this is a box with padding-4 inside a card".
|
|
54
|
-
*
|
|
55
|
-
* No surface props — CardContent inherits its background from the
|
|
56
|
-
* parent Card. The only configurable axis is the padding step.
|
|
57
|
-
*/
|
|
58
|
-
export interface CardContentProps {
|
|
59
|
-
/**
|
|
60
|
-
* Inner padding token step (same scale as `<Box p>`).
|
|
61
|
-
* @default 4
|
|
62
|
-
*/
|
|
63
|
-
p?: BoxProps['p'];
|
|
64
|
-
|
|
65
|
-
/** Content of the section. */
|
|
66
|
-
children: ReactNode;
|
|
67
|
-
|
|
68
|
-
/** Standard React `className` — appended to the root via `cn()`. */
|
|
69
|
-
className?: string;
|
|
70
|
-
|
|
71
|
-
/** Root-element class shortcut (string or clsx-compatible value). */
|
|
72
|
-
sx?: ClassValue;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* `<CardActionArea>` — clickable wrapper inside (or around) a Card.
|
|
77
|
-
*
|
|
78
|
-
* The single value-add over a raw `<Box>` wrapper: focus ring +
|
|
79
|
-
* hover state + Radix Slot polymorphism so the wrapper can become a
|
|
80
|
-
* router `<Link>` without nesting `<a>` inside `<button>` (a11y
|
|
81
|
-
* violation).
|
|
82
|
-
*
|
|
83
|
-
* Use cases:
|
|
84
|
-
* - "Card-as-CTA" patterns where the whole card surface should be
|
|
85
|
-
* clickable (e.g. "Open dashboard" tile)
|
|
86
|
-
* - Card-shaped router links in dashboards / navigation grids
|
|
87
|
-
* - Selectable cards in galleries (with `selected` + `onClick`)
|
|
88
|
-
*
|
|
89
|
-
* Always renders as `<button>` (or the asChild element) — focusable,
|
|
90
|
-
* keyboard-accessible by default. `aria-pressed` when `selected=true`
|
|
91
|
-
* for the toggle pattern (filter card / option card).
|
|
92
|
-
*/
|
|
93
|
-
export interface CardActionAreaProps
|
|
94
|
-
extends Omit<ComponentPropsWithoutRef<'button'>, 'className' | 'color'> {
|
|
95
|
-
/** The card body / content to wrap. */
|
|
96
|
-
children: ReactNode;
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Render-as-child via Radix Slot. The CardActionArea styles paint
|
|
100
|
-
* onto the immediate child element (typically a router `<Link>`).
|
|
101
|
-
* No `<button>` DOM emitted.
|
|
102
|
-
*/
|
|
103
|
-
asChild?: boolean;
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Selected state — for toggle / option-card patterns. Adds
|
|
107
|
-
* `aria-pressed="true"` and a primary-toned focus ring even when
|
|
108
|
-
* not focused.
|
|
109
|
-
*/
|
|
110
|
-
selected?: boolean;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* RBAC requirement — controls clickability via the centralized
|
|
114
|
-
* `@dashforge/rbac` policy engine.
|
|
115
|
-
* - `onUnauthorized: 'hide'` → action area does not render
|
|
116
|
-
* - `onUnauthorized: 'disable'` → clicks suppressed + dimmed
|
|
117
|
-
* - `onUnauthorized: 'readonly'` → mapped to disabled
|
|
118
|
-
*/
|
|
119
|
-
access?: AccessRequirement;
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Engine-reactive visibility predicate — Sprint 4.4 alignment.
|
|
123
|
-
* When the predicate returns `false`, the action area renders `null`.
|
|
124
|
-
*/
|
|
125
|
-
visibleWhen?: (engine: Engine) => boolean;
|
|
126
|
-
|
|
127
|
-
/** Root-element class shortcut. */
|
|
128
|
-
sx?: ClassValue;
|
|
129
|
-
|
|
130
|
-
/** Standard React className — appended via `cn()`. */
|
|
131
|
-
className?: string;
|
|
132
|
-
}
|
|
@@ -1,146 +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 { Checkbox } from './Checkbox.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('Checkbox — standalone (no DashFormProvider)', () => {
|
|
24
|
-
it('renders the Radix root button + label association', () => {
|
|
25
|
-
const { getByText, getByRole } = render(<Checkbox name="terms" label="Accept" />);
|
|
26
|
-
expect(getByText('Accept')).toBeTruthy();
|
|
27
|
-
expect(getByRole('checkbox')).toBeTruthy();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('fires onCheckedChange callback when toggled', () => {
|
|
31
|
-
const onCheckedChange = vi.fn();
|
|
32
|
-
const { getByRole } = render(
|
|
33
|
-
<Checkbox name="terms" label="Accept" onCheckedChange={onCheckedChange} />
|
|
34
|
-
);
|
|
35
|
-
fireEvent.click(getByRole('checkbox'));
|
|
36
|
-
expect(onCheckedChange).toHaveBeenCalledWith(true);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('respects defaultChecked', () => {
|
|
40
|
-
const { getByRole } = render(<Checkbox name="x" defaultChecked label="X" />);
|
|
41
|
-
expect(getByRole('checkbox').getAttribute('data-state')).toBe('checked');
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('applies size variants', () => {
|
|
45
|
-
const { container, rerender } = render(<Checkbox name="x" size="sm" label="X" />);
|
|
46
|
-
expect(container.querySelector('button[role="checkbox"]')?.className).toContain('h-4');
|
|
47
|
-
rerender(<Checkbox name="x" size="lg" label="X" />);
|
|
48
|
-
expect(container.querySelector('button[role="checkbox"]')?.className).toContain('h-6');
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('shows helperText when explicitly supplied', () => {
|
|
52
|
-
const { getByText } = render(
|
|
53
|
-
<Checkbox name="x" label="X" helperText="Hint" />
|
|
54
|
-
);
|
|
55
|
-
expect(getByText('Hint')).toBeTruthy();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('shows danger styling on error=true', () => {
|
|
59
|
-
const { container } = render(<Checkbox name="x" label="X" error helperText="bad" />);
|
|
60
|
-
const control = container.querySelector('button[role="checkbox"]');
|
|
61
|
-
expect(control?.className).toContain('border-danger-500');
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
describe('Checkbox — override (sx + slotProps)', () => {
|
|
66
|
-
it('sx is applied to the root wrapper', () => {
|
|
67
|
-
const { container } = render(<Checkbox name="x" label="X" sx="ml-8" />);
|
|
68
|
-
expect((container.firstChild as HTMLElement).className).toContain('ml-8');
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('slotProps.control adds classes to the Radix root', () => {
|
|
72
|
-
const { container } = render(
|
|
73
|
-
<Checkbox
|
|
74
|
-
name="x"
|
|
75
|
-
label="X"
|
|
76
|
-
slotProps={{ control: { className: 'ring-4 ring-purple-500' } }}
|
|
77
|
-
/>
|
|
78
|
-
);
|
|
79
|
-
expect(container.querySelector('button[role="checkbox"]')?.className).toContain(
|
|
80
|
-
'ring-purple-500'
|
|
81
|
-
);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('slotProps.label adds classes to the label element', () => {
|
|
85
|
-
const { getByText } = render(
|
|
86
|
-
<Checkbox name="x" label="Hi" slotProps={{ label: { className: 'uppercase' } }} />
|
|
87
|
-
);
|
|
88
|
-
expect((getByText('Hi') as HTMLLabelElement).className).toContain('uppercase');
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
describe('Checkbox — RBAC', () => {
|
|
93
|
-
it('hides when access denies with onUnauthorized=hide', () => {
|
|
94
|
-
const { queryByRole } = render(
|
|
95
|
-
<RbacProvider policy={READ_ONLY} subject={viewer}>
|
|
96
|
-
<Checkbox
|
|
97
|
-
name="x"
|
|
98
|
-
label="X"
|
|
99
|
-
access={{ resource: 'doc', action: 'update', onUnauthorized: 'hide' }}
|
|
100
|
-
/>
|
|
101
|
-
</RbacProvider>
|
|
102
|
-
);
|
|
103
|
-
expect(queryByRole('checkbox')).toBeNull();
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('disables when access denies with onUnauthorized=disable', () => {
|
|
107
|
-
const { getByRole } = render(
|
|
108
|
-
<RbacProvider policy={READ_ONLY} subject={viewer}>
|
|
109
|
-
<Checkbox
|
|
110
|
-
name="x"
|
|
111
|
-
label="X"
|
|
112
|
-
access={{ resource: 'doc', action: 'update', onUnauthorized: 'disable' }}
|
|
113
|
-
/>
|
|
114
|
-
</RbacProvider>
|
|
115
|
-
);
|
|
116
|
-
expect((getByRole('checkbox') as HTMLButtonElement).disabled).toBe(true);
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
describe('Checkbox — DashFormProvider integration', () => {
|
|
121
|
-
it('renders without crashing inside DashFormProvider', () => {
|
|
122
|
-
const { getByRole } = render(withForm(<Checkbox name="terms" label="Accept" />));
|
|
123
|
-
expect(getByRole('checkbox')).toBeTruthy();
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it('respects explicit `checked` prop (controlled mode wins over bridge)', () => {
|
|
127
|
-
// The explicit `checked` prop takes precedence over `bridge.getValue`.
|
|
128
|
-
// Defaults propagation through RHF/Engine is covered by the
|
|
129
|
-
// @dashforge/forms own test suite (DashFormProvider.* tests); here we
|
|
130
|
-
// only verify the Checkbox honours the override path correctly.
|
|
131
|
-
const { getByRole } = render(
|
|
132
|
-
withForm(<Checkbox name="terms" label="Accept" checked />, { terms: false })
|
|
133
|
-
);
|
|
134
|
-
expect(getByRole('checkbox').getAttribute('data-state')).toBe('checked');
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it('flips checked state on click (bridge.setValue + onChange)', () => {
|
|
138
|
-
const { getByRole } = render(
|
|
139
|
-
withForm(<Checkbox name="terms" label="Accept" />, { terms: false })
|
|
140
|
-
);
|
|
141
|
-
const cb = getByRole('checkbox');
|
|
142
|
-
expect(cb.getAttribute('data-state')).toBe('unchecked');
|
|
143
|
-
fireEvent.click(cb);
|
|
144
|
-
expect(cb.getAttribute('data-state')).toBe('checked');
|
|
145
|
-
});
|
|
146
|
-
});
|
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
import { useContext, useEffect, useId, useRef } from 'react';
|
|
2
|
-
import * as RadixCheckbox from '@radix-ui/react-checkbox';
|
|
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 { checkboxVariants } from './checkbox.variants.js';
|
|
10
|
-
import type { CheckboxProps } from './checkbox.types.js';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Inline checkmark SVG used by `Radix.Indicator` when fully checked.
|
|
14
|
-
* Stroke uses `currentColor` so the parent's `text-white` propagates.
|
|
15
|
-
*
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
function CheckIcon({ className }: { className?: string }) {
|
|
19
|
-
return (
|
|
20
|
-
<svg
|
|
21
|
-
aria-hidden="true"
|
|
22
|
-
viewBox="0 0 16 16"
|
|
23
|
-
fill="none"
|
|
24
|
-
className={className}
|
|
25
|
-
>
|
|
26
|
-
<path
|
|
27
|
-
d="M3 8.5l3 3 7-7"
|
|
28
|
-
stroke="currentColor"
|
|
29
|
-
strokeWidth="2.5"
|
|
30
|
-
strokeLinecap="round"
|
|
31
|
-
strokeLinejoin="round"
|
|
32
|
-
/>
|
|
33
|
-
</svg>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Inline dash SVG used by `Radix.Indicator` when the checkbox is in
|
|
39
|
-
* the `indeterminate` tri-state ("some, but not all, children
|
|
40
|
-
* selected" — the canonical "select all" partial state).
|
|
41
|
-
*
|
|
42
|
-
* Pre-0.2.2-beta the indicator rendered the CheckIcon for BOTH
|
|
43
|
-
* checked and indeterminate (Radix mounts the Indicator for either
|
|
44
|
-
* state). We now discriminate via the `data-state` attribute Radix
|
|
45
|
-
* sets on the Indicator element itself — see the parent `Indicator`
|
|
46
|
-
* rendering below for the CSS toggle.
|
|
47
|
-
*
|
|
48
|
-
* @internal
|
|
49
|
-
*/
|
|
50
|
-
function DashIcon({ className }: { className?: string }) {
|
|
51
|
-
return (
|
|
52
|
-
<svg
|
|
53
|
-
aria-hidden="true"
|
|
54
|
-
viewBox="0 0 16 16"
|
|
55
|
-
fill="none"
|
|
56
|
-
className={className}
|
|
57
|
-
>
|
|
58
|
-
<path
|
|
59
|
-
d="M3 8h10"
|
|
60
|
-
stroke="currentColor"
|
|
61
|
-
strokeWidth="2.5"
|
|
62
|
-
strokeLinecap="round"
|
|
63
|
-
/>
|
|
64
|
-
</svg>
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Dashforge TW Checkbox — bridge-integrated form control.
|
|
70
|
-
*
|
|
71
|
-
* Renders through Radix `Checkbox.Root` + `Checkbox.Indicator`, styled
|
|
72
|
-
* with the `checkboxVariants` TV recipe. Behaviour at the bridge level
|
|
73
|
-
* is a direct port of `@dashforge/ui/Checkbox` (MUI):
|
|
74
|
-
*
|
|
75
|
-
* - When mounted inside `DashFormProvider`, registers with the bridge
|
|
76
|
-
* (`bridge.register`), reads `bridge.getValue` for the checked
|
|
77
|
-
* state, writes `bridge.setValue` on change, fires
|
|
78
|
-
* `registration.onChange` / `onBlur` for RHF.
|
|
79
|
-
* - When mounted outside, behaves as a plain uncontrolled checkbox.
|
|
80
|
-
* - `visibleWhen` predicates the engine state; `false` → returns null.
|
|
81
|
-
* - `useAccessState(access)` resolves RBAC; `visible: false` → null.
|
|
82
|
-
* - `unregister`-on-unmount is StrictMode-safe (queueMicrotask +
|
|
83
|
-
* `isMountedRef`, mirrors the MUI-side pattern).
|
|
84
|
-
* - Error gating: bridge error shows only after `touched` or after
|
|
85
|
-
* the form has been submitted (`submitCount > 0`).
|
|
86
|
-
*
|
|
87
|
-
* Renderer differences vs MUI:
|
|
88
|
-
*
|
|
89
|
-
* - No `FormControlLabel` wrapper — uses a native `<label htmlFor>`
|
|
90
|
-
* bound via `useId()`. The label click toggles via HTML semantics.
|
|
91
|
-
* - The Radix root is a `<button>`, so it's keyboard-accessible by
|
|
92
|
-
* default (Space toggles).
|
|
93
|
-
* - Slot overrides are class-based (`slotProps={{ control: { className } }}`)
|
|
94
|
-
* rather than MUI slot components.
|
|
95
|
-
*/
|
|
96
|
-
export function Checkbox(props: CheckboxProps) {
|
|
97
|
-
const {
|
|
98
|
-
name,
|
|
99
|
-
rules,
|
|
100
|
-
visibleWhen,
|
|
101
|
-
label,
|
|
102
|
-
helperText,
|
|
103
|
-
error,
|
|
104
|
-
access,
|
|
105
|
-
size,
|
|
106
|
-
disabled,
|
|
107
|
-
checked,
|
|
108
|
-
defaultChecked,
|
|
109
|
-
onCheckedChange,
|
|
110
|
-
sx,
|
|
111
|
-
slotProps,
|
|
112
|
-
} = props;
|
|
113
|
-
|
|
114
|
-
// ───── Hooks (always called, unconditional) ─────
|
|
115
|
-
const bridge = useContext(DashFormContext) as DashFormBridge | null;
|
|
116
|
-
const isVisible = useEngineVisibility(bridge?.engine, visibleWhen);
|
|
117
|
-
// Per-field granular subscription. We READ from `fieldMeta.value`
|
|
118
|
-
// (reactive snapshot) rather than `bridge.getValue(name)` (eager
|
|
119
|
-
// read with no subscription).
|
|
120
|
-
const fieldMeta = useDashFieldMeta(name);
|
|
121
|
-
const accessState = useAccessState(access);
|
|
122
|
-
|
|
123
|
-
const controlId = useId();
|
|
124
|
-
|
|
125
|
-
// StrictMode-safe unregister-on-unmount — mirrors MUI Checkbox.tsx
|
|
126
|
-
// (the bridge identity changes on every keystroke, so we MUST NOT
|
|
127
|
-
// re-run cleanup on deps changes — empty deps + ref pattern).
|
|
128
|
-
const unregisterRef = useRef({ bridge, name });
|
|
129
|
-
unregisterRef.current = { bridge, name };
|
|
130
|
-
const isMountedRef = useRef(false);
|
|
131
|
-
|
|
132
|
-
useEffect(() => {
|
|
133
|
-
isMountedRef.current = true;
|
|
134
|
-
return () => {
|
|
135
|
-
isMountedRef.current = false;
|
|
136
|
-
const { bridge: cap, name: capName } = unregisterRef.current;
|
|
137
|
-
queueMicrotask(() => {
|
|
138
|
-
if (!isMountedRef.current) cap?.unregister?.(capName);
|
|
139
|
-
});
|
|
140
|
-
};
|
|
141
|
-
}, []);
|
|
142
|
-
|
|
143
|
-
// ───── Early returns ─────
|
|
144
|
-
if (!isVisible) return null;
|
|
145
|
-
if (!accessState.visible) return null;
|
|
146
|
-
|
|
147
|
-
// ───── Effective disabled (OR logic: explicit OR RBAC) ─────
|
|
148
|
-
const effectiveDisabled =
|
|
149
|
-
Boolean(disabled) || accessState.disabled || accessState.readonly;
|
|
150
|
-
|
|
151
|
-
// ───── Form mode vs Standalone ─────
|
|
152
|
-
const isFormMode = Boolean(bridge?.register);
|
|
153
|
-
|
|
154
|
-
let resolvedChecked: boolean | 'indeterminate' = checked ?? defaultChecked ?? false;
|
|
155
|
-
let resolvedError = error;
|
|
156
|
-
let resolvedHelperText: typeof helperText = helperText;
|
|
157
|
-
let registration: FieldRegistration | null = null;
|
|
158
|
-
|
|
159
|
-
if (isFormMode && bridge) {
|
|
160
|
-
registration = bridge.register(name, rules);
|
|
161
|
-
const validation = resolveValidationState(name, bridge, error, helperText);
|
|
162
|
-
resolvedError = validation.error;
|
|
163
|
-
resolvedHelperText = validation.helperText;
|
|
164
|
-
// Reactive snapshot from useDashFieldMeta — re-renders on per-field
|
|
165
|
-
// state change, unlike bridge.getValue (eager read, no subscription).
|
|
166
|
-
resolvedChecked =
|
|
167
|
-
checked !== undefined ? checked : Boolean(fieldMeta.value);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// ───── Handlers ─────
|
|
171
|
-
const handleCheckedChange = (next: boolean | 'indeterminate') => {
|
|
172
|
-
const nextBool = next === true; // indeterminate treated as unchecked at the bridge level
|
|
173
|
-
|
|
174
|
-
if (isFormMode && bridge) {
|
|
175
|
-
// Update bridge value FIRST so subsequent reads see the new state.
|
|
176
|
-
bridge.setValue?.(name, nextBool);
|
|
177
|
-
|
|
178
|
-
// Synthesise a minimal RHF-compatible event for registration.onChange.
|
|
179
|
-
const syntheticEvent = {
|
|
180
|
-
target: { name, checked: nextBool, value: nextBool },
|
|
181
|
-
type: 'change',
|
|
182
|
-
};
|
|
183
|
-
void registration?.onChange?.(syntheticEvent);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
onCheckedChange?.(nextBool);
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
const handleBlur = () => {
|
|
190
|
-
if (!isFormMode || !bridge) return;
|
|
191
|
-
const currentChecked = bridge.getValue(name) === true;
|
|
192
|
-
const syntheticEvent = {
|
|
193
|
-
target: { name, checked: currentChecked, value: currentChecked },
|
|
194
|
-
type: 'blur',
|
|
195
|
-
};
|
|
196
|
-
registration?.onBlur?.(syntheticEvent);
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
// ───── Render ─────
|
|
200
|
-
const v = checkboxVariants({ size, error: resolvedError });
|
|
201
|
-
|
|
202
|
-
// Radix Checkbox: pass `checked` (controlled) OR `defaultChecked`
|
|
203
|
-
// (uncontrolled), never both. In bridge mode the truth lives in the
|
|
204
|
-
// bridge — always controlled. Standalone: respect whichever prop the
|
|
205
|
-
// consumer supplied.
|
|
206
|
-
const radixStateProps: {
|
|
207
|
-
checked?: boolean | 'indeterminate';
|
|
208
|
-
defaultChecked?: boolean;
|
|
209
|
-
} = isFormMode
|
|
210
|
-
? { checked: resolvedChecked }
|
|
211
|
-
: checked !== undefined
|
|
212
|
-
? { checked }
|
|
213
|
-
: { defaultChecked: defaultChecked ?? false };
|
|
214
|
-
|
|
215
|
-
return (
|
|
216
|
-
<div className={cn(v.root(), sx, slotProps?.root?.className)}>
|
|
217
|
-
<RadixCheckbox.Root
|
|
218
|
-
id={controlId}
|
|
219
|
-
name={name}
|
|
220
|
-
{...radixStateProps}
|
|
221
|
-
disabled={effectiveDisabled}
|
|
222
|
-
onCheckedChange={handleCheckedChange}
|
|
223
|
-
onBlur={handleBlur}
|
|
224
|
-
ref={registration?.ref as React.Ref<HTMLButtonElement> | undefined}
|
|
225
|
-
className={cn(v.control(), slotProps?.control?.className)}
|
|
226
|
-
>
|
|
227
|
-
{/*
|
|
228
|
-
* Radix.Indicator natively mounts only when `data-state` is
|
|
229
|
-
* `checked` or `indeterminate` — i.e. it tracks Radix's
|
|
230
|
-
* internal state directly, no React state dependency.
|
|
231
|
-
*
|
|
232
|
-
* The previous implementation used `forceMount` + a React
|
|
233
|
-
* conditional `{resolvedChecked === true ? <CheckIcon /> : null}`,
|
|
234
|
-
* which broke standalone uncontrolled mode: Radix would flip
|
|
235
|
-
* its internal `data-state` on click (turning the control blue
|
|
236
|
-
* via `data-[state=checked]:bg-primary-500`) but the React
|
|
237
|
-
* snapshot for `resolvedChecked` stayed stale, so the
|
|
238
|
-
* `<CheckIcon />` never mounted. Result: blue box with no
|
|
239
|
-
* tick after user interaction.
|
|
240
|
-
*
|
|
241
|
-
* Dropping forceMount + the conditional defers the mount
|
|
242
|
-
* decision to Radix (the single source of truth in all three
|
|
243
|
-
* modes — controlled, uncontrolled, bridge). Indicator mounts
|
|
244
|
-
* exactly when the checkbox is checked OR indeterminate.
|
|
245
|
-
*
|
|
246
|
-
* Per-state glyph (Sprint 2 P4): when Indicator is mounted we
|
|
247
|
-
* render BOTH glyphs and toggle visibility via the Indicator's
|
|
248
|
-
* own `data-state` attribute. The `group` class on Indicator
|
|
249
|
-
* lets the SVG children target the parent's state with
|
|
250
|
-
* `group-data-[state=checked]:hidden` / `…:indeterminate:hidden`.
|
|
251
|
-
* No React state required — Radix's data-state attribute is
|
|
252
|
-
* the single source of truth.
|
|
253
|
-
*/}
|
|
254
|
-
<RadixCheckbox.Indicator
|
|
255
|
-
className={cn(v.indicator(), 'group', slotProps?.indicator?.className)}
|
|
256
|
-
>
|
|
257
|
-
<CheckIcon className="h-full w-full group-data-[state=indeterminate]:hidden" />
|
|
258
|
-
<DashIcon className="h-full w-full group-data-[state=checked]:hidden" />
|
|
259
|
-
</RadixCheckbox.Indicator>
|
|
260
|
-
</RadixCheckbox.Root>
|
|
261
|
-
|
|
262
|
-
<div className="flex flex-col">
|
|
263
|
-
{label && (
|
|
264
|
-
<label
|
|
265
|
-
htmlFor={controlId}
|
|
266
|
-
className={cn(v.label(), slotProps?.label?.className)}
|
|
267
|
-
>
|
|
268
|
-
{label}
|
|
269
|
-
</label>
|
|
270
|
-
)}
|
|
271
|
-
{resolvedHelperText && (
|
|
272
|
-
<p
|
|
273
|
-
className={cn(
|
|
274
|
-
resolvedError ? v.errorText() : v.helperText(),
|
|
275
|
-
resolvedError
|
|
276
|
-
? slotProps?.errorText?.className
|
|
277
|
-
: slotProps?.helperText?.className
|
|
278
|
-
)}
|
|
279
|
-
>
|
|
280
|
-
{resolvedHelperText}
|
|
281
|
-
</p>
|
|
282
|
-
)}
|
|
283
|
-
</div>
|
|
284
|
-
</div>
|
|
285
|
-
);
|
|
286
|
-
}
|
|
@@ -1,88 +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 { CheckboxVariants } from './checkbox.variants.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Per-slot className overrides for `<Checkbox>`. Shape mirrors the
|
|
8
|
-
* MUI-side `slotProps` convention: object-per-slot with a `className`
|
|
9
|
-
* key, so future extensions (style, aria-*, data-*) are additive.
|
|
10
|
-
*/
|
|
11
|
-
export interface CheckboxSlotProps {
|
|
12
|
-
root?: { className?: string };
|
|
13
|
-
control?: { className?: string };
|
|
14
|
-
indicator?: { className?: string };
|
|
15
|
-
label?: { className?: string };
|
|
16
|
-
helperText?: { className?: string };
|
|
17
|
-
errorText?: { className?: string };
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Props for the Dashforge TW `<Checkbox>` component.
|
|
22
|
-
*
|
|
23
|
-
* Behaves identically to `@dashforge/ui/Checkbox` (MUI) at the bridge
|
|
24
|
-
* level — same `name` / `rules` / `visibleWhen` / `access` semantics,
|
|
25
|
-
* same validation gating (touched OR submitCount > 0). The visual
|
|
26
|
-
* surface is rendered via Radix Checkbox + Tailwind classes.
|
|
27
|
-
*
|
|
28
|
-
* Note: the `error` prop here is the **public** form-validation
|
|
29
|
-
* semaphore (boolean override); it threads into the variant via
|
|
30
|
-
* `checkboxVariants({ error })` internally. The variant axis name and
|
|
31
|
-
* the prop name happen to coincide — same meaning.
|
|
32
|
-
*/
|
|
33
|
-
export interface CheckboxProps
|
|
34
|
-
extends Pick<CheckboxVariants, 'size'> {
|
|
35
|
-
/** Bridge field name (required when used inside `DashFormProvider`). */
|
|
36
|
-
name: string;
|
|
37
|
-
|
|
38
|
-
/** Visible label rendered next to the control. Click also toggles the box. */
|
|
39
|
-
label?: ReactNode;
|
|
40
|
-
|
|
41
|
-
/** Forwarded to the bridge as RHF rules — opaque to this component. */
|
|
42
|
-
rules?: unknown;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Engine predicate. When provided, the component renders only when
|
|
46
|
-
* the predicate returns truthy against the current engine state.
|
|
47
|
-
*/
|
|
48
|
-
visibleWhen?: (engine: Engine) => boolean;
|
|
49
|
-
|
|
50
|
-
/** Initial / controlled checked state. */
|
|
51
|
-
checked?: boolean;
|
|
52
|
-
|
|
53
|
-
/** Default checked when used uncontrolled. */
|
|
54
|
-
defaultChecked?: boolean;
|
|
55
|
-
|
|
56
|
-
/** Disabled — combined with RBAC disabled via OR. */
|
|
57
|
-
disabled?: boolean;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Forces helper text below the control. When the bridge surfaces an
|
|
61
|
-
* error and `helperText` is undefined, the bridge's error message
|
|
62
|
-
* shows up here (gated by `touched || submitCount > 0`).
|
|
63
|
-
*/
|
|
64
|
-
helperText?: ReactNode;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Explicit error flag. When `true`, the control renders with the
|
|
68
|
-
* danger ring + the error-text slot is used for `helperText`.
|
|
69
|
-
* Overrides the bridge's auto-detected error.
|
|
70
|
-
*/
|
|
71
|
-
error?: boolean;
|
|
72
|
-
|
|
73
|
-
/** RBAC requirement. */
|
|
74
|
-
access?: AccessRequirement;
|
|
75
|
-
|
|
76
|
-
/** Root-level Tailwind override. Wins over variant classes via `cn()`. */
|
|
77
|
-
sx?: string;
|
|
78
|
-
|
|
79
|
-
/** Per-slot overrides — see `CheckboxSlotProps`. */
|
|
80
|
-
slotProps?: CheckboxSlotProps;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Called when the user toggles the control. When inside a
|
|
84
|
-
* `DashFormProvider`, the bridge update happens first, then this
|
|
85
|
-
* callback fires with the new checked state.
|
|
86
|
-
*/
|
|
87
|
-
onCheckedChange?: (checked: boolean) => void;
|
|
88
|
-
}
|