@ozen-ui/kit 0.18.0 → 0.20.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 (66) hide show
  1. package/ChipNext/package.json +5 -0
  2. package/__inner__/cjs/components/Avatar/Avatar.css +28 -25
  3. package/__inner__/cjs/components/Avatar/Avatar.d.ts +3 -3
  4. package/__inner__/cjs/components/Avatar/Avatar.js +15 -27
  5. package/__inner__/cjs/components/Avatar/utils.d.ts +6 -0
  6. package/__inner__/cjs/components/Avatar/utils.js +26 -0
  7. package/__inner__/cjs/components/Button/Button.d.ts +5 -5
  8. package/__inner__/cjs/components/Button/Button.js +12 -3
  9. package/__inner__/cjs/components/Chip/Chip.d.ts +3 -0
  10. package/__inner__/cjs/components/Chip/Chip.js +3 -0
  11. package/__inner__/cjs/components/ChipNext/Chip.css +108 -0
  12. package/__inner__/cjs/components/ChipNext/Chip.d.ts +42 -0
  13. package/__inner__/cjs/components/ChipNext/Chip.js +46 -0
  14. package/__inner__/cjs/components/ChipNext/constants.d.ts +4 -0
  15. package/__inner__/cjs/components/ChipNext/constants.js +7 -0
  16. package/__inner__/cjs/components/ChipNext/index.d.ts +1 -0
  17. package/__inner__/cjs/components/ChipNext/index.js +4 -0
  18. package/__inner__/cjs/components/FieldIcon/FieldIcon.d.ts +4 -7
  19. package/__inner__/cjs/components/FieldIcon/FieldIcon.js +5 -21
  20. package/__inner__/cjs/components/Grid/Grid.css +18 -0
  21. package/__inner__/cjs/components/Grid/Grid.d.ts +8 -0
  22. package/__inner__/cjs/components/Grid/Grid.js +12 -3
  23. package/__inner__/cjs/components/Modal/Modal.js +3 -7
  24. package/__inner__/cjs/components/Popover/Popover.js +1 -5
  25. package/__inner__/cjs/components/Table/components/TableRow/TableRow.css +6 -1
  26. package/__inner__/cjs/components/ThemeProvider/_color/Theme_color_bBusinessDefault.css +2 -2
  27. package/__inner__/cjs/components/ThemeProvider/_color/Theme_color_ozenDark.css +1 -1
  28. package/__inner__/cjs/components/ThemeProvider/_color/Theme_color_ozenDefault.css +1 -1
  29. package/__inner__/cjs/components/ThemeProvider/types.d.ts +2 -0
  30. package/__inner__/cjs/utils/renderContent/index.d.ts +1 -0
  31. package/__inner__/cjs/utils/renderContent/index.js +4 -0
  32. package/__inner__/cjs/utils/renderContent/renderContent.d.ts +6 -0
  33. package/__inner__/cjs/utils/renderContent/renderContent.js +29 -0
  34. package/__inner__/esm/components/Avatar/Avatar.css +28 -25
  35. package/__inner__/esm/components/Avatar/Avatar.d.ts +3 -3
  36. package/__inner__/esm/components/Avatar/Avatar.js +14 -26
  37. package/__inner__/esm/components/Avatar/utils.d.ts +6 -0
  38. package/__inner__/esm/components/Avatar/utils.js +22 -0
  39. package/__inner__/esm/components/Button/Button.d.ts +5 -5
  40. package/__inner__/esm/components/Button/Button.js +12 -3
  41. package/__inner__/esm/components/Chip/Chip.d.ts +3 -0
  42. package/__inner__/esm/components/Chip/Chip.js +3 -0
  43. package/__inner__/esm/components/ChipNext/Chip.css +108 -0
  44. package/__inner__/esm/components/ChipNext/Chip.d.ts +42 -0
  45. package/__inner__/esm/components/ChipNext/Chip.js +43 -0
  46. package/__inner__/esm/components/ChipNext/constants.d.ts +4 -0
  47. package/__inner__/esm/components/ChipNext/constants.js +4 -0
  48. package/__inner__/esm/components/ChipNext/index.d.ts +1 -0
  49. package/__inner__/esm/components/ChipNext/index.js +1 -0
  50. package/__inner__/esm/components/FieldIcon/FieldIcon.d.ts +4 -7
  51. package/__inner__/esm/components/FieldIcon/FieldIcon.js +5 -21
  52. package/__inner__/esm/components/Grid/Grid.css +18 -0
  53. package/__inner__/esm/components/Grid/Grid.d.ts +8 -0
  54. package/__inner__/esm/components/Grid/Grid.js +11 -2
  55. package/__inner__/esm/components/Modal/Modal.js +3 -7
  56. package/__inner__/esm/components/Popover/Popover.js +1 -5
  57. package/__inner__/esm/components/Table/components/TableRow/TableRow.css +6 -1
  58. package/__inner__/esm/components/ThemeProvider/_color/Theme_color_bBusinessDefault.css +2 -2
  59. package/__inner__/esm/components/ThemeProvider/_color/Theme_color_ozenDark.css +1 -1
  60. package/__inner__/esm/components/ThemeProvider/_color/Theme_color_ozenDefault.css +1 -1
  61. package/__inner__/esm/components/ThemeProvider/types.d.ts +2 -0
  62. package/__inner__/esm/utils/renderContent/index.d.ts +1 -0
  63. package/__inner__/esm/utils/renderContent/index.js +1 -0
  64. package/__inner__/esm/utils/renderContent/renderContent.d.ts +6 -0
  65. package/__inner__/esm/utils/renderContent/renderContent.js +25 -0
  66. package/package.json +1 -1
@@ -6,6 +6,7 @@ import { useThemeProps } from '../../hooks/useThemeProps';
6
6
  import { cn } from '../../utils/classname';
7
7
  import { getIconSizeToFormElement } from '../../utils/getIconSizeToFormElement';
8
8
  import { polymorphicComponentWithRef } from '../../utils/polymorphicComponentWithRef';
9
+ import { renderContent } from '../../utils/renderContent';
9
10
  import { Loader } from '../Loader';
10
11
  import { BUTTON_DEFAULT_SIZE, BUTTON_DEFAULT_VARIANT, BUTTON_DEFAULT_COLOR, BUTTON_DEFAULT_TAG, } from './constants';
11
12
  export var buttonVariant = [
@@ -28,19 +29,27 @@ export var Button = polymorphicComponentWithRef(function (inProps, ref) {
28
29
  props: inProps,
29
30
  name: 'Button',
30
31
  });
31
- var _a = props.as, Tag = _a === void 0 ? BUTTON_DEFAULT_TAG : _a, _b = props.variant, variant = _b === void 0 ? BUTTON_DEFAULT_VARIANT : _b, _c = props.color, color = _c === void 0 ? BUTTON_DEFAULT_COLOR : _c, _d = props.size, size = _d === void 0 ? BUTTON_DEFAULT_SIZE : _d, IconLeft = props.iconLeft, IconRight = props.iconRight, loading = props.loading, children = props.children, disabled = props.disabled, className = props.className, fullWidth = props.fullWidth, onClick = props.onClick, other = __rest(props, ["as", "variant", "color", "size", "iconLeft", "iconRight", "loading", "children", "disabled", "className", "fullWidth", "onClick"]);
32
+ var _a = props.as, Tag = _a === void 0 ? BUTTON_DEFAULT_TAG : _a, _b = props.variant, variant = _b === void 0 ? BUTTON_DEFAULT_VARIANT : _b, _c = props.color, color = _c === void 0 ? BUTTON_DEFAULT_COLOR : _c, _d = props.size, size = _d === void 0 ? BUTTON_DEFAULT_SIZE : _d, iconLeft = props.iconLeft, iconRight = props.iconRight, loading = props.loading, children = props.children, disabled = props.disabled, className = props.className, fullWidth = props.fullWidth, onClick = props.onClick, other = __rest(props, ["as", "variant", "color", "size", "iconLeft", "iconRight", "loading", "children", "disabled", "className", "fullWidth", "onClick"]);
32
33
  var iconSize = getIconSizeToFormElement(size);
33
34
  var handleClick = function (event) {
34
35
  if (onClick && !disabled && !loading) {
35
36
  onClick(event);
36
37
  }
37
38
  };
39
+ var renderIcon = function (content) {
40
+ return renderContent({
41
+ content: content,
42
+ props: {
43
+ size: getIconSizeToFormElement(size),
44
+ },
45
+ });
46
+ };
38
47
  var isInteractionPrevented = disabled || loading;
39
48
  var childContent = (React.createElement(React.Fragment, null,
40
49
  React.createElement("span", { className: cnButton('Label') },
41
- IconLeft && React.createElement(IconLeft, { size: iconSize }),
50
+ renderIcon(iconLeft),
42
51
  children,
43
- IconRight && React.createElement(IconRight, { size: iconSize })),
52
+ renderIcon(iconRight)),
44
53
  React.createElement(CSSTransition, { in: loading, timeout: 120, classNames: cnButton('Loader', { animation: true }), unmountOnExit: true },
45
54
  React.createElement(Loader, { size: iconSize, color: "var(--color-content-disabled)", className: cnButton('Loader') }))));
46
55
  return (React.createElement(Tag, __assign({ disabled: isInteractionPrevented, onClick: handleClick, type: "button", className: cnButton({
@@ -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';
@@ -158,6 +158,24 @@
158
158
  .Grid_rowGap_8xl {
159
159
  grid-row-gap: var(--space-8xl);
160
160
  }
161
+ .Grid_align_start {
162
+ align-items: start;
163
+ }
164
+ .Grid_align_end {
165
+ align-items: end;
166
+ }
167
+ .Grid_align_center {
168
+ align-items: center;
169
+ }
170
+ .Grid_justify_start {
171
+ justify-items: start;
172
+ }
173
+ .Grid_justify_end {
174
+ justify-items: end;
175
+ }
176
+ .Grid_justify_center {
177
+ justify-items: center;
178
+ }
161
179
  @media (min-width: 0) {
162
180
  .Grid_gap_xs_0 {
163
181
  grid-gap: 0;
@@ -5,6 +5,10 @@ export declare const gridColsVariant: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1
5
5
  export type GridColsVariant = (typeof gridColsVariant)[number];
6
6
  export declare const gridGapVariant: readonly ["0", "xs", "s", "m", "l", "xl", "2xl", "3xl", "4xl", "5xl", "6xl", "7xl", "8xl"];
7
7
  export type GridGapVariant = (typeof gridGapVariant)[number];
8
+ export declare const gridAlignVariant: readonly ["start", "end", "center"];
9
+ export declare const gridJustifyVariant: readonly ["start", "end", "center"];
10
+ export type GridAlignVariant = (typeof gridAlignVariant)[number];
11
+ export type GridJustifyVariant = (typeof gridJustifyVariant)[number];
8
12
  export declare const cnGrid: import("@bem-react/classname").ClassNameFormatter;
9
13
  export type GridProps = {
10
14
  /** Количество колонок в сетке */
@@ -15,6 +19,10 @@ export type GridProps = {
15
19
  colGap?: ResponsiveValue<GridGapVariant>;
16
20
  /** Отступы вокруг строки */
17
21
  rowGap?: ResponsiveValue<GridGapVariant>;
22
+ /** Выравнивание */
23
+ align?: GridAlignVariant;
24
+ /** Пространство между элементами */
25
+ justify?: GridJustifyVariant;
18
26
  /** Содержимое компонента */
19
27
  children?: ReactNode;
20
28
  /** Дополнительные СSS-классы */
@@ -23,13 +23,22 @@ export var gridGapVariant = [
23
23
  '7xl',
24
24
  '8xl',
25
25
  ];
26
+ export var gridAlignVariant = ['start', 'end', 'center'];
27
+ export var gridJustifyVariant = ['start', 'end', 'center'];
26
28
  export var cnGrid = cn('Grid');
27
29
  export var Grid = polymorphicComponentWithRef(function (inProps, ref) {
28
30
  var props = useThemeProps({
29
31
  props: inProps,
30
32
  name: 'Grid',
31
33
  });
32
- var _a = props.cols, cols = _a === void 0 ? GRID_DEFAULT_COLS : _a, _b = props.gap, gap = _b === void 0 ? GRID_DEFAULT_GAP : _b, _c = props.as, Tag = _c === void 0 ? GRID_DEFAULT_TAG : _c, colGap = props.colGap, rowGap = props.rowGap, children = props.children, className = props.className, other = __rest(props, ["cols", "gap", "as", "colGap", "rowGap", "children", "className"]);
33
- return (React.createElement(Tag, __assign({ className: classnames(cnGrid({}), useGenerateGridModsCn(cnGrid, { cols: cols, gap: gap, colGap: colGap, rowGap: rowGap }), className) }, other, { ref: ref }), children));
34
+ var _a = props.cols, cols = _a === void 0 ? GRID_DEFAULT_COLS : _a, _b = props.gap, gap = _b === void 0 ? GRID_DEFAULT_GAP : _b, _c = props.as, Tag = _c === void 0 ? GRID_DEFAULT_TAG : _c, colGap = props.colGap, rowGap = props.rowGap, align = props.align, justify = props.justify, children = props.children, className = props.className, other = __rest(props, ["cols", "gap", "as", "colGap", "rowGap", "align", "justify", "children", "className"]);
35
+ return (React.createElement(Tag, __assign({ className: classnames(cnGrid({}), useGenerateGridModsCn(cnGrid, {
36
+ cols: cols,
37
+ gap: gap,
38
+ colGap: colGap,
39
+ rowGap: rowGap,
40
+ align: align,
41
+ justify: justify,
42
+ }), className) }, other, { ref: ref }), children));
34
43
  });
35
44
  Grid.displayName = 'Grid';
@@ -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();
@@ -1,7 +1,12 @@
1
- .TableRow_hover:hover {
1
+ .TableRow {
2
+ transition: background-color var(--transition-slow);
3
+ }
4
+
5
+ .TableRow_hover:hover {
2
6
  outline: none;
3
7
  background-color: var(--color-background-primary-hover);
4
8
  }
9
+
5
10
  .TableRow_hover:active,
6
11
  .TableRow_selected {
7
12
  outline: none;
@@ -29,7 +29,7 @@
29
29
  --color-content-primary-inverse: #fff;
30
30
  --color-content-accent-main: #a0a0a0;
31
31
  --color-accent-main: #181818;
32
- --color-content-accent-primary: #fff;
32
+ --color-content-accent-primary: #dcdcdc;
33
33
  --color-accent-primary: #282828;
34
34
  --color-content-accent-disabled: #606060;
35
35
  --color-background-main: #fff;
@@ -124,7 +124,7 @@
124
124
  --color-accent-tertiary-pressed: #686868;
125
125
  --color-accent-disabled: #484848;
126
126
  --color-accent-secondary-inverse: #808080;
127
- --color-accent-main-inverse: #fff;
127
+ --color-accent-main-inverse: #dcdcdc;
128
128
  --color-additional-a1: #0b6abe;
129
129
  --color-additional-a2: #1899e9;
130
130
  --color-additional-a3: #b3f1ff;
@@ -30,7 +30,7 @@
30
30
  --color-background-main-inverse: #f5f5f5;
31
31
  --color-content-accent-main: #a0a0a0;
32
32
  --color-accent-main: #181818;
33
- --color-content-accent-primary: #fff;
33
+ --color-content-accent-primary: #dcdcdc;
34
34
  --color-accent-primary: #282828;
35
35
  --color-content-accent-disabled: #606060;
36
36
  --color-background-main-hover: #2c2c2c;
@@ -29,7 +29,7 @@
29
29
  --color-content-primary-inverse: #fff;
30
30
  --color-content-accent-main: #a0a0a0;
31
31
  --color-accent-main: #181818;
32
- --color-content-accent-primary: #fff;
32
+ --color-content-accent-primary: #dcdcdc;
33
33
  --color-accent-primary: #282828;
34
34
  --color-content-accent-disabled: #606060;
35
35
  --color-background-main: #fff;
@@ -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.20.0",
4
4
  "description": "React component library",
5
5
  "files": [
6
6
  "*"