mimir-ui-kit 1.15.2 → 1.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. package/dist/Input-BFFPzelg.js +228 -0
  2. package/dist/{ProgressBar-BekX41HR.js → ProgressBar-CwLwhaeM.js} +23 -23
  3. package/dist/assets/Accordion.css +1 -1
  4. package/dist/assets/AnchorLink.css +1 -0
  5. package/dist/assets/Input.css +1 -1
  6. package/dist/assets/OtpInput.css +1 -1
  7. package/dist/assets/ProgressBar2.css +1 -1
  8. package/dist/assets/TextArea.css +1 -0
  9. package/dist/components/Accordion/Accordion.d.ts +2 -1
  10. package/dist/components/Accordion/Accordion.js +79 -38
  11. package/dist/components/Accordion/constants.d.ts +9 -1
  12. package/dist/components/Accordion/constants.js +18 -6
  13. package/dist/components/AnchorLink/AnchorLink.d.ts +13 -0
  14. package/dist/components/AnchorLink/AnchorLink.js +69 -0
  15. package/dist/components/AnchorLink/constants.d.ts +10 -0
  16. package/dist/components/AnchorLink/constants.js +16 -0
  17. package/dist/components/AnchorLink/index.d.ts +2 -0
  18. package/dist/components/AnchorLink/index.js +7 -0
  19. package/dist/components/DatePicker/DatePicker.d.ts +1 -9
  20. package/dist/components/DatePicker/DatePicker.js +1 -1
  21. package/dist/components/Input/Input.d.ts +11 -27
  22. package/dist/components/Input/Input.js +9 -120
  23. package/dist/components/Input/index.d.ts +1 -1
  24. package/dist/components/Input/index.js +2 -2
  25. package/dist/components/Input/types.d.ts +11 -0
  26. package/dist/components/InputPassword/InputPassword.d.ts +1 -9
  27. package/dist/components/InputPassword/InputPassword.js +1 -1
  28. package/dist/components/InputPhoneNumber/InputPhoneNumber.d.ts +1 -9
  29. package/dist/components/InputPhoneNumber/InputPhoneNumber.js +1 -1
  30. package/dist/components/OtpInput/OtpInput.js +5 -5
  31. package/dist/components/SelectSearch/SelectSearch.js +1 -1
  32. package/dist/components/TextArea/TextArea.d.ts +5 -0
  33. package/dist/components/TextArea/TextArea.js +209 -0
  34. package/dist/components/TextArea/hooks.d.ts +1 -0
  35. package/dist/components/TextArea/hooks.js +13 -0
  36. package/dist/components/TextArea/index.d.ts +1 -0
  37. package/dist/components/TextArea/index.js +4 -0
  38. package/dist/components/TextArea/types.d.ts +3 -0
  39. package/dist/components/TextArea/types.js +1 -0
  40. package/dist/components/Toasts/ProgressBar.js +1 -1
  41. package/dist/components/Toasts/Toast.js +1 -1
  42. package/dist/components/Toasts/ToastList.js +1 -1
  43. package/dist/components/Toasts/ToastsProvider.js +1 -1
  44. package/dist/components/index.d.ts +3 -0
  45. package/dist/components/index.js +9 -2
  46. package/dist/hooks/index.d.ts +1 -0
  47. package/dist/hooks/index.js +2 -0
  48. package/dist/hooks/useMergeRefs/index.d.ts +1 -0
  49. package/dist/hooks/useMergeRefs/index.js +4 -0
  50. package/dist/hooks/useMergeRefs/useMergeRefs.d.ts +4 -0
  51. package/dist/hooks/useMergeRefs/useMergeRefs.js +28 -0
  52. package/dist/icons/Icon.d.ts +1 -2
  53. package/dist/icons/components/12px/Close12px.js +1 -1
  54. package/dist/icons/index.d.ts +1 -1
  55. package/dist/index.js +11 -2
  56. package/package.json +2 -3
@@ -0,0 +1,69 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { c as classNames } from "../../index-CweZ_OcN.js";
3
+ import { forwardRef } from "react";
4
+ import { ELinkSize, ELinkVariant } from "./constants.js";
5
+ import { Icon } from "../../icons/Icon.js";
6
+ import '../../assets/AnchorLink.css';const link = "_link_12t08_2";
7
+ const sample = "_sample_12t08_19";
8
+ const anchor = "_anchor_12t08_23";
9
+ const disabled = "_disabled_12t08_27";
10
+ const icon = "_icon_12t08_35";
11
+ const xs = "_xs_12t08_44";
12
+ const s = "_s_12t08_19";
13
+ const m = "_m_12t08_56";
14
+ const l = "_l_12t08_2";
15
+ const cls = {
16
+ link,
17
+ sample,
18
+ anchor,
19
+ disabled,
20
+ icon,
21
+ xs,
22
+ s,
23
+ m,
24
+ l
25
+ };
26
+ const Link = forwardRef(
27
+ ({
28
+ leftIcon,
29
+ className,
30
+ size = ELinkSize.L,
31
+ variant = ELinkVariant.ANCHOR,
32
+ rightIcon,
33
+ disabled: disabled2,
34
+ ...props
35
+ }, ref) => {
36
+ return /* @__PURE__ */ jsxs(
37
+ "button",
38
+ {
39
+ ref,
40
+ type: "button",
41
+ disabled: disabled2,
42
+ className: classNames(cls.link, className, cls[variant], cls[size], {
43
+ [cls.disabled]: disabled2
44
+ }),
45
+ ...props,
46
+ children: [
47
+ leftIcon && /* @__PURE__ */ jsx(
48
+ Icon,
49
+ {
50
+ ...leftIcon,
51
+ className: classNames(cls.icon, leftIcon.className)
52
+ }
53
+ ),
54
+ props.children,
55
+ rightIcon && /* @__PURE__ */ jsx(
56
+ Icon,
57
+ {
58
+ ...rightIcon,
59
+ className: classNames(cls.icon, rightIcon.className)
60
+ }
61
+ )
62
+ ]
63
+ }
64
+ );
65
+ }
66
+ );
67
+ export {
68
+ Link
69
+ };
@@ -0,0 +1,10 @@
1
+ export declare enum ELinkSize {
2
+ XS = "xs",
3
+ S = "s",
4
+ M = "m",
5
+ L = "l"
6
+ }
7
+ export declare enum ELinkVariant {
8
+ SAMPLE = "sample",
9
+ ANCHOR = "anchor"
10
+ }
@@ -0,0 +1,16 @@
1
+ var ELinkSize = /* @__PURE__ */ ((ELinkSize2) => {
2
+ ELinkSize2["XS"] = "xs";
3
+ ELinkSize2["S"] = "s";
4
+ ELinkSize2["M"] = "m";
5
+ ELinkSize2["L"] = "l";
6
+ return ELinkSize2;
7
+ })(ELinkSize || {});
8
+ var ELinkVariant = /* @__PURE__ */ ((ELinkVariant2) => {
9
+ ELinkVariant2["SAMPLE"] = "sample";
10
+ ELinkVariant2["ANCHOR"] = "anchor";
11
+ return ELinkVariant2;
12
+ })(ELinkVariant || {});
13
+ export {
14
+ ELinkSize,
15
+ ELinkVariant
16
+ };
@@ -0,0 +1,2 @@
1
+ export { Link } from './AnchorLink';
2
+ export { ELinkSize, ELinkVariant } from './constants';
@@ -0,0 +1,7 @@
1
+ import { Link } from "./AnchorLink.js";
2
+ import { ELinkSize, ELinkVariant } from "./constants.js";
3
+ export {
4
+ ELinkSize,
5
+ ELinkVariant,
6
+ Link
7
+ };
@@ -33,12 +33,4 @@ export declare const DatePicker: import('react').MemoExoticComponent<import('rea
33
33
  * значение из стейта (data)
34
34
  */
35
35
  value?: string;
36
- } & import('../Input/types').TInputProps & {
37
- size?: import('../Input').TSize;
38
- variant?: import('../Input').TVariant;
39
- className?: string;
40
- wrapperClassName?: string;
41
- label?: import('react').ReactNode;
42
- autofocus?: boolean;
43
- readonly?: boolean;
44
- } & import('react').RefAttributes<HTMLInputElement>>>;
36
+ } & import('../Input/types').TInputProps & import('../Input').TAdditionalProps & import('react').RefAttributes<HTMLInputElement>>>;
@@ -5,7 +5,7 @@ import { c as cls, D as DatePickerModal } from "../../DatePickerModal-BM0BgzTb.j
5
5
  import { useClickOutside } from "../../hooks/useClickOutside/useClickOutside.js";
6
6
  import { formating } from "../../utils/index.js";
7
7
  import { Button } from "../Button/Button.js";
8
- import { Input } from "../Input/Input.js";
8
+ import { I as Input } from "../../Input-BFFPzelg.js";
9
9
  const DatePicker = memo(
10
10
  forwardRef(
11
11
  ({ size, value, onChangeValue, name, before, ...props }, ref) => {
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
- import { TInputProps, TSize, TVariant } from './types';
2
+ import { TInputProps, TAddon, TIconAddon, TSize, TVariant } from './types';
3
3
 
4
- export type TProps = TInputProps & {
4
+ export type TAdditionalProps = {
5
5
  /**
6
6
  * Размер ввода.
7
7
  */
@@ -30,34 +30,18 @@ export type TProps = TInputProps & {
30
30
  * Сделать ввод только для чтения.
31
31
  */
32
32
  readonly?: boolean;
33
- };
34
- export declare const Input: import('react').MemoExoticComponent<import('react').ForwardRefExoticComponent<TInputProps & {
35
- /**
36
- * Размер ввода.
37
- */
38
- size?: TSize;
39
- /**
40
- * `Варианты отображения ввода. Может быть 'alert', 'success', 'default', 'default-gray', 'default-white'.`
41
- */
42
- variant?: TVariant;
43
- /**
44
- * Дополнительный класс.
45
- */
46
- className?: string;
47
- /**
48
- * Дополнительный класс для обертки поля ввода.
49
- */
50
- wrapperClassName?: string;
51
33
  /**
52
- * Текстовое описание поля ввода.
34
+ * Дополнительный слот справа.
53
35
  */
54
- label?: ReactNode;
36
+ rightAddon?: TAddon;
55
37
  /**
56
- * Автоматически фокусировать ввод при монтировании.
38
+ * Дополнительный слот слева.
57
39
  */
58
- autofocus?: boolean;
40
+ leftAddon?: TIconAddon;
59
41
  /**
60
- * Сделать ввод только для чтения.
42
+ * Флаг, показывающий наличие кнопки очистки.
61
43
  */
62
- readonly?: boolean;
63
- } & import('react').RefAttributes<HTMLInputElement>>>;
44
+ withClearButton?: boolean;
45
+ };
46
+ export type TProps = TInputProps & TAdditionalProps;
47
+ export declare const Input: import('react').MemoExoticComponent<import('react').ForwardRefExoticComponent<TInputProps & TAdditionalProps & import('react').RefAttributes<HTMLInputElement>>>;
@@ -1,122 +1,11 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { c as classNames } from "../../index-CweZ_OcN.js";
3
- import { memo, forwardRef, useState, useEffect } from "react";
4
- import { EInputVariant } from "./constants.js";
5
- import '../../assets/Input.css';const label = "_label_1sn09_5";
6
- const input = "_input_1sn09_2";
7
- const s = "_s_1sn09_61";
8
- const m = "_m_1sn09_73";
9
- const l = "_l_1sn09_5";
10
- const success = "_success_1sn09_124";
11
- const alarm = "_alarm_1sn09_142";
12
- const error = "_error_1sn09_160";
13
- const disabled = "_disabled_1sn09_178";
14
- const cls = {
15
- "input-wrapper": "_input-wrapper_1sn09_2",
16
- label,
17
- "active-label": "_active-label_1sn09_18",
18
- input,
19
- s,
20
- m,
21
- l,
22
- "default-gray": "_default-gray_1sn09_97",
23
- "default-white": "_default-white_1sn09_109",
24
- success,
25
- alarm,
26
- error,
27
- disabled,
28
- "has-label": "_has-label_1sn09_198"
29
- };
30
- const Input = memo(
31
- forwardRef(
32
- (props, ref) => {
33
- const {
34
- value,
35
- className,
36
- wrapperClassName,
37
- variant = EInputVariant.DefaultGray,
38
- type = "text",
39
- autofocus,
40
- readonly,
41
- id,
42
- onFocus,
43
- onBlur,
44
- label: label2,
45
- disabled: disabled2,
46
- size = "m",
47
- ...otherProps
48
- } = props;
49
- const [isFocused, setIsFocused] = useState(autofocus);
50
- useEffect(() => {
51
- if (autofocus) {
52
- setIsFocused(true);
53
- }
54
- }, [autofocus]);
55
- const handleBlur = (event) => {
56
- const currentValue = event.currentTarget.value;
57
- onBlur == null ? void 0 : onBlur(event);
58
- if (currentValue) {
59
- return;
60
- }
61
- setIsFocused(false);
62
- };
63
- const handleFocus = (event) => {
64
- if (readonly) {
65
- return;
66
- }
67
- setIsFocused(true);
68
- onFocus == null ? void 0 : onFocus(event);
69
- };
70
- const mods = {
71
- [cls.readonly]: disabled2 || readonly,
72
- [cls.focused]: isFocused,
73
- [cls.disabled]: disabled2 || readonly,
74
- [cls["has-label"]]: !!label2
75
- };
76
- const labelClassNames = classNames(
77
- cls.label,
78
- {
79
- [cls["active-label"]]: isFocused || value,
80
- [cls.disabled]: disabled2 || readonly
81
- },
82
- className,
83
- cls[size]
84
- );
85
- const inputClassNames = classNames(cls.input, mods, className, [
86
- cls[variant],
87
- cls[size]
88
- ]);
89
- return /* @__PURE__ */ jsxs(
90
- "div",
91
- {
92
- className: classNames(
93
- cls["input-wrapper"],
94
- cls[variant],
95
- wrapperClassName
96
- ),
97
- children: [
98
- label2 && /* @__PURE__ */ jsx("label", { htmlFor: id, className: labelClassNames, children: label2 }),
99
- /* @__PURE__ */ jsx(
100
- "input",
101
- {
102
- ref,
103
- type,
104
- id,
105
- className: inputClassNames,
106
- onFocus: handleFocus,
107
- onBlur: handleBlur,
108
- readOnly: readonly,
109
- value: value || "",
110
- ...otherProps
111
- }
112
- )
113
- ]
114
- }
115
- );
116
- }
117
- )
118
- );
119
- Input.displayName = "Input";
1
+ import "react/jsx-runtime";
2
+ import "../../index-CweZ_OcN.js";
3
+ import "react";
4
+ import "./constants.js";
5
+ import { I } from "../../Input-BFFPzelg.js";
6
+ import "../../hooks/useMergeRefs/useMergeRefs.js";
7
+ import "../../icons/Icon.js";
8
+ import "../Button/Button.js";
120
9
  export {
121
- Input
10
+ I as Input
122
11
  };
@@ -1,3 +1,3 @@
1
- export { Input, type TProps as TInputProps } from './Input';
1
+ export { Input, type TProps as TInputProps, type TAdditionalProps } from './Input';
2
2
  export type { TSize, TVariant } from './types';
3
3
  export { EInputSize, EInputVariant } from './constants';
@@ -1,7 +1,7 @@
1
- import { Input } from "./Input.js";
1
+ import { I } from "../../Input-BFFPzelg.js";
2
2
  import { EInputSize, EInputVariant } from "./constants.js";
3
3
  export {
4
4
  EInputSize,
5
5
  EInputVariant,
6
- Input
6
+ I as Input
7
7
  };
@@ -1,5 +1,6 @@
1
1
  import { InputHTMLAttributes } from 'react';
2
2
  import { EInputSize, EInputVariant } from './constants';
3
+ import { TIcon } from '../../icons';
3
4
 
4
5
  export type TSize = `${EInputSize}` | EInputSize;
5
6
  export type TVariant = `${EInputVariant}` | EInputVariant;
@@ -8,4 +9,14 @@ export type TCommonCompoundInputProps = {
8
9
  variant?: TVariant;
9
10
  className?: string;
10
11
  };
12
+ type TTextAddon = {
13
+ addonType?: 'text';
14
+ addonContent?: string;
15
+ };
16
+ export type TIconAddon = {
17
+ addonType?: 'icon';
18
+ addonContent: TIcon;
19
+ };
20
+ export type TAddon = TTextAddon | TIconAddon;
11
21
  export type TInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'readOnly' | 'size' | 'placeholder'>;
22
+ export {};
@@ -1,12 +1,4 @@
1
1
  import { TInputProps } from '../Input';
2
2
 
3
3
  export type TProps = TInputProps;
4
- export declare const InputPassword: import('react').MemoExoticComponent<import('react').ForwardRefExoticComponent<import('../Input/types').TInputProps & {
5
- size?: import('../Input').TSize;
6
- variant?: import('../Input').TVariant;
7
- className?: string;
8
- wrapperClassName?: string;
9
- label?: import('react').ReactNode;
10
- autofocus?: boolean;
11
- readonly?: boolean;
12
- } & import('react').RefAttributes<HTMLInputElement>>>;
4
+ export declare const InputPassword: import('react').MemoExoticComponent<import('react').ForwardRefExoticComponent<import('../Input/types').TInputProps & import('../Input').TAdditionalProps & import('react').RefAttributes<HTMLInputElement>>>;
@@ -2,7 +2,7 @@ import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { memo, forwardRef, useState } from "react";
3
3
  import { Icon } from "../../icons/Icon.js";
4
4
  import { Button } from "../Button/Button.js";
5
- import { Input } from "../Input/Input.js";
5
+ import { I as Input } from "../../Input-BFFPzelg.js";
6
6
  import '../../assets/InputPassword.css';const input = "_input_mam1g_2";
7
7
  const wrapper = "_wrapper_mam1g_6";
8
8
  const button = "_button_mam1g_17";
@@ -1,12 +1,4 @@
1
1
  export type ImperativeHandle = Partial<HTMLInputElement> & {
2
2
  getPhoneNumber: () => string;
3
3
  };
4
- export declare const InputPhoneNumber: import('react').MemoExoticComponent<import('react').ForwardRefExoticComponent<import('../Input/types').TInputProps & {
5
- size?: import('../Input').TSize;
6
- variant?: import('../Input').TVariant;
7
- className?: string;
8
- wrapperClassName?: string;
9
- label?: import('react').ReactNode;
10
- autofocus?: boolean;
11
- readonly?: boolean;
12
- } & import('react').RefAttributes<HTMLInputElement>>>;
4
+ export declare const InputPhoneNumber: import('react').MemoExoticComponent<import('react').ForwardRefExoticComponent<import('../Input/types').TInputProps & import('../Input').TAdditionalProps & import('react').RefAttributes<HTMLInputElement>>>;
@@ -1,7 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { memo, forwardRef, useState, useCallback, useImperativeHandle } from "react";
3
3
  import { getMaskedInputPhoneValue, getUnmaskedInputValue } from "./utils.js";
4
- import { Input } from "../Input/Input.js";
4
+ import { I as Input } from "../../Input-BFFPzelg.js";
5
5
  const InputPhoneNumber = memo(
6
6
  forwardRef(
7
7
  ({ value = "", onChange, ...props }, ref) => {
@@ -3,13 +3,13 @@ import { c as classNames } from "../../index-CweZ_OcN.js";
3
3
  import { forwardRef, useImperativeHandle, Fragment } from "react";
4
4
  import { ITEMS_PER_SEPARATOR, DEFAULT_VALUE_LENGTH } from "./constants.js";
5
5
  import { useOTPInput } from "./hooks.js";
6
- import { Input } from "../Input/Input.js";
7
- import '../../assets/OtpInput.css';const otp = "_otp_1005h_3";
8
- const input = "_input_1005h_15";
9
- const separator = "_separator_1005h_29";
6
+ import { I as Input } from "../../Input-BFFPzelg.js";
7
+ import '../../assets/OtpInput.css';const otp = "_otp_196ev_3";
8
+ const input = "_input_196ev_14";
9
+ const separator = "_separator_196ev_28";
10
10
  const cls = {
11
11
  otp,
12
- "input-wrapper": "_input-wrapper_1005h_15",
12
+ "input-wrapper": "_input-wrapper_196ev_14",
13
13
  input,
14
14
  separator
15
15
  };
@@ -4,7 +4,7 @@ import * as React from "react";
4
4
  import React__default, { useReducer, useMemo, useSyncExternalStore, useId as useId$1, useEffect, useCallback, useRef, useLayoutEffect, createContext, useContext, useState, Fragment, createRef, forwardRef } from "react";
5
5
  import { ESelectSearchSize } from "./constants.js";
6
6
  import { Icon } from "../../icons/Icon.js";
7
- import { Input } from "../Input/Input.js";
7
+ import { I as Input } from "../../Input-BFFPzelg.js";
8
8
  import { EInputSize } from "../Input/constants.js";
9
9
  import { n as n$2, u as u$3, d as o$1, s as s$3, o as o$2, p as p$1, t as t$3, e as s$4, W as W$1, y as y$3, T, H, M as M$1, a as u$5, $ as $f7dceffc5ad7768b$export$4e328f61c538687f, b as $6179b936705e76d3$export$ae780daf29e6d456, D as D$2, c as o$3 } from "../../keyboard-B256ZoM-.js";
10
10
  import * as ReactDOM from "react-dom";
@@ -0,0 +1,5 @@
1
+ import { TTextAreaProps } from './types';
2
+ import { TAdditionalProps } from '../Input';
3
+
4
+ export type TProps = TAdditionalProps & TTextAreaProps;
5
+ export declare const TextArea: import('react').MemoExoticComponent<import('react').ForwardRefExoticComponent<TAdditionalProps & TTextAreaProps & import('react').RefAttributes<HTMLTextAreaElement>>>;
@@ -0,0 +1,209 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { c as classNames } from "../../index-CweZ_OcN.js";
3
+ import { memo, forwardRef, useState, useRef, useEffect } from "react";
4
+ import { useAutoResizeTextArea } from "./hooks.js";
5
+ import { useMergeRefs } from "../../hooks/useMergeRefs/useMergeRefs.js";
6
+ import { Icon } from "../../icons/Icon.js";
7
+ import { Button } from "../Button/Button.js";
8
+ import { c as cls } from "../../Input-BFFPzelg.js";
9
+ import { EInputVariant } from "../Input/constants.js";
10
+ import '../../assets/TextArea.css';const textarea = "_textarea_46c4k_2";
11
+ const s = "_s_46c4k_6";
12
+ const m = "_m_46c4k_11";
13
+ const l = "_l_46c4k_16";
14
+ const textareaCls = {
15
+ textarea,
16
+ s,
17
+ m,
18
+ l,
19
+ "has-label": "_has-label_46c4k_21"
20
+ };
21
+ const renderAddon = (addon) => {
22
+ var _a, _b;
23
+ if (!addon) {
24
+ return null;
25
+ }
26
+ switch (addon.addonType) {
27
+ case "icon": {
28
+ const is16px = (_a = addon.addonContent) == null ? void 0 : _a.includes("16px");
29
+ const is24px = (_b = addon.addonContent) == null ? void 0 : _b.includes("24px");
30
+ return /* @__PURE__ */ jsx(
31
+ Icon,
32
+ {
33
+ style: {
34
+ ["--icon-size"]: classNames({
35
+ "16px": is16px,
36
+ "24px": is24px
37
+ })
38
+ },
39
+ className: cls["addon-icon"],
40
+ iconName: addon.addonContent
41
+ }
42
+ );
43
+ }
44
+ case "text": {
45
+ return addon.addonContent;
46
+ }
47
+ default: {
48
+ return null;
49
+ }
50
+ }
51
+ };
52
+ const TextArea = memo(
53
+ forwardRef(
54
+ (props, ref) => {
55
+ const {
56
+ value,
57
+ className,
58
+ wrapperClassName,
59
+ variant = EInputVariant.DefaultGray,
60
+ autofocus,
61
+ readonly,
62
+ id,
63
+ onFocus,
64
+ onBlur,
65
+ label,
66
+ withClearButton,
67
+ disabled,
68
+ rightAddon,
69
+ leftAddon,
70
+ size = "m",
71
+ ...otherProps
72
+ } = props;
73
+ const [isFocused, setIsFocused] = useState(autofocus);
74
+ const [withValue, setWithValue] = useState(!!value);
75
+ const inputRef = useRef(null);
76
+ const mergedInputRef = useMergeRefs(inputRef, ref);
77
+ useEffect(() => {
78
+ if (autofocus) {
79
+ setIsFocused(true);
80
+ }
81
+ }, [autofocus]);
82
+ const handleResize = useAutoResizeTextArea(inputRef.current);
83
+ const handleBlur = (event) => {
84
+ const currentValue = event.currentTarget.value;
85
+ onBlur == null ? void 0 : onBlur(event);
86
+ if (currentValue) {
87
+ return;
88
+ }
89
+ setIsFocused(false);
90
+ };
91
+ const handleFocus = (event) => {
92
+ if (readonly) {
93
+ return;
94
+ }
95
+ setIsFocused(true);
96
+ onFocus == null ? void 0 : onFocus(event);
97
+ };
98
+ const handleClear = () => {
99
+ if (inputRef == null ? void 0 : inputRef.current) {
100
+ inputRef.current.value = "";
101
+ inputRef.current.focus();
102
+ setWithValue(false);
103
+ handleResize();
104
+ }
105
+ };
106
+ const handleChange = (event) => {
107
+ var _a;
108
+ const targetValue = event.target.value;
109
+ setWithValue(!!targetValue);
110
+ handleResize();
111
+ (_a = otherProps == null ? void 0 : otherProps.onChange) == null ? void 0 : _a.call(otherProps, event);
112
+ };
113
+ const currentLeftAddon = renderAddon(leftAddon);
114
+ const currentRightAddon = renderAddon(rightAddon);
115
+ const mods = {
116
+ [cls.readonly]: disabled || readonly,
117
+ [cls.focused]: isFocused || withValue,
118
+ [cls.disabled]: disabled || readonly,
119
+ [cls["has-left-slot"]]: !!currentLeftAddon,
120
+ [cls["has-right-slot"]]: !!currentRightAddon,
121
+ [textareaCls["has-label"]]: !!label
122
+ };
123
+ const labelClassNames = classNames(
124
+ cls.label,
125
+ {
126
+ [cls["active-label"]]: isFocused || value,
127
+ [cls.disabled]: disabled || readonly,
128
+ [cls["has-left-slot"]]: !!currentLeftAddon
129
+ },
130
+ className,
131
+ cls[size]
132
+ );
133
+ const inputClassNames = classNames(
134
+ textareaCls.textarea,
135
+ cls.input,
136
+ mods,
137
+ className,
138
+ [cls[variant], textareaCls[size], cls[size]]
139
+ );
140
+ return /* @__PURE__ */ jsxs(
141
+ "div",
142
+ {
143
+ className: classNames(
144
+ cls["input-wrapper"],
145
+ cls[variant],
146
+ textareaCls[size],
147
+ cls[size],
148
+ { [cls.focused]: isFocused || withValue },
149
+ wrapperClassName
150
+ ),
151
+ children: [
152
+ label && /* @__PURE__ */ jsx("label", { htmlFor: id, className: labelClassNames, children: label }),
153
+ currentLeftAddon && /* @__PURE__ */ jsx(
154
+ "span",
155
+ {
156
+ className: classNames(cls["left-slot"], {
157
+ [cls.focused]: isFocused,
158
+ [cls["has-label"]]: !!label
159
+ }),
160
+ children: currentLeftAddon
161
+ }
162
+ ),
163
+ /* @__PURE__ */ jsx(
164
+ "textarea",
165
+ {
166
+ ref: mergedInputRef,
167
+ id,
168
+ className: inputClassNames,
169
+ onFocus: handleFocus,
170
+ onBlur: handleBlur,
171
+ readOnly: readonly,
172
+ value,
173
+ onChange: handleChange,
174
+ ...otherProps
175
+ }
176
+ ),
177
+ currentRightAddon && /* @__PURE__ */ jsx(
178
+ "span",
179
+ {
180
+ className: classNames(cls["right-slot"], {
181
+ [cls.focused]: isFocused,
182
+ [cls["has-label"]]: !!label
183
+ }),
184
+ children: currentRightAddon
185
+ }
186
+ ),
187
+ withClearButton && withValue && /* @__PURE__ */ jsx(
188
+ Button,
189
+ {
190
+ tabIndex: -1,
191
+ className: cls.clear,
192
+ isIconButton: true,
193
+ iconName: "Close16px",
194
+ size: "m-s",
195
+ clear: true,
196
+ variant: "secondary-gray",
197
+ onClick: handleClear
198
+ }
199
+ )
200
+ ]
201
+ }
202
+ );
203
+ }
204
+ )
205
+ );
206
+ TextArea.displayName = "TextArea";
207
+ export {
208
+ TextArea
209
+ };
@@ -0,0 +1 @@
1
+ export declare const useAutoResizeTextArea: (textArea: HTMLTextAreaElement | null) => () => void;
@@ -0,0 +1,13 @@
1
+ import { useCallback } from "react";
2
+ const useAutoResizeTextArea = (textArea) => {
3
+ return useCallback(() => {
4
+ if (textArea) {
5
+ textArea.style.height = "var(--textarea-height)";
6
+ const scrollHeight = textArea.scrollHeight;
7
+ textArea.style.height = `${scrollHeight}px`;
8
+ }
9
+ }, [textArea]);
10
+ };
11
+ export {
12
+ useAutoResizeTextArea
13
+ };