@gsb-core/core
Version:
GSB core services and classes for platform-independent web applications
78 lines (77 loc) • 2.08 kB
TypeScript
/**
* GSB Form Models
*
* Defines interfaces for form components and form-related functionality
*/
import { GsbEntityDef } from './gsb-entity-def.model';
/**
* Base class for all GSB forms
* @template T The type of entity the form handles
*/
export declare class GsbForm<T = any> {
_entDefName?: string;
/**
* Entity definition for the form
* If not provided, the form initialization will attempt to fetch it based on entityDefId or entityDefName
*/
entityDef?: GsbEntityDef;
/**
* Entity definition ID
* Used to fetch the entity definition if entityDef is not provided
*/
entityDefId?: string;
/**
* Entity definition name
* Used to fetch the entity definition if entityDef and entityDefId are not provided
*/
entityDefName?: string;
/**
* The entity instance being edited/viewed
* If not provided but entityId is, the form will fetch it
*/
entity?: T;
/**
* Entity ID to fetch when entity is not provided
*/
entityId?: string;
/**
* Called when the form is submitted with valid values
*/
onSubmit?: (values: T) => void | Promise<void>;
/**
* Called when form values change
*/
onChange?: (values: T) => void;
/**
* Called when the form is cancelled
*/
onCancel?: () => void;
/**
* Indicates if the form is in a loading state
*/
isLoading?: boolean;
/**
* Whether the form is in read-only mode
*/
readOnly?: boolean;
/**
* Additional CSS class names
*/
className?: string;
constructor(obj?: Partial<GsbForm<T>>);
}
/**
* Class for forms that can be used in edit mode
* @template T The type of entity the form handles
*/
export declare class GsbEditableForm<T = any> extends GsbForm<T> {
/**
* Flag to indicate if the form is in edit mode
*/
isEditMode?: boolean;
/**
* Called when edit mode is toggled
*/
onEditModeChange?: (isEditMode: boolean) => void;
constructor(obj?: Partial<GsbEditableForm<T>>);
}