MCPcopy Create free account
hub / github.com/dailydotdev/apps / Textarea

Function Textarea

packages/shared/src/components/fields/Textarea.tsx:14–170  ·  view source on GitHub ↗
(
  {
    hint,
    inputId,
    saveHintSpace,
    label,
    value,
    valueChanged,
    valid,
    validityChanged,
    className = {},
    placeholder,
    readOnly,
    isLocked,
    disabled,
    name,
    maxLength = 100,
    showMaxLength = true,
    rows,
    fieldType = 'primary',
    variant = FieldVariant.Filled,
    ...props
  }: BaseFieldProps<HTMLTextAreaElement> & {
    className?: FieldClassName;
    variant?: FieldVariant;
    showMaxLength?: boolean;
  },
  ref: ForwardedRef<HTMLTextAreaElement>,
)

Source from the content-addressed store, hash-verified

12import { FieldVariant, fieldVariantToClassName } from './fieldVariants';
13
14function Textarea(
15 {
16 hint,
17 inputId,
18 saveHintSpace,
19 label,
20 value,
21 valueChanged,
22 valid,
23 validityChanged,
24 className = {},
25 placeholder,
26 readOnly,
27 isLocked,
28 disabled,
29 name,
30 maxLength = 100,
31 showMaxLength = true,
32 rows,
33 fieldType = 'primary',
34 variant = FieldVariant.Filled,
35 ...props
36 }: BaseFieldProps<HTMLTextAreaElement> & {
37 className?: FieldClassName;
38 variant?: FieldVariant;
39 showMaxLength?: boolean;
40 },
41 ref: ForwardedRef<HTMLTextAreaElement>,
42): ReactElement {
43 const {
44 validInput,
45 focused,
46 hasInput,
47 focusInput,
48 inputRef,
49 onFocus,
50 onBlur,
51 onInput,
52 inputLength,
53 } = useInputFieldFunctions<HTMLTextAreaElement>({
54 value,
55 valueChanged,
56 valid,
57 validityChanged,
58 });
59 const isPrimaryField = fieldType === 'primary';
60 const isSecondaryField = fieldType === 'secondary';
61 const isTertiaryField = fieldType === 'tertiary';
62 const isQuaternaryField = fieldType === 'quaternary';
63 const invalid = validInput === false;
64 // A "title inside" caption only appears for a primary field that has a label.
65 // When it can't appear, nothing reserves the top, so the content should sit
66 // with equal padding on every side instead of the tight floating-label top.
67 const hasInnerLabel = isPrimaryField && !!label;
68 const hasAdditionalSpacing = hasInnerLabel && !focused && !hasInput;
69 const getPaddingClass = (): string => {
70 if (!hasInnerLabel) {
71 return 'py-4';

Callers

nothing calls this directly

Calls 4

getFieldPlaceholderFunction · 0.90
getFieldFontColorFunction · 0.90
useInputFieldFunctionsFunction · 0.85
getPaddingClassFunction · 0.85

Tested by

no test coverage detected