@flowgram.ai/form 0.1.15 → 0.1.17
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/esm/index.js +9 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -173,7 +173,7 @@ declare class FieldArrayModel<TValue = FieldValue> extends FieldModel<Array<TVal
|
|
|
173
173
|
map<T>(cb: (f: FieldModel, index: number, arr: FieldModel[]) => T): T[];
|
|
174
174
|
append(value?: TValue): FieldModel<any>;
|
|
175
175
|
/**
|
|
176
|
-
*
|
|
176
|
+
* Delete the element in given index and delete the corresponding FieldModel as well
|
|
177
177
|
* @param index
|
|
178
178
|
*/
|
|
179
179
|
delete(index: number): void;
|
|
@@ -325,6 +325,10 @@ interface Form$1<TValues = any> {
|
|
|
325
325
|
* @param name path
|
|
326
326
|
*/
|
|
327
327
|
setValueIn<TValue>(name: FieldName, value: TValue): void;
|
|
328
|
+
/**
|
|
329
|
+
* Trigger validate for the whole form.
|
|
330
|
+
*/
|
|
331
|
+
validate: () => Promise<FormValidateReturn>;
|
|
328
332
|
}
|
|
329
333
|
interface FormRenderProps<TValues> {
|
|
330
334
|
/**
|
|
@@ -417,17 +421,23 @@ interface FieldArray$1<TFieldValue extends FieldValue = FieldValue> extends Fiel
|
|
|
417
421
|
* Same as native Array.map, the first param of the callback function is the child field of this FieldArray.
|
|
418
422
|
* @param cb callback function
|
|
419
423
|
*/
|
|
420
|
-
map: <T = any>(cb: (f: Field$1
|
|
424
|
+
map: <T = any>(cb: (f: Field$1<TFieldValue>, index: number) => T) => T[];
|
|
421
425
|
/**
|
|
422
426
|
* Append a value at the end of the array, it will create a new Field for this value as well.
|
|
423
427
|
* @param value the value to append
|
|
424
428
|
*/
|
|
425
429
|
append: (value: TFieldValue) => Field$1<TFieldValue>;
|
|
426
430
|
/**
|
|
431
|
+
* @deprecated use remove instead
|
|
427
432
|
* Delete the value and the related field at certain index of the array.
|
|
428
433
|
* @param index the index of the element to delete
|
|
429
434
|
*/
|
|
430
435
|
delete: (index: number) => void;
|
|
436
|
+
/**
|
|
437
|
+
* Delete the value and the related field at certain index of the array.
|
|
438
|
+
* @param index the index of the element to delete
|
|
439
|
+
*/
|
|
440
|
+
remove: (index: number) => void;
|
|
431
441
|
/**
|
|
432
442
|
* Move an array element from one position to another.
|
|
433
443
|
* @param from from position
|
package/dist/index.d.ts
CHANGED
|
@@ -173,7 +173,7 @@ declare class FieldArrayModel<TValue = FieldValue> extends FieldModel<Array<TVal
|
|
|
173
173
|
map<T>(cb: (f: FieldModel, index: number, arr: FieldModel[]) => T): T[];
|
|
174
174
|
append(value?: TValue): FieldModel<any>;
|
|
175
175
|
/**
|
|
176
|
-
*
|
|
176
|
+
* Delete the element in given index and delete the corresponding FieldModel as well
|
|
177
177
|
* @param index
|
|
178
178
|
*/
|
|
179
179
|
delete(index: number): void;
|
|
@@ -325,6 +325,10 @@ interface Form$1<TValues = any> {
|
|
|
325
325
|
* @param name path
|
|
326
326
|
*/
|
|
327
327
|
setValueIn<TValue>(name: FieldName, value: TValue): void;
|
|
328
|
+
/**
|
|
329
|
+
* Trigger validate for the whole form.
|
|
330
|
+
*/
|
|
331
|
+
validate: () => Promise<FormValidateReturn>;
|
|
328
332
|
}
|
|
329
333
|
interface FormRenderProps<TValues> {
|
|
330
334
|
/**
|
|
@@ -417,17 +421,23 @@ interface FieldArray$1<TFieldValue extends FieldValue = FieldValue> extends Fiel
|
|
|
417
421
|
* Same as native Array.map, the first param of the callback function is the child field of this FieldArray.
|
|
418
422
|
* @param cb callback function
|
|
419
423
|
*/
|
|
420
|
-
map: <T = any>(cb: (f: Field$1
|
|
424
|
+
map: <T = any>(cb: (f: Field$1<TFieldValue>, index: number) => T) => T[];
|
|
421
425
|
/**
|
|
422
426
|
* Append a value at the end of the array, it will create a new Field for this value as well.
|
|
423
427
|
* @param value the value to append
|
|
424
428
|
*/
|
|
425
429
|
append: (value: TFieldValue) => Field$1<TFieldValue>;
|
|
426
430
|
/**
|
|
431
|
+
* @deprecated use remove instead
|
|
427
432
|
* Delete the value and the related field at certain index of the array.
|
|
428
433
|
* @param index the index of the element to delete
|
|
429
434
|
*/
|
|
430
435
|
delete: (index: number) => void;
|
|
436
|
+
/**
|
|
437
|
+
* Delete the value and the related field at certain index of the array.
|
|
438
|
+
* @param index the index of the element to delete
|
|
439
|
+
*/
|
|
440
|
+
remove: (index: number) => void;
|
|
431
441
|
/**
|
|
432
442
|
* Move an array element from one position to another.
|
|
433
443
|
* @param from from position
|
package/dist/index.js
CHANGED
|
@@ -530,7 +530,8 @@ function toForm(model) {
|
|
|
530
530
|
},
|
|
531
531
|
state: toFormState(model.state),
|
|
532
532
|
getValueIn: (name) => model.getValueIn(name),
|
|
533
|
-
setValueIn: (name, value) => model.setValueIn(name, value)
|
|
533
|
+
setValueIn: (name, value) => model.setValueIn(name, value),
|
|
534
|
+
validate: model.validate.bind(model)
|
|
534
535
|
};
|
|
535
536
|
Object.defineProperty(res, "_formModel", {
|
|
536
537
|
enumerable: false,
|
|
@@ -666,7 +667,12 @@ function toFieldArray(model) {
|
|
|
666
667
|
},
|
|
667
668
|
map: (cb) => model.map((f, index) => cb(toField(f), index)),
|
|
668
669
|
append: (value) => toField(model.append(value)),
|
|
670
|
+
/**
|
|
671
|
+
* @deprecated: use remove instead
|
|
672
|
+
* @param index
|
|
673
|
+
*/
|
|
669
674
|
delete: (index) => model.delete(index),
|
|
675
|
+
remove: (index) => model.delete(index),
|
|
670
676
|
swap: (from, to) => model.swap(from, to),
|
|
671
677
|
move: (from, to) => model.move(from, to)
|
|
672
678
|
};
|
|
@@ -1072,7 +1078,7 @@ var FieldArrayModel = class extends FieldModel {
|
|
|
1072
1078
|
return newElemField;
|
|
1073
1079
|
}
|
|
1074
1080
|
/**
|
|
1075
|
-
*
|
|
1081
|
+
* Delete the element in given index and delete the corresponding FieldModel as well
|
|
1076
1082
|
* @param index
|
|
1077
1083
|
*/
|
|
1078
1084
|
delete(index) {
|
|
@@ -1568,7 +1574,7 @@ function FieldArray({
|
|
|
1568
1574
|
const formModel = useFormModel();
|
|
1569
1575
|
const fieldModel = React4.useMemo(
|
|
1570
1576
|
() => formModel.getField(name) || formModel.createFieldArray(name),
|
|
1571
|
-
[]
|
|
1577
|
+
[name]
|
|
1572
1578
|
);
|
|
1573
1579
|
const field = React4.useMemo(() => toFieldArray(fieldModel), [fieldModel]);
|
|
1574
1580
|
const refresh = (0, import_utils16.useRefresh)();
|