@snack-uikit/toolbar 0.4.2 → 0.5.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 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.5.0 (2023-12-14)
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+
12
+ * **FF-3729:** replace enum with unions ([910db4a](https://github.com/cloud-ru-tech/snack-uikit/commit/910db4aa8231ccbc58e538e5c5c1f461b1dec275))
13
+
14
+
15
+
16
+
6
17
  ## 0.4.2 (2023-12-07)
7
18
 
8
19
  ### Only dependencies have been changed
@@ -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", Object.assign({ "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;
@@ -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", 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: '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,7 +17,7 @@ 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, Object.assign({ 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);
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.0",
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",
35
+ "@snack-uikit/button": "0.15.0",
36
+ "@snack-uikit/droplist": "0.12.0",
37
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",
38
+ "@snack-uikit/search": "0.6.0",
39
+ "@snack-uikit/toggles": "0.9.0",
40
+ "@snack-uikit/utils": "3.2.0",
41
41
  "classnames": "2.3.2"
42
42
  },
43
- "gitHead": "e124e31699926810648702f97db72413d7ebd2b2"
43
+ "gitHead": "bd39c5e674f3b91b0e2487782a04b15034cf3d8b"
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
  /** Колбек смены значения чекбокса*/
@@ -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