|
|
|
|
@ -45,12 +45,21 @@ export class FormProvider<TForm extends Form = Form> {
|
|
|
|
|
private constructor(opts: FormProviderOpts<TForm>) {
|
|
|
|
|
this.opts = opts;
|
|
|
|
|
this.soma = Soma.require();
|
|
|
|
|
this.runtime = this.soma.runtime(formMorfo, {});
|
|
|
|
|
this.runtime = this.soma.runtime(formMorfo, {
|
|
|
|
|
props: {
|
|
|
|
|
isPending: () => this.isPending,
|
|
|
|
|
dirty: () => this.isDirty,
|
|
|
|
|
touched: () => this.isTouched,
|
|
|
|
|
invalid: () => this.isInvalid && this.isSubmitted,
|
|
|
|
|
submitted: () => this.isSubmitted
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.runtimePart = this.runtime.part('provider', {
|
|
|
|
|
id: opts.id,
|
|
|
|
|
ref: opts.ref,
|
|
|
|
|
owner: this,
|
|
|
|
|
context: FormProvider.ctx
|
|
|
|
|
context: FormProvider.ctx,
|
|
|
|
|
syncAttrs: true
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -119,12 +128,6 @@ export class FormProvider<TForm extends Form = Form> {
|
|
|
|
|
this.runtimePart.assert({
|
|
|
|
|
...this.runtimePart.props,
|
|
|
|
|
novalidate: this.opts.noValidate.current || undefined,
|
|
|
|
|
'aria-busy': boolToStr(this.isPending),
|
|
|
|
|
'data-pending': boolToEmptyStrOrUndef(this.isPending),
|
|
|
|
|
'data-dirty': boolToEmptyStrOrUndef(this.isDirty),
|
|
|
|
|
'data-touched': boolToEmptyStrOrUndef(this.isTouched),
|
|
|
|
|
'data-invalid': boolToEmptyStrOrUndef(this.isInvalid && this.isSubmitted),
|
|
|
|
|
'data-submitted': boolToEmptyStrOrUndef(this.isSubmitted),
|
|
|
|
|
onsubmit: this.handleSubmit
|
|
|
|
|
} as const)
|
|
|
|
|
);
|
|
|
|
|
|