@overmap-ai/forms 1.0.15 → 1.0.17-blank-value-updates.1
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/ColorPicker/ColorPicker.d.ts +10 -0
- package/dist/ColorPicker/index.d.ts +1 -0
- package/dist/FileCard/FileCard.d.ts +7 -0
- package/dist/FileCard/index.d.ts +1 -0
- package/dist/FileIcon/FileIcon.d.ts +7 -0
- package/dist/FileIcon/index.d.ts +1 -0
- package/dist/ImageCard/ImageCard.d.ts +8 -0
- package/dist/ImageCard/index.d.ts +1 -0
- package/dist/ImageMarkup/ImageMarkup.d.ts +14 -0
- package/dist/ImageMarkup/index.d.ts +1 -0
- package/dist/ImageViewer/ImageViewer.d.ts +6 -0
- package/dist/ImageViewer/ImageViewerProvider.d.ts +2 -0
- package/dist/ImageViewer/context.d.ts +3 -0
- package/dist/ImageViewer/hooks.d.ts +1 -0
- package/dist/ImageViewer/index.d.ts +3 -0
- package/dist/ImageViewer/typings.d.ts +4 -0
- package/dist/constants.d.ts +1 -0
- package/dist/{builder → forms/builder}/DropDispatch.d.ts +2 -2
- package/dist/forms/builder/FieldActions.d.ts +13 -0
- package/dist/forms/builder/FieldBuilder.d.ts +10 -0
- package/dist/forms/builder/FieldSectionWithActions.d.ts +10 -0
- package/dist/forms/builder/FieldSettingsPopover.d.ts +8 -0
- package/dist/forms/builder/FieldWithActions.d.ts +9 -0
- package/dist/forms/builder/FieldsEditor.d.ts +1 -0
- package/dist/forms/builder/FormBuilder.d.ts +26 -0
- package/dist/forms/builder/constants.d.ts +18 -0
- package/dist/forms/builder/context.d.ts +6 -0
- package/dist/forms/builder/hooks.d.ts +7 -0
- package/dist/forms/builder/index.d.ts +2 -0
- package/dist/{builder → forms/builder}/typings.d.ts +5 -4
- package/dist/forms/builder/utils.d.ts +24 -0
- package/dist/forms/constants.d.ts +5 -0
- package/dist/{fields → forms/fields}/BaseField/BaseField.d.ts +23 -10
- package/dist/forms/fields/BaseField/hooks.d.ts +394 -0
- package/dist/forms/fields/BaseField/index.d.ts +4 -0
- package/dist/{fields → forms/fields}/BaseField/layouts.d.ts +11 -5
- package/dist/{fields → forms/fields}/BaseField/typings.d.ts +2 -2
- package/dist/forms/fields/BooleanField/BooleanField.d.ts +22 -0
- package/dist/forms/fields/BooleanField/BooleanInput.d.ts +3 -0
- package/dist/forms/fields/BooleanField/index.d.ts +2 -0
- package/dist/{fields → forms/fields}/CustomField/CustomField.d.ts +12 -6
- package/dist/{fields → forms/fields}/CustomField/FieldInputClonerField/FieldInputCloner.d.ts +2 -3
- package/dist/{fields → forms/fields}/CustomField/FieldInputClonerField/FieldInputClonerField.d.ts +3 -3
- package/dist/forms/fields/CustomField/FieldInputClonerField/index.d.ts +3 -0
- package/dist/forms/fields/CustomField/FieldInputClonerField/typings.d.ts +5 -0
- package/dist/forms/fields/CustomField/index.d.ts +1 -0
- package/dist/forms/fields/DateField/DateField.d.ts +21 -0
- package/dist/forms/fields/DateField/DateInput.d.ts +3 -0
- package/dist/forms/fields/DateField/index.d.ts +2 -0
- package/dist/{fields → forms/fields}/FieldSection/FieldSection.d.ts +13 -9
- package/dist/forms/fields/FieldSection/FieldSectionLayout.d.ts +6 -0
- package/dist/forms/fields/FieldSection/index.d.ts +1 -0
- package/dist/forms/fields/MultiStringField/MultiStringField.d.ts +40 -0
- package/dist/forms/fields/MultiStringField/MultiStringInput.d.ts +7 -0
- package/dist/forms/fields/MultiStringField/index.d.ts +2 -0
- package/dist/forms/fields/NumberField/NumberField.d.ts +44 -0
- package/dist/forms/fields/NumberField/NumberInput.d.ts +3 -0
- package/dist/forms/fields/NumberField/index.d.ts +2 -0
- package/dist/forms/fields/QrField/QrField.d.ts +21 -0
- package/dist/forms/fields/QrField/QrInput.d.ts +8 -0
- package/dist/forms/fields/QrField/index.d.ts +2 -0
- package/dist/{fields → forms/fields}/SelectField/BaseSelectField.d.ts +12 -5
- package/dist/{fields → forms/fields}/SelectField/MultiSelectField.d.ts +15 -8
- package/dist/forms/fields/SelectField/MultiSelectInput.d.ts +3 -0
- package/dist/{fields → forms/fields}/SelectField/SelectField.d.ts +13 -7
- package/dist/forms/fields/SelectField/SelectInput.d.ts +3 -0
- package/dist/forms/fields/SelectField/index.d.ts +4 -0
- package/dist/forms/fields/StringOrTextFields/StringField/StringField.d.ts +26 -0
- package/dist/forms/fields/StringOrTextFields/StringField/StringInput.d.ts +3 -0
- package/dist/forms/fields/StringOrTextFields/StringField/index.d.ts +2 -0
- package/dist/{fields → forms/fields}/StringOrTextFields/StringOrTextField.d.ts +15 -10
- package/dist/forms/fields/StringOrTextFields/TextField/TextField.d.ts +22 -0
- package/dist/forms/fields/StringOrTextFields/TextField/TextInput.d.ts +3 -0
- package/dist/forms/fields/StringOrTextFields/TextField/index.d.ts +2 -0
- package/dist/forms/fields/StringOrTextFields/index.d.ts +2 -0
- package/dist/forms/fields/UploadField/UploadField.d.ts +44 -0
- package/dist/forms/fields/UploadField/UploadInput.d.ts +3 -0
- package/dist/forms/fields/UploadField/index.d.ts +2 -0
- package/dist/forms/fields/constants.d.ts +106 -0
- package/dist/forms/fields/hooks.d.ts +6 -0
- package/dist/forms/fields/index.d.ts +12 -0
- package/dist/{fields → forms/fields}/typings.d.ts +10 -7
- package/dist/forms/fields/utils.d.ts +18 -0
- package/dist/forms/index.d.ts +6 -0
- package/dist/forms/renderer/FormRenderer/FormRenderer.d.ts +34 -0
- package/dist/forms/renderer/FormRenderer/constants.d.ts +3 -0
- package/dist/{renderer → forms/renderer}/PatchForm/Field.d.ts +5 -3
- package/dist/forms/renderer/PatchForm/Provider.d.ts +29 -0
- package/dist/forms/renderer/PatchForm/index.d.ts +2 -0
- package/dist/forms/renderer/index.d.ts +2 -0
- package/dist/forms/typings.d.ts +104 -0
- package/dist/forms/utils.d.ts +8 -0
- package/dist/forms.js +4368 -2452
- package/dist/forms.umd.cjs +44 -2777
- package/dist/index.d.ts +7 -3
- package/package.json +97 -94
- package/README.md +0 -12
- package/dist/builder/FieldActions.d.ts +0 -12
- package/dist/builder/FieldBuilder.d.ts +0 -24
- package/dist/builder/FieldSectionWithActions.d.ts +0 -10
- package/dist/builder/FieldWithActions.d.ts +0 -11
- package/dist/builder/FieldsEditor.d.ts +0 -2
- package/dist/builder/FormBuilder.d.ts +0 -15
- package/dist/builder/constants.d.ts +0 -1
- package/dist/builder/index.d.ts +0 -2
- package/dist/builder/utils.d.ts +0 -13
- package/dist/fields/BaseField/hooks.d.ts +0 -374
- package/dist/fields/BaseField/index.d.ts +0 -4
- package/dist/fields/BooleanField/BooleanField.d.ts +0 -17
- package/dist/fields/BooleanField/BooleanInput.d.ts +0 -4
- package/dist/fields/BooleanField/index.d.ts +0 -2
- package/dist/fields/CustomField/FieldInputClonerField/index.d.ts +0 -3
- package/dist/fields/CustomField/FieldInputClonerField/typings.d.ts +0 -5
- package/dist/fields/CustomField/index.d.ts +0 -1
- package/dist/fields/DateField/DateField.d.ts +0 -16
- package/dist/fields/DateField/DateInput.d.ts +0 -4
- package/dist/fields/DateField/index.d.ts +0 -2
- package/dist/fields/FieldSection/FieldSectionLayout.d.ts +0 -7
- package/dist/fields/FieldSection/index.d.ts +0 -1
- package/dist/fields/MultiStringField/MultiStringField.d.ts +0 -30
- package/dist/fields/MultiStringField/MultiStringInput.d.ts +0 -8
- package/dist/fields/MultiStringField/index.d.ts +0 -2
- package/dist/fields/NumberField/NumberField.d.ts +0 -29
- package/dist/fields/NumberField/NumberInput.d.ts +0 -4
- package/dist/fields/NumberField/index.d.ts +0 -2
- package/dist/fields/SelectField/MultiSelectInput.d.ts +0 -4
- package/dist/fields/SelectField/SelectInput.d.ts +0 -4
- package/dist/fields/SelectField/index.d.ts +0 -4
- package/dist/fields/StringOrTextFields/StringField/StringField.d.ts +0 -19
- package/dist/fields/StringOrTextFields/StringField/StringInput.d.ts +0 -4
- package/dist/fields/StringOrTextFields/StringField/index.d.ts +0 -2
- package/dist/fields/StringOrTextFields/TextField/TextField.d.ts +0 -16
- package/dist/fields/StringOrTextFields/TextField/TextInput.d.ts +0 -4
- package/dist/fields/StringOrTextFields/TextField/index.d.ts +0 -2
- package/dist/fields/StringOrTextFields/index.d.ts +0 -2
- package/dist/fields/UploadField/UploadField.d.ts +0 -29
- package/dist/fields/UploadField/UploadInput.d.ts +0 -4
- package/dist/fields/UploadField/index.d.ts +0 -2
- package/dist/fields/constants.d.ts +0 -20
- package/dist/fields/hooks.d.ts +0 -6
- package/dist/fields/index.d.ts +0 -11
- package/dist/fields/utils.d.ts +0 -13
- package/dist/forms.js.map +0 -1
- package/dist/forms.umd.cjs.map +0 -1
- package/dist/renderer/FormBrowser/FormBrowser.d.ts +0 -11
- package/dist/renderer/FormRenderer/FormRenderer.d.ts +0 -29
- package/dist/renderer/FormSubmissionBrowser/FormSubmissionBrowser.d.ts +0 -28
- package/dist/renderer/FormSubmissionViewer/FormSubmissionViewer.d.ts +0 -17
- package/dist/renderer/PatchForm/Provider.d.ts +0 -24
- package/dist/renderer/PatchForm/index.d.ts +0 -2
- package/dist/renderer/index.d.ts +0 -5
- package/dist/style.css +0 -34
- package/dist/typings.d.ts +0 -17
- package/dist/utils.d.ts +0 -7
- /package/dist/{fields → forms/fields}/UploadField/utils.d.ts +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { RiListCheck } from 'react-icons/ri';
|
|
3
|
+
import { ISerializedField, SerializedMultiStringField } from '../../typings';
|
|
4
|
+
import { BaseField, ChildFieldOptions } from '../BaseField';
|
|
5
|
+
import { GetInputProps, InputFieldLevelValidator } from '../typings';
|
|
6
|
+
type MultiStringFieldOptions = ChildFieldOptions<string[]> & {
|
|
7
|
+
minimum_length?: number;
|
|
8
|
+
maximum_length?: number;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const emptyMultiStringField: {
|
|
12
|
+
type: string;
|
|
13
|
+
minimum_length: number;
|
|
14
|
+
maximum_length: null;
|
|
15
|
+
label: string;
|
|
16
|
+
description: string;
|
|
17
|
+
required: boolean;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A field that lets the user input multiple strings. Each string must be unique. Useful for things like:
|
|
21
|
+
* - Specifying the options of a SelectField (used in `SelectField.getFieldCreationSchema`
|
|
22
|
+
* - Listing serial numbers and similar
|
|
23
|
+
*/
|
|
24
|
+
export declare class MultiStringField extends BaseField<string[], "multi-string"> {
|
|
25
|
+
static readonly fieldTypeName = "Multi-string";
|
|
26
|
+
static readonly fieldTypeDescription = "Allows the user to provide multiple unique strings.";
|
|
27
|
+
readonly minLength: number;
|
|
28
|
+
readonly maxLength: number;
|
|
29
|
+
readonly onlyValidateAfterTouched = false;
|
|
30
|
+
readonly placeholder: string;
|
|
31
|
+
static Icon: typeof RiListCheck;
|
|
32
|
+
constructor(options: MultiStringFieldOptions);
|
|
33
|
+
getInput(props: GetInputProps<this>): ReactNode;
|
|
34
|
+
serialize(): SerializedMultiStringField;
|
|
35
|
+
protected isBlank(value: string[] | undefined): boolean;
|
|
36
|
+
isEqual(value1: string[] | undefined, value2: string[] | undefined): boolean;
|
|
37
|
+
getFieldValidators(): InputFieldLevelValidator<string[]>[];
|
|
38
|
+
static deserialize(data: ISerializedField): MultiStringField;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ComponentProps } from '../typings';
|
|
2
|
+
import { MultiStringField } from './MultiStringField';
|
|
3
|
+
/**
|
|
4
|
+
* Allows the user to create an array of unique strings and customize the order.
|
|
5
|
+
* User to generate options for the Select field.
|
|
6
|
+
*/
|
|
7
|
+
export declare const MultiStringInput: import('react').MemoExoticComponent<(props: ComponentProps<MultiStringField>) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { RiHashtag } from 'react-icons/ri';
|
|
3
|
+
import { ISerializedField, SerializedNumberField } from '../../typings';
|
|
4
|
+
import { BaseField, ChildFieldOptions } from '../BaseField';
|
|
5
|
+
import { BooleanField } from '../BooleanField';
|
|
6
|
+
import { GetInputProps, InputFieldLevelValidator, InputValidator } from '../typings';
|
|
7
|
+
export declare const emptyNumberField: {
|
|
8
|
+
type: string;
|
|
9
|
+
minimum: number;
|
|
10
|
+
maximum: number;
|
|
11
|
+
integers: boolean;
|
|
12
|
+
label: string;
|
|
13
|
+
description: string;
|
|
14
|
+
required: boolean;
|
|
15
|
+
};
|
|
16
|
+
export interface NumberFieldOptions extends ChildFieldOptions<number> {
|
|
17
|
+
maximum?: number;
|
|
18
|
+
minimum?: number;
|
|
19
|
+
integers?: boolean;
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare class NumberField extends BaseField<number, "number"> {
|
|
23
|
+
static readonly fieldTypeName = "Number";
|
|
24
|
+
static readonly fieldTypeDescription = "Allows specifying a number within a given range.";
|
|
25
|
+
readonly minimum: number | undefined;
|
|
26
|
+
readonly maximum: number | undefined;
|
|
27
|
+
readonly integers: boolean;
|
|
28
|
+
readonly placeholder: string;
|
|
29
|
+
static Icon: typeof RiHashtag;
|
|
30
|
+
constructor(options: NumberFieldOptions);
|
|
31
|
+
static _validateMin: (path: string) => InputValidator<number>;
|
|
32
|
+
static _validateMax: (path: string) => InputValidator<number>;
|
|
33
|
+
static getFieldCreationSchema(parentPath?: string): ({
|
|
34
|
+
field: NumberField;
|
|
35
|
+
showDirectly: boolean;
|
|
36
|
+
} | {
|
|
37
|
+
field: BooleanField;
|
|
38
|
+
showDirectly: boolean;
|
|
39
|
+
})[];
|
|
40
|
+
getFieldValidators(): InputFieldLevelValidator<number>[];
|
|
41
|
+
serialize(): SerializedNumberField;
|
|
42
|
+
static deserialize(data: ISerializedField): NumberField;
|
|
43
|
+
getInput(props: GetInputProps<this>): ReactNode;
|
|
44
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { RiQrCodeLine } from 'react-icons/ri';
|
|
3
|
+
import { ISerializedField, SerializedQrField } from '../../typings';
|
|
4
|
+
import { BaseField, ChildFieldOptions } from '../BaseField';
|
|
5
|
+
import { ComponentProps } from '../typings';
|
|
6
|
+
export declare const emptyQrField: {
|
|
7
|
+
type: string;
|
|
8
|
+
label: string;
|
|
9
|
+
description: string;
|
|
10
|
+
required: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare class QrField extends BaseField<string, "qr"> {
|
|
13
|
+
static readonly fieldTypeName = "QR";
|
|
14
|
+
static readonly fieldTypeDescription = "Used for scanning/reading QR codes.";
|
|
15
|
+
readonly onlyValidateAfterTouched = false;
|
|
16
|
+
static Icon: typeof RiQrCodeLine;
|
|
17
|
+
constructor(options: ChildFieldOptions<string>);
|
|
18
|
+
serialize(): SerializedQrField;
|
|
19
|
+
static deserialize(data: ISerializedField): QrField;
|
|
20
|
+
getInput(props: ComponentProps<QrField>): ReactNode;
|
|
21
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ComponentProps } from '../typings';
|
|
2
|
+
import { QrField } from './QrField';
|
|
3
|
+
export declare const QrInput: import('react').MemoExoticComponent<(props: ComponentProps<QrField>) => import("react/jsx-runtime").JSX.Element>;
|
|
4
|
+
interface QrScannerProps {
|
|
5
|
+
onQrScan: (data: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const QrScanner: import('react').MemoExoticComponent<(props: QrScannerProps) => import("react/jsx-runtime").JSX.Element>;
|
|
8
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FieldValue, SelectFieldOption } from
|
|
2
|
-
import { BaseField, ChildFieldOptions } from
|
|
3
|
-
import { MultiStringField } from
|
|
1
|
+
import { FieldValue, SelectFieldOption } from '../../typings';
|
|
2
|
+
import { BaseField, ChildFieldOptions } from '../BaseField';
|
|
3
|
+
import { MultiStringField } from '../MultiStringField';
|
|
4
4
|
/**
|
|
5
5
|
* The options passed to the constructor of SelectField.
|
|
6
6
|
*/
|
|
@@ -10,18 +10,25 @@ export interface BaseSelectFieldOptions<TValue, TIdentifier extends "select" | "
|
|
|
10
10
|
* where the `label` is the text to display to the user and the `value` is the value handled by Formik.*/
|
|
11
11
|
options: string[] | SelectFieldOption[];
|
|
12
12
|
type: TIdentifier;
|
|
13
|
+
placeholder?: string;
|
|
13
14
|
}
|
|
14
15
|
export declare abstract class BaseSelectField<TValue extends FieldValue, TIdentifier extends "select" | "multi-select"> extends BaseField<TValue, TIdentifier> {
|
|
15
16
|
readonly options: SelectFieldOption[];
|
|
16
17
|
readonly onlyValidateAfterTouched = false;
|
|
18
|
+
readonly placeholder: string;
|
|
17
19
|
protected constructor(options: BaseSelectFieldOptions<TValue, TIdentifier>);
|
|
18
20
|
protected _serialize(): {
|
|
19
21
|
options: SelectFieldOption[];
|
|
22
|
+
placeholder: string;
|
|
20
23
|
label: string;
|
|
21
24
|
required: boolean;
|
|
22
|
-
|
|
25
|
+
image?: File | Promise<File>;
|
|
26
|
+
description?: string | null;
|
|
23
27
|
identifier: string;
|
|
24
28
|
type: TIdentifier;
|
|
25
29
|
};
|
|
26
|
-
static getFieldCreationSchema():
|
|
30
|
+
static getFieldCreationSchema(parentPath?: string): {
|
|
31
|
+
field: MultiStringField;
|
|
32
|
+
showDirectly: boolean;
|
|
33
|
+
}[];
|
|
27
34
|
}
|
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { RiCheckboxLine } from 'react-icons/ri';
|
|
3
|
+
import { ISerializedField, SelectFieldOptionValue, SerializedMultiSelectField } from '../../typings';
|
|
4
|
+
import { GetInputProps } from '../typings';
|
|
5
|
+
import { BaseSelectField, BaseSelectFieldOptions } from './BaseSelectField';
|
|
6
6
|
/**
|
|
7
7
|
* The options passed to the constructor of MultiSelectField.
|
|
8
8
|
*/
|
|
9
9
|
export type MultiSelectFieldOptions = Omit<BaseSelectFieldOptions<SelectFieldOptionValue[], "multi-select">, "type">;
|
|
10
|
+
export declare const emptyMultiSelectField: {
|
|
11
|
+
type: string;
|
|
12
|
+
options: never[];
|
|
13
|
+
label: string;
|
|
14
|
+
description: string;
|
|
15
|
+
required: boolean;
|
|
16
|
+
};
|
|
10
17
|
export declare class MultiSelectField extends BaseSelectField<SelectFieldOptionValue[], "multi-select"> {
|
|
11
18
|
static readonly fieldTypeName = "Multi-select";
|
|
12
19
|
static readonly fieldTypeDescription = "Allows the user to select a multiple options from a list of options.";
|
|
13
|
-
static Icon: typeof
|
|
20
|
+
static Icon: typeof RiCheckboxLine;
|
|
14
21
|
constructor(options: MultiSelectFieldOptions);
|
|
15
|
-
|
|
16
|
-
|
|
22
|
+
protected isBlank(value: SelectFieldOptionValue[] | undefined): boolean;
|
|
23
|
+
isEqual(value1: SelectFieldOptionValue[] | undefined, value2: SelectFieldOptionValue[] | undefined): boolean;
|
|
17
24
|
serialize(): SerializedMultiSelectField;
|
|
18
25
|
static deserialize(data: ISerializedField): MultiSelectField;
|
|
19
26
|
getInput(props: GetInputProps<this>): ReactNode;
|
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { RiMenuFoldLine } from 'react-icons/ri';
|
|
3
|
+
import { ISerializedField, SelectFieldOptionValue, SerializedSelectField } from '../../typings';
|
|
4
|
+
import { GetInputProps } from '../typings';
|
|
5
|
+
import { BaseSelectField, BaseSelectFieldOptions } from './BaseSelectField';
|
|
6
6
|
/**
|
|
7
7
|
* The options passed to the constructor of SelectField.
|
|
8
8
|
*/
|
|
9
9
|
export type SelectFieldOptions = Omit<BaseSelectFieldOptions<SelectFieldOptionValue, "select">, "type">;
|
|
10
|
+
export declare const emptySelectField: {
|
|
11
|
+
type: string;
|
|
12
|
+
options: never[];
|
|
13
|
+
label: string;
|
|
14
|
+
description: string;
|
|
15
|
+
required: boolean;
|
|
16
|
+
};
|
|
10
17
|
export declare class SelectField extends BaseSelectField<SelectFieldOptionValue, "select"> {
|
|
11
18
|
static readonly fieldTypeName = "Dropdown";
|
|
12
19
|
static readonly fieldTypeDescription = "Allows the user to select a single option from a list of options.";
|
|
13
|
-
static Icon: typeof
|
|
20
|
+
static Icon: typeof RiMenuFoldLine;
|
|
14
21
|
constructor(options: SelectFieldOptions);
|
|
15
|
-
getValueFromChangeEvent(event: React.ChangeEvent<HTMLInputElement> | string): SelectFieldOptionValue;
|
|
16
22
|
serialize(): SerializedSelectField;
|
|
17
23
|
static deserialize(data: ISerializedField): SelectField;
|
|
18
24
|
getInput(props: GetInputProps<this>): ReactNode;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { RiInputField } from 'react-icons/ri';
|
|
3
|
+
import { ISerializedField, SerializedStringField, StringInputType } from '../../../typings';
|
|
4
|
+
import { GetInputProps } from '../../typings';
|
|
5
|
+
import { StringOrTextField, StringOrTextFieldOptions } from '../StringOrTextField';
|
|
6
|
+
export interface StringFieldOptions extends Omit<StringOrTextFieldOptions, "type"> {
|
|
7
|
+
inputType?: StringInputType;
|
|
8
|
+
}
|
|
9
|
+
export declare const emptyStringField: {
|
|
10
|
+
type: string;
|
|
11
|
+
maximum_length: number;
|
|
12
|
+
input_type: string;
|
|
13
|
+
label: string;
|
|
14
|
+
description: string;
|
|
15
|
+
required: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare class StringField extends StringOrTextField<"string"> {
|
|
18
|
+
static readonly fieldTypeName = "Short Text";
|
|
19
|
+
static readonly fieldTypeDescription = "Short text fields can hold up to 500 characters on a single line.";
|
|
20
|
+
readonly inputType: StringInputType;
|
|
21
|
+
static Icon: typeof RiInputField;
|
|
22
|
+
constructor(options: StringFieldOptions);
|
|
23
|
+
serialize(): SerializedStringField;
|
|
24
|
+
static deserialize(data: ISerializedField): StringField;
|
|
25
|
+
getInput(props: GetInputProps<this>): ReactNode;
|
|
26
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseField, FieldOptions } from
|
|
3
|
-
import {
|
|
1
|
+
import { SerializedStringField } from '../../typings';
|
|
2
|
+
import { BaseField, FieldOptions } from '../BaseField';
|
|
3
|
+
import { NumberField } from '../NumberField';
|
|
4
4
|
import { InputFieldLevelValidator, InputValidator } from '../typings';
|
|
5
5
|
export interface StringOrTextFieldOptions extends FieldOptions<string> {
|
|
6
|
-
minLength?:
|
|
7
|
-
maxLength?:
|
|
6
|
+
minLength?: number;
|
|
7
|
+
maxLength?: number;
|
|
8
|
+
placeholder?: string;
|
|
8
9
|
}
|
|
9
10
|
export type SerializedStringOrTextField<TIdentifier extends "string" | "text"> = Omit<SerializedStringField, "type"> & {
|
|
10
11
|
type: TIdentifier;
|
|
@@ -12,18 +13,22 @@ export type SerializedStringOrTextField<TIdentifier extends "string" | "text"> =
|
|
|
12
13
|
export declare abstract class StringOrTextField<TIdentifier extends "string" | "text"> extends BaseField<string, TIdentifier> {
|
|
13
14
|
readonly minLength?: number;
|
|
14
15
|
readonly maxLength: number;
|
|
16
|
+
readonly placeholder: string;
|
|
15
17
|
protected constructor(options: StringOrTextFieldOptions);
|
|
16
18
|
/**
|
|
17
|
-
* This function validates that the value given for "minimum length" (when creating a new field) is less than or
|
|
19
|
+
* This function returns a function that validates that the value given for "minimum length" (when creating a new field) is less than or
|
|
18
20
|
* equal to the value given for "maximum length".
|
|
19
21
|
*/
|
|
20
|
-
static _validateMin: InputValidator<
|
|
22
|
+
static _validateMin: (path: string) => InputValidator<number>;
|
|
21
23
|
/**
|
|
22
|
-
* This function validates that the value given for "maximum length" (when creating a new field) is greater than or
|
|
24
|
+
* This function returns a function that validates that the value given for "maximum length" (when creating a new field) is greater than or
|
|
23
25
|
* equal to the value given for "minimum length".
|
|
24
26
|
*/
|
|
25
|
-
static _validateMax: InputValidator<
|
|
26
|
-
static getFieldCreationSchema():
|
|
27
|
+
static _validateMax: (path: string) => InputValidator<number>;
|
|
28
|
+
static getFieldCreationSchema(parentPath?: string): {
|
|
29
|
+
field: NumberField;
|
|
30
|
+
showDirectly: boolean;
|
|
31
|
+
}[];
|
|
27
32
|
getFieldValidators(): InputFieldLevelValidator<string>[];
|
|
28
33
|
protected _serialize(): SerializedStringOrTextField<TIdentifier>;
|
|
29
34
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { RiAlignJustify } from 'react-icons/ri';
|
|
3
|
+
import { ISerializedField, SerializedTextField } from '../../../typings';
|
|
4
|
+
import { GetInputProps } from '../../typings';
|
|
5
|
+
import { StringOrTextField, StringOrTextFieldOptions } from '../StringOrTextField';
|
|
6
|
+
export type TextFieldOptions = Omit<StringOrTextFieldOptions, "type">;
|
|
7
|
+
export declare const emptyTextField: {
|
|
8
|
+
type: string;
|
|
9
|
+
maximum_length: number;
|
|
10
|
+
label: string;
|
|
11
|
+
description: string;
|
|
12
|
+
required: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare class TextField extends StringOrTextField<"text"> {
|
|
15
|
+
static readonly fieldTypeName = "Paragraph";
|
|
16
|
+
static readonly fieldTypeDescription = "Paragraph fields can hold up to 10000 characters and can have multiple lines.";
|
|
17
|
+
static Icon: typeof RiAlignJustify;
|
|
18
|
+
constructor(options: TextFieldOptions);
|
|
19
|
+
serialize(): SerializedTextField;
|
|
20
|
+
static deserialize(data: ISerializedField): TextField;
|
|
21
|
+
getInput(props: GetInputProps<this>): ReactNode;
|
|
22
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { RiUpload2Line } from 'react-icons/ri';
|
|
3
|
+
import { ISerializedField, SerializedUploadField } from '../../typings';
|
|
4
|
+
import { BaseField, ChildFieldOptions } from '../BaseField';
|
|
5
|
+
import { NumberField } from '../NumberField';
|
|
6
|
+
import { MultiSelectField } from '../SelectField';
|
|
7
|
+
import { GetInputProps, InputFieldLevelValidator } from '../typings';
|
|
8
|
+
export interface UploadFieldOptions extends ChildFieldOptions<File[]> {
|
|
9
|
+
extensions?: string[];
|
|
10
|
+
maximum_size?: number | string;
|
|
11
|
+
maximum_files?: number | string;
|
|
12
|
+
}
|
|
13
|
+
export declare const emptyUploadField: {
|
|
14
|
+
type: string;
|
|
15
|
+
extensions: never[];
|
|
16
|
+
maximum_size: undefined;
|
|
17
|
+
maximum_files: number;
|
|
18
|
+
label: string;
|
|
19
|
+
description: string;
|
|
20
|
+
required: boolean;
|
|
21
|
+
};
|
|
22
|
+
export declare class UploadField extends BaseField<File[], "upload"> {
|
|
23
|
+
static readonly fieldTypeName = "Upload";
|
|
24
|
+
static readonly fieldTypeDescription = "Allows a file to be uploaded.";
|
|
25
|
+
readonly extensions?: string[];
|
|
26
|
+
readonly maxFileSize: number | undefined;
|
|
27
|
+
readonly maxFiles: number;
|
|
28
|
+
readonly onlyValidateAfterTouched = false;
|
|
29
|
+
static Icon: typeof RiUpload2Line;
|
|
30
|
+
constructor(options: UploadFieldOptions);
|
|
31
|
+
protected isBlank(value: File[] | undefined): boolean;
|
|
32
|
+
isEqual(value1: File[] | undefined, value2: File[] | undefined): boolean;
|
|
33
|
+
static getFieldCreationSchema(parentPath?: string): ({
|
|
34
|
+
field: NumberField;
|
|
35
|
+
showDirectly: boolean;
|
|
36
|
+
} | {
|
|
37
|
+
field: MultiSelectField;
|
|
38
|
+
showDirectly: boolean;
|
|
39
|
+
})[];
|
|
40
|
+
getFieldValidators(): InputFieldLevelValidator<File[]>[];
|
|
41
|
+
serialize(): SerializedUploadField;
|
|
42
|
+
static deserialize(data: ISerializedField): UploadField;
|
|
43
|
+
getInput(props: GetInputProps<this>): ReactNode;
|
|
44
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { BooleanField } from './BooleanField';
|
|
2
|
+
import { CustomField } from './CustomField';
|
|
3
|
+
import { DateField } from './DateField';
|
|
4
|
+
import { MultiStringField } from './MultiStringField';
|
|
5
|
+
import { NumberField } from './NumberField';
|
|
6
|
+
import { QrField } from './QrField';
|
|
7
|
+
import { MultiSelectField, SelectField } from './SelectField';
|
|
8
|
+
import { StringField, TextField } from './StringOrTextFields';
|
|
9
|
+
import { UploadField } from './UploadField';
|
|
10
|
+
export declare const FieldTypeToClsMapping: {
|
|
11
|
+
readonly date: typeof DateField;
|
|
12
|
+
readonly number: typeof NumberField;
|
|
13
|
+
readonly boolean: typeof BooleanField;
|
|
14
|
+
readonly select: typeof SelectField;
|
|
15
|
+
readonly string: typeof StringField;
|
|
16
|
+
readonly text: typeof TextField;
|
|
17
|
+
readonly custom: typeof CustomField;
|
|
18
|
+
readonly upload: typeof UploadField;
|
|
19
|
+
readonly qr: typeof QrField;
|
|
20
|
+
readonly "multi-string": typeof MultiStringField;
|
|
21
|
+
readonly "multi-select": typeof MultiSelectField;
|
|
22
|
+
};
|
|
23
|
+
export declare const FieldTypeToEmptyFieldMapping: {
|
|
24
|
+
readonly date: {
|
|
25
|
+
type: string;
|
|
26
|
+
label: string;
|
|
27
|
+
description: string;
|
|
28
|
+
required: boolean;
|
|
29
|
+
};
|
|
30
|
+
readonly number: {
|
|
31
|
+
type: string;
|
|
32
|
+
minimum: number;
|
|
33
|
+
maximum: number;
|
|
34
|
+
integers: boolean;
|
|
35
|
+
label: string;
|
|
36
|
+
description: string;
|
|
37
|
+
required: boolean;
|
|
38
|
+
};
|
|
39
|
+
readonly boolean: {
|
|
40
|
+
type: string;
|
|
41
|
+
label: string;
|
|
42
|
+
description: string;
|
|
43
|
+
required: boolean;
|
|
44
|
+
};
|
|
45
|
+
readonly select: {
|
|
46
|
+
type: string;
|
|
47
|
+
options: never[];
|
|
48
|
+
label: string;
|
|
49
|
+
description: string;
|
|
50
|
+
required: boolean;
|
|
51
|
+
};
|
|
52
|
+
readonly string: {
|
|
53
|
+
type: string;
|
|
54
|
+
maximum_length: number;
|
|
55
|
+
input_type: string;
|
|
56
|
+
label: string;
|
|
57
|
+
description: string;
|
|
58
|
+
required: boolean;
|
|
59
|
+
};
|
|
60
|
+
readonly text: {
|
|
61
|
+
type: string;
|
|
62
|
+
maximum_length: number;
|
|
63
|
+
label: string;
|
|
64
|
+
description: string;
|
|
65
|
+
required: boolean;
|
|
66
|
+
};
|
|
67
|
+
readonly custom: {
|
|
68
|
+
type: string;
|
|
69
|
+
label: string;
|
|
70
|
+
description: string;
|
|
71
|
+
required: boolean;
|
|
72
|
+
};
|
|
73
|
+
readonly upload: {
|
|
74
|
+
type: string;
|
|
75
|
+
extensions: never[];
|
|
76
|
+
maximum_size: undefined;
|
|
77
|
+
maximum_files: number;
|
|
78
|
+
label: string;
|
|
79
|
+
description: string;
|
|
80
|
+
required: boolean;
|
|
81
|
+
};
|
|
82
|
+
readonly qr: {
|
|
83
|
+
type: string;
|
|
84
|
+
label: string;
|
|
85
|
+
description: string;
|
|
86
|
+
required: boolean;
|
|
87
|
+
};
|
|
88
|
+
readonly "multi-string": {
|
|
89
|
+
type: string;
|
|
90
|
+
minimum_length: number;
|
|
91
|
+
maximum_length: null;
|
|
92
|
+
label: string;
|
|
93
|
+
description: string;
|
|
94
|
+
required: boolean;
|
|
95
|
+
};
|
|
96
|
+
readonly "multi-select": {
|
|
97
|
+
type: string;
|
|
98
|
+
options: never[];
|
|
99
|
+
label: string;
|
|
100
|
+
description: string;
|
|
101
|
+
required: boolean;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
export declare const maxFileSizeMB = 50;
|
|
105
|
+
export declare const maxFileSizeKB: number;
|
|
106
|
+
export declare const maxFileSizeB: number;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { FieldValue } from '../typings';
|
|
3
|
+
import { BaseField, BaseFormElement } from './BaseField';
|
|
4
|
+
import { GetInputProps } from './typings';
|
|
5
|
+
export declare const useFieldInput: <TField extends BaseFormElement | null>(field: TField, props: TField extends BaseFormElement ? GetInputProps<TField> : null) => ReactNode;
|
|
6
|
+
export declare const useFieldInputs: (fields: BaseFormElement[], props: GetInputProps<BaseField<FieldValue>>) => ReactNode;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './BaseField';
|
|
2
|
+
export * from './BooleanField';
|
|
3
|
+
export * from './DateField';
|
|
4
|
+
export * from './FieldSection';
|
|
5
|
+
export * from './hooks';
|
|
6
|
+
export * from './MultiStringField';
|
|
7
|
+
export * from './NumberField';
|
|
8
|
+
export * from './QrField';
|
|
9
|
+
export * from './SelectField';
|
|
10
|
+
export * from './StringOrTextFields';
|
|
11
|
+
export * from './typings';
|
|
12
|
+
export * from './utils';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { TextSize } from '@overmap-ai/blocks';
|
|
2
|
+
import { HTMLProps, ReactNode } from 'react';
|
|
3
|
+
import { FormikFormRevision } from '../builder';
|
|
4
|
+
import { FormValues, ValueOfField } from '../typings';
|
|
5
|
+
import { BaseField, BaseFormElement } from './BaseField';
|
|
5
6
|
export interface SchemaMeta {
|
|
6
7
|
readonly: boolean;
|
|
7
8
|
}
|
|
@@ -13,12 +14,14 @@ export interface ISchema {
|
|
|
13
14
|
description?: ReactNode;
|
|
14
15
|
}
|
|
15
16
|
export type InputFieldLevelValidator<TValue> = (value: TValue | undefined) => string | null | undefined;
|
|
16
|
-
export type InputFormLevelValidator<TValue> = (value: TValue | undefined, allValues:
|
|
17
|
+
export type InputFormLevelValidator<TValue> = (value: TValue | undefined, allValues: FormValues | FormikFormRevision) => string | null | undefined;
|
|
17
18
|
export type InputValidator<TValue> = InputFieldLevelValidator<TValue> | InputFormLevelValidator<TValue>;
|
|
18
19
|
export interface ComponentProps<TField extends BaseFormElement> extends Omit<HTMLProps<HTMLElement>, "color" | "size" | "ref" | "type" | "onChange" | "onBlur" | "value" | "defaultValue" | "name" | "dir"> {
|
|
19
20
|
field: TField;
|
|
20
21
|
formId: string;
|
|
22
|
+
size?: TextSize;
|
|
23
|
+
onValuesChange?: (identifier: string, value: ValueOfField<AnyField>) => void;
|
|
24
|
+
showInputOnly?: boolean;
|
|
21
25
|
}
|
|
22
26
|
export type GetInputProps<TField extends BaseFormElement> = Omit<ComponentProps<TField>, "field">;
|
|
23
|
-
export type AnyField = BaseField<any>;
|
|
24
|
-
export type ISerializedOnlyField = Exclude<ISerializedField, SerializedFieldSection>;
|
|
27
|
+
export type AnyField = BaseField<any, any>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FormRevision, ISerializedOnlyField } from '@overmap-ai/core';
|
|
2
|
+
import { FieldValue, ISerializedField, SerializedCondition } from '../typings';
|
|
3
|
+
import { FieldSection } from './FieldSection';
|
|
4
|
+
import { AnyField, ISchema, SchemaMeta } from './typings';
|
|
5
|
+
/** Deserializes anything but a FieldSection.
|
|
6
|
+
* @see `deserialize` for most use cases
|
|
7
|
+
*/
|
|
8
|
+
export declare const deserializeField: (serializedField: ISerializedOnlyField) => AnyField;
|
|
9
|
+
/** Deserializes anything */
|
|
10
|
+
export declare const deserialize: (serialized: ISerializedField) => AnyField | FieldSection;
|
|
11
|
+
export type PartialFormRevision = Pick<FormRevision, "title" | "fields" | "description"> & Partial<FormRevision>;
|
|
12
|
+
export declare function formRevisionToSchema(formRevision: PartialFormRevision, meta?: Partial<SchemaMeta>): ISchema;
|
|
13
|
+
export declare function flattenFields(schema: ISchema): AnyField[];
|
|
14
|
+
export declare function getFieldsMapping(schema: ISchema): Record<string, AnyField>;
|
|
15
|
+
export declare function decodeFormValues(schema: ISchema, values: Record<string, string>): Record<string, FieldValue>;
|
|
16
|
+
export declare function encodeFormValues(schema: ISchema, values: Record<string, FieldValue>): Record<string, string>;
|
|
17
|
+
export declare function valueIsFile(v: FieldValue | Promise<File>[] | undefined): v is File[] | Promise<File>[];
|
|
18
|
+
export declare function isConditionMet<TValue extends FieldValue | Promise<File>[]>(condition: TValue extends FieldValue ? SerializedCondition<TValue> | null : null, value: TValue): boolean;
|