@bolttech/form-engine 0.14.3 → 3.0.0-beta.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/README.md +2 -1628
- package/index.esm.d.ts +1 -0
- package/index.esm.js +1683 -0
- package/package.json +15 -16
- package/src/components/AsFormField/AsFormField.d.ts +4 -0
- package/src/components/FieldWrapper/FieldWrapper.d.ts +4 -0
- package/src/components/Form/Form.d.ts +4 -0
- package/src/components/index.d.ts +2 -0
- package/src/context/FormGroupContext.d.ts +27 -0
- package/src/generators/formBuilder.d.ts +11 -0
- package/src/index.d.ts +3 -3
- package/src/types/index.d.ts +47 -0
- package/CHANGELOG.md +0 -529
- package/asFormField-3108e669.js +0 -2
- package/asFormField-3108e669.js.map +0 -1
- package/index.js +0 -2
- package/index.js.map +0 -1
- package/react.js +0 -2
- package/react.js.map +0 -1
- package/src/adapters/react/Field.d.ts +0 -4
- package/src/adapters/react/Form.d.ts +0 -5
- package/src/adapters/react/Submit.d.ts +0 -3
- package/src/adapters/react/asFormField.d.ts +0 -4
- package/src/adapters/react/context.d.ts +0 -5
- package/src/adapters/react/index.d.ts +0 -7
- package/src/adapters/react/types.d.ts +0 -326
- package/src/adapters/react/useForceUpdate.d.ts +0 -3
- package/src/adapters/react/useForm.d.ts +0 -12
- package/src/adapters/react/useFormGroup.d.ts +0 -3
- package/src/core/apis/formatters.d.ts +0 -16
- package/src/core/apis/index.d.ts +0 -4
- package/src/core/apis/masks.d.ts +0 -3
- package/src/core/apis/validations.d.ts +0 -11
- package/src/core/apis/varOps.d.ts +0 -4
- package/src/core/constants/events.d.ts +0 -32
- package/src/core/constants/index.d.ts +0 -5
- package/src/core/constants/observer.d.ts +0 -7
- package/src/core/events/ObserverError.d.ts +0 -7
- package/src/core/events/events.types.d.ts +0 -27
- package/src/core/events/index.d.ts +0 -2
- package/src/core/handlers/common/templating.d.ts +0 -2
- package/src/core/handlers/field/api.d.ts +0 -4
- package/src/core/handlers/field/blur.d.ts +0 -2
- package/src/core/handlers/field/change.d.ts +0 -2
- package/src/core/handlers/field/clearFields.d.ts +0 -4
- package/src/core/handlers/field/data.d.ts +0 -3
- package/src/core/handlers/field/filter.d.ts +0 -2
- package/src/core/handlers/field/focus.d.ts +0 -2
- package/src/core/handlers/field/formatters.d.ts +0 -4
- package/src/core/handlers/field/htmlEventParser.d.ts +0 -6
- package/src/core/handlers/field/keydown.d.ts +0 -2
- package/src/core/handlers/field/keyup.d.ts +0 -2
- package/src/core/handlers/field/masks.d.ts +0 -4
- package/src/core/handlers/field/mount.d.ts +0 -2
- package/src/core/handlers/field/validations.d.ts +0 -4
- package/src/core/handlers/field/visibilityConditions.d.ts +0 -4
- package/src/core/handlers/flows.d.ts +0 -47
- package/src/core/handlers/form/bindFields.d.ts +0 -3
- package/src/core/handlers/form/hooks.d.ts +0 -3
- package/src/core/handlers/form/steps.d.ts +0 -2
- package/src/core/handlers/form/templating.d.ts +0 -2
- package/src/core/handlers/form/validate.d.ts +0 -2
- package/src/core/handlers/form/visibilityConditions.d.ts +0 -4
- package/src/core/index.d.ts +0 -3
- package/src/core/managers/Base.d.ts +0 -19
- package/src/core/managers/Factory.d.ts +0 -52
- package/src/core/managers/Field.d.ts +0 -33
- package/src/core/managers/Form.d.ts +0 -28
- package/src/core/managers/Scope.d.ts +0 -12
- package/src/core/managers/index.d.ts +0 -1
- package/src/core/types/index.d.ts +0 -937
- package/src/core/utils/common.d.ts +0 -9
- package/src/core/utils/credit-card.d.ts +0 -16
- package/src/core/utils/index.d.ts +0 -6
- package/src/core/utils/object.d.ts +0 -27
- package/src/core/utils/string.d.ts +0 -3
- package/src/core/utils/value.d.ts +0 -2
- package/types.js +0 -2
- package/types.js.map +0 -1
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import Scope from '@core/managers/Scope';
|
|
2
|
-
declare const template: {
|
|
3
|
-
BEGIN: string;
|
|
4
|
-
END: string;
|
|
5
|
-
DEFAULT_SPLITTER: string;
|
|
6
|
-
};
|
|
7
|
-
declare const getScopedField: <T>(scope: T, childrenScope?: string[]) => T;
|
|
8
|
-
declare const extractTargetString: <T>(target: string, formScope: Scope, scope?: Scope) => T;
|
|
9
|
-
export { getScopedField, extractTargetString, template };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export interface ICreditCardType {
|
|
2
|
-
niceType: string;
|
|
3
|
-
type: string;
|
|
4
|
-
patterns: number[] | [number[]];
|
|
5
|
-
gaps: number[];
|
|
6
|
-
lengths: number[];
|
|
7
|
-
code: {
|
|
8
|
-
size: number;
|
|
9
|
-
name: string;
|
|
10
|
-
};
|
|
11
|
-
matchStrength?: number;
|
|
12
|
-
}
|
|
13
|
-
declare type TGetTypeCard = [ICreditCardType, string];
|
|
14
|
-
export declare const getTypeCard: (value: string, availableOptions?: string[]) => TGetTypeCard;
|
|
15
|
-
export declare const formatValue: (value: string, type: ICreditCardType) => string;
|
|
16
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export * as object from '@core/utils/object';
|
|
2
|
-
export * as creditCard from '@core/utils/credit-card';
|
|
3
|
-
export type { ICreditCardType } from '@core/utils/credit-card';
|
|
4
|
-
export * as string from '@core/utils/string';
|
|
5
|
-
export * as common from '@core/utils/common';
|
|
6
|
-
export * as value from '@core/utils/value';
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import Form from '@core/managers/Form';
|
|
2
|
-
import Field from '@core/managers/Field';
|
|
3
|
-
/**
|
|
4
|
-
* Encapsulates in a given object, at a given path the provided value
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ORIGINAL object
|
|
8
|
-
*
|
|
9
|
-
* encapsulateIn({maintain: 'spread_me'}, 'a.b.c','test')
|
|
10
|
-
*
|
|
11
|
-
* RESULT
|
|
12
|
-
*
|
|
13
|
-
* {
|
|
14
|
-
* maintain: 'spread_me',
|
|
15
|
-
* c: 'test
|
|
16
|
-
* }
|
|
17
|
-
* }
|
|
18
|
-
*
|
|
19
|
-
* @param origin - The original object where the new value will be appended
|
|
20
|
-
* @param path - The path at which the new value will be placed
|
|
21
|
-
* @param value - The new value
|
|
22
|
-
* @param form - The form instance to be used on extract string
|
|
23
|
-
* @param field - The field instance to be used on extract string
|
|
24
|
-
* @returns One new object with the new value at the provided path merged with the given object
|
|
25
|
-
*/
|
|
26
|
-
declare const encapsulateIn: (origin: Record<string, unknown>, path: string, value: string, form: Form, field: Field) => Record<string, unknown>;
|
|
27
|
-
export { encapsulateIn };
|
package/types.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),exports.TAvailableHooks=void 0,(e=exports.TAvailableHooks||(exports.TAvailableHooks={})).preMount="preMount",e.preUnmount="preUnmount",e.preSubmit="preSubmit",e.postSubmit="postSubmit";
|
|
2
|
-
//# sourceMappingURL=types.js.map
|
package/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../libs/form-engine/src/core/types/index.ts"],"sourcesContent":["import { ICustomValidationValue } from '@core/apis/validations';\nimport { EEVents } from '@core/constants';\nimport { TEventInformation } from '@core/events';\nimport Field from \"@core/managers/Field\";\n\nexport type TObserverData<T> = {\n data: any;\n event: TEventsKeys;\n namespace: string;\n payload: T;\n};\n\nexport type TObservable = (data: any, unsubscribe: () => void) => any;\n\nexport type TEvents = Record<string, TObservable[]>;\n\nexport interface IObservable {\n events: TEvents;\n}\n\nexport type TScopeNamespaces =\n | 'global'\n | 'api'\n | 'hooks'\n | 'fields'\n | 'configs';\n\nexport type TSetGlobalScope = {\n namespace: TScopeNamespaces;\n key?: string;\n data: any;\n merge?: boolean;\n};\nexport type TScope = {\n global?: any;\n api?: any;\n hooks?: any;\n configs?: TConfigs & {\n disable?: boolean;\n enableLogging?: boolean;\n };\n fields?: any;\n};\n\nexport type TFactoryOptions = {\n schema?: TSchema;\n initialScope?: TScope;\n initialValues?: Record<string, any>;\n newInstance?: boolean;\n group?: string;\n};\n\nexport type TMapper = Record<string, Record<string, unknown>>;\n\nexport type TMaskGeneric = {\n to: number;\n from: number;\n mask: string;\n}[];\n\ntype TCurrencyMask = {\n locale: string;\n currency: string;\n};\n\nexport type TComponentMasks = {\n generic?: TMaskGeneric;\n cardNumber?: boolean;\n hideCardNumber?: boolean;\n cardMask?: boolean;\n cardDate?: boolean;\n currencyMask?: TCurrencyMask;\n feinMask?: boolean;\n replaceAll?: string | number;\n callback?(value: string | number): string | number;\n};\n\ntype TFormMessages = Record<\n string,\n { name: string; value?: any; values?: string[]; required?: boolean }\n>;\n\nexport type TChildrenOptions = {\n childrenScope?: string[];\n blurredChildren?: string[];\n changedChildren?: string[];\n scopeBlurredChildren?: boolean;\n scopeChangedChildren?: boolean;\n};\n\nexport type TFieldData = Record<string, TField>;\nexport type TFields = { [x in string]: Field };\n\nexport type TSubmitValueData = Record<string, {\n value?: unknown,\n props?: Record<string,unknown>,\n}>\n\nexport type TFormRefActions = {\n submit(): void;\n step(index: number | string): TFormValues;\n stepForward(index?: number | string): TFormValues;\n stepBack(index?: number | string): TFormValues;\n validateForm(opts?: TChildrenOptions): Promise<TFormValues>;\n bindFields(payload: TSubmitValueData): void;\n values(\n opts: Pick<\n TChildrenOptions,\n 'scopeBlurredChildren' | 'scopeChangedChildren' | 'childrenScope'\n >,\n ): TFormValues;\n};\n\nexport type THookPayload = {\n setScope(data: TSetGlobalScope): void;\n};\n\nexport type THooks = {\n preMount?: () => Record<string, unknown>;\n preUnmount?: () => Record<string, unknown>;\n preSubmit?: (formData: TFormValues) => Record<string, unknown>;\n posSubmit?: (formData: TFormValues) => Record<string, unknown>;\n};\n\nexport type TIVars = Record<string, unknown>;\n\nexport type TEventsKeys = keyof typeof EEVents;\nexport enum TAvailableHooks {\n 'preMount' = 'preMount',\n 'preUnmount' = 'preUnmount',\n 'preSubmit' = 'preSubmit',\n 'postSubmit' = 'postSubmit',\n}\nexport type TField = {\n value?: string | number | boolean;\n errors?: TErrors;\n visible?: boolean;\n failedErrorMessages?: string[];\n mask?: string;\n changed?: boolean;\n keyup?: boolean;\n keydown?: boolean;\n blured?: boolean;\n focused?: boolean;\n name: string;\n mounted: boolean;\n metadata?: any;\n ignore?: boolean;\n schemaLocation?: {\n step: number;\n depth: number;\n index: number;\n };\n};\n\ntype TPathError = Omit<TSchemaValidation, 'path'> & {\n path?: string;\n paths?: string[];\n preventUnMountValidation?: boolean;\n};\n\nexport type TValidationDateFormats =\n | 'MMDDYYYY'\n | 'DDMMYYYY'\n | 'YYYYMMDD'\n | 'YYYYDDMM'\n | 'timestamp';\nexport type TValidationDateOperators = '<' | '>' | '===' | '>=' | '<=' | '!==' | '!!origin';\n\nexport type TVAvailableValidationConditionsSet = {\n forceDefinedOrigin?: boolean;\n forceDefinedTarget?: boolean;\n origin?: string | number | boolean;\n condition: TValidationDateOperators;\n target?: string | number | boolean;\n};\n\nexport type TVAvailableValidationConditions = {\n rule: 'and' | 'or';\n set: TVAvailableValidationConditionsSet[];\n conditions?: TVAvailableValidationConditions;\n};\n\nexport type TVAvailableValidationMultipleValidations = {\n rule: 'AND' | 'OR' | 'NOT';\n validations: TVAvailableValidations;\n};\n\nexport type TVAvailableValidations = {\n /**\n * The bool function is a validation function that checks if a given value indicating whether the validation has failed or not.\n *\n * @example - in a test environment\n * ```\n * const result = bool({\n * validationValue: false,\n * });\n * console.log(result); // { fail: false }\n * ```\n *\n * @example - real json usage with field value\n * ```\n * {\n * validations: {\n * bool: '${fields.input.value}'\n * },\n * },\n * ```\n *\n * @example - real json usage with iVar value\n * ```\n * {\n * validations: {\n * bool: '${global.validation}'\n * },\n * },\n * ```\n */\n bool?: string | boolean;\n /**\n * Validation based on conditions\n *\n * @example - Compare own field to two. Origin and target default to field value\n * ```\n * conditions: {\n * rule: 'and',\n * set: [\n * {\n * condition: '===',\n * target: '2',\n * },\n * {\n * origin: '2',\n * condition: '===',\n * },\n * ],\n * },\n * ```\n * @example - Binded to Postcode field value. Must be greater than or equal two\n * ```\n * conditions: {\n * rule: 'or',\n * set: [\n * {\n * origin: '${fields.postcode.value}',\n * condition: '>',\n * target: '2',\n * },\n * {\n * origin: '${fields.postcode.value}',\n * condition: '===',\n * target: '2',\n * },\n * ],\n * },\n * ```\n * @example - Binded to Postcode field value. Must be equal to two\n * ```\n * conditions: {\n * rule: 'or',\n * set: [\n * {\n * origin: '${fields.postcode.value}',\n * condition: '===',\n * target: '2',\n * },\n * ],\n * },\n * ```\n */\n conditions?: TVAvailableValidationConditions;\n /**\n * Applies multiple validations on the given value based on the specified truth table rule.\n *\n * @param {Object} TVAvailableValidationMultipleValidations - The multiple validations object param.\n * @param {'AND' | 'OR' | 'NOT'} TVAvailableValidationMultipleValidations.rule - The rule to be applied based of truth table ('AND', 'OR', or 'NOT').\n * @param {Object} TVAvailableValidationMultipleValidations.validations - Object containing validation rules.\n *\n * @example - Validating with the expression AND where current field must have a value of 'yes' and input 2 must have a value of 'no'\n * ```\n * multipleValidations: {\n * rule: 'AND',\n * validations: {\n * value: 'yes',\n * conditions: {\n * rule: 'and',\n * set: [\n * {\n * origin: '${fields.input2.value}',\n * condition: '===',\n * target: 'no'\n * },\n * ],\n * },\n * },\n * },\n * ```\n * @example - Validating with the expression OR where current field must have a value of '1995-12-12' or be a valid date with regex\n * ```\n * multipleValidations: {\n * rule: 'OR',\n * validations: {\n * value: '1995-12-12',\n * regex: '^\\d{4}-\\d{2}-\\d{2}$',\n * },\n * },\n * ```\n * @example - Validating with the expression NOT where current field doesn't have a value of '1995-12-12' and not be a valid date with regex\n * ```\n * multipleValidations: {\n * rule: 'NOT',\n * validations: {\n * value: '1995-12-12',\n * regex: '^\\d{4}-\\d{2}-\\d{2}$',\n * },\n * },\n * ```\n */\n multipleValidations?: TVAvailableValidationMultipleValidations;\n /**\n * Between validations\n *\n * @example - Between ages\n * ``` type teste = Pick<TVAvailableValidations, 'date'>\n * between: {\n * dates: [\n * {\n * operator: '>=',\n * origin: {\n * format: 'YYYYMMDD',\n * intervals: {\n * years: 18,\n * },\n * },\n * },\n * {\n * operator: '<=',\n * origin: {\n * format: 'YYYYMMDD',\n * intervals: {\n * years: 75,\n * },\n * },\n * }\n * ]\n * }\n * ```\n *\n * @example - Between numbers\n * ```\n * between: {\n * start: '3',\n * end: '4',\n * isIncludedBoundaries: true\n * },\n * ```\n *\n */\n between?: {\n /**\n * Array of date validations. To make it possible, ensure that the conditions is > and < in both date validations.\n */\n dates?: TVAvailableValidations['date'][];\n /**\n * The first number of the validation. If the current value is grater than this number, the validation will pass.\n */\n start?: number;\n /**\n * The second number of the validation. If the current value is lower than this number, the validation will pass.\n */\n end?: number;\n /**\n * If it's true, the comparision is transformed to >= and <=. So, the numbers that were passed are included in the validation.\n */\n isIncludedBoundaries?: boolean;\n };\n /**\n * Dates validations\n *\n * @example - Dates should be different\n * ```\n * date: {\n * operator: '!==',\n * origin: {\n * format: 'DDMMYYYY',\n * },\n * target: {\n * format: 'DDMMYYYY',\n * value: '10/10/2001',\n * },\n * },*\n * ```\n *\n * @example - Compare only valid dates using intervals\n * ```\n * date: {\n * onlyValidDate: true,\n * operator: '<',\n * origin: {\n * format: 'DD/MM/YYYY',\n * intervals: {\n * years: 1,\n * },\n * },\n * },\n * ```\n *\n * @example - Should have at max 85 years\n * ```\n * {\n * operator: '>',\n * origin: {\n * format: 'DDMMYYYY',\n * value: eightyFiveYearsDate,\n * intervals: {\n * years: 85,\n * },\n * },\n * }\n * }\n *\n * ```\n */\n date?: {\n /**\n * Flag to force only valid dates. Valid dates must be of min length of 8\n */\n onlyValidDate?: boolean;\n /**\n * List of operations you can do\n * - between origin and target dates\n * - between origin and intervals\n */\n operator: TValidationDateOperators;\n /**\n * The origin configurations\n */\n origin: {\n /**\n * Origin date value\n */\n value?: string | number;\n /**\n * The available date formats\n */\n format: TValidationDateFormats;\n /**\n * Intervals to compare with the original date.\n *\n * It will use todays date for comparison.\n *\n * @example\n *\n * origin date = 10/10/2022\n * interval.year = 1\n * operator = '==='\n *\n * It will compare (10/10/2022 + 1) with the current date and check if they are the same\n */\n intervals?: {\n years?: number;\n months?: number;\n days?: number;\n };\n };\n target?: {\n value: string | number;\n format: TValidationDateFormats;\n };\n };\n\n /**\n * Allow to validate if the input string is a valid date format\n */\n validDate?: TValidationDateFormats;\n\n /**\n * Allow to define a maximum length for the input to have no error\n */\n length?: number;\n\n /**\n * Will look into the input length and send an error if is not greater than this value\n */\n greaterThan?: number | string;\n\n /**\n * Specifies a regular expression pattern that the value should match.\n */\n regex?: string;\n\n /**\n * Specifies the maximum length of the value (if it's a string).\n */\n maxLength?: number;\n\n /**\n * Specifies the minimum length of the value (if it's a string).\n */\n minLength?: number;\n\n /**\n * Specifies whether the field is required.\n */\n required?: boolean;\n\n /**\n * Specifies that the value should contain only letters.\n */\n onlyLetters?: boolean;\n\n /**\n * Specifies a value that the field should match.\n */\n value?: string | number | boolean;\n\n /**\n * Specifies that the field should not be empty.\n */\n notEmpty?: boolean;\n\n /**\n * A callback function that performs custom validation on the value.\n * @param value - The value to be validated.\n * @returns An object with validation results.\n */\n callback?(value: string | number): { fail: boolean; errorMessage?: string };\n\n /**\n * Specifies a numeric range for the value.\n */\n numericRange?: { start: number | string; end: number | string };\n\n /**\n * Specifies whether the value should be a number.\n */\n isNumber?: boolean;\n\n /**\n * Specifies that the field should not have extra spaces.\n */\n hasNoExtraSpaces?: boolean;\n\n /**\n * Specifies that the value should be an email address.\n */\n email?: boolean;\n\n /**\n * Specifies that the value should be less than a given number or string.\n */\n lessThan?: number | string;\n\n /**\n * Specifies that the value should be a sequential number.\n */\n sequentialNumber?: boolean;\n\n /**\n * Specifies that the value should not contain repeated numbers.\n */\n repeatedNumbers?: boolean;\n\n /**\n * Specifies that the value should be a URL.\n */\n url?: boolean;\n\n /**\n * Specifies a path error type.\n */\n path?: TPathError;\n\n /**\n * Specifies that the value should be a valid credit card number.\n */\n isCreditCard?: string[];\n\n /**\n * Specifies that the value should be a valid credit card number with a specific length.\n */\n isCreditCardAndLength?: string[];\n\n /**\n * Specifies that the value should match a credit card code with available options.\n */\n isCreditCodeMatch?: { numberCard: string; availableOptions: string[] };\n\n /**\n * Specifies custom validation options for the field.\n */\n customValidation?: ICustomValidationValue[];\n\n /**\n * Specifies that spaces are not allowed in the field.\n */\n notAllowSpaces?: true;\n\n /**\n * Specifies that the value should be in a predefined list of values.\n */\n isInTheList?: string[] | number[] | string;\n\n /**\n * Specifies field validation rules for nested fields.\n */\n fields?: {\n /**\n * The rule for validating nested fields (e.g., 'every').\n */\n rule: 'every';\n\n /**\n * An array of nested field validation configurations.\n */\n set: {\n /**\n * The binding for the nested field.\n */\n bind: string;\n\n /**\n * The field name for the nested field.\n */\n fieldName: string;\n\n /**\n * Validation options for the nested field, excluding the 'fields' property.\n */\n validations: Omit<TVAvailableValidations, 'fields'>;\n }[];\n };\n\n /**\n * Specifies that the value should be existed.\n */\n exists?: string | number;\n};\n\nexport type TGenericValidationRule = {\n [key: string]: TVAvailableValidations;\n};\n\nexport type TSchemaValidation = TVAvailableValidations | TGenericValidationRule;\n\nexport type TStepData = {\n navigated: boolean;\n index: number;\n data: Record<\n number,\n Pick<\n TFormValues,\n 'fields' | 'erroredFields' | 'formatted' | 'filteredFields'\n >\n >;\n currentStepSchema?: TComponent;\n isValid: boolean;\n numSteps?: number;\n};\n\nexport type TFormValues = {\n predictableErroredFields: string[];\n erroredFields: string[];\n fields: TFieldData;\n formatted: Record<string, unknown>;\n filteredFields?: Record<string, unknown>;\n form: {\n steps: TStepData;\n isValid: boolean;\n messages: string[];\n scope: TScope;\n };\n};\n\nexport type TError = {\n value: unknown;\n message?: string;\n fail: boolean;\n};\n\nexport type TErrors = Record<string, TError> | undefined;\n\n// TODO - object with the available errors has props\nexport type TErrorMessages = Record<string, string>;\n\nexport type TSchemaValidations = TSchemaHandler<TSchemaValidation>;\n\ntype TFormLevelSchemaHandler<T> = Partial<\n Record<\n | EEVents.AFTER_FIELD_API_CALL\n | EEVents.ON_FIELD_CHANGE\n | EEVents.ON_FIELD_KEYUP\n | EEVents.ON_FIELD_KEYDOWN\n | EEVents.ON_FORM_REHYDRATE\n | EEVents.ON_FORM_MOUNT\n | EEVents.ON_SCOPE_CHANGE,\n T\n >\n>;\n\ntype TSchemaHandler<T> = Partial<\n Record<\n | EEVents.AFTER_FIELD_API_CALL\n | EEVents.ON_FIELD_REHYDRATE\n | EEVents.ON_FIELD_CLEARED\n | EEVents.ON_FIELD_BINDED\n | EEVents.ON_FIELD_CHANGE\n | EEVents.ON_FIELD_KEYUP\n | EEVents.ON_FIELD_KEYDOWN\n | EEVents.ON_FIELD_BLUR\n | EEVents.ON_FIELD_MOUNT\n | EEVents.ON_FIELD_FOCUS\n | EEVents.ON_FIELD_CLICK,\n T\n >\n>;\n\nexport type TSchemaVisibilityConditions = {\n /**\n * Enables visibility of fields only if any or all validation conditions are positive.\n *\n * The default is false, so if all validations are false, the field will display, if any are positive,\n * the field will hide, as well as if all are positive.\n */\n showOnlyIfTrue?: boolean;\n /**\n * Allows you to choose the type of chain for validations.\n *\n * The default is OR, where at least one validation needs to be true to work. In the case of AND,\n * all validations must be true.\n */\n rule?: 'or' | 'and';\n /**\n * The validations that will say if the target field will be visible or not\n *\n * Those validations will run against your field (the one that has this directive)\n */\n validations: TSchemaValidation;\n /**\n * Target field that will have the visibility toggled\n */\n fieldName?: string;\n /**\n * Target fields that will have the visibility toggled\n */\n fieldNames?: string[];\n}[];\n\nexport type TClearFieldValue = string | number | boolean;\n\nexport type TClearField = {\n /**\n * The clearValues runs validations on the target field and not on the field it is declaring.\n * Therefore, set this prop with true if you want validations to be performed on the current field.\n */\n useCurrentFieldValidation?: boolean;\n /**\n * Validations to run for the target field\n */\n validations?: TSchemaValidation | TSchemaValidation[];\n /**\n * target fields that will be used in the validation specified\n */\n fields: string[];\n /**\n * The cleared values on the fields in case they do not pass the validation\n */\n clearedValue: TClearFieldValue | TClearFieldValue[];\n /**\n * The cleared props from each component field on target fields array\n */\n clearedProps?: Record<string, unknown> | Record<string, unknown>[];\n /**\n * The cleared values on the fields in case they do pass the validation\n */\n defaultClearedValue?: TClearFieldValue | TClearFieldValue[];\n /**\n * The cleared props from each component field on target fields array if they pass validation\n */\n defaultClearedProps?: Record<string, unknown> | Record<string, unknown>[];\n};\n\nexport type TSchemaClearFields = TClearField[];\n\nexport type TSchemaApi = {\n /**\n * Specify a debounce time in miliseconds for your call\n */\n debounceTime?: number;\n method: 'GET' | 'POST' | 'PUT' | 'PATCH';\n url: string;\n headers?: HeadersInit | undefined;\n body?: Record<string, any>;\n fieldValueAsParams?: Record<string, string>;\n fieldValueAsPathParams?: string[];\n scope?: string;\n blockRequestWhenInvalid?: boolean;\n preConditions?: TSchemaValidation;\n}[];\n\nexport type TSchemaMasks = { cleanMask?: boolean } & TComponentMasks;\n\nexport type TFormEventDirectives = {\n visibilityConditions: TSchemaVisibilityConditions;\n};\n\nexport type TComponent = {\n /**\n * This name will be used later to correlate the field with the value, and you will be able to read it.\n *\n * You can also mount here complex objects like\n *\n * name={a.b.c}\n *\n * that will result in\n * a: {\n * b: {\n * c: 'field_value'\n * }\n * }\n */\n name: string;\n /**\n * A component name that should map to the one you gave in the form mappings\n *\n * @example - For React\n * ```\n * const mappings: TMapper = {\n * input: { component: Input },\n * formGroup: { component: FormGroup },\n * };\n * ```\n *\n * The component name for the Input element will be \"input\" ending up like\n * ```\n * {\n * component: 'input'\n * }\n * ```\n */\n component: string;\n /**\n * You can attach metadata to your component that will be forwarded to you after on your frontend\n * callback methods link `onData`, `onBlur` etc\n */\n metadata?: Record<string, any>;\n /**\n * This property allows you to specify a virtual fieldName that can be in several fields\n *\n * USAGE - You have two fields but you want to have the value stored only under one name\n *\n */\n group?: string;\n wrapper?: new () => React.Component;\n children?: TComponent[];\n /**\n * Field error messages in case any validation fails\n *\n * @example - Set a default error message for all the validations\n *\n * ```\n * {\n * errorMessages: {\n * default: 'default error message'\n * }\n * }\n * ```\n *\n * @example - Set error message for a given validation\n *\n * ```\n * {\n * validations: {\n * ON_FIELD_CHANGE: {\n * required: true\n * }\n * },\n * errorMessages: {\n * required: 'This field is required'\n * }\n * }\n * ```\n *\n */\n errorMessages?: TErrorMessages;\n type?: 'text' | 'number' | string;\n /**\n * Allow you to set a initial state for this field\n */\n state?: {\n /**\n * Hide the field\n */\n hidden?: boolean;\n /**\n * Ignore value from field\n */\n ignoreValue?: boolean;\n };\n /**\n * This key lets you inject props directly into the component\n */\n props?: Record<string, unknown>;\n /**\n * Setup validations to be used in the field.\n *\n * You can setup validations in several life-cycle methods\n *\n * @example - Required validation\n * ```\n * validations: {\n ON_FIELD_CHANGE: {\n required: true,\n },\n },\n * ```\n */\n validations?: TSchemaHandler<\n Pick<TEventReducedSchema, 'validations'>['validations']\n >;\n /**\n * Filters the component value based on a validation.\n */\n filter?: Pick<TEventReducedSchema, 'validations'>['validations'];\n /**\n * Allows you to specify the conditions a given field will be visible\n * what will run when this field meets the specified life-cycle\n */\n visibilityConditions?: Omit<\n TSchemaHandler<\n Pick<TEventReducedSchema, 'visibilityConditions'>['visibilityConditions']\n >,\n 'ON_FIELD_REHYDRATE' | 'ON_FIELD_CLEARED' | 'ON_FIELD_FOCUS'\n >;\n /**\n * Will clear target fields in case they do not pass with the specified validations\n */\n clearFields?: Omit<\n TSchemaHandler<Pick<TEventReducedSchema, 'clearFields'>['clearFields']>,\n 'ON_FIELD_REHYDRATE' | 'ON_FIELD_CLEARED' | 'ON_FIELD_FOCUS'\n >;\n /**\n * Allows you to make api calls using events emitted by the component.\n */\n api?: Omit<\n TSchemaHandler<Pick<TEventReducedSchema, 'api'>['api']>,\n 'ON_FIELD_REHYDRATE' | 'ON_FIELD_FOCUS' | 'AFTER_FIELD_API_CALL'\n >;\n /**\n * Allows you to display the value of the masked component by events\n */\n masks?: Partial<\n Record<\n | EEVents.ON_FIELD_BLUR\n | EEVents.ON_FIELD_MOUNT\n | EEVents.ON_FIELD_FOCUS\n | EEVents.ON_FIELD_CHANGE\n | EEVents.ON_FIELD_KEYUP\n | EEVents.ON_FIELD_KEYDOWN,\n Pick<TEventReducedSchema, 'masks'>['masks']\n >\n >;\n /**\n * Allows you to format the value that the field will receive for each event issuance\n */\n formatters?: Omit<\n TSchemaHandler<Pick<TEventReducedSchema, 'formatters'>['formatters']>,\n 'ON_FIELD_REHYDRATE' | 'ON_FIELD_FOCUS'\n >;\n};\n\nexport type TEventReducedSchema = {\n api: TSchemaApi;\n clearFields: TSchemaClearFields;\n formatters: TSchemaFormatters;\n masks: TSchemaMasks;\n validations: TSchemaValidation;\n visibilityConditions: TSchemaVisibilityConditions;\n};\n\nexport type TStep = {\n component: string;\n name: string;\n children: TComponent[];\n props?: Record<string, string>;\n};\n\nexport type TComponentPropsMapping = {\n getValue?: string;\n setValue?: string;\n onBlur?: string;\n onClick?: string;\n onFocus?: string;\n onKeyUp?: string;\n onKeyDown?: string;\n setErrorMessage?: string;\n setErrorState?: string;\n};\n\nexport type TPropsMapping = Record<string, TComponentPropsMapping>;\n\nexport type TSchema = {\n /**\n * Used to disable form submit input and prevent to submit form using enter event.\n * Default is false.\n */\n disableFormSubmit?: boolean;\n action?: string;\n method?: string;\n /**\n * Give some configurations to the form\n */\n configs?: TConfigs;\n /**\n * Allows you to expose some messages to the outside world when something happen\n */\n messages?: TFormMessages;\n /**\n * Specify some static field defaults before rendereing the form.\n *\n * If you have initialValues in the frontend setted, those will ovewride this\n */\n formattedDataDefaults?: Record<string, unknown>;\n /**\n * Form level props mapping\n */\n propsMapping?: TPropsMapping;\n visibilityConditions?: TFormLevelSchemaHandler<TSchemaVisibilityConditions>;\n /**\n * Entry point for the form should be a step (even if you have only one)\n */\n components: TStep[];\n /**\n * You can have many fields in the form, but be interested only in some\n *\n * You can put here the fields you want to read onSubmit for example\n *\n * You will receive those in TFormValues.filteredFields\n */\n filteredFields?: string[];\n /**\n * Schema level iVars.\n *\n * These iVars will go to the global scope namespace\n */\n iVars?: TIVars;\n};\n\nexport type TSplitterFormatterValue = {\n value: string;\n position: number;\n}[];\n\nexport type TSchemaFormatters = {\n splitter?: TSplitterFormatterValue;\n capitalize?: boolean;\n upperCase?: boolean;\n gapsCreditCard?: string[];\n onlyNumbers?: boolean;\n onlyLetters?: boolean;\n regex?: string;\n callback?(value: string | number): string | number;\n};\n\nexport type TConfigs = {\n observables?: { templates?: { exclude?: string[] } };\n};\n\nexport type TFlowType = {\n [x: string]: {\n events: (component?: TComponent) => EEVents[];\n handler: (args: TEventInformation<unknown>) => void;\n }[];\n};\n"],"names":["TAvailableHooks"],"mappings":"aA+HA,IAAYA,yDAAAA,QAKXA,qBAAA,GALWA,EAAAA,QAAeA,kBAAfA,wBAKX,CAAA,IAJC,SAAA,WACAA,EAAA,WAAA,aACAA,EAAA,UAAA,YACAA,EAAA,WAAA"}
|