import {BaseElement, Animation} from "./smart.element" export interface FormProperties { /** * Defines or retrieves the number of columns used to arrange form fields, determining how fields are organized and displayed within the form layout. * Default value: 1 */ columns?: number; /** * Gets or sets the collection of form controls associated with the form. This allows you to retrieve the current controls or update them with a new set of controls. * Default value: null */ controls?: Control[]; /** * Callback function invoked when the status changes. The status parameter passed to the function reflects the new state of the process, and can be one of the following string values: 'disabled', 'invalid', 'pending', or 'valid'. Use this callback to handle logic based on each specific status transition. * Default value: null */ onStatusChanges?: {(value: string): void}; /** * Callback function invoked when the form's value changes. Receives the updated form data as a JSON object argument, allowing you to handle or process the new values within your application. * Default value: null */ onValueChanges?: {(value: any): void}; /** * Defines or retrieves the position of the labels relative to their associated elements. Specify this property to control where labels are displayed (e.g., above, below, left, or right of the element). * Default value: left */ labelPosition?: FormLabelPosition | string; /** * Sets all form fields to read-only mode, preventing users from modifying their input while still allowing them to view the existing data. * Default value: false */ readonly?: boolean; /** * Controls the visibility of the colon character that appears after label text. When enabled, a colon is displayed after each label; when disabled, the colon is omitted. * Default value: false */ showColonAfterLabel?: boolean; /** * Toggles the visibility of the validation summary, allowing users to display or hide a list of validation errors based on form input. * Default value: true */ showSummary?: boolean; /** * Retrieves the current status of the Form. Each entry within the status object contains the following boolean properties: dirty (indicates if the form field has been modified), untouched (indicates if the field has not been focused by the user), and disabled (indicates if the field is currently disabled). * Default value: null */ status?: any; /** * Retrieves or assigns the current value of the form. Use this property to access the form's data for processing or to update the form with new values programmatically. * Default value: null */ value?: any; /** * Automatically triggers form validation immediately upon form initialization, ensuring that all form fields are checked for correctness as soon as the form is rendered or instantiated. * Default value: false */ validateOnLoad?: boolean; } /** Reactive Form Component with Advanced Validation */ export interface Form extends BaseElement, FormProperties { /* Get a member by its name */ [name: string]: any; /** * Inserts a new control element, such as an input field, button, or checkbox, into the Form, allowing users to interact with and submit data. * @param {any} controlOptions. Control options. The control options description is available in the controls property. */ addControl(controlOptions: any): void; /** * Retrieves a specific control element from the form using its name attribute, as defined by the dataField parameter. This method enables direct access to the control's properties and methods for further manipulation or data retrieval. * @param {string} dataField. dataField of a FormControl or FormGroup * @returns {Control} */ getControl(dataField: string): Control; /** * Adds a new control element to the Form, allowing users to dynamically extend the form’s functionality. This method enables the inclusion of input fields, buttons, dropdowns, or other interactive components within the Form, ensuring seamless integration and consistent behavior with existing controls. * @param {number} index. Control insert index * @param {any} controlOptions. Control options. The control options description is available in the controls property. */ insertControl(index: number, controlOptions: any): void; /** * Removes a specified control element from the Form, ensuring it is no longer rendered or managed as part of the Form's structure and behavior. * @param {any} controlOptions. Control options. The control options description is available in the controls property. */ removeControl(controlOptions: any): void; /** * Triggers the submission of the form, sending the user-entered data to the specified server endpoint for processing. This action may also initiate form validation and execute any associated event handlers before transmitting the data. * @param {any} submitOptions?. Sets the submit options object. The object may have the following properties: async, action, target, method. async determines whether the form will be submitted asynchronously. action determines the submit url, method sets whether the submit is through 'GET' or 'POST'. target determines the submit target. */ submit(submitOptions?: any): void; /** * Resets all fields in the form to their initial, default values, effectively clearing any user input or changes made. */ reset(): void; /** * Performs comprehensive validation of the form fields, ensuring that all required inputs are provided, data types and formats are correct, and any specified constraints or validation rules are met before allowing form submission. */ validate(): void; } export interface Control { /** * HTML Content displayed after the Form Control * Default value: "" */ append?: string; /** * JSON object with initialization properties of the UI component. Example: { dataSource: ['item 1', 'item 2', 'item 3'] } will set the dataSource property of the Form control. * Default value: null */ controlOptions?: any; /** * The type of the control. * Default value: input */ controlType?: ControlControlType | string; /** * Sets the Form Group columns. * Default value: 1 */ columns?: number; /** * Sets the Form control column span. * Default value: 1 */ columnSpan?: number; /** * * Default value: null */ controls?: Control[]; /** * Sets the Form control data field. The control's inner input's name is set to the dataField value and in the FormGroup it is accessible through the dataField value. * Default value: "" */ dataField?: string; /** * Sets the Form control disabled mode. * Default value: false */ disabled?: boolean; /** * Gets whether the Form control is 'dirty' i.e its value is changed by the user. * Default value: false */ dirty?: boolean; /** * Gets or Sets the Form control's info icon's tooltip. * Default value: "" */ info?: string; /** * Gets whether the Form control is invalid. * Default value: false */ invalid?: boolean; /** * Gets or Sets the Form control's label. * Default value: "" */ label?: string; /** * Gets or Sets the Form control's label position. * Default value: left */ labelPosition?: ControlLabelPosition | string; /** * Gets or Sets the offset between the label and the control. * Default value: 10 */ labelOffset?: number; /** * FormGroup only(when controlType is set to 'group'). Gets or Sets whether the navigation buttons are displayed. The property has effect when the viewMode property is set. * Default value: "left" */ labelAlign?: string; /** * FormGroup only(when controlType is set to 'group'). Gets or Sets the next button label. * Default value: "Next" */ nextButtonLabel?: string; /** * FormGroup only(when controlType is set to 'group'). Gets or Sets the back button label. * Default value: "Back" */ backButtonLabel?: string; /** * HTML Content displayed before the Form Control * Default value: "" */ prepend?: string; /** * Gets or Sets the Form control readonly mode. * Default value: false */ readonly?: boolean; /** * Gets whether the Form control is not touched by the user. This flag is changed usually on blur, after the user interacted with the Form control * Default value: false */ untouched?: boolean; /** * Gets or Sets the placeholder. * Default value: "" */ placeholder?: string; /** * FormGroup only(when controlType is set to 'group'). Gets or Sets whether the navigation buttons are displayed. The property has effect when the viewMode property is set. * Default value: false */ showButtons?: boolean; /** * Sets or Gets the Form control or Form group value. * Default value: null */ value?: any; /** * Gets whether the Form control is valid. * Default value: false */ valid?: boolean; /** * Sets or gets the column's validation rules. The expected value is an Array of Objects. Each object should have a 'type' property that can be set to 'required', 'min', 'max', 'minLength', 'maxLength', 'email', 'null', 'requiredTrue', 'minData', 'maxDate', 'pattern'. The 'value' property should be set, too. For validation rule types 'required', 'requiredTrue' and 'null' you can skip the 'value' property. Optional property is 'message', which determines the error message. * Default value: null */ validationRules?: [] | null; /** * FormGroup only(when controlType is set to 'group'). Gets or Sets the form'group view mode. * Default value: */ viewMode?: ControlViewMode | string; } declare global { interface Document { createElement(tagName: "smart-form"): Form; querySelector(selectors: "smart-form"): Form | null; querySelectorAll(selectors: "smart-form"): NodeListOf