@snack-uikit/toolbar 0.9.18 → 0.10.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.
Files changed (67) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +2 -3
  3. package/dist/cjs/components/Toolbar/Toolbar.d.ts +1 -1
  4. package/dist/cjs/components/Toolbar/Toolbar.js +10 -10
  5. package/dist/cjs/components/Toolbar/helpers.d.ts +4 -4
  6. package/dist/cjs/components/Toolbar/helpers.js +7 -7
  7. package/dist/cjs/components/Toolbar/styles.module.css +11 -0
  8. package/dist/cjs/components/Toolbar/types.d.ts +7 -5
  9. package/dist/cjs/constants.d.ts +7 -2
  10. package/dist/cjs/constants.js +7 -2
  11. package/dist/cjs/helperComponents/BulkActions/BulkActions.d.ts +5 -0
  12. package/dist/cjs/helperComponents/BulkActions/BulkActions.js +131 -0
  13. package/dist/cjs/helperComponents/{DeleteAction → BulkActions}/index.d.ts +1 -1
  14. package/dist/cjs/helperComponents/{DeleteAction → BulkActions}/index.js +1 -1
  15. package/dist/{esm/helperComponents/DeleteAction → cjs/helperComponents/BulkActions}/styles.module.css +26 -0
  16. package/dist/cjs/helperComponents/BulkActions/types.d.ts +26 -0
  17. package/dist/cjs/helperComponents/Separator/Separator.js +5 -2
  18. package/dist/cjs/helperComponents/Separator/styles.module.css +7 -2
  19. package/dist/cjs/helperComponents/index.d.ts +1 -1
  20. package/dist/cjs/helperComponents/index.js +1 -1
  21. package/dist/esm/components/Toolbar/Toolbar.d.ts +1 -1
  22. package/dist/esm/components/Toolbar/Toolbar.js +8 -6
  23. package/dist/esm/components/Toolbar/helpers.d.ts +4 -4
  24. package/dist/esm/components/Toolbar/helpers.js +8 -10
  25. package/dist/esm/components/Toolbar/styles.module.css +11 -0
  26. package/dist/esm/components/Toolbar/types.d.ts +7 -5
  27. package/dist/esm/constants.d.ts +7 -2
  28. package/dist/esm/constants.js +7 -2
  29. package/dist/esm/helperComponents/BulkActions/BulkActions.d.ts +5 -0
  30. package/dist/esm/helperComponents/BulkActions/BulkActions.js +34 -0
  31. package/dist/esm/helperComponents/{DeleteAction → BulkActions}/index.d.ts +1 -1
  32. package/dist/esm/helperComponents/{DeleteAction → BulkActions}/index.js +1 -1
  33. package/dist/{cjs/helperComponents/DeleteAction → esm/helperComponents/BulkActions}/styles.module.css +26 -0
  34. package/dist/esm/helperComponents/BulkActions/types.d.ts +26 -0
  35. package/dist/esm/helperComponents/Separator/Separator.js +1 -1
  36. package/dist/esm/helperComponents/Separator/styles.module.css +7 -2
  37. package/dist/esm/helperComponents/index.d.ts +1 -1
  38. package/dist/esm/helperComponents/index.js +1 -1
  39. package/package.json +10 -9
  40. package/src/components/Toolbar/Toolbar.tsx +17 -14
  41. package/src/components/Toolbar/helpers.ts +11 -13
  42. package/src/components/Toolbar/styles.module.scss +18 -9
  43. package/src/components/Toolbar/types.ts +8 -5
  44. package/src/constants.ts +7 -2
  45. package/src/helperComponents/BulkActions/BulkActions.tsx +118 -0
  46. package/src/helperComponents/{DeleteAction → BulkActions}/index.ts +1 -1
  47. package/src/helperComponents/BulkActions/styles.module.scss +55 -0
  48. package/src/helperComponents/BulkActions/types.ts +29 -0
  49. package/src/helperComponents/Separator/Separator.tsx +5 -1
  50. package/src/helperComponents/Separator/styles.module.scss +10 -6
  51. package/src/helperComponents/index.ts +1 -1
  52. package/dist/cjs/helperComponents/DeleteAction/DeleteAction.d.ts +0 -14
  53. package/dist/cjs/helperComponents/DeleteAction/DeleteAction.js +0 -56
  54. package/dist/cjs/helperComponents/DeleteAction/types.d.ts +0 -3
  55. package/dist/esm/helperComponents/DeleteAction/DeleteAction.d.ts +0 -14
  56. package/dist/esm/helperComponents/DeleteAction/DeleteAction.js +0 -16
  57. package/dist/esm/helperComponents/DeleteAction/types.d.ts +0 -3
  58. package/src/helperComponents/DeleteAction/DeleteAction.tsx +0 -68
  59. package/src/helperComponents/DeleteAction/styles.module.scss +0 -24
  60. package/src/helperComponents/DeleteAction/types.ts +0 -5
  61. /package/dist/cjs/helperComponents/{DeleteAction → BulkActions}/constants.d.ts +0 -0
  62. /package/dist/cjs/helperComponents/{DeleteAction → BulkActions}/constants.js +0 -0
  63. /package/dist/cjs/helperComponents/{DeleteAction → BulkActions}/types.js +0 -0
  64. /package/dist/esm/helperComponents/{DeleteAction → BulkActions}/constants.d.ts +0 -0
  65. /package/dist/esm/helperComponents/{DeleteAction → BulkActions}/constants.js +0 -0
  66. /package/dist/esm/helperComponents/{DeleteAction → BulkActions}/types.js +0 -0
  67. /package/src/helperComponents/{DeleteAction → BulkActions}/constants.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # 0.10.0 (2025-01-23)
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+
12
+ * **PDS-926:** add bulk actions, remove onDelete and before props ([a871db9](https://github.com/cloud-ru-tech/snack-uikit/commit/a871db9ea3446189852704ee135e8a510d2f7204))
13
+
14
+
15
+
16
+
6
17
  ## 0.9.18 (2025-01-22)
7
18
 
8
19
  ### Only dependencies have been changed
package/README.md CHANGED
@@ -17,12 +17,11 @@ Toolbar
17
17
  | className | `string` | - | Класснейм |
18
18
  | outline | `boolean` | - | Внешний бордер |
19
19
  | onCheck | `() => void` | - | Колбек смены значения чекбокса |
20
- | onDelete | `() => void` | - | Колбек удаления |
21
- | checked | `boolean` | - | Значения чекбокса |
20
+ | checked | `boolean` | - | Значение чекбокса |
22
21
  | indeterminate | `boolean` | - | Состояние частичного выбора |
23
22
  | selectionMode | enum SelectionMode: `"single"`, `"multiple"` | 'multiple' | Режим выбора |
23
+ | bulkActions | `BulkAction[]` | - | Список массовых действий |
24
24
  | onRefresh | `() => void` | - | Колбек обновления |
25
- | before | `ReactNode` | - | Дополнительный слот в начале Тулбара |
26
25
  | after | `ReactNode` | - | Дополнительный слот в конце тулбара |
27
26
  | moreActions | `Action[]` | - | Элементы выпадающего списка кнопки с действиями |
28
27
 
@@ -1,4 +1,4 @@
1
1
  import { WithSupportProps } from '@snack-uikit/utils';
2
2
  import { CheckedToolbarProps, DefaultToolbarProps } from './types';
3
3
  export type ToolbarProps = WithSupportProps<DefaultToolbarProps | CheckedToolbarProps>;
4
- export declare function Toolbar({ className, before, after, outline, moreActions, onRefresh, search, ...rest }: ToolbarProps): import("react/jsx-runtime").JSX.Element;
4
+ export declare function Toolbar({ className, after, outline, moreActions, onRefresh, search, ...rest }: ToolbarProps): import("react/jsx-runtime").JSX.Element;
@@ -19,6 +19,7 @@ Object.defineProperty(exports, "__esModule", {
19
19
  exports.Toolbar = Toolbar;
20
20
  const jsx_runtime_1 = require("react/jsx-runtime");
21
21
  const classnames_1 = __importDefault(require("classnames"));
22
+ const react_1 = require("react");
22
23
  const button_1 = require("@snack-uikit/button");
23
24
  const icons_1 = require("@snack-uikit/icons");
24
25
  const search_private_1 = require("@snack-uikit/search-private");
@@ -30,27 +31,26 @@ const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
30
31
  function Toolbar(_a) {
31
32
  var {
32
33
  className,
33
- before,
34
34
  after,
35
35
  outline,
36
36
  moreActions,
37
37
  onRefresh,
38
38
  search
39
39
  } = _a,
40
- rest = __rest(_a, ["className", "before", "after", "outline", "moreActions", "onRefresh", "search"]);
41
- const needsDeleteAction = (0, helpers_1.isDeleteActionProps)(rest);
42
- const hasLeftSideElements = Boolean(needsDeleteAction || before || onRefresh);
40
+ rest = __rest(_a, ["className", "after", "outline", "moreActions", "onRefresh", "search"]);
41
+ const needsBulkActions = (0, helpers_1.isBulkActionsProps)(rest);
42
+ const hasLeftSideElements = Boolean(needsBulkActions || onRefresh);
43
+ const resizingContainerRef = (0, react_1.useRef)(null);
43
44
  return (0, jsx_runtime_1.jsxs)("div", Object.assign({
44
45
  className: (0, classnames_1.default)(styles_module_scss_1.default.container, className)
45
46
  }, (0, utils_1.extractSupportProps)(rest), {
46
47
  "data-outline": outline || undefined,
48
+ ref: resizingContainerRef,
47
49
  children: [hasLeftSideElements && (0, jsx_runtime_1.jsxs)("div", {
48
- className: styles_module_scss_1.default.flexRow,
49
- children: [needsDeleteAction && (0, jsx_runtime_1.jsx)(helperComponents_1.DeleteAction, Object.assign({}, (0, helpers_1.extractDeleteActionProps)(rest))), before && (0, jsx_runtime_1.jsx)("div", {
50
- "data-test-id": constants_1.TEST_IDS.before,
51
- className: styles_module_scss_1.default.actions,
52
- children: before
53
- }), (needsDeleteAction || before) && (0, jsx_runtime_1.jsx)(helperComponents_1.Separator, {}), onRefresh && (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, {
50
+ className: styles_module_scss_1.default.beforeSearch,
51
+ children: [needsBulkActions && (0, jsx_runtime_1.jsx)(helperComponents_1.BulkActions, Object.assign({}, (0, helpers_1.extractBulkActionsProps)(rest), {
52
+ resizingContainerRef: resizingContainerRef
53
+ })), needsBulkActions && (0, jsx_runtime_1.jsx)(helperComponents_1.Separator, {}), onRefresh && (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, {
54
54
  children: [(0, jsx_runtime_1.jsx)(button_1.ButtonFunction, {
55
55
  icon: (0, jsx_runtime_1.jsx)(icons_1.UpdateSVG, {}),
56
56
  size: 'm',
@@ -1,10 +1,10 @@
1
1
  import { ToolbarProps } from './Toolbar';
2
- import { CheckedToolbarProps } from './types';
3
- export declare function extractDeleteActionProps({ onCheck, checked, indeterminate, onDelete, selectionMode, }: Omit<CheckedToolbarProps, 'onRefresh'>): {
2
+ import { ToolbarBulkActionProps } from './types';
3
+ export declare function extractBulkActionsProps({ onCheck, checked, indeterminate, bulkActions, selectionMode, }: ToolbarBulkActionProps): {
4
4
  onCheck: (() => void) | undefined;
5
5
  checked: boolean | undefined;
6
6
  indeterminate: boolean | undefined;
7
- onDelete: (() => void) | undefined;
7
+ actions: import("../../helperComponents").BulkAction[];
8
8
  selectionMode: import("../../helperComponents").SelectionMode | undefined;
9
9
  };
10
- export declare function isDeleteActionProps(props: Partial<ToolbarProps>): props is CheckedToolbarProps;
10
+ export declare function isBulkActionsProps(props: Partial<ToolbarProps>): props is ToolbarBulkActionProps;
@@ -3,24 +3,24 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.extractDeleteActionProps = extractDeleteActionProps;
7
- exports.isDeleteActionProps = isDeleteActionProps;
8
- function extractDeleteActionProps(_ref) {
6
+ exports.extractBulkActionsProps = extractBulkActionsProps;
7
+ exports.isBulkActionsProps = isBulkActionsProps;
8
+ function extractBulkActionsProps(_ref) {
9
9
  let {
10
10
  onCheck,
11
11
  checked,
12
12
  indeterminate,
13
- onDelete,
13
+ bulkActions = [],
14
14
  selectionMode
15
15
  } = _ref;
16
16
  return {
17
17
  onCheck,
18
18
  checked,
19
19
  indeterminate,
20
- onDelete,
20
+ actions: bulkActions,
21
21
  selectionMode
22
22
  };
23
23
  }
24
- function isDeleteActionProps(props) {
25
- return 'onDelete' in props && props.onDelete !== undefined || 'checked' in props && props.checked !== undefined && 'onCheck' in props && props.onCheck !== undefined && 'selectionMode' in props && props.selectionMode === 'multiple';
24
+ function isBulkActionsProps(props) {
25
+ return 'bulkActions' in props && Array.isArray(props.bulkActions) && props.bulkActions.length > 0 && 'selectionMode' in props && props.selectionMode === 'multiple';
26
26
  }
@@ -30,6 +30,7 @@
30
30
  padding-left:var(--space-toolbar-search-horizontal-padding, 8px);
31
31
  padding-right:var(--space-toolbar-search-horizontal-padding, 8px);
32
32
  border-radius:var(--radius-toolbar-search, 14px);
33
+ min-width:var(--size-toolbar-search-min-width, 80px);
33
34
  }
34
35
  .search:focus-within{
35
36
  outline-width:var(--border-state-focus-s-border-width, 2px);
@@ -39,6 +40,9 @@
39
40
  outline-color:var(--sys-available-complementary, #1c1c24);
40
41
  }
41
42
 
43
+ .updateButton{
44
+ flex-shrink:0;
45
+ }
42
46
  .updateButton svg{
43
47
  transform:rotate(360deg);
44
48
  transition:transform 0.5s;
@@ -48,6 +52,13 @@
48
52
  transition-duration:0s;
49
53
  }
50
54
 
55
+ .beforeSearch{
56
+ display:flex;
57
+ flex-shrink:1;
58
+ box-sizing:border-box;
59
+ min-width:0;
60
+ }
61
+
51
62
  .flexRow{
52
63
  display:flex;
53
64
  flex-shrink:0;
@@ -1,11 +1,9 @@
1
1
  import { ReactNode } from 'react';
2
- import { DeleteActionProps, MoreActionsProps } from '../../helperComponents';
2
+ import { BulkActionsProps, MoreActionsProps } from '../../helperComponents';
3
3
  import { NeverOrUndefined, RequireAtLeastOne } from './typesUtils';
4
4
  type OptionalProps = {
5
5
  /** Колбек обновления */
6
6
  onRefresh?(): void;
7
- /** Дополнительный слот в начале Тулбара */
8
- before?: ReactNode;
9
7
  /** Дополнительный слот в конце тулбара */
10
8
  after?: ReactNode;
11
9
  /** Элементы выпадающего списка кнопки с действиями */
@@ -31,6 +29,10 @@ export type CommonToolbarProps = {
31
29
  /** Внешний бордер */
32
30
  outline?: boolean;
33
31
  };
34
- export type CheckedToolbarProps = CommonToolbarProps & DeleteActionProps & OptionalProps;
35
- export type DefaultToolbarProps = CommonToolbarProps & NeverOrUndefined<DeleteActionProps> & RequireAtLeastOne<OptionalProps>;
32
+ export type ToolbarBulkActionProps = Omit<BulkActionsProps, 'actions'> & {
33
+ /** Список массовых действий */
34
+ bulkActions?: BulkActionsProps['actions'];
35
+ };
36
+ export type CheckedToolbarProps = CommonToolbarProps & ToolbarBulkActionProps & OptionalProps;
37
+ export type DefaultToolbarProps = CommonToolbarProps & NeverOrUndefined<ToolbarBulkActionProps> & RequireAtLeastOne<OptionalProps>;
36
38
  export {};
@@ -1,12 +1,17 @@
1
1
  export declare const TEST_IDS: {
2
2
  main: string;
3
3
  checkbox: string;
4
- deleteButton: string;
4
+ confirmAction: string;
5
+ rejectAction: string;
6
+ deleteAction: string;
7
+ deactivateAction: string;
8
+ disabledAction: string;
9
+ bulkActions: string;
10
+ moreBulkActionsButton: string;
5
11
  refreshButton: string;
6
12
  search: string;
7
13
  moreActionsButton: string;
8
14
  droplist: string;
9
15
  option: string;
10
- before: string;
11
16
  after: string;
12
17
  };
@@ -7,12 +7,17 @@ exports.TEST_IDS = void 0;
7
7
  exports.TEST_IDS = {
8
8
  main: 'toolbar',
9
9
  checkbox: 'toolbar__checkbox',
10
- deleteButton: 'toolbar__delete-button',
10
+ confirmAction: 'toolbar__confirm-action',
11
+ rejectAction: 'toolbar__reject-action',
12
+ deleteAction: 'toolbar__delete-action',
13
+ deactivateAction: 'toolbar__deactivate-action',
14
+ disabledAction: 'toolbar__disabled-action',
15
+ bulkActions: 'toolbar__bulk-actions',
16
+ moreBulkActionsButton: 'toolbar__more-bulk-actions-button',
11
17
  refreshButton: 'toolbar__refresh-button',
12
18
  search: 'toolbar__search',
13
19
  moreActionsButton: 'toolbar__more-actions-button',
14
20
  droplist: 'toolbar__droplist',
15
21
  option: 'toolbar__droplist-option',
16
- before: 'toolbar__before',
17
22
  after: 'toolbar__after'
18
23
  };
@@ -0,0 +1,5 @@
1
+ import { RefObject } from 'react';
2
+ import { BulkActionsProps } from './types';
3
+ export declare function BulkActions({ actions, checked, onCheck, indeterminate, selectionMode, resizingContainerRef, }: BulkActionsProps & {
4
+ resizingContainerRef: RefObject<HTMLDivElement>;
5
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+
3
+ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
4
+ return mod && mod.__esModule ? mod : {
5
+ "default": mod
6
+ };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", {
9
+ value: true
10
+ });
11
+ exports.BulkActions = BulkActions;
12
+ const jsx_runtime_1 = require("react/jsx-runtime");
13
+ const react_1 = require("react");
14
+ const button_1 = require("@snack-uikit/button");
15
+ const icons_1 = require("@snack-uikit/icons");
16
+ const list_1 = require("@snack-uikit/list");
17
+ const toggles_1 = require("@snack-uikit/toggles");
18
+ const tooltip_1 = require("@snack-uikit/tooltip");
19
+ const utils_1 = require("@snack-uikit/utils");
20
+ const constants_1 = require("../../constants");
21
+ const constants_2 = require("./constants");
22
+ const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
23
+ function BulkActions(_ref) {
24
+ let {
25
+ actions,
26
+ checked,
27
+ onCheck,
28
+ indeterminate,
29
+ selectionMode = constants_2.SELECTION_MODE.Multiple,
30
+ resizingContainerRef
31
+ } = _ref;
32
+ const handleKeyDown = (0, react_1.useCallback)(e => {
33
+ if (e.key === ' ') {
34
+ onCheck === null || onCheck === void 0 ? void 0 : onCheck();
35
+ }
36
+ }, [onCheck]);
37
+ const parentContainerRef = (0, react_1.useRef)(null);
38
+ const {
39
+ visibleItems,
40
+ hiddenItems
41
+ } = (0, utils_1.useDynamicList)({
42
+ items: actions,
43
+ resizingContainerRef,
44
+ parentContainerRef,
45
+ maxVisibleItems: 3
46
+ });
47
+ return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, {
48
+ children: [selectionMode === constants_2.SELECTION_MODE.Multiple && (0, jsx_runtime_1.jsx)("div", {
49
+ className: styles_module_scss_1.default.checkboxWrapper,
50
+ onClick: onCheck,
51
+ tabIndex: 0,
52
+ role: 'checkbox',
53
+ "aria-checked": checked,
54
+ onKeyDown: handleKeyDown,
55
+ "data-test-id": constants_1.TEST_IDS.checkbox,
56
+ children: (0, jsx_runtime_1.jsx)(toggles_1.Checkbox, {
57
+ size: 's',
58
+ checked: checked,
59
+ indeterminate: indeterminate,
60
+ tabIndex: -1
61
+ })
62
+ }), (checked || indeterminate) && (0, jsx_runtime_1.jsxs)("div", {
63
+ className: styles_module_scss_1.default.bulkActions,
64
+ "data-test-id": constants_1.TEST_IDS.bulkActions,
65
+ ref: parentContainerRef,
66
+ children: [visibleItems.map(_ref2 => {
67
+ let {
68
+ label,
69
+ icon: Icon,
70
+ onClick,
71
+ disabled,
72
+ tooltip,
73
+ 'data-test-id': testId
74
+ } = _ref2;
75
+ return (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, {
76
+ tip: tooltip,
77
+ open: tooltip ? undefined : false,
78
+ placement: 'top',
79
+ "data-test-id": `${testId}-tooltip`,
80
+ children: (0, jsx_runtime_1.jsx)(button_1.ButtonFunction, {
81
+ className: styles_module_scss_1.default.action,
82
+ fullWidth: true,
83
+ "data-test-id": testId,
84
+ iconPosition: 'before',
85
+ icon: (0, jsx_runtime_1.jsx)(Icon, {}),
86
+ label: label,
87
+ size: 'm',
88
+ onClick: onClick,
89
+ disabled: disabled
90
+ })
91
+ }, label);
92
+ }), hiddenItems.length > 0 && (0, jsx_runtime_1.jsx)(list_1.Droplist, {
93
+ trigger: 'clickAndFocusVisible',
94
+ closeDroplistOnItemClick: true,
95
+ items: hiddenItems.map(_ref3 => {
96
+ let {
97
+ label,
98
+ icon: Icon,
99
+ onClick,
100
+ disabled,
101
+ tooltip,
102
+ 'data-test-id': testId
103
+ } = _ref3;
104
+ return {
105
+ id: label,
106
+ content: {
107
+ option: label
108
+ },
109
+ beforeContent: (0, jsx_runtime_1.jsx)(Icon, {}),
110
+ onClick,
111
+ disabled,
112
+ itemWrapRender: item => (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, {
113
+ tip: tooltip,
114
+ open: tooltip ? undefined : false,
115
+ placement: 'right',
116
+ "data-test-id": `${testId}-tooltip`,
117
+ children: item
118
+ }),
119
+ 'data-test-id': testId
120
+ };
121
+ }),
122
+ children: (0, jsx_runtime_1.jsx)(button_1.ButtonFunction, {
123
+ className: styles_module_scss_1.default.moreActionButton,
124
+ size: 'm',
125
+ icon: (0, jsx_runtime_1.jsx)(icons_1.MoreSVG, {}),
126
+ "data-test-id": constants_1.TEST_IDS.moreBulkActionsButton
127
+ })
128
+ })]
129
+ })]
130
+ });
131
+ }
@@ -1,3 +1,3 @@
1
- export * from './DeleteAction';
1
+ export * from './BulkActions';
2
2
  export * from './constants';
3
3
  export * from './types';
@@ -22,6 +22,6 @@ var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
22
22
  Object.defineProperty(exports, "__esModule", {
23
23
  value: true
24
24
  });
25
- __exportStar(require("./DeleteAction"), exports);
25
+ __exportStar(require("./BulkActions"), exports);
26
26
  __exportStar(require("./constants"), exports);
27
27
  __exportStar(require("./types"), exports);
@@ -1,3 +1,17 @@
1
+ .bulkActions{
2
+ padding-right:var(--space-toolbar-bulk-action-padding-right, 12px);
3
+ gap:var(--space-toolbar-bulk-action-gap, 8px);
4
+ scrollbar-width:none;
5
+ display:flex;
6
+ flex-shrink:1;
7
+ justify-content:stretch;
8
+ min-width:0;
9
+ -ms-overflow-style:none;
10
+ }
11
+ .bulkActions::-webkit-scrollbar{
12
+ display:none;
13
+ }
14
+
1
15
  .checkboxWrapper{
2
16
  border-radius:var(--radius-toolbar-checkbox, 14px);
3
17
  width:var(--size-toolbar-checkbox, 40px);
@@ -15,4 +29,16 @@
15
29
  outline-style:var(--border-state-focus-s-border-style, solid);
16
30
  outline-color:var(--border-state-focus-s-border-color, );
17
31
  outline-color:var(--sys-available-complementary, #1c1c24);
32
+ }
33
+
34
+ .moreActionButton{
35
+ flex-shrink:0;
36
+ }
37
+
38
+ .action{
39
+ white-space:nowrap;
40
+ }
41
+ .action[data-full-width]:not([data-variant=icon-only]){
42
+ flex-shrink:0;
43
+ width:auto;
18
44
  }
@@ -0,0 +1,26 @@
1
+ import { JSXElementConstructor } from 'react';
2
+ import { TooltipProps } from '@snack-uikit/tooltip';
3
+ import { ValueOf, WithSupportProps } from '@snack-uikit/utils';
4
+ import { SELECTION_MODE } from './constants';
5
+ export type SelectionMode = ValueOf<typeof SELECTION_MODE>;
6
+ export type BulkAction = WithSupportProps<{
7
+ label: string;
8
+ icon: JSXElementConstructor<{
9
+ className?: string;
10
+ }>;
11
+ disabled?: boolean;
12
+ tooltip?: TooltipProps['tip'];
13
+ onClick?(): void;
14
+ }>;
15
+ export type BulkActionsProps = {
16
+ /** Список массовых действий */
17
+ actions: BulkAction[];
18
+ /** Колбек смены значения чекбокса */
19
+ onCheck?(): void;
20
+ /** Значение чекбокса */
21
+ checked?: boolean;
22
+ /** Состояние частичного выбора */
23
+ indeterminate?: boolean;
24
+ /** Режим выбора @default 'multiple'*/
25
+ selectionMode?: SelectionMode;
26
+ };
@@ -12,7 +12,10 @@ exports.Separator = Separator;
12
12
  const jsx_runtime_1 = require("react/jsx-runtime");
13
13
  const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
14
14
  function Separator() {
15
- return (0, jsx_runtime_1.jsx)("span", {
16
- className: styles_module_scss_1.default.separator
15
+ return (0, jsx_runtime_1.jsx)("div", {
16
+ className: styles_module_scss_1.default.separatorWrapper,
17
+ children: (0, jsx_runtime_1.jsx)("div", {
18
+ className: styles_module_scss_1.default.separator
19
+ })
17
20
  });
18
21
  }
@@ -1,7 +1,12 @@
1
- .separator{
1
+ .separatorWrapper{
2
+ padding-top:var(--space-toolbar-separator-padding, 8px);
3
+ padding-bottom:var(--space-toolbar-separator-padding, 8px);
2
4
  flex-shrink:0;
5
+ }
6
+
7
+ .separator{
3
8
  box-sizing:border-box;
4
9
  width:var(--border-width-toolbar-separator, 1px);
5
- margin:var(--space-toolbar-separator-padding, 8px) 0;
10
+ height:100%;
6
11
  background-color:var(--sys-neutral-decor-default, #dde0ea);
7
12
  }
@@ -1,3 +1,3 @@
1
- export * from './DeleteAction';
1
+ export * from './BulkActions';
2
2
  export * from './Separator';
3
3
  export * from './MoreActions';
@@ -22,6 +22,6 @@ var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
22
22
  Object.defineProperty(exports, "__esModule", {
23
23
  value: true
24
24
  });
25
- __exportStar(require("./DeleteAction"), exports);
25
+ __exportStar(require("./BulkActions"), exports);
26
26
  __exportStar(require("./Separator"), exports);
27
27
  __exportStar(require("./MoreActions"), exports);
@@ -1,4 +1,4 @@
1
1
  import { WithSupportProps } from '@snack-uikit/utils';
2
2
  import { CheckedToolbarProps, DefaultToolbarProps } from './types';
3
3
  export type ToolbarProps = WithSupportProps<DefaultToolbarProps | CheckedToolbarProps>;
4
- export declare function Toolbar({ className, before, after, outline, moreActions, onRefresh, search, ...rest }: ToolbarProps): import("react/jsx-runtime").JSX.Element;
4
+ export declare function Toolbar({ className, after, outline, moreActions, onRefresh, search, ...rest }: ToolbarProps): import("react/jsx-runtime").JSX.Element;
@@ -11,17 +11,19 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import cn from 'classnames';
14
+ import { useRef } from 'react';
14
15
  import { ButtonFunction } from '@snack-uikit/button';
15
16
  import { UpdateSVG } from '@snack-uikit/icons';
16
17
  import { SearchPrivate } from '@snack-uikit/search-private';
17
18
  import { extractSupportProps } from '@snack-uikit/utils';
18
19
  import { TEST_IDS } from '../../constants';
19
- import { DeleteAction, MoreActions, Separator } from '../../helperComponents';
20
- import { extractDeleteActionProps, isDeleteActionProps } from './helpers';
20
+ import { BulkActions, MoreActions, Separator } from '../../helperComponents';
21
+ import { extractBulkActionsProps, isBulkActionsProps } from './helpers';
21
22
  import styles from './styles.module.css';
22
23
  export function Toolbar(_a) {
23
- var { className, before, after, outline, moreActions, onRefresh, search } = _a, rest = __rest(_a, ["className", "before", "after", "outline", "moreActions", "onRefresh", "search"]);
24
- const needsDeleteAction = isDeleteActionProps(rest);
25
- const hasLeftSideElements = Boolean(needsDeleteAction || before || onRefresh);
26
- return (_jsxs("div", Object.assign({ className: cn(styles.container, className) }, extractSupportProps(rest), { "data-outline": outline || undefined, children: [hasLeftSideElements && (_jsxs("div", { className: styles.flexRow, children: [needsDeleteAction && _jsx(DeleteAction, Object.assign({}, extractDeleteActionProps(rest))), before && (_jsx("div", { "data-test-id": TEST_IDS.before, className: styles.actions, children: before })), (needsDeleteAction || before) && _jsx(Separator, {}), onRefresh && (_jsxs(_Fragment, { children: [_jsx(ButtonFunction, { icon: _jsx(UpdateSVG, {}), size: 'm', className: styles.updateButton, onClick: onRefresh, "data-test-id": TEST_IDS.refreshButton }), _jsx(Separator, {})] }))] })), search && _jsx(SearchPrivate, Object.assign({}, search, { className: styles.search, size: 'm', "data-test-id": TEST_IDS.search })), (moreActions || after) && (_jsxs("div", { className: styles.flexRow, "data-align-right": (!search && !hasLeftSideElements) || undefined, children: [after && (_jsxs(_Fragment, { children: [(search || hasLeftSideElements) && _jsx(Separator, {}), _jsx("div", { "data-test-id": TEST_IDS.after, className: styles.actions, children: after })] })), moreActions && (_jsxs(_Fragment, { children: [_jsx(Separator, {}), _jsx(MoreActions, { moreActions: moreActions })] }))] }))] })));
24
+ var { className, after, outline, moreActions, onRefresh, search } = _a, rest = __rest(_a, ["className", "after", "outline", "moreActions", "onRefresh", "search"]);
25
+ const needsBulkActions = isBulkActionsProps(rest);
26
+ const hasLeftSideElements = Boolean(needsBulkActions || onRefresh);
27
+ const resizingContainerRef = useRef(null);
28
+ return (_jsxs("div", Object.assign({ className: cn(styles.container, className) }, extractSupportProps(rest), { "data-outline": outline || undefined, ref: resizingContainerRef, children: [hasLeftSideElements && (_jsxs("div", { className: styles.beforeSearch, children: [needsBulkActions && (_jsx(BulkActions, Object.assign({}, extractBulkActionsProps(rest), { resizingContainerRef: resizingContainerRef }))), needsBulkActions && _jsx(Separator, {}), onRefresh && (_jsxs(_Fragment, { children: [_jsx(ButtonFunction, { icon: _jsx(UpdateSVG, {}), size: 'm', className: styles.updateButton, onClick: onRefresh, "data-test-id": TEST_IDS.refreshButton }), _jsx(Separator, {})] }))] })), search && _jsx(SearchPrivate, Object.assign({}, search, { className: styles.search, size: 'm', "data-test-id": TEST_IDS.search })), (moreActions || after) && (_jsxs("div", { className: styles.flexRow, "data-align-right": (!search && !hasLeftSideElements) || undefined, children: [after && (_jsxs(_Fragment, { children: [(search || hasLeftSideElements) && _jsx(Separator, {}), _jsx("div", { "data-test-id": TEST_IDS.after, className: styles.actions, children: after })] })), moreActions && (_jsxs(_Fragment, { children: [_jsx(Separator, {}), _jsx(MoreActions, { moreActions: moreActions })] }))] }))] })));
27
29
  }
@@ -1,10 +1,10 @@
1
1
  import { ToolbarProps } from './Toolbar';
2
- import { CheckedToolbarProps } from './types';
3
- export declare function extractDeleteActionProps({ onCheck, checked, indeterminate, onDelete, selectionMode, }: Omit<CheckedToolbarProps, 'onRefresh'>): {
2
+ import { ToolbarBulkActionProps } from './types';
3
+ export declare function extractBulkActionsProps({ onCheck, checked, indeterminate, bulkActions, selectionMode, }: ToolbarBulkActionProps): {
4
4
  onCheck: (() => void) | undefined;
5
5
  checked: boolean | undefined;
6
6
  indeterminate: boolean | undefined;
7
- onDelete: (() => void) | undefined;
7
+ actions: import("../../helperComponents").BulkAction[];
8
8
  selectionMode: import("../../helperComponents").SelectionMode | undefined;
9
9
  };
10
- export declare function isDeleteActionProps(props: Partial<ToolbarProps>): props is CheckedToolbarProps;
10
+ export declare function isBulkActionsProps(props: Partial<ToolbarProps>): props is ToolbarBulkActionProps;
@@ -1,12 +1,10 @@
1
- export function extractDeleteActionProps({ onCheck, checked, indeterminate, onDelete, selectionMode, }) {
2
- return { onCheck, checked, indeterminate, onDelete, selectionMode };
1
+ export function extractBulkActionsProps({ onCheck, checked, indeterminate, bulkActions = [], selectionMode, }) {
2
+ return { onCheck, checked, indeterminate, actions: bulkActions, selectionMode };
3
3
  }
4
- export function isDeleteActionProps(props) {
5
- return (('onDelete' in props && props.onDelete !== undefined) ||
6
- ('checked' in props &&
7
- props.checked !== undefined &&
8
- 'onCheck' in props &&
9
- props.onCheck !== undefined &&
10
- 'selectionMode' in props &&
11
- props.selectionMode === 'multiple'));
4
+ export function isBulkActionsProps(props) {
5
+ return ('bulkActions' in props &&
6
+ Array.isArray(props.bulkActions) &&
7
+ props.bulkActions.length > 0 &&
8
+ 'selectionMode' in props &&
9
+ props.selectionMode === 'multiple');
12
10
  }
@@ -30,6 +30,7 @@
30
30
  padding-left:var(--space-toolbar-search-horizontal-padding, 8px);
31
31
  padding-right:var(--space-toolbar-search-horizontal-padding, 8px);
32
32
  border-radius:var(--radius-toolbar-search, 14px);
33
+ min-width:var(--size-toolbar-search-min-width, 80px);
33
34
  }
34
35
  .search:focus-within{
35
36
  outline-width:var(--border-state-focus-s-border-width, 2px);
@@ -39,6 +40,9 @@
39
40
  outline-color:var(--sys-available-complementary, #1c1c24);
40
41
  }
41
42
 
43
+ .updateButton{
44
+ flex-shrink:0;
45
+ }
42
46
  .updateButton svg{
43
47
  transform:rotate(360deg);
44
48
  transition:transform 0.5s;
@@ -48,6 +52,13 @@
48
52
  transition-duration:0s;
49
53
  }
50
54
 
55
+ .beforeSearch{
56
+ display:flex;
57
+ flex-shrink:1;
58
+ box-sizing:border-box;
59
+ min-width:0;
60
+ }
61
+
51
62
  .flexRow{
52
63
  display:flex;
53
64
  flex-shrink:0;
@@ -1,11 +1,9 @@
1
1
  import { ReactNode } from 'react';
2
- import { DeleteActionProps, MoreActionsProps } from '../../helperComponents';
2
+ import { BulkActionsProps, MoreActionsProps } from '../../helperComponents';
3
3
  import { NeverOrUndefined, RequireAtLeastOne } from './typesUtils';
4
4
  type OptionalProps = {
5
5
  /** Колбек обновления */
6
6
  onRefresh?(): void;
7
- /** Дополнительный слот в начале Тулбара */
8
- before?: ReactNode;
9
7
  /** Дополнительный слот в конце тулбара */
10
8
  after?: ReactNode;
11
9
  /** Элементы выпадающего списка кнопки с действиями */
@@ -31,6 +29,10 @@ export type CommonToolbarProps = {
31
29
  /** Внешний бордер */
32
30
  outline?: boolean;
33
31
  };
34
- export type CheckedToolbarProps = CommonToolbarProps & DeleteActionProps & OptionalProps;
35
- export type DefaultToolbarProps = CommonToolbarProps & NeverOrUndefined<DeleteActionProps> & RequireAtLeastOne<OptionalProps>;
32
+ export type ToolbarBulkActionProps = Omit<BulkActionsProps, 'actions'> & {
33
+ /** Список массовых действий */
34
+ bulkActions?: BulkActionsProps['actions'];
35
+ };
36
+ export type CheckedToolbarProps = CommonToolbarProps & ToolbarBulkActionProps & OptionalProps;
37
+ export type DefaultToolbarProps = CommonToolbarProps & NeverOrUndefined<ToolbarBulkActionProps> & RequireAtLeastOne<OptionalProps>;
36
38
  export {};