@lets-events/react 11.0.4 → 11.0.6
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +33 -23
- package/dist/index.mjs +33 -23
- package/package.json +1 -1
- package/src/components/TextField.tsx +1 -0
- package/src/components/TextareaField.tsx +83 -72
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @lets-events/react@11.0.
|
|
2
|
+
> @lets-events/react@11.0.6 build
|
|
3
3
|
> tsup src/index.tsx --format esm,cjs --dts --external react
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.tsx
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
[34mCLI[39m Target: es6
|
|
9
9
|
[34mESM[39m Build start
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
|
-
[32mESM[39m [1mdist\index.mjs [22m[32m275.
|
|
12
|
-
[32mESM[39m ⚡️ Build success in
|
|
13
|
-
[32mCJS[39m [1mdist\index.js [22m[
|
|
14
|
-
[32mCJS[39m ⚡️ Build success in
|
|
11
|
+
[32mESM[39m [1mdist\index.mjs [22m[32m275.82 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 219ms
|
|
13
|
+
[32mCJS[39m [1mdist\index.js [22m[32m284.17 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 220ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist\index.d.mts [22m[32m338.
|
|
18
|
-
[32mDTS[39m [1mdist\index.d.ts [22m[32m338.
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 3594ms
|
|
17
|
+
[32mDTS[39m [1mdist\index.d.mts [22m[32m338.39 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist\index.d.ts [22m[32m338.39 KB[39m
|
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -10647,7 +10647,7 @@ type CardProps = ComponentProps<typeof CardStyled> & {
|
|
|
10647
10647
|
};
|
|
10648
10648
|
declare function Card({ asChild, children, ...props }: CardProps): react_jsx_runtime.JSX.Element;
|
|
10649
10649
|
|
|
10650
|
-
declare const TextareaFieldStyle: _stitches_react_types_styled_component.StyledComponent<
|
|
10650
|
+
declare const TextareaFieldStyle: _stitches_react_types_styled_component.StyledComponent<react__default.ForwardRefExoticComponent<_radix_ui_themes.TextAreaProps & react__default.RefAttributes<HTMLTextAreaElement>>, {
|
|
10651
10651
|
typography?: "tooltip" | "displayLarge" | "displayMedium" | "displaySmall" | "headline1" | "headline2" | "headline3" | "headline4" | "headline5" | "headline6" | "headline7" | "headline8" | "bodyXL" | "bodyL" | "bodyM" | "bodyS" | "bodyXS" | "bodyXXS" | "badgeLarge" | "badgeMedium" | "badgeSmall" | "badgeExtraSmall" | "popoversRegular" | "captionLarge" | "captionMedium" | "captionSmall" | "buttonLarge" | "buttonMedium" | "buttonSmall" | "buttonExtraSmall" | "labelLarge" | "labelMedium" | "labelSmall" | "labelExtraSmall" | undefined;
|
|
10652
10652
|
}, {}, _stitches_react_types_css_util.CSS<{}, {
|
|
10653
10653
|
colors: {
|
|
@@ -11022,7 +11022,7 @@ declare const TextareaFieldStyle: _stitches_react_types_styled_component.StyledC
|
|
|
11022
11022
|
type TextareaFieldProps = ComponentProps<typeof TextareaFieldStyle> & {
|
|
11023
11023
|
limit: number;
|
|
11024
11024
|
};
|
|
11025
|
-
declare
|
|
11025
|
+
declare const TextareaField: react__default.ForwardRefExoticComponent<Omit<TextareaFieldProps, "ref"> & react__default.RefAttributes<HTMLTextAreaElement>>;
|
|
11026
11026
|
|
|
11027
11027
|
type ToastType = 'success' | 'error' | 'warning' | 'info';
|
|
11028
11028
|
interface ToastConfig {
|
package/dist/index.d.ts
CHANGED
|
@@ -10647,7 +10647,7 @@ type CardProps = ComponentProps<typeof CardStyled> & {
|
|
|
10647
10647
|
};
|
|
10648
10648
|
declare function Card({ asChild, children, ...props }: CardProps): react_jsx_runtime.JSX.Element;
|
|
10649
10649
|
|
|
10650
|
-
declare const TextareaFieldStyle: _stitches_react_types_styled_component.StyledComponent<
|
|
10650
|
+
declare const TextareaFieldStyle: _stitches_react_types_styled_component.StyledComponent<react__default.ForwardRefExoticComponent<_radix_ui_themes.TextAreaProps & react__default.RefAttributes<HTMLTextAreaElement>>, {
|
|
10651
10651
|
typography?: "tooltip" | "displayLarge" | "displayMedium" | "displaySmall" | "headline1" | "headline2" | "headline3" | "headline4" | "headline5" | "headline6" | "headline7" | "headline8" | "bodyXL" | "bodyL" | "bodyM" | "bodyS" | "bodyXS" | "bodyXXS" | "badgeLarge" | "badgeMedium" | "badgeSmall" | "badgeExtraSmall" | "popoversRegular" | "captionLarge" | "captionMedium" | "captionSmall" | "buttonLarge" | "buttonMedium" | "buttonSmall" | "buttonExtraSmall" | "labelLarge" | "labelMedium" | "labelSmall" | "labelExtraSmall" | undefined;
|
|
10652
10652
|
}, {}, _stitches_react_types_css_util.CSS<{}, {
|
|
10653
10653
|
colors: {
|
|
@@ -11022,7 +11022,7 @@ declare const TextareaFieldStyle: _stitches_react_types_styled_component.StyledC
|
|
|
11022
11022
|
type TextareaFieldProps = ComponentProps<typeof TextareaFieldStyle> & {
|
|
11023
11023
|
limit: number;
|
|
11024
11024
|
};
|
|
11025
|
-
declare
|
|
11025
|
+
declare const TextareaField: react__default.ForwardRefExoticComponent<Omit<TextareaFieldProps, "ref"> & react__default.RefAttributes<HTMLTextAreaElement>>;
|
|
11026
11026
|
|
|
11027
11027
|
type ToastType = 'success' | 'error' | 'warning' | 'info';
|
|
11028
11028
|
interface ToastConfig {
|
package/dist/index.js
CHANGED
|
@@ -2600,6 +2600,7 @@ var TextFieldStyled = styled(import_themes7.TextField.Root, {
|
|
|
2600
2600
|
alignItems: "center",
|
|
2601
2601
|
padding: "0 $14",
|
|
2602
2602
|
gap: "$14",
|
|
2603
|
+
backgroundColor: "$dark50",
|
|
2603
2604
|
input: {
|
|
2604
2605
|
order: 1,
|
|
2605
2606
|
outline: "none",
|
|
@@ -8754,37 +8755,35 @@ function Card(_a) {
|
|
|
8754
8755
|
|
|
8755
8756
|
// src/components/TextareaField.tsx
|
|
8756
8757
|
var import_themes18 = require("@radix-ui/themes");
|
|
8757
|
-
var import_react8 = require("react");
|
|
8758
|
+
var import_react8 = __toESM(require("react"));
|
|
8758
8759
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
8759
8760
|
var TextareaFieldStyle = styled(import_themes18.TextArea, {
|
|
8760
8761
|
display: "flex",
|
|
8761
|
-
width: "fit-content",
|
|
8762
8762
|
flex: 1,
|
|
8763
8763
|
textarea: {
|
|
8764
8764
|
width: "100%",
|
|
8765
|
-
minHeight: "3.75rem",
|
|
8766
8765
|
border: "none",
|
|
8767
8766
|
padding: "$12 $14",
|
|
8768
8767
|
fontFamily: "$default",
|
|
8769
|
-
fontSize: "$16",
|
|
8770
8768
|
outline: "none",
|
|
8771
|
-
resize: "vertical"
|
|
8769
|
+
resize: "vertical",
|
|
8770
|
+
height: "auto"
|
|
8772
8771
|
},
|
|
8773
8772
|
variants: {
|
|
8774
8773
|
typography: typographyValues
|
|
8775
8774
|
},
|
|
8776
8775
|
defaultVariants: {
|
|
8777
|
-
typography: "
|
|
8776
|
+
typography: "labelSmall"
|
|
8778
8777
|
}
|
|
8779
8778
|
});
|
|
8780
8779
|
var TextareaContainer = styled("div", {
|
|
8781
|
-
position: "relative",
|
|
8782
8780
|
display: "flex",
|
|
8781
|
+
flexDirection: "column",
|
|
8783
8782
|
overflow: "hidden",
|
|
8784
|
-
|
|
8783
|
+
width: "100%",
|
|
8785
8784
|
border: "1px solid",
|
|
8786
8785
|
borderColor: "$dark300",
|
|
8787
|
-
borderRadius: "$
|
|
8786
|
+
borderRadius: "$sm",
|
|
8788
8787
|
"&:has(textarea:focus)": {
|
|
8789
8788
|
border: "1px solid $brand300"
|
|
8790
8789
|
},
|
|
@@ -8796,14 +8795,12 @@ var TextareaContainer = styled("div", {
|
|
|
8796
8795
|
}
|
|
8797
8796
|
});
|
|
8798
8797
|
var TextareaLimitIndicator = styled("div", {
|
|
8799
|
-
position: "absolute",
|
|
8800
|
-
bottom: 0,
|
|
8801
|
-
left: 0,
|
|
8802
8798
|
padding: "$12 $16",
|
|
8803
8799
|
borderTop: "1px solid $neutral300",
|
|
8804
8800
|
width: "100%",
|
|
8805
8801
|
flex: 1,
|
|
8806
8802
|
display: "flex",
|
|
8803
|
+
backgroundColor: "$dark50",
|
|
8807
8804
|
span: {
|
|
8808
8805
|
backgroundColor: "$neutral200",
|
|
8809
8806
|
color: "$neutral700",
|
|
@@ -8811,30 +8808,43 @@ var TextareaLimitIndicator = styled("div", {
|
|
|
8811
8808
|
padding: "$4"
|
|
8812
8809
|
}
|
|
8813
8810
|
});
|
|
8814
|
-
|
|
8811
|
+
var TextareaField = import_react8.default.forwardRef((_a, fowardedRef) => {
|
|
8815
8812
|
var _b = _a, { maxLength } = _b, props = __objRest(_b, ["maxLength"]);
|
|
8816
8813
|
const inputRef = (0, import_react8.useRef)(null);
|
|
8817
8814
|
const badgeRef = (0, import_react8.useRef)(null);
|
|
8818
|
-
|
|
8819
|
-
|
|
8820
|
-
|
|
8821
|
-
|
|
8815
|
+
const updateCharCountBadge = () => {
|
|
8816
|
+
var _a2, _b2;
|
|
8817
|
+
if (!maxLength || !badgeRef.current) return;
|
|
8818
|
+
const remainingChars = maxLength - ((_b2 = (_a2 = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _a2.value.length) != null ? _b2 : 0);
|
|
8819
|
+
badgeRef.current.textContent = String(remainingChars);
|
|
8820
|
+
};
|
|
8821
|
+
const handleInput = (e) => {
|
|
8822
8822
|
var _a2;
|
|
8823
|
-
|
|
8824
|
-
|
|
8823
|
+
updateCharCountBadge();
|
|
8824
|
+
(_a2 = props.onInput) == null ? void 0 : _a2.call(props, e);
|
|
8825
8825
|
};
|
|
8826
|
-
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(TextareaContainer, {
|
|
8826
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(TextareaContainer, { children: [
|
|
8827
8827
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
8828
8828
|
TextareaFieldStyle,
|
|
8829
8829
|
__spreadValues({
|
|
8830
|
-
|
|
8830
|
+
rows: 4,
|
|
8831
|
+
ref: (r) => {
|
|
8832
|
+
if (!r) return;
|
|
8833
|
+
inputRef.current = r;
|
|
8834
|
+
if (fowardedRef) {
|
|
8835
|
+
if (typeof fowardedRef === "function") fowardedRef(r);
|
|
8836
|
+
else {
|
|
8837
|
+
fowardedRef.current = r;
|
|
8838
|
+
}
|
|
8839
|
+
}
|
|
8840
|
+
},
|
|
8831
8841
|
onInput: handleInput,
|
|
8832
8842
|
maxLength
|
|
8833
8843
|
}, props)
|
|
8834
8844
|
),
|
|
8835
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(TextareaLimitIndicator, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Text, { typography: "badgeMedium", ref: badgeRef, children: maxLength }) })
|
|
8845
|
+
maxLength && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(TextareaLimitIndicator, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Text, { typography: "badgeMedium", ref: badgeRef, children: maxLength }) })
|
|
8836
8846
|
] });
|
|
8837
|
-
}
|
|
8847
|
+
});
|
|
8838
8848
|
|
|
8839
8849
|
// src/components/Toast/components/ToastItem.tsx
|
|
8840
8850
|
var import_react10 = require("react");
|
package/dist/index.mjs
CHANGED
|
@@ -2514,6 +2514,7 @@ var TextFieldStyled = styled(TextFieldRadix.Root, {
|
|
|
2514
2514
|
alignItems: "center",
|
|
2515
2515
|
padding: "0 $14",
|
|
2516
2516
|
gap: "$14",
|
|
2517
|
+
backgroundColor: "$dark50",
|
|
2517
2518
|
input: {
|
|
2518
2519
|
order: 1,
|
|
2519
2520
|
outline: "none",
|
|
@@ -8668,37 +8669,35 @@ function Card(_a) {
|
|
|
8668
8669
|
|
|
8669
8670
|
// src/components/TextareaField.tsx
|
|
8670
8671
|
import { TextArea as TextAreaRadix } from "@radix-ui/themes";
|
|
8671
|
-
import { useRef as useRef3 } from "react";
|
|
8672
|
+
import React6, { useRef as useRef3 } from "react";
|
|
8672
8673
|
import { jsx as jsx20, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
8673
8674
|
var TextareaFieldStyle = styled(TextAreaRadix, {
|
|
8674
8675
|
display: "flex",
|
|
8675
|
-
width: "fit-content",
|
|
8676
8676
|
flex: 1,
|
|
8677
8677
|
textarea: {
|
|
8678
8678
|
width: "100%",
|
|
8679
|
-
minHeight: "3.75rem",
|
|
8680
8679
|
border: "none",
|
|
8681
8680
|
padding: "$12 $14",
|
|
8682
8681
|
fontFamily: "$default",
|
|
8683
|
-
fontSize: "$16",
|
|
8684
8682
|
outline: "none",
|
|
8685
|
-
resize: "vertical"
|
|
8683
|
+
resize: "vertical",
|
|
8684
|
+
height: "auto"
|
|
8686
8685
|
},
|
|
8687
8686
|
variants: {
|
|
8688
8687
|
typography: typographyValues
|
|
8689
8688
|
},
|
|
8690
8689
|
defaultVariants: {
|
|
8691
|
-
typography: "
|
|
8690
|
+
typography: "labelSmall"
|
|
8692
8691
|
}
|
|
8693
8692
|
});
|
|
8694
8693
|
var TextareaContainer = styled("div", {
|
|
8695
|
-
position: "relative",
|
|
8696
8694
|
display: "flex",
|
|
8695
|
+
flexDirection: "column",
|
|
8697
8696
|
overflow: "hidden",
|
|
8698
|
-
|
|
8697
|
+
width: "100%",
|
|
8699
8698
|
border: "1px solid",
|
|
8700
8699
|
borderColor: "$dark300",
|
|
8701
|
-
borderRadius: "$
|
|
8700
|
+
borderRadius: "$sm",
|
|
8702
8701
|
"&:has(textarea:focus)": {
|
|
8703
8702
|
border: "1px solid $brand300"
|
|
8704
8703
|
},
|
|
@@ -8710,14 +8709,12 @@ var TextareaContainer = styled("div", {
|
|
|
8710
8709
|
}
|
|
8711
8710
|
});
|
|
8712
8711
|
var TextareaLimitIndicator = styled("div", {
|
|
8713
|
-
position: "absolute",
|
|
8714
|
-
bottom: 0,
|
|
8715
|
-
left: 0,
|
|
8716
8712
|
padding: "$12 $16",
|
|
8717
8713
|
borderTop: "1px solid $neutral300",
|
|
8718
8714
|
width: "100%",
|
|
8719
8715
|
flex: 1,
|
|
8720
8716
|
display: "flex",
|
|
8717
|
+
backgroundColor: "$dark50",
|
|
8721
8718
|
span: {
|
|
8722
8719
|
backgroundColor: "$neutral200",
|
|
8723
8720
|
color: "$neutral700",
|
|
@@ -8725,30 +8722,43 @@ var TextareaLimitIndicator = styled("div", {
|
|
|
8725
8722
|
padding: "$4"
|
|
8726
8723
|
}
|
|
8727
8724
|
});
|
|
8728
|
-
|
|
8725
|
+
var TextareaField = React6.forwardRef((_a, fowardedRef) => {
|
|
8729
8726
|
var _b = _a, { maxLength } = _b, props = __objRest(_b, ["maxLength"]);
|
|
8730
8727
|
const inputRef = useRef3(null);
|
|
8731
8728
|
const badgeRef = useRef3(null);
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
|
|
8735
|
-
|
|
8729
|
+
const updateCharCountBadge = () => {
|
|
8730
|
+
var _a2, _b2;
|
|
8731
|
+
if (!maxLength || !badgeRef.current) return;
|
|
8732
|
+
const remainingChars = maxLength - ((_b2 = (_a2 = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _a2.value.length) != null ? _b2 : 0);
|
|
8733
|
+
badgeRef.current.textContent = String(remainingChars);
|
|
8734
|
+
};
|
|
8735
|
+
const handleInput = (e) => {
|
|
8736
8736
|
var _a2;
|
|
8737
|
-
|
|
8738
|
-
|
|
8737
|
+
updateCharCountBadge();
|
|
8738
|
+
(_a2 = props.onInput) == null ? void 0 : _a2.call(props, e);
|
|
8739
8739
|
};
|
|
8740
|
-
return /* @__PURE__ */ jsxs8(TextareaContainer, {
|
|
8740
|
+
return /* @__PURE__ */ jsxs8(TextareaContainer, { children: [
|
|
8741
8741
|
/* @__PURE__ */ jsx20(
|
|
8742
8742
|
TextareaFieldStyle,
|
|
8743
8743
|
__spreadValues({
|
|
8744
|
-
|
|
8744
|
+
rows: 4,
|
|
8745
|
+
ref: (r) => {
|
|
8746
|
+
if (!r) return;
|
|
8747
|
+
inputRef.current = r;
|
|
8748
|
+
if (fowardedRef) {
|
|
8749
|
+
if (typeof fowardedRef === "function") fowardedRef(r);
|
|
8750
|
+
else {
|
|
8751
|
+
fowardedRef.current = r;
|
|
8752
|
+
}
|
|
8753
|
+
}
|
|
8754
|
+
},
|
|
8745
8755
|
onInput: handleInput,
|
|
8746
8756
|
maxLength
|
|
8747
8757
|
}, props)
|
|
8748
8758
|
),
|
|
8749
|
-
/* @__PURE__ */ jsx20(TextareaLimitIndicator, { children: /* @__PURE__ */ jsx20(Text, { typography: "badgeMedium", ref: badgeRef, children: maxLength }) })
|
|
8759
|
+
maxLength && /* @__PURE__ */ jsx20(TextareaLimitIndicator, { children: /* @__PURE__ */ jsx20(Text, { typography: "badgeMedium", ref: badgeRef, children: maxLength }) })
|
|
8750
8760
|
] });
|
|
8751
|
-
}
|
|
8761
|
+
});
|
|
8752
8762
|
|
|
8753
8763
|
// src/components/Toast/components/ToastItem.tsx
|
|
8754
8764
|
import { useState as useState3 } from "react";
|
package/package.json
CHANGED
|
@@ -1,101 +1,112 @@
|
|
|
1
|
-
import { TextArea as TextAreaRadix } from
|
|
2
|
-
import { styled } from
|
|
3
|
-
import { ComponentProps, useRef } from
|
|
4
|
-
|
|
5
|
-
import {
|
|
1
|
+
import { TextArea as TextAreaRadix, Flex, Box } from "@radix-ui/themes";
|
|
2
|
+
import { styled } from "../styles";
|
|
3
|
+
import React, { ComponentProps, useRef } from "react";
|
|
4
|
+
|
|
5
|
+
import { typographyValues } from "../types/typographyValues";
|
|
6
|
+
import { Text } from "./Text";
|
|
6
7
|
|
|
7
8
|
export const TextareaFieldStyle = styled(TextAreaRadix, {
|
|
8
|
-
display:
|
|
9
|
-
width: 'fit-content',
|
|
9
|
+
display: "flex",
|
|
10
10
|
flex: 1,
|
|
11
11
|
textarea: {
|
|
12
|
-
width:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
resize: 'vertical',
|
|
12
|
+
width: "100%",
|
|
13
|
+
border: "none",
|
|
14
|
+
padding: "$12 $14",
|
|
15
|
+
fontFamily: "$default",
|
|
16
|
+
outline: "none",
|
|
17
|
+
resize: "vertical",
|
|
18
|
+
height: "auto",
|
|
20
19
|
},
|
|
21
20
|
variants: {
|
|
22
21
|
typography: typographyValues,
|
|
23
22
|
},
|
|
24
23
|
defaultVariants: {
|
|
25
|
-
typography:
|
|
24
|
+
typography: "labelSmall",
|
|
26
25
|
},
|
|
27
|
-
})
|
|
26
|
+
});
|
|
28
27
|
|
|
29
28
|
export type TextareaFieldProps = ComponentProps<typeof TextareaFieldStyle> & {
|
|
30
|
-
limit: number
|
|
31
|
-
}
|
|
29
|
+
limit: number;
|
|
30
|
+
};
|
|
32
31
|
|
|
33
|
-
const TextareaContainer = styled(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
overflow:
|
|
37
|
-
|
|
38
|
-
border:
|
|
39
|
-
borderColor:
|
|
40
|
-
borderRadius:
|
|
32
|
+
const TextareaContainer = styled("div", {
|
|
33
|
+
display: "flex",
|
|
34
|
+
flexDirection: "column",
|
|
35
|
+
overflow: "hidden",
|
|
36
|
+
width: "100%",
|
|
37
|
+
border: "1px solid",
|
|
38
|
+
borderColor: "$dark300",
|
|
39
|
+
borderRadius: "$sm",
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
border:
|
|
41
|
+
"&:has(textarea:focus)": {
|
|
42
|
+
border: "1px solid $brand300",
|
|
44
43
|
},
|
|
45
|
-
|
|
46
|
-
backgroundColor:
|
|
47
|
-
color:
|
|
48
|
-
border:
|
|
49
|
-
cursor:
|
|
44
|
+
"&:has(textarea:disabled)": {
|
|
45
|
+
backgroundColor: "$dark100",
|
|
46
|
+
color: "$dark400",
|
|
47
|
+
border: "1px solid $dark200",
|
|
48
|
+
cursor: "not-allowed",
|
|
50
49
|
},
|
|
51
|
-
})
|
|
50
|
+
});
|
|
52
51
|
|
|
53
|
-
const TextareaLimitIndicator = styled(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
padding: '$12 $16',
|
|
58
|
-
borderTop: '1px solid $neutral300',
|
|
59
|
-
width: '100%',
|
|
52
|
+
const TextareaLimitIndicator = styled("div", {
|
|
53
|
+
padding: "$12 $16",
|
|
54
|
+
borderTop: "1px solid $neutral300",
|
|
55
|
+
width: "100%",
|
|
60
56
|
flex: 1,
|
|
61
|
-
display:
|
|
57
|
+
display: "flex",
|
|
58
|
+
backgroundColor: "$dark50",
|
|
62
59
|
span: {
|
|
63
|
-
backgroundColor:
|
|
64
|
-
color:
|
|
65
|
-
borderRadius:
|
|
66
|
-
padding:
|
|
60
|
+
backgroundColor: "$neutral200",
|
|
61
|
+
color: "$neutral700",
|
|
62
|
+
borderRadius: "$2xs",
|
|
63
|
+
padding: "$4",
|
|
67
64
|
},
|
|
68
|
-
})
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export const TextareaField = React.forwardRef<
|
|
68
|
+
HTMLTextAreaElement,
|
|
69
|
+
TextareaFieldProps
|
|
70
|
+
>(({ maxLength, ...props }, fowardedRef) => {
|
|
71
|
+
const inputRef = useRef<HTMLTextAreaElement>(null);
|
|
72
|
+
const badgeRef = useRef<HTMLSpanElement>(null);
|
|
69
73
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
const updateCharCountBadge = () => {
|
|
75
|
+
if (!maxLength || !badgeRef.current) return;
|
|
76
|
+
const remainingChars = maxLength - (inputRef?.current?.value.length ?? 0);
|
|
77
|
+
badgeRef.current.textContent = String(remainingChars);
|
|
78
|
+
};
|
|
73
79
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
</TextareaContainer>
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
const handleInput = () => {
|
|
82
|
-
const remainingChars = maxLength - (inputRef?.current?.value.length || 0)
|
|
83
|
-
if (badgeRef.current) badgeRef.current.textContent = String(remainingChars)
|
|
84
|
-
}
|
|
80
|
+
const handleInput = (e: React.FormEvent<HTMLTextAreaElement>) => {
|
|
81
|
+
updateCharCountBadge();
|
|
82
|
+
props.onInput?.(e);
|
|
83
|
+
};
|
|
85
84
|
|
|
86
85
|
return (
|
|
87
|
-
<TextareaContainer
|
|
86
|
+
<TextareaContainer>
|
|
88
87
|
<TextareaFieldStyle
|
|
89
|
-
|
|
88
|
+
rows={4}
|
|
89
|
+
ref={(r) => {
|
|
90
|
+
if (!r) return;
|
|
91
|
+
inputRef.current = r;
|
|
92
|
+
if (fowardedRef) {
|
|
93
|
+
if (typeof fowardedRef === "function") fowardedRef(r);
|
|
94
|
+
else {
|
|
95
|
+
fowardedRef.current = r;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}}
|
|
90
99
|
onInput={handleInput}
|
|
91
100
|
maxLength={maxLength}
|
|
92
101
|
{...props}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
<
|
|
96
|
-
{
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
/>
|
|
103
|
+
{maxLength && (
|
|
104
|
+
<TextareaLimitIndicator>
|
|
105
|
+
<Text typography={"badgeMedium"} ref={badgeRef}>
|
|
106
|
+
{maxLength}
|
|
107
|
+
</Text>
|
|
108
|
+
</TextareaLimitIndicator>
|
|
109
|
+
)}
|
|
99
110
|
</TextareaContainer>
|
|
100
|
-
)
|
|
101
|
-
}
|
|
111
|
+
);
|
|
112
|
+
});
|