Class Form<TModel, TElt, TSharer>

User input form.

A component shares form (e.g. using @SharedForm decorator) to make its accessible by component itself and nested ones. E.g. to add fields to it or submit it.

A form may be nested within another one, as it implements a Field interface.

The form instance is not usable until it is bound to its sharer component. The latter is done automatically when the form is shared by FormShare.

Type Parameters

  • TModel = any

    A model type of the form, i.e. a type of its control value.

  • TElt extends HTMLElement = HTMLElement

    A type of HTML form element.

  • TSharer extends object = any

    Form sharer component type.

Hierarchy

Constructors

Accessors

  • get body(): TBody
  • Shareable body.

    Accessing is throws an exception until bound to sharer.

    Returns TBody

  • get control(): undefined | InControl<TValue>
  • Input control of the field, if present.

    Returns undefined | InControl<TValue>

  • get element(): undefined | InFormElement<TElt>
  • Form element control, if present.

    Unlike input control this one is not supposed to be submitted, but rather contains a <form> element issuing a submit event.

    Returns undefined | InFormElement<TElt>

  • get read(): AfterEvent<[TBody]>
  • An AfterEvent keeper of shareable body.

    An [AfterEvent__symbol] method always returns this value.

    Returns AfterEvent<[TBody]>

  • get sharer(): ComponentContext<TSharer>
  • Sharer component context.

    Accessing it throws an exception until bound to sharer.

    Returns ComponentContext<TSharer>

Methods

  • Returns AfterEvent<[undefined | Form.Body<TModel, TElt, any>]>

  • Creates a form instance by the given control factories.

    Returns

    New form instance.

    Type Parameters

    • TModel

    • TElt extends HTMLElement<TElt> = HTMLElement

    • TSharer extends object = any

    Parameters

    • factory: Factory<InControl<TModel>, TModel>

      Submittable form control factory.

    • elementFactory: ((this: void, options: {
          aspects?: Aspect<void, void>;
      } & {
          form: InControl<TModel>;
      }) => InFormElement<TElt>)

      Form element control factory or options.

        • (this: void, options: {
              aspects?: Aspect<void, void>;
          } & {
              form: InControl<TModel>;
          }): InFormElement<TElt>
        • Parameters

          • this: void
          • options: {
                aspects?: Aspect<void, void>;
            } & {
                form: InControl<TModel>;
            }

          Returns InFormElement<TElt>

    Returns Form<TModel, TElt, TSharer>

  • Builds a user input form for the given form control and HTML element.

    Returns

    New form instance.

    Type Parameters

    • TModel

    • TElt extends HTMLElement<TElt>

    Parameters

    • control: InControl<TModel>

      Submitted control. Typically a container one.

    • element: TElt

      HTML element to create control for.

    • Optional options: Omit<Options, "form">

      Form element control options.

    Returns Form.Controls<TModel, TElt>

  • Converts shareable body or its provider to provider that always returns an AfterEvent keeper of shareable body.

    Returns

    Shareable body provider.

    Type Parameters

    • TBody = unknown

      Shareable body type.

    • TSharer extends object = any

      Sharer component type.

    Parameters

    • body: TBody | Provider<TBody, TSharer>

      Either shareable body, or its provider.

    Returns ((this: void, sharer: ComponentContext<TSharer>) => AfterEvent<[TBody]>)

      • (this: void, sharer: ComponentContext<TSharer>): AfterEvent<[TBody]>
      • Converts shareable body or its provider to provider that always returns an AfterEvent keeper of shareable body.

        Returns

        Shareable body provider.

        Parameters

        • this: void
        • sharer: ComponentContext<TSharer>

        Returns AfterEvent<[TBody]>

  • Creates a form controls provider by the given control factories.

    Returns

    New form controls provider.

    Type Parameters

    • TModel

    • TElt extends HTMLElement<TElt> = HTMLElement

    • TSharer extends object = any

    Parameters

    • factory: Factory<InControl<TModel>, TModel>

      Submittable form control factory.

    • elementFactory: ((this: void, options: {
          aspects?: Aspect<void, void>;
      } & {
          form: InControl<TModel>;
      }) => InFormElement<TElt>)

      Form element control factory or options.

        • (this: void, options: {
              aspects?: Aspect<void, void>;
          } & {
              form: InControl<TModel>;
          }): InFormElement<TElt>
        • Parameters

          • this: void
          • options: {
                aspects?: Aspect<void, void>;
            } & {
                form: InControl<TModel>;
            }

          Returns InFormElement<TElt>

    Returns Form.Provider<TModel, TElt, TSharer>

Generated using TypeDoc