@ozen-ui/kit 0.13.4 → 0.14.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.
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import './FieldIcon.css';
|
|
2
|
-
import type { ComponentPropsWithRef, ComponentRef, FC } from 'react';
|
|
2
|
+
import type { ComponentPropsWithRef, ComponentRef, FC, ReactElement } 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
6
|
export declare const FIELD_ICON_DEFAULT_TAG = "div";
|
|
7
7
|
export type FieldIconRef = ComponentRef<typeof FIELD_ICON_DEFAULT_TAG>;
|
|
8
8
|
export type FieldIconProps = ComponentPropsWithRef<typeof FIELD_ICON_DEFAULT_TAG> & {
|
|
9
|
-
icon?: string |
|
|
9
|
+
icon?: string | ReactElement<IconProps & {
|
|
10
10
|
size?: IconSize;
|
|
11
|
-
}> |
|
|
11
|
+
}> | (() => ReactElement<IconProps & {
|
|
12
|
+
size?: IconSize;
|
|
13
|
+
}>) | FC<IconProps & {
|
|
14
|
+
size?: IconSize;
|
|
15
|
+
}>;
|
|
12
16
|
size?: FormElementSizeVariant;
|
|
13
17
|
children?: never;
|
|
14
18
|
};
|
|
@@ -10,11 +10,21 @@ var getIconSizeToFormElement_1 = require("../../utils/getIconSizeToFormElement")
|
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
// TODO: взять за основу для всех рендер-функций
|
|
14
|
+
var resolveChildren = function (content, size) {
|
|
15
|
+
if (typeof content === 'string') {
|
|
16
|
+
return content;
|
|
16
17
|
}
|
|
17
|
-
if ((0, react_is_1.
|
|
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;
|
|
18
28
|
return react_1.default.createElement(Content, { size: size && (0, getIconSizeToFormElement_1.getIconSizeToFormElement)(size) });
|
|
19
29
|
}
|
|
20
30
|
return null;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import './FieldIcon.css';
|
|
2
|
-
import type { ComponentPropsWithRef, ComponentRef, FC } from 'react';
|
|
2
|
+
import type { ComponentPropsWithRef, ComponentRef, FC, ReactElement } 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
6
|
export declare const FIELD_ICON_DEFAULT_TAG = "div";
|
|
7
7
|
export type FieldIconRef = ComponentRef<typeof FIELD_ICON_DEFAULT_TAG>;
|
|
8
8
|
export type FieldIconProps = ComponentPropsWithRef<typeof FIELD_ICON_DEFAULT_TAG> & {
|
|
9
|
-
icon?: string |
|
|
9
|
+
icon?: string | ReactElement<IconProps & {
|
|
10
10
|
size?: IconSize;
|
|
11
|
-
}> |
|
|
11
|
+
}> | (() => ReactElement<IconProps & {
|
|
12
|
+
size?: IconSize;
|
|
13
|
+
}>) | FC<IconProps & {
|
|
14
|
+
size?: IconSize;
|
|
15
|
+
}>;
|
|
12
16
|
size?: FormElementSizeVariant;
|
|
13
17
|
children?: never;
|
|
14
18
|
};
|
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
import { __assign, __read, __rest } from "tslib";
|
|
2
2
|
import './FieldIcon.css';
|
|
3
3
|
import React, { forwardRef, useContext } from 'react';
|
|
4
|
-
import { isValidElementType } from 'react-is';
|
|
4
|
+
import { isValidElementType, isElement } from 'react-is';
|
|
5
5
|
import { cn } from '../../utils/classname';
|
|
6
6
|
import { getIconSizeToFormElement } from '../../utils/getIconSizeToFormElement';
|
|
7
7
|
import { FieldControlContext } from '../FieldControl';
|
|
8
8
|
export var FIELD_ICON_DEFAULT_TAG = 'div';
|
|
9
9
|
export var cnFieldIcon = cn('FieldIcon');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
// TODO: взять за основу для всех рендер-функций
|
|
11
|
+
var resolveChildren = function (content, size) {
|
|
12
|
+
if (typeof content === 'string') {
|
|
13
|
+
return content;
|
|
13
14
|
}
|
|
14
|
-
if (
|
|
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;
|
|
15
25
|
return React.createElement(Content, { size: size && getIconSizeToFormElement(size) });
|
|
16
26
|
}
|
|
17
27
|
return null;
|