@aemforms/af-core 0.22.67 → 0.22.69
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/esm/afb-events.js +161 -0
- package/esm/afb-runtime.js +4304 -0
- package/esm/types/src/BaseNode.d.ts +99 -0
- package/esm/types/src/Captcha.d.ts +5 -0
- package/esm/types/src/Checkbox.d.ts +84 -0
- package/esm/types/src/CheckboxGroup.d.ts +23 -0
- package/esm/types/src/Container.d.ts +75 -0
- package/esm/types/src/DateField.d.ts +9 -0
- package/esm/types/src/EmailInput.d.ts +16 -0
- package/esm/types/src/Field.d.ts +223 -0
- package/esm/types/src/Fieldset.d.ts +16 -0
- package/esm/types/src/FileObject.d.ts +16 -0
- package/esm/types/src/FileUpload.d.ts +27 -0
- package/esm/types/src/Form.d.ts +125 -0
- package/esm/types/src/FormInstance.d.ts +16 -0
- package/esm/types/src/FormMetaData.d.ts +7 -0
- package/esm/types/src/InstanceManager.d.ts +9 -0
- package/esm/types/src/Node.d.ts +7 -0
- package/esm/types/src/Scriptable.d.ts +17 -0
- package/esm/types/src/SubmitMetaData.d.ts +7 -0
- package/esm/types/src/controller/EventQueue.d.ts +18 -0
- package/esm/types/src/controller/Events.d.ts +91 -0
- package/esm/types/src/controller/Logger.d.ts +11 -0
- package/esm/types/src/data/DataGroup.d.ts +20 -0
- package/esm/types/src/data/DataValue.d.ts +16 -0
- package/esm/types/src/data/EmptyDataValue.d.ts +14 -0
- package/esm/types/src/index.d.ts +24 -0
- package/esm/types/src/rules/FunctionRuntime.d.ts +62 -0
- package/esm/types/src/rules/RuleEngine.d.ts +16 -0
- package/esm/types/src/types/Json.d.ts +180 -0
- package/esm/types/src/types/Model.d.ts +141 -0
- package/esm/types/src/types/index.d.ts +2 -0
- package/esm/types/src/utils/CoercionUtils.d.ts +1 -0
- package/esm/types/src/utils/DataRefParser.d.ts +33 -0
- package/esm/types/src/utils/Fetch.d.ts +8 -0
- package/esm/types/src/utils/FormCreationUtils.d.ts +10 -0
- package/esm/types/src/utils/FormUtils.d.ts +14 -0
- package/esm/types/src/utils/JsonUtils.d.ts +13 -0
- package/esm/types/src/utils/LogUtils.d.ts +4 -0
- package/esm/types/src/utils/SchemaUtils.d.ts +3 -0
- package/esm/types/src/utils/TranslationUtils.d.ts +11 -0
- package/esm/types/src/utils/ValidationUtils.d.ts +20 -0
- package/lib/BaseNode.d.ts +8 -5
- package/lib/BaseNode.js +19 -3
- package/lib/Container.d.ts +12 -5
- package/lib/Container.js +43 -19
- package/lib/Field.d.ts +8 -3
- package/lib/Field.js +12 -12
- package/lib/Fieldset.d.ts +2 -1
- package/lib/Form.d.ts +10 -6
- package/lib/Form.js +34 -12
- package/lib/FormInstance.d.ts +3 -0
- package/lib/FormInstance.js +16 -1
- package/lib/controller/EventQueue.d.ts +1 -0
- package/lib/controller/EventQueue.js +3 -0
- package/lib/types/Model.d.ts +2 -1
- package/lib/utils/FormCreationUtils.d.ts +2 -1
- package/package.json +5 -3
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import Container from './Container';
|
|
2
|
+
import { Action, BaseModel, FieldModel, FieldsetModel, FormCreationMode, FormJson, FocusOption, FormModel, IFormFieldFactory } from './types/index';
|
|
3
|
+
import FormMetaData from './FormMetaData';
|
|
4
|
+
import SubmitMetaData from './SubmitMetaData';
|
|
5
|
+
import EventQueue from './controller/EventQueue';
|
|
6
|
+
import { Logger, LogLevel } from './controller/Logger';
|
|
7
|
+
import RuleEngine from './rules/RuleEngine';
|
|
8
|
+
declare class Form extends Container<FormJson> implements FormModel {
|
|
9
|
+
#private;
|
|
10
|
+
private _ruleEngine;
|
|
11
|
+
private _eventQueue;
|
|
12
|
+
private _fields;
|
|
13
|
+
_ids: Generator<string, void, string>;
|
|
14
|
+
private _invalidFields;
|
|
15
|
+
constructor(n: FormJson, fieldFactory: IFormFieldFactory, _ruleEngine: RuleEngine, _eventQueue?: EventQueue, logLevel?: LogLevel, mode?: FormCreationMode);
|
|
16
|
+
private _logger;
|
|
17
|
+
get logger(): Logger;
|
|
18
|
+
private dataRefRegex;
|
|
19
|
+
get metaData(): FormMetaData;
|
|
20
|
+
get action(): string | undefined;
|
|
21
|
+
importData(dataModel: any): void;
|
|
22
|
+
exportData(): any;
|
|
23
|
+
resolveQualifiedName(qualifiedName: string): FieldModel | FieldsetModel | null;
|
|
24
|
+
exportSubmitMetaData(): SubmitMetaData;
|
|
25
|
+
setFocus(field: BaseModel, focusOption: FocusOption): void;
|
|
26
|
+
getState(forRestore?: boolean): {
|
|
27
|
+
description?: string | undefined;
|
|
28
|
+
} & import("./types/Json").RulesJson & {
|
|
29
|
+
enumNames?: string[] | import("./types/Json").EnumName[] | undefined;
|
|
30
|
+
enum?: any[] | undefined;
|
|
31
|
+
} & {
|
|
32
|
+
accept?: string[] | undefined;
|
|
33
|
+
enforceEnum?: boolean | undefined;
|
|
34
|
+
exclusiveMinimum?: number | undefined;
|
|
35
|
+
exclusiveMaximum?: number | undefined;
|
|
36
|
+
format?: string | undefined;
|
|
37
|
+
maxFileSize?: string | number | undefined;
|
|
38
|
+
maxLength?: number | undefined;
|
|
39
|
+
maximum?: number | undefined;
|
|
40
|
+
maxItems?: number | undefined;
|
|
41
|
+
minOccur?: number | undefined;
|
|
42
|
+
maxOccur?: number | undefined;
|
|
43
|
+
minLength?: number | undefined;
|
|
44
|
+
minimum?: number | undefined;
|
|
45
|
+
minItems?: number | undefined;
|
|
46
|
+
pattern?: string | undefined;
|
|
47
|
+
required?: boolean | undefined;
|
|
48
|
+
step?: number | undefined;
|
|
49
|
+
type?: string | undefined;
|
|
50
|
+
validationExpression?: string | undefined;
|
|
51
|
+
uniqueItems?: boolean | undefined;
|
|
52
|
+
} & {
|
|
53
|
+
dataRef?: string | null | undefined;
|
|
54
|
+
lang?: string | undefined;
|
|
55
|
+
':type'?: string | undefined;
|
|
56
|
+
appliedCssClassNames?: string | undefined;
|
|
57
|
+
label?: import("./types/Json").Label | undefined;
|
|
58
|
+
enabled?: boolean | undefined;
|
|
59
|
+
visible?: boolean | undefined;
|
|
60
|
+
name?: string | undefined;
|
|
61
|
+
constraintMessages?: import("./types/Json").ConstraintsMessages | undefined;
|
|
62
|
+
fieldType?: string | undefined;
|
|
63
|
+
errorMessage?: string | undefined;
|
|
64
|
+
properties?: {
|
|
65
|
+
[key: string]: any;
|
|
66
|
+
} | undefined;
|
|
67
|
+
repeatable?: boolean | undefined;
|
|
68
|
+
screenReaderText?: string | undefined;
|
|
69
|
+
tooltip?: string | undefined;
|
|
70
|
+
altText?: string | undefined;
|
|
71
|
+
viewType?: string | undefined;
|
|
72
|
+
} & {
|
|
73
|
+
items: (import("./types/Json").FieldJson | import("./types/Json").ContainerJson)[];
|
|
74
|
+
initialItems?: number | undefined;
|
|
75
|
+
activeChild?: string | undefined;
|
|
76
|
+
} & {
|
|
77
|
+
metadata?: import("./types/Json").MetaDataJson | undefined;
|
|
78
|
+
data?: any;
|
|
79
|
+
title?: string | undefined;
|
|
80
|
+
action?: string | undefined;
|
|
81
|
+
adaptiveForm?: string | undefined;
|
|
82
|
+
lang?: string | undefined;
|
|
83
|
+
} & {
|
|
84
|
+
items: any[];
|
|
85
|
+
enabled: boolean | undefined;
|
|
86
|
+
readOnly: any;
|
|
87
|
+
':items'?: undefined;
|
|
88
|
+
':itemsOrder'?: undefined;
|
|
89
|
+
_dependents?: string[] | undefined;
|
|
90
|
+
allowedComponents?: undefined;
|
|
91
|
+
columnClassNames?: undefined;
|
|
92
|
+
columnCount?: undefined;
|
|
93
|
+
gridClassNames?: undefined;
|
|
94
|
+
properties: {
|
|
95
|
+
[key: string]: any;
|
|
96
|
+
};
|
|
97
|
+
index: number;
|
|
98
|
+
parent: undefined;
|
|
99
|
+
qualifiedName: any;
|
|
100
|
+
repeatable: boolean | undefined;
|
|
101
|
+
':type': string;
|
|
102
|
+
id: string;
|
|
103
|
+
};
|
|
104
|
+
get type(): string;
|
|
105
|
+
isTransparent(): boolean;
|
|
106
|
+
get form(): FormModel;
|
|
107
|
+
get ruleEngine(): RuleEngine;
|
|
108
|
+
getUniqueId(): string;
|
|
109
|
+
fieldAdded(field: FieldModel | FieldsetModel): void;
|
|
110
|
+
visit(callBack: (field: FieldModel | FieldsetModel) => void): void;
|
|
111
|
+
traverseChild(container: Container<any>, callBack: (field: FieldModel | FieldsetModel) => void): void;
|
|
112
|
+
validate(): import("./types/Model").ValidationError[];
|
|
113
|
+
isValid(): boolean;
|
|
114
|
+
dispatch(action: Action): void;
|
|
115
|
+
submit(action: Action, context: any): void;
|
|
116
|
+
reset(): void;
|
|
117
|
+
getElement(id: string): FieldModel | FieldsetModel | this;
|
|
118
|
+
get qualifiedName(): string;
|
|
119
|
+
getEventQueue(): EventQueue;
|
|
120
|
+
get name(): string;
|
|
121
|
+
get value(): null;
|
|
122
|
+
get id(): string;
|
|
123
|
+
get title(): string;
|
|
124
|
+
}
|
|
125
|
+
export default Form;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FormModel } from './types/index';
|
|
2
|
+
import { LogLevel } from './controller/Logger';
|
|
3
|
+
import { CustomFunction, FunctionDefinition } from './rules/FunctionRuntime';
|
|
4
|
+
export declare const createFormInstance: (formModel: any, callback?: ((f: FormModel) => any) | undefined, logLevel?: LogLevel, fModel?: any) => FormModel;
|
|
5
|
+
export declare const restoreFormInstance: (formModel: any, { logLevel }?: {
|
|
6
|
+
logLevel: LogLevel;
|
|
7
|
+
}) => FormModel;
|
|
8
|
+
export declare const validateFormInstance: (formModel: any, data: any) => boolean;
|
|
9
|
+
export declare const validateFormData: (formModel: any, data: any) => {
|
|
10
|
+
messages: any[];
|
|
11
|
+
valid: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare const fetchForm: (url: string, headers?: any) => Promise<string>;
|
|
14
|
+
export declare const registerFunctions: (functions: {
|
|
15
|
+
[key: string]: Function | FunctionDefinition;
|
|
16
|
+
}) => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Action, FieldsetModel } from './types/index';
|
|
2
|
+
import { Fieldset } from './Fieldset';
|
|
3
|
+
export declare class InstanceManager extends Fieldset implements FieldsetModel {
|
|
4
|
+
get maxOccur(): number;
|
|
5
|
+
set maxOccur(m: number);
|
|
6
|
+
get minOccur(): number;
|
|
7
|
+
addInstance(action: Action): void;
|
|
8
|
+
removeInstance(action: Action): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Action, RulesJson, ScriptableField } from './types/index';
|
|
2
|
+
import { BaseNode } from './BaseNode';
|
|
3
|
+
declare abstract class Scriptable<T extends RulesJson> extends BaseNode<T> implements ScriptableField {
|
|
4
|
+
private _events;
|
|
5
|
+
private _rules;
|
|
6
|
+
getRules(): import("./types/Json").Items<string>;
|
|
7
|
+
private getCompiledRule;
|
|
8
|
+
private getCompiledEvent;
|
|
9
|
+
private applyUpdates;
|
|
10
|
+
protected executeAllRules(context: any): void;
|
|
11
|
+
private getExpressionScope;
|
|
12
|
+
private executeEvent;
|
|
13
|
+
executeRule(event: Action, context: any): void;
|
|
14
|
+
executeExpression(expr: string): any;
|
|
15
|
+
executeAction(action: Action): void;
|
|
16
|
+
}
|
|
17
|
+
export default Scriptable;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SubmitMetaDataModel } from './types/index';
|
|
2
|
+
declare class SubmitMetaData implements SubmitMetaDataModel {
|
|
3
|
+
lang: string;
|
|
4
|
+
captchaInfo: Record<string, any>;
|
|
5
|
+
constructor(lang: string | undefined, captchaInfo: Record<string, any>);
|
|
6
|
+
}
|
|
7
|
+
export default SubmitMetaData;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Action, BaseJson } from '../types/index';
|
|
2
|
+
import { BaseNode } from '../BaseNode';
|
|
3
|
+
import { Logger } from './Logger';
|
|
4
|
+
declare class EventQueue {
|
|
5
|
+
private logger;
|
|
6
|
+
static readonly MAX_EVENT_CYCLE_COUNT = 10;
|
|
7
|
+
private _runningEventCount;
|
|
8
|
+
private _isProcessing;
|
|
9
|
+
private _pendingEvents;
|
|
10
|
+
constructor(logger?: Logger);
|
|
11
|
+
get length(): number;
|
|
12
|
+
get isProcessing(): boolean;
|
|
13
|
+
isQueued<T extends BaseJson>(node: BaseNode<T>, event: Action): boolean;
|
|
14
|
+
queue<T extends BaseJson>(node: BaseNode<T>, events: Action | Action[], priority?: boolean): void;
|
|
15
|
+
empty(): void;
|
|
16
|
+
runPendingQueue(): void;
|
|
17
|
+
}
|
|
18
|
+
export default EventQueue;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Action, BaseJson, FieldModel, FieldsetModel, FormModel, ValidationError } from '../types/index';
|
|
2
|
+
declare class ActionImpl implements Action {
|
|
3
|
+
private _metadata?;
|
|
4
|
+
protected _type: string;
|
|
5
|
+
private _payload?;
|
|
6
|
+
private _target;
|
|
7
|
+
constructor(payload: any, type: string, _metadata?: any);
|
|
8
|
+
get type(): string;
|
|
9
|
+
get payload(): any;
|
|
10
|
+
get metadata(): any;
|
|
11
|
+
get target(): FormModel | FieldModel | FieldsetModel;
|
|
12
|
+
get isCustomEvent(): boolean;
|
|
13
|
+
protected payloadToJson(): any;
|
|
14
|
+
toJson(): {
|
|
15
|
+
payload: any;
|
|
16
|
+
type: string;
|
|
17
|
+
isCustomEvent: boolean;
|
|
18
|
+
};
|
|
19
|
+
toString(): string;
|
|
20
|
+
}
|
|
21
|
+
export type ChangePayload = {
|
|
22
|
+
changes: Array<{
|
|
23
|
+
propertyName: string;
|
|
24
|
+
prevValue?: any;
|
|
25
|
+
currentValue: any;
|
|
26
|
+
}>;
|
|
27
|
+
};
|
|
28
|
+
export declare class Change extends ActionImpl {
|
|
29
|
+
constructor(payload: ChangePayload, dispatch?: boolean);
|
|
30
|
+
withAdditionalChange(change: Change): Change;
|
|
31
|
+
}
|
|
32
|
+
export declare class Invalid extends ActionImpl {
|
|
33
|
+
constructor(payload?: any);
|
|
34
|
+
}
|
|
35
|
+
export declare class Valid extends ActionImpl {
|
|
36
|
+
constructor(payload?: any);
|
|
37
|
+
}
|
|
38
|
+
export declare class ExecuteRule extends ActionImpl {
|
|
39
|
+
constructor(payload?: any, dispatch?: boolean);
|
|
40
|
+
}
|
|
41
|
+
export declare const propertyChange: (propertyName: string, currentValue: any, prevValue?: any) => Change;
|
|
42
|
+
export declare class Initialize extends ActionImpl {
|
|
43
|
+
constructor(payload?: any, dispatch?: boolean);
|
|
44
|
+
}
|
|
45
|
+
export declare class FormLoad extends ActionImpl {
|
|
46
|
+
constructor();
|
|
47
|
+
}
|
|
48
|
+
export declare class Click extends ActionImpl {
|
|
49
|
+
constructor(payload?: any, dispatch?: boolean);
|
|
50
|
+
}
|
|
51
|
+
export declare class Blur extends ActionImpl {
|
|
52
|
+
constructor(payload?: any, dispatch?: boolean);
|
|
53
|
+
}
|
|
54
|
+
export declare class ValidationComplete extends ActionImpl {
|
|
55
|
+
constructor(payload?: Array<ValidationError>, dispatch?: boolean);
|
|
56
|
+
}
|
|
57
|
+
export declare class Focus extends ActionImpl {
|
|
58
|
+
constructor();
|
|
59
|
+
}
|
|
60
|
+
export declare class Submit extends ActionImpl {
|
|
61
|
+
constructor(payload?: any, dispatch?: boolean);
|
|
62
|
+
}
|
|
63
|
+
export declare class SubmitSuccess extends ActionImpl {
|
|
64
|
+
constructor(payload?: any, dispatch?: boolean);
|
|
65
|
+
}
|
|
66
|
+
export declare class SubmitFailure extends ActionImpl {
|
|
67
|
+
constructor(payload?: any, dispatch?: boolean);
|
|
68
|
+
}
|
|
69
|
+
export declare class Reset extends ActionImpl {
|
|
70
|
+
constructor(payload?: any, dispatch?: boolean);
|
|
71
|
+
}
|
|
72
|
+
export declare class FieldChanged extends ActionImpl {
|
|
73
|
+
constructor(changes: ChangePayload, field: BaseJson);
|
|
74
|
+
}
|
|
75
|
+
export declare class CustomEvent extends ActionImpl {
|
|
76
|
+
constructor(eventName: string, payload?: any, dispatch?: boolean);
|
|
77
|
+
get isCustomEvent(): boolean;
|
|
78
|
+
}
|
|
79
|
+
export declare class AddItem extends ActionImpl {
|
|
80
|
+
constructor(payload?: number);
|
|
81
|
+
}
|
|
82
|
+
export declare class RemoveItem extends ActionImpl {
|
|
83
|
+
constructor(payload?: number);
|
|
84
|
+
}
|
|
85
|
+
export declare class AddInstance extends ActionImpl {
|
|
86
|
+
constructor(payload?: number);
|
|
87
|
+
}
|
|
88
|
+
export declare class RemoveInstance extends ActionImpl {
|
|
89
|
+
constructor(payload?: number);
|
|
90
|
+
}
|
|
91
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type LogFunction = 'info' | 'warn' | 'error' | 'debug';
|
|
2
|
+
export type LogLevel = 'off' | LogFunction;
|
|
3
|
+
export declare class Logger {
|
|
4
|
+
debug(msg: string): void;
|
|
5
|
+
info(msg: string): void;
|
|
6
|
+
warn(msg: string): void;
|
|
7
|
+
error(msg: string): void;
|
|
8
|
+
log(msg: string, level: LogFunction): void;
|
|
9
|
+
private logLevel;
|
|
10
|
+
constructor(logLevel?: LogLevel);
|
|
11
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import DataValue from './DataValue';
|
|
2
|
+
export default class DataGroup extends DataValue {
|
|
3
|
+
$_items: {
|
|
4
|
+
[key: string]: DataValue | DataGroup;
|
|
5
|
+
} | DataValue[] | DataGroup[];
|
|
6
|
+
private createEntry;
|
|
7
|
+
constructor(_name: string | number, _value: {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
} | any[], _type?: string);
|
|
10
|
+
get $value(): Array<any> | {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
};
|
|
13
|
+
get $length(): number;
|
|
14
|
+
$convertToDataValue(): DataValue;
|
|
15
|
+
$addDataNode(name: string | number, value: DataGroup | DataValue, override?: boolean): void;
|
|
16
|
+
$removeDataNode(name: string | number): void;
|
|
17
|
+
$getDataNode(name: string | number): any;
|
|
18
|
+
$containsDataNode(name: string | number): boolean;
|
|
19
|
+
get $isDataGroup(): boolean;
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FieldModel } from '../types/index';
|
|
2
|
+
export default class DataValue {
|
|
3
|
+
private $_name;
|
|
4
|
+
private $_value;
|
|
5
|
+
private $_type;
|
|
6
|
+
$_fields: Array<FieldModel>;
|
|
7
|
+
constructor($_name: string | number, $_value: any, $_type?: string);
|
|
8
|
+
valueOf(): any;
|
|
9
|
+
get $name(): string | number;
|
|
10
|
+
get $value(): any;
|
|
11
|
+
setValue(typedValue: any, originalValue: any, fromField: FieldModel): void;
|
|
12
|
+
get $type(): string;
|
|
13
|
+
$bindToField(field: FieldModel): void;
|
|
14
|
+
$convertToDataValue(): DataValue;
|
|
15
|
+
get $isDataGroup(): boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import DataValue from './DataValue';
|
|
2
|
+
declare class NullDataValueClass extends DataValue {
|
|
3
|
+
constructor();
|
|
4
|
+
setValue(): void;
|
|
5
|
+
$bindToField(): void;
|
|
6
|
+
$length(): number;
|
|
7
|
+
$convertToDataValue(): DataValue;
|
|
8
|
+
$addDataNode(): void;
|
|
9
|
+
$removeDataNode(): void;
|
|
10
|
+
$getDataNode(): this;
|
|
11
|
+
$containsDataNode(): boolean;
|
|
12
|
+
}
|
|
13
|
+
declare const NullDataValue: NullDataValueClass;
|
|
14
|
+
export default NullDataValue;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export * from './FormInstance';
|
|
2
|
+
export * from './types/index';
|
|
3
|
+
export * from './controller/Events';
|
|
4
|
+
export * from './utils/TranslationUtils';
|
|
5
|
+
export * from './utils/JsonUtils';
|
|
6
|
+
export * from './utils/SchemaUtils';
|
|
7
|
+
import { getFileSizeInBytes, extractFileInfo, isEmpty } from './utils/FormUtils';
|
|
8
|
+
import { BaseNode } from './BaseNode';
|
|
9
|
+
import Checkbox from './Checkbox';
|
|
10
|
+
import CheckboxGroup from './CheckboxGroup';
|
|
11
|
+
import EmailInput from './EmailInput';
|
|
12
|
+
import Captcha from './Captcha';
|
|
13
|
+
import Container from './Container';
|
|
14
|
+
import Field from './Field';
|
|
15
|
+
import { Fieldset } from './Fieldset';
|
|
16
|
+
import { FileObject } from './FileObject';
|
|
17
|
+
import FileUpload from './FileUpload';
|
|
18
|
+
import FormMetaData from './FormMetaData';
|
|
19
|
+
import SubmitMetaData from './SubmitMetaData';
|
|
20
|
+
import Node from './Node';
|
|
21
|
+
import Scriptable from './Scriptable';
|
|
22
|
+
import Form from './Form';
|
|
23
|
+
import { FunctionRuntime, request } from './rules/FunctionRuntime';
|
|
24
|
+
export { Form, BaseNode, Checkbox, CheckboxGroup, Container, Field, Fieldset, FileObject, FileUpload, FormMetaData, Node, Scriptable, getFileSizeInBytes, extractFileInfo, FunctionRuntime, request, isEmpty, SubmitMetaData, EmailInput, Captcha };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
type HTTP_VERB = 'GET' | 'POST';
|
|
2
|
+
export declare const request: (context: any, uri: string, httpVerb: HTTP_VERB, payload: any, success: string, error: string, headers: any) => Promise<void>;
|
|
3
|
+
export declare const submit: (context: any, success: string, error: string, submitAs?: 'application/json' | 'multipart/form-data' | 'application/x-www-form-urlencoded', input_data?: any) => Promise<void>;
|
|
4
|
+
export type CustomFunction = Function;
|
|
5
|
+
export type FunctionDefinition = {
|
|
6
|
+
_func: CustomFunction;
|
|
7
|
+
_signature: Array<any>;
|
|
8
|
+
};
|
|
9
|
+
declare class FunctionRuntimeImpl {
|
|
10
|
+
private static instance;
|
|
11
|
+
private customFunctions;
|
|
12
|
+
private constructor();
|
|
13
|
+
static getInstance(): FunctionRuntimeImpl;
|
|
14
|
+
registerFunctions(functions: {
|
|
15
|
+
[key: string]: FunctionDefinition | CustomFunction;
|
|
16
|
+
}): void;
|
|
17
|
+
unregisterFunctions(...names: string[]): void;
|
|
18
|
+
getFunctions(): {
|
|
19
|
+
validate: {
|
|
20
|
+
_func: (args: Array<unknown>, data: unknown, interpreter: any) => any;
|
|
21
|
+
_signature: never[];
|
|
22
|
+
};
|
|
23
|
+
setFocus: {
|
|
24
|
+
_func: (args: Array<unknown>, data: unknown, interpreter: any) => void;
|
|
25
|
+
_signature: never[];
|
|
26
|
+
};
|
|
27
|
+
getData: {
|
|
28
|
+
_func: (args: unknown, data: unknown, interpreter: any) => any;
|
|
29
|
+
_signature: never[];
|
|
30
|
+
};
|
|
31
|
+
exportData: {
|
|
32
|
+
_func: (args: unknown, data: unknown, interpreter: any) => any;
|
|
33
|
+
_signature: never[];
|
|
34
|
+
};
|
|
35
|
+
importData: {
|
|
36
|
+
_func: (args: Array<unknown>, data: unknown, interpreter: any) => {};
|
|
37
|
+
_signature: never[];
|
|
38
|
+
};
|
|
39
|
+
submitForm: {
|
|
40
|
+
_func: (args: Array<unknown>, data: unknown, interpreter: any) => {};
|
|
41
|
+
_signature: never[];
|
|
42
|
+
};
|
|
43
|
+
request: {
|
|
44
|
+
_func: (args: Array<unknown>, data: unknown, interpreter: any) => {};
|
|
45
|
+
_signature: never[];
|
|
46
|
+
};
|
|
47
|
+
addInstance: {
|
|
48
|
+
_func: (args: Array<unknown>, data: unknown, interpreter: any) => void;
|
|
49
|
+
_signature: never[];
|
|
50
|
+
};
|
|
51
|
+
removeInstance: {
|
|
52
|
+
_func: (args: Array<unknown>, data: unknown, interpreter: any) => void;
|
|
53
|
+
_signature: never[];
|
|
54
|
+
};
|
|
55
|
+
dispatchEvent: {
|
|
56
|
+
_func: (args: Array<unknown>, data: unknown, interpreter: any) => {};
|
|
57
|
+
_signature: never[];
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export declare const FunctionRuntime: FunctionRuntimeImpl;
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseModel } from '../types/index';
|
|
2
|
+
import Formula from '@adobe/json-formula';
|
|
3
|
+
declare class RuleEngine {
|
|
4
|
+
private _context;
|
|
5
|
+
private _globalNames;
|
|
6
|
+
private readonly customFunctions;
|
|
7
|
+
private debugInfo;
|
|
8
|
+
constructor();
|
|
9
|
+
compileRule(rule: string, locale?: string): {
|
|
10
|
+
formula: Formula;
|
|
11
|
+
ast: any;
|
|
12
|
+
};
|
|
13
|
+
execute(node: any, data: any, globals: any, useValueOf?: boolean): any;
|
|
14
|
+
trackDependency(subscriber: BaseModel): void;
|
|
15
|
+
}
|
|
16
|
+
export default RuleEngine;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
export type Items<T> = {
|
|
2
|
+
[key: string]: T;
|
|
3
|
+
};
|
|
4
|
+
export type Primitives = string | number | boolean | null | undefined;
|
|
5
|
+
export type Label = {
|
|
6
|
+
value: string;
|
|
7
|
+
richText?: boolean;
|
|
8
|
+
visible?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type EnumName = {
|
|
11
|
+
value: string;
|
|
12
|
+
richText?: boolean;
|
|
13
|
+
};
|
|
14
|
+
type TranslationConstraintsJson = {
|
|
15
|
+
enumNames?: string[] | EnumName[];
|
|
16
|
+
enum?: any[];
|
|
17
|
+
};
|
|
18
|
+
export type ConstraintsJson = TranslationConstraintsJson & {
|
|
19
|
+
accept?: string[];
|
|
20
|
+
enforceEnum?: boolean;
|
|
21
|
+
exclusiveMinimum?: number;
|
|
22
|
+
exclusiveMaximum?: number;
|
|
23
|
+
format?: string;
|
|
24
|
+
maxFileSize?: number | string;
|
|
25
|
+
maxLength?: number;
|
|
26
|
+
maximum?: number;
|
|
27
|
+
maxItems?: number;
|
|
28
|
+
minOccur?: number;
|
|
29
|
+
maxOccur?: number;
|
|
30
|
+
minLength?: number;
|
|
31
|
+
minimum?: number;
|
|
32
|
+
minItems?: number;
|
|
33
|
+
pattern?: string;
|
|
34
|
+
required?: boolean;
|
|
35
|
+
step?: number;
|
|
36
|
+
type?: string;
|
|
37
|
+
validationExpression?: string;
|
|
38
|
+
uniqueItems?: boolean;
|
|
39
|
+
};
|
|
40
|
+
export type ConstraintsMessages = {
|
|
41
|
+
accept?: string;
|
|
42
|
+
enum?: string;
|
|
43
|
+
exclusiveMinimum?: string;
|
|
44
|
+
exclusiveMaximum?: string;
|
|
45
|
+
format?: string;
|
|
46
|
+
maxFileSize?: string;
|
|
47
|
+
maxLength?: string;
|
|
48
|
+
maximum?: string;
|
|
49
|
+
maxItems?: string;
|
|
50
|
+
minLength?: string;
|
|
51
|
+
minimum?: string;
|
|
52
|
+
minItems?: string;
|
|
53
|
+
uniqueItems?: string;
|
|
54
|
+
pattern?: string;
|
|
55
|
+
required?: string;
|
|
56
|
+
step?: string;
|
|
57
|
+
type?: string;
|
|
58
|
+
validationExpression?: string;
|
|
59
|
+
};
|
|
60
|
+
export type RulesJson = {
|
|
61
|
+
rules?: Items<string>;
|
|
62
|
+
events?: Items<string[] | string | undefined>;
|
|
63
|
+
};
|
|
64
|
+
type TranslationBaseJson = {
|
|
65
|
+
description?: string;
|
|
66
|
+
};
|
|
67
|
+
export type BaseJson = TranslationBaseJson & RulesJson & ConstraintsJson & {
|
|
68
|
+
dataRef?: string | null;
|
|
69
|
+
lang?: string;
|
|
70
|
+
':type'?: string;
|
|
71
|
+
appliedCssClassNames?: string;
|
|
72
|
+
label?: Label;
|
|
73
|
+
enabled?: boolean;
|
|
74
|
+
visible?: boolean;
|
|
75
|
+
name?: string;
|
|
76
|
+
constraintMessages?: ConstraintsMessages;
|
|
77
|
+
fieldType?: string;
|
|
78
|
+
errorMessage?: string;
|
|
79
|
+
properties?: {
|
|
80
|
+
[key: string]: any;
|
|
81
|
+
};
|
|
82
|
+
repeatable?: boolean;
|
|
83
|
+
screenReaderText?: string;
|
|
84
|
+
tooltip?: string;
|
|
85
|
+
altText?: string;
|
|
86
|
+
viewType?: string;
|
|
87
|
+
};
|
|
88
|
+
type TranslationFieldJson = {
|
|
89
|
+
placeholder?: string;
|
|
90
|
+
};
|
|
91
|
+
export type FieldJson = BaseJson & TranslationFieldJson & {
|
|
92
|
+
readOnly?: boolean;
|
|
93
|
+
valid?: boolean;
|
|
94
|
+
validity?: any;
|
|
95
|
+
validationMessage?: string;
|
|
96
|
+
default?: any;
|
|
97
|
+
value?: any;
|
|
98
|
+
displayFormat?: string;
|
|
99
|
+
editFormat?: string;
|
|
100
|
+
editValue?: string;
|
|
101
|
+
displayValue?: string;
|
|
102
|
+
emptyValue?: 'null' | 'undefined' | '';
|
|
103
|
+
};
|
|
104
|
+
export type ContainerJson = BaseJson & {
|
|
105
|
+
items: Array<FieldJson | ContainerJson>;
|
|
106
|
+
initialItems?: number;
|
|
107
|
+
activeChild?: string;
|
|
108
|
+
};
|
|
109
|
+
export type MetaDataJson = {
|
|
110
|
+
version?: string;
|
|
111
|
+
grammar?: string;
|
|
112
|
+
};
|
|
113
|
+
export type FieldsetJson = ContainerJson & {
|
|
114
|
+
'type'?: 'array' | 'object';
|
|
115
|
+
readOnly?: boolean;
|
|
116
|
+
};
|
|
117
|
+
export type FormJson = ContainerJson & {
|
|
118
|
+
metadata?: MetaDataJson;
|
|
119
|
+
data?: any;
|
|
120
|
+
title?: string;
|
|
121
|
+
action?: string;
|
|
122
|
+
adaptiveForm?: string;
|
|
123
|
+
lang?: string;
|
|
124
|
+
};
|
|
125
|
+
export type TranslationJson = TranslationBaseJson & TranslationFieldJson & TranslationConstraintsJson;
|
|
126
|
+
export declare const translationProps: string[];
|
|
127
|
+
export declare const constraintProps: string[];
|
|
128
|
+
export declare const ConstraintType: Readonly<{
|
|
129
|
+
PATTERN_MISMATCH: "patternMismatch";
|
|
130
|
+
TOO_SHORT: "tooShort";
|
|
131
|
+
TOO_LONG: "tooLong";
|
|
132
|
+
RANGE_OVERFLOW: "rangeOverflow";
|
|
133
|
+
RANGE_UNDERFLOW: "rangeUnderflow";
|
|
134
|
+
TYPE_MISMATCH: "typeMismatch";
|
|
135
|
+
VALUE_MISSING: "valueMissing";
|
|
136
|
+
STEP_MISMATCH: "stepMismatch";
|
|
137
|
+
FORMAT_MISMATCH: "formatMismatch";
|
|
138
|
+
ACCEPT_MISMATCH: "acceptMismatch";
|
|
139
|
+
FILE_SIZE_MISMATCH: "fileSizeMismatch";
|
|
140
|
+
UNIQUE_ITEMS_MISMATCH: "uniqueItemsMismatch";
|
|
141
|
+
MIN_ITEMS_MISMATCH: "minItemsMismatch";
|
|
142
|
+
MAX_ITEMS_MISMATCH: "maxItemsMismatch";
|
|
143
|
+
EXPRESSION_MISMATCH: "expressionMismatch";
|
|
144
|
+
}>;
|
|
145
|
+
export declare const constraintKeys: Readonly<{
|
|
146
|
+
pattern: "patternMismatch";
|
|
147
|
+
minLength: "tooShort";
|
|
148
|
+
maxLength: "tooLong";
|
|
149
|
+
maximum: "rangeOverflow";
|
|
150
|
+
minimum: "rangeUnderflow";
|
|
151
|
+
type: "typeMismatch";
|
|
152
|
+
required: "valueMissing";
|
|
153
|
+
step: "stepMismatch";
|
|
154
|
+
format: "formatMismatch";
|
|
155
|
+
accept: "acceptMismatch";
|
|
156
|
+
maxFileSize: "fileSizeMismatch";
|
|
157
|
+
uniqueItems: "uniqueItemsMismatch";
|
|
158
|
+
minItems: "minItemsMismatch";
|
|
159
|
+
maxItems: "maxItemsMismatch";
|
|
160
|
+
validationExpression: "expressionMismatch";
|
|
161
|
+
}>;
|
|
162
|
+
export declare const setCustomDefaultConstraintTypeMessages: (messages: Record<string, string>) => void;
|
|
163
|
+
export declare const getConstraintTypeMessages: () => {
|
|
164
|
+
patternMismatch: "Please match the format requested.";
|
|
165
|
+
tooShort: "Please lengthen this text to ${0} characters or more.";
|
|
166
|
+
tooLong: "Please shorten this text to ${0} characters or less.";
|
|
167
|
+
rangeOverflow: "Value must be less than or equal to ${0}.";
|
|
168
|
+
rangeUnderflow: "Value must be greater than or equal to ${0}.";
|
|
169
|
+
typeMismatch: "Please enter a valid value.";
|
|
170
|
+
valueMissing: "Please fill in this field.";
|
|
171
|
+
stepMismatch: "Please enter a valid value.";
|
|
172
|
+
formatMismatch: "Specify the value in allowed format : ${0}.";
|
|
173
|
+
acceptMismatch: "The specified file type not supported.";
|
|
174
|
+
fileSizeMismatch: "File too large. Reduce size and try again.";
|
|
175
|
+
uniqueItemsMismatch: "All the items must be unique.";
|
|
176
|
+
minItemsMismatch: "Specify a number of items equal to or greater than ${0}.";
|
|
177
|
+
maxItemsMismatch: "Specify a number of items equal to or less than ${0}.";
|
|
178
|
+
expressionMismatch: "Please enter a valid value.";
|
|
179
|
+
};
|
|
180
|
+
export {};
|