Skip to content

Commit 97ee2a6

Browse files
committed
fix: added typescript types to fluidTextArea and FluidTextAreaSkeleton
1 parent 2e82ab9 commit 97ee2a6

File tree

4 files changed

+165
-36
lines changed

4 files changed

+165
-36
lines changed

packages/react/src/components/FluidTextArea/FluidTextArea.Skeleton.js

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import PropTypes from 'prop-types';
2+
import React from 'react';
3+
import classnames from 'classnames';
4+
import { usePrefix } from '../../internal/usePrefix';
5+
import { FormContext } from '../FluidForm/FormContext';
6+
7+
export interface FluidTextAreaSkeletonProps {
8+
/**
9+
* Specify an optional className to be applied to the outer FluidForm wrapper
10+
*/
11+
className?: string;
12+
}
13+
14+
function FluidTextAreaSkeleton({ className, ...other }) {
15+
const prefix = usePrefix();
16+
17+
const FluidTextAreaSkeleton: React.FC<FluidTextAreaSkeletonProps> = ({
18+
className,
19+
...other
20+
}) => {
21+
const prefix = usePrefix();
22+
23+
return (
24+
<FormContext.Provider value={{ isFluid: true }}>
25+
<div
26+
className={classnames(
27+
`${prefix}--form-item ${prefix}--text-area--fluid__skeleton`,
28+
className
29+
)}
30+
{...other}>
31+
<span className={`${prefix}--label ${prefix}--skeleton`} />
32+
<div className={`${prefix}--skeleton ${prefix}--text-area`} />
33+
</div>
34+
</FormContext.Provider>
35+
);
36+
};
37+
}
38+
39+
FluidTextAreaSkeleton.propTypes = {
40+
/**
41+
* Specify an optional className to be applied to the outer FluidForm wrapper
42+
*/
43+
className: PropTypes.string,
44+
};
45+
46+
export default FluidTextAreaSkeleton;

packages/react/src/components/FluidTextArea/FluidTextArea.js renamed to packages/react/src/components/FluidTextArea/FluidTextArea.tsx

Lines changed: 112 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,117 @@ import deprecate from '../../prop-types/deprecate';
1313
import { usePrefix } from '../../internal/usePrefix';
1414
import { FormContext } from '../FluidForm/FormContext';
1515

16-
function FluidTextArea({ className, ...other }) {
16+
export interface FluidTextAreaProps {
17+
/**
18+
* Provide a custom className that is applied directly to the underlying
19+
* `<textarea>` node
20+
*/
21+
className?: string;
22+
23+
/**
24+
* Specify the `cols` attribute for the underlying `<textarea>` node
25+
*/
26+
cols?: number;
27+
28+
/**
29+
* Optionally provide the default value of the `<textarea>`
30+
*/
31+
defaultValue?: string | number;
32+
33+
/**
34+
* Specify whether the control is disabled
35+
*/
36+
disabled?: boolean;
37+
38+
/**
39+
* Specify whether to display the character counter
40+
*/
41+
enableCounter?: boolean;
42+
43+
/**
44+
* Provide text that is used alongside the control label for additional help
45+
*/
46+
helperText?: React.ReactNode;
47+
48+
/**
49+
* Specify whether you want the underlying label to be visually hidden
50+
*/
51+
hideLabel?: boolean;
52+
53+
/**
54+
* Provide a unique identifier for the control
55+
*/
56+
id?: string;
57+
58+
/**
59+
* Specify whether the control is currently invalid
60+
*/
61+
invalid?: boolean;
62+
63+
/**
64+
* Provide the text that is displayed when the control is in an invalid state
65+
*/
66+
invalidText?: React.ReactNode;
67+
68+
/**
69+
* Provide the text that will be read by a screen reader when visiting this
70+
* control
71+
*/
72+
labelText: React.ReactNode;
73+
74+
/**
75+
* `true` to use the light version. For use on $ui-01 backgrounds only.
76+
* Don't use this to make tile background color same as container background color.
77+
*/
78+
light?: boolean;
79+
80+
/**
81+
* Max character count allowed for the textarea. This is needed in order for enableCounter to display
82+
*/
83+
maxCount?: number;
84+
85+
/**
86+
* Optionally provide an `onChange` handler that is called whenever `<textarea>`
87+
* is updated
88+
*/
89+
onChange?: React.ChangeEventHandler<HTMLTextAreaElement>;
90+
91+
/**
92+
* Optionally provide an `onClick` handler that is called whenever the
93+
* `<textarea>` is clicked
94+
*/
95+
onClick?: React.MouseEventHandler<HTMLTextAreaElement>;
96+
97+
/**
98+
* Specify the placeholder attribute for the `<textarea>`
99+
*/
100+
placeholder?: string;
101+
102+
/**
103+
* Specify the rows attribute for the `<textarea>`
104+
*/
105+
rows?: number;
106+
107+
/**
108+
* Provide the current value of the `<textarea>`
109+
*/
110+
value?: string | number;
111+
112+
/**
113+
* Specify whether the control is currently in warning state
114+
*/
115+
warn?: boolean;
116+
117+
/**
118+
* Provide the text that is displayed when the control is in warning state
119+
*/
120+
warnText?: React.ReactNode;
121+
}
122+
123+
const FluidTextArea: React.FC<FluidTextAreaProps> = ({
124+
className,
125+
...other
126+
}) => {
17127
const prefix = usePrefix();
18128
const classNames = classnames(`${prefix}--text-area--fluid`, className);
19129

@@ -22,7 +132,7 @@ function FluidTextArea({ className, ...other }) {
22132
<TextArea className={classNames} {...other} />
23133
</FormContext.Provider>
24134
);
25-
}
135+
};
26136

27137
FluidTextArea.propTypes = {
28138
/**

packages/react/src/components/FluidTextArea/index.js renamed to packages/react/src/components/FluidTextArea/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
*/
77

88
import FluidTextArea from './FluidTextArea';
9-
9+
import { type FluidTextAreaProps } from './FluidTextArea';
10+
import { type FluidTextAreaSkeletonProps } from './FluidTextArea.Skeleton';
1011
export default FluidTextArea;
11-
export { FluidTextArea };
12+
export {
13+
FluidTextArea,
14+
type FluidTextAreaProps,
15+
type FluidTextAreaSkeletonProps,
16+
};
1217
export { default as FluidTextAreaSkeleton } from './FluidTextArea.Skeleton';

0 commit comments

Comments
 (0)