@orkestrel/form 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/src/browser/index.d.ts +726 -0
- package/dist/src/browser/index.js +916 -0
- package/dist/src/browser/index.js.map +1 -0
- package/dist/src/core/index.cjs +183 -17
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +95 -15
- package/dist/src/core/index.d.ts +95 -15
- package/dist/src/core/index.js +183 -17
- package/dist/src/core/index.js.map +1 -1
- package/package.json +27 -14
|
@@ -502,8 +502,10 @@ export declare class Form implements FormInterface {
|
|
|
502
502
|
get schema(): FormSchema;
|
|
503
503
|
/** Reports the answers the form holds. */
|
|
504
504
|
get values(): FormValues;
|
|
505
|
-
/** Holds the answers the
|
|
505
|
+
/** Holds the acknowledged answers, initially the schema's defaults overlaid with seeded values. */
|
|
506
506
|
get baseline(): FormValues;
|
|
507
|
+
/** Holds the submission awaiting acknowledgement, or `undefined` when none is pending. */
|
|
508
|
+
get pending(): FormSubmission | undefined;
|
|
507
509
|
/** Holds every error the last completed evaluation produced. */
|
|
508
510
|
get errors(): readonly FieldError[];
|
|
509
511
|
/** Lists the names of the fields somebody has visited. */
|
|
@@ -514,7 +516,7 @@ export declare class Form implements FormInterface {
|
|
|
514
516
|
get status(): FormStatus;
|
|
515
517
|
/** Reports whether the last completed evaluation found no error. */
|
|
516
518
|
get valid(): boolean;
|
|
517
|
-
/** Reports whether any answer
|
|
519
|
+
/** Reports whether any answer differs from its acknowledged baseline. */
|
|
518
520
|
get dirty(): boolean;
|
|
519
521
|
/**
|
|
520
522
|
* Holds the answers after the form settles.
|
|
@@ -557,13 +559,15 @@ export declare class Form implements FormInterface {
|
|
|
557
559
|
*
|
|
558
560
|
* @param name - The field's name.
|
|
559
561
|
* @param message - What to tell the person.
|
|
562
|
+
* @param submission - The active receipt to check against the field's captured revision.
|
|
563
|
+
* @returns True if the failure was applied; false if the receipt or field revision is stale.
|
|
560
564
|
* @remarks
|
|
561
565
|
* One field holds one external failure: a second call replaces the first. The failure lasts
|
|
562
566
|
* until that field is filled again or the form is cleared.
|
|
563
567
|
* @throws A {@link FormError} coded `SETTLED` or `ABANDONED` when the form has ended, and
|
|
564
568
|
* `FIELD` when the schema declares no such name.
|
|
565
569
|
*/
|
|
566
|
-
invalidate(name: string, message: string):
|
|
570
|
+
invalidate(name: string, message: string, submission?: FormSubmission): boolean;
|
|
567
571
|
/** Takes every field out of the form. */
|
|
568
572
|
disable(): void;
|
|
569
573
|
/**
|
|
@@ -610,8 +614,34 @@ export declare class Form implements FormInterface {
|
|
|
610
614
|
*/
|
|
611
615
|
submit(): FormResult;
|
|
612
616
|
/**
|
|
613
|
-
*
|
|
614
|
-
*
|
|
617
|
+
* Prepares an owned enabled snapshot for acknowledgement while leaving the form editable.
|
|
618
|
+
*
|
|
619
|
+
* @returns The submission on success, or the errors that prevented preparation.
|
|
620
|
+
* @remarks
|
|
621
|
+
* A failed check refuses its checked errors even if an observer repairs them. A passing check
|
|
622
|
+
* drains observer mutations through one further check. The receipt always carries that check's
|
|
623
|
+
* snapshot, including when its notifications produce later edits. A throwing validator creates
|
|
624
|
+
* no receipt. The pending identity is installed before `prepare` listeners run.
|
|
625
|
+
* @throws A {@link FormError} coded `PENDING` while another preparation or receipt is pending,
|
|
626
|
+
* or when clear interrupts preparation; terminal forms retain their terminal refusals.
|
|
627
|
+
*/
|
|
628
|
+
prepare(): FormPreparationResult;
|
|
629
|
+
/**
|
|
630
|
+
* Adopts the active submission's captured answers into the baseline without changing live state.
|
|
631
|
+
*
|
|
632
|
+
* @param submission - The receipt returned by preparation.
|
|
633
|
+
* @returns True if this active receipt was accepted; false otherwise, including after teardown.
|
|
634
|
+
*/
|
|
635
|
+
accept(submission: FormSubmission): boolean;
|
|
636
|
+
/**
|
|
637
|
+
* Consumes the active submission and aborts its signal without changing answers or baseline.
|
|
638
|
+
*
|
|
639
|
+
* @param submission - The receipt returned by preparation.
|
|
640
|
+
* @returns True if this active receipt was aborted; false otherwise, including after teardown.
|
|
641
|
+
*/
|
|
642
|
+
abort(submission: FormSubmission): boolean;
|
|
643
|
+
/**
|
|
644
|
+
* Returns every answer to its acknowledged baseline and aborts pending acknowledgement.
|
|
615
645
|
*
|
|
616
646
|
* @throws A {@link FormError} coded `SETTLED` or `ABANDONED` when the form has ended.
|
|
617
647
|
*/
|
|
@@ -679,9 +709,10 @@ export declare class FormError extends Error {
|
|
|
679
709
|
* @remarks
|
|
680
710
|
* `SCHEMA` rejects a malformed schema. `FIELD` names a field the schema does not declare.
|
|
681
711
|
* `CONTROL` reports a value the field's control cannot hold. `SETTLED` and `ABANDONED`
|
|
682
|
-
* refuse a write to a form that has already ended.
|
|
712
|
+
* refuse a write to a form that has already ended. `PENDING` refuses a preparation or terminal
|
|
713
|
+
* submit while preparation or acknowledgement is pending, or a preparation interrupted by clear.
|
|
683
714
|
*/
|
|
684
|
-
export declare type FormErrorCode = 'SCHEMA' | 'FIELD' | 'CONTROL' | 'SETTLED' | 'ABANDONED';
|
|
715
|
+
export declare type FormErrorCode = 'SCHEMA' | 'FIELD' | 'CONTROL' | 'SETTLED' | 'ABANDONED' | 'PENDING';
|
|
685
716
|
|
|
686
717
|
/**
|
|
687
718
|
* Lists everything a form announces.
|
|
@@ -691,14 +722,19 @@ export declare type FormErrorCode = 'SCHEMA' | 'FIELD' | 'CONTROL' | 'SETTLED' |
|
|
|
691
722
|
* being cleared. `validate` carries the errors a check produced, empty when it found none.
|
|
692
723
|
* `disable` and `enable` each carry one field, and fire once per field whose state actually
|
|
693
724
|
* moved, in the order the schema declares them. `submit` fires only on a submit that passed.
|
|
694
|
-
* `clear` and `
|
|
725
|
+
* `touch` announces the first visit since clear. `prepare`, `accept`, and `abort` carry the receipt
|
|
726
|
+
* after their state is committed. `clear` and `abandon` are signals.
|
|
695
727
|
*/
|
|
696
728
|
export declare type FormEventMap = {
|
|
697
729
|
readonly fill: readonly [name: string, value: FieldValue | undefined];
|
|
730
|
+
readonly touch: readonly [name: string];
|
|
698
731
|
readonly validate: readonly [errors: readonly FieldError[]];
|
|
699
732
|
readonly disable: readonly [name: string];
|
|
700
733
|
readonly enable: readonly [name: string];
|
|
701
734
|
readonly submit: readonly [values: FormValues];
|
|
735
|
+
readonly prepare: readonly [submission: FormSubmission];
|
|
736
|
+
readonly accept: readonly [submission: FormSubmission];
|
|
737
|
+
readonly abort: readonly [submission: FormSubmission];
|
|
702
738
|
readonly clear: readonly [];
|
|
703
739
|
readonly abandon: readonly [];
|
|
704
740
|
};
|
|
@@ -737,7 +773,7 @@ export declare interface FormGroup {
|
|
|
737
773
|
*
|
|
738
774
|
* @remarks
|
|
739
775
|
* `valid` is true when the last completed evaluation found no error, and `dirty` is true once
|
|
740
|
-
* an answer differs from
|
|
776
|
+
* an answer differs from its acknowledged baseline. Both are derived, never stored.
|
|
741
777
|
*
|
|
742
778
|
* `touched` holds the fields somebody has visited, which is what lets a renderer withhold an
|
|
743
779
|
* error until the person has had their turn at it.
|
|
@@ -757,13 +793,15 @@ export declare interface FormInterface {
|
|
|
757
793
|
/** Reports the answers the form holds. */
|
|
758
794
|
readonly values: FormValues;
|
|
759
795
|
/**
|
|
760
|
-
* Holds the answers
|
|
796
|
+
* Holds the acknowledged answers, initially the schema's defaults overlaid with seeded values.
|
|
761
797
|
*
|
|
762
798
|
* @remarks
|
|
763
|
-
*
|
|
764
|
-
* against and what {@link FormInterface.clear} returns to.
|
|
799
|
+
* Acceptance advances only the enabled fields captured by the submission, including absence.
|
|
800
|
+
* It is what `dirty` measures against and what {@link FormInterface.clear} returns to.
|
|
765
801
|
*/
|
|
766
802
|
readonly baseline: FormValues;
|
|
803
|
+
/** Holds the submission awaiting acknowledgement, or `undefined` when none is pending. */
|
|
804
|
+
readonly pending: FormSubmission | undefined;
|
|
767
805
|
/** Holds every error the last check produced. */
|
|
768
806
|
readonly errors: readonly FieldError[];
|
|
769
807
|
/** Lists the names of the fields somebody has visited. */
|
|
@@ -781,7 +819,7 @@ export declare interface FormInterface {
|
|
|
781
819
|
readonly status: FormStatus;
|
|
782
820
|
/** Reports whether the last completed evaluation found no error. */
|
|
783
821
|
readonly valid: boolean;
|
|
784
|
-
/** Reports whether any answer
|
|
822
|
+
/** Reports whether any answer differs from its acknowledged baseline. */
|
|
785
823
|
readonly dirty: boolean;
|
|
786
824
|
/**
|
|
787
825
|
* Holds the answers after the form settles.
|
|
@@ -823,11 +861,16 @@ export declare interface FormInterface {
|
|
|
823
861
|
* @remarks
|
|
824
862
|
* One field holds one external failure, so a second call replaces the first, and the failure
|
|
825
863
|
* lasts until that field is filled again or the form is cleared.
|
|
864
|
+
* A receipt admits only a captured enabled field whose fill revision still matches. Stale,
|
|
865
|
+
* foreign, copied, consumed, and teardown-invalidated receipts return `false`; unknown fields
|
|
866
|
+
* still throw `FIELD`.
|
|
826
867
|
*
|
|
827
868
|
* @param name - The field's name.
|
|
828
869
|
* @param message - What to tell the person.
|
|
870
|
+
* @param submission - The active receipt to check against the field's captured revision.
|
|
871
|
+
* @returns True if the failure was applied; false if the receipt or field revision is stale.
|
|
829
872
|
*/
|
|
830
|
-
invalidate(name: string, message: string):
|
|
873
|
+
invalidate(name: string, message: string, submission?: FormSubmission): boolean;
|
|
831
874
|
/**
|
|
832
875
|
* Takes one field, several fields, or every field out of the form.
|
|
833
876
|
*
|
|
@@ -885,7 +928,29 @@ export declare interface FormInterface {
|
|
|
885
928
|
*/
|
|
886
929
|
submit(): FormResult;
|
|
887
930
|
/**
|
|
888
|
-
*
|
|
931
|
+
* Prepares an owned enabled snapshot for acknowledgement while leaving the form editable.
|
|
932
|
+
*
|
|
933
|
+
* @returns The submission on success, or the errors that prevented preparation.
|
|
934
|
+
* @throws A {@link FormError} coded `PENDING` for an overlapping preparation or pending receipt,
|
|
935
|
+
* or when clear interrupts preparation; terminal forms retain their terminal refusals.
|
|
936
|
+
*/
|
|
937
|
+
prepare(): FormPreparationResult;
|
|
938
|
+
/**
|
|
939
|
+
* Adopts the active submission's captured answers into the baseline without changing live state.
|
|
940
|
+
*
|
|
941
|
+
* @param submission - The receipt returned by preparation.
|
|
942
|
+
* @returns True if this active receipt was accepted; false otherwise, including after teardown.
|
|
943
|
+
*/
|
|
944
|
+
accept(submission: FormSubmission): boolean;
|
|
945
|
+
/**
|
|
946
|
+
* Consumes the active submission and aborts its signal without changing answers or baseline.
|
|
947
|
+
*
|
|
948
|
+
* @param submission - The receipt returned by preparation.
|
|
949
|
+
* @returns True if this active receipt was aborted; false otherwise, including after teardown.
|
|
950
|
+
*/
|
|
951
|
+
abort(submission: FormSubmission): boolean;
|
|
952
|
+
/**
|
|
953
|
+
* Returns every answer to its acknowledged baseline and aborts pending acknowledgement.
|
|
889
954
|
*
|
|
890
955
|
* @remarks
|
|
891
956
|
* Those answers are {@link FormInterface.baseline}. The runtime disabled overlay resets with
|
|
@@ -927,6 +992,9 @@ export declare interface FormOptions {
|
|
|
927
992
|
readonly messages?: Readonly<Partial<Record<FieldRuleName, string>>>;
|
|
928
993
|
}
|
|
929
994
|
|
|
995
|
+
/** Reports a prepared submission, or every error that prevented its preparation. */
|
|
996
|
+
export declare type FormPreparationResult = Result<FormSubmission, readonly FieldError[]>;
|
|
997
|
+
|
|
930
998
|
/**
|
|
931
999
|
* Reports what a submit answers with: the values, or every error that stopped them.
|
|
932
1000
|
*
|
|
@@ -978,6 +1046,18 @@ export declare interface FormSchema {
|
|
|
978
1046
|
*/
|
|
979
1047
|
export declare type FormStatus = 'editing' | 'settled' | 'abandoned';
|
|
980
1048
|
|
|
1049
|
+
/**
|
|
1050
|
+
* Carries an owned, frozen answer snapshot and the signal for its pending acknowledgement.
|
|
1051
|
+
*
|
|
1052
|
+
* @remarks
|
|
1053
|
+
* Only the producing form accepts this object's identity. Copying its members cannot create a
|
|
1054
|
+
* receipt. The values and their lists are frozen; the native signal remains usable by transports.
|
|
1055
|
+
*/
|
|
1056
|
+
export declare interface FormSubmission {
|
|
1057
|
+
readonly values: FormValues;
|
|
1058
|
+
readonly signal: AbortSignal;
|
|
1059
|
+
}
|
|
1060
|
+
|
|
981
1061
|
/**
|
|
982
1062
|
* Represents a form's answers, keyed by field name.
|
|
983
1063
|
*
|
package/dist/src/core/index.d.ts
CHANGED
|
@@ -502,8 +502,10 @@ export declare class Form implements FormInterface {
|
|
|
502
502
|
get schema(): FormSchema;
|
|
503
503
|
/** Reports the answers the form holds. */
|
|
504
504
|
get values(): FormValues;
|
|
505
|
-
/** Holds the answers the
|
|
505
|
+
/** Holds the acknowledged answers, initially the schema's defaults overlaid with seeded values. */
|
|
506
506
|
get baseline(): FormValues;
|
|
507
|
+
/** Holds the submission awaiting acknowledgement, or `undefined` when none is pending. */
|
|
508
|
+
get pending(): FormSubmission | undefined;
|
|
507
509
|
/** Holds every error the last completed evaluation produced. */
|
|
508
510
|
get errors(): readonly FieldError[];
|
|
509
511
|
/** Lists the names of the fields somebody has visited. */
|
|
@@ -514,7 +516,7 @@ export declare class Form implements FormInterface {
|
|
|
514
516
|
get status(): FormStatus;
|
|
515
517
|
/** Reports whether the last completed evaluation found no error. */
|
|
516
518
|
get valid(): boolean;
|
|
517
|
-
/** Reports whether any answer
|
|
519
|
+
/** Reports whether any answer differs from its acknowledged baseline. */
|
|
518
520
|
get dirty(): boolean;
|
|
519
521
|
/**
|
|
520
522
|
* Holds the answers after the form settles.
|
|
@@ -557,13 +559,15 @@ export declare class Form implements FormInterface {
|
|
|
557
559
|
*
|
|
558
560
|
* @param name - The field's name.
|
|
559
561
|
* @param message - What to tell the person.
|
|
562
|
+
* @param submission - The active receipt to check against the field's captured revision.
|
|
563
|
+
* @returns True if the failure was applied; false if the receipt or field revision is stale.
|
|
560
564
|
* @remarks
|
|
561
565
|
* One field holds one external failure: a second call replaces the first. The failure lasts
|
|
562
566
|
* until that field is filled again or the form is cleared.
|
|
563
567
|
* @throws A {@link FormError} coded `SETTLED` or `ABANDONED` when the form has ended, and
|
|
564
568
|
* `FIELD` when the schema declares no such name.
|
|
565
569
|
*/
|
|
566
|
-
invalidate(name: string, message: string):
|
|
570
|
+
invalidate(name: string, message: string, submission?: FormSubmission): boolean;
|
|
567
571
|
/** Takes every field out of the form. */
|
|
568
572
|
disable(): void;
|
|
569
573
|
/**
|
|
@@ -610,8 +614,34 @@ export declare class Form implements FormInterface {
|
|
|
610
614
|
*/
|
|
611
615
|
submit(): FormResult;
|
|
612
616
|
/**
|
|
613
|
-
*
|
|
614
|
-
*
|
|
617
|
+
* Prepares an owned enabled snapshot for acknowledgement while leaving the form editable.
|
|
618
|
+
*
|
|
619
|
+
* @returns The submission on success, or the errors that prevented preparation.
|
|
620
|
+
* @remarks
|
|
621
|
+
* A failed check refuses its checked errors even if an observer repairs them. A passing check
|
|
622
|
+
* drains observer mutations through one further check. The receipt always carries that check's
|
|
623
|
+
* snapshot, including when its notifications produce later edits. A throwing validator creates
|
|
624
|
+
* no receipt. The pending identity is installed before `prepare` listeners run.
|
|
625
|
+
* @throws A {@link FormError} coded `PENDING` while another preparation or receipt is pending,
|
|
626
|
+
* or when clear interrupts preparation; terminal forms retain their terminal refusals.
|
|
627
|
+
*/
|
|
628
|
+
prepare(): FormPreparationResult;
|
|
629
|
+
/**
|
|
630
|
+
* Adopts the active submission's captured answers into the baseline without changing live state.
|
|
631
|
+
*
|
|
632
|
+
* @param submission - The receipt returned by preparation.
|
|
633
|
+
* @returns True if this active receipt was accepted; false otherwise, including after teardown.
|
|
634
|
+
*/
|
|
635
|
+
accept(submission: FormSubmission): boolean;
|
|
636
|
+
/**
|
|
637
|
+
* Consumes the active submission and aborts its signal without changing answers or baseline.
|
|
638
|
+
*
|
|
639
|
+
* @param submission - The receipt returned by preparation.
|
|
640
|
+
* @returns True if this active receipt was aborted; false otherwise, including after teardown.
|
|
641
|
+
*/
|
|
642
|
+
abort(submission: FormSubmission): boolean;
|
|
643
|
+
/**
|
|
644
|
+
* Returns every answer to its acknowledged baseline and aborts pending acknowledgement.
|
|
615
645
|
*
|
|
616
646
|
* @throws A {@link FormError} coded `SETTLED` or `ABANDONED` when the form has ended.
|
|
617
647
|
*/
|
|
@@ -679,9 +709,10 @@ export declare class FormError extends Error {
|
|
|
679
709
|
* @remarks
|
|
680
710
|
* `SCHEMA` rejects a malformed schema. `FIELD` names a field the schema does not declare.
|
|
681
711
|
* `CONTROL` reports a value the field's control cannot hold. `SETTLED` and `ABANDONED`
|
|
682
|
-
* refuse a write to a form that has already ended.
|
|
712
|
+
* refuse a write to a form that has already ended. `PENDING` refuses a preparation or terminal
|
|
713
|
+
* submit while preparation or acknowledgement is pending, or a preparation interrupted by clear.
|
|
683
714
|
*/
|
|
684
|
-
export declare type FormErrorCode = 'SCHEMA' | 'FIELD' | 'CONTROL' | 'SETTLED' | 'ABANDONED';
|
|
715
|
+
export declare type FormErrorCode = 'SCHEMA' | 'FIELD' | 'CONTROL' | 'SETTLED' | 'ABANDONED' | 'PENDING';
|
|
685
716
|
|
|
686
717
|
/**
|
|
687
718
|
* Lists everything a form announces.
|
|
@@ -691,14 +722,19 @@ export declare type FormErrorCode = 'SCHEMA' | 'FIELD' | 'CONTROL' | 'SETTLED' |
|
|
|
691
722
|
* being cleared. `validate` carries the errors a check produced, empty when it found none.
|
|
692
723
|
* `disable` and `enable` each carry one field, and fire once per field whose state actually
|
|
693
724
|
* moved, in the order the schema declares them. `submit` fires only on a submit that passed.
|
|
694
|
-
* `clear` and `
|
|
725
|
+
* `touch` announces the first visit since clear. `prepare`, `accept`, and `abort` carry the receipt
|
|
726
|
+
* after their state is committed. `clear` and `abandon` are signals.
|
|
695
727
|
*/
|
|
696
728
|
export declare type FormEventMap = {
|
|
697
729
|
readonly fill: readonly [name: string, value: FieldValue | undefined];
|
|
730
|
+
readonly touch: readonly [name: string];
|
|
698
731
|
readonly validate: readonly [errors: readonly FieldError[]];
|
|
699
732
|
readonly disable: readonly [name: string];
|
|
700
733
|
readonly enable: readonly [name: string];
|
|
701
734
|
readonly submit: readonly [values: FormValues];
|
|
735
|
+
readonly prepare: readonly [submission: FormSubmission];
|
|
736
|
+
readonly accept: readonly [submission: FormSubmission];
|
|
737
|
+
readonly abort: readonly [submission: FormSubmission];
|
|
702
738
|
readonly clear: readonly [];
|
|
703
739
|
readonly abandon: readonly [];
|
|
704
740
|
};
|
|
@@ -737,7 +773,7 @@ export declare interface FormGroup {
|
|
|
737
773
|
*
|
|
738
774
|
* @remarks
|
|
739
775
|
* `valid` is true when the last completed evaluation found no error, and `dirty` is true once
|
|
740
|
-
* an answer differs from
|
|
776
|
+
* an answer differs from its acknowledged baseline. Both are derived, never stored.
|
|
741
777
|
*
|
|
742
778
|
* `touched` holds the fields somebody has visited, which is what lets a renderer withhold an
|
|
743
779
|
* error until the person has had their turn at it.
|
|
@@ -757,13 +793,15 @@ export declare interface FormInterface {
|
|
|
757
793
|
/** Reports the answers the form holds. */
|
|
758
794
|
readonly values: FormValues;
|
|
759
795
|
/**
|
|
760
|
-
* Holds the answers
|
|
796
|
+
* Holds the acknowledged answers, initially the schema's defaults overlaid with seeded values.
|
|
761
797
|
*
|
|
762
798
|
* @remarks
|
|
763
|
-
*
|
|
764
|
-
* against and what {@link FormInterface.clear} returns to.
|
|
799
|
+
* Acceptance advances only the enabled fields captured by the submission, including absence.
|
|
800
|
+
* It is what `dirty` measures against and what {@link FormInterface.clear} returns to.
|
|
765
801
|
*/
|
|
766
802
|
readonly baseline: FormValues;
|
|
803
|
+
/** Holds the submission awaiting acknowledgement, or `undefined` when none is pending. */
|
|
804
|
+
readonly pending: FormSubmission | undefined;
|
|
767
805
|
/** Holds every error the last check produced. */
|
|
768
806
|
readonly errors: readonly FieldError[];
|
|
769
807
|
/** Lists the names of the fields somebody has visited. */
|
|
@@ -781,7 +819,7 @@ export declare interface FormInterface {
|
|
|
781
819
|
readonly status: FormStatus;
|
|
782
820
|
/** Reports whether the last completed evaluation found no error. */
|
|
783
821
|
readonly valid: boolean;
|
|
784
|
-
/** Reports whether any answer
|
|
822
|
+
/** Reports whether any answer differs from its acknowledged baseline. */
|
|
785
823
|
readonly dirty: boolean;
|
|
786
824
|
/**
|
|
787
825
|
* Holds the answers after the form settles.
|
|
@@ -823,11 +861,16 @@ export declare interface FormInterface {
|
|
|
823
861
|
* @remarks
|
|
824
862
|
* One field holds one external failure, so a second call replaces the first, and the failure
|
|
825
863
|
* lasts until that field is filled again or the form is cleared.
|
|
864
|
+
* A receipt admits only a captured enabled field whose fill revision still matches. Stale,
|
|
865
|
+
* foreign, copied, consumed, and teardown-invalidated receipts return `false`; unknown fields
|
|
866
|
+
* still throw `FIELD`.
|
|
826
867
|
*
|
|
827
868
|
* @param name - The field's name.
|
|
828
869
|
* @param message - What to tell the person.
|
|
870
|
+
* @param submission - The active receipt to check against the field's captured revision.
|
|
871
|
+
* @returns True if the failure was applied; false if the receipt or field revision is stale.
|
|
829
872
|
*/
|
|
830
|
-
invalidate(name: string, message: string):
|
|
873
|
+
invalidate(name: string, message: string, submission?: FormSubmission): boolean;
|
|
831
874
|
/**
|
|
832
875
|
* Takes one field, several fields, or every field out of the form.
|
|
833
876
|
*
|
|
@@ -885,7 +928,29 @@ export declare interface FormInterface {
|
|
|
885
928
|
*/
|
|
886
929
|
submit(): FormResult;
|
|
887
930
|
/**
|
|
888
|
-
*
|
|
931
|
+
* Prepares an owned enabled snapshot for acknowledgement while leaving the form editable.
|
|
932
|
+
*
|
|
933
|
+
* @returns The submission on success, or the errors that prevented preparation.
|
|
934
|
+
* @throws A {@link FormError} coded `PENDING` for an overlapping preparation or pending receipt,
|
|
935
|
+
* or when clear interrupts preparation; terminal forms retain their terminal refusals.
|
|
936
|
+
*/
|
|
937
|
+
prepare(): FormPreparationResult;
|
|
938
|
+
/**
|
|
939
|
+
* Adopts the active submission's captured answers into the baseline without changing live state.
|
|
940
|
+
*
|
|
941
|
+
* @param submission - The receipt returned by preparation.
|
|
942
|
+
* @returns True if this active receipt was accepted; false otherwise, including after teardown.
|
|
943
|
+
*/
|
|
944
|
+
accept(submission: FormSubmission): boolean;
|
|
945
|
+
/**
|
|
946
|
+
* Consumes the active submission and aborts its signal without changing answers or baseline.
|
|
947
|
+
*
|
|
948
|
+
* @param submission - The receipt returned by preparation.
|
|
949
|
+
* @returns True if this active receipt was aborted; false otherwise, including after teardown.
|
|
950
|
+
*/
|
|
951
|
+
abort(submission: FormSubmission): boolean;
|
|
952
|
+
/**
|
|
953
|
+
* Returns every answer to its acknowledged baseline and aborts pending acknowledgement.
|
|
889
954
|
*
|
|
890
955
|
* @remarks
|
|
891
956
|
* Those answers are {@link FormInterface.baseline}. The runtime disabled overlay resets with
|
|
@@ -927,6 +992,9 @@ export declare interface FormOptions {
|
|
|
927
992
|
readonly messages?: Readonly<Partial<Record<FieldRuleName, string>>>;
|
|
928
993
|
}
|
|
929
994
|
|
|
995
|
+
/** Reports a prepared submission, or every error that prevented its preparation. */
|
|
996
|
+
export declare type FormPreparationResult = Result<FormSubmission, readonly FieldError[]>;
|
|
997
|
+
|
|
930
998
|
/**
|
|
931
999
|
* Reports what a submit answers with: the values, or every error that stopped them.
|
|
932
1000
|
*
|
|
@@ -978,6 +1046,18 @@ export declare interface FormSchema {
|
|
|
978
1046
|
*/
|
|
979
1047
|
export declare type FormStatus = 'editing' | 'settled' | 'abandoned';
|
|
980
1048
|
|
|
1049
|
+
/**
|
|
1050
|
+
* Carries an owned, frozen answer snapshot and the signal for its pending acknowledgement.
|
|
1051
|
+
*
|
|
1052
|
+
* @remarks
|
|
1053
|
+
* Only the producing form accepts this object's identity. Copying its members cannot create a
|
|
1054
|
+
* receipt. The values and their lists are frozen; the native signal remains usable by transports.
|
|
1055
|
+
*/
|
|
1056
|
+
export declare interface FormSubmission {
|
|
1057
|
+
readonly values: FormValues;
|
|
1058
|
+
readonly signal: AbortSignal;
|
|
1059
|
+
}
|
|
1060
|
+
|
|
981
1061
|
/**
|
|
982
1062
|
* Represents a form's answers, keyed by field name.
|
|
983
1063
|
*
|