@usefui/components 1.5.2 → 1.5.3
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/CHANGELOG.md +6 -0
- package/dist/index.d.mts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +41 -79
- package/dist/index.mjs +41 -79
- package/package.json +2 -2
- package/src/field/styles/index.ts +1 -0
- package/src/text-area/Textarea.stories.tsx +7 -2
- package/src/text-area/index.tsx +30 -14
- package/src/text-area/styles/index.ts +32 -72
- package/src/tooltip/index.tsx +4 -3
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1317,16 +1317,23 @@ type ScrollContainerProps = {
|
|
|
1317
1317
|
$trackColor?: string;
|
|
1318
1318
|
$thumbHoverColor?: string;
|
|
1319
1319
|
};
|
|
1320
|
-
interface TextareaProps extends React$1.TextareaHTMLAttributes<HTMLTextAreaElement>, IComponentStyling, IComponentVariant {
|
|
1320
|
+
interface TextareaProps extends React$1.TextareaHTMLAttributes<HTMLTextAreaElement>, IComponentStyling, IComponentSize, IComponentVariant {
|
|
1321
|
+
resizable?: boolean;
|
|
1322
|
+
shape?: "square" | "smooth";
|
|
1321
1323
|
}
|
|
1322
1324
|
/**
|
|
1323
1325
|
* Textarea are used to allow users to write large chunks of text.
|
|
1324
1326
|
*
|
|
1325
1327
|
* @param {TextareaProps} props - The props for the Textarea component.
|
|
1328
|
+
* @param {string} props.variant - The style definition used by the component. Defaults to `secondary`.
|
|
1329
|
+
* @param {TComponentShape} props.shape - The size of the component. Defaults to `smooth`.
|
|
1330
|
+
* @param {ComponentSizeEnum} props.sizing - The size of the component. Defaults to `medium`.
|
|
1331
|
+
* @param {boolean} props.resizable - Define whether the component is resizable or not. Defaults to 'true'.
|
|
1332
|
+
*
|
|
1326
1333
|
* @returns {ReactElement} The TextareaProps component.
|
|
1327
1334
|
*/
|
|
1328
1335
|
declare const Textarea: {
|
|
1329
|
-
(
|
|
1336
|
+
(props: TextareaProps): React$1.JSX.Element;
|
|
1330
1337
|
displayName: string;
|
|
1331
1338
|
};
|
|
1332
1339
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1317,16 +1317,23 @@ type ScrollContainerProps = {
|
|
|
1317
1317
|
$trackColor?: string;
|
|
1318
1318
|
$thumbHoverColor?: string;
|
|
1319
1319
|
};
|
|
1320
|
-
interface TextareaProps extends React$1.TextareaHTMLAttributes<HTMLTextAreaElement>, IComponentStyling, IComponentVariant {
|
|
1320
|
+
interface TextareaProps extends React$1.TextareaHTMLAttributes<HTMLTextAreaElement>, IComponentStyling, IComponentSize, IComponentVariant {
|
|
1321
|
+
resizable?: boolean;
|
|
1322
|
+
shape?: "square" | "smooth";
|
|
1321
1323
|
}
|
|
1322
1324
|
/**
|
|
1323
1325
|
* Textarea are used to allow users to write large chunks of text.
|
|
1324
1326
|
*
|
|
1325
1327
|
* @param {TextareaProps} props - The props for the Textarea component.
|
|
1328
|
+
* @param {string} props.variant - The style definition used by the component. Defaults to `secondary`.
|
|
1329
|
+
* @param {TComponentShape} props.shape - The size of the component. Defaults to `smooth`.
|
|
1330
|
+
* @param {ComponentSizeEnum} props.sizing - The size of the component. Defaults to `medium`.
|
|
1331
|
+
* @param {boolean} props.resizable - Define whether the component is resizable or not. Defaults to 'true'.
|
|
1332
|
+
*
|
|
1326
1333
|
* @returns {ReactElement} The TextareaProps component.
|
|
1327
1334
|
*/
|
|
1328
1335
|
declare const Textarea: {
|
|
1329
|
-
(
|
|
1336
|
+
(props: TextareaProps): React$1.JSX.Element;
|
|
1330
1337
|
displayName: string;
|
|
1331
1338
|
};
|
|
1332
1339
|
|
package/dist/index.js
CHANGED
|
@@ -2099,6 +2099,7 @@ var FieldDefaultStyles = import_styled_components10.css`
|
|
|
2099
2099
|
display: flex;
|
|
2100
2100
|
align-items: center;
|
|
2101
2101
|
justify-content: center;
|
|
2102
|
+
box-sizing: border-box;
|
|
2102
2103
|
|
|
2103
2104
|
font-size: var(--fontsize-medium-20);
|
|
2104
2105
|
|
|
@@ -3862,80 +3863,36 @@ var CustomScrollbar2 = import_styled_components23.css`
|
|
|
3862
3863
|
scrollbar-width: thin;
|
|
3863
3864
|
scrollbar-color: ${({ $thumbColor, $trackColor }) => `${$thumbColor ?? "var(--font-color-alpha-10)"} ${$trackColor ?? "transparent"}`};
|
|
3864
3865
|
`;
|
|
3866
|
+
var TextareaSizeStyles = import_styled_components23.css`
|
|
3867
|
+
padding: var(--measurement-medium-30);
|
|
3868
|
+
max-height: var(--measurement-large-60);
|
|
3869
|
+
|
|
3870
|
+
&[data-size="small"] {
|
|
3871
|
+
min-height: var(--measurement-large-30);
|
|
3872
|
+
}
|
|
3873
|
+
&[data-size="medium"] {
|
|
3874
|
+
min-height: var(--measurement-large-50);
|
|
3875
|
+
}
|
|
3876
|
+
&[data-size="large"] {
|
|
3877
|
+
min-height: var(--measurement-large-60);
|
|
3878
|
+
max-height: var(--measurement-large-80);
|
|
3879
|
+
}
|
|
3880
|
+
`;
|
|
3881
|
+
var TextareaResizableStyles = import_styled_components23.css`
|
|
3882
|
+
&[data-resizable="true"] {
|
|
3883
|
+
resize: vertical;
|
|
3884
|
+
}
|
|
3885
|
+
&[data-resizable="false"] {
|
|
3886
|
+
resize: none;
|
|
3887
|
+
}
|
|
3888
|
+
`;
|
|
3865
3889
|
var TextAreaContainer = import_styled_components23.default.textarea`
|
|
3866
3890
|
&[data-raw="false"] {
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
min-height: auto;
|
|
3870
|
-
width: 100%;
|
|
3871
|
-
|
|
3872
|
-
overflow-y: auto;
|
|
3873
|
-
|
|
3874
|
-
outline: none;
|
|
3875
|
-
cursor: pointer;
|
|
3876
|
-
display: flex;
|
|
3877
|
-
align-items: center;
|
|
3878
|
-
justify-content: center;
|
|
3879
|
-
|
|
3880
|
-
font-size: var(--fontsize-small-80);
|
|
3881
|
-
padding: var(--measurement-medium-30) var(--measurement-medium-30)
|
|
3882
|
-
var(--measurement-large-10) var(--measurement-medium-30);
|
|
3883
|
-
|
|
3884
|
-
font-weight: 500;
|
|
3885
|
-
line-height: 1.1;
|
|
3886
|
-
letter-spacing: calc(
|
|
3887
|
-
var(--fontsize-small-10) - ((var(--fontsize-small-10) * 1.066))
|
|
3888
|
-
);
|
|
3889
|
-
|
|
3890
|
-
border: var(--measurement-small-10) solid transparent;
|
|
3891
|
-
border-radius: var(--measurement-medium-30);
|
|
3892
|
-
backdrop-filter: blur(var(--measurement-small-10));
|
|
3893
|
-
color: var(--font-color-alpha-60);
|
|
3894
|
-
|
|
3895
|
-
transition: all ease-in-out 0.2s;
|
|
3896
|
-
|
|
3897
|
-
svg,
|
|
3898
|
-
span,
|
|
3899
|
-
img {
|
|
3900
|
-
opacity: 0.6;
|
|
3901
|
-
}
|
|
3902
|
-
|
|
3903
|
-
&:hover,
|
|
3904
|
-
&:focus,
|
|
3905
|
-
&:active {
|
|
3906
|
-
color: var(--font-color);
|
|
3907
|
-
|
|
3908
|
-
svg,
|
|
3909
|
-
span,
|
|
3910
|
-
img {
|
|
3911
|
-
opacity: 1;
|
|
3912
|
-
}
|
|
3913
|
-
}
|
|
3914
|
-
&::placeholder {
|
|
3915
|
-
color: var(--font-color-alpha-30);
|
|
3916
|
-
}
|
|
3917
|
-
&:disabled {
|
|
3918
|
-
cursor: not-allowed;
|
|
3919
|
-
opacity: 0.6;
|
|
3920
|
-
}
|
|
3921
|
-
|
|
3922
|
-
&::placeholder {
|
|
3923
|
-
color: var(--font-color-alpha-30);
|
|
3924
|
-
}
|
|
3925
|
-
|
|
3926
|
-
&:focus-visible {
|
|
3927
|
-
outline: none;
|
|
3928
|
-
}
|
|
3891
|
+
${FieldDefaultStyles}
|
|
3892
|
+
${FieldShapeStyles}
|
|
3929
3893
|
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
}
|
|
3933
|
-
|
|
3934
|
-
&[data-error="true"] {
|
|
3935
|
-
&::placeholder {
|
|
3936
|
-
color: var(--alpha-red-30);
|
|
3937
|
-
}
|
|
3938
|
-
}
|
|
3894
|
+
${TextareaSizeStyles}
|
|
3895
|
+
${TextareaResizableStyles}
|
|
3939
3896
|
|
|
3940
3897
|
${CustomScrollbar2}
|
|
3941
3898
|
${FieldVariantsStyles}
|
|
@@ -3943,7 +3900,8 @@ var TextAreaContainer = import_styled_components23.default.textarea`
|
|
|
3943
3900
|
`;
|
|
3944
3901
|
|
|
3945
3902
|
// src/text-area/index.tsx
|
|
3946
|
-
var Textarea = (
|
|
3903
|
+
var Textarea = (props) => {
|
|
3904
|
+
const { raw, shape, sizing, variant, resizable, onChange } = props;
|
|
3947
3905
|
const textareaRef = import_react39.default.useRef(null);
|
|
3948
3906
|
const adjustHeight = () => {
|
|
3949
3907
|
const textarea = textareaRef.current;
|
|
@@ -3960,16 +3918,19 @@ var Textarea = ({ onChange, ...props }) => {
|
|
|
3960
3918
|
onChange?.(e);
|
|
3961
3919
|
};
|
|
3962
3920
|
import_react39.default.useEffect(() => adjustHeight(), [props.value]);
|
|
3963
|
-
return /* @__PURE__ */ import_react39.default.createElement(
|
|
3921
|
+
return /* @__PURE__ */ import_react39.default.createElement(
|
|
3964
3922
|
TextAreaContainer,
|
|
3965
3923
|
{
|
|
3966
3924
|
ref: textareaRef,
|
|
3967
3925
|
onChange: handleChange,
|
|
3968
|
-
"data-variant":
|
|
3969
|
-
"data-
|
|
3926
|
+
"data-variant": variant ?? "secondary",
|
|
3927
|
+
"data-shape": shape ?? "smooth",
|
|
3928
|
+
"data-size": sizing ?? "medium" /* Medium */,
|
|
3929
|
+
"data-resizable": resizable,
|
|
3930
|
+
"data-raw": String(Boolean(raw)),
|
|
3970
3931
|
...props
|
|
3971
3932
|
}
|
|
3972
|
-
)
|
|
3933
|
+
);
|
|
3973
3934
|
};
|
|
3974
3935
|
Textarea.displayName = "Textarea";
|
|
3975
3936
|
|
|
@@ -4336,11 +4297,12 @@ var Tooltip = ({
|
|
|
4336
4297
|
const contentRef = import_react43.default.useRef(null);
|
|
4337
4298
|
const timeoutRef = import_react43.default.useRef(null);
|
|
4338
4299
|
const contentRect = () => contentRef?.current?.getBoundingClientRect();
|
|
4339
|
-
const bodyRect =
|
|
4300
|
+
const bodyRect = () => {
|
|
4340
4301
|
if (typeof document !== "undefined") {
|
|
4341
|
-
return document
|
|
4302
|
+
return document?.body?.getBoundingClientRect();
|
|
4342
4303
|
}
|
|
4343
|
-
|
|
4304
|
+
return void 0;
|
|
4305
|
+
};
|
|
4344
4306
|
const positions = {
|
|
4345
4307
|
btt: `calc((${triggerProps?.top}px - ${contentProps?.height}px) - (var(--measurement-medium-10)))`,
|
|
4346
4308
|
ttb: `calc((${triggerProps?.top}px + ${triggerProps?.height}px) + var(--measurement-medium-10))`,
|
package/dist/index.mjs
CHANGED
|
@@ -1972,6 +1972,7 @@ var FieldDefaultStyles = css8`
|
|
|
1972
1972
|
display: flex;
|
|
1973
1973
|
align-items: center;
|
|
1974
1974
|
justify-content: center;
|
|
1975
|
+
box-sizing: border-box;
|
|
1975
1976
|
|
|
1976
1977
|
font-size: var(--fontsize-medium-20);
|
|
1977
1978
|
|
|
@@ -3735,80 +3736,36 @@ var CustomScrollbar2 = css15`
|
|
|
3735
3736
|
scrollbar-width: thin;
|
|
3736
3737
|
scrollbar-color: ${({ $thumbColor, $trackColor }) => `${$thumbColor ?? "var(--font-color-alpha-10)"} ${$trackColor ?? "transparent"}`};
|
|
3737
3738
|
`;
|
|
3739
|
+
var TextareaSizeStyles = css15`
|
|
3740
|
+
padding: var(--measurement-medium-30);
|
|
3741
|
+
max-height: var(--measurement-large-60);
|
|
3742
|
+
|
|
3743
|
+
&[data-size="small"] {
|
|
3744
|
+
min-height: var(--measurement-large-30);
|
|
3745
|
+
}
|
|
3746
|
+
&[data-size="medium"] {
|
|
3747
|
+
min-height: var(--measurement-large-50);
|
|
3748
|
+
}
|
|
3749
|
+
&[data-size="large"] {
|
|
3750
|
+
min-height: var(--measurement-large-60);
|
|
3751
|
+
max-height: var(--measurement-large-80);
|
|
3752
|
+
}
|
|
3753
|
+
`;
|
|
3754
|
+
var TextareaResizableStyles = css15`
|
|
3755
|
+
&[data-resizable="true"] {
|
|
3756
|
+
resize: vertical;
|
|
3757
|
+
}
|
|
3758
|
+
&[data-resizable="false"] {
|
|
3759
|
+
resize: none;
|
|
3760
|
+
}
|
|
3761
|
+
`;
|
|
3738
3762
|
var TextAreaContainer = styled23.textarea`
|
|
3739
3763
|
&[data-raw="false"] {
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
min-height: auto;
|
|
3743
|
-
width: 100%;
|
|
3744
|
-
|
|
3745
|
-
overflow-y: auto;
|
|
3746
|
-
|
|
3747
|
-
outline: none;
|
|
3748
|
-
cursor: pointer;
|
|
3749
|
-
display: flex;
|
|
3750
|
-
align-items: center;
|
|
3751
|
-
justify-content: center;
|
|
3752
|
-
|
|
3753
|
-
font-size: var(--fontsize-small-80);
|
|
3754
|
-
padding: var(--measurement-medium-30) var(--measurement-medium-30)
|
|
3755
|
-
var(--measurement-large-10) var(--measurement-medium-30);
|
|
3756
|
-
|
|
3757
|
-
font-weight: 500;
|
|
3758
|
-
line-height: 1.1;
|
|
3759
|
-
letter-spacing: calc(
|
|
3760
|
-
var(--fontsize-small-10) - ((var(--fontsize-small-10) * 1.066))
|
|
3761
|
-
);
|
|
3762
|
-
|
|
3763
|
-
border: var(--measurement-small-10) solid transparent;
|
|
3764
|
-
border-radius: var(--measurement-medium-30);
|
|
3765
|
-
backdrop-filter: blur(var(--measurement-small-10));
|
|
3766
|
-
color: var(--font-color-alpha-60);
|
|
3767
|
-
|
|
3768
|
-
transition: all ease-in-out 0.2s;
|
|
3769
|
-
|
|
3770
|
-
svg,
|
|
3771
|
-
span,
|
|
3772
|
-
img {
|
|
3773
|
-
opacity: 0.6;
|
|
3774
|
-
}
|
|
3775
|
-
|
|
3776
|
-
&:hover,
|
|
3777
|
-
&:focus,
|
|
3778
|
-
&:active {
|
|
3779
|
-
color: var(--font-color);
|
|
3780
|
-
|
|
3781
|
-
svg,
|
|
3782
|
-
span,
|
|
3783
|
-
img {
|
|
3784
|
-
opacity: 1;
|
|
3785
|
-
}
|
|
3786
|
-
}
|
|
3787
|
-
&::placeholder {
|
|
3788
|
-
color: var(--font-color-alpha-30);
|
|
3789
|
-
}
|
|
3790
|
-
&:disabled {
|
|
3791
|
-
cursor: not-allowed;
|
|
3792
|
-
opacity: 0.6;
|
|
3793
|
-
}
|
|
3794
|
-
|
|
3795
|
-
&::placeholder {
|
|
3796
|
-
color: var(--font-color-alpha-30);
|
|
3797
|
-
}
|
|
3798
|
-
|
|
3799
|
-
&:focus-visible {
|
|
3800
|
-
outline: none;
|
|
3801
|
-
}
|
|
3764
|
+
${FieldDefaultStyles}
|
|
3765
|
+
${FieldShapeStyles}
|
|
3802
3766
|
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
}
|
|
3806
|
-
|
|
3807
|
-
&[data-error="true"] {
|
|
3808
|
-
&::placeholder {
|
|
3809
|
-
color: var(--alpha-red-30);
|
|
3810
|
-
}
|
|
3811
|
-
}
|
|
3767
|
+
${TextareaSizeStyles}
|
|
3768
|
+
${TextareaResizableStyles}
|
|
3812
3769
|
|
|
3813
3770
|
${CustomScrollbar2}
|
|
3814
3771
|
${FieldVariantsStyles}
|
|
@@ -3816,7 +3773,8 @@ var TextAreaContainer = styled23.textarea`
|
|
|
3816
3773
|
`;
|
|
3817
3774
|
|
|
3818
3775
|
// src/text-area/index.tsx
|
|
3819
|
-
var Textarea = (
|
|
3776
|
+
var Textarea = (props) => {
|
|
3777
|
+
const { raw, shape, sizing, variant, resizable, onChange } = props;
|
|
3820
3778
|
const textareaRef = React37.useRef(null);
|
|
3821
3779
|
const adjustHeight = () => {
|
|
3822
3780
|
const textarea = textareaRef.current;
|
|
@@ -3833,16 +3791,19 @@ var Textarea = ({ onChange, ...props }) => {
|
|
|
3833
3791
|
onChange?.(e);
|
|
3834
3792
|
};
|
|
3835
3793
|
React37.useEffect(() => adjustHeight(), [props.value]);
|
|
3836
|
-
return /* @__PURE__ */ React37.createElement(
|
|
3794
|
+
return /* @__PURE__ */ React37.createElement(
|
|
3837
3795
|
TextAreaContainer,
|
|
3838
3796
|
{
|
|
3839
3797
|
ref: textareaRef,
|
|
3840
3798
|
onChange: handleChange,
|
|
3841
|
-
"data-variant":
|
|
3842
|
-
"data-
|
|
3799
|
+
"data-variant": variant ?? "secondary",
|
|
3800
|
+
"data-shape": shape ?? "smooth",
|
|
3801
|
+
"data-size": sizing ?? "medium" /* Medium */,
|
|
3802
|
+
"data-resizable": resizable,
|
|
3803
|
+
"data-raw": String(Boolean(raw)),
|
|
3843
3804
|
...props
|
|
3844
3805
|
}
|
|
3845
|
-
)
|
|
3806
|
+
);
|
|
3846
3807
|
};
|
|
3847
3808
|
Textarea.displayName = "Textarea";
|
|
3848
3809
|
|
|
@@ -4209,11 +4170,12 @@ var Tooltip = ({
|
|
|
4209
4170
|
const contentRef = React41.useRef(null);
|
|
4210
4171
|
const timeoutRef = React41.useRef(null);
|
|
4211
4172
|
const contentRect = () => contentRef?.current?.getBoundingClientRect();
|
|
4212
|
-
const bodyRect =
|
|
4173
|
+
const bodyRect = () => {
|
|
4213
4174
|
if (typeof document !== "undefined") {
|
|
4214
|
-
return document
|
|
4175
|
+
return document?.body?.getBoundingClientRect();
|
|
4215
4176
|
}
|
|
4216
|
-
|
|
4177
|
+
return void 0;
|
|
4178
|
+
};
|
|
4217
4179
|
const positions = {
|
|
4218
4180
|
btt: `calc((${triggerProps?.top}px - ${contentProps?.height}px) - (var(--measurement-medium-10)))`,
|
|
4219
4181
|
ttb: `calc((${triggerProps?.top}px + ${triggerProps?.height}px) + var(--measurement-medium-10))`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usefui/components",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.3",
|
|
4
4
|
"description": "Open Source React components library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"typescript": "^5.9.3",
|
|
34
34
|
"@usefui/core": "^1.3.4",
|
|
35
35
|
"@usefui/hooks": "^1.3.4",
|
|
36
|
-
"@usefui/tokens": "^1.5.
|
|
36
|
+
"@usefui/tokens": "^1.5.4"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"test": "vitest run --coverage --logHeapUsage",
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
|
|
3
4
|
import { Page, Textarea } from "..";
|
|
5
|
+
import { TComponentSize } from "../../../../types";
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Textarea are used to allow users to write large chunks of text.
|
|
@@ -16,11 +18,14 @@ type Story = StoryObj<typeof meta>;
|
|
|
16
18
|
export const Default: Story = {
|
|
17
19
|
args: {
|
|
18
20
|
variant: "secondary",
|
|
21
|
+
resizable: false,
|
|
19
22
|
},
|
|
20
23
|
render: ({ ...args }) => (
|
|
21
24
|
<Page>
|
|
22
|
-
<Page.Content className="p-large-30">
|
|
23
|
-
|
|
25
|
+
<Page.Content className="p-large-30 flex flex-column g-large-10">
|
|
26
|
+
{["small", "medium", "large"].map((size) => (
|
|
27
|
+
<Textarea key={size} sizing={size as TComponentSize} {...args} />
|
|
28
|
+
))}
|
|
24
29
|
</Page.Content>
|
|
25
30
|
</Page>
|
|
26
31
|
),
|
package/src/text-area/index.tsx
CHANGED
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
|
|
5
5
|
import { TextAreaContainer } from "./styles";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import {
|
|
7
|
+
IComponentSize,
|
|
8
|
+
IComponentStyling,
|
|
9
|
+
IComponentVariant,
|
|
10
|
+
TComponentShape,
|
|
11
|
+
ComponentSizeEnum,
|
|
12
|
+
} from "../../../../types";
|
|
9
13
|
|
|
10
14
|
export type ScrollContainerProps = {
|
|
11
15
|
$height?: string;
|
|
@@ -18,15 +22,26 @@ export type ScrollContainerProps = {
|
|
|
18
22
|
export interface TextareaProps
|
|
19
23
|
extends React.TextareaHTMLAttributes<HTMLTextAreaElement>,
|
|
20
24
|
IComponentStyling,
|
|
21
|
-
|
|
25
|
+
IComponentSize,
|
|
26
|
+
IComponentVariant {
|
|
27
|
+
resizable?: boolean;
|
|
28
|
+
shape?: "square" | "smooth";
|
|
29
|
+
}
|
|
22
30
|
|
|
23
31
|
/**
|
|
24
32
|
* Textarea are used to allow users to write large chunks of text.
|
|
25
33
|
*
|
|
26
34
|
* @param {TextareaProps} props - The props for the Textarea component.
|
|
35
|
+
* @param {string} props.variant - The style definition used by the component. Defaults to `secondary`.
|
|
36
|
+
* @param {TComponentShape} props.shape - The size of the component. Defaults to `smooth`.
|
|
37
|
+
* @param {ComponentSizeEnum} props.sizing - The size of the component. Defaults to `medium`.
|
|
38
|
+
* @param {boolean} props.resizable - Define whether the component is resizable or not. Defaults to 'true'.
|
|
39
|
+
*
|
|
27
40
|
* @returns {ReactElement} The TextareaProps component.
|
|
28
41
|
*/
|
|
29
|
-
export const Textarea = (
|
|
42
|
+
export const Textarea = (props: TextareaProps) => {
|
|
43
|
+
const { raw, shape, sizing, variant, resizable, onChange } = props;
|
|
44
|
+
|
|
30
45
|
const textareaRef = React.useRef<HTMLTextAreaElement>(null);
|
|
31
46
|
|
|
32
47
|
const adjustHeight = () => {
|
|
@@ -48,15 +63,16 @@ export const Textarea = ({ onChange, ...props }: TextareaProps) => {
|
|
|
48
63
|
React.useEffect(() => adjustHeight(), [props.value]);
|
|
49
64
|
|
|
50
65
|
return (
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
66
|
+
<TextAreaContainer
|
|
67
|
+
ref={textareaRef}
|
|
68
|
+
onChange={handleChange}
|
|
69
|
+
data-variant={variant ?? "secondary"}
|
|
70
|
+
data-shape={shape ?? "smooth"}
|
|
71
|
+
data-size={sizing ?? ComponentSizeEnum.Medium}
|
|
72
|
+
data-resizable={resizable}
|
|
73
|
+
data-raw={String(Boolean(raw))}
|
|
74
|
+
{...props}
|
|
75
|
+
/>
|
|
60
76
|
);
|
|
61
77
|
};
|
|
62
78
|
Textarea.displayName = "Textarea";
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import styled, { css } from "styled-components";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
FieldShapeStyles,
|
|
6
|
+
FieldDefaultStyles,
|
|
7
|
+
FieldVariantsStyles,
|
|
8
|
+
} from "../../field/styles";
|
|
5
9
|
|
|
6
10
|
import type { ScrollContainerProps } from "text-area";
|
|
7
11
|
|
|
@@ -42,81 +46,37 @@ const CustomScrollbar = css<ScrollContainerProps>`
|
|
|
42
46
|
$trackColor ?? "transparent"
|
|
43
47
|
}`};
|
|
44
48
|
`;
|
|
49
|
+
const TextareaSizeStyles = css`
|
|
50
|
+
padding: var(--measurement-medium-30);
|
|
51
|
+
max-height: var(--measurement-large-60);
|
|
45
52
|
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
&[data-size="small"] {
|
|
54
|
+
min-height: var(--measurement-large-30);
|
|
55
|
+
}
|
|
56
|
+
&[data-size="medium"] {
|
|
57
|
+
min-height: var(--measurement-large-50);
|
|
58
|
+
}
|
|
59
|
+
&[data-size="large"] {
|
|
60
|
+
min-height: var(--measurement-large-60);
|
|
61
|
+
max-height: var(--measurement-large-80);
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
64
|
+
const TextareaResizableStyles = css`
|
|
65
|
+
&[data-resizable="true"] {
|
|
48
66
|
resize: vertical;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
outline: none;
|
|
56
|
-
cursor: pointer;
|
|
57
|
-
display: flex;
|
|
58
|
-
align-items: center;
|
|
59
|
-
justify-content: center;
|
|
60
|
-
|
|
61
|
-
font-size: var(--fontsize-small-80);
|
|
62
|
-
padding: var(--measurement-medium-30) var(--measurement-medium-30)
|
|
63
|
-
var(--measurement-large-10) var(--measurement-medium-30);
|
|
64
|
-
|
|
65
|
-
font-weight: 500;
|
|
66
|
-
line-height: 1.1;
|
|
67
|
-
letter-spacing: calc(
|
|
68
|
-
var(--fontsize-small-10) - ((var(--fontsize-small-10) * 1.066))
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
border: var(--measurement-small-10) solid transparent;
|
|
72
|
-
border-radius: var(--measurement-medium-30);
|
|
73
|
-
backdrop-filter: blur(var(--measurement-small-10));
|
|
74
|
-
color: var(--font-color-alpha-60);
|
|
75
|
-
|
|
76
|
-
transition: all ease-in-out 0.2s;
|
|
77
|
-
|
|
78
|
-
svg,
|
|
79
|
-
span,
|
|
80
|
-
img {
|
|
81
|
-
opacity: 0.6;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
&:hover,
|
|
85
|
-
&:focus,
|
|
86
|
-
&:active {
|
|
87
|
-
color: var(--font-color);
|
|
88
|
-
|
|
89
|
-
svg,
|
|
90
|
-
span,
|
|
91
|
-
img {
|
|
92
|
-
opacity: 1;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
&::placeholder {
|
|
96
|
-
color: var(--font-color-alpha-30);
|
|
97
|
-
}
|
|
98
|
-
&:disabled {
|
|
99
|
-
cursor: not-allowed;
|
|
100
|
-
opacity: 0.6;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
&::placeholder {
|
|
104
|
-
color: var(--font-color-alpha-30);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
&:focus-visible {
|
|
108
|
-
outline: none;
|
|
109
|
-
}
|
|
67
|
+
}
|
|
68
|
+
&[data-resizable="false"] {
|
|
69
|
+
resize: none;
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
110
72
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
73
|
+
export const TextAreaContainer = styled.textarea<ScrollContainerProps>`
|
|
74
|
+
&[data-raw="false"] {
|
|
75
|
+
${FieldDefaultStyles}
|
|
76
|
+
${FieldShapeStyles}
|
|
114
77
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
color: var(--alpha-red-30);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
78
|
+
${TextareaSizeStyles}
|
|
79
|
+
${TextareaResizableStyles}
|
|
120
80
|
|
|
121
81
|
${CustomScrollbar}
|
|
122
82
|
${FieldVariantsStyles}
|
package/src/tooltip/index.tsx
CHANGED
|
@@ -59,11 +59,12 @@ const Tooltip = ({
|
|
|
59
59
|
const timeoutRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
60
60
|
|
|
61
61
|
const contentRect = () => contentRef?.current?.getBoundingClientRect();
|
|
62
|
-
const bodyRect =
|
|
62
|
+
const bodyRect = (): DOMRect | undefined => {
|
|
63
63
|
if (typeof document !== "undefined") {
|
|
64
|
-
return document
|
|
64
|
+
return document?.body?.getBoundingClientRect();
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
return undefined;
|
|
67
|
+
};
|
|
67
68
|
|
|
68
69
|
const positions = {
|
|
69
70
|
btt: `calc((${triggerProps?.top}px - ${contentProps?.height}px) - (var(--measurement-medium-10)))`,
|