@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
@@ -1,5 +1,9 @@
1
1
  import styles from './styles.module.scss';
2
2
 
3
3
  export function Separator() {
4
- return <span className={styles.separator} />;
4
+ return (
5
+ <div className={styles.separatorWrapper}>
6
+ <div className={styles.separator}></div>
7
+ </div>
8
+ );
5
9
  }
@@ -1,13 +1,17 @@
1
- @use '@snack-uikit/figma-tokens/build/scss/styles-theme-variables';
1
+ @use '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-toolbar' as toolbar;
2
+
3
+ .separatorWrapper {
4
+ @include toolbar.composite-var(toolbar.$toolbar-separator-wrap);
2
5
 
3
- .separator {
4
6
  flex-shrink: 0;
7
+ }
5
8
 
6
- box-sizing: border-box;
7
- width: styles-theme-variables.$border-width-toolbar-separator;
8
- margin: styles-theme-variables.$space-toolbar-separator-padding 0;
9
9
 
10
- background-color: styles-theme-variables.$sys-neutral-decor-default;
10
+ .separator {
11
+ box-sizing: border-box;
12
+ width: toolbar.$border-width-toolbar-separator;
13
+ height: 100%;
14
+ background-color: toolbar.$sys-neutral-decor-default;
11
15
  }
12
16
 
13
17
 
@@ -1,3 +1,3 @@
1
- export * from './DeleteAction';
1
+ export * from './BulkActions';
2
2
  export * from './Separator';
3
3
  export * from './MoreActions';
@@ -1,14 +0,0 @@
1
- import { SelectionMode } from './types';
2
- export type DeleteActionProps = {
3
- /** Колбек смены значения чекбокса*/
4
- onCheck?(): void;
5
- /** Колбек удаления */
6
- onDelete?(): void;
7
- /** Значения чекбокса*/
8
- checked?: boolean;
9
- /** Состояние частичного выбора */
10
- indeterminate?: boolean;
11
- /** Режим выбора @default 'multiple'*/
12
- selectionMode?: SelectionMode;
13
- };
14
- export declare function DeleteAction({ checked, onCheck, onDelete, indeterminate, selectionMode, }: DeleteActionProps): import("react/jsx-runtime").JSX.Element;
@@ -1,56 +0,0 @@
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.DeleteAction = DeleteAction;
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 toggles_1 = require("@snack-uikit/toggles");
17
- const constants_1 = require("../../constants");
18
- const constants_2 = require("./constants");
19
- const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
20
- function DeleteAction(_ref) {
21
- let {
22
- checked,
23
- onCheck,
24
- onDelete,
25
- indeterminate,
26
- selectionMode = constants_2.SELECTION_MODE.Multiple
27
- } = _ref;
28
- const handleKeyDown = (0, react_1.useCallback)(e => {
29
- if (e.key === ' ') {
30
- onCheck === null || onCheck === void 0 ? void 0 : onCheck();
31
- }
32
- }, [onCheck]);
33
- return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, {
34
- children: [selectionMode === constants_2.SELECTION_MODE.Multiple && (0, jsx_runtime_1.jsx)("div", {
35
- className: styles_module_scss_1.default.checkboxWrapper,
36
- onClick: onCheck,
37
- tabIndex: 0,
38
- role: 'checkbox',
39
- "aria-checked": checked,
40
- onKeyDown: handleKeyDown,
41
- "data-test-id": constants_1.TEST_IDS.checkbox,
42
- children: (0, jsx_runtime_1.jsx)(toggles_1.Checkbox, {
43
- size: 's',
44
- checked: checked,
45
- indeterminate: indeterminate,
46
- tabIndex: -1
47
- })
48
- }), onDelete && (0, jsx_runtime_1.jsx)(button_1.ButtonFunction, {
49
- "data-test-id": constants_1.TEST_IDS.deleteButton,
50
- icon: (0, jsx_runtime_1.jsx)(icons_1.TrashSVG, {}),
51
- size: 'm',
52
- onClick: onDelete,
53
- disabled: !checked && !indeterminate
54
- })]
55
- });
56
- }
@@ -1,3 +0,0 @@
1
- import { ValueOf } from '@snack-uikit/utils';
2
- import { SELECTION_MODE } from './constants';
3
- export type SelectionMode = ValueOf<typeof SELECTION_MODE>;
@@ -1,14 +0,0 @@
1
- import { SelectionMode } from './types';
2
- export type DeleteActionProps = {
3
- /** Колбек смены значения чекбокса*/
4
- onCheck?(): void;
5
- /** Колбек удаления */
6
- onDelete?(): void;
7
- /** Значения чекбокса*/
8
- checked?: boolean;
9
- /** Состояние частичного выбора */
10
- indeterminate?: boolean;
11
- /** Режим выбора @default 'multiple'*/
12
- selectionMode?: SelectionMode;
13
- };
14
- export declare function DeleteAction({ checked, onCheck, onDelete, indeterminate, selectionMode, }: DeleteActionProps): import("react/jsx-runtime").JSX.Element;
@@ -1,16 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useCallback } from 'react';
3
- import { ButtonFunction } from '@snack-uikit/button';
4
- import { TrashSVG } from '@snack-uikit/icons';
5
- import { Checkbox } from '@snack-uikit/toggles';
6
- import { TEST_IDS } from '../../constants';
7
- import { SELECTION_MODE } from './constants';
8
- import styles from './styles.module.css';
9
- export function DeleteAction({ checked, onCheck, onDelete, indeterminate, selectionMode = SELECTION_MODE.Multiple, }) {
10
- const handleKeyDown = useCallback((e) => {
11
- if (e.key === ' ') {
12
- onCheck === null || onCheck === void 0 ? void 0 : onCheck();
13
- }
14
- }, [onCheck]);
15
- return (_jsxs(_Fragment, { children: [selectionMode === SELECTION_MODE.Multiple && (_jsx("div", { className: styles.checkboxWrapper, onClick: onCheck, tabIndex: 0, role: 'checkbox', "aria-checked": checked, onKeyDown: handleKeyDown, "data-test-id": TEST_IDS.checkbox, children: _jsx(Checkbox, { size: 's', checked: checked, indeterminate: indeterminate, tabIndex: -1 }) })), onDelete && (_jsx(ButtonFunction, { "data-test-id": TEST_IDS.deleteButton, icon: _jsx(TrashSVG, {}), size: 'm', onClick: onDelete, disabled: !checked && !indeterminate }))] }));
16
- }
@@ -1,3 +0,0 @@
1
- import { ValueOf } from '@snack-uikit/utils';
2
- import { SELECTION_MODE } from './constants';
3
- export type SelectionMode = ValueOf<typeof SELECTION_MODE>;
@@ -1,68 +0,0 @@
1
- import { KeyboardEvent, useCallback } from 'react';
2
-
3
- import { ButtonFunction } from '@snack-uikit/button';
4
- import { TrashSVG } from '@snack-uikit/icons';
5
- import { Checkbox } from '@snack-uikit/toggles';
6
-
7
- import { TEST_IDS } from '../../constants';
8
- import { SELECTION_MODE } from './constants';
9
- import styles from './styles.module.scss';
10
- import { SelectionMode } from './types';
11
-
12
- export type DeleteActionProps = {
13
- /** Колбек смены значения чекбокса*/
14
- onCheck?(): void;
15
- /** Колбек удаления */
16
- onDelete?(): void;
17
- /** Значения чекбокса*/
18
- checked?: boolean;
19
- /** Состояние частичного выбора */
20
- indeterminate?: boolean;
21
- /** Режим выбора @default 'multiple'*/
22
- selectionMode?: SelectionMode;
23
- };
24
-
25
- export function DeleteAction({
26
- checked,
27
- onCheck,
28
- onDelete,
29
- indeterminate,
30
- selectionMode = SELECTION_MODE.Multiple,
31
- }: DeleteActionProps) {
32
- const handleKeyDown = useCallback(
33
- (e: KeyboardEvent<HTMLDivElement>) => {
34
- if (e.key === ' ') {
35
- onCheck?.();
36
- }
37
- },
38
- [onCheck],
39
- );
40
-
41
- return (
42
- <>
43
- {selectionMode === SELECTION_MODE.Multiple && (
44
- <div
45
- className={styles.checkboxWrapper}
46
- onClick={onCheck}
47
- tabIndex={0}
48
- role='checkbox'
49
- aria-checked={checked}
50
- onKeyDown={handleKeyDown}
51
- data-test-id={TEST_IDS.checkbox}
52
- >
53
- <Checkbox size='s' checked={checked} indeterminate={indeterminate} tabIndex={-1} />
54
- </div>
55
- )}
56
-
57
- {onDelete && (
58
- <ButtonFunction
59
- data-test-id={TEST_IDS.deleteButton}
60
- icon={<TrashSVG />}
61
- size='m'
62
- onClick={onDelete}
63
- disabled={!checked && !indeterminate}
64
- />
65
- )}
66
- </>
67
- );
68
- }
@@ -1,24 +0,0 @@
1
- @use '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-toolbar';
2
- @use '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-element';
3
-
4
-
5
- .checkboxWrapper {
6
- @include styles-tokens-toolbar.composite-var(styles-tokens-toolbar.$toolbar-checkbox);
7
-
8
- cursor: pointer;
9
-
10
- position: relative;
11
-
12
- display: flex;
13
- flex-shrink: 0;
14
- align-items: center;
15
- justify-content: center;
16
-
17
- box-sizing: border-box;
18
-
19
- &:focus-visible {
20
- @include styles-tokens-toolbar.outline-var(styles-tokens-element.$container-focused-s);
21
-
22
- outline-color: styles-tokens-toolbar.$sys-available-complementary;
23
- }
24
- }
@@ -1,5 +0,0 @@
1
- import { ValueOf } from '@snack-uikit/utils';
2
-
3
- import { SELECTION_MODE } from './constants';
4
-
5
- export type SelectionMode = ValueOf<typeof SELECTION_MODE>;