jb-form
Version:
form web component with extended feature like validation and dirty check
73 lines • 3.29 kB
TypeScript
import { JBCheckValidityParameter, CheckValidityAsyncResult, FormValidationMessages, FormValidationResult, FormValidationSummary, FormValues, TraverseResult, ValidationValue, VirtualElementConfig } from './types';
import { ValidationHelper } from 'jb-validation';
import { VirtualElement } from './virtual-element';
export * from './types.js';
export * from './utils.js';
export { VirtualElement };
export declare class JBFormWebComponent extends HTMLFormElement {
#private;
callbacks: {
showValidationError: (message: string) => void;
cleanValidationError: () => void;
setValidationResult: () => void;
};
get validation(): ValidationHelper<ValidationValue>;
get isDirty(): boolean;
get value(): FormValues;
get virtualElements(): {
list: ReadonlyArray<VirtualElement<any, any>>;
dictionary: Readonly<Record<string, VirtualElement<any, any>>>;
add: <TValue, TValidationValue>(config: VirtualElementConfig<TValue, TValidationValue>) => VirtualElement<TValue, TValidationValue>;
};
get subForms(): {
list: readonly JBFormWebComponent[];
dictionary: Readonly<{
[x: string]: JBFormWebComponent;
}>;
};
constructor();
initWebComponent(): void;
connectedCallback(): void;
static get observedAttributes(): string[];
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
/**
* @description this function will check all standard jb validations includes async validations virtual elements and sub forms. it have most rich validation result betweens jb-form validation results methods
* @public
*/
jbCheckValidity(params: JBCheckValidityParameter): Promise<CheckValidityAsyncResult>;
/**
* @description returns key value object contains validation message of named element
* @returns @public
*/
getValidationMessages(): FormValidationMessages;
/**
* @description returns key value object contains validation summary result of named element
* @returns @public
*/
getValidationSummary(): FormValidationSummary;
/**
* @description returns key value object contains validation summary result of named element
* @returns @public
*/
getValidationResult(): FormValidationResult;
/**
* @description returns key value object contains value of named element
* @returns @public
*/
getFormValues<TFormValue extends FormValues = FormValues>(): TFormValue;
/**
* @description returns key value object contains dirty status of named element
* @returns @public
*/
getFormDirtyStatus(): TraverseResult<boolean>;
/**
* @description set value of named form input elements
* @param shouldUpdateInitialValue determine if we should also update initial value or not. pass false if you want initialValue remain untouched
*/
setFormValues<TFormValue extends FormValues = FormValues>(value: TFormValue, shouldUpdateInitialValue?: boolean): void;
/**
* @description set initial value of named form input elements used for dirty field detection
*/
setFormInitialValues<TFormValue extends FormValues = FormValues>(value: TFormValue, shouldUpdateValue?: boolean): void;
}
//# sourceMappingURL=jb-form.d.ts.map