@snack-uikit/toolbar 0.4.2 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,29 @@
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.5.1 (2023-12-14)
7
+
8
+ ### Only dependencies have been changed
9
+ * [@snack-uikit/droplist@0.12.1](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/-/blob/master/packages/droplist/CHANGELOG.md)
10
+ * [@snack-uikit/icons@0.19.1](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/-/blob/master/packages/icons/CHANGELOG.md)
11
+ * [@snack-uikit/search@0.6.1](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/-/blob/master/packages/search/CHANGELOG.md)
12
+ * [@snack-uikit/toggles@0.9.1](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/-/blob/master/packages/toggles/CHANGELOG.md)
13
+
14
+
15
+
16
+
17
+
18
+ # 0.5.0 (2023-12-14)
19
+
20
+
21
+ ### BREAKING CHANGES
22
+
23
+
24
+ * **FF-3729:** replace enum with unions ([910db4a](https://github.com/cloud-ru-tech/snack-uikit/commit/910db4aa8231ccbc58e538e5c5c1f461b1dec275))
25
+
26
+
27
+
28
+
6
29
  ## 0.4.2 (2023-12-07)
7
30
 
8
31
  ### Only dependencies have been changed
package/README.md CHANGED
@@ -24,7 +24,7 @@ Toolbar
24
24
  | onDelete | `() => void` | - | Колбек удаления |
25
25
  | checked | `boolean` | - | Значения чекбокса |
26
26
  | indeterminate | `boolean` | - | Состояние частичного выбора |
27
- | selectionMode | enum SelectionMode: `"single"`, `"multiple"` | - | Режим выбора @default SelectionMode.Multiple |
27
+ | selectionMode | enum SelectionMode: `"single"`, `"multiple"` | 'multiple' | Режим выбора |
28
28
  | onRefresh | `() => void` | - | Колбек обновления |
29
29
  | actions | `ReactNode` | - | Дополнительный слот |
30
30
  | moreActions | `Pick<DroplistItemSingleProps, "option" \| "caption" \| "description" \| "tagLabel" \| "disabled" \| "icon" \| "onClick">[]` | - | Элементы выпадающего списка кнопки с действиями |
@@ -1,8 +1,4 @@
1
1
  import { WithSupportProps } from '@snack-uikit/utils';
2
- import { SelectionMode } from '../../helperComponents';
3
2
  import { CheckedToolbarProps, DefaultToolbarProps } from './types';
4
3
  export type ToolbarProps = WithSupportProps<DefaultToolbarProps | CheckedToolbarProps>;
5
4
  export declare function Toolbar({ className, actions, outline, moreActions, onRefresh, ...rest }: ToolbarProps): import("react/jsx-runtime").JSX.Element;
6
- export declare namespace Toolbar {
7
- var selectionModes: typeof SelectionMode;
8
- }
@@ -16,11 +16,10 @@ import { UpdateSVG } from '@snack-uikit/icons';
16
16
  import { SearchPrivate } from '@snack-uikit/search';
17
17
  import { extractSupportProps } from '@snack-uikit/utils';
18
18
  import { TEST_IDS } from '../../constants';
19
- import { DeleteAction, MoreActions, SelectionMode, Separator } from '../../helperComponents';
19
+ import { DeleteAction, MoreActions, Separator } from '../../helperComponents';
20
20
  import { extractDeleteActionProps, extractSearchPrivateProps, isDeleteActionProps } from './helpers';
21
21
  import styles from './styles.module.css';
22
22
  export function Toolbar(_a) {
23
23
  var { className, actions, outline, moreActions, onRefresh } = _a, rest = __rest(_a, ["className", "actions", "outline", "moreActions", "onRefresh"]);
24
- return (_jsxs("div", Object.assign({ className: cn(styles.container, className) }, extractSupportProps(rest), { "data-outline": outline || undefined }, { children: [isDeleteActionProps(rest) && (_jsxs(_Fragment, { children: [_jsx(DeleteAction, Object.assign({}, extractDeleteActionProps(rest))), _jsx(Separator, {})] })), onRefresh && (_jsxs(_Fragment, { children: [_jsx(ButtonFunction, { icon: _jsx(UpdateSVG, {}), size: ButtonFunction.sizes.M, className: styles.updateButton, onClick: onRefresh, "data-test-id": TEST_IDS.refreshButton }), _jsx(Separator, {})] })), _jsx(SearchPrivate, Object.assign({}, extractSearchPrivateProps(rest), { className: styles.search, size: SearchPrivate.sizes.M, "data-test-id": TEST_IDS.search })), actions && (_jsxs(_Fragment, { children: [_jsx(Separator, {}), _jsx("div", Object.assign({ "data-test-id": TEST_IDS.actions, className: styles.actions }, { children: actions }))] })), moreActions && (_jsxs(_Fragment, { children: [_jsx(Separator, {}), _jsx(MoreActions, { moreActions: moreActions })] }))] })));
24
+ return (_jsxs("div", Object.assign({ className: cn(styles.container, className) }, extractSupportProps(rest), { "data-outline": outline || undefined, children: [isDeleteActionProps(rest) && (_jsxs(_Fragment, { children: [_jsx(DeleteAction, Object.assign({}, extractDeleteActionProps(rest))), _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, {})] })), _jsx(SearchPrivate, Object.assign({}, extractSearchPrivateProps(rest), { className: styles.search, size: 'm', "data-test-id": TEST_IDS.search })), actions && (_jsxs(_Fragment, { children: [_jsx(Separator, {}), _jsx("div", { "data-test-id": TEST_IDS.actions, className: styles.actions, children: actions })] })), moreActions && (_jsxs(_Fragment, { children: [_jsx(Separator, {}), _jsx(MoreActions, { moreActions: moreActions })] }))] })));
25
25
  }
26
- Toolbar.selectionModes = SelectionMode;
@@ -1,4 +1,4 @@
1
- import { SelectionMode } from './constants';
1
+ import { SelectionMode } from './types';
2
2
  export type DeleteActionProps = {
3
3
  /** Колбек смены значения чекбокса*/
4
4
  onCheck?(): void;
@@ -8,7 +8,7 @@ export type DeleteActionProps = {
8
8
  checked?: boolean;
9
9
  /** Состояние частичного выбора */
10
10
  indeterminate?: boolean;
11
- /** Режим выбора @default SelectionMode.Multiple*/
11
+ /** Режим выбора @default 'multiple'*/
12
12
  selectionMode?: SelectionMode;
13
13
  };
14
14
  export declare function DeleteAction({ checked, onCheck, onDelete, indeterminate, selectionMode, }: DeleteActionProps): import("react/jsx-runtime").JSX.Element;
@@ -4,13 +4,13 @@ import { ButtonFunction } from '@snack-uikit/button';
4
4
  import { TrashSVG } from '@snack-uikit/icons';
5
5
  import { Checkbox } from '@snack-uikit/toggles';
6
6
  import { TEST_IDS } from '../../constants';
7
- import { SelectionMode } from './constants';
7
+ import { SELECTION_MODE } from './constants';
8
8
  import styles from './styles.module.css';
9
- export function DeleteAction({ checked, onCheck, onDelete, indeterminate, selectionMode = SelectionMode.Multiple, }) {
9
+ export function DeleteAction({ checked, onCheck, onDelete, indeterminate, selectionMode = SELECTION_MODE.Multiple, }) {
10
10
  const handleKeyDown = useCallback((e) => {
11
11
  if (e.key === ' ') {
12
12
  onCheck === null || onCheck === void 0 ? void 0 : onCheck();
13
13
  }
14
14
  }, [onCheck]);
15
- return (_jsxs(_Fragment, { children: [selectionMode === SelectionMode.Multiple && (_jsx("div", Object.assign({ className: styles.checkboxWrapper, onClick: onCheck, tabIndex: 0, role: 'checkbox', "aria-checked": checked, onKeyDown: handleKeyDown, "data-test-id": TEST_IDS.checkbox }, { children: _jsx(Checkbox, { size: Checkbox.sizes.S, checked: checked, indeterminate: indeterminate, tabIndex: -1 }) }))), onDelete && (_jsx(ButtonFunction, { "data-test-id": TEST_IDS.deleteButton, icon: _jsx(TrashSVG, {}), size: ButtonFunction.sizes.M, onClick: onDelete, disabled: !checked && !indeterminate }))] }));
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
16
  }
@@ -1,4 +1,4 @@
1
- export declare enum SelectionMode {
2
- Single = "single",
3
- Multiple = "multiple"
4
- }
1
+ export declare const SELECTION_MODE: {
2
+ readonly Single: "single";
3
+ readonly Multiple: "multiple";
4
+ };
@@ -1,5 +1,4 @@
1
- export var SelectionMode;
2
- (function (SelectionMode) {
3
- SelectionMode["Single"] = "single";
4
- SelectionMode["Multiple"] = "multiple";
5
- })(SelectionMode || (SelectionMode = {}));
1
+ export const SELECTION_MODE = {
2
+ Single: 'single',
3
+ Multiple: 'multiple',
4
+ };
@@ -1,2 +1,3 @@
1
1
  export * from './DeleteAction';
2
2
  export * from './constants';
3
+ export * from './types';
@@ -1,2 +1,3 @@
1
1
  export * from './DeleteAction';
2
2
  export * from './constants';
3
+ export * from './types';
@@ -0,0 +1,3 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+ import { SELECTION_MODE } from './constants';
3
+ export type SelectionMode = ValueOf<typeof SELECTION_MODE>;
@@ -0,0 +1 @@
1
+ export {};
@@ -17,11 +17,11 @@ export function MoreActions({ moreActions }) {
17
17
  needsFocus,
18
18
  setNeedsFocus,
19
19
  });
20
- return (_jsx(Droplist, Object.assign({ open: isOpen, "data-test-id": TEST_IDS.droplist, onOpenChange: setIsOpen, placement: Droplist.placements.BottomEnd, onFocusLeave: onFocusLeave, firstElementRefCallback: firstElementRefCallback, useScroll: true, triggerRef: triggerRef, triggerElement: _jsx(ButtonFunction, { icon: _jsx(KebabSVG, { size: 24 }), size: ButtonFunction.sizes.M, onKeyDown: onKeyDown, "data-test-id": TEST_IDS.moreActionsButton }), size: Droplist.sizes.S }, { children: moreActions.map(item => (_createElement(Droplist.ItemSingle, Object.assign({}, item, { key: item.option, className: styles.item, onClick: e => {
20
+ return (_jsx(Droplist, { open: isOpen, "data-test-id": TEST_IDS.droplist, onOpenChange: setIsOpen, placement: 'bottom-end', onFocusLeave: onFocusLeave, firstElementRefCallback: firstElementRefCallback, useScroll: true, triggerRef: triggerRef, triggerElement: _jsx(ButtonFunction, { icon: _jsx(KebabSVG, { size: 24 }), size: 'm', onKeyDown: onKeyDown, "data-test-id": TEST_IDS.moreActionsButton }), size: 's', children: moreActions.map(item => (_createElement(Droplist.ItemSingle, Object.assign({}, item, { key: item.option, className: styles.item, onClick: e => {
21
21
  var _a;
22
22
  (_a = item.onClick) === null || _a === void 0 ? void 0 : _a.call(item, e);
23
23
  setIsOpen(false);
24
24
  setNeedsFocus(false);
25
25
  e.stopPropagation();
26
- }, "data-test-id": TEST_IDS.option })))) })));
26
+ }, "data-test-id": TEST_IDS.option })))) }));
27
27
  }
@@ -1,5 +1,5 @@
1
1
  export const TRIGGER_OPEN_DROPLIST_KEY_KEYS = [
2
- ' ',
2
+ ' ', // <- Space key
3
3
  'ArrowDown',
4
4
  ];
5
5
  export const TRIGGER_CLOSE_DROPLIST_KEY_CODES = ['Escape', 'Tab'];
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Toolbar",
7
- "version": "0.4.2",
7
+ "version": "0.5.1",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -32,13 +32,13 @@
32
32
  "license": "Apache-2.0",
33
33
  "scripts": {},
34
34
  "dependencies": {
35
- "@snack-uikit/button": "0.14.1",
36
- "@snack-uikit/droplist": "0.11.2",
37
- "@snack-uikit/icons": "0.19.0",
38
- "@snack-uikit/search": "0.5.2",
39
- "@snack-uikit/toggles": "0.8.1",
40
- "@snack-uikit/utils": "3.1.0",
35
+ "@snack-uikit/button": "0.15.0",
36
+ "@snack-uikit/droplist": "0.12.1",
37
+ "@snack-uikit/icons": "0.19.1",
38
+ "@snack-uikit/search": "0.6.1",
39
+ "@snack-uikit/toggles": "0.9.1",
40
+ "@snack-uikit/utils": "3.2.0",
41
41
  "classnames": "2.3.2"
42
42
  },
43
- "gitHead": "e124e31699926810648702f97db72413d7ebd2b2"
43
+ "gitHead": "62f43bf0cbfd611d0b746117400f67096b1790f6"
44
44
  }
@@ -6,7 +6,7 @@ import { SearchPrivate } from '@snack-uikit/search';
6
6
  import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
7
7
 
8
8
  import { TEST_IDS } from '../../constants';
9
- import { DeleteAction, MoreActions, SelectionMode, Separator } from '../../helperComponents';
9
+ import { DeleteAction, MoreActions, Separator } from '../../helperComponents';
10
10
  import { extractDeleteActionProps, extractSearchPrivateProps, isDeleteActionProps } from './helpers';
11
11
  import styles from './styles.module.scss';
12
12
  import { CheckedToolbarProps, DefaultToolbarProps } from './types';
@@ -27,7 +27,7 @@ export function Toolbar({ className, actions, outline, moreActions, onRefresh, .
27
27
  <>
28
28
  <ButtonFunction
29
29
  icon={<UpdateSVG />}
30
- size={ButtonFunction.sizes.M}
30
+ size='m'
31
31
  className={styles.updateButton}
32
32
  onClick={onRefresh}
33
33
  data-test-id={TEST_IDS.refreshButton}
@@ -39,7 +39,7 @@ export function Toolbar({ className, actions, outline, moreActions, onRefresh, .
39
39
  <SearchPrivate
40
40
  {...extractSearchPrivateProps(rest)}
41
41
  className={styles.search}
42
- size={SearchPrivate.sizes.M}
42
+ size='m'
43
43
  data-test-id={TEST_IDS.search}
44
44
  />
45
45
 
@@ -61,5 +61,3 @@ export function Toolbar({ className, actions, outline, moreActions, onRefresh, .
61
61
  </div>
62
62
  );
63
63
  }
64
-
65
- Toolbar.selectionModes = SelectionMode;
@@ -5,8 +5,9 @@ import { TrashSVG } from '@snack-uikit/icons';
5
5
  import { Checkbox } from '@snack-uikit/toggles';
6
6
 
7
7
  import { TEST_IDS } from '../../constants';
8
- import { SelectionMode } from './constants';
8
+ import { SELECTION_MODE } from './constants';
9
9
  import styles from './styles.module.scss';
10
+ import { SelectionMode } from './types';
10
11
 
11
12
  export type DeleteActionProps = {
12
13
  /** Колбек смены значения чекбокса*/
@@ -17,7 +18,7 @@ export type DeleteActionProps = {
17
18
  checked?: boolean;
18
19
  /** Состояние частичного выбора */
19
20
  indeterminate?: boolean;
20
- /** Режим выбора @default SelectionMode.Multiple*/
21
+ /** Режим выбора @default 'multiple'*/
21
22
  selectionMode?: SelectionMode;
22
23
  };
23
24
 
@@ -26,7 +27,7 @@ export function DeleteAction({
26
27
  onCheck,
27
28
  onDelete,
28
29
  indeterminate,
29
- selectionMode = SelectionMode.Multiple,
30
+ selectionMode = SELECTION_MODE.Multiple,
30
31
  }: DeleteActionProps) {
31
32
  const handleKeyDown = useCallback(
32
33
  (e: KeyboardEvent<HTMLDivElement>) => {
@@ -39,7 +40,7 @@ export function DeleteAction({
39
40
 
40
41
  return (
41
42
  <>
42
- {selectionMode === SelectionMode.Multiple && (
43
+ {selectionMode === SELECTION_MODE.Multiple && (
43
44
  <div
44
45
  className={styles.checkboxWrapper}
45
46
  onClick={onCheck}
@@ -49,7 +50,7 @@ export function DeleteAction({
49
50
  onKeyDown={handleKeyDown}
50
51
  data-test-id={TEST_IDS.checkbox}
51
52
  >
52
- <Checkbox size={Checkbox.sizes.S} checked={checked} indeterminate={indeterminate} tabIndex={-1} />
53
+ <Checkbox size='s' checked={checked} indeterminate={indeterminate} tabIndex={-1} />
53
54
  </div>
54
55
  )}
55
56
 
@@ -57,7 +58,7 @@ export function DeleteAction({
57
58
  <ButtonFunction
58
59
  data-test-id={TEST_IDS.deleteButton}
59
60
  icon={<TrashSVG />}
60
- size={ButtonFunction.sizes.M}
61
+ size='m'
61
62
  onClick={onDelete}
62
63
  disabled={!checked && !indeterminate}
63
64
  />
@@ -1,4 +1,4 @@
1
- export enum SelectionMode {
2
- Single = 'single',
3
- Multiple = 'multiple',
4
- }
1
+ export const SELECTION_MODE = {
2
+ Single: 'single',
3
+ Multiple: 'multiple',
4
+ } as const;
@@ -1,2 +1,3 @@
1
1
  export * from './DeleteAction';
2
2
  export * from './constants';
3
+ export * from './types';
@@ -0,0 +1,5 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+
3
+ import { SELECTION_MODE } from './constants';
4
+
5
+ export type SelectionMode = ValueOf<typeof SELECTION_MODE>;
@@ -32,7 +32,7 @@ export function MoreActions({ moreActions }: MoreActionsProps) {
32
32
  open={isOpen}
33
33
  data-test-id={TEST_IDS.droplist}
34
34
  onOpenChange={setIsOpen}
35
- placement={Droplist.placements.BottomEnd}
35
+ placement='bottom-end'
36
36
  onFocusLeave={onFocusLeave}
37
37
  firstElementRefCallback={firstElementRefCallback}
38
38
  useScroll
@@ -40,12 +40,12 @@ export function MoreActions({ moreActions }: MoreActionsProps) {
40
40
  triggerElement={
41
41
  <ButtonFunction
42
42
  icon={<KebabSVG size={24} />}
43
- size={ButtonFunction.sizes.M}
43
+ size='m'
44
44
  onKeyDown={onKeyDown}
45
45
  data-test-id={TEST_IDS.moreActionsButton}
46
46
  />
47
47
  }
48
- size={Droplist.sizes.S}
48
+ size='s'
49
49
  >
50
50
  {moreActions.map(item => (
51
51
  <Droplist.ItemSingle