@overmap-ai/forms 1.0.17-forms-refactor-1.1 → 1.0.17-forms-refactor-1.2
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/forms/builder/typings.d.ts +1 -1
- package/dist/forms/builder/utils.d.ts +4 -4
- package/dist/forms/fields/BaseField/BaseField.d.ts +2 -2
- package/dist/forms/fields/FieldSection/FieldSection.d.ts +2 -2
- package/dist/forms/fields/typings.d.ts +2 -2
- package/dist/forms/utils.d.ts +2 -2
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ export type FormBuilderSaveHandler = (form: NewForm | FormRevision) => void;
|
|
|
6
6
|
*
|
|
7
7
|
* The only difference between the two is that new forms do not have `id` attributes.
|
|
8
8
|
*/
|
|
9
|
-
export type
|
|
9
|
+
export type FormikFormRevision = FormRevision<SerializedFieldSection> | NewForm;
|
|
10
10
|
/** Using `lodash.get` and `lodash.set`, we can set and get attributes of nested objects using a string path. This is
|
|
11
11
|
used to get and set attributes of the `fields` of a `SerializedFieldSection` object. */
|
|
12
12
|
export type NestedFieldPath = "fields" | `fields.${number}.fields`;
|
|
@@ -2,7 +2,7 @@ import { FormRevision, ISerializedOnlyField } from '@overmap-ai/core';
|
|
|
2
2
|
import { FormikHelpers } from 'formik';
|
|
3
3
|
import { ISerializedField, SerializedFieldSection } from '../typings';
|
|
4
4
|
import { DropState } from './DropDispatch';
|
|
5
|
-
import {
|
|
5
|
+
import { FormikFormRevision, NestedFieldPath } from './typings';
|
|
6
6
|
export declare const emptySection: (id?: string, fields?: ISerializedOnlyField[]) => SerializedFieldSection;
|
|
7
7
|
export declare const wrapRootFieldsWithFieldSection: (revision?: FormRevision) => FormRevision<SerializedFieldSection> | undefined;
|
|
8
8
|
export declare function reorder<T>(list: T[], source: number, destination: number): T[];
|
|
@@ -15,9 +15,9 @@ export declare const makeConditionalSourceFields: (sections: SerializedFieldSect
|
|
|
15
15
|
export type NewFieldInitialValues = Omit<ISerializedField, "identifier"> & {
|
|
16
16
|
label: string;
|
|
17
17
|
};
|
|
18
|
-
export declare const createNewField: (parentPath: NestedFieldPath, index: number, initialValues: NewFieldInitialValues, values:
|
|
19
|
-
export declare const createNewEmptySection: (index: number, values:
|
|
18
|
+
export declare const createNewField: (parentPath: NestedFieldPath, index: number, initialValues: NewFieldInitialValues, values: FormikFormRevision, setFieldValue: FormikHelpers<unknown>["setFieldValue"]) => void;
|
|
19
|
+
export declare const createNewEmptySection: (index: number, values: FormikFormRevision, setFieldValue: FormikHelpers<unknown>["setFieldValue"]) => void;
|
|
20
20
|
export declare const useFieldReordering: () => {
|
|
21
|
-
reorderSection: (dropState: DropState, sectionId: string, sectionIndex: number, destinationIndex: number, values:
|
|
21
|
+
reorderSection: (dropState: DropState, sectionId: string, sectionIndex: number, destinationIndex: number, values: FormikFormRevision, setFieldValue: FormikHelpers<unknown>["setFieldValue"]) => void;
|
|
22
22
|
reorderField: (srcSection: SerializedFieldSection | undefined, srcSectionIndex: string | number | undefined, srcFieldIndex: number, destSection: SerializedFieldSection | undefined, destSectionIndex: string | number | undefined, destFieldIndex: number, setFieldValue: FormikHelpers<unknown>["setFieldValue"]) => void;
|
|
23
23
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ISerializedOnlyField } from '@overmap-ai/core';
|
|
2
2
|
import { ChangeEvent, ReactNode } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { FormikFormRevision } from '../../builder';
|
|
4
4
|
import { BaseSerializedField, BaseSerializedObject, FieldTypeIdentifier, FieldValue, FormValues, ISerializedField } from '../../typings';
|
|
5
5
|
import { FieldSection } from '../FieldSection';
|
|
6
6
|
import { AnyField, GetInputProps, InputFieldLevelValidator, InputFormLevelValidator } from '../typings';
|
|
@@ -43,7 +43,7 @@ export declare abstract class BaseField<TValue extends FieldValue, TIdentifier e
|
|
|
43
43
|
static getFieldCreationSchema(): FieldCreationSchemaObject[];
|
|
44
44
|
protected isBlank(value: TValue | undefined): boolean;
|
|
45
45
|
getValueFromChangeEvent(event: ChangeEvent<HTMLInputElement>): TValue;
|
|
46
|
-
getError(value: TValue, allValues?: FormValues |
|
|
46
|
+
getError(value: TValue, allValues?: FormValues | FormikFormRevision): string | undefined;
|
|
47
47
|
protected _serialize(): BaseSerializedField<TIdentifier>;
|
|
48
48
|
abstract serialize(): ISerializedOnlyField;
|
|
49
49
|
getFieldValidators(): InputFieldLevelValidator<TValue>[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { FormikFormRevision } from '../../builder';
|
|
3
3
|
import { BaseSerializedObject, FormValues, ISerializedField, SerializedCondition, SerializedFieldSection } from '../../typings';
|
|
4
4
|
import { AnyField, BaseFormElement, BooleanField, GetInputProps } from '../index';
|
|
5
5
|
interface FieldSectionOptions extends Omit<BaseSerializedObject, "type"> {
|
|
@@ -27,7 +27,7 @@ export declare class FieldSection extends BaseFormElement<"section"> {
|
|
|
27
27
|
condition: SerializedCondition;
|
|
28
28
|
};
|
|
29
29
|
serialize(): SerializedFieldSection;
|
|
30
|
-
getErrors(allValues: FormValues |
|
|
30
|
+
getErrors(allValues: FormValues | FormikFormRevision): Record<string, string>;
|
|
31
31
|
getInput(props: GetInputProps<this>): ReactNode;
|
|
32
32
|
}
|
|
33
33
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TextSize } from '@overmap-ai/blocks';
|
|
2
2
|
import { HTMLProps, ReactNode } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { FormikFormRevision } from '../builder';
|
|
4
4
|
import { FormValues } from '../typings';
|
|
5
5
|
import { BaseField, BaseFormElement } from './BaseField';
|
|
6
6
|
export interface SchemaMeta {
|
|
@@ -14,7 +14,7 @@ export interface ISchema {
|
|
|
14
14
|
description?: ReactNode;
|
|
15
15
|
}
|
|
16
16
|
export type InputFieldLevelValidator<TValue> = (value: TValue | undefined) => string | null | undefined;
|
|
17
|
-
export type InputFormLevelValidator<TValue> = (value: TValue | undefined, allValues: FormValues |
|
|
17
|
+
export type InputFormLevelValidator<TValue> = (value: TValue | undefined, allValues: FormValues | FormikFormRevision) => string | null | undefined;
|
|
18
18
|
export type InputValidator<TValue> = InputFieldLevelValidator<TValue> | InputFormLevelValidator<TValue>;
|
|
19
19
|
export interface ComponentProps<TField extends BaseFormElement> extends Omit<HTMLProps<HTMLElement>, "color" | "size" | "ref" | "type" | "onChange" | "onBlur" | "value" | "defaultValue" | "name" | "dir"> {
|
|
20
20
|
field: TField;
|
package/dist/forms/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FormikErrors } from 'formik';
|
|
2
|
-
import {
|
|
2
|
+
import { FormikFormRevision } from './builder';
|
|
3
3
|
import { BaseFormElement, ISchema } from './fields';
|
|
4
4
|
import { FormValues } from './typings';
|
|
5
5
|
export declare const hasKeys: (errors: object) => boolean;
|
|
6
|
-
export declare const validateForm: (schema: ISchema, form: FormValues |
|
|
6
|
+
export declare const validateForm: (schema: ISchema, form: FormValues | FormikFormRevision) => FormikErrors<FormValues> | FormikErrors<import('./builder').NewForm> | undefined;
|
|
7
7
|
export declare const initialFormValues: (fields: BaseFormElement[], values: FormValues) => FormValues;
|