@ozen-ui/kit 0.18.0 → 0.19.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 (38) hide show
  1. package/ChipNext/package.json +5 -0
  2. package/__inner__/cjs/components/Chip/Chip.d.ts +3 -0
  3. package/__inner__/cjs/components/Chip/Chip.js +3 -0
  4. package/__inner__/cjs/components/ChipNext/Chip.css +108 -0
  5. package/__inner__/cjs/components/ChipNext/Chip.d.ts +42 -0
  6. package/__inner__/cjs/components/ChipNext/Chip.js +46 -0
  7. package/__inner__/cjs/components/ChipNext/constants.d.ts +4 -0
  8. package/__inner__/cjs/components/ChipNext/constants.js +7 -0
  9. package/__inner__/cjs/components/ChipNext/index.d.ts +1 -0
  10. package/__inner__/cjs/components/ChipNext/index.js +4 -0
  11. package/__inner__/cjs/components/FieldIcon/FieldIcon.d.ts +4 -7
  12. package/__inner__/cjs/components/FieldIcon/FieldIcon.js +5 -21
  13. package/__inner__/cjs/components/Modal/Modal.js +3 -7
  14. package/__inner__/cjs/components/Popover/Popover.js +1 -5
  15. package/__inner__/cjs/components/ThemeProvider/types.d.ts +2 -0
  16. package/__inner__/cjs/utils/renderContent/index.d.ts +1 -0
  17. package/__inner__/cjs/utils/renderContent/index.js +4 -0
  18. package/__inner__/cjs/utils/renderContent/renderContent.d.ts +6 -0
  19. package/__inner__/cjs/utils/renderContent/renderContent.js +29 -0
  20. package/__inner__/esm/components/Chip/Chip.d.ts +3 -0
  21. package/__inner__/esm/components/Chip/Chip.js +3 -0
  22. package/__inner__/esm/components/ChipNext/Chip.css +108 -0
  23. package/__inner__/esm/components/ChipNext/Chip.d.ts +42 -0
  24. package/__inner__/esm/components/ChipNext/Chip.js +43 -0
  25. package/__inner__/esm/components/ChipNext/constants.d.ts +4 -0
  26. package/__inner__/esm/components/ChipNext/constants.js +4 -0
  27. package/__inner__/esm/components/ChipNext/index.d.ts +1 -0
  28. package/__inner__/esm/components/ChipNext/index.js +1 -0
  29. package/__inner__/esm/components/FieldIcon/FieldIcon.d.ts +4 -7
  30. package/__inner__/esm/components/FieldIcon/FieldIcon.js +5 -21
  31. package/__inner__/esm/components/Modal/Modal.js +3 -7
  32. package/__inner__/esm/components/Popover/Popover.js +1 -5
  33. package/__inner__/esm/components/ThemeProvider/types.d.ts +2 -0
  34. package/__inner__/esm/utils/renderContent/index.d.ts +1 -0
  35. package/__inner__/esm/utils/renderContent/index.js +1 -0
  36. package/__inner__/esm/utils/renderContent/renderContent.d.ts +6 -0
  37. package/__inner__/esm/utils/renderContent/renderContent.js +25 -0
  38. package/package.json +1 -1
@@ -0,0 +1,5 @@
1
+ {
2
+ "main": "../__inner__/cjs/components/ChipNext/index.js",
3
+ "module": "../__inner__/esm/components/ChipNext/index.js",
4
+ "types": "../__inner__/esm/components/ChipNext/index.d.ts"
5
+ }
@@ -33,4 +33,7 @@ export type ChipBaseProps = {
33
33
  'data-testid'?: string;
34
34
  };
35
35
  export type ChipProps = ExtendableProps<InputHTMLAttributes<HTMLInputElement>, ChipBaseProps>;
36
+ /**
37
+ * @deprecated Компонент устарел. Для замены используйте компонент ChipNext
38
+ */
36
39
  export declare const Chip: React.ForwardRefExoticComponent<ChipBaseProps & Omit<React.InputHTMLAttributes<HTMLInputElement>, keyof ChipBaseProps> & React.RefAttributes<HTMLLabelElement>>;
@@ -11,6 +11,9 @@ var constants_1 = require("./constants");
11
11
  exports.cnChip = (0, classname_1.cn)('Chip');
12
12
  exports.chipSizeVariant = ['xs', 's', 'm', 'l'];
13
13
  exports.chipColorVariant = ['primary', 'secondary'];
14
+ /**
15
+ * @deprecated Компонент устарел. Для замены используйте компонент ChipNext
16
+ */
14
17
  exports.Chip = (0, react_1.forwardRef)(function (inProps, ref) {
15
18
  var _a = (0, useThemeProps_1.useThemeProps)({ name: 'Chip', props: inProps }), _b = _a.size, size = _b === void 0 ? constants_1.CHIP_DEFAULT_SIZE : _b, _c = _a.color, color = _c === void 0 ? constants_1.CHIP_DEFAULT_VARIANT : _c, _d = _a.disabled, disabled = _d === void 0 ? constants_1.CHIP_DEFAULT_DISABLED : _d, IconLeft = _a.iconLeft, IconRight = _a.iconRight, labelProps = _a.labelProps, inputRef = _a.inputRef, className = _a.className, children = _a.children, dataTestId = _a["data-testid"], other = tslib_1.__rest(_a, ["size", "color", "disabled", "iconLeft", "iconRight", "labelProps", "inputRef", "className", "children", 'data-testid']);
16
19
  var iconSize = (0, react_1.useMemo)(function () { return (0, getIconSizeToFormElement_1.getIconSizeToFormElement)(size); }, [size]);
@@ -0,0 +1,108 @@
1
+ /* stylelint-disable */
2
+ .ChipNext {
3
+ --chip-border-radius: 24px;
4
+ --chip-text-wrap: nowrap;
5
+ background-color: var(--chip-bg-color);
6
+ border-radius: var(--chip-border-radius);
7
+ min-block-size: var(--chip-height);
8
+ padding: 0 var(--chip-padding-x);
9
+ min-inline-size: var(--chip-min-width);
10
+ color: var(--chip-text-color);
11
+ gap: var(--space-s);
12
+ display: inline-flex;
13
+ justify-content: center;
14
+ align-items: center;
15
+ cursor: pointer;
16
+ box-sizing: border-box;
17
+ text-decoration: none;
18
+ border: none;
19
+ outline: none;
20
+ transition:
21
+ border-color var(--transition-default),
22
+ color var(--transition-default),
23
+ background-color var(--transition-default),
24
+ box-shadow var(--transition-default);
25
+ }
26
+ .ChipNext-Content {
27
+ overflow: hidden;
28
+ text-overflow: ellipsis;
29
+ white-space: var(--chip-text-wrap);
30
+ }
31
+ .ChipNext-Icon {
32
+ color: inherit;
33
+ flex-shrink: 0;
34
+ }
35
+ .ChipNext_multiline {
36
+ --chip-text-wrap: normal;
37
+ }
38
+ .ChipNext_size_xs {
39
+ font: var(--typography-text-2xs-font);
40
+ letter-spacing: var(--typography-text-2xs-letter_spacing, 0);
41
+ text-transform: var(--typography-text-2xs-text_transform, none);
42
+
43
+ --chip-min-width: 64px;
44
+ --chip-height: var(--space-xl);
45
+ --chip-padding-x: var(--space-m);
46
+ }
47
+ .ChipNext_size_s {
48
+ font: var(--typography-text-s-font);
49
+ letter-spacing: var(--typography-text-s-letter_spacing, 0);
50
+ text-transform: var(--typography-text-s-text_transform, none);
51
+
52
+ --chip-min-width: 72px;
53
+ --chip-height: var(--space-2xl);
54
+ --chip-padding-x: var(--space-l);
55
+ }
56
+ .ChipNext_size_m {
57
+ font: var(--typography-text-m-font);
58
+ letter-spacing: var(--typography-text-m-letter_spacing, 0);
59
+ text-transform: var(--typography-text-m-text_transform, none);
60
+
61
+ --chip-min-width: 80px;
62
+ --chip-height: var(--space-3xl);
63
+ --chip-padding-x: 20px;
64
+ }
65
+ .ChipNext_size_l {
66
+ font: var(--typography-text-l-font);
67
+ letter-spacing: var(--typography-text-l-letter_spacing, 0);
68
+ text-transform: var(--typography-text-l-text_transform, none);
69
+
70
+ --chip-min-width: 88px;
71
+ --chip-height: var(--space-4xl);
72
+ --chip-padding-x: var(--space-xl);
73
+ }
74
+ .ChipNext_color_primary {
75
+ --chip-bg-color: var(--color-background-action-light);
76
+ --chip-bg-color-hover: var(--color-background-action-light-hover);
77
+ --chip-bg-color-active: var(--color-background-action-light-pressed);
78
+ --chip-text-color: var(--color-content-action-dark);
79
+ }
80
+ .ChipNext_color_secondary {
81
+ --chip-bg-color: var(--color-background-secondary);
82
+ --chip-bg-color-hover: var(--color-background-secondary-hover);
83
+ --chip-bg-color-active: var(--color-background-secondary-pressed);
84
+ --chip-text-color: var(--color-content-primary);
85
+ }
86
+ .ChipNext:hover {
87
+ --chip-bg-color: var(--chip-bg-color-hover);
88
+ }
89
+ .ChipNext:active {
90
+ --chip-bg-color: var(--chip-bg-color-active);
91
+ }
92
+ .ChipNext:focus {
93
+ box-shadow: var(--shadow-outline-focused);
94
+ }
95
+ .ChipNext:focus:not(:focus-visible) {
96
+ box-shadow: none;
97
+ }
98
+ .ChipNext_checked,
99
+ .ChipNext_checked:hover,
100
+ .ChipNext_checked:active {
101
+ --chip-bg-color: var(--color-background-action);
102
+ --chip-text-color: var(--color-content-action-on);
103
+ }
104
+ .ChipNext_disabled {
105
+ --chip-bg-color: var(--color-background-disabled);
106
+ --chip-text-color: var(--color-content-disabled);
107
+ pointer-events: none;
108
+ }
@@ -0,0 +1,42 @@
1
+ import './Chip.css';
2
+ import type { ReactNode, MouseEvent, ElementType } from 'react';
3
+ import type { IconProps, IconSize } from '@ozen-ui/icons';
4
+ import type { PolymorphicComponentPropsWithRef } from '../../utils/polymorphicComponentWithRef';
5
+ import type { RenderContentType } from '../../utils/renderContent';
6
+ import { CHIP_DEFAULT_TAG } from './constants';
7
+ export declare const cnChip: import("@bem-react/classname").ClassNameFormatter;
8
+ export declare const chipSizeVariant: readonly ["xs", "s", "m", "l"];
9
+ export declare const chipColorVariant: readonly ["primary", "secondary"];
10
+ export type ChipSizeVariant = (typeof chipSizeVariant)[number];
11
+ export type ChipColorVariant = (typeof chipColorVariant)[number];
12
+ export type ChipIcon = RenderContentType<IconProps & {
13
+ size?: IconSize;
14
+ }>['content'];
15
+ export type ChipBaseProps = {
16
+ /** Размер компонента */
17
+ size?: ChipSizeVariant;
18
+ /** Вариант представления компонента */
19
+ color?: ChipColorVariant;
20
+ /** Если {true} компонент отображается как заблокированный */
21
+ disabled?: boolean;
22
+ /** Если {true} делает элемент выбранным */
23
+ checked?: boolean;
24
+ /** Обработчик нажатия */
25
+ onClick?: (e: MouseEvent<HTMLElement>, payload: {
26
+ checked: boolean;
27
+ }) => void;
28
+ /** Иконка слева */
29
+ iconLeft?: ChipIcon;
30
+ /** Иконка справа */
31
+ iconRight?: ChipIcon;
32
+ /** Если {true} разбивает длинный текст на несколько строк */
33
+ multiline?: boolean;
34
+ /** Дополнительные СSS-классы */
35
+ className?: string;
36
+ /** Содержимое компонента */
37
+ children?: ReactNode;
38
+ /** Идентификатор компонента для тестов */
39
+ 'data-testid'?: string;
40
+ };
41
+ export type ChipProps<As extends ElementType = typeof CHIP_DEFAULT_TAG> = PolymorphicComponentPropsWithRef<ChipBaseProps, As>;
42
+ export declare const Chip: import("../../utils/polymorphicComponentWithRef").PolymorphicComponentWithRef<ChipBaseProps, "button">;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Chip = exports.chipColorVariant = exports.chipSizeVariant = exports.cnChip = void 0;
4
+ var tslib_1 = require("tslib");
5
+ require("./Chip.css");
6
+ var react_1 = tslib_1.__importDefault(require("react"));
7
+ var useControlled_1 = require("../../hooks/useControlled");
8
+ var useThemeProps_1 = require("../../hooks/useThemeProps");
9
+ var classname_1 = require("../../utils/classname");
10
+ var getIconSizeToFormElement_1 = require("../../utils/getIconSizeToFormElement");
11
+ var polymorphicComponentWithRef_1 = require("../../utils/polymorphicComponentWithRef");
12
+ var renderContent_1 = require("../../utils/renderContent");
13
+ var constants_1 = require("./constants");
14
+ exports.cnChip = (0, classname_1.cn)('ChipNext');
15
+ exports.chipSizeVariant = ['xs', 's', 'm', 'l'];
16
+ exports.chipColorVariant = ['primary', 'secondary'];
17
+ exports.Chip = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)(function (inProps, ref) {
18
+ var _a = (0, useThemeProps_1.useThemeProps)({ name: 'ChipNext', props: inProps }), _b = _a.size, size = _b === void 0 ? constants_1.CHIP_DEFAULT_SIZE : _b, _c = _a.color, color = _c === void 0 ? constants_1.CHIP_DEFAULT_VARIANT : _c, _d = _a.disabled, disabled = _d === void 0 ? constants_1.CHIP_DEFAULT_DISABLED : _d, iconLeft = _a.iconLeft, iconRight = _a.iconRight, multiline = _a.multiline, className = _a.className, children = _a.children, onClick = _a.onClick, checkedProp = _a.checked, _e = _a.as, Tag = _e === void 0 ? constants_1.CHIP_DEFAULT_TAG : _e, dataTestId = _a["data-testid"], other = tslib_1.__rest(_a, ["size", "color", "disabled", "iconLeft", "iconRight", "multiline", "className", "children", "onClick", "checked", "as", 'data-testid']);
19
+ var _f = tslib_1.__read((0, useControlled_1.useControlled)({
20
+ value: checkedProp,
21
+ defaultValue: false,
22
+ name: 'ChipNext',
23
+ state: 'open',
24
+ }), 2), checkedState = _f[0], setCheckedState = _f[1];
25
+ var handleClick = function (event) {
26
+ if (disabled) {
27
+ return;
28
+ }
29
+ setCheckedState(!checkedState);
30
+ onClick === null || onClick === void 0 ? void 0 : onClick(event, { checked: !checkedState });
31
+ };
32
+ var renderIcon = function (content) {
33
+ return (0, renderContent_1.renderContent)({
34
+ content: content,
35
+ props: {
36
+ size: (0, getIconSizeToFormElement_1.getIconSizeToFormElement)(size),
37
+ className: (0, exports.cnChip)('Icon'),
38
+ },
39
+ });
40
+ };
41
+ return (react_1.default.createElement(Tag, tslib_1.__assign({ type: "button", "data-testid": dataTestId, disabled: disabled }, other, { className: (0, exports.cnChip)({ size: size, disabled: disabled, color: color, multiline: multiline, checked: checkedState }, [className]), onClick: handleClick, ref: ref }),
42
+ renderIcon(iconLeft),
43
+ children && react_1.default.createElement("span", { className: (0, exports.cnChip)('Content') }, children),
44
+ renderIcon(iconRight)));
45
+ });
46
+ exports.Chip.displayName = 'Chip';
@@ -0,0 +1,4 @@
1
+ export declare const CHIP_DEFAULT_TAG = "button";
2
+ export declare const CHIP_DEFAULT_VARIANT = "primary";
3
+ export declare const CHIP_DEFAULT_SIZE = "m";
4
+ export declare const CHIP_DEFAULT_DISABLED = false;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CHIP_DEFAULT_DISABLED = exports.CHIP_DEFAULT_SIZE = exports.CHIP_DEFAULT_VARIANT = exports.CHIP_DEFAULT_TAG = void 0;
4
+ exports.CHIP_DEFAULT_TAG = 'button';
5
+ exports.CHIP_DEFAULT_VARIANT = 'primary';
6
+ exports.CHIP_DEFAULT_SIZE = 'm';
7
+ exports.CHIP_DEFAULT_DISABLED = false;
@@ -0,0 +1 @@
1
+ export * from './Chip';
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./Chip"), exports);
@@ -1,18 +1,15 @@
1
1
  import './FieldIcon.css';
2
- import type { ComponentPropsWithRef, ComponentRef, FC, ReactElement } from 'react';
2
+ import type { ComponentPropsWithRef, ComponentRef } from 'react';
3
3
  import React from 'react';
4
4
  import type { IconProps, IconSize } from '@ozen-ui/icons';
5
5
  import type { FormElementSizeVariant } from '../../types/FormElementSizeVariant';
6
+ import type { RenderContentType } from '../../utils/renderContent';
6
7
  export declare const FIELD_ICON_DEFAULT_TAG = "div";
7
8
  export type FieldIconRef = ComponentRef<typeof FIELD_ICON_DEFAULT_TAG>;
8
9
  export type FieldIconProps = ComponentPropsWithRef<typeof FIELD_ICON_DEFAULT_TAG> & {
9
- icon?: string | ReactElement<IconProps & {
10
+ icon?: RenderContentType<IconProps & {
10
11
  size?: IconSize;
11
- }> | (() => ReactElement<IconProps & {
12
- size?: IconSize;
13
- }>) | FC<IconProps & {
14
- size?: IconSize;
15
- }>;
12
+ }>['content'];
16
13
  size?: FormElementSizeVariant;
17
14
  children?: never;
18
15
  };
@@ -4,31 +4,12 @@ exports.FieldIcon = exports.cnFieldIcon = exports.FIELD_ICON_DEFAULT_TAG = void
4
4
  var tslib_1 = require("tslib");
5
5
  require("./FieldIcon.css");
6
6
  var react_1 = tslib_1.__importStar(require("react"));
7
- var react_is_1 = require("react-is");
8
7
  var classname_1 = require("../../utils/classname");
9
8
  var getIconSizeToFormElement_1 = require("../../utils/getIconSizeToFormElement");
9
+ var renderContent_1 = require("../../utils/renderContent");
10
10
  var FieldControl_1 = require("../FieldControl");
11
11
  exports.FIELD_ICON_DEFAULT_TAG = 'div';
12
12
  exports.cnFieldIcon = (0, classname_1.cn)('FieldIcon');
13
- // TODO: взять за основу для всех рендер-функций
14
- var resolveChildren = function (content, size) {
15
- if (typeof content === 'string') {
16
- return content;
17
- }
18
- if ((0, react_is_1.isElement)(content)) {
19
- return react_1.default.cloneElement(content, {
20
- size: content.props.size || (size && (0, getIconSizeToFormElement_1.getIconSizeToFormElement)(size)),
21
- });
22
- }
23
- if (typeof content === 'function' && !react_1.default.isValidElement(content)) {
24
- return content({ size: size && (0, getIconSizeToFormElement_1.getIconSizeToFormElement)(size) });
25
- }
26
- if ((0, react_is_1.isValidElementType)(content)) {
27
- var Content = content;
28
- return react_1.default.createElement(Content, { size: size && (0, getIconSizeToFormElement_1.getIconSizeToFormElement)(size) });
29
- }
30
- return null;
31
- };
32
13
  exports.FieldIcon = (0, react_1.forwardRef)(function (_a, ref) {
33
14
  var icon = _a.icon, className = _a.className, sizeProp = _a.size, other = tslib_1.__rest(_a, ["icon", "className", "size"]);
34
15
  var context = (0, react_1.useContext)(FieldControl_1.FieldControlContext);
@@ -43,6 +24,9 @@ exports.FieldIcon = (0, react_1.forwardRef)(function (_a, ref) {
43
24
  size = fieldControl.size;
44
25
  }
45
26
  }
46
- return (react_1.default.createElement(Tag, tslib_1.__assign({ className: (0, exports.cnFieldIcon)({ size: size }, [className]) }, other, { ref: ref }), resolveChildren(icon, size)));
27
+ return (react_1.default.createElement(Tag, tslib_1.__assign({ className: (0, exports.cnFieldIcon)({ size: size }, [className]) }, other, { ref: ref }), (0, renderContent_1.renderContent)({
28
+ content: icon,
29
+ props: { size: size && (0, getIconSizeToFormElement_1.getIconSizeToFormElement)(size) },
30
+ })));
47
31
  });
48
32
  exports.FieldIcon.displayName = 'FieldIcon';
@@ -22,7 +22,6 @@ exports.Modal = (0, react_1.forwardRef)(function (_a, ref) {
22
22
  var hasBackdrop = !hideBackdrop;
23
23
  var modalInnerRef = (0, react_1.useRef)(null);
24
24
  var focusedElement = (0, react_1.useRef)(null);
25
- var isClickOutSide = (0, react_1.useRef)(null);
26
25
  var _h = tslib_1.__read((0, react_1.useState)(false), 2), openState = _h[0], setOpenState = _h[1];
27
26
  var _j = tslib_1.__read((0, react_1.useState)(false), 2), opened = _j[0], setOpened = _j[1];
28
27
  var _k = (0, index_1.useModalManager)(modalInnerRef, 1000, openState), isTop = _k.isTop, refsClickOutside = _k.refsClickOutside;
@@ -31,7 +30,6 @@ exports.Modal = (0, react_1.forwardRef)(function (_a, ref) {
31
30
  modalInnerRef
32
31
  ], tslib_1.__read(refsClickOutside), false), tslib_1.__read((ignoreClickOutsideRefs || [])), false),
33
32
  handler: function () {
34
- isClickOutSide.current = true;
35
33
  onClose === null || onClose === void 0 ? void 0 : onClose();
36
34
  },
37
35
  active: !disableClickOutside,
@@ -43,7 +41,6 @@ exports.Modal = (0, react_1.forwardRef)(function (_a, ref) {
43
41
  // Сохраняем фокус активного элемента до момента открытия всплывающего окна
44
42
  if (open) {
45
43
  setOpened(true);
46
- isClickOutSide.current = null;
47
44
  focusedElement.current =
48
45
  document.activeElement;
49
46
  (_a = focusedElement.current) === null || _a === void 0 ? void 0 : _a.blur();
@@ -57,10 +54,9 @@ exports.Modal = (0, react_1.forwardRef)(function (_a, ref) {
57
54
  var onExited = (0, react_1.useCallback)(function () {
58
55
  var _a, _b;
59
56
  // Возвращаем фокус активного элемента
60
- if (!isClickOutSide.current &&
61
- (((_a = modalInnerRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement)) ||
62
- document.activeElement === document.body)) {
63
- (_b = focusedElement.current) === null || _b === void 0 ? void 0 : _b.focus();
57
+ if (((_a = modalInnerRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement)) ||
58
+ document.activeElement === document.body) {
59
+ (_b = focusedElement.current) === null || _b === void 0 ? void 0 : _b.focus({ preventScroll: true });
64
60
  }
65
61
  setOpened(false);
66
62
  onExitedProp === null || onExitedProp === void 0 ? void 0 : onExitedProp();
@@ -23,7 +23,6 @@ exports.cnPopover = (0, classname_1.cn)('Popover');
23
23
  exports.Popover = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)(function (inProps, ref) {
24
24
  var props = (0, useThemeProps_1.useThemeProps)({ props: inProps, name: 'Popover' });
25
25
  var _a = props.arrow, arrow = _a === void 0 ? constants_1.POPOVER_DEFAULT_ARROW : _a, _b = props.open, open = _b === void 0 ? constants_1.POPOVER_DEFAULT_OPEN : _b, _c = props.disableInteractive, disableInteractive = _c === void 0 ? constants_1.POPOVER_DEFAULT_DISABLE_INTERACTIVE : _c, _d = props.disableEnforceFocus, disableEnforceFocus = _d === void 0 ? constants_1.POPOVER_DEFAULT_DISABLE_ENFORCE_FOCUS : _d, _e = props.disableReturnFocus, disableReturnFocus = _e === void 0 ? constants_1.POPOVER_DEFAULT_DISABLE_RETURN_FOCUS : _e, _f = props.disableClickOutside, disableClickOutside = _f === void 0 ? constants_1.POPOVER_DEFAULT_DISABLE_CLICK_OUTSIDE : _f, _g = props.placement, placement = _g === void 0 ? constants_1.POPOVER_DEFAULT_PLACEMENT : _g, ignoreClickOutsideRefs = props.ignoreClickOutsideRefs, arrowProps = props.arrowProps, anchorRef = props.anchorRef, equalAnchorWidth = props.equalAnchorWidth, offset = props.offset, children = props.children, transitionProps = props.transitionProps, onClose = props.onClose, onEnter = props.onEnter, onEntered = props.onEntered, onExit = props.onExit, onExitedProp = props.onExited, className = props.className, position = props.position, style = props.style, setUpdate = props.setUpdate, _h = props.as, as = _h === void 0 ? constants_1.POPOVER_DEFAULT_TAG : _h, other = tslib_1.__rest(props, ["arrow", "open", "disableInteractive", "disableEnforceFocus", "disableReturnFocus", "disableClickOutside", "placement", "ignoreClickOutsideRefs", "arrowProps", "anchorRef", "equalAnchorWidth", "offset", "children", "transitionProps", "onClose", "onEnter", "onEntered", "onExit", "onExited", "className", "position", "style", "setUpdate", "as"]);
26
- var isClickOutSide = (0, react_1.useRef)(null);
27
26
  var _j = tslib_1.__read((0, react_1.useState)(false), 2), openState = _j[0], setOpenState = _j[1];
28
27
  var focusedElement = (0, react_1.useRef)(null);
29
28
  var popoverRef = (0, react_1.useRef)(null);
@@ -49,7 +48,6 @@ exports.Popover = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)
49
48
  popoverRef
50
49
  ], tslib_1.__read(refsClickOutside), false), tslib_1.__read((anchorRef ? [anchorRef] : [])), false), tslib_1.__read((ignoreClickOutsideRefs || [])), false),
51
50
  handler: function () {
52
- isClickOutSide.current = true;
53
51
  onClose === null || onClose === void 0 ? void 0 : onClose();
54
52
  },
55
53
  active: openState && !disableClickOutside,
@@ -58,10 +56,9 @@ exports.Popover = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)
58
56
  var _a, _b;
59
57
  // Возвращаем фокус активного элемента
60
58
  if (!disableReturnFocus &&
61
- !isClickOutSide.current &&
62
59
  (((_a = popoverRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement)) ||
63
60
  document.activeElement === document.body)) {
64
- (_b = focusedElement.current) === null || _b === void 0 ? void 0 : _b.focus();
61
+ (_b = focusedElement.current) === null || _b === void 0 ? void 0 : _b.focus({ preventScroll: true });
65
62
  }
66
63
  onExitedProp === null || onExitedProp === void 0 ? void 0 : onExitedProp();
67
64
  }, [onExitedProp]);
@@ -136,7 +133,6 @@ exports.Popover = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)
136
133
  var _a;
137
134
  // Сохраняем фокус активного элемента до момента открытия всплывающего окна
138
135
  if (open && !disableReturnFocus) {
139
- isClickOutSide.current = null;
140
136
  focusedElement.current =
141
137
  document.activeElement;
142
138
  (_a = focusedElement.current) === null || _a === void 0 ? void 0 : _a.blur();
@@ -8,6 +8,7 @@ import type { CardProps } from '../Card';
8
8
  import type { CheckboxProps } from '../Checkbox';
9
9
  import type { CheckboxGroupProps } from '../CheckboxGroup';
10
10
  import type { ChipProps } from '../Chip';
11
+ import type { ChipProps as ChiPropsNext } from '../ChipNext';
11
12
  import type { CollapseProps } from '../Collapse';
12
13
  import type { ContainerProps } from '../Container';
13
14
  import type { DataListProps } from '../DataList';
@@ -69,6 +70,7 @@ export type Theme = {
69
70
  Checkbox?: Partial<CheckboxProps>;
70
71
  CheckboxGroup?: Partial<CheckboxGroupProps>;
71
72
  Chip?: Partial<ChipProps>;
73
+ ChipNext?: Partial<ChiPropsNext>;
72
74
  Collapse?: Partial<CollapseProps>;
73
75
  Container?: Partial<ContainerProps>;
74
76
  DataList?: Partial<DataListProps>;
@@ -0,0 +1 @@
1
+ export * from './renderContent';
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./renderContent"), exports);
@@ -0,0 +1,6 @@
1
+ import type { FC, ReactElement, ReactNode } from 'react';
2
+ export type RenderContentType<Props extends object> = {
3
+ content?: string | number | FC<Props> | ReactElement<Props> | (() => ReactElement<Props>);
4
+ props?: Props;
5
+ };
6
+ export declare function renderContent<Props extends object>({ content, props, }: RenderContentType<Props>): ReactNode;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderContent = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var react_1 = tslib_1.__importStar(require("react"));
6
+ var react_is_1 = require("react-is");
7
+ var mergeDeep_1 = require("../../utils/mergeDeep");
8
+ function renderContent(_a) {
9
+ var content = _a.content, props = _a.props;
10
+ // primitives: string or number
11
+ if (typeof content === 'string' || typeof content === 'number') {
12
+ return content;
13
+ }
14
+ // react-element
15
+ if ((0, react_is_1.isElement)(content)) {
16
+ return (0, react_1.cloneElement)(content, (0, mergeDeep_1.mergeDeep)(props, content.props));
17
+ }
18
+ // render-function
19
+ if (typeof content === 'function' && !(0, react_1.isValidElement)(content)) {
20
+ return content(props);
21
+ }
22
+ // react-component
23
+ if ((0, react_is_1.isValidElementType)(content)) {
24
+ var Content = content;
25
+ return react_1.default.createElement(Content, tslib_1.__assign({}, props));
26
+ }
27
+ return null;
28
+ }
29
+ exports.renderContent = renderContent;
@@ -33,4 +33,7 @@ export type ChipBaseProps = {
33
33
  'data-testid'?: string;
34
34
  };
35
35
  export type ChipProps = ExtendableProps<InputHTMLAttributes<HTMLInputElement>, ChipBaseProps>;
36
+ /**
37
+ * @deprecated Компонент устарел. Для замены используйте компонент ChipNext
38
+ */
36
39
  export declare const Chip: React.ForwardRefExoticComponent<ChipBaseProps & Omit<React.InputHTMLAttributes<HTMLInputElement>, keyof ChipBaseProps> & React.RefAttributes<HTMLLabelElement>>;
@@ -8,6 +8,9 @@ import { CHIP_DEFAULT_SIZE, CHIP_DEFAULT_VARIANT, CHIP_DEFAULT_DISABLED, } from
8
8
  export var cnChip = cn('Chip');
9
9
  export var chipSizeVariant = ['xs', 's', 'm', 'l'];
10
10
  export var chipColorVariant = ['primary', 'secondary'];
11
+ /**
12
+ * @deprecated Компонент устарел. Для замены используйте компонент ChipNext
13
+ */
11
14
  export var Chip = forwardRef(function (inProps, ref) {
12
15
  var _a = useThemeProps({ name: 'Chip', props: inProps }), _b = _a.size, size = _b === void 0 ? CHIP_DEFAULT_SIZE : _b, _c = _a.color, color = _c === void 0 ? CHIP_DEFAULT_VARIANT : _c, _d = _a.disabled, disabled = _d === void 0 ? CHIP_DEFAULT_DISABLED : _d, IconLeft = _a.iconLeft, IconRight = _a.iconRight, labelProps = _a.labelProps, inputRef = _a.inputRef, className = _a.className, children = _a.children, dataTestId = _a["data-testid"], other = __rest(_a, ["size", "color", "disabled", "iconLeft", "iconRight", "labelProps", "inputRef", "className", "children", 'data-testid']);
13
16
  var iconSize = useMemo(function () { return getIconSizeToFormElement(size); }, [size]);
@@ -0,0 +1,108 @@
1
+ /* stylelint-disable */
2
+ .ChipNext {
3
+ --chip-border-radius: 24px;
4
+ --chip-text-wrap: nowrap;
5
+ background-color: var(--chip-bg-color);
6
+ border-radius: var(--chip-border-radius);
7
+ min-block-size: var(--chip-height);
8
+ padding: 0 var(--chip-padding-x);
9
+ min-inline-size: var(--chip-min-width);
10
+ color: var(--chip-text-color);
11
+ gap: var(--space-s);
12
+ display: inline-flex;
13
+ justify-content: center;
14
+ align-items: center;
15
+ cursor: pointer;
16
+ box-sizing: border-box;
17
+ text-decoration: none;
18
+ border: none;
19
+ outline: none;
20
+ transition:
21
+ border-color var(--transition-default),
22
+ color var(--transition-default),
23
+ background-color var(--transition-default),
24
+ box-shadow var(--transition-default);
25
+ }
26
+ .ChipNext-Content {
27
+ overflow: hidden;
28
+ text-overflow: ellipsis;
29
+ white-space: var(--chip-text-wrap);
30
+ }
31
+ .ChipNext-Icon {
32
+ color: inherit;
33
+ flex-shrink: 0;
34
+ }
35
+ .ChipNext_multiline {
36
+ --chip-text-wrap: normal;
37
+ }
38
+ .ChipNext_size_xs {
39
+ font: var(--typography-text-2xs-font);
40
+ letter-spacing: var(--typography-text-2xs-letter_spacing, 0);
41
+ text-transform: var(--typography-text-2xs-text_transform, none);
42
+
43
+ --chip-min-width: 64px;
44
+ --chip-height: var(--space-xl);
45
+ --chip-padding-x: var(--space-m);
46
+ }
47
+ .ChipNext_size_s {
48
+ font: var(--typography-text-s-font);
49
+ letter-spacing: var(--typography-text-s-letter_spacing, 0);
50
+ text-transform: var(--typography-text-s-text_transform, none);
51
+
52
+ --chip-min-width: 72px;
53
+ --chip-height: var(--space-2xl);
54
+ --chip-padding-x: var(--space-l);
55
+ }
56
+ .ChipNext_size_m {
57
+ font: var(--typography-text-m-font);
58
+ letter-spacing: var(--typography-text-m-letter_spacing, 0);
59
+ text-transform: var(--typography-text-m-text_transform, none);
60
+
61
+ --chip-min-width: 80px;
62
+ --chip-height: var(--space-3xl);
63
+ --chip-padding-x: 20px;
64
+ }
65
+ .ChipNext_size_l {
66
+ font: var(--typography-text-l-font);
67
+ letter-spacing: var(--typography-text-l-letter_spacing, 0);
68
+ text-transform: var(--typography-text-l-text_transform, none);
69
+
70
+ --chip-min-width: 88px;
71
+ --chip-height: var(--space-4xl);
72
+ --chip-padding-x: var(--space-xl);
73
+ }
74
+ .ChipNext_color_primary {
75
+ --chip-bg-color: var(--color-background-action-light);
76
+ --chip-bg-color-hover: var(--color-background-action-light-hover);
77
+ --chip-bg-color-active: var(--color-background-action-light-pressed);
78
+ --chip-text-color: var(--color-content-action-dark);
79
+ }
80
+ .ChipNext_color_secondary {
81
+ --chip-bg-color: var(--color-background-secondary);
82
+ --chip-bg-color-hover: var(--color-background-secondary-hover);
83
+ --chip-bg-color-active: var(--color-background-secondary-pressed);
84
+ --chip-text-color: var(--color-content-primary);
85
+ }
86
+ .ChipNext:hover {
87
+ --chip-bg-color: var(--chip-bg-color-hover);
88
+ }
89
+ .ChipNext:active {
90
+ --chip-bg-color: var(--chip-bg-color-active);
91
+ }
92
+ .ChipNext:focus {
93
+ box-shadow: var(--shadow-outline-focused);
94
+ }
95
+ .ChipNext:focus:not(:focus-visible) {
96
+ box-shadow: none;
97
+ }
98
+ .ChipNext_checked,
99
+ .ChipNext_checked:hover,
100
+ .ChipNext_checked:active {
101
+ --chip-bg-color: var(--color-background-action);
102
+ --chip-text-color: var(--color-content-action-on);
103
+ }
104
+ .ChipNext_disabled {
105
+ --chip-bg-color: var(--color-background-disabled);
106
+ --chip-text-color: var(--color-content-disabled);
107
+ pointer-events: none;
108
+ }
@@ -0,0 +1,42 @@
1
+ import './Chip.css';
2
+ import type { ReactNode, MouseEvent, ElementType } from 'react';
3
+ import type { IconProps, IconSize } from '@ozen-ui/icons';
4
+ import type { PolymorphicComponentPropsWithRef } from '../../utils/polymorphicComponentWithRef';
5
+ import type { RenderContentType } from '../../utils/renderContent';
6
+ import { CHIP_DEFAULT_TAG } from './constants';
7
+ export declare const cnChip: import("@bem-react/classname").ClassNameFormatter;
8
+ export declare const chipSizeVariant: readonly ["xs", "s", "m", "l"];
9
+ export declare const chipColorVariant: readonly ["primary", "secondary"];
10
+ export type ChipSizeVariant = (typeof chipSizeVariant)[number];
11
+ export type ChipColorVariant = (typeof chipColorVariant)[number];
12
+ export type ChipIcon = RenderContentType<IconProps & {
13
+ size?: IconSize;
14
+ }>['content'];
15
+ export type ChipBaseProps = {
16
+ /** Размер компонента */
17
+ size?: ChipSizeVariant;
18
+ /** Вариант представления компонента */
19
+ color?: ChipColorVariant;
20
+ /** Если {true} компонент отображается как заблокированный */
21
+ disabled?: boolean;
22
+ /** Если {true} делает элемент выбранным */
23
+ checked?: boolean;
24
+ /** Обработчик нажатия */
25
+ onClick?: (e: MouseEvent<HTMLElement>, payload: {
26
+ checked: boolean;
27
+ }) => void;
28
+ /** Иконка слева */
29
+ iconLeft?: ChipIcon;
30
+ /** Иконка справа */
31
+ iconRight?: ChipIcon;
32
+ /** Если {true} разбивает длинный текст на несколько строк */
33
+ multiline?: boolean;
34
+ /** Дополнительные СSS-классы */
35
+ className?: string;
36
+ /** Содержимое компонента */
37
+ children?: ReactNode;
38
+ /** Идентификатор компонента для тестов */
39
+ 'data-testid'?: string;
40
+ };
41
+ export type ChipProps<As extends ElementType = typeof CHIP_DEFAULT_TAG> = PolymorphicComponentPropsWithRef<ChipBaseProps, As>;
42
+ export declare const Chip: import("../../utils/polymorphicComponentWithRef").PolymorphicComponentWithRef<ChipBaseProps, "button">;
@@ -0,0 +1,43 @@
1
+ import { __assign, __read, __rest } from "tslib";
2
+ import './Chip.css';
3
+ import React from 'react';
4
+ import { useControlled } from '../../hooks/useControlled';
5
+ import { useThemeProps } from '../../hooks/useThemeProps';
6
+ import { cn } from '../../utils/classname';
7
+ import { getIconSizeToFormElement } from '../../utils/getIconSizeToFormElement';
8
+ import { polymorphicComponentWithRef } from '../../utils/polymorphicComponentWithRef';
9
+ import { renderContent } from '../../utils/renderContent';
10
+ import { CHIP_DEFAULT_TAG, CHIP_DEFAULT_SIZE, CHIP_DEFAULT_VARIANT, CHIP_DEFAULT_DISABLED, } from './constants';
11
+ export var cnChip = cn('ChipNext');
12
+ export var chipSizeVariant = ['xs', 's', 'm', 'l'];
13
+ export var chipColorVariant = ['primary', 'secondary'];
14
+ export var Chip = polymorphicComponentWithRef(function (inProps, ref) {
15
+ var _a = useThemeProps({ name: 'ChipNext', props: inProps }), _b = _a.size, size = _b === void 0 ? CHIP_DEFAULT_SIZE : _b, _c = _a.color, color = _c === void 0 ? CHIP_DEFAULT_VARIANT : _c, _d = _a.disabled, disabled = _d === void 0 ? CHIP_DEFAULT_DISABLED : _d, iconLeft = _a.iconLeft, iconRight = _a.iconRight, multiline = _a.multiline, className = _a.className, children = _a.children, onClick = _a.onClick, checkedProp = _a.checked, _e = _a.as, Tag = _e === void 0 ? CHIP_DEFAULT_TAG : _e, dataTestId = _a["data-testid"], other = __rest(_a, ["size", "color", "disabled", "iconLeft", "iconRight", "multiline", "className", "children", "onClick", "checked", "as", 'data-testid']);
16
+ var _f = __read(useControlled({
17
+ value: checkedProp,
18
+ defaultValue: false,
19
+ name: 'ChipNext',
20
+ state: 'open',
21
+ }), 2), checkedState = _f[0], setCheckedState = _f[1];
22
+ var handleClick = function (event) {
23
+ if (disabled) {
24
+ return;
25
+ }
26
+ setCheckedState(!checkedState);
27
+ onClick === null || onClick === void 0 ? void 0 : onClick(event, { checked: !checkedState });
28
+ };
29
+ var renderIcon = function (content) {
30
+ return renderContent({
31
+ content: content,
32
+ props: {
33
+ size: getIconSizeToFormElement(size),
34
+ className: cnChip('Icon'),
35
+ },
36
+ });
37
+ };
38
+ return (React.createElement(Tag, __assign({ type: "button", "data-testid": dataTestId, disabled: disabled }, other, { className: cnChip({ size: size, disabled: disabled, color: color, multiline: multiline, checked: checkedState }, [className]), onClick: handleClick, ref: ref }),
39
+ renderIcon(iconLeft),
40
+ children && React.createElement("span", { className: cnChip('Content') }, children),
41
+ renderIcon(iconRight)));
42
+ });
43
+ Chip.displayName = 'Chip';
@@ -0,0 +1,4 @@
1
+ export declare const CHIP_DEFAULT_TAG = "button";
2
+ export declare const CHIP_DEFAULT_VARIANT = "primary";
3
+ export declare const CHIP_DEFAULT_SIZE = "m";
4
+ export declare const CHIP_DEFAULT_DISABLED = false;
@@ -0,0 +1,4 @@
1
+ export var CHIP_DEFAULT_TAG = 'button';
2
+ export var CHIP_DEFAULT_VARIANT = 'primary';
3
+ export var CHIP_DEFAULT_SIZE = 'm';
4
+ export var CHIP_DEFAULT_DISABLED = false;
@@ -0,0 +1 @@
1
+ export * from './Chip';
@@ -0,0 +1 @@
1
+ export * from './Chip';
@@ -1,18 +1,15 @@
1
1
  import './FieldIcon.css';
2
- import type { ComponentPropsWithRef, ComponentRef, FC, ReactElement } from 'react';
2
+ import type { ComponentPropsWithRef, ComponentRef } from 'react';
3
3
  import React from 'react';
4
4
  import type { IconProps, IconSize } from '@ozen-ui/icons';
5
5
  import type { FormElementSizeVariant } from '../../types/FormElementSizeVariant';
6
+ import type { RenderContentType } from '../../utils/renderContent';
6
7
  export declare const FIELD_ICON_DEFAULT_TAG = "div";
7
8
  export type FieldIconRef = ComponentRef<typeof FIELD_ICON_DEFAULT_TAG>;
8
9
  export type FieldIconProps = ComponentPropsWithRef<typeof FIELD_ICON_DEFAULT_TAG> & {
9
- icon?: string | ReactElement<IconProps & {
10
+ icon?: RenderContentType<IconProps & {
10
11
  size?: IconSize;
11
- }> | (() => ReactElement<IconProps & {
12
- size?: IconSize;
13
- }>) | FC<IconProps & {
14
- size?: IconSize;
15
- }>;
12
+ }>['content'];
16
13
  size?: FormElementSizeVariant;
17
14
  children?: never;
18
15
  };
@@ -1,31 +1,12 @@
1
1
  import { __assign, __read, __rest } from "tslib";
2
2
  import './FieldIcon.css';
3
3
  import React, { forwardRef, useContext } from 'react';
4
- import { isValidElementType, isElement } from 'react-is';
5
4
  import { cn } from '../../utils/classname';
6
5
  import { getIconSizeToFormElement } from '../../utils/getIconSizeToFormElement';
6
+ import { renderContent } from '../../utils/renderContent';
7
7
  import { FieldControlContext } from '../FieldControl';
8
8
  export var FIELD_ICON_DEFAULT_TAG = 'div';
9
9
  export var cnFieldIcon = cn('FieldIcon');
10
- // TODO: взять за основу для всех рендер-функций
11
- var resolveChildren = function (content, size) {
12
- if (typeof content === 'string') {
13
- return content;
14
- }
15
- if (isElement(content)) {
16
- return React.cloneElement(content, {
17
- size: content.props.size || (size && getIconSizeToFormElement(size)),
18
- });
19
- }
20
- if (typeof content === 'function' && !React.isValidElement(content)) {
21
- return content({ size: size && getIconSizeToFormElement(size) });
22
- }
23
- if (isValidElementType(content)) {
24
- var Content = content;
25
- return React.createElement(Content, { size: size && getIconSizeToFormElement(size) });
26
- }
27
- return null;
28
- };
29
10
  export var FieldIcon = forwardRef(function (_a, ref) {
30
11
  var icon = _a.icon, className = _a.className, sizeProp = _a.size, other = __rest(_a, ["icon", "className", "size"]);
31
12
  var context = useContext(FieldControlContext);
@@ -40,6 +21,9 @@ export var FieldIcon = forwardRef(function (_a, ref) {
40
21
  size = fieldControl.size;
41
22
  }
42
23
  }
43
- return (React.createElement(Tag, __assign({ className: cnFieldIcon({ size: size }, [className]) }, other, { ref: ref }), resolveChildren(icon, size)));
24
+ return (React.createElement(Tag, __assign({ className: cnFieldIcon({ size: size }, [className]) }, other, { ref: ref }), renderContent({
25
+ content: icon,
26
+ props: { size: size && getIconSizeToFormElement(size) },
27
+ })));
44
28
  });
45
29
  FieldIcon.displayName = 'FieldIcon';
@@ -19,7 +19,6 @@ export var Modal = forwardRef(function (_a, ref) {
19
19
  var hasBackdrop = !hideBackdrop;
20
20
  var modalInnerRef = useRef(null);
21
21
  var focusedElement = useRef(null);
22
- var isClickOutSide = useRef(null);
23
22
  var _h = __read(useState(false), 2), openState = _h[0], setOpenState = _h[1];
24
23
  var _j = __read(useState(false), 2), opened = _j[0], setOpened = _j[1];
25
24
  var _k = useModalManager(modalInnerRef, 1000, openState), isTop = _k.isTop, refsClickOutside = _k.refsClickOutside;
@@ -28,7 +27,6 @@ export var Modal = forwardRef(function (_a, ref) {
28
27
  modalInnerRef
29
28
  ], __read(refsClickOutside), false), __read((ignoreClickOutsideRefs || [])), false),
30
29
  handler: function () {
31
- isClickOutSide.current = true;
32
30
  onClose === null || onClose === void 0 ? void 0 : onClose();
33
31
  },
34
32
  active: !disableClickOutside,
@@ -40,7 +38,6 @@ export var Modal = forwardRef(function (_a, ref) {
40
38
  // Сохраняем фокус активного элемента до момента открытия всплывающего окна
41
39
  if (open) {
42
40
  setOpened(true);
43
- isClickOutSide.current = null;
44
41
  focusedElement.current =
45
42
  document.activeElement;
46
43
  (_a = focusedElement.current) === null || _a === void 0 ? void 0 : _a.blur();
@@ -54,10 +51,9 @@ export var Modal = forwardRef(function (_a, ref) {
54
51
  var onExited = useCallback(function () {
55
52
  var _a, _b;
56
53
  // Возвращаем фокус активного элемента
57
- if (!isClickOutSide.current &&
58
- (((_a = modalInnerRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement)) ||
59
- document.activeElement === document.body)) {
60
- (_b = focusedElement.current) === null || _b === void 0 ? void 0 : _b.focus();
54
+ if (((_a = modalInnerRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement)) ||
55
+ document.activeElement === document.body) {
56
+ (_b = focusedElement.current) === null || _b === void 0 ? void 0 : _b.focus({ preventScroll: true });
61
57
  }
62
58
  setOpened(false);
63
59
  onExitedProp === null || onExitedProp === void 0 ? void 0 : onExitedProp();
@@ -20,7 +20,6 @@ export var cnPopover = cn('Popover');
20
20
  export var Popover = polymorphicComponentWithRef(function (inProps, ref) {
21
21
  var props = useThemeProps({ props: inProps, name: 'Popover' });
22
22
  var _a = props.arrow, arrow = _a === void 0 ? POPOVER_DEFAULT_ARROW : _a, _b = props.open, open = _b === void 0 ? POPOVER_DEFAULT_OPEN : _b, _c = props.disableInteractive, disableInteractive = _c === void 0 ? POPOVER_DEFAULT_DISABLE_INTERACTIVE : _c, _d = props.disableEnforceFocus, disableEnforceFocus = _d === void 0 ? POPOVER_DEFAULT_DISABLE_ENFORCE_FOCUS : _d, _e = props.disableReturnFocus, disableReturnFocus = _e === void 0 ? POPOVER_DEFAULT_DISABLE_RETURN_FOCUS : _e, _f = props.disableClickOutside, disableClickOutside = _f === void 0 ? POPOVER_DEFAULT_DISABLE_CLICK_OUTSIDE : _f, _g = props.placement, placement = _g === void 0 ? POPOVER_DEFAULT_PLACEMENT : _g, ignoreClickOutsideRefs = props.ignoreClickOutsideRefs, arrowProps = props.arrowProps, anchorRef = props.anchorRef, equalAnchorWidth = props.equalAnchorWidth, offset = props.offset, children = props.children, transitionProps = props.transitionProps, onClose = props.onClose, onEnter = props.onEnter, onEntered = props.onEntered, onExit = props.onExit, onExitedProp = props.onExited, className = props.className, position = props.position, style = props.style, setUpdate = props.setUpdate, _h = props.as, as = _h === void 0 ? POPOVER_DEFAULT_TAG : _h, other = __rest(props, ["arrow", "open", "disableInteractive", "disableEnforceFocus", "disableReturnFocus", "disableClickOutside", "placement", "ignoreClickOutsideRefs", "arrowProps", "anchorRef", "equalAnchorWidth", "offset", "children", "transitionProps", "onClose", "onEnter", "onEntered", "onExit", "onExited", "className", "position", "style", "setUpdate", "as"]);
23
- var isClickOutSide = useRef(null);
24
23
  var _j = __read(useState(false), 2), openState = _j[0], setOpenState = _j[1];
25
24
  var focusedElement = useRef(null);
26
25
  var popoverRef = useRef(null);
@@ -46,7 +45,6 @@ export var Popover = polymorphicComponentWithRef(function (inProps, ref) {
46
45
  popoverRef
47
46
  ], __read(refsClickOutside), false), __read((anchorRef ? [anchorRef] : [])), false), __read((ignoreClickOutsideRefs || [])), false),
48
47
  handler: function () {
49
- isClickOutSide.current = true;
50
48
  onClose === null || onClose === void 0 ? void 0 : onClose();
51
49
  },
52
50
  active: openState && !disableClickOutside,
@@ -55,10 +53,9 @@ export var Popover = polymorphicComponentWithRef(function (inProps, ref) {
55
53
  var _a, _b;
56
54
  // Возвращаем фокус активного элемента
57
55
  if (!disableReturnFocus &&
58
- !isClickOutSide.current &&
59
56
  (((_a = popoverRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement)) ||
60
57
  document.activeElement === document.body)) {
61
- (_b = focusedElement.current) === null || _b === void 0 ? void 0 : _b.focus();
58
+ (_b = focusedElement.current) === null || _b === void 0 ? void 0 : _b.focus({ preventScroll: true });
62
59
  }
63
60
  onExitedProp === null || onExitedProp === void 0 ? void 0 : onExitedProp();
64
61
  }, [onExitedProp]);
@@ -133,7 +130,6 @@ export var Popover = polymorphicComponentWithRef(function (inProps, ref) {
133
130
  var _a;
134
131
  // Сохраняем фокус активного элемента до момента открытия всплывающего окна
135
132
  if (open && !disableReturnFocus) {
136
- isClickOutSide.current = null;
137
133
  focusedElement.current =
138
134
  document.activeElement;
139
135
  (_a = focusedElement.current) === null || _a === void 0 ? void 0 : _a.blur();
@@ -8,6 +8,7 @@ import type { CardProps } from '../Card';
8
8
  import type { CheckboxProps } from '../Checkbox';
9
9
  import type { CheckboxGroupProps } from '../CheckboxGroup';
10
10
  import type { ChipProps } from '../Chip';
11
+ import type { ChipProps as ChiPropsNext } from '../ChipNext';
11
12
  import type { CollapseProps } from '../Collapse';
12
13
  import type { ContainerProps } from '../Container';
13
14
  import type { DataListProps } from '../DataList';
@@ -69,6 +70,7 @@ export type Theme = {
69
70
  Checkbox?: Partial<CheckboxProps>;
70
71
  CheckboxGroup?: Partial<CheckboxGroupProps>;
71
72
  Chip?: Partial<ChipProps>;
73
+ ChipNext?: Partial<ChiPropsNext>;
72
74
  Collapse?: Partial<CollapseProps>;
73
75
  Container?: Partial<ContainerProps>;
74
76
  DataList?: Partial<DataListProps>;
@@ -0,0 +1 @@
1
+ export * from './renderContent';
@@ -0,0 +1 @@
1
+ export * from './renderContent';
@@ -0,0 +1,6 @@
1
+ import type { FC, ReactElement, ReactNode } from 'react';
2
+ export type RenderContentType<Props extends object> = {
3
+ content?: string | number | FC<Props> | ReactElement<Props> | (() => ReactElement<Props>);
4
+ props?: Props;
5
+ };
6
+ export declare function renderContent<Props extends object>({ content, props, }: RenderContentType<Props>): ReactNode;
@@ -0,0 +1,25 @@
1
+ import { __assign } from "tslib";
2
+ import React, { isValidElement, cloneElement } from 'react';
3
+ import { isElement, isValidElementType } from 'react-is';
4
+ import { mergeDeep } from '../../utils/mergeDeep';
5
+ export function renderContent(_a) {
6
+ var content = _a.content, props = _a.props;
7
+ // primitives: string or number
8
+ if (typeof content === 'string' || typeof content === 'number') {
9
+ return content;
10
+ }
11
+ // react-element
12
+ if (isElement(content)) {
13
+ return cloneElement(content, mergeDeep(props, content.props));
14
+ }
15
+ // render-function
16
+ if (typeof content === 'function' && !isValidElement(content)) {
17
+ return content(props);
18
+ }
19
+ // react-component
20
+ if (isValidElementType(content)) {
21
+ var Content = content;
22
+ return React.createElement(Content, __assign({}, props));
23
+ }
24
+ return null;
25
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ozen-ui/kit",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "React component library",
5
5
  "files": [
6
6
  "*"