@flowgram.ai/form 0.2.16 → 0.2.18

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/dist/index.d.mts CHANGED
@@ -4,8 +4,17 @@ import * as _flowgram_ai_utils from '@flowgram.ai/utils';
4
4
  import { MaybePromise, Disposable, Emitter, DisposableCollection } from '@flowgram.ai/utils';
5
5
  import { ReactiveState } from '@flowgram.ai/reactive';
6
6
 
7
+ /**
8
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
9
+ * SPDX-License-Identifier: MIT
10
+ */
7
11
  type Context = any;
8
12
 
13
+ /**
14
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
15
+ * SPDX-License-Identifier: MIT
16
+ */
17
+
9
18
  declare enum FeedbackLevel {
10
19
  Error = "error",
11
20
  Warning = "warning"
@@ -58,6 +67,10 @@ declare enum ValidateTrigger {
58
67
  }
59
68
  type FormValidateReturn = (FieldError | FieldWarning)[];
60
69
 
70
+ /**
71
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
72
+ * SPDX-License-Identifier: MIT
73
+ */
61
74
  declare class Path {
62
75
  protected _path: string[];
63
76
  constructor(path: string | string[]);
@@ -82,6 +95,11 @@ declare class Path {
82
95
  replaceParent(parent: Path, newParent: Path): Path;
83
96
  }
84
97
 
98
+ /**
99
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
100
+ * SPDX-License-Identifier: MIT
101
+ */
102
+
85
103
  declare class Store<TValues = FieldValue> {
86
104
  protected _values: TValues;
87
105
  get values(): TValues;
@@ -252,6 +270,11 @@ declare class FormModel<TValues = any> implements Disposable {
252
270
  dispose(): void;
253
271
  }
254
272
 
273
+ /**
274
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
275
+ * SPDX-License-Identifier: MIT
276
+ */
277
+
255
278
  interface FormState {
256
279
  /**
257
280
  * If the form data is valid
@@ -367,6 +390,11 @@ interface OnFormValuesUpdatedPayload {
367
390
  options?: OnFormValuesChangeOptions;
368
391
  }
369
392
 
393
+ /**
394
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
395
+ * SPDX-License-Identifier: MIT
396
+ */
397
+
370
398
  type FieldValue = any;
371
399
  type FieldName = string;
372
400
  type CustomElement = Partial<HTMLElement> & {
@@ -527,6 +555,11 @@ interface FieldModelState extends Omit<FieldState, 'errors' | 'warnings'> {
527
555
  warnings?: Warnings;
528
556
  }
529
557
 
558
+ /**
559
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
560
+ * SPDX-License-Identifier: MIT
561
+ */
562
+
530
563
  type FieldProps<TValue> = FieldOptions<TValue> & {
531
564
  /**
532
565
  * A React element or a render prop
@@ -542,6 +575,11 @@ type FieldProps<TValue> = FieldOptions<TValue> & {
542
575
  */
543
576
  declare function Field<TValue>({ name, defaultValue, render, children, deps, }: FieldProps<TValue>): React$1.ReactElement;
544
577
 
578
+ /**
579
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
580
+ * SPDX-License-Identifier: MIT
581
+ */
582
+
545
583
  type FormProps<TValues> = FormOptions & {
546
584
  /**
547
585
  * React children or child render prop
@@ -564,17 +602,32 @@ type FormProps<TValues> = FormOptions & {
564
602
  */
565
603
  declare function Form<TValues>(props: FormProps<TValues>): React__default.JSX.Element;
566
604
 
605
+ /**
606
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
607
+ * SPDX-License-Identifier: MIT
608
+ */
609
+
567
610
  /**
568
611
  * Get Form instance. It should be use in a child component of <Form />
569
612
  */
570
613
  declare function useForm(): Form$1;
571
614
 
615
+ /**
616
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
617
+ * SPDX-License-Identifier: MIT
618
+ */
619
+
572
620
  /**
573
621
  * Listen to the field data change and refresh the React component.
574
622
  * @param name the field's uniq name (path)
575
623
  */
576
624
  declare function useWatch<TValue = FieldValue>(name: FieldName): TValue;
577
625
 
626
+ /**
627
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
628
+ * SPDX-License-Identifier: MIT
629
+ */
630
+
578
631
  type FieldArrayProps<TValue> = FieldArrayOptions<TValue> & {
579
632
  /**
580
633
  * A React element or a render prop
@@ -590,6 +643,11 @@ type FieldArrayProps<TValue> = FieldArrayOptions<TValue> & {
590
643
  */
591
644
  declare function FieldArray<TValue extends FieldValue>({ name, defaultValue, deps, render, children, }: FieldArrayProps<TValue>): React$1.ReactElement;
592
645
 
646
+ /**
647
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
648
+ * SPDX-License-Identifier: MIT
649
+ */
650
+
593
651
  /**
594
652
  * @deprecated
595
653
  * `useField` is deprecated because its return relies on React render. if the Field is not rendered, the return would be
@@ -602,6 +660,11 @@ declare function useFormState(control?: FormControl<any> | Form$1): FormState;
602
660
  declare function useFormErrors(control?: FormControl<any> | Form$1): Errors | undefined;
603
661
  declare function useFormWarnings(control?: FormControl<any> | Form$1): Warnings | undefined;
604
662
 
663
+ /**
664
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
665
+ * SPDX-License-Identifier: MIT
666
+ */
667
+
605
668
  /**
606
669
  * Get validate method of a field with given name. the returned function could possibly do nothing if the field is not found.
607
670
  * The reason could be that the field is not rendered yet or the name given is wrong.
@@ -609,16 +672,31 @@ declare function useFormWarnings(control?: FormControl<any> | Form$1): Warnings
609
672
  */
610
673
  declare function useFieldValidate(name?: FieldName): () => void;
611
674
 
675
+ /**
676
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
677
+ * SPDX-License-Identifier: MIT
678
+ */
679
+
612
680
  /**
613
681
  * Get the current Field. It should be used in a child component of <Field />, otherwise it throws an error
614
682
  */
615
683
  declare function useCurrentField<TFieldValue = FieldValue, TField extends Field$1<TFieldValue> | FieldArray$1<TFieldValue> = Field$1<TFieldValue>>(): Field$1<TFieldValue> | FieldArray$1<TFieldValue>;
616
684
 
685
+ /**
686
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
687
+ * SPDX-License-Identifier: MIT
688
+ */
689
+
617
690
  /**
618
691
  * Get the current field state. It should be used in a child component of <Field />, otherwise it throws an error
619
692
  */
620
693
  declare function useCurrentFieldState(): FieldState;
621
694
 
695
+ /**
696
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
697
+ * SPDX-License-Identifier: MIT
698
+ */
699
+
622
700
  type CreateFormOptions<T = any> = FormOptions<T> & {
623
701
  /**
624
702
  * 为 true 时,createForm 不会对form 初始化, 用户需要手动调用 control.init()
@@ -629,6 +707,10 @@ type CreateFormOptions<T = any> = FormOptions<T> & {
629
707
  };
630
708
  declare function createForm<TValues>(options?: CreateFormOptions<TValues>): CreateFormReturn<TValues>;
631
709
 
710
+ /**
711
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
712
+ * SPDX-License-Identifier: MIT
713
+ */
632
714
  declare namespace Glob {
633
715
  const DIVIDER = ".";
634
716
  const ALL = "*";
@@ -685,8 +767,18 @@ declare function toFieldState(modelState: FieldModelState): {
685
767
  readonly warnings: FieldWarning[] | undefined;
686
768
  };
687
769
 
770
+ /**
771
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
772
+ * SPDX-License-Identifier: MIT
773
+ */
774
+
688
775
  declare function toFieldArray<TValue>(model: FieldArrayModel<TValue>): FieldArray$1<TValue>;
689
776
 
777
+ /**
778
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
779
+ * SPDX-License-Identifier: MIT
780
+ */
781
+
690
782
  declare function toForm<TValue>(model: FormModel): Form$1<TValue>;
691
783
  declare function toFormState(modelState: FormModelState): FormState;
692
784
 
package/dist/index.d.ts CHANGED
@@ -4,8 +4,17 @@ import * as _flowgram_ai_utils from '@flowgram.ai/utils';
4
4
  import { MaybePromise, Disposable, Emitter, DisposableCollection } from '@flowgram.ai/utils';
5
5
  import { ReactiveState } from '@flowgram.ai/reactive';
6
6
 
7
+ /**
8
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
9
+ * SPDX-License-Identifier: MIT
10
+ */
7
11
  type Context = any;
8
12
 
13
+ /**
14
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
15
+ * SPDX-License-Identifier: MIT
16
+ */
17
+
9
18
  declare enum FeedbackLevel {
10
19
  Error = "error",
11
20
  Warning = "warning"
@@ -58,6 +67,10 @@ declare enum ValidateTrigger {
58
67
  }
59
68
  type FormValidateReturn = (FieldError | FieldWarning)[];
60
69
 
70
+ /**
71
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
72
+ * SPDX-License-Identifier: MIT
73
+ */
61
74
  declare class Path {
62
75
  protected _path: string[];
63
76
  constructor(path: string | string[]);
@@ -82,6 +95,11 @@ declare class Path {
82
95
  replaceParent(parent: Path, newParent: Path): Path;
83
96
  }
84
97
 
98
+ /**
99
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
100
+ * SPDX-License-Identifier: MIT
101
+ */
102
+
85
103
  declare class Store<TValues = FieldValue> {
86
104
  protected _values: TValues;
87
105
  get values(): TValues;
@@ -252,6 +270,11 @@ declare class FormModel<TValues = any> implements Disposable {
252
270
  dispose(): void;
253
271
  }
254
272
 
273
+ /**
274
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
275
+ * SPDX-License-Identifier: MIT
276
+ */
277
+
255
278
  interface FormState {
256
279
  /**
257
280
  * If the form data is valid
@@ -367,6 +390,11 @@ interface OnFormValuesUpdatedPayload {
367
390
  options?: OnFormValuesChangeOptions;
368
391
  }
369
392
 
393
+ /**
394
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
395
+ * SPDX-License-Identifier: MIT
396
+ */
397
+
370
398
  type FieldValue = any;
371
399
  type FieldName = string;
372
400
  type CustomElement = Partial<HTMLElement> & {
@@ -527,6 +555,11 @@ interface FieldModelState extends Omit<FieldState, 'errors' | 'warnings'> {
527
555
  warnings?: Warnings;
528
556
  }
529
557
 
558
+ /**
559
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
560
+ * SPDX-License-Identifier: MIT
561
+ */
562
+
530
563
  type FieldProps<TValue> = FieldOptions<TValue> & {
531
564
  /**
532
565
  * A React element or a render prop
@@ -542,6 +575,11 @@ type FieldProps<TValue> = FieldOptions<TValue> & {
542
575
  */
543
576
  declare function Field<TValue>({ name, defaultValue, render, children, deps, }: FieldProps<TValue>): React$1.ReactElement;
544
577
 
578
+ /**
579
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
580
+ * SPDX-License-Identifier: MIT
581
+ */
582
+
545
583
  type FormProps<TValues> = FormOptions & {
546
584
  /**
547
585
  * React children or child render prop
@@ -564,17 +602,32 @@ type FormProps<TValues> = FormOptions & {
564
602
  */
565
603
  declare function Form<TValues>(props: FormProps<TValues>): React__default.JSX.Element;
566
604
 
605
+ /**
606
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
607
+ * SPDX-License-Identifier: MIT
608
+ */
609
+
567
610
  /**
568
611
  * Get Form instance. It should be use in a child component of <Form />
569
612
  */
570
613
  declare function useForm(): Form$1;
571
614
 
615
+ /**
616
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
617
+ * SPDX-License-Identifier: MIT
618
+ */
619
+
572
620
  /**
573
621
  * Listen to the field data change and refresh the React component.
574
622
  * @param name the field's uniq name (path)
575
623
  */
576
624
  declare function useWatch<TValue = FieldValue>(name: FieldName): TValue;
577
625
 
626
+ /**
627
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
628
+ * SPDX-License-Identifier: MIT
629
+ */
630
+
578
631
  type FieldArrayProps<TValue> = FieldArrayOptions<TValue> & {
579
632
  /**
580
633
  * A React element or a render prop
@@ -590,6 +643,11 @@ type FieldArrayProps<TValue> = FieldArrayOptions<TValue> & {
590
643
  */
591
644
  declare function FieldArray<TValue extends FieldValue>({ name, defaultValue, deps, render, children, }: FieldArrayProps<TValue>): React$1.ReactElement;
592
645
 
646
+ /**
647
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
648
+ * SPDX-License-Identifier: MIT
649
+ */
650
+
593
651
  /**
594
652
  * @deprecated
595
653
  * `useField` is deprecated because its return relies on React render. if the Field is not rendered, the return would be
@@ -602,6 +660,11 @@ declare function useFormState(control?: FormControl<any> | Form$1): FormState;
602
660
  declare function useFormErrors(control?: FormControl<any> | Form$1): Errors | undefined;
603
661
  declare function useFormWarnings(control?: FormControl<any> | Form$1): Warnings | undefined;
604
662
 
663
+ /**
664
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
665
+ * SPDX-License-Identifier: MIT
666
+ */
667
+
605
668
  /**
606
669
  * Get validate method of a field with given name. the returned function could possibly do nothing if the field is not found.
607
670
  * The reason could be that the field is not rendered yet or the name given is wrong.
@@ -609,16 +672,31 @@ declare function useFormWarnings(control?: FormControl<any> | Form$1): Warnings
609
672
  */
610
673
  declare function useFieldValidate(name?: FieldName): () => void;
611
674
 
675
+ /**
676
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
677
+ * SPDX-License-Identifier: MIT
678
+ */
679
+
612
680
  /**
613
681
  * Get the current Field. It should be used in a child component of <Field />, otherwise it throws an error
614
682
  */
615
683
  declare function useCurrentField<TFieldValue = FieldValue, TField extends Field$1<TFieldValue> | FieldArray$1<TFieldValue> = Field$1<TFieldValue>>(): Field$1<TFieldValue> | FieldArray$1<TFieldValue>;
616
684
 
685
+ /**
686
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
687
+ * SPDX-License-Identifier: MIT
688
+ */
689
+
617
690
  /**
618
691
  * Get the current field state. It should be used in a child component of <Field />, otherwise it throws an error
619
692
  */
620
693
  declare function useCurrentFieldState(): FieldState;
621
694
 
695
+ /**
696
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
697
+ * SPDX-License-Identifier: MIT
698
+ */
699
+
622
700
  type CreateFormOptions<T = any> = FormOptions<T> & {
623
701
  /**
624
702
  * 为 true 时,createForm 不会对form 初始化, 用户需要手动调用 control.init()
@@ -629,6 +707,10 @@ type CreateFormOptions<T = any> = FormOptions<T> & {
629
707
  };
630
708
  declare function createForm<TValues>(options?: CreateFormOptions<TValues>): CreateFormReturn<TValues>;
631
709
 
710
+ /**
711
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
712
+ * SPDX-License-Identifier: MIT
713
+ */
632
714
  declare namespace Glob {
633
715
  const DIVIDER = ".";
634
716
  const ALL = "*";
@@ -685,8 +767,18 @@ declare function toFieldState(modelState: FieldModelState): {
685
767
  readonly warnings: FieldWarning[] | undefined;
686
768
  };
687
769
 
770
+ /**
771
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
772
+ * SPDX-License-Identifier: MIT
773
+ */
774
+
688
775
  declare function toFieldArray<TValue>(model: FieldArrayModel<TValue>): FieldArray$1<TValue>;
689
776
 
777
+ /**
778
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
779
+ * SPDX-License-Identifier: MIT
780
+ */
781
+
690
782
  declare function toForm<TValue>(model: FormModel): Form$1<TValue>;
691
783
  declare function toFormState(modelState: FormModelState): FormState;
692
784