import { Filesystem } from "../file_system"; import { EventSystem } from "../util/event_system"; type ReadType = Filesystem.ReadType; export declare enum FormInputType { Text = "text", Password = "password", Number = "number", Range = "range", Checkbox = "checkbox", Select = "select", Radio = "radio", Textarea = "textarea", Vector = "vector", Color = "color", File = "file", Folder = "folder", Save = "save", InlineSelect = "inline_select", MultiSelect = "multi_select", InlineMultiSelect = "inline_multi_select", OutlinerNode = "outliner_node", Info = "info", NumSlider = "num_slider", Buttons = "buttons" } export interface FormElementOptions { label?: string; /** * Detailed description of the field, available behind the questionmark icon or on mouse hover */ description?: string; /** * Type of the input. If unspecified, defaults to text */ type?: FormInputType | `${FormInputType}`; /** * Visual style of the input. Checkbox inputs support 'checkbox' or 'toggle_switch'. Textarea supports 'code' */ style?: 'checkbox' | 'toggle_switch' | 'code'; /** * Stretch the input field across the whole width of the form */ full_width?: boolean; /** Set the input to read-only */ readonly?: boolean; /** Add buttons to allow copying and sharing the text or link */ share_text?: boolean; /** * The default value */ value?: any; /** * The default selected option for 'select', 'inline_select' and 'radio' types. Alias for 'value' */ default?: any; placeholder?: string; list?: string[]; /** * When using 'text' type, the text to display. Markdown is supported */ text?: string; condition?: ConditionResolvable; /** * When using 'range' type, allow users to modify the numeric input */ editable_range_label?: boolean; colorpicker?: any; /** * On numeric inputs, the minimum possible value */ min?: number; /** * On numeric inputs, the maximum possible value */ max?: number; /** * The step in which the value can be increased / decreased */ step?: number; /** * On num slider inputs, The color of the slider */ color?: string; /** * If enabled, the value is forced to multiples of the "step" value. This can be used to create integer-only inputs etc. */ force_step?: boolean; /** * The number of dimensions when using a vector type */ dimensions?: number; /** * The height of the input on textareas, in pixels */ height?: number; /** * Available options on select or inline_select inputs */ options?: Record | (() => Record); /** * List of buttons for the button type */ buttons?: string[]; /** * Function to get the interval value for a num_slider based on the input event * @returns Interval value */ getInterval?: (event: Event) => number; getOutlinerNodes?: () => OutlinerNode[]; /** * For num_sliders, the sliding interval mode */ interval_type?: 'position' | 'rotation'; /** * Allow users to toggle the entire option on or off */ toggle_enabled?: boolean; /** * Set whether the setting is toggled on or off by default. Requires 'toggle_enabled' field to be set to true */ toggle_default?: boolean; /** * Lock the ratio of a vector */ linked_ratio?: boolean; /** * Adds a reset button for the input */ reset_button?: boolean; /** * Extra actions that display as icon buttons next to the input */ extra_actions?: { icon: string; name: string; click: (event: Event) => void; }[]; /** * Set the return type of files on file inputs */ return_as?: 'file'; /** * Runs when any of the buttons is pressed * @param button_index Index of the clicked button in the buttons list */ click?: (button_index: number, event: PointerEvent) => void; readtype?: ReadType | ((file: string) => ReadType); resource_id?: string; extensions?: string[]; filetype?: string; } export type FormResultValue = string | number | boolean | any[] | {}; export type InputFormConfig = { [formElement: string]: '_' | FormElementOptions; }; type FormValues = Record; export declare class InputForm extends EventSystem { uuid: string; form_config: InputFormConfig; form_data: { [formElement: string]: FormElement; }; node: HTMLDivElement; max_label_width: number; uses_wide_inputs: boolean; constructor(form_config: InputFormConfig, options?: {}); buildForm(): void; deleteFormElements(): void; delete(): void; updateLabelWidth(ignore_hidden?: boolean): void; update(form_result: FormValues): void; updateValues(context?: { cause?: string; changed_keys?: string[]; }): FormValues; setValues(values: FormValues, update?: boolean): void; setToggles(values: Record, update?: boolean): void; getResult(): FormValues; static getDefaultValue(input_config: FormElementOptions): FormResultValue; } export declare class FormElement extends EventSystem { id: string; form: InputForm; condition: ConditionResolvable; options: FormElementOptions; bar: HTMLElement; input_toggle?: HTMLInputElement; label_width: number; constructor(id: string, options: FormElementOptions, form: InputForm); build(bar: HTMLDivElement): void; get uses_wide_inputs(): boolean; getValue(): any; setValue(value: any): void; getDefault(): any; delete(): void; change(): void; setup(): void; addShareButtons(bar: HTMLElement): void; static types: Record; static registerType(id: string, type_class: typeof FormElement): void; } declare const global: { InputForm: typeof import("./form").InputForm; FormElement: typeof import("./form").FormElement; }; declare global { const InputForm: typeof global.InputForm; type InputForm = import('./form').InputForm; const FormElement: typeof global.FormElement; type FormElement = import('./form').FormElement; type FormElementOptions = import('./form').FormElementOptions; } export {};