@astral/ui 4.113.3 → 4.115.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/ActionGroup/ActionGroup.js +2 -2
- package/components/ActionGroup/SecondaryActions/SecondaryActions.d.ts +1 -1
- package/components/ActionGroup/SecondaryActions/SecondaryActions.js +2 -2
- package/components/ActionGroup/types.d.ts +9 -0
- package/components/DataGrid/Body/Body.d.ts +1 -1
- package/components/DataGrid/Body/Body.js +7 -3
- package/components/DataGrid/Body/types.d.ts +11 -3
- package/components/DataGrid/DataGrid.js +13 -6
- package/components/DataGrid/DataGridContext/DataGridProvider/DataGridProvider.d.ts +3 -2
- package/components/DataGrid/DataGridContext/DataGridProvider/DataGridProvider.js +3 -2
- package/components/DataGrid/DataGridSelectionContext/DataGridSelectionContext.d.ts +25 -0
- package/components/DataGrid/DataGridSelectionContext/DataGridSelectionContext.js +13 -0
- package/components/DataGrid/DataGridSelectionContext/DataGridSelectionProvider/DataGridSelectionProvider.d.ts +7 -0
- package/components/DataGrid/DataGridSelectionContext/DataGridSelectionProvider/DataGridSelectionProvider.js +8 -0
- package/components/DataGrid/DataGridSelectionContext/DataGridSelectionProvider/index.d.ts +1 -0
- package/components/DataGrid/DataGridSelectionContext/DataGridSelectionProvider/index.js +1 -0
- package/components/DataGrid/DataGridSelectionContext/index.d.ts +2 -0
- package/components/DataGrid/DataGridSelectionContext/index.js +2 -0
- package/components/DataGrid/PinnedSections/PinnedSections.js +2 -2
- package/components/DataGrid/PinnedSections/useLogic/useLogic.d.ts +1 -0
- package/components/DataGrid/PinnedSections/useLogic/useLogic.js +4 -3
- package/components/DataGrid/Row/Row.js +13 -9
- package/components/DataGrid/Row/RowContext/RowContext.d.ts +15 -4
- package/components/DataGrid/Row/RowContext/RowContext.js +3 -3
- package/components/DataGrid/Row/RowContext/RowProvider/RowProvider.d.ts +10 -1
- package/components/DataGrid/Row/RowContext/RowProvider/RowProvider.js +23 -17
- package/components/DataGrid/Row/types.d.ts +7 -3
- package/components/DataGrid/Row/useLogic/useLogic.d.ts +6 -4
- package/components/DataGrid/Row/useLogic/useLogic.js +21 -12
- package/components/DataGrid/RowBase/RowBase.js +5 -2
- package/components/DataGrid/RowBase/types.d.ts +9 -5
- package/components/DataGrid/RowBase/useLogic/useLogic.d.ts +5 -4
- package/components/DataGrid/RowBase/useLogic/useLogic.js +16 -10
- package/components/DataGrid/RowCheckbox/RowCheckbox.d.ts +5 -0
- package/components/DataGrid/RowCheckbox/RowCheckbox.js +13 -0
- package/components/DataGrid/RowCheckbox/constants.d.ts +4 -0
- package/components/DataGrid/RowCheckbox/constants.js +4 -0
- package/components/DataGrid/RowCheckbox/index.d.ts +1 -0
- package/components/DataGrid/RowCheckbox/index.js +1 -0
- package/components/DataGrid/RowCheckbox/types.d.ts +7 -0
- package/components/DataGrid/RowCheckbox/types.js +1 -0
- package/components/DataGrid/constants.d.ts +2 -0
- package/components/DataGrid/constants.js +2 -0
- package/components/DataGrid/hooks/index.d.ts +1 -0
- package/components/DataGrid/hooks/index.js +1 -0
- package/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/index.d.ts +1 -0
- package/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/index.js +1 -0
- package/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/useWarnRowsWithoutDisabledReason.d.ts +5 -0
- package/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/useWarnRowsWithoutDisabledReason.js +17 -0
- package/components/DataGrid/index.d.ts +1 -1
- package/components/DataGrid/public.d.ts +1 -1
- package/components/DataGrid/styles.d.ts +4 -0
- package/components/DataGrid/styles.js +26 -0
- package/components/DataGrid/tests/performance/testDataGridPerformance.d.ts +3 -1
- package/components/DataGrid/tests/performance/testDataGridPerformance.js +234 -2
- package/components/DataGrid/tests/selection/testDataGridSelection.d.ts +14 -0
- package/components/DataGrid/tests/selection/testDataGridSelection.js +562 -0
- package/components/DataGrid/types.d.ts +41 -1
- package/components/DataGrid/useLogic/useLogic.d.ts +8 -3
- package/components/DataGrid/useLogic/useLogic.js +23 -10
- package/components/DataGrid/utils/checkIsMassActionsOpen/checkIsMassActionsOpen.d.ts +10 -0
- package/components/DataGrid/utils/checkIsMassActionsOpen/checkIsMassActionsOpen.js +4 -0
- package/components/DataGrid/utils/checkIsMassActionsOpen/index.d.ts +1 -0
- package/components/DataGrid/utils/checkIsMassActionsOpen/index.js +1 -0
- package/components/DataGrid/utils/getRowDisabledState/getRowDisabledState.d.ts +31 -0
- package/components/DataGrid/utils/getRowDisabledState/getRowDisabledState.js +20 -0
- package/components/DataGrid/utils/getRowDisabledState/index.d.ts +1 -0
- package/components/DataGrid/utils/getRowDisabledState/index.js +1 -0
- package/components/DataGrid/utils/index.d.ts +4 -0
- package/components/DataGrid/utils/index.js +4 -0
- package/components/DataGrid/utils/resolveRowDisabled/index.d.ts +1 -0
- package/components/DataGrid/utils/resolveRowDisabled/index.js +1 -0
- package/components/DataGrid/utils/resolveRowDisabled/resolveRowDisabled.d.ts +5 -0
- package/components/DataGrid/utils/resolveRowDisabled/resolveRowDisabled.js +17 -0
- package/components/DataGrid/utils/resolveRowsDisabled/index.d.ts +1 -0
- package/components/DataGrid/utils/resolveRowsDisabled/index.js +1 -0
- package/components/DataGrid/utils/resolveRowsDisabled/resolveRowsDisabled.d.ts +16 -0
- package/components/DataGrid/utils/resolveRowsDisabled/resolveRowsDisabled.js +17 -0
- package/components/DataGridActionCell/hooks/useBlockingActions/useBlockingActions.js +3 -3
- package/components/DataGridCollapsibleRow/useLogic/useLogic.d.ts +3 -2
- package/components/DataGridCollapsibleRow/useLogic/useLogic.js +4 -3
- package/components/DataGridInfinite/DataGridInfinite.js +18 -14
- package/components/DataGridInfinite/DataGridInfiniteContext/DataGridInfiniteContext.d.ts +1 -1
- package/components/DataGridInfinite/DataGridInfiniteContext/DataGridInfiniteContext.js +1 -1
- package/components/DataGridInfinite/Footer/Footer.d.ts +6 -0
- package/components/DataGridInfinite/Footer/Footer.js +25 -0
- package/components/DataGridInfinite/Footer/index.d.ts +2 -0
- package/components/DataGridInfinite/Footer/index.js +1 -0
- package/components/DataGridInfinite/Footer/types.d.ts +26 -0
- package/components/DataGridInfinite/Footer/types.js +1 -0
- package/components/DataGridInfinite/Row/Row.js +2 -2
- package/components/DataGridInfinite/Row/index.d.ts +1 -0
- package/components/DataGridInfinite/Row/types.d.ts +17 -2
- package/components/DataGridInfinite/Row/useLogic/useLogic.d.ts +4 -2
- package/components/DataGridInfinite/Row/useLogic/useLogic.js +12 -4
- package/components/DataGridInfinite/constants.d.ts +3 -0
- package/components/DataGridInfinite/constants.js +3 -0
- package/components/DataGridInfinite/faker.d.ts +1 -5
- package/components/DataGridInfinite/faker.js +1 -2
- package/components/DataGridInfinite/styles.d.ts +4 -0
- package/components/DataGridInfinite/styles.js +24 -0
- package/components/DataGridInfinite/useLogic/useLogic.d.ts +7 -3
- package/components/DataGridInfinite/useLogic/useLogic.js +52 -16
- package/components/DataGridMassActions/DataGridMassActions.d.ts +15 -0
- package/components/DataGridMassActions/DataGridMassActions.js +32 -0
- package/components/DataGridMassActions/constants.d.ts +4 -0
- package/components/DataGridMassActions/constants.js +5 -0
- package/components/DataGridMassActions/index.d.ts +2 -0
- package/components/DataGridMassActions/index.js +1 -0
- package/components/DataGridMassActions/public.d.ts +2 -0
- package/components/DataGridMassActions/public.js +1 -0
- package/components/DataGridMassActions/styles.d.ts +8 -0
- package/components/DataGridMassActions/styles.js +49 -0
- package/components/DataGridMassActions/tests/testDataGridMassActions.d.ts +23 -0
- package/components/DataGridMassActions/tests/testDataGridMassActions.js +77 -0
- package/components/DataGridMassActions/types.d.ts +2 -0
- package/components/DataGridMassActions/types.js +1 -0
- package/components/DataGridMassActions/useLogic/index.d.ts +1 -0
- package/components/DataGridMassActions/useLogic/index.js +1 -0
- package/components/DataGridMassActions/useLogic/useLogic.d.ts +6 -0
- package/components/DataGridMassActions/useLogic/useLogic.js +21 -0
- package/components/IconDropdownButton/IconDropdownButton.d.ts +5 -0
- package/components/IconDropdownButton/IconDropdownButton.js +2 -2
- package/components/MassActions/MassActions.d.ts +5 -0
- package/components/MassActions/MassActions.js +17 -0
- package/components/MassActions/constants.d.ts +6 -0
- package/components/MassActions/constants.js +12 -0
- package/components/MassActions/index.d.ts +2 -0
- package/components/MassActions/index.js +1 -0
- package/components/MassActions/styles.d.ts +34 -0
- package/components/MassActions/styles.js +43 -0
- package/components/MassActions/types.d.ts +20 -0
- package/components/MassActions/types.js +1 -0
- package/components/MassActions/useLogic/index.d.ts +1 -0
- package/components/MassActions/useLogic/index.js +1 -0
- package/components/MassActions/useLogic/useLogic.d.ts +7 -0
- package/components/MassActions/useLogic/useLogic.js +9 -0
- package/components/PageHeader/PageActions/SecondaryActions/styles.d.ts +1 -1
- package/components/Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/index.d.ts +0 -1
- package/components/Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/index.js +0 -1
- package/components/Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/useLogic.js +2 -1
- package/components/index.d.ts +1 -1
- package/node/components/ActionGroup/ActionGroup.js +2 -2
- package/node/components/ActionGroup/SecondaryActions/SecondaryActions.d.ts +1 -1
- package/node/components/ActionGroup/SecondaryActions/SecondaryActions.js +2 -2
- package/node/components/ActionGroup/types.d.ts +9 -0
- package/node/components/DataGrid/Body/Body.d.ts +1 -1
- package/node/components/DataGrid/Body/Body.js +7 -3
- package/node/components/DataGrid/Body/types.d.ts +11 -3
- package/node/components/DataGrid/DataGrid.js +12 -5
- package/node/components/DataGrid/DataGridContext/DataGridProvider/DataGridProvider.d.ts +3 -2
- package/node/components/DataGrid/DataGridContext/DataGridProvider/DataGridProvider.js +3 -2
- package/node/components/DataGrid/DataGridSelectionContext/DataGridSelectionContext.d.ts +25 -0
- package/node/components/DataGrid/DataGridSelectionContext/DataGridSelectionContext.js +16 -0
- package/node/components/DataGrid/DataGridSelectionContext/DataGridSelectionProvider/DataGridSelectionProvider.d.ts +7 -0
- package/node/components/DataGrid/DataGridSelectionContext/DataGridSelectionProvider/DataGridSelectionProvider.js +12 -0
- package/node/components/DataGrid/DataGridSelectionContext/DataGridSelectionProvider/index.d.ts +1 -0
- package/node/components/DataGrid/DataGridSelectionContext/DataGridSelectionProvider/index.js +17 -0
- package/node/components/DataGrid/DataGridSelectionContext/index.d.ts +2 -0
- package/node/components/DataGrid/DataGridSelectionContext/index.js +18 -0
- package/node/components/DataGrid/PinnedSections/PinnedSections.js +2 -2
- package/node/components/DataGrid/PinnedSections/useLogic/useLogic.d.ts +1 -0
- package/node/components/DataGrid/PinnedSections/useLogic/useLogic.js +4 -3
- package/node/components/DataGrid/Row/Row.js +13 -9
- package/node/components/DataGrid/Row/RowContext/RowContext.d.ts +15 -4
- package/node/components/DataGrid/Row/RowContext/RowContext.js +3 -3
- package/node/components/DataGrid/Row/RowContext/RowProvider/RowProvider.d.ts +10 -1
- package/node/components/DataGrid/Row/RowContext/RowProvider/RowProvider.js +23 -17
- package/node/components/DataGrid/Row/types.d.ts +7 -3
- package/node/components/DataGrid/Row/useLogic/useLogic.d.ts +6 -4
- package/node/components/DataGrid/Row/useLogic/useLogic.js +23 -14
- package/node/components/DataGrid/RowBase/RowBase.js +5 -2
- package/node/components/DataGrid/RowBase/types.d.ts +9 -5
- package/node/components/DataGrid/RowBase/useLogic/useLogic.d.ts +5 -4
- package/node/components/DataGrid/RowBase/useLogic/useLogic.js +16 -10
- package/node/components/DataGrid/RowCheckbox/RowCheckbox.d.ts +5 -0
- package/node/components/DataGrid/RowCheckbox/RowCheckbox.js +17 -0
- package/node/components/DataGrid/RowCheckbox/constants.d.ts +4 -0
- package/node/components/DataGrid/RowCheckbox/constants.js +7 -0
- package/node/components/DataGrid/RowCheckbox/index.d.ts +1 -0
- package/node/components/DataGrid/RowCheckbox/index.js +17 -0
- package/node/components/DataGrid/RowCheckbox/types.d.ts +7 -0
- package/node/components/DataGrid/RowCheckbox/types.js +2 -0
- package/node/components/DataGrid/constants.d.ts +2 -0
- package/node/components/DataGrid/constants.js +2 -0
- package/node/components/DataGrid/hooks/index.d.ts +1 -0
- package/node/components/DataGrid/hooks/index.js +1 -0
- package/node/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/index.d.ts +1 -0
- package/node/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/index.js +17 -0
- package/node/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/useWarnRowsWithoutDisabledReason.d.ts +5 -0
- package/node/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/useWarnRowsWithoutDisabledReason.js +21 -0
- package/node/components/DataGrid/index.d.ts +1 -1
- package/node/components/DataGrid/public.d.ts +1 -1
- package/node/components/DataGrid/styles.d.ts +4 -0
- package/node/components/DataGrid/styles.js +27 -1
- package/node/components/DataGrid/tests/performance/testDataGridPerformance.d.ts +3 -1
- package/node/components/DataGrid/tests/performance/testDataGridPerformance.js +232 -0
- package/node/components/DataGrid/tests/selection/testDataGridSelection.d.ts +14 -0
- package/node/components/DataGrid/tests/selection/testDataGridSelection.js +566 -0
- package/node/components/DataGrid/types.d.ts +41 -1
- package/node/components/DataGrid/useLogic/useLogic.d.ts +8 -3
- package/node/components/DataGrid/useLogic/useLogic.js +25 -12
- package/node/components/DataGrid/utils/checkIsMassActionsOpen/checkIsMassActionsOpen.d.ts +10 -0
- package/node/components/DataGrid/utils/checkIsMassActionsOpen/checkIsMassActionsOpen.js +8 -0
- package/node/components/DataGrid/utils/checkIsMassActionsOpen/index.d.ts +1 -0
- package/node/components/DataGrid/utils/checkIsMassActionsOpen/index.js +5 -0
- package/node/components/DataGrid/utils/getRowDisabledState/getRowDisabledState.d.ts +31 -0
- package/node/components/DataGrid/utils/getRowDisabledState/getRowDisabledState.js +24 -0
- package/node/components/DataGrid/utils/getRowDisabledState/index.d.ts +1 -0
- package/node/components/DataGrid/utils/getRowDisabledState/index.js +5 -0
- package/node/components/DataGrid/utils/index.d.ts +4 -0
- package/node/components/DataGrid/utils/index.js +9 -1
- package/node/components/DataGrid/utils/resolveRowDisabled/index.d.ts +1 -0
- package/node/components/DataGrid/utils/resolveRowDisabled/index.js +5 -0
- package/node/components/DataGrid/utils/resolveRowDisabled/resolveRowDisabled.d.ts +5 -0
- package/node/components/DataGrid/utils/resolveRowDisabled/resolveRowDisabled.js +21 -0
- package/node/components/DataGrid/utils/resolveRowsDisabled/index.d.ts +1 -0
- package/node/components/DataGrid/utils/resolveRowsDisabled/index.js +5 -0
- package/node/components/DataGrid/utils/resolveRowsDisabled/resolveRowsDisabled.d.ts +16 -0
- package/node/components/DataGrid/utils/resolveRowsDisabled/resolveRowsDisabled.js +21 -0
- package/node/components/DataGridActionCell/hooks/useBlockingActions/useBlockingActions.js +3 -3
- package/node/components/DataGridCollapsibleRow/useLogic/useLogic.d.ts +3 -2
- package/node/components/DataGridCollapsibleRow/useLogic/useLogic.js +4 -3
- package/node/components/DataGridInfinite/DataGridInfinite.js +19 -15
- package/node/components/DataGridInfinite/DataGridInfiniteContext/DataGridInfiniteContext.d.ts +1 -1
- package/node/components/DataGridInfinite/DataGridInfiniteContext/DataGridInfiniteContext.js +1 -1
- package/node/components/DataGridInfinite/Footer/Footer.d.ts +6 -0
- package/node/components/DataGridInfinite/Footer/Footer.js +29 -0
- package/node/components/DataGridInfinite/Footer/index.d.ts +2 -0
- package/node/components/DataGridInfinite/Footer/index.js +17 -0
- package/node/components/DataGridInfinite/Footer/types.d.ts +26 -0
- package/node/components/DataGridInfinite/Footer/types.js +2 -0
- package/node/components/DataGridInfinite/Row/Row.js +2 -2
- package/node/components/DataGridInfinite/Row/index.d.ts +1 -0
- package/node/components/DataGridInfinite/Row/types.d.ts +17 -2
- package/node/components/DataGridInfinite/Row/useLogic/useLogic.d.ts +4 -2
- package/node/components/DataGridInfinite/Row/useLogic/useLogic.js +12 -4
- package/node/components/DataGridInfinite/constants.d.ts +3 -0
- package/node/components/DataGridInfinite/constants.js +3 -0
- package/node/components/DataGridInfinite/faker.d.ts +1 -5
- package/node/components/DataGridInfinite/faker.js +1 -2
- package/node/components/DataGridInfinite/styles.d.ts +4 -0
- package/node/components/DataGridInfinite/styles.js +27 -3
- package/node/components/DataGridInfinite/useLogic/useLogic.d.ts +7 -3
- package/node/components/DataGridInfinite/useLogic/useLogic.js +52 -16
- package/node/components/DataGridMassActions/DataGridMassActions.d.ts +15 -0
- package/node/components/DataGridMassActions/DataGridMassActions.js +36 -0
- package/node/components/DataGridMassActions/constants.d.ts +4 -0
- package/node/components/DataGridMassActions/constants.js +8 -0
- package/node/components/DataGridMassActions/index.d.ts +2 -0
- package/node/components/DataGridMassActions/index.js +5 -0
- package/node/components/DataGridMassActions/public.d.ts +2 -0
- package/node/components/DataGridMassActions/public.js +5 -0
- package/node/components/DataGridMassActions/styles.d.ts +8 -0
- package/node/components/DataGridMassActions/styles.js +52 -0
- package/node/components/DataGridMassActions/tests/testDataGridMassActions.d.ts +23 -0
- package/node/components/DataGridMassActions/tests/testDataGridMassActions.js +81 -0
- package/node/components/DataGridMassActions/types.d.ts +2 -0
- package/node/components/DataGridMassActions/types.js +2 -0
- package/node/components/DataGridMassActions/useLogic/index.d.ts +1 -0
- package/node/components/DataGridMassActions/useLogic/index.js +17 -0
- package/node/components/DataGridMassActions/useLogic/useLogic.d.ts +6 -0
- package/node/components/DataGridMassActions/useLogic/useLogic.js +25 -0
- package/node/components/IconDropdownButton/IconDropdownButton.d.ts +5 -0
- package/node/components/IconDropdownButton/IconDropdownButton.js +2 -2
- package/node/components/MassActions/MassActions.d.ts +5 -0
- package/node/components/MassActions/MassActions.js +21 -0
- package/node/components/MassActions/constants.d.ts +6 -0
- package/node/components/MassActions/constants.js +15 -0
- package/node/components/MassActions/index.d.ts +2 -0
- package/node/components/MassActions/index.js +5 -0
- package/node/components/MassActions/styles.d.ts +34 -0
- package/node/components/MassActions/styles.js +46 -0
- package/node/components/MassActions/types.d.ts +20 -0
- package/node/components/MassActions/types.js +2 -0
- package/node/components/MassActions/useLogic/index.d.ts +1 -0
- package/node/components/MassActions/useLogic/index.js +17 -0
- package/node/components/MassActions/useLogic/useLogic.d.ts +7 -0
- package/node/components/MassActions/useLogic/useLogic.js +13 -0
- package/node/components/PageHeader/PageActions/SecondaryActions/styles.d.ts +1 -1
- package/node/components/Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/index.d.ts +0 -1
- package/node/components/Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/index.js +0 -1
- package/node/components/Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/useLogic.js +2 -1
- package/node/components/index.d.ts +1 -1
- package/package.json +1 -1
- /package/components/{Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/useDelayedUnmount → useDelayedUnmount}/index.d.ts +0 -0
- /package/components/{Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/useDelayedUnmount → useDelayedUnmount}/index.js +0 -0
- /package/components/{Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/useDelayedUnmount → useDelayedUnmount}/useDelayedUnmount.d.ts +0 -0
- /package/components/{Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/useDelayedUnmount → useDelayedUnmount}/useDelayedUnmount.js +0 -0
- /package/node/components/{Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/useDelayedUnmount → useDelayedUnmount}/index.d.ts +0 -0
- /package/node/components/{Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/useDelayedUnmount → useDelayedUnmount}/index.js +0 -0
- /package/node/components/{Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/useDelayedUnmount → useDelayedUnmount}/useDelayedUnmount.d.ts +0 -0
- /package/node/components/{Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/useDelayedUnmount → useDelayedUnmount}/useDelayedUnmount.js +0 -0
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.testDataGridSelection = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const tests_1 = require("@ui/dev/tests");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const vitest_1 = require("vitest");
|
|
8
|
+
const Tooltip_1 = require("../../../Tooltip");
|
|
9
|
+
const constants_1 = require("../../Row/constants");
|
|
10
|
+
const COLUMNS = [
|
|
11
|
+
{ field: 'name', label: 'Наименование' },
|
|
12
|
+
];
|
|
13
|
+
const COLUMNS_WITH_ACTION = [
|
|
14
|
+
{ field: 'name', label: 'Наименование' },
|
|
15
|
+
{
|
|
16
|
+
label: 'Действия',
|
|
17
|
+
renderCell: ({ name }) => (0, jsx_runtime_1.jsxs)("button", { type: "button", children: ["\u041E\u0442\u043A\u0440\u044B\u0442\u044C ", name] }),
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
const FIRST_PAGE_ROWS = [
|
|
21
|
+
{ id: '1', name: 'Договор №1' },
|
|
22
|
+
{ id: '2', name: 'Договор №2' },
|
|
23
|
+
];
|
|
24
|
+
const SECOND_PAGE_ROWS = [
|
|
25
|
+
{ id: '3', name: 'Договор №3' },
|
|
26
|
+
{ id: '4', name: 'Договор №4' },
|
|
27
|
+
];
|
|
28
|
+
const NUMERIC_ID_ROWS = [{ id: 1, name: 'Договор №1' }];
|
|
29
|
+
const SELECTION_DISABLED = {
|
|
30
|
+
mode: 'selection',
|
|
31
|
+
reason: 'Документ отправляется',
|
|
32
|
+
};
|
|
33
|
+
const ROW_DISABLED = {
|
|
34
|
+
mode: 'row',
|
|
35
|
+
reason: 'Нет доступа',
|
|
36
|
+
};
|
|
37
|
+
const ROW_EXCEPT_LAST_CELL_DISABLED = {
|
|
38
|
+
mode: 'row-except-last-cell',
|
|
39
|
+
reason: 'Нет доступа',
|
|
40
|
+
};
|
|
41
|
+
const SELECTION_DISABLED_WITHOUT_REASON = {
|
|
42
|
+
mode: 'selection',
|
|
43
|
+
reason: '',
|
|
44
|
+
};
|
|
45
|
+
const ROW_DISABLED_WITHOUT_REASON = {
|
|
46
|
+
mode: 'row',
|
|
47
|
+
reason: '',
|
|
48
|
+
};
|
|
49
|
+
const INERT_BY_MODE_CASES = [
|
|
50
|
+
{ mode: 'row', isInertCell: true, isInertLastCell: true },
|
|
51
|
+
{ mode: 'row-except-last-cell', isInertCell: true, isInertLastCell: false },
|
|
52
|
+
{ mode: 'selection', isInertCell: false, isInertLastCell: false },
|
|
53
|
+
];
|
|
54
|
+
const NESTED_ROWS = [
|
|
55
|
+
{
|
|
56
|
+
id: '1',
|
|
57
|
+
name: 'Пакет документов',
|
|
58
|
+
children: [{ id: '1-1', name: 'Вложенный договор' }],
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
const getSelectAllCheckbox = () => (0, tests_1.within)(tests_1.screen.getByRole('heading')).getByRole('checkbox');
|
|
62
|
+
// closest берёт ближайшую строку, поэтому для вложенной строки не находится родительская
|
|
63
|
+
const getRowCheckbox = (name) => {
|
|
64
|
+
const row = tests_1.screen.getByText(name).closest('li');
|
|
65
|
+
if (!row) {
|
|
66
|
+
throw new Error(`Строка «${name}» не найдена`);
|
|
67
|
+
}
|
|
68
|
+
return (0, tests_1.within)(row).getByRole('checkbox');
|
|
69
|
+
};
|
|
70
|
+
// Заблокированная ячейка недоступна через атрибут inert
|
|
71
|
+
const checkIsInert = (element) => Boolean(element.closest('[inert]'));
|
|
72
|
+
const getActionButton = (name) => tests_1.screen.getByRole('button', { name: `Открыть ${name}` });
|
|
73
|
+
const getRowContent = (name) => {
|
|
74
|
+
const rowContent = tests_1.screen.getByText(name).closest(`[${constants_1.DISABLE_ROW_ATTR}]`);
|
|
75
|
+
if (!(rowContent instanceof HTMLElement)) {
|
|
76
|
+
throw new Error(`Содержимое строки «${name}» не найдено`);
|
|
77
|
+
}
|
|
78
|
+
return rowContent;
|
|
79
|
+
};
|
|
80
|
+
const testDataGridSelection = ({ render, renderGrid, }) => {
|
|
81
|
+
const setup = (props = {}) => {
|
|
82
|
+
const onSelectRowSpy = vitest_1.vi.fn();
|
|
83
|
+
const renderUi = (nextProps) => renderGrid({
|
|
84
|
+
rows: FIRST_PAGE_ROWS,
|
|
85
|
+
columns: COLUMNS,
|
|
86
|
+
onSelectRow: onSelectRowSpy,
|
|
87
|
+
onRetry: () => { },
|
|
88
|
+
...nextProps,
|
|
89
|
+
});
|
|
90
|
+
const view = render(renderUi(props));
|
|
91
|
+
const rerenderGrid = (nextProps) => view.rerender(renderUi(nextProps));
|
|
92
|
+
return { onSelectRowSpy, rerenderGrid };
|
|
93
|
+
};
|
|
94
|
+
(0, vitest_1.it)('Выбор строк предыдущей страницы сохраняется при выборе строки на новой странице', async () => {
|
|
95
|
+
const { onSelectRowSpy } = setup({
|
|
96
|
+
rows: SECOND_PAGE_ROWS,
|
|
97
|
+
selectedRows: [FIRST_PAGE_ROWS[0]],
|
|
98
|
+
});
|
|
99
|
+
await tests_1.userEvents.click(getRowCheckbox('Договор №3'));
|
|
100
|
+
(0, vitest_1.expect)(onSelectRowSpy).toHaveBeenCalledWith([
|
|
101
|
+
FIRST_PAGE_ROWS[0],
|
|
102
|
+
SECOND_PAGE_ROWS[0],
|
|
103
|
+
]);
|
|
104
|
+
});
|
|
105
|
+
(0, vitest_1.it)('Строки отмечены выбранными при возврате на страницу с выбранными строками', () => {
|
|
106
|
+
const selectedRows = [FIRST_PAGE_ROWS[0]];
|
|
107
|
+
const { rerenderGrid } = setup({
|
|
108
|
+
rows: SECOND_PAGE_ROWS,
|
|
109
|
+
selectedRows,
|
|
110
|
+
});
|
|
111
|
+
rerenderGrid({ rows: FIRST_PAGE_ROWS, selectedRows });
|
|
112
|
+
(0, vitest_1.expect)(getRowCheckbox('Договор №1')).toBeChecked();
|
|
113
|
+
});
|
|
114
|
+
(0, vitest_1.it)('Строка выбрана при числовом keyId', () => {
|
|
115
|
+
setup({ rows: NUMERIC_ID_ROWS, selectedRows: NUMERIC_ID_ROWS });
|
|
116
|
+
(0, vitest_1.expect)(getRowCheckbox('Договор №1')).toBeChecked();
|
|
117
|
+
});
|
|
118
|
+
(0, vitest_1.it)('«Выбрать все» не отмечен при selectedRows только из строк вне выдачи', () => {
|
|
119
|
+
setup({ selectedRows: SECOND_PAGE_ROWS });
|
|
120
|
+
(0, vitest_1.expect)(getSelectAllCheckbox()).not.toBeChecked();
|
|
121
|
+
});
|
|
122
|
+
(0, vitest_1.describe)('onSelectRow не вызывается', () => {
|
|
123
|
+
(0, vitest_1.it)('При новом массиве selectedRows', () => {
|
|
124
|
+
const { rerenderGrid, onSelectRowSpy } = setup({
|
|
125
|
+
selectedRows: [FIRST_PAGE_ROWS[0]],
|
|
126
|
+
});
|
|
127
|
+
rerenderGrid({ selectedRows: [FIRST_PAGE_ROWS[1]] });
|
|
128
|
+
(0, vitest_1.expect)(onSelectRowSpy).not.toHaveBeenCalled();
|
|
129
|
+
});
|
|
130
|
+
(0, vitest_1.it)('При новом массиве rows с теми же строками', () => {
|
|
131
|
+
const { rerenderGrid, onSelectRowSpy } = setup({
|
|
132
|
+
selectedRows: [FIRST_PAGE_ROWS[0]],
|
|
133
|
+
});
|
|
134
|
+
rerenderGrid({
|
|
135
|
+
rows: [...FIRST_PAGE_ROWS],
|
|
136
|
+
selectedRows: [FIRST_PAGE_ROWS[0]],
|
|
137
|
+
});
|
|
138
|
+
(0, vitest_1.expect)(onSelectRowSpy).not.toHaveBeenCalled();
|
|
139
|
+
});
|
|
140
|
+
(0, vitest_1.it)('При новой функции getRowDisabled', () => {
|
|
141
|
+
const selectedRows = [FIRST_PAGE_ROWS[0]];
|
|
142
|
+
const { rerenderGrid, onSelectRowSpy } = setup({
|
|
143
|
+
selectedRows,
|
|
144
|
+
getRowDisabled: () => undefined,
|
|
145
|
+
});
|
|
146
|
+
rerenderGrid({
|
|
147
|
+
selectedRows,
|
|
148
|
+
getRowDisabled: () => SELECTION_DISABLED,
|
|
149
|
+
});
|
|
150
|
+
(0, vitest_1.expect)(onSelectRowSpy).not.toHaveBeenCalled();
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
(0, vitest_1.describe)('Выбрать все', () => {
|
|
154
|
+
(0, vitest_1.it)('Выбор строк других страниц сохраняется', async () => {
|
|
155
|
+
const { onSelectRowSpy } = setup({
|
|
156
|
+
rows: SECOND_PAGE_ROWS,
|
|
157
|
+
selectedRows: [FIRST_PAGE_ROWS[0]],
|
|
158
|
+
});
|
|
159
|
+
await tests_1.userEvents.click(getSelectAllCheckbox());
|
|
160
|
+
(0, vitest_1.expect)(onSelectRowSpy).toHaveBeenCalledWith([
|
|
161
|
+
FIRST_PAGE_ROWS[0],
|
|
162
|
+
...SECOND_PAGE_ROWS,
|
|
163
|
+
]);
|
|
164
|
+
});
|
|
165
|
+
vitest_1.it.each([
|
|
166
|
+
{ condition: 'mode=selection', rowDisabled: SELECTION_DISABLED },
|
|
167
|
+
{ condition: 'mode=row', rowDisabled: ROW_DISABLED },
|
|
168
|
+
{
|
|
169
|
+
condition: 'mode=row-except-last-cell',
|
|
170
|
+
rowDisabled: ROW_EXCEPT_LAST_CELL_DISABLED,
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
condition: 'options.isDisabled=true',
|
|
174
|
+
options: { isDisabled: true },
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
condition: 'isNotSelectable=true',
|
|
178
|
+
options: { isNotSelectable: true },
|
|
179
|
+
},
|
|
180
|
+
])('Строка с $condition не выбирается', async ({ rowDisabled, options }) => {
|
|
181
|
+
const rows = [
|
|
182
|
+
FIRST_PAGE_ROWS[0],
|
|
183
|
+
{ ...FIRST_PAGE_ROWS[1], options },
|
|
184
|
+
];
|
|
185
|
+
const { onSelectRowSpy } = setup({
|
|
186
|
+
rows,
|
|
187
|
+
selectedRows: [],
|
|
188
|
+
getRowDisabled: rowDisabled
|
|
189
|
+
? (row) => (row.id === '2' ? rowDisabled : undefined)
|
|
190
|
+
: undefined,
|
|
191
|
+
});
|
|
192
|
+
await tests_1.userEvents.click(getSelectAllCheckbox());
|
|
193
|
+
(0, vitest_1.expect)(onSelectRowSpy).toHaveBeenCalledWith([FIRST_PAGE_ROWS[0]]);
|
|
194
|
+
});
|
|
195
|
+
(0, vitest_1.it)('Чекбокс отмечен, если выбраны все доступные строки', () => {
|
|
196
|
+
setup({
|
|
197
|
+
selectedRows: [FIRST_PAGE_ROWS[0]],
|
|
198
|
+
getRowDisabled: (row) => row.id === '2' ? SELECTION_DISABLED : undefined,
|
|
199
|
+
});
|
|
200
|
+
(0, vitest_1.expect)(getSelectAllCheckbox()).toBeChecked();
|
|
201
|
+
});
|
|
202
|
+
(0, vitest_1.it)('Чекбокс в неопределённом состоянии при выборе части доступных строк', () => {
|
|
203
|
+
setup({ selectedRows: [FIRST_PAGE_ROWS[0]] });
|
|
204
|
+
(0, vitest_1.expect)(getSelectAllCheckbox()).toHaveAttribute('aria-checked', 'mixed');
|
|
205
|
+
});
|
|
206
|
+
(0, vitest_1.it)('Чекбокс не отмечен, если выбрана только строка с mode=selection', () => {
|
|
207
|
+
setup({
|
|
208
|
+
selectedRows: [FIRST_PAGE_ROWS[1]],
|
|
209
|
+
getRowDisabled: (row) => row.id === '2' ? SELECTION_DISABLED : undefined,
|
|
210
|
+
});
|
|
211
|
+
(0, vitest_1.expect)(getSelectAllCheckbox()).toHaveAttribute('aria-checked', 'false');
|
|
212
|
+
});
|
|
213
|
+
(0, vitest_1.it)('Выбранная строка с mode=selection остаётся выбранной', async () => {
|
|
214
|
+
const { onSelectRowSpy } = setup({
|
|
215
|
+
selectedRows: [FIRST_PAGE_ROWS[1]],
|
|
216
|
+
getRowDisabled: (row) => row.id === '2' ? SELECTION_DISABLED : undefined,
|
|
217
|
+
});
|
|
218
|
+
await tests_1.userEvents.click(getSelectAllCheckbox());
|
|
219
|
+
(0, vitest_1.expect)(onSelectRowSpy).toHaveBeenCalledWith([
|
|
220
|
+
FIRST_PAGE_ROWS[1],
|
|
221
|
+
FIRST_PAGE_ROWS[0],
|
|
222
|
+
]);
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
(0, vitest_1.describe)('Снятие «Выбрать все»', () => {
|
|
226
|
+
(0, vitest_1.it)('Выбор строк других страниц сохраняется', async () => {
|
|
227
|
+
const { onSelectRowSpy } = setup({
|
|
228
|
+
selectedRows: [SECOND_PAGE_ROWS[0], ...FIRST_PAGE_ROWS],
|
|
229
|
+
});
|
|
230
|
+
await tests_1.userEvents.click(getSelectAllCheckbox());
|
|
231
|
+
(0, vitest_1.expect)(onSelectRowSpy).toHaveBeenCalledWith([SECOND_PAGE_ROWS[0]]);
|
|
232
|
+
});
|
|
233
|
+
(0, vitest_1.it)('Выбор строки с mode=selection снимается', async () => {
|
|
234
|
+
const { onSelectRowSpy } = setup({
|
|
235
|
+
selectedRows: FIRST_PAGE_ROWS,
|
|
236
|
+
getRowDisabled: (row) => row.id === '2' ? SELECTION_DISABLED : undefined,
|
|
237
|
+
});
|
|
238
|
+
await tests_1.userEvents.click(getSelectAllCheckbox());
|
|
239
|
+
(0, vitest_1.expect)(onSelectRowSpy).toHaveBeenCalledWith([]);
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
(0, vitest_1.describe)('Выбранная строка с mode=selection', () => {
|
|
243
|
+
const setupSelectedDisabledRow = () => setup({
|
|
244
|
+
selectedRows: [FIRST_PAGE_ROWS[1]],
|
|
245
|
+
getRowDisabled: (row) => row.id === '2' ? SELECTION_DISABLED : undefined,
|
|
246
|
+
});
|
|
247
|
+
(0, vitest_1.it)('Чекбокс строки отмечен', () => {
|
|
248
|
+
setupSelectedDisabledRow();
|
|
249
|
+
(0, vitest_1.expect)(getRowCheckbox('Договор №2')).toBeChecked();
|
|
250
|
+
});
|
|
251
|
+
(0, vitest_1.it)('Чекбокс строки заблокирован', () => {
|
|
252
|
+
setupSelectedDisabledRow();
|
|
253
|
+
(0, vitest_1.expect)(getRowCheckbox('Договор №2')).toBeDisabled();
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
(0, vitest_1.describe)('Блокировка через getRowDisabled', () => {
|
|
257
|
+
(0, vitest_1.it)('Чекбокс строки заблокирован при mode=selection', () => {
|
|
258
|
+
setup({
|
|
259
|
+
getRowDisabled: (row) => row.id === '1' ? SELECTION_DISABLED : undefined,
|
|
260
|
+
});
|
|
261
|
+
(0, vitest_1.expect)(getRowCheckbox('Договор №1')).toBeDisabled();
|
|
262
|
+
});
|
|
263
|
+
(0, vitest_1.it)('Чекбокс строки заблокирован при mode=row', () => {
|
|
264
|
+
setup({
|
|
265
|
+
getRowDisabled: (row) => (row.id === '1' ? ROW_DISABLED : undefined),
|
|
266
|
+
});
|
|
267
|
+
(0, vitest_1.expect)(getRowCheckbox('Договор №1')).toBeDisabled();
|
|
268
|
+
});
|
|
269
|
+
(0, vitest_1.it)('onSelectRow не вызывается при клике по checkbox с mode=selection', async () => {
|
|
270
|
+
const { onSelectRowSpy } = setup({
|
|
271
|
+
getRowDisabled: (row) => row.id === '1' ? SELECTION_DISABLED : undefined,
|
|
272
|
+
});
|
|
273
|
+
await tests_1.userEvents.click(getRowCheckbox('Договор №1'));
|
|
274
|
+
(0, vitest_1.expect)(onSelectRowSpy).not.toHaveBeenCalled();
|
|
275
|
+
});
|
|
276
|
+
(0, vitest_1.it)('onRowClick вызывается при клике по строке с mode=selection', async () => {
|
|
277
|
+
const onRowClickSpy = vitest_1.vi.fn();
|
|
278
|
+
setup({
|
|
279
|
+
onRowClick: onRowClickSpy,
|
|
280
|
+
getRowDisabled: (row) => row.id === '1' ? SELECTION_DISABLED : undefined,
|
|
281
|
+
});
|
|
282
|
+
await tests_1.userEvents.click(tests_1.screen.getByText('Договор №1'));
|
|
283
|
+
(0, vitest_1.expect)(onRowClickSpy).toHaveBeenCalledWith(FIRST_PAGE_ROWS[0]);
|
|
284
|
+
});
|
|
285
|
+
(0, vitest_1.it)('onRowClick не вызывается при клике по строке с mode=row', async () => {
|
|
286
|
+
const onRowClickSpy = vitest_1.vi.fn();
|
|
287
|
+
setup({
|
|
288
|
+
onRowClick: onRowClickSpy,
|
|
289
|
+
getRowDisabled: (row) => (row.id === '1' ? ROW_DISABLED : undefined),
|
|
290
|
+
});
|
|
291
|
+
await tests_1.userEvents.click(tests_1.screen.getByText('Договор №1'));
|
|
292
|
+
(0, vitest_1.expect)(onRowClickSpy).not.toHaveBeenCalled();
|
|
293
|
+
});
|
|
294
|
+
(0, vitest_1.it)('onRowClick вызывается при mode=selection и options.isDisabled=true', async () => {
|
|
295
|
+
const onRowClickSpy = vitest_1.vi.fn();
|
|
296
|
+
const row = {
|
|
297
|
+
...FIRST_PAGE_ROWS[0],
|
|
298
|
+
options: { isDisabled: true },
|
|
299
|
+
};
|
|
300
|
+
setup({
|
|
301
|
+
rows: [row],
|
|
302
|
+
onRowClick: onRowClickSpy,
|
|
303
|
+
getRowDisabled: () => SELECTION_DISABLED,
|
|
304
|
+
});
|
|
305
|
+
await tests_1.userEvents.click(tests_1.screen.getByText('Договор №1'));
|
|
306
|
+
(0, vitest_1.expect)(onRowClickSpy).toHaveBeenCalledWith(row);
|
|
307
|
+
});
|
|
308
|
+
vitest_1.it.each(INERT_BY_MODE_CASES)('Ячейки строки недоступны=$isInertCell при mode=$mode', ({ mode, isInertCell }) => {
|
|
309
|
+
setup({
|
|
310
|
+
columns: COLUMNS_WITH_ACTION,
|
|
311
|
+
getRowDisabled: (row) => row.id === '1' ? { mode, reason: 'Нет доступа' } : undefined,
|
|
312
|
+
});
|
|
313
|
+
(0, vitest_1.expect)(checkIsInert(tests_1.screen.getByText('Договор №1'))).toBe(isInertCell);
|
|
314
|
+
});
|
|
315
|
+
vitest_1.it.each(INERT_BY_MODE_CASES)('Последняя ячейка недоступна=$isInertLastCell при mode=$mode', ({ mode, isInertLastCell }) => {
|
|
316
|
+
setup({
|
|
317
|
+
columns: COLUMNS_WITH_ACTION,
|
|
318
|
+
getRowDisabled: (row) => row.id === '1' ? { mode, reason: 'Нет доступа' } : undefined,
|
|
319
|
+
});
|
|
320
|
+
(0, vitest_1.expect)(checkIsInert(getActionButton('Договор №1'))).toBe(isInertLastCell);
|
|
321
|
+
});
|
|
322
|
+
(0, vitest_1.it)('Ячейки соседней строки доступны при mode=row', () => {
|
|
323
|
+
setup({
|
|
324
|
+
columns: COLUMNS_WITH_ACTION,
|
|
325
|
+
getRowDisabled: (row) => (row.id === '1' ? ROW_DISABLED : undefined),
|
|
326
|
+
});
|
|
327
|
+
(0, vitest_1.expect)(checkIsInert(tests_1.screen.getByText('Договор №2'))).toBe(false);
|
|
328
|
+
});
|
|
329
|
+
(0, vitest_1.it)('Tooltip строки показывает причину при mode=row', async () => {
|
|
330
|
+
setup({
|
|
331
|
+
getRowDisabled: (row) => (row.id === '1' ? ROW_DISABLED : undefined),
|
|
332
|
+
});
|
|
333
|
+
await tests_1.userEvents.hover(getRowContent('Договор №1'));
|
|
334
|
+
(0, vitest_1.expect)(await tests_1.screen.findByRole('tooltip')).toHaveTextContent(ROW_DISABLED.reason);
|
|
335
|
+
});
|
|
336
|
+
(0, vitest_1.it)('Чекбокс строки с options.isDisabled=true заблокирован, если getRowDisabled её не блокирует', () => {
|
|
337
|
+
setup({
|
|
338
|
+
rows: [{ ...FIRST_PAGE_ROWS[0], options: { isDisabled: true } }],
|
|
339
|
+
getRowDisabled: () => undefined,
|
|
340
|
+
});
|
|
341
|
+
(0, vitest_1.expect)(getRowCheckbox('Договор №1')).toBeDisabled();
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
(0, vitest_1.describe)('Блокировка через options без getRowDisabled', () => {
|
|
345
|
+
(0, vitest_1.it)('Чекбокс строки заблокирован при options.isDisabled=true', () => {
|
|
346
|
+
setup({
|
|
347
|
+
rows: [{ ...FIRST_PAGE_ROWS[0], options: { isDisabled: true } }],
|
|
348
|
+
});
|
|
349
|
+
(0, vitest_1.expect)(getRowCheckbox('Договор №1')).toBeDisabled();
|
|
350
|
+
});
|
|
351
|
+
(0, vitest_1.it)('Ячейки строки, кроме последней, недоступны при options.isDisabledLastCell=false', () => {
|
|
352
|
+
setup({
|
|
353
|
+
columns: COLUMNS_WITH_ACTION,
|
|
354
|
+
rows: [
|
|
355
|
+
{
|
|
356
|
+
...FIRST_PAGE_ROWS[0],
|
|
357
|
+
options: { isDisabled: true, isDisabledLastCell: false },
|
|
358
|
+
},
|
|
359
|
+
],
|
|
360
|
+
});
|
|
361
|
+
(0, vitest_1.expect)(checkIsInert(tests_1.screen.getByText('Договор №1'))).toBe(true);
|
|
362
|
+
});
|
|
363
|
+
(0, vitest_1.it)('Tooltip строки показывает options.disabledReason', async () => {
|
|
364
|
+
setup({
|
|
365
|
+
rows: [
|
|
366
|
+
{
|
|
367
|
+
...FIRST_PAGE_ROWS[0],
|
|
368
|
+
options: { isDisabled: true, disabledReason: 'Нет доступа' },
|
|
369
|
+
},
|
|
370
|
+
],
|
|
371
|
+
});
|
|
372
|
+
await tests_1.userEvents.hover(getRowContent('Договор №1'));
|
|
373
|
+
(0, vitest_1.expect)(await tests_1.screen.findByRole('tooltip')).toHaveTextContent('Нет доступа');
|
|
374
|
+
});
|
|
375
|
+
(0, vitest_1.it)('onSelectRow не вызывается при клике по checkbox строки с options.isDisabled=true', async () => {
|
|
376
|
+
const { onSelectRowSpy } = setup({
|
|
377
|
+
rows: [{ ...FIRST_PAGE_ROWS[0], options: { isDisabled: true } }],
|
|
378
|
+
});
|
|
379
|
+
await tests_1.userEvents.click(getRowCheckbox('Договор №1'));
|
|
380
|
+
(0, vitest_1.expect)(onSelectRowSpy).not.toHaveBeenCalled();
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
(0, vitest_1.describe)('Блокировка без причины', () => {
|
|
384
|
+
const WARN_MESSAGE_PREFIX = 'UIKIT. DataGrid: getRowDisabled вернул блокировку без reason для строк: ';
|
|
385
|
+
let consoleWarnSpy;
|
|
386
|
+
(0, vitest_1.beforeEach)(() => {
|
|
387
|
+
consoleWarnSpy = vitest_1.vi.spyOn(console, 'warn').mockImplementation(() => { });
|
|
388
|
+
});
|
|
389
|
+
(0, vitest_1.afterEach)(() => {
|
|
390
|
+
consoleWarnSpy.mockRestore();
|
|
391
|
+
});
|
|
392
|
+
(0, vitest_1.it)('Выводится одно предупреждение со всеми строками без причины', () => {
|
|
393
|
+
setup({ getRowDisabled: () => SELECTION_DISABLED_WITHOUT_REASON });
|
|
394
|
+
(0, vitest_1.expect)(consoleWarnSpy.mock.calls).toEqual([
|
|
395
|
+
[`${WARN_MESSAGE_PREFIX}1, 2`],
|
|
396
|
+
]);
|
|
397
|
+
});
|
|
398
|
+
(0, vitest_1.it)('Не выводится повторно при новой функции getRowDisabled с тем же результатом', () => {
|
|
399
|
+
const { rerenderGrid } = setup({
|
|
400
|
+
getRowDisabled: () => ROW_DISABLED_WITHOUT_REASON,
|
|
401
|
+
});
|
|
402
|
+
rerenderGrid({ getRowDisabled: () => ROW_DISABLED_WITHOUT_REASON });
|
|
403
|
+
(0, vitest_1.expect)(consoleWarnSpy).toHaveBeenCalledTimes(1);
|
|
404
|
+
});
|
|
405
|
+
(0, vitest_1.it)('Выводится только для строк без причины, появившихся позже', () => {
|
|
406
|
+
const getRowDisabled = () => SELECTION_DISABLED_WITHOUT_REASON;
|
|
407
|
+
const { rerenderGrid } = setup({ getRowDisabled });
|
|
408
|
+
rerenderGrid({
|
|
409
|
+
rows: [...FIRST_PAGE_ROWS, ...SECOND_PAGE_ROWS],
|
|
410
|
+
getRowDisabled,
|
|
411
|
+
});
|
|
412
|
+
(0, vitest_1.expect)(consoleWarnSpy.mock.calls).toEqual([
|
|
413
|
+
[`${WARN_MESSAGE_PREFIX}1, 2`],
|
|
414
|
+
[`${WARN_MESSAGE_PREFIX}3, 4`],
|
|
415
|
+
]);
|
|
416
|
+
});
|
|
417
|
+
(0, vitest_1.it)('Не выводится для options.isDisabled=true без disabledReason', () => {
|
|
418
|
+
setup({
|
|
419
|
+
rows: [{ ...FIRST_PAGE_ROWS[0], options: { isDisabled: true } }],
|
|
420
|
+
});
|
|
421
|
+
(0, vitest_1.expect)(consoleWarnSpy).not.toHaveBeenCalled();
|
|
422
|
+
});
|
|
423
|
+
(0, vitest_1.it)('Не выводится при mode=selection с reason', () => {
|
|
424
|
+
setup({ getRowDisabled: () => SELECTION_DISABLED });
|
|
425
|
+
(0, vitest_1.expect)(consoleWarnSpy).not.toHaveBeenCalled();
|
|
426
|
+
});
|
|
427
|
+
(0, vitest_1.it)('Tooltip не отображается при наведении на строку с mode=row без причины', async () => {
|
|
428
|
+
setup({
|
|
429
|
+
getRowDisabled: (row) => row.id === '1' ? ROW_DISABLED_WITHOUT_REASON : undefined,
|
|
430
|
+
});
|
|
431
|
+
await tests_1.userEvents.hover(tests_1.screen.getByText('Договор №1'));
|
|
432
|
+
(0, vitest_1.expect)(tests_1.screen.queryByRole('tooltip')).not.toBeInTheDocument();
|
|
433
|
+
});
|
|
434
|
+
});
|
|
435
|
+
(0, vitest_1.describe)('Tooltip причины блокировки выбора', () => {
|
|
436
|
+
const user = tests_1.userEvents.setup({
|
|
437
|
+
advanceTimers: vitest_1.vi.advanceTimersByTime.bind(vitest_1.vi),
|
|
438
|
+
});
|
|
439
|
+
const TOOLTIP_CONTAINER_SELECTOR = `.${Tooltip_1.tooltipClassnames.contentWrapper}`;
|
|
440
|
+
const getCheckboxTooltipContainer = (name) => {
|
|
441
|
+
const container = getRowCheckbox(name).closest(TOOLTIP_CONTAINER_SELECTOR);
|
|
442
|
+
if (!container) {
|
|
443
|
+
throw new Error(`Контейнер tooltip checkbox строки «${name}» не найден`);
|
|
444
|
+
}
|
|
445
|
+
return container;
|
|
446
|
+
};
|
|
447
|
+
const advanceTime = (ms) => (0, react_1.act)(() => {
|
|
448
|
+
vitest_1.vi.advanceTimersByTime(ms);
|
|
449
|
+
});
|
|
450
|
+
const setupSelectionDisabledRow = () => setup({
|
|
451
|
+
getRowDisabled: (row) => row.id === '1' ? SELECTION_DISABLED : undefined,
|
|
452
|
+
});
|
|
453
|
+
// shouldAdvanceTime: асинхронная обёртка RTL ждёт setTimeout и без него зависает
|
|
454
|
+
(0, vitest_1.beforeEach)(() => {
|
|
455
|
+
vitest_1.vi.useFakeTimers({ shouldAdvanceTime: true });
|
|
456
|
+
});
|
|
457
|
+
(0, vitest_1.afterEach)(() => {
|
|
458
|
+
vitest_1.vi.useRealTimers();
|
|
459
|
+
});
|
|
460
|
+
(0, vitest_1.it)('Отображается через 300ms после наведения на checkbox с mode=selection', async () => {
|
|
461
|
+
setupSelectionDisabledRow();
|
|
462
|
+
await user.hover(getCheckboxTooltipContainer('Договор №1'));
|
|
463
|
+
advanceTime(300);
|
|
464
|
+
(0, vitest_1.expect)(tests_1.screen.getByRole('tooltip')).toHaveTextContent(SELECTION_DISABLED.reason);
|
|
465
|
+
});
|
|
466
|
+
(0, vitest_1.it)('Не отображается раньше 300ms после наведения', async () => {
|
|
467
|
+
setupSelectionDisabledRow();
|
|
468
|
+
await user.hover(getCheckboxTooltipContainer('Договор №1'));
|
|
469
|
+
advanceTime(250);
|
|
470
|
+
(0, vitest_1.expect)(tests_1.screen.queryByRole('tooltip')).not.toBeInTheDocument();
|
|
471
|
+
});
|
|
472
|
+
(0, vitest_1.it)('Не отображается, если курсор ушёл с checkbox раньше 300ms', async () => {
|
|
473
|
+
setupSelectionDisabledRow();
|
|
474
|
+
await user.hover(getCheckboxTooltipContainer('Договор №1'));
|
|
475
|
+
advanceTime(150);
|
|
476
|
+
await user.unhover(getCheckboxTooltipContainer('Договор №1'));
|
|
477
|
+
advanceTime(300);
|
|
478
|
+
(0, vitest_1.expect)(tests_1.screen.queryByRole('tooltip')).not.toBeInTheDocument();
|
|
479
|
+
});
|
|
480
|
+
(0, vitest_1.it)('Checkbox строки с mode=row не показывает собственную причину', () => {
|
|
481
|
+
setup({
|
|
482
|
+
getRowDisabled: (row) => (row.id === '1' ? ROW_DISABLED : undefined),
|
|
483
|
+
});
|
|
484
|
+
(0, vitest_1.expect)(getRowCheckbox('Договор №1').closest(TOOLTIP_CONTAINER_SELECTOR)).not.toBeInTheDocument();
|
|
485
|
+
});
|
|
486
|
+
});
|
|
487
|
+
(0, vitest_1.describe)('Вложенные строки', () => {
|
|
488
|
+
(0, vitest_1.it)('Чекбокс вложенной строки заблокирован при mode=selection для неё', () => {
|
|
489
|
+
setup({
|
|
490
|
+
rows: NESTED_ROWS,
|
|
491
|
+
tree: { isInitialExpanded: true },
|
|
492
|
+
getRowDisabled: (row) => row.id === '1-1' ? SELECTION_DISABLED : undefined,
|
|
493
|
+
});
|
|
494
|
+
(0, vitest_1.expect)(getRowCheckbox('Вложенный договор')).toBeDisabled();
|
|
495
|
+
});
|
|
496
|
+
(0, vitest_1.it)('Чекбокс вложенной строки доступен при mode=row у родителя', () => {
|
|
497
|
+
setup({
|
|
498
|
+
rows: NESTED_ROWS,
|
|
499
|
+
tree: { isInitialExpanded: true },
|
|
500
|
+
getRowDisabled: (row) => (row.id === '1' ? ROW_DISABLED : undefined),
|
|
501
|
+
});
|
|
502
|
+
(0, vitest_1.expect)(getRowCheckbox('Вложенный договор')).toBeEnabled();
|
|
503
|
+
});
|
|
504
|
+
(0, vitest_1.it)('Чекбокс вложенной строки заблокирован при variant=subrows и mode=selection', () => {
|
|
505
|
+
setup({
|
|
506
|
+
rows: NESTED_ROWS,
|
|
507
|
+
variant: 'subrows',
|
|
508
|
+
getRowDisabled: (row) => row.id === '1-1' ? SELECTION_DISABLED : undefined,
|
|
509
|
+
});
|
|
510
|
+
(0, vitest_1.expect)(getRowCheckbox('Вложенный договор')).toBeDisabled();
|
|
511
|
+
});
|
|
512
|
+
(0, vitest_1.describe)('mode=row у вложенной строки', () => {
|
|
513
|
+
const setupNestedRowDisabled = () => setup({
|
|
514
|
+
rows: NESTED_ROWS,
|
|
515
|
+
tree: { isInitialExpanded: true },
|
|
516
|
+
getRowDisabled: (row) => row.id === '1-1' ? ROW_DISABLED : undefined,
|
|
517
|
+
});
|
|
518
|
+
(0, vitest_1.it)('Ячейки вложенной строки недоступны', () => {
|
|
519
|
+
setupNestedRowDisabled();
|
|
520
|
+
(0, vitest_1.expect)(checkIsInert(tests_1.screen.getByText('Вложенный договор'))).toBe(true);
|
|
521
|
+
});
|
|
522
|
+
(0, vitest_1.it)('Ячейки родительской строки доступны', () => {
|
|
523
|
+
setupNestedRowDisabled();
|
|
524
|
+
(0, vitest_1.expect)(checkIsInert(tests_1.screen.getByText('Пакет документов'))).toBe(false);
|
|
525
|
+
});
|
|
526
|
+
});
|
|
527
|
+
(0, vitest_1.describe)('options.isDisabled=true у вложенной строки', () => {
|
|
528
|
+
const NESTED_ROWS_WITH_DISABLED_CHILD = [
|
|
529
|
+
{
|
|
530
|
+
...NESTED_ROWS[0],
|
|
531
|
+
children: [
|
|
532
|
+
{
|
|
533
|
+
id: '1-1',
|
|
534
|
+
name: 'Вложенный договор',
|
|
535
|
+
options: { isDisabled: true },
|
|
536
|
+
},
|
|
537
|
+
],
|
|
538
|
+
},
|
|
539
|
+
];
|
|
540
|
+
(0, vitest_1.it)('Чекбокс вложенной строки заблокирован без getRowDisabled', () => {
|
|
541
|
+
setup({
|
|
542
|
+
rows: NESTED_ROWS_WITH_DISABLED_CHILD,
|
|
543
|
+
tree: { isInitialExpanded: true },
|
|
544
|
+
});
|
|
545
|
+
(0, vitest_1.expect)(getRowCheckbox('Вложенный договор')).toBeDisabled();
|
|
546
|
+
});
|
|
547
|
+
(0, vitest_1.it)('Чекбокс вложенной строки заблокирован, если getRowDisabled её не блокирует', () => {
|
|
548
|
+
setup({
|
|
549
|
+
rows: NESTED_ROWS_WITH_DISABLED_CHILD,
|
|
550
|
+
tree: { isInitialExpanded: true },
|
|
551
|
+
getRowDisabled: () => undefined,
|
|
552
|
+
});
|
|
553
|
+
(0, vitest_1.expect)(getRowCheckbox('Вложенный договор')).toBeDisabled();
|
|
554
|
+
});
|
|
555
|
+
(0, vitest_1.it)('Ячейки вложенной строки доступны при mode=selection из getRowDisabled', () => {
|
|
556
|
+
setup({
|
|
557
|
+
rows: NESTED_ROWS_WITH_DISABLED_CHILD,
|
|
558
|
+
tree: { isInitialExpanded: true },
|
|
559
|
+
getRowDisabled: (row) => row.id === '1-1' ? SELECTION_DISABLED : undefined,
|
|
560
|
+
});
|
|
561
|
+
(0, vitest_1.expect)(checkIsInert(tests_1.screen.getByText('Вложенный договор'))).toBe(false);
|
|
562
|
+
});
|
|
563
|
+
});
|
|
564
|
+
});
|
|
565
|
+
};
|
|
566
|
+
exports.testDataGridSelection = testDataGridSelection;
|
|
@@ -46,6 +46,11 @@ export type DataGridProps<TData extends Record<string, CellValue> = DataGridRow,
|
|
|
46
46
|
* Компонент кастомного футера (например Pagination)
|
|
47
47
|
*/
|
|
48
48
|
footer?: ReactNode;
|
|
49
|
+
/**
|
|
50
|
+
* Панель массовых действий над выбранными строками
|
|
51
|
+
* @example <DataGrid massActions={<DataGridMassActions />} />
|
|
52
|
+
*/
|
|
53
|
+
massActions?: ReactNode;
|
|
49
54
|
/**
|
|
50
55
|
* Используется для отображения placeholder при отсутствии данных в таблице
|
|
51
56
|
*/
|
|
@@ -149,6 +154,23 @@ export type DataGridProps<TData extends Record<string, CellValue> = DataGridRow,
|
|
|
149
154
|
* Обработчик выбора строки
|
|
150
155
|
*/
|
|
151
156
|
onSelectRow?: (row: TData[]) => void;
|
|
157
|
+
/**
|
|
158
|
+
* Возвращает блокировку строки { mode, reason }
|
|
159
|
+
* @example
|
|
160
|
+
* const getRowDisabled = useCallback(
|
|
161
|
+
* (row: Document): DataGridRowDisabled | undefined => {
|
|
162
|
+
* if (row.status === 'Отправлен') {
|
|
163
|
+
* return { mode: 'selection', reason: 'Документ уже отправлен получателю' };
|
|
164
|
+
* }
|
|
165
|
+
*
|
|
166
|
+
* return undefined;
|
|
167
|
+
* },
|
|
168
|
+
* [],
|
|
169
|
+
* );
|
|
170
|
+
*
|
|
171
|
+
* <DataGrid getRowDisabled={getRowDisabled} />
|
|
172
|
+
*/
|
|
173
|
+
getRowDisabled?: (row: TData) => DataGridRowDisabled | undefined;
|
|
152
174
|
/**
|
|
153
175
|
* @example <DataGrid onSort={({fieldId: 'test', sort: 'asc'}) => console.log('sorted')} />
|
|
154
176
|
* Обработчик сортировки
|
|
@@ -313,14 +335,29 @@ export type DataGridRowOptionColumns<TData extends Record<string, CellValue>> =
|
|
|
313
335
|
*/
|
|
314
336
|
renderCell?: RenderCell<TData>;
|
|
315
337
|
};
|
|
338
|
+
/**
|
|
339
|
+
* Состояние блокировки строки
|
|
340
|
+
*/
|
|
341
|
+
export type DataGridRowDisabled = {
|
|
342
|
+
/**
|
|
343
|
+
* Тип блокировки
|
|
344
|
+
*/
|
|
345
|
+
mode: 'selection' | 'row' | 'row-except-last-cell';
|
|
346
|
+
/**
|
|
347
|
+
* Причина блокировки
|
|
348
|
+
*/
|
|
349
|
+
reason: string;
|
|
350
|
+
};
|
|
316
351
|
export type DataGridRowOptions<TData extends Record<string, CellValue>> = {
|
|
317
352
|
/**
|
|
318
353
|
* Если true, строка будет недоступна для взаимодействия
|
|
354
|
+
* @deprecated Используйте `getRowDisabled` с `mode: 'row'`.
|
|
319
355
|
*/
|
|
320
356
|
isDisabled?: boolean;
|
|
321
357
|
/**
|
|
322
|
-
* Если
|
|
358
|
+
* Если false, последняя ячейка не блокируется при `isDisabled=true`
|
|
323
359
|
* @default 'true'
|
|
360
|
+
* @deprecated Используйте `getRowDisabled` с `mode: 'row-except-last-cell'`.
|
|
324
361
|
*/
|
|
325
362
|
isDisabledLastCell?: boolean;
|
|
326
363
|
/**
|
|
@@ -329,6 +366,7 @@ export type DataGridRowOptions<TData extends Record<string, CellValue>> = {
|
|
|
329
366
|
isNotSelectable?: boolean;
|
|
330
367
|
/**
|
|
331
368
|
* Причина блокировки строки
|
|
369
|
+
* @deprecated Используйте `reason` в `getRowDisabled`.
|
|
332
370
|
*/
|
|
333
371
|
disabledReason?: string;
|
|
334
372
|
/**
|
|
@@ -367,4 +405,6 @@ export type DataGridRowWithOptions<TData extends DataGridRow> = TData & {
|
|
|
367
405
|
children?: DataGridRowWithOptions<TData>[];
|
|
368
406
|
};
|
|
369
407
|
export type ContextOnRowClick = (row: Record<string, unknown>) => void;
|
|
408
|
+
export type ContextSelectedRows = Record<string, unknown>[];
|
|
409
|
+
export type ContextOnChangeSelectedRows = (rows: ContextSelectedRows) => void;
|
|
370
410
|
export type RenderRow = (row: Record<string, unknown>, index: number) => ReactNode;
|