@cloud-ru/ds-toolbar 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/LICENSE +201 -0
- package/README.md +301 -0
- package/dist/cjs/components/Toolbar/Toolbar.d.ts +3 -0
- package/dist/cjs/components/Toolbar/Toolbar.js +51 -0
- package/dist/cjs/components/Toolbar/helpers.d.ts +12 -0
- package/dist/cjs/components/Toolbar/helpers.js +27 -0
- package/dist/cjs/components/Toolbar/hooks/index.d.ts +2 -0
- package/dist/cjs/components/Toolbar/hooks/index.js +18 -0
- package/dist/cjs/components/Toolbar/hooks/useFilters.d.ts +12 -0
- package/dist/cjs/components/Toolbar/hooks/useFilters.js +55 -0
- package/dist/cjs/components/Toolbar/hooks/usePersistState/index.d.ts +1 -0
- package/dist/cjs/components/Toolbar/hooks/usePersistState/index.js +17 -0
- package/dist/cjs/components/Toolbar/hooks/usePersistState/usePersistState.d.ts +9 -0
- package/dist/cjs/components/Toolbar/hooks/usePersistState/usePersistState.js +72 -0
- package/dist/cjs/components/Toolbar/hooks/usePersistState/utils/index.d.ts +3 -0
- package/dist/cjs/components/Toolbar/hooks/usePersistState/utils/index.js +19 -0
- package/dist/cjs/components/Toolbar/hooks/usePersistState/utils/isDateString.d.ts +9 -0
- package/dist/cjs/components/Toolbar/hooks/usePersistState/utils/isDateString.js +45 -0
- package/dist/cjs/components/Toolbar/hooks/usePersistState/utils/parser.d.ts +4 -0
- package/dist/cjs/components/Toolbar/hooks/usePersistState/utils/parser.js +46 -0
- package/dist/cjs/components/Toolbar/hooks/usePersistState/utils/serializer.d.ts +11 -0
- package/dist/cjs/components/Toolbar/hooks/usePersistState/utils/serializer.js +41 -0
- package/dist/cjs/components/Toolbar/index.d.ts +3 -0
- package/dist/cjs/components/Toolbar/index.js +19 -0
- package/dist/cjs/components/Toolbar/styles.module.css +297 -0
- package/dist/cjs/components/Toolbar/types.d.ts +80 -0
- package/dist/cjs/components/Toolbar/types.js +2 -0
- package/dist/cjs/components/Toolbar/typesUtils.d.ts +12 -0
- package/dist/cjs/components/Toolbar/typesUtils.js +2 -0
- package/dist/cjs/components/Toolbar/utils/buildMobileOverflowActions.d.ts +10 -0
- package/dist/cjs/components/Toolbar/utils/buildMobileOverflowActions.js +84 -0
- package/dist/cjs/components/Toolbar/utils/toolbarAfterOverflow.d.ts +2 -0
- package/dist/cjs/components/Toolbar/utils/toolbarAfterOverflow.js +5 -0
- package/dist/cjs/components/index.d.ts +4 -0
- package/dist/cjs/components/index.js +23 -0
- package/dist/cjs/helperComponents/BulkActions/BulkActions.d.ts +2 -0
- package/dist/cjs/helperComponents/BulkActions/BulkActions.js +20 -0
- package/dist/cjs/helperComponents/BulkActions/components/BulkActionsCheckbox/BulkActionsCheckbox.d.ts +8 -0
- package/dist/cjs/helperComponents/BulkActions/components/BulkActionsCheckbox/BulkActionsCheckbox.js +20 -0
- package/dist/cjs/helperComponents/BulkActions/components/BulkActionsCheckbox/index.d.ts +1 -0
- package/dist/cjs/helperComponents/BulkActions/components/BulkActionsCheckbox/index.js +17 -0
- package/dist/cjs/helperComponents/BulkActions/components/BulkActionsCheckbox/styles.module.css +3 -0
- package/dist/cjs/helperComponents/BulkActions/components/BulkActionsControls/BulkActionsControls.d.ts +17 -0
- package/dist/cjs/helperComponents/BulkActions/components/BulkActionsControls/BulkActionsControls.js +39 -0
- package/dist/cjs/helperComponents/BulkActions/components/BulkActionsControls/index.d.ts +1 -0
- package/dist/cjs/helperComponents/BulkActions/components/BulkActionsControls/index.js +17 -0
- package/dist/cjs/helperComponents/BulkActions/components/BulkActionsControls/styles.module.css +39 -0
- package/dist/cjs/helperComponents/BulkActions/components/MobileBulkActionsSheet/MobileBulkActionsSheet.d.ts +14 -0
- package/dist/cjs/helperComponents/BulkActions/components/MobileBulkActionsSheet/MobileBulkActionsSheet.js +27 -0
- package/dist/cjs/helperComponents/BulkActions/components/MobileBulkActionsSheet/index.d.ts +1 -0
- package/dist/cjs/helperComponents/BulkActions/components/MobileBulkActionsSheet/index.js +17 -0
- package/dist/cjs/helperComponents/BulkActions/components/SelectionLabel/SelectionLabel.d.ts +9 -0
- package/dist/cjs/helperComponents/BulkActions/components/SelectionLabel/SelectionLabel.js +21 -0
- package/dist/cjs/helperComponents/BulkActions/components/SelectionLabel/index.d.ts +1 -0
- package/dist/cjs/helperComponents/BulkActions/components/SelectionLabel/index.js +17 -0
- package/dist/cjs/helperComponents/BulkActions/components/SelectionLabel/styles.module.css +40 -0
- package/dist/cjs/helperComponents/BulkActions/components/index.d.ts +4 -0
- package/dist/cjs/helperComponents/BulkActions/components/index.js +20 -0
- package/dist/cjs/helperComponents/BulkActions/index.d.ts +2 -0
- package/dist/cjs/helperComponents/BulkActions/index.js +18 -0
- package/dist/cjs/helperComponents/BulkActions/styles.module.css +9 -0
- package/dist/cjs/helperComponents/BulkActions/types.d.ts +31 -0
- package/dist/cjs/helperComponents/BulkActions/types.js +2 -0
- package/dist/cjs/helperComponents/BulkActions/utils.d.ts +15 -0
- package/dist/cjs/helperComponents/BulkActions/utils.js +26 -0
- package/dist/cjs/helperComponents/DataView/DataView.d.ts +2 -0
- package/dist/cjs/helperComponents/DataView/DataView.js +9 -0
- package/dist/cjs/helperComponents/DataView/constants.d.ts +9 -0
- package/dist/cjs/helperComponents/DataView/constants.js +13 -0
- package/dist/cjs/helperComponents/DataView/index.d.ts +3 -0
- package/dist/cjs/helperComponents/DataView/index.js +19 -0
- package/dist/cjs/helperComponents/DataView/types.d.ts +12 -0
- package/dist/cjs/helperComponents/DataView/types.js +2 -0
- package/dist/cjs/helperComponents/FilterButton/FilterButton.d.ts +12 -0
- package/dist/cjs/helperComponents/FilterButton/FilterButton.js +17 -0
- package/dist/cjs/helperComponents/FilterButton/index.d.ts +1 -0
- package/dist/cjs/helperComponents/FilterButton/index.js +17 -0
- package/dist/cjs/helperComponents/FilterButton/styles.module.css +5 -0
- package/dist/cjs/helperComponents/MoreActions/MoreActions.d.ts +13 -0
- package/dist/cjs/helperComponents/MoreActions/MoreActions.js +35 -0
- package/dist/cjs/helperComponents/MoreActions/index.d.ts +1 -0
- package/dist/cjs/helperComponents/MoreActions/index.js +17 -0
- package/dist/cjs/helperComponents/MoreActions/styles.module.css +5 -0
- package/dist/cjs/helperComponents/Search/ToolbarSearch.d.ts +9 -0
- package/dist/cjs/helperComponents/Search/ToolbarSearch.js +19 -0
- package/dist/cjs/helperComponents/Search/index.d.ts +1 -0
- package/dist/cjs/helperComponents/Search/index.js +17 -0
- package/dist/cjs/helperComponents/Search/styles.module.css +25 -0
- package/dist/cjs/helperComponents/Separator/Separator.d.ts +1 -0
- package/dist/cjs/helperComponents/Separator/Separator.js +11 -0
- package/dist/cjs/helperComponents/Separator/index.d.ts +1 -0
- package/dist/cjs/helperComponents/Separator/index.js +17 -0
- package/dist/cjs/helperComponents/Separator/styles.module.css +14 -0
- package/dist/cjs/helperComponents/index.d.ts +6 -0
- package/dist/cjs/helperComponents/index.js +22 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.js +24 -0
- package/dist/cjs/locale/index.d.ts +55 -0
- package/dist/cjs/locale/index.js +32 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/style.css +437 -0
- package/dist/cjs/testIds.d.ts +24 -0
- package/dist/cjs/testIds.js +27 -0
- package/dist/esm/components/Toolbar/Toolbar.d.ts +3 -0
- package/dist/esm/components/Toolbar/Toolbar.js +45 -0
- package/dist/esm/components/Toolbar/helpers.d.ts +12 -0
- package/dist/esm/components/Toolbar/helpers.js +23 -0
- package/dist/esm/components/Toolbar/hooks/index.d.ts +2 -0
- package/dist/esm/components/Toolbar/hooks/index.js +2 -0
- package/dist/esm/components/Toolbar/hooks/useFilters.d.ts +12 -0
- package/dist/esm/components/Toolbar/hooks/useFilters.js +49 -0
- package/dist/esm/components/Toolbar/hooks/usePersistState/index.d.ts +1 -0
- package/dist/esm/components/Toolbar/hooks/usePersistState/index.js +1 -0
- package/dist/esm/components/Toolbar/hooks/usePersistState/usePersistState.d.ts +9 -0
- package/dist/esm/components/Toolbar/hooks/usePersistState/usePersistState.js +69 -0
- package/dist/esm/components/Toolbar/hooks/usePersistState/utils/index.d.ts +3 -0
- package/dist/esm/components/Toolbar/hooks/usePersistState/utils/index.js +3 -0
- package/dist/esm/components/Toolbar/hooks/usePersistState/utils/isDateString.d.ts +9 -0
- package/dist/esm/components/Toolbar/hooks/usePersistState/utils/isDateString.js +42 -0
- package/dist/esm/components/Toolbar/hooks/usePersistState/utils/parser.d.ts +4 -0
- package/dist/esm/components/Toolbar/hooks/usePersistState/utils/parser.js +42 -0
- package/dist/esm/components/Toolbar/hooks/usePersistState/utils/serializer.d.ts +11 -0
- package/dist/esm/components/Toolbar/hooks/usePersistState/utils/serializer.js +37 -0
- package/dist/esm/components/Toolbar/index.d.ts +3 -0
- package/dist/esm/components/Toolbar/index.js +3 -0
- package/dist/esm/components/Toolbar/styles.module.css +297 -0
- package/dist/esm/components/Toolbar/types.d.ts +80 -0
- package/dist/esm/components/Toolbar/types.js +1 -0
- package/dist/esm/components/Toolbar/typesUtils.d.ts +12 -0
- package/dist/esm/components/Toolbar/typesUtils.js +1 -0
- package/dist/esm/components/Toolbar/utils/buildMobileOverflowActions.d.ts +10 -0
- package/dist/esm/components/Toolbar/utils/buildMobileOverflowActions.js +81 -0
- package/dist/esm/components/Toolbar/utils/toolbarAfterOverflow.d.ts +2 -0
- package/dist/esm/components/Toolbar/utils/toolbarAfterOverflow.js +2 -0
- package/dist/esm/components/index.d.ts +4 -0
- package/dist/esm/components/index.js +3 -0
- package/dist/esm/helperComponents/BulkActions/BulkActions.d.ts +2 -0
- package/dist/esm/helperComponents/BulkActions/BulkActions.js +14 -0
- package/dist/esm/helperComponents/BulkActions/components/BulkActionsCheckbox/BulkActionsCheckbox.d.ts +8 -0
- package/dist/esm/helperComponents/BulkActions/components/BulkActionsCheckbox/BulkActionsCheckbox.js +14 -0
- package/dist/esm/helperComponents/BulkActions/components/BulkActionsCheckbox/index.d.ts +1 -0
- package/dist/esm/helperComponents/BulkActions/components/BulkActionsCheckbox/index.js +1 -0
- package/dist/esm/helperComponents/BulkActions/components/BulkActionsCheckbox/styles.module.css +3 -0
- package/dist/esm/helperComponents/BulkActions/components/BulkActionsControls/BulkActionsControls.d.ts +17 -0
- package/dist/esm/helperComponents/BulkActions/components/BulkActionsControls/BulkActionsControls.js +33 -0
- package/dist/esm/helperComponents/BulkActions/components/BulkActionsControls/index.d.ts +1 -0
- package/dist/esm/helperComponents/BulkActions/components/BulkActionsControls/index.js +1 -0
- package/dist/esm/helperComponents/BulkActions/components/BulkActionsControls/styles.module.css +39 -0
- package/dist/esm/helperComponents/BulkActions/components/MobileBulkActionsSheet/MobileBulkActionsSheet.d.ts +14 -0
- package/dist/esm/helperComponents/BulkActions/components/MobileBulkActionsSheet/MobileBulkActionsSheet.js +24 -0
- package/dist/esm/helperComponents/BulkActions/components/MobileBulkActionsSheet/index.d.ts +1 -0
- package/dist/esm/helperComponents/BulkActions/components/MobileBulkActionsSheet/index.js +1 -0
- package/dist/esm/helperComponents/BulkActions/components/SelectionLabel/SelectionLabel.d.ts +9 -0
- package/dist/esm/helperComponents/BulkActions/components/SelectionLabel/SelectionLabel.js +15 -0
- package/dist/esm/helperComponents/BulkActions/components/SelectionLabel/index.d.ts +1 -0
- package/dist/esm/helperComponents/BulkActions/components/SelectionLabel/index.js +1 -0
- package/dist/esm/helperComponents/BulkActions/components/SelectionLabel/styles.module.css +40 -0
- package/dist/esm/helperComponents/BulkActions/components/index.d.ts +4 -0
- package/dist/esm/helperComponents/BulkActions/components/index.js +4 -0
- package/dist/esm/helperComponents/BulkActions/index.d.ts +2 -0
- package/dist/esm/helperComponents/BulkActions/index.js +2 -0
- package/dist/esm/helperComponents/BulkActions/styles.module.css +9 -0
- package/dist/esm/helperComponents/BulkActions/types.d.ts +31 -0
- package/dist/esm/helperComponents/BulkActions/types.js +1 -0
- package/dist/esm/helperComponents/BulkActions/utils.d.ts +15 -0
- package/dist/esm/helperComponents/BulkActions/utils.js +21 -0
- package/dist/esm/helperComponents/DataView/DataView.d.ts +2 -0
- package/dist/esm/helperComponents/DataView/DataView.js +6 -0
- package/dist/esm/helperComponents/DataView/constants.d.ts +9 -0
- package/dist/esm/helperComponents/DataView/constants.js +10 -0
- package/dist/esm/helperComponents/DataView/index.d.ts +3 -0
- package/dist/esm/helperComponents/DataView/index.js +3 -0
- package/dist/esm/helperComponents/DataView/types.d.ts +12 -0
- package/dist/esm/helperComponents/DataView/types.js +1 -0
- package/dist/esm/helperComponents/FilterButton/FilterButton.d.ts +12 -0
- package/dist/esm/helperComponents/FilterButton/FilterButton.js +11 -0
- package/dist/esm/helperComponents/FilterButton/index.d.ts +1 -0
- package/dist/esm/helperComponents/FilterButton/index.js +1 -0
- package/dist/esm/helperComponents/FilterButton/styles.module.css +5 -0
- package/dist/esm/helperComponents/MoreActions/MoreActions.d.ts +13 -0
- package/dist/esm/helperComponents/MoreActions/MoreActions.js +29 -0
- package/dist/esm/helperComponents/MoreActions/index.d.ts +1 -0
- package/dist/esm/helperComponents/MoreActions/index.js +1 -0
- package/dist/esm/helperComponents/MoreActions/styles.module.css +5 -0
- package/dist/esm/helperComponents/Search/ToolbarSearch.d.ts +9 -0
- package/dist/esm/helperComponents/Search/ToolbarSearch.js +13 -0
- package/dist/esm/helperComponents/Search/index.d.ts +1 -0
- package/dist/esm/helperComponents/Search/index.js +1 -0
- package/dist/esm/helperComponents/Search/styles.module.css +25 -0
- package/dist/esm/helperComponents/Separator/Separator.d.ts +1 -0
- package/dist/esm/helperComponents/Separator/Separator.js +5 -0
- package/dist/esm/helperComponents/Separator/index.d.ts +1 -0
- package/dist/esm/helperComponents/Separator/index.js +1 -0
- package/dist/esm/helperComponents/Separator/styles.module.css +14 -0
- package/dist/esm/helperComponents/index.d.ts +6 -0
- package/dist/esm/helperComponents/index.js +6 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/locale/index.d.ts +55 -0
- package/dist/esm/locale/index.js +29 -0
- package/dist/esm/style.css +437 -0
- package/dist/esm/testIds.d.ts +24 -0
- package/dist/esm/testIds.js +24 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/package.json +65 -0
- package/src/components/Toolbar/Toolbar.tsx +145 -0
- package/src/components/Toolbar/helpers.ts +39 -0
- package/src/components/Toolbar/hooks/index.ts +2 -0
- package/src/components/Toolbar/hooks/useFilters.ts +87 -0
- package/src/components/Toolbar/hooks/usePersistState/index.ts +1 -0
- package/src/components/Toolbar/hooks/usePersistState/usePersistState.ts +107 -0
- package/src/components/Toolbar/hooks/usePersistState/utils/index.ts +3 -0
- package/src/components/Toolbar/hooks/usePersistState/utils/isDateString.ts +49 -0
- package/src/components/Toolbar/hooks/usePersistState/utils/parser.ts +62 -0
- package/src/components/Toolbar/hooks/usePersistState/utils/serializer.ts +51 -0
- package/src/components/Toolbar/index.ts +3 -0
- package/src/components/Toolbar/styles.module.scss +116 -0
- package/src/components/Toolbar/types.ts +99 -0
- package/src/components/Toolbar/typesUtils.ts +17 -0
- package/src/components/Toolbar/utils/buildMobileOverflowActions.tsx +142 -0
- package/src/components/Toolbar/utils/toolbarAfterOverflow.ts +2 -0
- package/src/components/index.ts +4 -0
- package/src/helperComponents/BulkActions/BulkActions.tsx +54 -0
- package/src/helperComponents/BulkActions/components/BulkActionsCheckbox/BulkActionsCheckbox.tsx +35 -0
- package/src/helperComponents/BulkActions/components/BulkActionsCheckbox/index.ts +1 -0
- package/src/helperComponents/BulkActions/components/BulkActionsCheckbox/styles.module.scss +3 -0
- package/src/helperComponents/BulkActions/components/BulkActionsControls/BulkActionsControls.tsx +135 -0
- package/src/helperComponents/BulkActions/components/BulkActionsControls/index.ts +1 -0
- package/src/helperComponents/BulkActions/components/BulkActionsControls/styles.module.scss +49 -0
- package/src/helperComponents/BulkActions/components/MobileBulkActionsSheet/MobileBulkActionsSheet.tsx +88 -0
- package/src/helperComponents/BulkActions/components/MobileBulkActionsSheet/index.ts +1 -0
- package/src/helperComponents/BulkActions/components/SelectionLabel/SelectionLabel.tsx +40 -0
- package/src/helperComponents/BulkActions/components/SelectionLabel/index.ts +1 -0
- package/src/helperComponents/BulkActions/components/SelectionLabel/styles.module.scss +38 -0
- package/src/helperComponents/BulkActions/components/index.ts +4 -0
- package/src/helperComponents/BulkActions/index.ts +2 -0
- package/src/helperComponents/BulkActions/styles.module.scss +13 -0
- package/src/helperComponents/BulkActions/types.ts +32 -0
- package/src/helperComponents/BulkActions/utils.tsx +32 -0
- package/src/helperComponents/DataView/DataView.tsx +22 -0
- package/src/helperComponents/DataView/constants.tsx +15 -0
- package/src/helperComponents/DataView/index.ts +3 -0
- package/src/helperComponents/DataView/types.ts +15 -0
- package/src/helperComponents/FilterButton/FilterButton.tsx +40 -0
- package/src/helperComponents/FilterButton/index.ts +1 -0
- package/src/helperComponents/FilterButton/styles.module.scss +5 -0
- package/src/helperComponents/MoreActions/MoreActions.tsx +69 -0
- package/src/helperComponents/MoreActions/index.ts +1 -0
- package/src/helperComponents/MoreActions/styles.module.scss +5 -0
- package/src/helperComponents/Search/ToolbarSearch.tsx +48 -0
- package/src/helperComponents/Search/index.ts +1 -0
- package/src/helperComponents/Search/styles.module.scss +35 -0
- package/src/helperComponents/Separator/Separator.tsx +9 -0
- package/src/helperComponents/Separator/index.ts +1 -0
- package/src/helperComponents/Separator/styles.module.scss +18 -0
- package/src/helperComponents/index.ts +6 -0
- package/src/index.ts +5 -0
- package/src/locale/index.ts +33 -0
- package/src/testIds.ts +24 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
@use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
|
|
2
|
+
@use '@cloud-ru/ds-figma-variables/build/scss/components/toolbar.module' as toolbar;
|
|
3
|
+
@use '@cloud-ru/ds-materials' as m;
|
|
4
|
+
|
|
5
|
+
.containerWrapper {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
gap: toolbar.$sn-toolbar-anatomy-container-gap;
|
|
9
|
+
width: 100%;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.acrylic {
|
|
13
|
+
pointer-events: none;
|
|
14
|
+
|
|
15
|
+
position: absolute;
|
|
16
|
+
z-index: 0;
|
|
17
|
+
inset: 0;
|
|
18
|
+
|
|
19
|
+
border-radius: inherit;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.border {
|
|
23
|
+
pointer-events: none;
|
|
24
|
+
|
|
25
|
+
position: absolute;
|
|
26
|
+
z-index: 1;
|
|
27
|
+
inset: 0;
|
|
28
|
+
|
|
29
|
+
box-sizing: border-box;
|
|
30
|
+
border: toolbar.$sn-toolbar-anatomy-container-tool-borderWidth solid base.$sn-theme-color-available-borderColor;
|
|
31
|
+
border-radius: inherit;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.container {
|
|
35
|
+
@include m.with-material('acrylic', #{acrylic});
|
|
36
|
+
|
|
37
|
+
isolation: isolate;
|
|
38
|
+
position: relative;
|
|
39
|
+
z-index: 0;
|
|
40
|
+
|
|
41
|
+
overflow: auto hidden;
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: stretch;
|
|
44
|
+
|
|
45
|
+
box-sizing: border-box;
|
|
46
|
+
width: 100%;
|
|
47
|
+
min-height: toolbar.$sn-toolbar-anatomy-container-tool-minHeight;
|
|
48
|
+
padding-inline: toolbar.$sn-toolbar-anatomy-container-tool-paddingHorizontal;
|
|
49
|
+
border-radius: toolbar.$sn-toolbar-anatomy-container-tool-borderRadius;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.content {
|
|
53
|
+
position: relative;
|
|
54
|
+
z-index: 2;
|
|
55
|
+
|
|
56
|
+
display: flex;
|
|
57
|
+
flex: 1 1 auto;
|
|
58
|
+
flex-wrap: nowrap;
|
|
59
|
+
gap: toolbar.$sn-toolbar-anatomy-container-tool-gap;
|
|
60
|
+
align-items: center;
|
|
61
|
+
|
|
62
|
+
box-sizing: border-box;
|
|
63
|
+
width: 100%;
|
|
64
|
+
min-width: min-content;
|
|
65
|
+
min-height: toolbar.$sn-toolbar-anatomy-container-tool-minHeight;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.searchWrapper {
|
|
69
|
+
display: flex;
|
|
70
|
+
flex: 1 1 0;
|
|
71
|
+
flex-direction: column;
|
|
72
|
+
align-items: stretch;
|
|
73
|
+
justify-content: center;
|
|
74
|
+
|
|
75
|
+
min-width: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.updateButton {
|
|
79
|
+
flex-shrink: 0;
|
|
80
|
+
|
|
81
|
+
svg {
|
|
82
|
+
transform: rotate(360deg);
|
|
83
|
+
transition: transform 0.5s;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&:active {
|
|
87
|
+
svg {
|
|
88
|
+
transform: rotate(0deg);
|
|
89
|
+
transition-duration: 0s;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.beforeSearch {
|
|
95
|
+
position: relative;
|
|
96
|
+
|
|
97
|
+
display: flex;
|
|
98
|
+
flex-shrink: 0;
|
|
99
|
+
align-items: center;
|
|
100
|
+
|
|
101
|
+
box-sizing: border-box;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.slot {
|
|
105
|
+
display: flex;
|
|
106
|
+
flex-shrink: 0;
|
|
107
|
+
align-items: center;
|
|
108
|
+
box-sizing: border-box;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
$filterDropDownMinWidthGridSteps: 25;
|
|
112
|
+
$filter-dropDown-minWidth: calc(#{$filterDropDownMinWidthGridSteps} * #{base.$sn-primitive-dimension-8});
|
|
113
|
+
|
|
114
|
+
.list {
|
|
115
|
+
min-width: $filter-dropDown-minWidth;
|
|
116
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { ChipChoiceRowProps, FiltersState } from '@cloud-ru/ds-chips';
|
|
2
|
+
import { WithSupportProps } from '@cloud-ru/ds-utils';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
import { RequestPayloadParams } from '@cloud-ru/ft-request-payload-transform';
|
|
6
|
+
|
|
7
|
+
import { BulkActionsProps, DataViewProps, DataViewValue, MoreActionsProps, SearchProps } from '../../helperComponents';
|
|
8
|
+
import { NeverOrUndefined, RequireAtLeastOne } from './typesUtils';
|
|
9
|
+
|
|
10
|
+
export type ToolbarDataViewValue = DataViewValue;
|
|
11
|
+
|
|
12
|
+
export type ToolbarDataViewProps = DataViewProps & {
|
|
13
|
+
/** Показать переключатель вида. Если `dataView` не передан — равносильно `show: false` */
|
|
14
|
+
show?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type OptionalProps = {
|
|
18
|
+
/** Колбек обновления */
|
|
19
|
+
onRefresh?(): void;
|
|
20
|
+
/** Дополнительный слот между поиском и переключателем вида (+ slotExtraButton в Figma). <br>
|
|
21
|
+
* На mobile-раскладке (из `AdaptiveProvider`) не рендерится в строке — кнопки переносятся в меню «⋯»
|
|
22
|
+
* (`Button` с `onClick` и `label` / `icon` / `aria-label`, одна обёртка вокруг кнопки
|
|
23
|
+
* или элемент с `data-toolbar-after-overflow`). Иначе — в `moreActions`. */
|
|
24
|
+
after?: ReactNode;
|
|
25
|
+
/** Переключатель вида данных — SegmentControl (showDataView в Figma) */
|
|
26
|
+
dataView?: ToolbarDataViewProps;
|
|
27
|
+
/** Элементы выпадающего списка кнопки с действиями */
|
|
28
|
+
moreActions?: MoreActionsProps['moreActions'];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type CommonToolbarProps = {
|
|
32
|
+
/** Параметры отвечают за строку поиска <br>
|
|
33
|
+
* <strong>value</strong>: Значение строки поиска <br>
|
|
34
|
+
* <strong>onChange</strong>: Колбэк смены значения <br>
|
|
35
|
+
* <strong>onSubmit</strong>: Колбэк на подтверждение поиска по строке
|
|
36
|
+
* <strong>placeholder</strong>: Плейсхолдер <br>
|
|
37
|
+
* <strong>loading</strong>: Состояние загрузки <br>
|
|
38
|
+
* */
|
|
39
|
+
search?: SearchProps;
|
|
40
|
+
/** Класснейм */
|
|
41
|
+
className?: string;
|
|
42
|
+
/** Внешний бордер */
|
|
43
|
+
outline?: boolean;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type ToolbarBulkActionProps = Omit<BulkActionsProps, 'actions'> & {
|
|
47
|
+
/** Список массовых действий */
|
|
48
|
+
bulkActions?: BulkActionsProps['actions'];
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type CheckedToolbarProps = CommonToolbarProps & ToolbarBulkActionProps & OptionalProps;
|
|
52
|
+
|
|
53
|
+
export type DefaultToolbarProps = CommonToolbarProps &
|
|
54
|
+
NeverOrUndefined<ToolbarBulkActionProps> &
|
|
55
|
+
RequireAtLeastOne<OptionalProps>;
|
|
56
|
+
|
|
57
|
+
export type FilterRow<TState extends FiltersState = Record<string, unknown>> = Omit<
|
|
58
|
+
ChipChoiceRowProps<TState>,
|
|
59
|
+
'size' | 'data-test-id'
|
|
60
|
+
> & {
|
|
61
|
+
open?: boolean;
|
|
62
|
+
/** Начальное состояние filter-row (mobile) */
|
|
63
|
+
initialOpen?: boolean;
|
|
64
|
+
onOpenChange?(isOpen: boolean): void;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type PersistedFilterState<T extends FiltersState> = {
|
|
68
|
+
pagination?: RequestPayloadParams['pagination'];
|
|
69
|
+
ordering?: RequestPayloadParams['ordering'];
|
|
70
|
+
search?: string;
|
|
71
|
+
filter?: T;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export type ToolbarPersistConfig<T extends FiltersState> = {
|
|
75
|
+
/** Уникальный id для текущего инстанса компонента */
|
|
76
|
+
id?: string;
|
|
77
|
+
/** Ключ для queryParams */
|
|
78
|
+
filterQueryKey?: string;
|
|
79
|
+
/** Валидатор сохраненных */
|
|
80
|
+
validateData?(value: unknown): value is PersistedFilterState<T>;
|
|
81
|
+
/** Custom-сериализация состояния перед сохранением в queryParams */
|
|
82
|
+
serializer?(value: PersistedFilterState<T>): string;
|
|
83
|
+
/** Custom-парсер queryParams для преобразования в данные состояния */
|
|
84
|
+
parser?(value: string): PersistedFilterState<T>;
|
|
85
|
+
/** Состояние для сохранения */
|
|
86
|
+
state?: PersistedFilterState<T>;
|
|
87
|
+
/** Колбэк при первом рендере для получения сохраненных данных и установки их в стейт */
|
|
88
|
+
onLoad?(state: PersistedFilterState<T>): void;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export type ToolbarProps<TState extends FiltersState = Record<string, unknown>> = WithSupportProps<
|
|
92
|
+
DefaultToolbarProps | CheckedToolbarProps
|
|
93
|
+
> & {
|
|
94
|
+
filterRow?: FilterRow<TState>;
|
|
95
|
+
/** Конфиг для сохранения состояния в localStorage и queryParams. <br>
|
|
96
|
+
* Поле id должно быть уникальным для каждого инстанса компонента. <br>
|
|
97
|
+
* */
|
|
98
|
+
persist?: ToolbarPersistConfig<TState>;
|
|
99
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type IsEqual<A, B> = (<G>() => G extends A ? 1 : 2) extends <G>() => G extends B ? 1 : 2 ? true : false;
|
|
2
|
+
|
|
3
|
+
type Filter<KeyType, ExcludeType> =
|
|
4
|
+
IsEqual<KeyType, ExcludeType> extends true ? never : KeyType extends ExcludeType ? never : KeyType;
|
|
5
|
+
|
|
6
|
+
type Except<ObjectType, KeysType extends keyof ObjectType> = {
|
|
7
|
+
[KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = {
|
|
11
|
+
[Key in KeysType]-?: Required<Pick<ObjectType, Key>> & Partial<Pick<ObjectType, Exclude<KeysType, Key>>>;
|
|
12
|
+
}[KeysType] &
|
|
13
|
+
Except<ObjectType, KeysType>;
|
|
14
|
+
|
|
15
|
+
export type NeverOrUndefined<T> = {
|
|
16
|
+
[P in keyof T]?: never;
|
|
17
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Button } from '@cloud-ru/ds-button';
|
|
2
|
+
import { UpdateSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
3
|
+
import { Children, Fragment, isValidElement, MouseEvent, ReactElement, ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
import { MoreActionsProps } from '../../../helperComponents/MoreActions';
|
|
6
|
+
import { TEST_IDS } from '../../../testIds';
|
|
7
|
+
import { TOOLBAR_AFTER_OVERFLOW_ATTR } from './toolbarAfterOverflow';
|
|
8
|
+
|
|
9
|
+
type MoreAction = MoreActionsProps['moreActions'][number];
|
|
10
|
+
|
|
11
|
+
type BuildMobileOverflowActionsParams = {
|
|
12
|
+
onRefresh?: () => void;
|
|
13
|
+
after?: ReactNode;
|
|
14
|
+
moreActions?: MoreActionsProps['moreActions'];
|
|
15
|
+
refreshLabel: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function collectElements(node: ReactNode): ReactElement[] {
|
|
19
|
+
if (node == null || typeof node === 'boolean') {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return Children.toArray(node).flatMap(child => {
|
|
24
|
+
if (!isValidElement(child)) {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (child.type === Fragment) {
|
|
29
|
+
return collectElements(child.props.children);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return [child];
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function hasOverflowMarker(element: ReactElement): boolean {
|
|
37
|
+
return TOOLBAR_AFTER_OVERFLOW_ATTR in (element.props as Record<string, unknown>);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function isSlotButton(element: ReactElement): boolean {
|
|
41
|
+
if (hasOverflowMarker(element)) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (element.type === Button) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const {
|
|
50
|
+
onClick,
|
|
51
|
+
label,
|
|
52
|
+
icon,
|
|
53
|
+
'aria-label': ariaLabel,
|
|
54
|
+
} = element.props as {
|
|
55
|
+
onClick?: (event: MouseEvent<HTMLElement>) => void;
|
|
56
|
+
label?: string;
|
|
57
|
+
icon?: ReactNode;
|
|
58
|
+
'aria-label'?: string;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
return typeof onClick === 'function' && Boolean(label || icon || ariaLabel);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function resolveAfterActionElement(element: ReactElement): ReactElement | null {
|
|
65
|
+
if (isSlotButton(element)) {
|
|
66
|
+
return element;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const childElements = collectElements((element.props as { children?: ReactNode }).children);
|
|
70
|
+
|
|
71
|
+
if (childElements.length === 1) {
|
|
72
|
+
return resolveAfterActionElement(childElements[0]);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function mapSlotButtonToAction(element: ReactElement): MoreAction | null {
|
|
79
|
+
const {
|
|
80
|
+
label,
|
|
81
|
+
icon,
|
|
82
|
+
onClick,
|
|
83
|
+
disabled,
|
|
84
|
+
'aria-label': ariaLabel,
|
|
85
|
+
} = element.props as {
|
|
86
|
+
label?: string;
|
|
87
|
+
icon?: ReactNode;
|
|
88
|
+
onClick?: (event: MouseEvent<HTMLElement>) => void;
|
|
89
|
+
disabled?: boolean;
|
|
90
|
+
'aria-label'?: string;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const optionLabel = label ?? ariaLabel;
|
|
94
|
+
|
|
95
|
+
if (!optionLabel && !icon) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
content: optionLabel ? { label: optionLabel } : { label: '' },
|
|
101
|
+
icon,
|
|
102
|
+
onClick,
|
|
103
|
+
disabled,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function buildMobileOverflowActions({
|
|
108
|
+
onRefresh,
|
|
109
|
+
after,
|
|
110
|
+
moreActions = [],
|
|
111
|
+
refreshLabel,
|
|
112
|
+
}: BuildMobileOverflowActionsParams): MoreActionsProps['moreActions'] {
|
|
113
|
+
const actions: MoreAction[] = [];
|
|
114
|
+
|
|
115
|
+
if (onRefresh) {
|
|
116
|
+
actions.push({
|
|
117
|
+
content: { label: refreshLabel },
|
|
118
|
+
icon: <UpdateSVG />,
|
|
119
|
+
onClick: onRefresh,
|
|
120
|
+
'data-test-id': TEST_IDS.refreshOption,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
collectElements(after).forEach((element, index) => {
|
|
125
|
+
const actionElement = resolveAfterActionElement(element);
|
|
126
|
+
|
|
127
|
+
if (!actionElement) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const action = mapSlotButtonToAction(actionElement);
|
|
132
|
+
|
|
133
|
+
if (action) {
|
|
134
|
+
actions.push({
|
|
135
|
+
...action,
|
|
136
|
+
'data-test-id': `${TEST_IDS.afterOption}__${index}`,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
return [...actions, ...moreActions];
|
|
142
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export * from './Toolbar';
|
|
2
|
+
export type { BulkAction, BulkActionsProps } from '../helperComponents';
|
|
3
|
+
export { formatFilterStateToRequestPayload, isDateString } from './Toolbar/hooks/usePersistState/utils';
|
|
4
|
+
export { TOOLBAR_AFTER_OVERFLOW_ATTR } from './Toolbar/utils/toolbarAfterOverflow';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { isMobileLayout, useAdaptiveLayout } from '@cloud-ru/ds-adaptive';
|
|
2
|
+
|
|
3
|
+
import { TEST_IDS } from '../../testIds';
|
|
4
|
+
import { BulkActionsCheckbox, BulkActionsControls, MobileBulkActionsSheet, SelectionLabel } from './components';
|
|
5
|
+
import styles from './styles.module.scss';
|
|
6
|
+
import { BulkActionsComponentProps } from './types';
|
|
7
|
+
|
|
8
|
+
export function BulkActions({
|
|
9
|
+
actions = [],
|
|
10
|
+
checked,
|
|
11
|
+
onCheck,
|
|
12
|
+
indeterminate,
|
|
13
|
+
selectedCount = 0,
|
|
14
|
+
totalCount,
|
|
15
|
+
showBulkCheckbox = true,
|
|
16
|
+
resizingContainerRef,
|
|
17
|
+
}: BulkActionsComponentProps) {
|
|
18
|
+
const { layoutType } = useAdaptiveLayout();
|
|
19
|
+
const isMobile = isMobileLayout(layoutType);
|
|
20
|
+
const hasSelection = Boolean(checked || indeterminate);
|
|
21
|
+
const showActions = hasSelection && actions.length > 0;
|
|
22
|
+
const showInlineActions = showActions && !isMobile;
|
|
23
|
+
const showCheckboxInToolbar = showBulkCheckbox;
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<>
|
|
27
|
+
<div className={styles.bulkTool} data-test-id={TEST_IDS.bulkTool}>
|
|
28
|
+
{showCheckboxInToolbar && (
|
|
29
|
+
<BulkActionsCheckbox checked={checked} indeterminate={indeterminate} onCheck={onCheck} />
|
|
30
|
+
)}
|
|
31
|
+
|
|
32
|
+
<SelectionLabel selectedCount={selectedCount} totalCount={totalCount} hasSelection={hasSelection} />
|
|
33
|
+
|
|
34
|
+
{showInlineActions && (
|
|
35
|
+
<BulkActionsControls variant='toolbar' actions={actions} resizingContainerRef={resizingContainerRef} />
|
|
36
|
+
)}
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
{isMobile && showActions && (
|
|
40
|
+
<MobileBulkActionsSheet
|
|
41
|
+
open={hasSelection}
|
|
42
|
+
actions={actions}
|
|
43
|
+
selectedCount={selectedCount}
|
|
44
|
+
totalCount={totalCount}
|
|
45
|
+
hasSelection={hasSelection}
|
|
46
|
+
checked={checked}
|
|
47
|
+
indeterminate={indeterminate}
|
|
48
|
+
onCheck={onCheck}
|
|
49
|
+
showBulkCheckbox={showBulkCheckbox}
|
|
50
|
+
/>
|
|
51
|
+
)}
|
|
52
|
+
</>
|
|
53
|
+
);
|
|
54
|
+
}
|
package/src/helperComponents/BulkActions/components/BulkActionsCheckbox/BulkActionsCheckbox.tsx
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Checkbox } from '@cloud-ru/ds-toggles';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
|
|
4
|
+
import { TEST_IDS } from '../../../../testIds';
|
|
5
|
+
import styles from './styles.module.scss';
|
|
6
|
+
|
|
7
|
+
type BulkActionsCheckboxProps = {
|
|
8
|
+
checked?: boolean;
|
|
9
|
+
indeterminate?: boolean;
|
|
10
|
+
onCheck?(): void;
|
|
11
|
+
className?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function getCheckboxAriaChecked(checked?: boolean, indeterminate?: boolean): boolean | 'mixed' {
|
|
15
|
+
if (indeterminate) {
|
|
16
|
+
return 'mixed';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return Boolean(checked);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function BulkActionsCheckbox({ checked, indeterminate, onCheck, className }: BulkActionsCheckboxProps) {
|
|
23
|
+
return (
|
|
24
|
+
<Checkbox
|
|
25
|
+
size='xs'
|
|
26
|
+
checked={checked}
|
|
27
|
+
indeterminate={indeterminate}
|
|
28
|
+
tabIndex={-1}
|
|
29
|
+
data-test-id={TEST_IDS.checkbox}
|
|
30
|
+
className={cn(styles.checkbox, className)}
|
|
31
|
+
onClick={onCheck}
|
|
32
|
+
aria-checked={getCheckboxAriaChecked(checked, indeterminate)}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './BulkActionsCheckbox';
|
package/src/helperComponents/BulkActions/components/BulkActionsControls/BulkActionsControls.tsx
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Button } from '@cloud-ru/ds-button';
|
|
2
|
+
import { KebabSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
3
|
+
import { Droplist } from '@cloud-ru/ds-list';
|
|
4
|
+
import { Tooltip } from '@cloud-ru/ds-tooltip';
|
|
5
|
+
import { useDynamicList } from '@cloud-ru/ds-utils';
|
|
6
|
+
import { RefObject, useRef, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { toolbarLocale } from '../../../../locale';
|
|
9
|
+
import { TEST_IDS } from '../../../../testIds';
|
|
10
|
+
import { BulkAction } from '../../types';
|
|
11
|
+
import { getBulkActionIndex, getBulkActionKey, mapBulkActionToDroplistItem } from '../../utils';
|
|
12
|
+
import { BulkActionsCheckbox } from '../BulkActionsCheckbox';
|
|
13
|
+
import { SelectionLabel } from '../SelectionLabel';
|
|
14
|
+
import styles from './styles.module.scss';
|
|
15
|
+
|
|
16
|
+
type BulkActionsControlsVariant = 'toolbar' | 'sheet';
|
|
17
|
+
|
|
18
|
+
type BulkActionsControlsProps = {
|
|
19
|
+
actions: BulkAction[];
|
|
20
|
+
variant: BulkActionsControlsVariant;
|
|
21
|
+
checked?: boolean;
|
|
22
|
+
indeterminate?: boolean;
|
|
23
|
+
onCheck?(): void;
|
|
24
|
+
showCheckbox?: boolean;
|
|
25
|
+
resizingContainerRef?: RefObject<HTMLDivElement>;
|
|
26
|
+
selectedCount?: number;
|
|
27
|
+
totalCount?: number;
|
|
28
|
+
hasSelection?: boolean;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export function BulkActionsControls({
|
|
32
|
+
actions,
|
|
33
|
+
variant,
|
|
34
|
+
checked,
|
|
35
|
+
indeterminate,
|
|
36
|
+
onCheck,
|
|
37
|
+
showCheckbox = false,
|
|
38
|
+
resizingContainerRef,
|
|
39
|
+
selectedCount = 0,
|
|
40
|
+
totalCount,
|
|
41
|
+
hasSelection = false,
|
|
42
|
+
}: BulkActionsControlsProps) {
|
|
43
|
+
const { t } = toolbarLocale.useTranslations();
|
|
44
|
+
const [isMoreOpen, setIsMoreOpen] = useState(false);
|
|
45
|
+
const actionsAreaRef = useRef<HTMLDivElement>(null);
|
|
46
|
+
const triggerRef = useRef<HTMLButtonElement>(null);
|
|
47
|
+
const isSheet = variant === 'sheet';
|
|
48
|
+
|
|
49
|
+
const { visibleItems, hiddenItems } = useDynamicList({
|
|
50
|
+
items: actions,
|
|
51
|
+
resizingContainerRef: isSheet ? undefined : resizingContainerRef,
|
|
52
|
+
parentContainerRef: actionsAreaRef,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const droplistActions = isSheet ? actions : hiddenItems;
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<div className={styles.actionsArea} ref={actionsAreaRef} data-variant={variant} data-test-id={TEST_IDS.bulkActions}>
|
|
59
|
+
{showCheckbox && <BulkActionsCheckbox checked={checked} indeterminate={indeterminate} onCheck={onCheck} />}
|
|
60
|
+
|
|
61
|
+
<div className={isSheet ? styles.sheetActions : styles.bulkActions}>
|
|
62
|
+
{visibleItems.map((action, visibleIndex) => {
|
|
63
|
+
const { label, icon: Icon, onClick, disabled, tooltip, 'data-test-id': testId } = action;
|
|
64
|
+
const actionIndex = getBulkActionIndex(actions, action, visibleIndex);
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<Tooltip
|
|
68
|
+
tip={tooltip}
|
|
69
|
+
key={getBulkActionKey(action, actionIndex)}
|
|
70
|
+
open={tooltip ? undefined : false}
|
|
71
|
+
placement='top'
|
|
72
|
+
data-test-id={`${testId}-tooltip`}
|
|
73
|
+
triggerClassName={styles.triggerClassName}
|
|
74
|
+
>
|
|
75
|
+
<Button
|
|
76
|
+
view='tonal'
|
|
77
|
+
appearance='primary'
|
|
78
|
+
className={styles.action}
|
|
79
|
+
data-test-id={testId}
|
|
80
|
+
iconPosition='before'
|
|
81
|
+
icon={<Icon />}
|
|
82
|
+
label={label}
|
|
83
|
+
size='s'
|
|
84
|
+
onClick={onClick}
|
|
85
|
+
disabled={disabled}
|
|
86
|
+
/>
|
|
87
|
+
</Tooltip>
|
|
88
|
+
);
|
|
89
|
+
})}
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
{hiddenItems.length > 0 && (
|
|
93
|
+
<Droplist
|
|
94
|
+
label={isSheet ? t('multipleActions') : undefined}
|
|
95
|
+
// TODO: slotAfterTitle должен расширяться на всю ширину, а section-label уходить вправо
|
|
96
|
+
slotAfterTitle={
|
|
97
|
+
isSheet ? (
|
|
98
|
+
<SelectionLabel
|
|
99
|
+
placement='headline'
|
|
100
|
+
selectedCount={selectedCount}
|
|
101
|
+
totalCount={totalCount}
|
|
102
|
+
hasSelection={hasSelection}
|
|
103
|
+
/>
|
|
104
|
+
) : undefined
|
|
105
|
+
}
|
|
106
|
+
open={isMoreOpen}
|
|
107
|
+
onOpenChange={setIsMoreOpen}
|
|
108
|
+
trigger='clickAndFocusVisible'
|
|
109
|
+
triggerElemRef={triggerRef}
|
|
110
|
+
triggerClassName={styles.triggerClassName}
|
|
111
|
+
closeDroplistOnItemClick
|
|
112
|
+
placement='bottom-end'
|
|
113
|
+
scroll
|
|
114
|
+
size='s'
|
|
115
|
+
items={droplistActions.map((action, index) =>
|
|
116
|
+
mapBulkActionToDroplistItem(action, getBulkActionIndex(actions, action, index)),
|
|
117
|
+
)}
|
|
118
|
+
>
|
|
119
|
+
{({ onKeyDown }) => (
|
|
120
|
+
<Button
|
|
121
|
+
view='function'
|
|
122
|
+
appearance='neutral'
|
|
123
|
+
className={styles.moreActionButton}
|
|
124
|
+
size='s'
|
|
125
|
+
icon={<KebabSVG />}
|
|
126
|
+
data-test-id={TEST_IDS.moreBulkActionsButton}
|
|
127
|
+
innerRef={triggerRef}
|
|
128
|
+
onKeyDown={onKeyDown}
|
|
129
|
+
/>
|
|
130
|
+
)}
|
|
131
|
+
</Droplist>
|
|
132
|
+
)}
|
|
133
|
+
</div>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './BulkActionsControls';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
@use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
|
|
2
|
+
@use '@cloud-ru/ds-figma-variables/build/scss/components/toolbar.module' as toolbar;
|
|
3
|
+
@use '@cloud-ru/ds-figma-variables/build/scss/components/toggles.module' as toggles;
|
|
4
|
+
|
|
5
|
+
$action-focus-padding: calc(2 * #{base.$sn-primitive-strokeWeight-strokeSemiBold});
|
|
6
|
+
|
|
7
|
+
.actionsArea {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex: 1 1 0;
|
|
10
|
+
gap: toolbar.$sn-toolbar-anatomy-container-tool-bulkAction-gap;
|
|
11
|
+
align-items: center;
|
|
12
|
+
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
width: 100%;
|
|
15
|
+
min-width: 0;
|
|
16
|
+
|
|
17
|
+
// В строке тулбара отступ ряда даёт `.bulkTool`, а в BottomSheet этой обёртки нет —
|
|
18
|
+
// здесь корнем ряда служит сама `.actionsArea`, поэтому отступ берём на себя.
|
|
19
|
+
&[data-variant='sheet'] {
|
|
20
|
+
padding-left: toolbar.$sn-toolbar-anatomy-container-tool-bulkAction-paddingLeft;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.bulkActions {
|
|
25
|
+
display: inline-flex;
|
|
26
|
+
flex-shrink: 0;
|
|
27
|
+
gap: base.$sn-primitive-dimension-4;
|
|
28
|
+
align-items: center;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.moreActionButton {
|
|
32
|
+
flex-shrink: 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.action {
|
|
36
|
+
flex-shrink: 0;
|
|
37
|
+
white-space: nowrap;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.sheetActions {
|
|
41
|
+
display: inline-flex;
|
|
42
|
+
flex-shrink: 0;
|
|
43
|
+
gap: base.$sn-primitive-dimension-4;
|
|
44
|
+
align-items: center;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.triggerClassName {
|
|
48
|
+
display: inline-flex;
|
|
49
|
+
}
|