@ssa-ui-kit/core 0.0.12-alpha → 0.0.13-alpha

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssa-ui-kit/core",
3
- "version": "0.0.12-alpha",
3
+ "version": "0.0.13-alpha",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "private": false,
@@ -1,37 +1,44 @@
1
+ import React from 'react';
2
+ import { useMergeRefs } from '@floating-ui/react';
1
3
  import { callAll } from '@ssa-ui-kit/utils';
2
-
3
4
  import { TextareaProps } from './types';
4
5
  import { TextareaBase } from './TextareaBase';
5
6
 
6
- const Textarea = ({
7
- name,
8
- placeholder,
9
- register,
10
- validationSchema,
11
- disabled = false,
12
- rows = 10,
13
- setCountChar,
14
- maxLength,
15
- title,
16
- }: TextareaProps) => {
17
- if (!register) {
18
- throw new Error('Input component must be used within a Form component');
19
- }
7
+ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
8
+ function TextareaInner(
9
+ {
10
+ name,
11
+ placeholder,
12
+ validationSchema,
13
+ disabled = false,
14
+ rows = 10,
15
+ maxLength,
16
+ title,
17
+ register,
18
+ setCountChar,
19
+ }: TextareaProps,
20
+ ref?: React.ForwardedRef<HTMLTextAreaElement | null>,
21
+ ) {
22
+ if (!register) {
23
+ throw new Error('Input component must be used within a Form component');
24
+ }
20
25
 
21
- const { onChange, ...options } = register(name, validationSchema);
26
+ const { onChange, ...options } = register(name, validationSchema);
22
27
 
23
- return (
24
- <TextareaBase
25
- id={`formElement-${name}`}
26
- placeholder={placeholder}
27
- disabled={disabled}
28
- rows={rows}
29
- maxLength={maxLength}
30
- onChange={callAll(setCountChar, onChange)}
31
- title={title}
32
- {...options}
33
- />
34
- );
35
- };
28
+ return (
29
+ <TextareaBase
30
+ id={`formElement-${name}`}
31
+ placeholder={placeholder}
32
+ disabled={disabled}
33
+ rows={rows}
34
+ maxLength={maxLength}
35
+ onChange={callAll(setCountChar, onChange)}
36
+ title={title}
37
+ {...options}
38
+ ref={useMergeRefs([options.ref, ref])}
39
+ />
40
+ );
41
+ },
42
+ );
36
43
 
37
44
  export default Textarea;