import { EventTypeWithTarget, JBBaseComponent } from "jb-core"; import { ShowValidationErrorParameters, ValidationHelper, ValidationResult, ValidationResultSummary, WithValidation } from "jb-validation"; import { JBButtonWebComponent } from "jb-button"; //#region modules/jb-file-input/web-component/lib/types.d.ts export type ElementObjects = { componentWrapper: HTMLDivElement; virtualInput: HTMLInputElement; placeholder: { section: HTMLButtonElement; wrapper: HTMLSpanElement; title: HTMLSpanElement; message: HTMLSpanElement; }; file: { section: HTMLDivElement; wrapper: HTMLButtonElement; fileName: HTMLSpanElement; }; uploader: { bg: HTMLDivElement; }; overlay: { wrapper: HTMLDivElement; reselect: HTMLButtonElement; delete: JBButtonWebComponent; download: JBButtonWebComponent; }; errorOverlay: { container: HTMLDivElement; message: HTMLSpanElement; }; }; export type ValidationErrorType = "REQUIRED"; export type FileInputStatus = "empty" | "selected"; export type ValidationValue = { file: File | null; }; export type JBFileInputEventType = EventTypeWithTarget; //#endregion //#region modules/jb-form/web-component/dist/jb-form.d.ts //#region modules/jb-form/web-component/lib/virtual-element.d.ts declare class VirtualElement { #private; name: string; /** * name maybe repeated but id must be unique */ id?: string; validation?: ValidationHelper; dom?: HTMLElement; getValue?: () => TValue; getDirtyStatus?: () => boolean; setValue?: (value: TValue) => void; setInitialValue?: (value: TValue) => void; reset?: () => void; get value(): TValue | undefined; set Value(value: TValue); constructor(config: VirtualElementConfig); attachCallbacks(callbacks: VirtualElementCallbacks): void; /** * @public * @description call this function when form value change so it can trigger dirty and validation check for form */ dispatchOnChange: () => void; } //#endregion //#region modules/jb-form/web-component/lib/collections.d.ts /** * @public this symbol will be putted in Map value to indicate that value is gathered from multiple fields and it's not a array value */ declare const ValueCollectionSymbol: unique symbol; declare class TraverseCollection extends Map { [ValueCollectionSymbol]: boolean; constructor(...params: ConstructorParameters>); } //#endregion //#region modules/jb-form/web-component/lib/types.d.ts interface JBFormInputStandards extends HTMLElement { disabled: boolean; required: boolean; /** * name can't be null it must return empty string "" when it's not available (it's HTML standard) */ name: string; value: TValue; /** * if id is not defined it return empty string */ id: string; /** * @description check if user change the value of component based on value provided from outside and return true if user change a initial value */ readonly isDirty: boolean; initialValue: TValue; reset: () => void; get form(): HTMLFormElement | JBFormWebComponent | null; /** * calls when element form changed. */ formAssociatedCallback?: (form: HTMLFormElement | null) => void; /** * when reset method of the forms called */ formResetCallback: () => void; /** * when form disable or enable function called */ formDisabledCallback?: (disabled: boolean) => void; /** * when form restore or autocomplete called. */ formStateRestoreCallback?: (state: string | File | FormData | null, mode: 'autocomplete' | 'restore') => void; } type NativeFormElements = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | HTMLFieldSetElement | HTMLOutputElement | HTMLObjectElement; type TraverseResult = { [key: string]: T | TraverseCollection; }; type FormValidationMessages = { [key: string]: string | null | TraverseCollection; }; type FormValidationSummary = { [key: string]: ValidationResultSummary | TraverseCollection | null; }; type FormValidationResult = { [key: string]: ValidationResult | TraverseCollection | null> | null; }; type FormValues = { [key: string]: TValue; }; type ValidationValue$1 = FormValues; type VirtualElementConfig = { /** * @requires * @property name of your virtual element */ name: string; /** * @property jb-validation ValidationHelper instance. if not provided, this virtual element will not be participated in validation methods and results */ validation?: ValidationHelper; /** * @property help you spot your virtual elements DOM so you could scroll to, in invalidate cases or use it any other way you see fit. */ dom?: HTMLElement; /** * @property we need your component value for value oriented methods like isDirty */ getValue?: () => TValue; /** * @property function that return true if your component value is changed from initialValue (write deep compare functions of value compare here) */ getDirtyStatus?: () => boolean; /** * @property this callback function will be called in case of form setValue called. */ setValue?: (value: TValue) => void; /** * @property this callback function will be called in case of form setInitialValue called. */ setInitialValue?: (value: TValue) => void; /** * Restore the virtual element to its initial value. */ reset?: () => void; }; type VirtualElementCallbacks = { onChange: () => void; }; type JBCheckValidityParameter = { /** * @property in case of error do you want to show it or you just want to get result. true will show error */ showError: boolean; }; type CheckValidityAsyncResult = { /** * @property result of all validations */ isAllValid: boolean; /** * @property keep validation result of standard jb-validation form elements (nested elements not included) */ elements: Map>; /** * @property keep validation result of virtual elements (nested elements not included) */ virtualElements: Map, ValidationResult>; /** * @property keep validation result of sub forms and sub forms (you can access nested elements from here) */ subForms: Map; }; //#endregion //#region modules/jb-form/web-component/lib/form-elements.d.ts declare class FormElements { #private; form: HTMLFormElement; observer: MutationObserver; customElements: Map>, null>; nativeElements: Map; get allElements(): (Partial> | NativeFormElements)[]; reset(): void; constructor(jbForm: JBFormWebComponent); initElements(): void; } //#endregion //#region modules/jb-form/web-component/lib/jb-form.d.ts declare class JBFormWebComponent extends JBBaseComponent { #private; static get formAssociated(): boolean; callbacks: { showValidationError: (_message: ShowValidationErrorParameters) => void; cleanValidationError: () => void; setValidationResult: () => void; }; get validElements(): (Partial> | NativeFormElements)[]; get validation(): ValidationHelper; get isDirty(): boolean; get value(): FormValues; set value(value: FormValues); get name(): string; set name(value: string | null | undefined); get virtualElements(): { list: ReadonlyArray>; dictionary: Readonly>>; add: (config: VirtualElementConfig) => VirtualElement; remove: ({ virtualElement }: { virtualElement: VirtualElement; }) => void; }; get subForms(): { list: readonly JBFormWebComponent[]; dictionary: Readonly<{ [x: string]: JBFormWebComponent[] | JBFormWebComponent; }>; }; get formElements(): FormElements; constructor(); initWebComponent(): void; connectedCallback(): void; static get observedAttributes(): string[]; attributeChangedCallback(name: string, _oldValue: string, newValue: string): void; checkValidity(): boolean; reportValidity(): boolean; /** * @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; /** * @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; /** * @description returns key value object contains dirty status of named element * @returns @public */ getFormDirtyStatus(): TraverseResult; /** * @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(value: TFormValue, shouldUpdateInitialValue?: boolean): void; /** * @description set initial value of named form input elements used for dirty field detection */ setFormInitialValues(value: TFormValue, shouldUpdateValue?: boolean): void; /** * Restore all controls to their initial values and clear validation state. */ reset(): void; formResetCallback(): void; disconnectedCallback(): void; } declare global { interface HTMLElementTagNameMap { "jb-form": JBFormWebComponent; } } //#endregion //#endregion //#region modules/jb-file-input/web-component/lib/jb-file-input.d.ts export declare class JBFileInputWebComponent extends JBBaseComponent implements WithValidation, JBFormInputStandards { #private; static formAssociated: boolean; get disabled(): boolean; set disabled(value: boolean); set required(value: boolean); get required(): boolean; get label(): string | null | undefined; set label(value: string | null | undefined); get message(): string; set message(value: string | null | undefined); get error(): string | null | undefined; set error(value: string | null | undefined); /** * Maximum allowed file size in KB. Set to null to disable size validation. */ get maxSize(): number | null; set maxSize(value: number | null); get name(): string; set name(value: string | null | undefined); get form(): HTMLFormElement | null; get accept(): string; set accept(value: string); get value(): File | null; set value(value: File | null); /** * Default and reset value. It initializes `value` until the live value is explicitly set. */ get initialValue(): File | null; set initialValue(value: File | null); get isDirty(): boolean; reset(): void; formResetCallback(): void; get status(): FileInputStatus; get selectedFileType(): string | null; get isUploading(): boolean; set isUploading(value: boolean); get isLoading(): boolean; get uploadPercent(): number | null; set uploadPercent(value: number | null); get validation(): ValidationHelper; get isAutoValidationDisabled(): boolean; set isAutoValidationDisabled(value: boolean); connectedCallback(): void; initWebComponent(): void; initProp(): void; registerEventListener(): void; openFileSelector(event?: Event): void; static get observedAttributes(): string[]; attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void; onAttributeChange(name: string, value: string | null): void; setStatus(status: FileInputStatus): void; showValidationError(error: ShowValidationErrorParameters): void; clearValidationError(): void; /** * @public * @description this method used to check for validity but doesn't show error to user and just return the result * this method used by #internal of component */ checkValidity(): boolean; /** * @public * @description this method used to check for validity and show error to user */ reportValidity(): boolean; get validationMessage(): string | null; get validity(): ValidityState | undefined; formDisabledCallback(disabled: boolean): void; } declare global { interface HTMLElementTagNameMap { "jb-file-input": JBFileInputWebComponent; } } //#endregion //# sourceMappingURL=jb-file-input.d.ts.map