@ozen-ui/kit 0.20.0 → 0.21.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 (25) hide show
  1. package/__inner__/cjs/components/Card/Card.js +1 -1
  2. package/__inner__/cjs/components/IconButton/IconButton.d.ts +5 -5
  3. package/__inner__/cjs/components/IconButton/IconButton.js +14 -6
  4. package/__inner__/cjs/components/Indicator/Indicator.css +1 -0
  5. package/__inner__/cjs/components/List/List.css +6 -1
  6. package/__inner__/cjs/components/List/components/ListItem/ListItem.css +1 -1
  7. package/__inner__/cjs/components/List/components/ListItemButton/ListItemButton.css +11 -11
  8. package/__inner__/cjs/components/List/components/ListItemButton/ListItemButton.d.ts +3 -0
  9. package/__inner__/cjs/components/List/components/ListItemButton/ListItemButton.js +2 -1
  10. package/__inner__/cjs/components/Menu/components/MenuItem/MenuItem.d.ts +0 -2
  11. package/__inner__/cjs/components/Menu/components/MenuItem/MenuItem.js +1 -1
  12. package/__inner__/cjs/hooks/useBoolean/useBoolean.d.ts +2 -3
  13. package/__inner__/esm/components/Card/Card.js +1 -1
  14. package/__inner__/esm/components/IconButton/IconButton.d.ts +5 -5
  15. package/__inner__/esm/components/IconButton/IconButton.js +14 -6
  16. package/__inner__/esm/components/Indicator/Indicator.css +1 -0
  17. package/__inner__/esm/components/List/List.css +6 -1
  18. package/__inner__/esm/components/List/components/ListItem/ListItem.css +1 -1
  19. package/__inner__/esm/components/List/components/ListItemButton/ListItemButton.css +11 -11
  20. package/__inner__/esm/components/List/components/ListItemButton/ListItemButton.d.ts +3 -0
  21. package/__inner__/esm/components/List/components/ListItemButton/ListItemButton.js +2 -1
  22. package/__inner__/esm/components/Menu/components/MenuItem/MenuItem.d.ts +0 -2
  23. package/__inner__/esm/components/Menu/components/MenuItem/MenuItem.js +2 -2
  24. package/__inner__/esm/hooks/useBoolean/useBoolean.d.ts +2 -3
  25. package/package.json +1 -1
@@ -28,7 +28,7 @@ exports.Card = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)(fu
28
28
  var _a = props.size, size = _a === void 0 ? 'm' : _a, _b = props.disabled, disabled = _b === void 0 ? false : _b, _c = props.interactive, interactive = _c === void 0 ? false : _c, _d = props.borderWidth, borderWidth = _d === void 0 ? 's' : _d, _e = props.borderVariant, borderVariant = _e === void 0 ? 'solid' : _e, _f = props.borderColor, borderColor = _f === void 0 ? 'standard' : _f, _g = props.backgroundColor, backgroundColor = _g === void 0 ? 'standard' : _g, _h = props.as, Tag = _h === void 0 ? 'div' : _h, className = props.className, children = props.children, other = tslib_1.__rest(props, ["size", "disabled", "interactive", "borderWidth", "borderVariant", "borderColor", "backgroundColor", "as", "className", "children"]);
29
29
  var shouldBeInteractive = !disabled && interactive;
30
30
  var shouldShowBorder = borderWidth !== 'none';
31
- return (react_1.default.createElement(Paper_1.Paper, tslib_1.__assign({ as: Tag, radius: matchBorderRadiusPaperToCard[size], background: matchBackgroundColorPaperToCard[backgroundColor] }, other, { ref: ref, "aria-disabled": disabled }, (shouldBeInteractive && { tabIndex: 0 }), { className: (0, exports.cnCard)(tslib_1.__assign({ size: size, disabled: disabled, interactive: shouldBeInteractive, backgroundColor: backgroundColor, borderWidth: borderWidth }, (shouldShowBorder && {
31
+ return (react_1.default.createElement(Paper_1.Paper, tslib_1.__assign({ as: Tag, radius: matchBorderRadiusPaperToCard[size], background: matchBackgroundColorPaperToCard[backgroundColor] }, (shouldBeInteractive && { tabIndex: 0 }), { "aria-disabled": disabled }, other, { ref: ref, className: (0, exports.cnCard)(tslib_1.__assign({ size: size, disabled: disabled, interactive: shouldBeInteractive, backgroundColor: backgroundColor, borderWidth: borderWidth }, (shouldShowBorder && {
32
32
  borderVariant: borderVariant,
33
33
  borderColor: borderColor,
34
34
  })), [className]) }), children));
@@ -1,20 +1,20 @@
1
1
  import './IconButton.css';
2
- import React from 'react';
3
2
  import type { ElementType } from 'react';
4
3
  import type { IconSize, IconProps } from '@ozen-ui/icons';
5
4
  import type { FormElementSizeVariant } from '../../types/FormElementSizeVariant';
6
5
  import type { PolymorphicComponentPropsWithoutRef } from '../../utils/polymorphicComponentWithRef';
6
+ import type { RenderContentType } from '../../utils/renderContent';
7
7
  import { ICON_BUTTON_DEFAULT_TAG } from './constants';
8
8
  export declare const iconButtonColorVariant: readonly ["primary", "secondary"];
9
9
  export declare const iconButtonVariant: readonly ["contained", "outlined", "ghost", "function", "floating"];
10
10
  export type IconButtonVariant = (typeof iconButtonVariant)[number];
11
11
  export type IconButtonColorVariant = (typeof iconButtonColorVariant)[number];
12
- export type IconButtonIconProps = {
12
+ export type IconButtonIcon = RenderContentType<IconProps & {
13
13
  size?: IconSize;
14
- };
14
+ }>['content'];
15
15
  type IconButtonBaseProps = {
16
16
  /** Иконка */
17
- icon: React.FC<IconProps & IconButtonIconProps>;
17
+ icon: IconButtonIcon;
18
18
  /** Вариант представления компонента */
19
19
  variant?: IconButtonVariant;
20
20
  /** Размер */
@@ -31,9 +31,9 @@ type IconButtonBaseProps = {
31
31
  loading?: boolean;
32
32
  /** Дополнительные CSS-классы */
33
33
  className?: string;
34
- children?: never;
35
34
  /** Если {true} делает компонент круглым */
36
35
  rounded?: boolean;
36
+ children?: never;
37
37
  };
38
38
  export type IconButtonProps<As extends ElementType = typeof ICON_BUTTON_DEFAULT_TAG> = PolymorphicComponentPropsWithoutRef<IconButtonBaseProps, As>;
39
39
  export declare const cnIconButton: import("@bem-react/classname").ClassNameFormatter;
@@ -4,11 +4,11 @@ exports.IconButton = exports.cnIconButton = exports.iconButtonVariant = exports.
4
4
  var tslib_1 = require("tslib");
5
5
  require("./IconButton.css");
6
6
  var react_1 = tslib_1.__importStar(require("react"));
7
- var react_is_1 = require("react-is");
8
7
  var useThemeProps_1 = require("../../hooks/useThemeProps");
9
8
  var classname_1 = require("../../utils/classname");
10
9
  var getIconSizeToFormElement_1 = require("../../utils/getIconSizeToFormElement");
11
10
  var polymorphicComponentWithRef_1 = require("../../utils/polymorphicComponentWithRef");
11
+ var renderContent_1 = require("../../utils/renderContent");
12
12
  var Loader_1 = require("../Loader");
13
13
  var constants_1 = require("./constants");
14
14
  exports.iconButtonColorVariant = ['primary', 'secondary'];
@@ -32,23 +32,31 @@ exports.IconButton = (0, polymorphicComponentWithRef_1.polymorphicComponentWithR
32
32
  props: inProps,
33
33
  name: 'IconButton',
34
34
  });
35
- var _a = props.size, size = _a === void 0 ? constants_1.ICON_BUTTON_DEFAULT_SIZE : _a, _b = props.variant, variant = _b === void 0 ? constants_1.ICON_BUTTON_DEFAULT_VARIANT : _b, _c = props.color, color = _c === void 0 ? constants_1.ICON_BUTTON_DEFAULT_COLOR : _c, _d = props.as, Tag = _d === void 0 ? constants_1.ICON_BUTTON_DEFAULT_TAG : _d, iconColor = props.iconColor, compressed = props.compressed, loading = props.loading, disabled = props.disabled, className = props.className, Icon = props.icon, onClick = props.onClick, rounded = props.rounded, other = tslib_1.__rest(props, ["size", "variant", "color", "as", "iconColor", "compressed", "loading", "disabled", "className", "icon", "onClick", "rounded"]);
36
- var iconSize = (0, getIconSizeToFormElement_1.getIconSizeToFormElement)(size);
35
+ var _a = props.size, size = _a === void 0 ? constants_1.ICON_BUTTON_DEFAULT_SIZE : _a, _b = props.variant, variant = _b === void 0 ? constants_1.ICON_BUTTON_DEFAULT_VARIANT : _b, _c = props.color, color = _c === void 0 ? constants_1.ICON_BUTTON_DEFAULT_COLOR : _c, _d = props.as, Tag = _d === void 0 ? constants_1.ICON_BUTTON_DEFAULT_TAG : _d, iconColor = props.iconColor, compressed = props.compressed, loading = props.loading, disabled = props.disabled, className = props.className, icon = props.icon, onClick = props.onClick, rounded = props.rounded, other = tslib_1.__rest(props, ["size", "variant", "color", "as", "iconColor", "compressed", "loading", "disabled", "className", "icon", "onClick", "rounded"]);
37
36
  var isInteractionPrevented = disabled || loading;
38
37
  var handleClick = function (event) {
39
38
  if (onClick && !disabled && !loading) {
40
39
  onClick(event);
41
40
  }
42
41
  };
42
+ var renderIcon = function (content) {
43
+ return (0, renderContent_1.renderContent)({
44
+ content: content,
45
+ props: {
46
+ size: (0, getIconSizeToFormElement_1.getIconSizeToFormElement)(size),
47
+ color: iconColor,
48
+ },
49
+ });
50
+ };
43
51
  var resolvedChildren = (0, react_1.useMemo)(function () {
44
52
  if (loading) {
45
53
  return (react_1.default.createElement(Loader_1.Loader, { className: (0, exports.cnIconButton)('Loader'), color: "var(--color-content-disabled)", size: loaderSizeMapper[size] }));
46
54
  }
47
- if ((0, react_is_1.isValidElementType)(Icon)) {
48
- return react_1.default.createElement(Icon, { size: iconSize, color: iconColor });
55
+ if (icon) {
56
+ return renderIcon(icon);
49
57
  }
50
58
  return null;
51
- }, [loading, size, iconColor, iconSize, Icon]);
59
+ }, [loading, size, iconColor, icon, renderIcon]);
52
60
  return (react_1.default.createElement(Tag, tslib_1.__assign({ className: (0, exports.cnIconButton)({
53
61
  variant: variant,
54
62
  size: size,
@@ -3,6 +3,7 @@
3
3
  inline-size: var(--indicator-size);
4
4
  block-size: var(--indicator-size);
5
5
  border-radius: calc(var(--indicator-size) / 2);
6
+ flex-shrink: 0;
6
7
  }
7
8
 
8
9
  .Indicator_variant_neutral {
@@ -1,6 +1,11 @@
1
1
  .List {
2
+ --list-item-color: var(--color-content-primary);
2
3
  --list-item-border-radius: var(--border-radius-xs);
3
- --list-pipka-background-color: var(--color-content-action);
4
+ --list-item-bg-color: transparent;
5
+ --list-item-bg-color-hover: var(--color-background-main-hover);
6
+ --list-item-bg-color-active: var(--color-background-main-pressed);
7
+ --list-item-bg-color-disabled: var(--color-content-tertiary);
8
+ --list-pipka-bg-color: var(--color-content-action);
4
9
  --list-pipka-border-radius: 0 var(--border-radius-xs) var(--border-radius-xs)
5
10
  0;
6
11
  display: flex;
@@ -4,7 +4,7 @@
4
4
  min-block-size: var(--list-item-min-height);
5
5
  padding: var(--list-item-padding);
6
6
  border-radius: var(--list-item-border-radius);
7
- color: var(--color-content-primary);
7
+ color: var(--list-item-color);
8
8
  box-sizing: border-box;
9
9
  flex-shrink: 0;
10
10
  margin: 0 var(--list-gutter);
@@ -1,31 +1,31 @@
1
1
  .ListItemButton {
2
2
  inline-size: calc(100% - 2 * var(--list-gutter));
3
+ min-block-size: var(--list-item-min-height);
4
+ padding: var(--list-item-padding);
5
+ color: var(--list-item-color);
6
+ border-radius: var(--list-item-border-radius);
7
+ background-color: var(--list-item-bg-color);
8
+ margin: 0 var(--list-gutter);
9
+ transition: background-color var(--transition-default);
3
10
  display: flex;
4
11
  flex-shrink: 0;
5
12
  align-items: center;
6
13
  box-sizing: border-box;
7
- min-block-size: var(--list-item-min-height);
8
- padding: var(--list-item-padding);
9
- color: var(--color-content-primary);
10
14
  outline: none;
11
15
  text-decoration: none;
12
- border-radius: var(--list-item-border-radius);
13
- transition: background-color var(--transition-default);
14
16
  text-align: start;
15
- background-color: transparent;
16
17
  cursor: pointer;
17
18
  overflow: hidden;
18
19
  -webkit-tap-highlight-color: transparent;
19
- margin: 0 var(--list-gutter);
20
20
  border: none;
21
21
  }
22
22
 
23
23
  .ListItemButton:hover {
24
- background-color: var(--color-background-main-hover);
24
+ background-color: var(--list-item-bg-color-hover);
25
25
  }
26
26
 
27
27
  .ListItemButton:active {
28
- background-color: var(--color-background-main-pressed);
28
+ background-color: var(--list-item-bg-color-active);
29
29
  }
30
30
 
31
31
  .ListItemButton:focus {
@@ -38,7 +38,7 @@
38
38
 
39
39
  .ListItemButton_disabled {
40
40
  pointer-events: none;
41
- color: var(--color-content-tertiary);
41
+ color: var(--list-item-bg-color-disabled);
42
42
  }
43
43
 
44
44
  .ListItemButton_disabled .ListItemText-TextPrimary,
@@ -50,7 +50,7 @@
50
50
  content: '';
51
51
  inline-size: var(--list-pipka-width);
52
52
  block-size: var(--list-pipka-height);
53
- background-color: var(--list-pipka-background-color);
53
+ background-color: var(--list-pipka-bg-color);
54
54
  border-radius: var(--list-pipka-border-radius);
55
55
  position: absolute;
56
56
  inset-inline-start: 0;
@@ -8,6 +8,9 @@ export type ListItemButtonBaseProps = {
8
8
  children?: ReactNode;
9
9
  /** Если {true} делает элемент неактивным */
10
10
  disabled?: boolean;
11
+ /** Если {true} отображает элемент списка как выбранный */
12
+ selected?: boolean;
13
+ /** Идентификатор компонента для тестов */
11
14
  'data-testid'?: string;
12
15
  };
13
16
  export type ListItemButtonProps<As extends ElementType = typeof LIST_ITEM_BUTTON_DEFAULT_TAG> = PolymorphicComponentPropsWithoutRef<ListItemButtonBaseProps, As>;
@@ -12,7 +12,7 @@ var constants_1 = require("../../constants");
12
12
  exports.cnListItemButton = (0, classname_1.cn)('ListItemButton');
13
13
  exports.ListItemButton = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)(function (inProps, ref) {
14
14
  var props = (0, useThemeProps_1.useThemeProps)({ props: inProps, name: 'ListItemButton' });
15
- var _a = props.as, Tag = _a === void 0 ? constants_1.LIST_ITEM_BUTTON_DEFAULT_TAG : _a, children = props.children, disabled = props.disabled, className = props.className, onClick = props.onClick, tabIndexProp = props.tabIndex, onKeyDownProp = props.onKeyDown, other = tslib_1.__rest(props, ["as", "children", "disabled", "className", "onClick", "tabIndex", "onKeyDown"]);
15
+ var _a = props.as, Tag = _a === void 0 ? constants_1.LIST_ITEM_BUTTON_DEFAULT_TAG : _a, children = props.children, disabled = props.disabled, className = props.className, onClick = props.onClick, tabIndexProp = props.tabIndex, onKeyDownProp = props.onKeyDown, selected = props.selected, other = tslib_1.__rest(props, ["as", "children", "disabled", "className", "onClick", "tabIndex", "onKeyDown", "selected"]);
16
16
  var tabIndex = (0, react_1.useMemo)(function () { return (!disabled ? 0 : -1); }, [disabled]);
17
17
  var handleClick = function (event) {
18
18
  if (!disabled)
@@ -44,6 +44,7 @@ exports.ListItemButton = (0, polymorphicComponentWithRef_1.polymorphicComponentW
44
44
  }, [Tag, handleKeyDown]);
45
45
  return (react_1.default.createElement(Tag, tslib_1.__assign({ className: (0, exports.cnListItemButton)({
46
46
  disabled: disabled,
47
+ selected: selected,
47
48
  }, [className]), onClick: handleClick, tabIndex: tabIndexProp || tabIndex }, additionalTagProps, other, { ref: ref }), children));
48
49
  });
49
50
  exports.ListItemButton.displayName = 'ListItemButton';
@@ -4,8 +4,6 @@ import { type ListItemButtonBaseProps } from '../../../List';
4
4
  import { LIST_ITEM_BUTTON_DEFAULT_TAG } from '../../../List/constants';
5
5
  export declare const cnMenuItem: import("@bem-react/classname").ClassNameFormatter;
6
6
  export type MenuItemBaseProps = ListItemButtonBaseProps & {
7
- /** Если {true} отображает элемент меню как выбранный */
8
- selected?: boolean;
9
7
  /** Используется для вычисления лейбла выбранного элемента меню в выпадающих списках */
10
8
  label?: string;
11
9
  /** Используется для вычисления значения выбранного элемента меню в выпадающих списках */
@@ -20,6 +20,6 @@ exports.MenuItem = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef
20
20
  (_a = innerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
21
21
  }
22
22
  }, [autoFocus, disabled]);
23
- return (react_1.default.createElement(List_1.ListItemButton, tslib_1.__assign({ role: "menuitem", as: Tag, disabled: disabled }, other, { ref: (0, useMultiRef_1.useMultiRef)([ref, innerRef]), className: (0, List_1.cnListItemButton)({ selected: selected }, [className, (0, exports.cnMenuItem)()]), "data-value": value, "data-label": label }), children));
23
+ return (react_1.default.createElement(List_1.ListItemButton, tslib_1.__assign({ role: "menuitem", as: Tag, disabled: disabled, selected: selected }, other, { ref: (0, useMultiRef_1.useMultiRef)([ref, innerRef]), className: (0, exports.cnMenuItem)('', [className]), "data-value": value, "data-label": label }), children));
24
24
  });
25
25
  exports.MenuItem.displayName = 'MenuItem';
@@ -1,4 +1,4 @@
1
- type UseBooleanControllers = {
1
+ export type UseBooleanControllers = {
2
2
  /** Установить значение в {true} */
3
3
  on: () => void;
4
4
  /** Установить значение в {false} */
@@ -6,8 +6,7 @@ type UseBooleanControllers = {
6
6
  /** Перевести значение в противоположное состояние */
7
7
  toggle: () => void;
8
8
  };
9
- type UseBooleanReturnValue = [boolean, UseBooleanControllers];
9
+ export type UseBooleanReturnValue = [boolean, UseBooleanControllers];
10
10
  export declare function useBoolean(
11
11
  /** Значение по умолчанию */
12
12
  defaultValue?: boolean): UseBooleanReturnValue;
13
- export {};
@@ -25,7 +25,7 @@ export var Card = polymorphicComponentWithRef(function (inProps, ref) {
25
25
  var _a = props.size, size = _a === void 0 ? 'm' : _a, _b = props.disabled, disabled = _b === void 0 ? false : _b, _c = props.interactive, interactive = _c === void 0 ? false : _c, _d = props.borderWidth, borderWidth = _d === void 0 ? 's' : _d, _e = props.borderVariant, borderVariant = _e === void 0 ? 'solid' : _e, _f = props.borderColor, borderColor = _f === void 0 ? 'standard' : _f, _g = props.backgroundColor, backgroundColor = _g === void 0 ? 'standard' : _g, _h = props.as, Tag = _h === void 0 ? 'div' : _h, className = props.className, children = props.children, other = __rest(props, ["size", "disabled", "interactive", "borderWidth", "borderVariant", "borderColor", "backgroundColor", "as", "className", "children"]);
26
26
  var shouldBeInteractive = !disabled && interactive;
27
27
  var shouldShowBorder = borderWidth !== 'none';
28
- return (React.createElement(Paper, __assign({ as: Tag, radius: matchBorderRadiusPaperToCard[size], background: matchBackgroundColorPaperToCard[backgroundColor] }, other, { ref: ref, "aria-disabled": disabled }, (shouldBeInteractive && { tabIndex: 0 }), { className: cnCard(__assign({ size: size, disabled: disabled, interactive: shouldBeInteractive, backgroundColor: backgroundColor, borderWidth: borderWidth }, (shouldShowBorder && {
28
+ return (React.createElement(Paper, __assign({ as: Tag, radius: matchBorderRadiusPaperToCard[size], background: matchBackgroundColorPaperToCard[backgroundColor] }, (shouldBeInteractive && { tabIndex: 0 }), { "aria-disabled": disabled }, other, { ref: ref, className: cnCard(__assign({ size: size, disabled: disabled, interactive: shouldBeInteractive, backgroundColor: backgroundColor, borderWidth: borderWidth }, (shouldShowBorder && {
29
29
  borderVariant: borderVariant,
30
30
  borderColor: borderColor,
31
31
  })), [className]) }), children));
@@ -1,20 +1,20 @@
1
1
  import './IconButton.css';
2
- import React from 'react';
3
2
  import type { ElementType } from 'react';
4
3
  import type { IconSize, IconProps } from '@ozen-ui/icons';
5
4
  import type { FormElementSizeVariant } from '../../types/FormElementSizeVariant';
6
5
  import type { PolymorphicComponentPropsWithoutRef } from '../../utils/polymorphicComponentWithRef';
6
+ import type { RenderContentType } from '../../utils/renderContent';
7
7
  import { ICON_BUTTON_DEFAULT_TAG } from './constants';
8
8
  export declare const iconButtonColorVariant: readonly ["primary", "secondary"];
9
9
  export declare const iconButtonVariant: readonly ["contained", "outlined", "ghost", "function", "floating"];
10
10
  export type IconButtonVariant = (typeof iconButtonVariant)[number];
11
11
  export type IconButtonColorVariant = (typeof iconButtonColorVariant)[number];
12
- export type IconButtonIconProps = {
12
+ export type IconButtonIcon = RenderContentType<IconProps & {
13
13
  size?: IconSize;
14
- };
14
+ }>['content'];
15
15
  type IconButtonBaseProps = {
16
16
  /** Иконка */
17
- icon: React.FC<IconProps & IconButtonIconProps>;
17
+ icon: IconButtonIcon;
18
18
  /** Вариант представления компонента */
19
19
  variant?: IconButtonVariant;
20
20
  /** Размер */
@@ -31,9 +31,9 @@ type IconButtonBaseProps = {
31
31
  loading?: boolean;
32
32
  /** Дополнительные CSS-классы */
33
33
  className?: string;
34
- children?: never;
35
34
  /** Если {true} делает компонент круглым */
36
35
  rounded?: boolean;
36
+ children?: never;
37
37
  };
38
38
  export type IconButtonProps<As extends ElementType = typeof ICON_BUTTON_DEFAULT_TAG> = PolymorphicComponentPropsWithoutRef<IconButtonBaseProps, As>;
39
39
  export declare const cnIconButton: import("@bem-react/classname").ClassNameFormatter;
@@ -1,11 +1,11 @@
1
1
  import { __assign, __rest } from "tslib";
2
2
  import './IconButton.css';
3
3
  import React, { useMemo } from 'react';
4
- import { isValidElementType } from 'react-is';
5
4
  import { useThemeProps } from '../../hooks/useThemeProps';
6
5
  import { cn } from '../../utils/classname';
7
6
  import { getIconSizeToFormElement } from '../../utils/getIconSizeToFormElement';
8
7
  import { polymorphicComponentWithRef } from '../../utils/polymorphicComponentWithRef';
8
+ import { renderContent } from '../../utils/renderContent';
9
9
  import { Loader } from '../Loader';
10
10
  import { ICON_BUTTON_DEFAULT_SIZE, ICON_BUTTON_DEFAULT_VARIANT, ICON_BUTTON_DEFAULT_COLOR, ICON_BUTTON_DEFAULT_TAG, } from './constants';
11
11
  export var iconButtonColorVariant = ['primary', 'secondary'];
@@ -29,23 +29,31 @@ export var IconButton = polymorphicComponentWithRef(function (inProps, ref) {
29
29
  props: inProps,
30
30
  name: 'IconButton',
31
31
  });
32
- var _a = props.size, size = _a === void 0 ? ICON_BUTTON_DEFAULT_SIZE : _a, _b = props.variant, variant = _b === void 0 ? ICON_BUTTON_DEFAULT_VARIANT : _b, _c = props.color, color = _c === void 0 ? ICON_BUTTON_DEFAULT_COLOR : _c, _d = props.as, Tag = _d === void 0 ? ICON_BUTTON_DEFAULT_TAG : _d, iconColor = props.iconColor, compressed = props.compressed, loading = props.loading, disabled = props.disabled, className = props.className, Icon = props.icon, onClick = props.onClick, rounded = props.rounded, other = __rest(props, ["size", "variant", "color", "as", "iconColor", "compressed", "loading", "disabled", "className", "icon", "onClick", "rounded"]);
33
- var iconSize = getIconSizeToFormElement(size);
32
+ var _a = props.size, size = _a === void 0 ? ICON_BUTTON_DEFAULT_SIZE : _a, _b = props.variant, variant = _b === void 0 ? ICON_BUTTON_DEFAULT_VARIANT : _b, _c = props.color, color = _c === void 0 ? ICON_BUTTON_DEFAULT_COLOR : _c, _d = props.as, Tag = _d === void 0 ? ICON_BUTTON_DEFAULT_TAG : _d, iconColor = props.iconColor, compressed = props.compressed, loading = props.loading, disabled = props.disabled, className = props.className, icon = props.icon, onClick = props.onClick, rounded = props.rounded, other = __rest(props, ["size", "variant", "color", "as", "iconColor", "compressed", "loading", "disabled", "className", "icon", "onClick", "rounded"]);
34
33
  var isInteractionPrevented = disabled || loading;
35
34
  var handleClick = function (event) {
36
35
  if (onClick && !disabled && !loading) {
37
36
  onClick(event);
38
37
  }
39
38
  };
39
+ var renderIcon = function (content) {
40
+ return renderContent({
41
+ content: content,
42
+ props: {
43
+ size: getIconSizeToFormElement(size),
44
+ color: iconColor,
45
+ },
46
+ });
47
+ };
40
48
  var resolvedChildren = useMemo(function () {
41
49
  if (loading) {
42
50
  return (React.createElement(Loader, { className: cnIconButton('Loader'), color: "var(--color-content-disabled)", size: loaderSizeMapper[size] }));
43
51
  }
44
- if (isValidElementType(Icon)) {
45
- return React.createElement(Icon, { size: iconSize, color: iconColor });
52
+ if (icon) {
53
+ return renderIcon(icon);
46
54
  }
47
55
  return null;
48
- }, [loading, size, iconColor, iconSize, Icon]);
56
+ }, [loading, size, iconColor, icon, renderIcon]);
49
57
  return (React.createElement(Tag, __assign({ className: cnIconButton({
50
58
  variant: variant,
51
59
  size: size,
@@ -3,6 +3,7 @@
3
3
  inline-size: var(--indicator-size);
4
4
  block-size: var(--indicator-size);
5
5
  border-radius: calc(var(--indicator-size) / 2);
6
+ flex-shrink: 0;
6
7
  }
7
8
 
8
9
  .Indicator_variant_neutral {
@@ -1,6 +1,11 @@
1
1
  .List {
2
+ --list-item-color: var(--color-content-primary);
2
3
  --list-item-border-radius: var(--border-radius-xs);
3
- --list-pipka-background-color: var(--color-content-action);
4
+ --list-item-bg-color: transparent;
5
+ --list-item-bg-color-hover: var(--color-background-main-hover);
6
+ --list-item-bg-color-active: var(--color-background-main-pressed);
7
+ --list-item-bg-color-disabled: var(--color-content-tertiary);
8
+ --list-pipka-bg-color: var(--color-content-action);
4
9
  --list-pipka-border-radius: 0 var(--border-radius-xs) var(--border-radius-xs)
5
10
  0;
6
11
  display: flex;
@@ -4,7 +4,7 @@
4
4
  min-block-size: var(--list-item-min-height);
5
5
  padding: var(--list-item-padding);
6
6
  border-radius: var(--list-item-border-radius);
7
- color: var(--color-content-primary);
7
+ color: var(--list-item-color);
8
8
  box-sizing: border-box;
9
9
  flex-shrink: 0;
10
10
  margin: 0 var(--list-gutter);
@@ -1,31 +1,31 @@
1
1
  .ListItemButton {
2
2
  inline-size: calc(100% - 2 * var(--list-gutter));
3
+ min-block-size: var(--list-item-min-height);
4
+ padding: var(--list-item-padding);
5
+ color: var(--list-item-color);
6
+ border-radius: var(--list-item-border-radius);
7
+ background-color: var(--list-item-bg-color);
8
+ margin: 0 var(--list-gutter);
9
+ transition: background-color var(--transition-default);
3
10
  display: flex;
4
11
  flex-shrink: 0;
5
12
  align-items: center;
6
13
  box-sizing: border-box;
7
- min-block-size: var(--list-item-min-height);
8
- padding: var(--list-item-padding);
9
- color: var(--color-content-primary);
10
14
  outline: none;
11
15
  text-decoration: none;
12
- border-radius: var(--list-item-border-radius);
13
- transition: background-color var(--transition-default);
14
16
  text-align: start;
15
- background-color: transparent;
16
17
  cursor: pointer;
17
18
  overflow: hidden;
18
19
  -webkit-tap-highlight-color: transparent;
19
- margin: 0 var(--list-gutter);
20
20
  border: none;
21
21
  }
22
22
 
23
23
  .ListItemButton:hover {
24
- background-color: var(--color-background-main-hover);
24
+ background-color: var(--list-item-bg-color-hover);
25
25
  }
26
26
 
27
27
  .ListItemButton:active {
28
- background-color: var(--color-background-main-pressed);
28
+ background-color: var(--list-item-bg-color-active);
29
29
  }
30
30
 
31
31
  .ListItemButton:focus {
@@ -38,7 +38,7 @@
38
38
 
39
39
  .ListItemButton_disabled {
40
40
  pointer-events: none;
41
- color: var(--color-content-tertiary);
41
+ color: var(--list-item-bg-color-disabled);
42
42
  }
43
43
 
44
44
  .ListItemButton_disabled .ListItemText-TextPrimary,
@@ -50,7 +50,7 @@
50
50
  content: '';
51
51
  inline-size: var(--list-pipka-width);
52
52
  block-size: var(--list-pipka-height);
53
- background-color: var(--list-pipka-background-color);
53
+ background-color: var(--list-pipka-bg-color);
54
54
  border-radius: var(--list-pipka-border-radius);
55
55
  position: absolute;
56
56
  inset-inline-start: 0;
@@ -8,6 +8,9 @@ export type ListItemButtonBaseProps = {
8
8
  children?: ReactNode;
9
9
  /** Если {true} делает элемент неактивным */
10
10
  disabled?: boolean;
11
+ /** Если {true} отображает элемент списка как выбранный */
12
+ selected?: boolean;
13
+ /** Идентификатор компонента для тестов */
11
14
  'data-testid'?: string;
12
15
  };
13
16
  export type ListItemButtonProps<As extends ElementType = typeof LIST_ITEM_BUTTON_DEFAULT_TAG> = PolymorphicComponentPropsWithoutRef<ListItemButtonBaseProps, As>;
@@ -9,7 +9,7 @@ import { LIST_ITEM_BUTTON_DEFAULT_TAG } from '../../constants';
9
9
  export var cnListItemButton = cn('ListItemButton');
10
10
  export var ListItemButton = polymorphicComponentWithRef(function (inProps, ref) {
11
11
  var props = useThemeProps({ props: inProps, name: 'ListItemButton' });
12
- var _a = props.as, Tag = _a === void 0 ? LIST_ITEM_BUTTON_DEFAULT_TAG : _a, children = props.children, disabled = props.disabled, className = props.className, onClick = props.onClick, tabIndexProp = props.tabIndex, onKeyDownProp = props.onKeyDown, other = __rest(props, ["as", "children", "disabled", "className", "onClick", "tabIndex", "onKeyDown"]);
12
+ var _a = props.as, Tag = _a === void 0 ? LIST_ITEM_BUTTON_DEFAULT_TAG : _a, children = props.children, disabled = props.disabled, className = props.className, onClick = props.onClick, tabIndexProp = props.tabIndex, onKeyDownProp = props.onKeyDown, selected = props.selected, other = __rest(props, ["as", "children", "disabled", "className", "onClick", "tabIndex", "onKeyDown", "selected"]);
13
13
  var tabIndex = useMemo(function () { return (!disabled ? 0 : -1); }, [disabled]);
14
14
  var handleClick = function (event) {
15
15
  if (!disabled)
@@ -41,6 +41,7 @@ export var ListItemButton = polymorphicComponentWithRef(function (inProps, ref)
41
41
  }, [Tag, handleKeyDown]);
42
42
  return (React.createElement(Tag, __assign({ className: cnListItemButton({
43
43
  disabled: disabled,
44
+ selected: selected,
44
45
  }, [className]), onClick: handleClick, tabIndex: tabIndexProp || tabIndex }, additionalTagProps, other, { ref: ref }), children));
45
46
  });
46
47
  ListItemButton.displayName = 'ListItemButton';
@@ -4,8 +4,6 @@ import { type ListItemButtonBaseProps } from '../../../List';
4
4
  import { LIST_ITEM_BUTTON_DEFAULT_TAG } from '../../../List/constants';
5
5
  export declare const cnMenuItem: import("@bem-react/classname").ClassNameFormatter;
6
6
  export type MenuItemBaseProps = ListItemButtonBaseProps & {
7
- /** Если {true} отображает элемент меню как выбранный */
8
- selected?: boolean;
9
7
  /** Используется для вычисления лейбла выбранного элемента меню в выпадающих списках */
10
8
  label?: string;
11
9
  /** Используется для вычисления значения выбранного элемента меню в выпадающих списках */
@@ -4,7 +4,7 @@ import { useMultiRef } from '../../../../hooks/useMultiRef';
4
4
  import { useThemeProps } from '../../../../hooks/useThemeProps';
5
5
  import { cn } from '../../../../utils/classname';
6
6
  import { polymorphicComponentWithRef, } from '../../../../utils/polymorphicComponentWithRef';
7
- import { cnListItemButton, ListItemButton, } from '../../../List';
7
+ import { ListItemButton } from '../../../List';
8
8
  import { LIST_ITEM_BUTTON_DEFAULT_TAG } from '../../../List/constants';
9
9
  export var cnMenuItem = cn('MenuItem');
10
10
  export var MenuItem = polymorphicComponentWithRef(function (inProps, ref) {
@@ -17,6 +17,6 @@ export var MenuItem = polymorphicComponentWithRef(function (inProps, ref) {
17
17
  (_a = innerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
18
18
  }
19
19
  }, [autoFocus, disabled]);
20
- return (React.createElement(ListItemButton, __assign({ role: "menuitem", as: Tag, disabled: disabled }, other, { ref: useMultiRef([ref, innerRef]), className: cnListItemButton({ selected: selected }, [className, cnMenuItem()]), "data-value": value, "data-label": label }), children));
20
+ return (React.createElement(ListItemButton, __assign({ role: "menuitem", as: Tag, disabled: disabled, selected: selected }, other, { ref: useMultiRef([ref, innerRef]), className: cnMenuItem('', [className]), "data-value": value, "data-label": label }), children));
21
21
  });
22
22
  MenuItem.displayName = 'MenuItem';
@@ -1,4 +1,4 @@
1
- type UseBooleanControllers = {
1
+ export type UseBooleanControllers = {
2
2
  /** Установить значение в {true} */
3
3
  on: () => void;
4
4
  /** Установить значение в {false} */
@@ -6,8 +6,7 @@ type UseBooleanControllers = {
6
6
  /** Перевести значение в противоположное состояние */
7
7
  toggle: () => void;
8
8
  };
9
- type UseBooleanReturnValue = [boolean, UseBooleanControllers];
9
+ export type UseBooleanReturnValue = [boolean, UseBooleanControllers];
10
10
  export declare function useBoolean(
11
11
  /** Значение по умолчанию */
12
12
  defaultValue?: boolean): UseBooleanReturnValue;
13
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ozen-ui/kit",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "React component library",
5
5
  "files": [
6
6
  "*"