@carton-org/react-neumorphism
Version:
A React component library implementing the neumorphism design style
30 lines (29 loc) • 1.02 kB
JavaScript
import { jsxs as p, jsx as a } from "@emotion/react/jsx-runtime";
import { forwardRef as c, useCallback as h, useEffect as n } from "react";
import y from "../Typography/Typography.js";
import { StyledLabel as $, StyledTextArea as A } from "./textArea.styles.js";
import { useForwardRef as S } from "../../hooks/useForwardRef.js";
const C = c(({
label: o,
textAreaSize: e = "sm",
enableDynamicHeight: t = !0,
value: l,
textAreaStyle: i,
textAreaContainerStyle: u,
textAreaLabelStyle: x,
...d
}, m) => {
const s = S(m), f = h(() => {
const r = s.current;
t && (r.style.height = "auto", r.style.height = `${r.scrollHeight}px`);
}, [t]);
return n(() => {
t && f();
}, [l, f]), /* @__PURE__ */ p($, { $textAreaSize: e, $textAreaContainerStyle: u, children: [
o !== void 0 && /* @__PURE__ */ a(y, { size: e, labelStyle: x, children: o }),
/* @__PURE__ */ a(A, { ref: s, $textAreaSize: e, $enableDynamicHeight: t, $textAreaStyle: i, ...d })
] });
});
export {
C as default
};