UNPKG

@fluent-form/core

Version:

An Angular dynamic forms library powered by Fluent API and JSON.

943 lines (869 loc) 44.5 kB
import { AbstractControl, FormGroup, FormControlStatus, ValidatorFn, FormControl, AbstractControlOptions, AsyncValidatorFn, FormArray } from '@angular/forms'; import { AnyObject, SafeAny as SafeAny$1, PickProperty, AnyArray } from '@ngify/core'; import * as i0 from '@angular/core'; import { TemplateRef, OnInit, EventEmitter, OutputRef, Signal, Provider, InjectionToken, Type, PipeTransform, ProviderToken, InjectOptions } from '@angular/core'; import * as _fluent_form_core from '@fluent-form/core'; import { Observable } from 'rxjs'; import * as i1 from '@angular/common'; declare abstract class TemplateRefHolder<C> { templateRef: TemplateRef<C>; static ɵfac: i0.ɵɵFactoryDeclaration<TemplateRefHolder<any>, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<TemplateRefHolder<any>, never, never, {}, {}, never, never, true, never>; } /** * @internal */ declare class FluentBindingDirective<E extends HTMLElement, C extends object, S extends AbstractSchema> implements OnInit { private readonly destroyRef; private readonly injector; readonly fluentBinding: i0.InputSignal<{ component?: C; schema: S; control: AbstractControl; model: AnyObject; }>; private readonly schema; private readonly model; private readonly control; private readonly component; constructor(); ngOnInit(): void; static ɵfac: i0.ɵɵFactoryDeclaration<FluentBindingDirective<any, any, any>, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<FluentBindingDirective<any, any, any>, "[fluentBinding]", never, { "fluentBinding": { "alias": "fluentBinding"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>; } /** * @internal */ declare class FluentContextGuardDirective<T> { fluentContextGuard: T; /** * @internal */ static ngTemplateContextGuard<T>(_: FluentContextGuardDirective<T>, context: unknown): context is T; static ɵfac: i0.ɵɵFactoryDeclaration<FluentContextGuardDirective<any>, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<FluentContextGuardDirective<any>, "ng-template[fluentContextGuard]", never, { "fluentContextGuard": { "alias": "fluentContextGuard"; "required": false; }; }, {}, never, never, true, never>; } declare class FluentControlWrapperDirective { static ɵfac: i0.ɵɵFactoryDeclaration<FluentControlWrapperDirective, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<FluentControlWrapperDirective, "[fluentControlWrapper]", never, {}, {}, never, never, true, never>; } /** * Attribute map for HTML elements. */ type HTMLElementPropertyMap<E extends HTMLElement> = Partial<PickProperty<E>>; /** * The name of the component's `Output` * ```ts * nzChange | nzVisibleChange * ``` * @template C The component's class type */ type ComponentOutputName<C> = Exclude<{ [K in keyof C]: C[K] extends EventEmitter<SafeAny$1> | OutputRef<SafeAny$1> ? K : never; }[keyof C], undefined>; /** * The output object of the component * ```ts * { nzChange: EventType, ... } * ``` * @template C The component's class type * @template S The schemas of various controls */ type ComponentOutputMap<C> = { [K in ComponentOutputName<C>]?: C[K] extends EventEmitter<infer E> | OutputRef<infer E> ? E : never; }; /** * Component class properties * ```ts * { nzValue: string, other: unknown, ... } * ``` * @template C The component's class type */ type ComponentPropertyMap<C> = { [K in keyof Omit<C, ComponentOutputName<C>>]?: C[K] extends Signal<infer S> ? S : C[K]; }; type Stringify<T> = T extends number ? `${T}` : never; type Indexable<T> = T & Record<string, SafeAny$1>; type Cell = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12; type Span = Cell | 'fill' | null; type Offset = Cell | 'auto' | null; declare class FluentColDirective { readonly fluentCol: i0.InputSignalWithTransform<boolean, unknown>; readonly span: i0.InputSignal<Span | Stringify<Span> | Partial<Record<"xs" | "sm" | "md" | "lg" | "xl" | "xxl", Span>> | undefined>; readonly flex: i0.InputSignal<string | number | null | undefined>; readonly offset: i0.InputSignal<Offset | Stringify<Offset> | Partial<Record<"xs" | "sm" | "md" | "lg" | "xl" | "xxl", Offset>> | undefined>; protected readonly classes: i0.Signal<string[]>; constructor(); static ɵfac: i0.ɵɵFactoryDeclaration<FluentColDirective, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<FluentColDirective, "fluent-col,[fluentCol]", ["fluentCol"], { "fluentCol": { "alias": "fluentCol"; "required": false; "isSignal": true; }; "span": { "alias": "span"; "required": false; "isSignal": true; }; "flex": { "alias": "flex"; "required": false; "isSignal": true; }; "offset": { "alias": "offset"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>; } type Gap = 0 | 1 | 2 | 3 | 4 | 5 | 6; type Justify = 'start' | 'end' | 'center' | 'space-around' | 'space-between' | 'space-evenly'; type Align = 'start' | 'end' | 'center'; declare class FluentRowDirective { readonly gap: i0.InputSignal<Gap | Stringify<Gap> | [x: Gap, y: Gap] | Partial<Record<"xs" | "sm" | "md" | "lg" | "xl" | "xxl", Gap | [x: Gap, y: Gap]>> | null | undefined>; readonly justify: i0.InputSignal<Justify | null | undefined>; readonly align: i0.InputSignal<Align | null | undefined>; /** Currently matched breakpoints. */ private readonly breakpoints; protected readonly gapPx: i0.Signal<[number, (number | undefined)?]>; protected readonly justifyContent: i0.Signal<string | null | undefined>; protected readonly alignItems: i0.Signal<string | null | undefined>; constructor(); static ɵfac: i0.ɵɵFactoryDeclaration<FluentRowDirective, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<FluentRowDirective, "fluent-row,[fluentRow]", ["fluentRow"], { "gap": { "alias": "gap"; "required": false; "isSignal": true; }; "justify": { "alias": "justify"; "required": false; "isSignal": true; }; "align": { "alias": "align"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>; } declare class FluentGridModule { static ɵfac: i0.ɵɵFactoryDeclaration<FluentGridModule, never>; static ɵmod: i0.ɵɵNgModuleDeclaration<FluentGridModule, never, [typeof FluentRowDirective, typeof FluentColDirective], [typeof FluentRowDirective, typeof FluentColDirective]>; static ɵinj: i0.ɵɵInjectorDeclaration<FluentGridModule>; } declare abstract class FluentControlContainer<T extends AnyObject | AnyArray> { abstract readonly schema: Signal<AbstractControlContainerSchema>; abstract readonly patchedSchema: Signal<AbstractControlContainerSchema>; abstract readonly form: Signal<FormGroup>; abstract readonly model: Signal<T>; } declare class FluentFormDirective<T extends AnyObject | AnyArray> implements FluentControlContainer<T> { private readonly formUtil; private readonly schemaUtil; private readonly modelUtil; private internalModel; readonly schema: i0.InputSignal<AbstractFormGroupSchema>; readonly model: i0.ModelSignal<T>; readonly patchedSchema: i0.Signal<AbstractFormGroupSchema>; readonly form: i0.Signal<FormGroup<any>>; readonly formChange: i0.OutputEmitterRef<FormGroup<any>>; readonly valueChanges: i0.OutputEmitterRef<T>; readonly statusChanges: i0.OutputEmitterRef<FormControlStatus>; /** The submit event will only be triggered when the host element is a form element */ readonly submit: i0.OutputEmitterRef<SubmitEvent>; constructor(); onSubmit(event: SubmitEvent): boolean; private onValueChanges; static ɵfac: i0.ɵɵFactoryDeclaration<FluentFormDirective<any>, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<FluentFormDirective<any>, "[fluentSchema]", ["fluentForm"], { "schema": { "alias": "fluentSchema"; "required": true; "isSignal": true; }; "model": { "alias": "fluentModel"; "required": true; "isSignal": true; }; }, { "model": "fluentModelChange"; "formChange": "fluentFormChange"; "valueChanges": "fluentValueChanges"; "statusChanges": "fluentStatusChanges"; "submit": "fluentSubmit"; }, never, never, true, never>; } declare const enum FluentFormFeatureKind { UIAdapter = 0, StaticExpression = 1, SchemaPatcher = 2, Preloading = 3 } interface FluentFormFeature<K extends FluentFormFeatureKind> { kind: K; providers: Provider[]; } declare function makeFluentFeature<K extends FluentFormFeatureKind>(kind: K, providers: Provider[]): FluentFormFeature<K>; declare function withPreloading(): FluentFormFeature<FluentFormFeatureKind.Preloading>; type SchemaSelector = '*' | string | SchemaType | (string | SchemaType)[]; type SchemaPatchFn<S extends AbstractSchema> = (schema: S & Record<string, SafeAny$1>) => S; interface SchemaPatcher<S extends AbstractSchema = AbstractSchema> { selector: SchemaSelector; patch: SchemaPatchFn<S>; } declare const SCHEMA_PATCHERS: InjectionToken<SchemaPatcher<_fluent_form_core.AbstractSchema<_fluent_form_core.SchemaKey>>[]>; declare function provideSchemaPatcher(patcher: SchemaPatcher): Provider; declare function withSchemaPatchers(patchers: (SchemaPatcher | SchemaPatcher[])[]): FluentFormFeature<FluentFormFeatureKind.SchemaPatcher>; declare function withStaticExpression(): FluentFormFeature<FluentFormFeatureKind.StaticExpression>; /** Name of any kind of field control */ type SchemaKey = SingleSchemaKey | MultiSchemaKey; /** Name of a single-field schema */ type SingleSchemaKey = string | number; /** Name of a multi-field schema */ type MultiSchemaKey = readonly string[]; /** * @public */ declare enum SchemaType { Control = 0, ControlGroup = 1, ControlArray = 2, ControlWrapper = 3, Component = 4, ComponentContainer = 5, ComponentWrapper = 6 } declare const enum SchemaKind { Headless = "headless", Headful = "headful", Template = "template", Row = "row" } interface SchemaLike<Key extends SchemaKey = SchemaKey> { kind: string; key?: Key; } interface SchemaContext<S extends SchemaLike = AbstractSchema> { schema: S; /** * If there is no corresponding control, the parent control will be returned, * usually a `FormGroup` or `FormArray`. */ control: AbstractControl; model: SafeAny$1; } type Length = number | { max?: number; min?: number; }; type SchemaReactiveFn<S extends AbstractSchema, R> = (ctx: SchemaContext<S>) => R; type MaybeSchemaReactiveFn<S extends AbstractSchema, R> = R | SchemaReactiveFn<S, R>; type WithoutSchemaReactiveFn<T extends MaybeSchemaReactiveFn<AbstractSchema, SafeAny$1>> = Exclude<T, SchemaReactiveFn<SafeAny$1, SafeAny$1>>; interface SchemaConfig<S extends AbstractSchema> { type: SchemaType; /** Add built-in validators from the schema. */ validators?: (schema: S) => ValidatorFn[]; } interface DefaultExport<T> { default: T; } type MaybeDefaultExport<T> = T | DefaultExport<T>; interface FluentFormWidgetConfig<S extends AbstractSchema> extends SchemaConfig<S> { kind: S['kind']; widget?: Type<AbstractWidget<unknown>>; loadWidget?: () => Promise<MaybeDefaultExport<Type<AbstractWidget<unknown>>>>; /** Patch the schema, called when normalizing the schema. */ patch?: SchemaPatchFn<S>; } declare function provideWidgetConfigs(configs: (FluentFormWidgetConfig<SafeAny$1> | FluentFormWidgetConfig<SafeAny$1>[])[]): Provider[]; declare function useRowWidget(): FluentFormWidgetConfig<RowComponentSchema>; interface WidgetTemplateContext<S extends AbstractSchema, C extends AbstractControl = FormControl> { schema: S; control: C; model: AnyObject; } declare abstract class AbstractWidget<C> extends TemplateRefHolder<C> { protected readonly contextGuard: C; static ɵfac: i0.ɵɵFactoryDeclaration<AbstractWidget<any>, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<AbstractWidget<any>, never, never, {}, {}, never, never, true, never>; } declare class FluentOutletDirective<T extends AnyObject | AnyArray> implements WidgetTemplateContext<AbstractSchema, AbstractControl> { private readonly schemaUtil; private readonly registry; private readonly viewContainerRef; private readonly controlContainer; private readonly _schema; private readonly _control; private readonly _model; get control(): AbstractControl; get schema(): AbstractSchema<SchemaKey>; get model(): T; readonly key: i0.InputSignal<SingleSchemaKey | SchemaKey[]>; constructor(); static ɵfac: i0.ɵɵFactoryDeclaration<FluentOutletDirective<any>, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<FluentOutletDirective<any>, "fluent-outlet,[fluentOutlet]", ["fluentOutlet"], { "key": { "alias": "key"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>; } declare class FluentFormRenderModule { static ɵfac: i0.ɵɵFactoryDeclaration<FluentFormRenderModule, never>; static ɵmod: i0.ɵɵNgModuleDeclaration<FluentFormRenderModule, never, [typeof FluentFormDirective, typeof FluentOutletDirective], [typeof FluentFormDirective, typeof FluentOutletDirective]>; static ɵinj: i0.ɵɵInjectorDeclaration<FluentFormRenderModule>; } declare class FluentTemplateOutlet<C = unknown> { readonly fluentTemplateOutlet: i0.InputSignal<string | TemplateRef<C> | null | undefined>; readonly fluentTemplateOutletContext: i0.InputSignal<C | null>; constructor(); /** * For a given outlet instance, we create a proxy object that delegates * to the user-specified context. This allows changing, or swapping out * the context object completely without having to destroy/re-create the view. */ private createContextProxy; static ɵfac: i0.ɵɵFactoryDeclaration<FluentTemplateOutlet<any>, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<FluentTemplateOutlet<any>, "[fluentTemplateOutlet]", never, { "fluentTemplateOutlet": { "alias": "fluentTemplateOutlet"; "required": true; "isSignal": true; }; "fluentTemplateOutletContext": { "alias": "fluentTemplateOutletContext"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>; } declare class FluentTemplate implements OnInit { private readonly templateRef; private readonly templates; readonly fluentTemplate: i0.InputSignal<string>; constructor(); ngOnInit(): void; static ɵfac: i0.ɵɵFactoryDeclaration<FluentTemplate, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<FluentTemplate, "[fluentTemplate]", never, { "fluentTemplate": { "alias": "fluentTemplate"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>; } /** * @deprecated * This will be removed in the next major version. Use {@link FluentTemplate} instead. */ declare const FluentTemplateDirective: typeof FluentTemplate; /** * @internal */ declare class FluentWithInjectorDirective { constructor(); static ɵfac: i0.ɵɵFactoryDeclaration<FluentWithInjectorDirective, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<FluentWithInjectorDirective, "[ngTemplateOutlet][fluentWithInjector]", never, {}, {}, never, never, true, never>; } interface WidgetWrapperContext { control: AbstractControl; model: AnyObject; schema: AbstractSchema; templateRef: TemplateRef<WidgetWrapperContext>; next?: WidgetWrapperContext; } declare abstract class AbstractWidgetWrapper extends TemplateRefHolder<WidgetWrapperContext> { static ɵfac: i0.ɵɵFactoryDeclaration<AbstractWidgetWrapper, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<AbstractWidgetWrapper, never, never, {}, {}, never, never, true, never>; } declare class FluentNextWidgetWrapperOutlet { constructor(); static ɵfac: i0.ɵɵFactoryDeclaration<FluentNextWidgetWrapperOutlet, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<FluentNextWidgetWrapperOutlet, "[fluentNextWidgetWrapperOutlet]", never, {}, {}, never, never, true, [{ directive: typeof i1.NgTemplateOutlet; inputs: { "ngTemplateOutletContext": "fluentNextWidgetWrapperOutlet"; }; outputs: {}; }]>; } declare class FluentNextWidgetWrapper extends AbstractWidgetWrapper { static ɵfac: i0.ɵɵFactoryDeclaration<FluentNextWidgetWrapper, never>; static ɵcmp: i0.ɵɵComponentDeclaration<FluentNextWidgetWrapper, "ng-component", never, {}, {}, never, never, true, never>; } declare class FluentWidgetWrapperOutlet<C extends SchemaContext> { readonly context: i0.InputSignal<C>; readonly wrappers: i0.InputSignal<Type<AbstractWidgetWrapper>[] | undefined>; readonly schema: i0.Signal<AbstractSchema<SchemaKey>>; constructor(); static ɵfac: i0.ɵɵFactoryDeclaration<FluentWidgetWrapperOutlet<any>, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<FluentWidgetWrapperOutlet<any>, "[fluentWidgetWrapperOutlet]", never, { "context": { "alias": "fluentWidgetWrapperOutlet"; "required": true; "isSignal": true; }; "wrappers": { "alias": "fluentWidgetWrapperOutletWrappers"; "required": false; "isSignal": true; }; }, {}, never, never, true, [{ directive: typeof i1.NgTemplateOutlet; inputs: {}; outputs: {}; }]>; } interface Row { align?: ReturnType<FluentRowDirective['align']>; justify?: ReturnType<FluentRowDirective['justify']>; gap?: ReturnType<FluentRowDirective['gap']>; } interface Column { span?: ReturnType<FluentColDirective['span']>; offset?: ReturnType<FluentColDirective['offset']>; flex?: ReturnType<FluentColDirective['flex']>; } interface HooksHolder<S extends SchemaLike = SchemaLike> { hooks?: { onInit?: (context: SchemaContext<S>) => void; onDestroy?: (context: SchemaContext<S>) => void; }; } type WidgetWrapperType = Type<TemplateRefHolder<WidgetWrapperContext>> | string; type ClassType = string | string[] | undefined | null | Record<string, boolean | undefined | null>; type StyleType = Partial<Record<keyof CSSStyleDeclaration | (string & {}), string>> | undefined | null; type ElementType = 'host' | 'wrapper'; /** * 抽象图示 */ interface AbstractSchema<Key extends SchemaKey = SchemaKey> extends SchemaLike<Key>, HooksHolder<AbstractSchema> { col?: Column | ReturnType<FluentColDirective['span']>; hidden?: MaybeSchemaReactiveFn<AbstractSchema, boolean>; class?: MaybeSchemaReactiveFn<AbstractSchema, ClassType | Partial<Record<ElementType, ClassType>>>; style?: MaybeSchemaReactiveFn<AbstractSchema, StyleType | Partial<Record<ElementType, StyleType>>>; wrappers?: (WidgetWrapperType[] | WidgetWrapperType)[]; } interface AbstractBranchSchema<Key extends SchemaKey = SchemaKey> extends AbstractSchema<Key> { schemas: Indexable<AbstractSchema>[]; } type AbstractComponentSchema<Key extends SingleSchemaKey = SingleSchemaKey> = AbstractSchema<Key>; interface ListenerContext extends SchemaContext { element: HTMLElement; component: unknown; } type ControlEventListenerMap<Val> = { valueChange?: (value: Val, context: ListenerContext) => void; statusChange?: (status: FormControlStatus, context: ListenerContext) => void; }; type ComponentOutputListenerMap<C> = { [K in keyof ComponentOutputMap<C>]?: (value: ComponentOutputMap<C>[K], context: ListenerContext) => void; }; type ElementEventListenerMap = { [K in keyof HTMLElementEventMap]?: (event: HTMLElementEventMap[K], context: ListenerContext) => void; }; /** 事件侦听器 */ interface EventListenerHolder { listeners?: Partial<Record<string, ((event: SafeAny$1, context: ListenerContext) => SafeAny$1)>>; } /** 控件事件侦听器 */ interface ControlEventListenerHolder<V = SafeAny$1> extends EventListenerHolder { listeners?: ControlEventListenerMap<V> & ElementEventListenerMap; } /** 组件事件侦听器 */ interface ComponentEventListenerHolder<C> extends EventListenerHolder { listeners?: ComponentOutputListenerMap<C> & ElementEventListenerMap; } /** 组件控件事件侦听器 */ interface ComponentControlEventListenerHolder<C, V = SafeAny$1> extends EventListenerHolder { listeners?: ComponentOutputListenerMap<C> & ControlEventListenerMap<V> & ElementEventListenerMap; } /** 元素事件侦听器 */ interface ElementEventListenerHolder extends EventListenerHolder { listeners?: ElementEventListenerMap; } /** 元素控件事件侦听器 */ interface ElementControlEventListenerHolder<V = SafeAny$1> extends EventListenerHolder { listeners?: ElementEventListenerMap & ControlEventListenerMap<V>; } type ControlEventObserverMap<Val> = { valueChange?: (source: Observable<{ event: Val; context: ListenerContext; }>) => Observable<SafeAny$1>; statusChange?: (source: Observable<{ event: FormControlStatus; context: ListenerContext; }>) => Observable<SafeAny$1>; }; type ComponentOutputObserverMap<C> = { [K in keyof ComponentOutputMap<C>]?: (source: Observable<{ event: ComponentOutputMap<C>[K]; context: ListenerContext; }>) => Observable<SafeAny$1>; }; type ElementEventObserverMap = { [K in keyof HTMLElementEventMap]?: (source: Observable<{ event: HTMLElementEventMap[K]; context: ListenerContext; }>) => Observable<SafeAny$1>; }; /** 事件侦听器 */ interface EventObserverHolder { observers?: Partial<Record<string, ((source: Observable<{ event: SafeAny$1; context: ListenerContext; }>) => Observable<SafeAny$1>)>>; } /** 控件事件侦听器 */ interface ControlEventObserverHolder<V = SafeAny$1> extends EventObserverHolder { observers?: ControlEventObserverMap<V> & ElementEventObserverMap; } /** 组件事件侦听器 */ interface ComponentEventObserverHolder<C> extends EventObserverHolder { observers?: ComponentOutputObserverMap<C> & ElementEventObserverMap; } /** 组件控件事件侦听器 */ interface ComponentControlEventObserverHolder<C, V = SafeAny$1> extends EventObserverHolder { observers?: ComponentOutputObserverMap<C> & ControlEventObserverMap<V> & ElementEventObserverMap; } /** 元素事件侦听器 */ interface ElementEventObserverHolder extends EventObserverHolder { observers?: ElementEventObserverMap; } /** 元素控件事件侦听器 */ interface ElementControlEventObserverHolder<V = SafeAny$1> extends EventObserverHolder { observers?: ElementEventObserverMap & ControlEventObserverMap<V>; } /** 属性修补器 */ interface PropertyHolder { properties?: Record<string, SafeAny$1>; } /** 组件属性修补器 */ interface ComponentPropertyHolder<C> extends PropertyHolder { properties?: ComponentPropertyMap<C> & HTMLElementPropertyMap<HTMLElement>; } /** 元素属性修补器 */ interface ElementPropertyHolder<E extends HTMLElement = HTMLElement> extends PropertyHolder { properties?: HTMLElementPropertyMap<E>; } /** * @public */ type AbstractComponentContainerSchema<Key extends SingleSchemaKey = SingleSchemaKey> = AbstractBranchSchema<Key>; /** * @public */ interface RowComponentSchema<Key extends SingleSchemaKey = SingleSchemaKey> extends AbstractComponentContainerSchema<Key>, ElementEventListenerHolder, ElementEventObserverHolder, ElementPropertyHolder<HTMLElement>, Row { kind: 'row'; } /** * @public */ type AbstractComponentWrapperSchema<Key extends SingleSchemaKey = SingleSchemaKey> = AbstractBranchSchema<Key>; interface ControlValueMapper<V> { /** A parser that maps from a model's value to a form control's value */ parser: (value: SafeAny$1 | null, schema: AbstractControlSchema) => V | null; /** A formatter that maps from a form control's value to a model's value */ formatter: (value: V | null, schema: AbstractControlSchema) => SafeAny$1 | null; } /** * Abstract representation of a real (concrete) control schema. */ interface AbstractControlSchema<Key extends SchemaKey = SchemaKey, Val = SafeAny$1> extends AbstractSchema<Key> { id?: string; /** I/O mapper for control */ mapper?: ControlValueMapper<Val>; /** Linkage control values */ value?: SchemaReactiveFn<AbstractControlSchema, Val>; defaultValue?: SafeAny$1 | Val; /** Is it a required control */ required?: MaybeSchemaReactiveFn<AbstractControlSchema<SchemaKey, Val>, boolean>; /** Whether to disable control */ disabled?: MaybeSchemaReactiveFn<AbstractControlSchema<SchemaKey, Val>, boolean>; /** Validator for the control */ validators?: ValidatorFn[]; /** Async validators for control */ asyncValidators?: AsyncValidatorFn[]; config?: ControlSchemaConfig; } interface ControlSchemaConfig { /** The event name for control to update upon. */ updateOn?: AbstractControlOptions['updateOn']; } /** * @public */ interface HeadlessControlSchema<Key extends SingleSchemaKey = SingleSchemaKey> extends AbstractControlSchema<Key>, ControlEventObserverHolder, ControlEventListenerHolder { kind: 'headless'; } /** * @public */ interface AbstractHeadfulControlSchema extends PropertyHolder, EventListenerHolder, EventObserverHolder { kind: 'headful'; template: string; } /** * @public * 抽象的容器控件图示 */ interface AbstractControlContainerSchema<Key extends SingleSchemaKey = SingleSchemaKey> extends AbstractBranchSchema<Key>, ControlEventListenerHolder<SafeAny$1>, ControlEventObserverHolder<SafeAny$1>, Row { /** Validator for the control */ validators?: ValidatorFn[]; /** Async validators for control */ asyncValidators?: AsyncValidatorFn[]; config?: ControlSchemaConfig; } /** * @public */ type AbstractFormGroupSchema<Key extends SingleSchemaKey = SingleSchemaKey> = AbstractControlContainerSchema<Key>; /** * @public */ interface AbstractFormArraySchema<Key extends SingleSchemaKey = SingleSchemaKey> extends AbstractControlContainerSchema<Key> { length?: Length; } /** * @public */ interface AbstractControlWrapperSchema<Key extends SingleSchemaKey = SingleSchemaKey> extends AbstractBranchSchema<Key> { schemas: Indexable<AbstractControlSchema>[]; } interface FormContentTemplateContext { form: FormGroup; model: AnyObject; schema: AbstractSchema; onSubmit: (event: SubmitEvent) => boolean; } declare abstract class AbstractFormContentComponent extends TemplateRefHolder<FormContentTemplateContext> { static ɵfac: i0.ɵɵFactoryDeclaration<AbstractFormContentComponent, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<AbstractFormContentComponent, never, never, {}, {}, never, never, true, never>; } declare class FluentForm<T extends AnyObject> { private readonly formUtil; private readonly modelUtil; private readonly schemaUtil; private internalModel; protected readonly formContentRef: i0.ComponentRef<_fluent_form_core.AbstractFormContentComponent>; readonly schema: i0.InputSignal<AbstractFormGroupSchema>; readonly model: i0.ModelSignal<T>; readonly patchedSchema: i0.Signal<AbstractFormGroupSchema>; readonly form: i0.Signal<FormGroup<any>>; readonly formChange: i0.OutputEmitterRef<FormGroup<any>>; readonly valueChanges: i0.OutputEmitterRef<T>; readonly statusChanges: i0.OutputEmitterRef<FormControlStatus>; readonly submit: i0.OutputEmitterRef<SubmitEvent>; readonly onSubmit: (event: SubmitEvent) => boolean; constructor(); private onValueChanges; static ɵfac: i0.ɵɵFactoryDeclaration<FluentForm<any>, never>; static ɵcmp: i0.ɵɵComponentDeclaration<FluentForm<any>, "fluent-form", never, { "schema": { "alias": "schema"; "required": true; "isSignal": true; }; "model": { "alias": "model"; "required": true; "isSignal": true; }; }, { "model": "modelChange"; "formChange": "formChange"; "valueChanges": "valueChanges"; "statusChanges": "statusChanges"; "submit": "submit"; }, never, never, true, never>; } /** * @deprecated * This component will be removed in future versions. Please use {@link FluentForm} instead. */ declare const FluentFormComponent: typeof FluentForm; interface Schema { [k: string]: SafeAny$1; schemas?: Schema[]; } declare const COMPOSE_KEY = "schemas"; declare function getCurrentSchema(): Schema | undefined; declare const BUILD_KEY = "build"; declare function composeBuilder<T extends Record<string, SafeAny$1>>(target?: AnyObject, append?: boolean): Builder<T>; /** * Determines whether the value is a builder. */ declare function isBuilder<T = unknown>(value: SafeAny$1): value is StableBuilder<T>; type ComposeKey = typeof COMPOSE_KEY; type BuildKey = typeof BUILD_KEY; type RequiredKey<T> = { [K in keyof T]-?: undefined extends T[K] ? never : K; }[keyof T]; type ComposeFn$1<T extends Record<string, SafeAny$1>> = (it: Builder<T>) => SafeAny$1; /** * @template T 原型 * @template TCandidateKey 候选 * @template TRequiredKey 必填字段 * @template TSelectedKey 已选字段 */ type Builder<T extends Record<string, SafeAny$1>, TCandidateKey extends keyof T = keyof T, TRequiredKey extends keyof T = RequiredKey<T>, TSelectedKey extends keyof T = never> = { [K in keyof Pick<T, Exclude<TCandidateKey, TSelectedKey>>]-?: ((val: K extends ComposeKey ? ComposeFn$1<T> : T[K]) => Builder<T, TCandidateKey, TRequiredKey, TSelectedKey | K>); } & Record<[TRequiredKey] extends [TSelectedKey] ? BuildKey : never, () => Pick<T, TSelectedKey>>; type StableBuilder<T> = Record<BuildKey, () => T>; /** * @template T 原型 * @template TRequiredKey 必填字段 * @template TSelectedKey 已选字段 */ type UnstableBuilder<T extends Record<string, SafeAny$1>, TSelectedKey extends keyof T, TRequiredKey extends keyof T = RequiredKey<T>> = Builder<T, keyof T, TRequiredKey, TSelectedKey>; type KindOrKey = 'kind' | 'key'; declare function row<Key extends SingleSchemaKey>(key?: Key): UnstableBuilder<RowComponentSchema<Key>, KindOrKey>; declare function headless<Key extends SingleSchemaKey>(key?: Key): UnstableBuilder<HeadlessControlSchema<Key>, KindOrKey>; type SafeAny = any; type ComposeFn = () => SafeAny; declare function form(composeFn: ComposeFn): Signal<AbstractFormGroupSchema>; declare function form(schemas: Indexable<AbstractSchema>[]): AbstractFormGroupSchema; declare class FluentFormModule { static ɵfac: i0.ɵɵFactoryDeclaration<FluentFormModule, never>; static ɵmod: i0.ɵɵNgModuleDeclaration<FluentFormModule, never, [typeof FluentForm, typeof FluentTemplate, typeof FluentNextWidgetWrapperOutlet], [typeof FluentForm, typeof FluentTemplate, typeof FluentNextWidgetWrapperOutlet]>; static ɵinj: i0.ɵɵInjectorDeclaration<FluentFormModule>; } declare class ClassPipe implements PipeTransform { transform(value: WithoutSchemaReactiveFn<AbstractSchema['class']>, type?: ElementType): ClassType; static ɵfac: i0.ɵɵFactoryDeclaration<ClassPipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<ClassPipe, "class", true>; } /** * @internal */ declare class FluentColumnPipe implements PipeTransform { transform<T extends keyof Column>(value: AbstractSchema['col'], type: T): Column[T]; static ɵfac: i0.ɵɵFactoryDeclaration<FluentColumnPipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<FluentColumnPipe, "col", true>; } /** * @internal */ declare class FluentControlPipe implements PipeTransform { /** * Use value as a key to get the instance from the form. * @param value * @param form * @param type Used to overload the method's return type. */ transform(value: SchemaKey | undefined, form: FormGroup | FormArray, type: 'control'): FormControl; transform(value: SchemaKey | undefined, form: FormGroup | FormArray, type: 'group'): FormGroup; transform(value: SchemaKey | undefined, form: FormGroup | FormArray, type: 'array'): FormArray; transform(value: SchemaKey | undefined, form: FormGroup | FormArray): AbstractControl; static ɵfac: i0.ɵɵFactoryDeclaration<FluentControlPipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<FluentControlPipe, "control", true>; } /** * @internal */ declare class FluentInjectPipe implements PipeTransform { private readonly injector; transform<T>(value: ProviderToken<T>, options?: InjectOptions): T | null; static ɵfac: i0.ɵɵFactoryDeclaration<FluentInjectPipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<FluentInjectPipe, "inject", true>; } /** * @internal */ declare class InvokePipe implements PipeTransform { transform<A extends unknown[], R>(value: (...args: A) => R, ...args: A): R; static ɵfac: i0.ɵɵFactoryDeclaration<InvokePipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<InvokePipe, "invoke", true>; } /** * @internal */ declare class FluentNewPipe implements PipeTransform { private readonly injector; transform<T>(clazz: Type<T>, ...args: SafeAny$1[]): T; static ɵfac: i0.ɵɵFactoryDeclaration<FluentNewPipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<FluentNewPipe, "new", true>; } /** * @internal */ declare class FluentReactivePipe implements PipeTransform { private readonly transformer; transform<T>(value: MaybeSchemaReactiveFn<SafeAny$1, T>, model: unknown, schema: AbstractSchema, control: AbstractControl): T; static ɵfac: i0.ɵɵFactoryDeclaration<FluentReactivePipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<FluentReactivePipe, "reactive", true>; } declare class RenderablePipe implements PipeTransform { transform(schema: AbstractSchema): boolean; static ɵfac: i0.ɵɵFactoryDeclaration<RenderablePipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<RenderablePipe, "renderable", true>; } /** * @internal */ declare class FluentSchemaTypePipe implements PipeTransform { private readonly schemaMap; transform(value: string): SchemaType; static ɵfac: i0.ɵɵFactoryDeclaration<FluentSchemaTypePipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<FluentSchemaTypePipe, "schemaType", true>; } /** * @internal */ declare class FluentSchemaPipe implements PipeTransform { private readonly schemaUtil; /** * Use value as a key to get the schema from schemas. * @param value * @param schemas * @param type Used to overload the method's return type */ transform(value: SingleSchemaKey | SchemaKey[], schema: Indexable<AbstractBranchSchema>, type: 'control'): AbstractControlSchema | null; transform(value: SingleSchemaKey | SchemaKey[], schema: Indexable<AbstractBranchSchema>, type: 'group'): AbstractControlContainerSchema | null; transform(value: SingleSchemaKey | SchemaKey[], schema: Indexable<AbstractBranchSchema>, type: 'array'): AbstractControlContainerSchema | null; transform(value: SingleSchemaKey | SchemaKey[], schema: Indexable<AbstractBranchSchema>): AbstractControlSchema | AbstractControlContainerSchema | null; static ɵfac: i0.ɵɵFactoryDeclaration<FluentSchemaPipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<FluentSchemaPipe, "schema", true>; } declare class StylePipe implements PipeTransform { transform(value: WithoutSchemaReactiveFn<AbstractSchema['style']>, type?: ElementType): StyleType; static ɵfac: i0.ɵɵFactoryDeclaration<StylePipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<StylePipe, "style", true>; } /** * @internal */ declare class FluentTemplatePipe implements PipeTransform { private readonly templates; transform<T>(value: T): T | TemplateRef<SafeAny$1>; transform<T, U>(value: T, defaultValue: U): NonNullable<T> | U | TemplateRef<SafeAny$1>; static ɵfac: i0.ɵɵFactoryDeclaration<FluentTemplatePipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<FluentTemplatePipe, "template", true>; } declare class FluentWidgetTemplatePipe implements PipeTransform { private readonly registry; private readonly templates; transform(value: Indexable<AbstractSchema>): Promise<TemplateRef<unknown>>; static ɵfac: i0.ɵɵFactoryDeclaration<FluentWidgetTemplatePipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<FluentWidgetTemplatePipe, "widgetTemplate", true>; } declare function provideFluentForm(...features: FluentFormFeature<FluentFormFeatureKind>[]): i0.EnvironmentProviders; declare const WIDGET_MAP: InjectionToken<Map<string, () => Promise<Type<AbstractWidget<unknown>>>>>; declare const SCHEMA_MAP: InjectionToken<Map<string, SchemaConfig<any>>>; declare const NAMED_TEMPLATES: InjectionToken<{ name: string; templateRef: TemplateRef<SafeAny$1>; }[]>; declare const FLUENT_FORM_CONTENT: InjectionToken<Type<AbstractFormContentComponent>>; declare const FLUENT_WIDGET_WRAPPERS: InjectionToken<Type<AbstractWidgetWrapper>[]>; declare class FormUtil { private readonly schemaUtil; private readonly valueUtil; private readonly valueTransformer; createFormControl(schema: AbstractControlSchema, model: AnyObject): FormControl; createFormGroup(schema: AbstractFormGroupSchema, model: AnyObject): FormGroup; createFormGroup(schemas: Indexable<AbstractSchema>[], model: AnyObject): FormGroup; createFormGroup(schemaOrSchemas: AbstractFormGroupSchema | Indexable<AbstractSchema>[], model: AnyObject): FormGroup; private createControlMap; createFormArray(schema: AbstractFormArraySchema, model: AnyArray): FormArray; createFormArrayElements(schemas: Indexable<AbstractSchema>[], model: AnyArray): AbstractControl<any, any, any>[]; createAnyControl(schema: AbstractControlSchema, model: AnyObject | AnyArray): AbstractControl; /** * Update the form state, currently includes: * - Updating validators * - Updating status - enabled / disabled * - Updating value * @param form * @param model * @param schemas */ updateForm(form: FormGroup, model: AnyObject, schemas: AbstractSchema[]): void; updateForm(form: FormArray, model: AnyArray, schemas: AbstractSchema[]): void; /** * Assign value from form to model * @param model * @param form * @param schemas */ updateModel(model: AnyObject, form: FormGroup, schemas: AbstractSchema[]): AnyObject; updateModel(model: AnyArray, form: FormArray, schemas: AbstractSchema[]): AnyArray; static ɵfac: i0.ɵɵFactoryDeclaration<FormUtil, never>; static ɵprov: i0.ɵɵInjectableDeclaration<FormUtil>; } /** * Automatically choose to use `.get()` or `.at()` to get a child control * based on the type of the form. * @param form * @param key * @returns */ declare function getChildControl(form: FormGroup | FormArray, key: SchemaKey): AbstractControl | null; declare const isObject: (o: unknown) => o is object; declare const isNumber: (o: unknown) => o is number; declare const isString: (o: unknown) => o is string; declare const isFunction: (o: unknown) => o is (...args: SafeAny$1) => SafeAny$1; declare const isBoolean: (o: unknown) => o is boolean; declare const isUndefined: (o: unknown) => o is undefined; declare const isArray: (o: unknown) => o is SafeAny$1[]; /** * @internal */ declare class ModelUtil { private readonly schemaUtil; private readonly valueUtil; private readonly formUtil; /** * 从 model 赋值到 form * @param form * @param model * @param schemas * @param completed */ updateForm(form: FormGroup, model: AnyObject, schemas: Indexable<AbstractSchema>[], completed?: boolean): FormGroup; updateForm(form: FormArray, model: AnyArray, schemas: Indexable<AbstractSchema>[], completed?: boolean): FormArray; static ɵfac: i0.ɵɵFactoryDeclaration<ModelUtil, never>; static ɵprov: i0.ɵɵInjectableDeclaration<ModelUtil>; } declare class SchemaUtil { private readonly schemaMap; private readonly schemaPatchers; patch<T extends Indexable<AbstractSchema>>(schema: T): T; /** * Filter out top-level control/control container schemas. */ filterControls(schemas: Indexable<AbstractSchema>[]): (AbstractControlContainerSchema<SingleSchemaKey> | AbstractControlSchema<SchemaKey, any>)[]; isControlGroup(schema: SchemaLike): schema is AbstractControlContainerSchema; isControlArray(schema: SchemaLike): schema is AbstractControlContainerSchema; isControlContainer(schema: SchemaLike): schema is AbstractControlContainerSchema; isControlWrapper(schema: SchemaLike): schema is AbstractControlWrapperSchema; isControl(schema: SchemaLike): schema is AbstractControlSchema; isComponentContainer(schema: SchemaLike): schema is AbstractComponentContainerSchema; isComponentWrapper(schema: SchemaLike): schema is AbstractComponentWrapperSchema; isComponent(schema: SchemaLike): schema is AbstractSchema; /** * Whether it is a multi-field schema. */ isMultiKeySchema(schema: SchemaLike): boolean; /** * Whether it is a path field schema. */ isPathKeySchema(schema: SchemaLike): boolean; /** * Non-control schema, indicating that it or its child nodes * do not contain any control schemas. */ isNonControl(schema: SchemaLike): schema is AbstractSchema; typeOf(schema: SchemaLike): SchemaType | undefined; validatorsOf(schema: AbstractControlSchema): ValidatorFn[]; parsePathKey(key: string): string[]; norimalizePaths(paths: SingleSchemaKey | SchemaKey[]): string[]; find(schema: Indexable<AbstractBranchSchema>, key: SingleSchemaKey): AbstractSchema | null; find(schema: Indexable<AbstractBranchSchema>, key: SchemaKey[]): AbstractSchema | null; find(schema: Indexable<AbstractBranchSchema>, paths: SingleSchemaKey | SchemaKey[]): AbstractSchema | null; static ɵfac: i0.ɵɵFactoryDeclaration<SchemaUtil, never>; static ɵprov: i0.ɵɵInjectableDeclaration<SchemaUtil>; } /** * @internal */ declare class ValueUtil { private readonly schemaUtil; valueOfModel<M extends AnyObject | AnyArray>(model: M, schema: AbstractControlSchema): unknown; valueOfControl(control: AbstractControl, schema: AbstractControlSchema): unknown; static ɵfac: i0.ɵɵFactoryDeclaration<ValueUtil, never>; static ɵprov: i0.ɵɵInjectableDeclaration<ValueUtil>; } export { AbstractFormContentComponent, AbstractWidget, AbstractWidgetWrapper, ClassPipe, FLUENT_FORM_CONTENT, FLUENT_WIDGET_WRAPPERS, FluentBindingDirective, FluentColDirective, FluentColumnPipe, FluentContextGuardDirective, FluentControlPipe, FluentControlWrapperDirective, FluentForm, FluentFormComponent, FluentFormDirective, FluentFormFeatureKind, FluentFormModule, FluentFormRenderModule, FluentGridModule, FluentInjectPipe, FluentNewPipe, FluentNextWidgetWrapper, FluentNextWidgetWrapperOutlet, FluentOutletDirective, FluentReactivePipe, FluentRowDirective, FluentSchemaPipe, FluentSchemaTypePipe, FluentTemplate, FluentTemplateDirective, FluentTemplateOutlet, FluentTemplatePipe, FluentWidgetTemplatePipe, FluentWidgetWrapperOutlet, FluentWithInjectorDirective, FormUtil, InvokePipe, ModelUtil, NAMED_TEMPLATES, RenderablePipe, SCHEMA_MAP, SCHEMA_PATCHERS, SchemaKind, SchemaType, SchemaUtil, StylePipe, TemplateRefHolder, ValueUtil, WIDGET_MAP, composeBuilder, form, getChildControl, getCurrentSchema, headless, isArray, isBoolean, isBuilder, isFunction, isNumber, isObject, isString, isUndefined, makeFluentFeature, provideFluentForm, provideSchemaPatcher, provideWidgetConfigs, row, useRowWidget, withPreloading, withSchemaPatchers, withStaticExpression }; export type { AbstractBranchSchema, AbstractComponentContainerSchema, AbstractComponentSchema, AbstractComponentWrapperSchema, AbstractControlContainerSchema, AbstractControlSchema, AbstractControlWrapperSchema, AbstractFormArraySchema, AbstractFormGroupSchema, AbstractHeadfulControlSchema, AbstractSchema, Builder, ClassType, Column, ComponentControlEventListenerHolder, ComponentControlEventObserverHolder, ComponentEventListenerHolder, ComponentEventObserverHolder, ComponentOutputMap, ComponentPropertyHolder, ComponentPropertyMap, ControlEventListenerHolder, ControlEventObserverHolder, ControlSchemaConfig, ControlValueMapper, ElementControlEventListenerHolder, ElementControlEventObserverHolder, ElementEventListenerHolder, ElementEventObserverHolder, ElementPropertyHolder, ElementType, EventListenerHolder, EventObserverHolder, FluentFormFeature, FluentFormWidgetConfig, FormContentTemplateContext, HTMLElementPropertyMap, HeadlessControlSchema, HooksHolder, Indexable, Length, ListenerContext, MaybeSchemaReactiveFn, MultiSchemaKey, PropertyHolder, Row, RowComponentSchema, SchemaConfig, SchemaContext, SchemaKey, SchemaLike, SchemaPatchFn, SchemaPatcher, SchemaReactiveFn, SchemaSelector, SingleSchemaKey, StableBuilder, Stringify, StyleType, UnstableBuilder, WidgetTemplateContext, WidgetWrapperContext, WidgetWrapperType, WithoutSchemaReactiveFn };