UNPKG

@yamada-ui/react

Version:

React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion

40 lines (36 loc) 1.01 kB
"use client"; import { assignRef, mergeRefs } from "../../utils/ref.js"; import { utils_exports } from "../../utils/index.js"; import { useAutosize } from "./use-autosize.js"; import { useCallback } from "react"; //#region src/components/textarea/use-textarea.ts const useTextarea = ({ autosize, maxRows, minRows, resizeRef,...rest } = {}) => { const { ref, onResizeTextarea } = useAutosize({ disabled: !autosize, maxRows, minRows }); assignRef(resizeRef, onResizeTextarea); return { getTextareaProps: useCallback(({ style,...props } = {}) => ({ ...rest, ...props, ref: mergeRefs(props.ref, rest.ref, ref), style: { resize: autosize ? "none" : void 0, ...rest.style, ...style }, onChange: (0, utils_exports.handlerAll)(props.onChange, rest.onChange, autosize ? onResizeTextarea : utils_exports.noop) }), [ autosize, onResizeTextarea, rest, ref ]), onResizeTextarea }; }; //#endregion export { useTextarea }; //# sourceMappingURL=use-textarea.js.map