teableio/teable

View on GitHub
apps/nextjs-app/src/features/app/components/field-setting/options/LongTextOptions.tsx

Summary

Maintainability
A
0 mins
Test Coverage
import type { ILongTextFieldOptions } from '@teable/core';
import { Textarea } from '@teable/ui-lib/shadcn';
import { DefaultValue } from '../DefaultValue';

export const LongTextOptions = (props: {
  options: Partial<ILongTextFieldOptions> | undefined;
  onChange?: (options: Partial<ILongTextFieldOptions>) => void;
  isLookup?: boolean;
}) => {
  const { isLookup, options, onChange } = props;

  const onDefaultValueChange = (defaultValue: string | undefined) => {
    onChange?.({
      defaultValue,
    });
  };

  return (
    <div className="form-control space-y-2">
      {!isLookup && (
        <DefaultValue onReset={() => onDefaultValueChange(undefined)}>
          <Textarea
            className="w-full"
            value={options?.defaultValue || ''}
            onChange={(e) => onDefaultValueChange(e.target.value)}
            rows={3}
          />
        </DefaultValue>
      )}
    </div>
  );
};