@mantine/core
Version:
React components library focused on usability, accessibility and developer experience
32 lines (31 loc) • 1.61 kB
TypeScript
import { Factory } from '../../core';
import { __InputStylesNames } from '../Input';
import { TextareaProps } from '../Textarea';
export interface JsonInputProps extends Omit<TextareaProps, 'onChange'> {
/** Controlled component value */
value?: string;
/** Uncontrolled component default value */
defaultValue?: string;
/** Called when value changes */
onChange?: (value: string) => void;
/** Determines whether the value should be formatted on blur @default false */
formatOnBlur?: boolean;
/** Error message shown when the input value is invalid JSON (checked on blur). If not provided, a generic error state is shown. Takes precedence over the `error` prop when validation fails. */
validationError?: React.ReactNode;
/** Function to serialize value into a string for formatting. Called with (value, null, 2) where 2 is the indentation level. @default JSON.stringify */
serialize?: typeof JSON.stringify;
/** Function to deserialize string value for formatting and validation. Must throw an error if the string is invalid JSON. @default JSON.parse */
deserialize?: typeof JSON.parse;
/** Number of spaces to use as white space for formatting. Passed as the third argument to `serialize` function. @default 2 */
indentSpaces?: number;
}
export type JsonInputFactory = Factory<{
props: JsonInputProps;
ref: HTMLTextAreaElement;
stylesNames: __InputStylesNames;
}>;
export declare const JsonInput: import("../..").MantineComponent<{
props: JsonInputProps;
ref: HTMLTextAreaElement;
stylesNames: __InputStylesNames;
}>;