@picked/client 0.0.1-dev.1774231221701 → 0.0.1-dev.1774912386475
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/{api-BEXzPJHZ.cjs → api-B-wGEgt8.cjs} +1 -1
- package/dist/{api-oudcFuUX.js → api-DwERBrAZ.js} +1 -1
- package/dist/cjs/form/index.js +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/web-components/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/form/index.js +128 -84
- package/dist/esm/index.js +393 -334
- package/dist/esm/plugins/create-experience/index.js +183 -151
- package/dist/esm/plugins/dynamic-experiences/index.js +52 -30
- package/dist/esm/plugins/responses-browser-storage/index.js +47 -20
- package/dist/esm/plugins/web-components/index.js +1 -1
- package/dist/esm/server/index.js +1 -1
- package/dist/{experience-instance-DZiAwXph.js → experience-instance-CwwrKUI8.js} +50 -46
- package/dist/experience-instance-DdFUcVRd.cjs +1 -0
- package/dist/{rules-logic-B7vJrWyO.js → rules-logic-BIkBWZmf.js} +4 -2
- package/dist/rules-logic-DDxCiq4P.cjs +1 -0
- package/dist/types/entities/condition/condition.d.ts +17 -0
- package/dist/types/entities/condition/condition.d.ts.map +1 -0
- package/dist/types/entities/experience/experience.d.ts +40 -35
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts +21 -2
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/entities/field/field.d.ts +13 -2
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/entities/response/response-validation.d.ts +76 -0
- package/dist/types/entities/response/response-validation.d.ts.map +1 -0
- package/dist/types/entities/response/response.d.ts +24 -17
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/entities/step/step.d.ts +36 -0
- package/dist/types/entities/step/step.d.ts.map +1 -0
- package/dist/types/form/build-responses.d.ts +12 -9
- package/dist/types/form/build-responses.d.ts.map +1 -1
- package/dist/types/form/create-field-evaluator.d.ts +11 -3
- package/dist/types/form/create-field-evaluator.d.ts.map +1 -1
- package/dist/types/form/create-field-validation.d.ts +21 -6
- package/dist/types/form/create-field-validation.d.ts.map +1 -1
- package/dist/types/form/create-form.d.ts +42 -11
- package/dist/types/form/create-form.d.ts.map +1 -1
- package/dist/types/form/create-submit-pipeline.d.ts +21 -9
- package/dist/types/form/create-submit-pipeline.d.ts.map +1 -1
- package/dist/types/form/get-step-fields.d.ts +13 -0
- package/dist/types/form/get-step-fields.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logic-engine.d.ts +10 -2
- package/dist/types/logic-engine.d.ts.map +1 -1
- package/dist/types/picked.d.ts +68 -32
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +51 -29
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/index.d.ts +2 -2
- package/dist/types/plugins/create-experience/index.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/plugin.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/serialization.d.ts +1 -0
- package/dist/types/plugins/create-experience/serialization.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +21 -4
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +41 -0
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/utils/events.d.ts +1 -1
- package/dist/types/utils/events.d.ts.map +1 -1
- package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts +3 -0
- package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts.map +1 -0
- package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts +10 -6
- package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
- package/dist/types/utils/nodes.d.ts +74 -2
- package/dist/types/utils/nodes.d.ts.map +1 -1
- package/dist/types/utils/rules-logic.d.ts +31 -0
- package/dist/types/utils/rules-logic.d.ts.map +1 -1
- package/package.json +32 -6
- package/dist/experience-instance-Ddk4Jktn.cjs +0 -1
- package/dist/rules-logic-CXr4wXcG.cjs +0 -1
- package/dist/types/utils/node-tree/get-next-node-from-conditional.d.ts +0 -3
- package/dist/types/utils/node-tree/get-next-node-from-conditional.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experience.d.ts","sourceRoot":"","sources":["../../../../src/entities/experience/experience.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"experience.d.ts","sourceRoot":"","sources":["../../../../src/entities/experience/experience.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAG1C,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAI/D,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAC3E,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAIjE,QAAA,MAAM,uBAAuB,2BACF;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,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EAAE,MAAM,CAAA;IACV,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B,cAAc,CAAC,EAAE,SAAS,GAAG,UAAU,CAAA;IACvC,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAC5B,2EAA2E;IAC3E,SAAS,CAAC,EAAE,SAAS,GAAG,UAAU,CAAA;IAClC,KAAK,EAAE,cAAc,EAAE,CAAA;IACvB,KAAK,EAAE,cAAc,EAAE,CAAA;IACvB,OAAO,EAAE,gBAAgB,EAAE,CAAA;CAC5B;AAED;;;;;GAKG;AAEH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,MAAM,EACd,YAAY,eAAe,EAC3B,UAAU,uBAAuB,SAkBlC,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,GAAU,QAAQ,MAAM,kBASzD,CAAA;AAmBD,eAAO,MAAM,0BAA0B,GACrC,QAAQ,MAAM,EACd,YAAY,eAAe,KAC1B,OAAO,CAAC,OAAO,CAiCjB,CAAA"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { EventCallable, Store } from 'effector';
|
|
2
|
-
import { Experience, ExperienceNode,
|
|
2
|
+
import { Experience, ExperienceNode, ExperienceStore, ExperienceTarget, LaunchExperienceOptions } from '../experience/experience';
|
|
3
|
+
import { ExperienceStep } from '../step/step';
|
|
3
4
|
import { Picked } from '../../picked';
|
|
4
5
|
import { HistoryEntry } from '../history/history';
|
|
5
6
|
export interface ExperienceInstance {
|
|
6
7
|
id: string;
|
|
8
|
+
experienceKey: Experience['key'];
|
|
7
9
|
experienceId: Experience['id'];
|
|
8
10
|
configStore: ExperienceStore['configStore'];
|
|
9
11
|
target: HTMLElement | undefined;
|
|
@@ -15,7 +17,6 @@ export interface ExperienceInstance {
|
|
|
15
17
|
toggleOpen: EventCallable<void>;
|
|
16
18
|
setOpen: EventCallable<boolean>;
|
|
17
19
|
treeStore: ExperienceStore['treeStore'];
|
|
18
|
-
fieldsStore: ExperienceStore['fieldsStore'];
|
|
19
20
|
currentNodeStore: Store<ExperienceNode | null>;
|
|
20
21
|
currentStepStore: Store<ExperienceStep | null>;
|
|
21
22
|
previousStepStore: Store<ExperienceStep | null>;
|
|
@@ -38,6 +39,15 @@ declare const createExperienceInstanceFactory: ({ client, experience, target, op
|
|
|
38
39
|
target?: HTMLElement;
|
|
39
40
|
options?: LaunchExperienceOptions;
|
|
40
41
|
}) => Readonly<ExperienceInstance>;
|
|
42
|
+
/**
|
|
43
|
+
* Creates an experience instance with lifecycle stores and navigation logic.
|
|
44
|
+
*
|
|
45
|
+
* @param params - Factory parameters including the client and experience store.
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const instance = createExperienceInstance({ client, experience })
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
41
51
|
export declare function createExperienceInstance<T extends Parameters<typeof createExperienceInstanceFactory>[0]>(params: T): ReturnType<typeof createExperienceInstanceFactory>;
|
|
42
52
|
declare const createExperienceInstanceIndexFactory: ({ client }: {
|
|
43
53
|
client: Picked;
|
|
@@ -46,6 +56,15 @@ declare const createExperienceInstanceIndexFactory: ({ client }: {
|
|
|
46
56
|
getByExperienceId: (id: Experience["id"]) => Store<ExperienceInstance[]>;
|
|
47
57
|
listStore: Store<ExperienceInstance[]>;
|
|
48
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* Creates an index that tracks all experience instances keyed by experience ID.
|
|
61
|
+
*
|
|
62
|
+
* @param params - Factory parameters including the client.
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const index = createExperienceInstanceIndex({ client })
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
49
68
|
export declare function createExperienceInstanceIndex<T extends Parameters<typeof createExperienceInstanceIndexFactory>[0]>(params: T): ReturnType<typeof createExperienceInstanceIndexFactory>;
|
|
50
69
|
export {};
|
|
51
70
|
//# sourceMappingURL=experience-instance.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experience-instance.d.ts","sourceRoot":"","sources":["../../../../src/entities/experience-instance/experience-instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,aAAa,EAGlB,KAAK,KAAK,EACX,MAAM,UAAU,CAAA;AAEjB,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,
|
|
1
|
+
{"version":3,"file":"experience-instance.d.ts","sourceRoot":"","sources":["../../../../src/entities/experience-instance/experience-instance.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,OAAO,EAOL,KAAK,aAAa,EAGlB,KAAK,KAAK,EACX,MAAM,UAAU,CAAA;AAEjB,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAkB1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAItD,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,aAAa,EAAE,UAAU,CAAC,KAAK,CAAC,CAAA;IAChC,YAAY,EAAE,UAAU,CAAC,IAAI,CAAC,CAAA;IAC9B,WAAW,EAAE,eAAe,CAAC,aAAa,CAAC,CAAA;IAC3C,MAAM,EAAE,WAAW,GAAG,SAAS,CAAA;IAC/B,cAAc,EAAE,eAAe,CAAC,gBAAgB,CAAC,CAAA;IACjD,UAAU,EAAE,KAAK,CAAC,eAAe,GAAG,OAAO,CAAC,CAAA;IAC5C,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;IAC3B,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,CAAA;IACzB,KAAK,EAAE,aAAa,C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/D,MAAM,EAAE,CAAC,GAAG,UAAU,CAAC,OAAO,+BAA+B,CAAC,CAE/D;AAED,QAAA,MAAM,oCAAoC,eAA8B;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE;wBA0J1E,eAAe,UACnB,WAAW,YACT,uBAAuB;4BAkBJ,UAAU,CAAC,IAAI,CAAC;;CAS/C,CAAA;AAEF;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,CAAC,SAAS,UAAU,CAAC,OAAO,oCAAoC,CAAC,CAAC,CAAC,CAAC,EACpE,MAAM,EAAE,CAAC,GAAG,UAAU,CAAC,OAAO,oCAAoC,CAAC,CAEpE"}
|
|
@@ -21,6 +21,8 @@ export type JsonValue = string | number | boolean | null | {
|
|
|
21
21
|
export type FieldValue = PrimitiveFieldValue | PrimitiveFieldValue[] | JsonValue | JsonValue[];
|
|
22
22
|
export interface FieldBase<TOptionValue = JsonValue> {
|
|
23
23
|
id: string;
|
|
24
|
+
/** Stable identifier used for lookups across API versions. */
|
|
25
|
+
key: string;
|
|
24
26
|
name: string;
|
|
25
27
|
label: string;
|
|
26
28
|
type: 'text' | 'number' | 'object' | 'boolean';
|
|
@@ -81,12 +83,21 @@ export interface FieldBooleanMultiple extends FieldBase<boolean> {
|
|
|
81
83
|
export type Field = FieldTextSingular | FieldTextMultiple | FieldNumberSingular | FieldNumberMultiple | FieldObjectSingular | FieldObjectMultiple | FieldBooleanSingular | FieldBooleanMultiple;
|
|
82
84
|
declare const createFieldIndexFactory: () => {
|
|
83
85
|
register: (field: Field) => void;
|
|
84
|
-
update: (
|
|
86
|
+
update: (fieldKeyOrId: string, updates: Partial<Field>) => void;
|
|
85
87
|
getById: (id: FieldBase["id"]) => Store<Field | null>;
|
|
88
|
+
getByKey: (key: FieldBase["key"]) => Store<Field | null>;
|
|
86
89
|
listStore: Store<Field[]>;
|
|
87
90
|
getByName: (name: FieldBase["name"]) => Store<Field | null>;
|
|
88
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* Creates an Effector-based index for registering and retrieving fields.
|
|
94
|
+
*
|
|
95
|
+
* @returns {FieldsStore} A field index with register, update, get, and list methods.
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const fields = createFieldIndex()
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
89
101
|
export declare function createFieldIndex(): ReturnType<typeof createFieldIndexFactory>;
|
|
90
|
-
export declare const setupField: (field: Field, fields: FieldsStore) => void;
|
|
91
102
|
export {};
|
|
92
103
|
//# sourceMappingURL=field.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../../../src/entities/field/field.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAEnD,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAI7D,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;AAElE,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAExD,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,gBAAgB;IAC/C,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,CAAC,CAAA;IACR,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB;AAED,MAAM,MAAM,gBAAgB,CAAC,CAAC,GAAG,gBAAgB,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAA;AAErE;;;GAGG;AACH,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GA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,EAAE,SAAS,EAAE,CAAA;CAC3B;AAED,MAAM,WAAW,oBAAqB,SAAQ,SAAS,CAAC,OAAO,CAAC;IAC9D,IAAI,EAAE,SAAS,CAAA;IACf,QAAQ,EAAE,KAAK,CAAA;IACf,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,oBAAqB,SAAQ,SAAS,CAAC,OAAO,CAAC;IAC9D,IAAI,EAAE,SAAS,CAAA;IACf,QAAQ,EAAE,IAAI,CAAA;IACd,YAAY,CAAC,EAAE,OAAO,EAAE,CAAA;CACzB;AAED,MAAM,MAAM,KAAK,GACb,iBAAiB,GACjB,iBAAiB,GACjB,mBAAmB,GACnB,mBAAmB,GACnB,mBAAmB,GACnB,mBAAmB,GACnB,oBAAoB,GACpB,oBAAoB,CAAA;AAGxB,QAAA,MAAM,uBAAuB;sBA6BF,KAAK,KAAG,IAAI;2BAcP,MAAM,WAAW,OAAO,CAAC,KAAK,CAAC,KAAG,IAAI;kBAsB/C,SAAS,CAAC,IAAI,CAAC,KAAG,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC;oBAcnC,SAAS,CAAC,KAAK,CAAC,KAAG,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC;;sBAcpC,SAAS,CAAC,MAAM,CAAC,KAAG,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC;CAahE,CAAA;AAEF;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,IAAI,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAE7E"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Field, FieldValue } from '../field/field';
|
|
2
|
+
import { LogicObject, LogicRule } from '../../logic-engine';
|
|
3
|
+
export interface ValidationError {
|
|
4
|
+
fieldKey: Field['key'];
|
|
5
|
+
/** @deprecated Use `fieldKey` instead. */
|
|
6
|
+
fieldId?: Field['id'];
|
|
7
|
+
userMessage: string;
|
|
8
|
+
systemMessage: string;
|
|
9
|
+
value: FieldValue;
|
|
10
|
+
}
|
|
11
|
+
/** Callback signature for evaluating rule-based validation logic. */
|
|
12
|
+
type RuleEvaluator = (logic: LogicRule, context?: LogicObject) => Promise<unknown>;
|
|
13
|
+
/**
|
|
14
|
+
* Resolves a field from an array by id or key.
|
|
15
|
+
*
|
|
16
|
+
* @param inputKey - The field id or key to look up.
|
|
17
|
+
* @param allFields - All registered fields.
|
|
18
|
+
* @returns The matching field, or null if not found.
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* resolveField('email', allFields) // Field | null
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveField(inputKey: string, allFields: Field[]): Field | null;
|
|
25
|
+
/**
|
|
26
|
+
* Coerces a scalar value into a single-element array when the field expects multiple values.
|
|
27
|
+
*
|
|
28
|
+
* @param field - The field definition.
|
|
29
|
+
* @param value - The response value to coerce.
|
|
30
|
+
* @returns The original or coerced value.
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* coerceToArray(multipleField, 'hello') // ['hello']
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function coerceToArray(field: Field, value: FieldValue): FieldValue;
|
|
37
|
+
/**
|
|
38
|
+
* Validates that an object field value has the correct shape and is JSON-serializable.
|
|
39
|
+
*
|
|
40
|
+
* @param field - The field definition.
|
|
41
|
+
* @param value - The response value to validate.
|
|
42
|
+
* @returns A validation error if the value is invalid, or null if valid.
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* getObjectValueError(objectField, { key: 'val' }) // null
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function getObjectValueError(field: Field, value: FieldValue): ValidationError | null;
|
|
49
|
+
/**
|
|
50
|
+
* Validates that a response value matches one of the field's allowed options.
|
|
51
|
+
*
|
|
52
|
+
* @param field - The field definition with options.
|
|
53
|
+
* @param value - The response value to validate.
|
|
54
|
+
* @returns A validation error if the value is not a valid option, or null if valid.
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* getOptionsError(fieldWithOptions, 'valid-option') // null
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function getOptionsError(field: Field, value: FieldValue): ValidationError | null;
|
|
61
|
+
/**
|
|
62
|
+
* Runs field-level validation including rule-based validation, required checks, and multiplicity checks.
|
|
63
|
+
*
|
|
64
|
+
* @param evaluateRule - Callback to evaluate rule-based validation logic.
|
|
65
|
+
* @param field - The field definition.
|
|
66
|
+
* @param value - The response value to validate.
|
|
67
|
+
* @param responses - All current responses for cross-field validation.
|
|
68
|
+
* @returns A validation error if the field fails validation, or null if valid.
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* await getFieldValidationError(evaluate, field, 'hello') // null
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function getFieldValidationError(evaluateRule: RuleEvaluator, field: Field, value: FieldValue, responses?: Record<string, FieldValue>): Promise<ValidationError | null>;
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=response-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-validation.d.ts","sourceRoot":"","sources":["../../../../src/entities/response/response-validation.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAuB,MAAM,gBAAgB,CAAA;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAGhE,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;IACtB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;IACrB,KAAK,EAAE,UAAU,CAAA;CAClB;AAED,qEAAqE;AACrE,KAAK,aAAa,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;AA+ElF;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,KAAK,GAAG,IAAI,CAI/E;AAED;;;;;;;;;;GAUG;AAEH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,GAAG,UAAU,CASzE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,GAAG,eAAe,GAAG,IAAI,CAgE3F;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,GAAG,eAAe,GAAG,IAAI,CAsCvF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,uBAAuB,CAC3C,YAAY,EAAE,aAAa,EAC3B,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,UAAU,EACjB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GACrC,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAsCjC"}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { Store } from 'effector';
|
|
2
2
|
import { Picked } from '../../picked';
|
|
3
|
-
import { Field, FieldValue
|
|
3
|
+
import { Field, FieldValue } from '../field/field';
|
|
4
|
+
import { ValidationError } from './response-validation';
|
|
5
|
+
export type { ValidationError } from './response-validation';
|
|
4
6
|
export type ResponsesStore = ReturnType<typeof createResponseIndex>;
|
|
5
7
|
export type Response = FieldValue;
|
|
6
8
|
export interface ResponseListItem {
|
|
9
|
+
/** @deprecated Use `fieldKey` instead. */
|
|
7
10
|
fieldId: string;
|
|
11
|
+
fieldKey: string;
|
|
8
12
|
value: Response | undefined;
|
|
9
13
|
}
|
|
10
14
|
declare const createResponseIndexFactory: ({ client }: {
|
|
11
15
|
client: Picked;
|
|
12
16
|
}) => {
|
|
13
17
|
register: {
|
|
14
|
-
(
|
|
15
|
-
(payload: Record<Field["
|
|
18
|
+
(fieldKey: Field["key"], response: Response): void;
|
|
19
|
+
(payload: Record<Field["key"], Response>, response?: never): void;
|
|
16
20
|
};
|
|
17
21
|
clearAll: import('effector').EventCallable<void>;
|
|
18
22
|
clear: import('effector').EventCallable<string>;
|
|
@@ -25,24 +29,27 @@ declare const createResponseIndexFactory: ({ client }: {
|
|
|
25
29
|
}>;
|
|
26
30
|
listStore: Store<{
|
|
27
31
|
fieldId: string;
|
|
28
|
-
|
|
32
|
+
fieldKey: string;
|
|
33
|
+
value: FieldValue;
|
|
29
34
|
}[]>;
|
|
30
35
|
getAllStore: Store<{
|
|
31
|
-
[
|
|
36
|
+
[fieldKey: string]: FieldValue;
|
|
32
37
|
}>;
|
|
33
|
-
getByFieldId:
|
|
34
|
-
|
|
35
|
-
<T extends JsonValue>(fieldId: Field["id"]): Store<T | null>;
|
|
36
|
-
};
|
|
38
|
+
getByFieldId: (fieldIdOrKey: string) => Store<FieldValue>;
|
|
39
|
+
getByFieldKey: (key: Field["key"]) => Store<FieldValue>;
|
|
37
40
|
getByFieldName: (fieldName: Field["name"]) => Store<FieldValue>;
|
|
38
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Creates a response index instance bound to the given client.
|
|
44
|
+
*
|
|
45
|
+
* @param params - Configuration including the Picked client instance.
|
|
46
|
+
* @returns The response index with register, commit, and lookup methods.
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const responses = createResponseIndex({ client })
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
39
52
|
export declare function createResponseIndex<T extends Parameters<typeof createResponseIndexFactory>[0]>(params: T): ReturnType<typeof createResponseIndexFactory>;
|
|
40
|
-
|
|
41
|
-
export
|
|
42
|
-
fieldId: Field['id'];
|
|
43
|
-
userMessage: string;
|
|
44
|
-
systemMessage: string;
|
|
45
|
-
value: FieldValue;
|
|
46
|
-
}
|
|
47
|
-
export {};
|
|
53
|
+
/** Record keyed by field `key`. */
|
|
54
|
+
export type CommitResponses = Record<string, FieldValue>;
|
|
48
55
|
//# sourceMappingURL=response.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../../../src/entities/response/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiE,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAEpG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../../../src/entities/response/response.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,OAAO,EAAiE,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAEpG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAGvD,OAAO,EAML,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAA;AAE9B,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5D,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAInE,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAA;AAGjC,MAAM,WAAW,gBAAgB;IAC/B,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAA;CAC5B;AAED,QAAA,MAAM,0BAA0B,eAA8B;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE;;mBA6BlD,KAAK,CAAC,KAAK,CAAC,YAAY,QAAQ,GAAG,IAAI;kBACxC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,aAAa,KAAK,GAAG,IAAI;;;;gCAwK7D,eAAe,KACjC,OAAO,CAAC;QAAE,MAAM,EAAE,eAAe,EAAE,CAAA;KAAE,CAAC;8CAtCpB,eAAe,KACjC,OAAO,CAAC;QAAE,iBAAiB,EAAE,eAAe,CAAC;QAAC,gBAAgB,EAAE,eAAe,EAAE,CAAA;KAAE,CAAC;;;;;;;;;iCAsEnD,MAAM,KAAG,KAAK,CAAC,UAAU,CAAC;yBA+BlC,KAAK,CAAC,KAAK,CAAC,KAAG,KAAK,CAAC,UAAU,CAAC;gCA6BzB,KAAK,CAAC,MAAM,CAAC;CA0ChD,CAAA;AAEF;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC,CAAC,CAAC,EAC5F,MAAM,EAAE,CAAC,GACR,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAE/C;AAED,mCAAmC;AACnC,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type StepsStore = ReturnType<typeof createStepIndex>;
|
|
2
|
+
export interface ExperienceStep {
|
|
3
|
+
id: string;
|
|
4
|
+
key: string;
|
|
5
|
+
name: string;
|
|
6
|
+
/** @deprecated Use `name` instead. Populated for backwards compatibility. */
|
|
7
|
+
label?: string;
|
|
8
|
+
fieldIds: string[];
|
|
9
|
+
}
|
|
10
|
+
declare const createStepIndexFactory: () => {
|
|
11
|
+
register: (step: ExperienceStep) => void;
|
|
12
|
+
getById: (id: ExperienceStep["id"]) => import('effector').Store<ExperienceStep | null>;
|
|
13
|
+
listStore: import('effector').Store<ExperienceStep[]>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Creates an Effector-based index for registering and retrieving steps.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const steps = createStepIndex()
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function createStepIndex(): ReturnType<typeof createStepIndexFactory>;
|
|
24
|
+
/**
|
|
25
|
+
* Registers a step with the given index via the helper function.
|
|
26
|
+
*
|
|
27
|
+
* @param step - The step definition to register.
|
|
28
|
+
* @param index - The step index to register the step with.
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* setupStep(step, index)
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function setupStep(step: ExperienceStep, index: ReturnType<typeof createStepIndex>): void;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=step.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../../../src/entities/step/step.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;AAI3D,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB;AAGD,QAAA,MAAM,sBAAsB;qBAuBF,cAAc,KAAG,IAAI;kBAiBxB,cAAc,CAAC,IAAI,CAAC;;CASzC,CAAA;AAEF;;;;;;;GAOG;AACH,wBAAgB,eAAe,IAAI,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAE3E;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,GAAG,IAAI,CAE/F"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { FieldBase, FieldValue } from '../entities/field/field';
|
|
2
|
-
type FieldLike = Pick<FieldBase, 'id' | 'type' | 'multiple'>;
|
|
3
2
|
/**
|
|
4
|
-
* Parses a FormData snapshot into a typed record of field responses.
|
|
3
|
+
* Parses a FormData snapshot into a typed record of field responses keyed by field key. Fields
|
|
4
|
+
* absent from FormData are mapped to `null`. Empty string values are mapped to `null`. Repeated
|
|
5
|
+
* entries for the same field (such as multi-select checkboxes) are merged into a typed array
|
|
6
|
+
* matching the field's declared element type. Values are coerced to the field's declared type.
|
|
5
7
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* @param fields - The field definitions to parse against.
|
|
9
|
+
* @param formData - The FormData snapshot to parse.
|
|
10
|
+
* @returns A record of field keys to their parsed values.
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* buildResponsesFromFormData([field], new FormData(formElement))
|
|
14
|
+
* ```
|
|
11
15
|
*/
|
|
12
|
-
export declare function buildResponsesFromFormData(fields:
|
|
13
|
-
export {};
|
|
16
|
+
export declare function buildResponsesFromFormData(fields: FieldBase[], formData: FormData): Record<string, FieldValue>;
|
|
14
17
|
//# sourceMappingURL=build-responses.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-responses.d.ts","sourceRoot":"","sources":["../../../src/form/build-responses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"build-responses.d.ts","sourceRoot":"","sources":["../../../src/form/build-responses.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAwCpE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,SAAS,EAAE,EACnB,QAAQ,EAAE,QAAQ,GACjB,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAsC5B"}
|
|
@@ -1,17 +1,25 @@
|
|
|
1
|
+
import { Store, StoreWritable } from 'effector';
|
|
1
2
|
import { Field, FieldValue } from '../entities/field/field';
|
|
2
3
|
import { Picked } from '../picked';
|
|
3
|
-
import { Store, StoreWritable } from 'effector';
|
|
4
4
|
/**
|
|
5
5
|
* Creates a reactive store of evaluated fields for a given set of field IDs.
|
|
6
6
|
*
|
|
7
7
|
* Fields are re-evaluated whenever:
|
|
8
|
-
* - The available field IDs change (e.g.
|
|
8
|
+
* - The available field IDs change (e.g. A step is entered)
|
|
9
9
|
* - Any response is committed (options may depend on prior answers)
|
|
10
10
|
* - The global field registry changes (fields registered after init)
|
|
11
|
-
* - Staged values change (field visibility conditions may reference responses.*)
|
|
11
|
+
* - Staged values change (field visibility conditions may reference responses.*).
|
|
12
12
|
*
|
|
13
13
|
* Evaluation runs `getStepFields` with effective responses (committed + staged) as context,
|
|
14
14
|
* so visibility conditions see live in-session values rather than only committed responses.
|
|
15
|
+
*
|
|
16
|
+
* @param client - The Picked client instance.
|
|
17
|
+
* @param fieldIds - Store of field identifiers (keys or IDs) to evaluate.
|
|
18
|
+
* @param stagedValuesStore - Store of in-progress field values not yet committed.
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const { fieldsStore } = createFieldEvaluator(client, fieldIdsStore, stagedStore)
|
|
22
|
+
* ```
|
|
15
23
|
*/
|
|
16
24
|
export declare function createFieldEvaluator(client: Picked, fieldIds: Store<string[]>, stagedValuesStore: StoreWritable<Record<string, FieldValue>>): {
|
|
17
25
|
fieldsStore: Store<Field[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-field-evaluator.d.ts","sourceRoot":"","sources":["../../../src/form/create-field-evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"create-field-evaluator.d.ts","sourceRoot":"","sources":["../../../src/form/create-field-evaluator.ts"],"names":[],"mappings":"AAAA,8GAA8G;AAC9G,OAAO,EAA6C,KAAK,KAAK,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAA;AACpG,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAGvC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,EACzB,iBAAiB,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,GAC3D;IAAE,WAAW,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CA0CjC"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import { EventCallable, Store, StoreWritable } from 'effector';
|
|
1
2
|
import { Field, FieldValue } from '../entities/field/field';
|
|
2
3
|
import { ValidationError } from '../entities/response/response';
|
|
3
4
|
import { Picked } from '../picked';
|
|
4
|
-
import { EventCallable, Store, StoreWritable } from 'effector';
|
|
5
5
|
export interface FieldValidation {
|
|
6
|
-
/** Dispatch
|
|
6
|
+
/** Dispatch on keyboard input — updates staged values and runs validation if the field has been touched. */
|
|
7
|
+
fieldInputEvent: EventCallable<{
|
|
8
|
+
fieldId: string;
|
|
9
|
+
value: FieldValue;
|
|
10
|
+
}>;
|
|
11
|
+
/** Dispatch when a field value is committed (onchange) — updates staged values and runs validation if the field has been touched. */
|
|
7
12
|
fieldChangeEvent: EventCallable<{
|
|
8
13
|
fieldId: string;
|
|
9
14
|
value: FieldValue;
|
|
@@ -34,11 +39,21 @@ export interface FieldValidation {
|
|
|
34
39
|
* Creates the client-side validation slice for a form.
|
|
35
40
|
*
|
|
36
41
|
* Responsibilities:
|
|
37
|
-
* - Tracks which fields have been touched (first blur = touched)
|
|
38
|
-
* - Validates on blur (full: includes required check) and on change (if already touched)
|
|
39
|
-
* - Uses the same json-logic evaluator the server uses, so client and server results match
|
|
42
|
+
* - Tracks which fields have been touched (first blur = touched).
|
|
43
|
+
* - Validates on blur (full: includes required check) and on change (if already touched).
|
|
44
|
+
* - Uses the same json-logic evaluator the server uses, so client and server results match.
|
|
40
45
|
* - Maintains stagedValuesStore: current in-session values used as responses context for
|
|
41
|
-
* condition evaluation, avoiding premature writes to client.responses
|
|
46
|
+
* condition evaluation, avoiding premature writes to client.responses.
|
|
47
|
+
*
|
|
48
|
+
* @param {Picked} client - The Picked client instance providing responses and field registry.
|
|
49
|
+
* @param {Store<Field[]>} fieldsStore - Reactive store of the current field definitions.
|
|
50
|
+
* @param {StoreWritable<Record<string, FieldValue>>} stagedValuesStore - Writable store of in-session field values.
|
|
51
|
+
* @returns {FieldValidation} The validation slice containing events, stores, and wiring.
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* const validation = createFieldValidation(client, fieldsStore, stagedValuesStore)
|
|
55
|
+
* validation.fieldInputEvent({ fieldId: 'email', value: 'hi' })
|
|
56
|
+
* ```
|
|
42
57
|
*/
|
|
43
58
|
export declare function createFieldValidation(client: Picked, fieldsStore: Store<Field[]>, stagedValuesStore: StoreWritable<Record<string, FieldValue>>): FieldValidation;
|
|
44
59
|
//# sourceMappingURL=create-field-validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-field-validation.d.ts","sourceRoot":"","sources":["../../../src/form/create-field-validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"create-field-validation.d.ts","sourceRoot":"","sources":["../../../src/form/create-field-valid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B,iBAAiB,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,GAC3D,eAAe,CA2KjB"}
|
|
@@ -9,13 +9,17 @@ export type FormField = Field & {
|
|
|
9
9
|
/** Validation error for this field, or undefined if valid. */
|
|
10
10
|
error: ValidationError | undefined;
|
|
11
11
|
touched: boolean;
|
|
12
|
-
|
|
13
|
-
onBlur: (e: Event) => void;
|
|
14
|
-
/** HTML-safe attributes to spread onto an input element */
|
|
12
|
+
/** HTML-safe attributes to spread onto an input element. */
|
|
15
13
|
props: {
|
|
16
|
-
name: string;
|
|
17
14
|
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
key: string;
|
|
17
|
+
value: FieldValue | undefined;
|
|
18
|
+
type: 'text' | 'number' | 'checkbox';
|
|
19
|
+
required: boolean;
|
|
20
|
+
placeholder: string | undefined;
|
|
18
21
|
oninput: (e: Event) => void;
|
|
22
|
+
onchange: (e: Event) => void;
|
|
19
23
|
onblur: (e: Event) => void;
|
|
20
24
|
};
|
|
21
25
|
};
|
|
@@ -28,30 +32,42 @@ export interface CreateFormDeps {
|
|
|
28
32
|
experienceInstance: ExperienceInstance;
|
|
29
33
|
}
|
|
30
34
|
/**
|
|
31
|
-
* Return type for createForm()
|
|
35
|
+
* Return type for createForm().
|
|
32
36
|
* Provides form handlers, reactive stores, and callback registration.
|
|
33
37
|
*/
|
|
34
38
|
export interface FormInstance<TFieldIds extends string = string> {
|
|
35
|
-
/** Form element props (bind to
|
|
39
|
+
/** Form element props (bind to a form element). */
|
|
36
40
|
form: {
|
|
37
|
-
/** HTML-safe attributes to spread onto a
|
|
41
|
+
/** HTML-safe attributes to spread onto a form element. */
|
|
38
42
|
props: {
|
|
39
43
|
onsubmit: EventCallable<SubmitEventWithCurrentTarget>;
|
|
40
44
|
};
|
|
41
|
-
/** Flat list of all current validation errors — derived from fieldErrors */
|
|
45
|
+
/** Flat list of all current validation errors — derived from fieldErrors. */
|
|
42
46
|
errors: Store<ValidationError[]>;
|
|
43
|
-
/** Reactive store indicating if form is currently submitting */
|
|
47
|
+
/** Reactive store indicating if form is currently submitting. */
|
|
44
48
|
submitting: Store<boolean>;
|
|
45
49
|
/** Register callbacks to transform/validate data before submission. Returns unsubscribe. */
|
|
46
|
-
|
|
50
|
+
onBeforeSubmit: (callback: SubmitCallback<TFieldIds>) => () => void;
|
|
47
51
|
/** Register callbacks to run on successful form submission. Returns unsubscribe. */
|
|
48
52
|
onSuccess: (callback: SuccessCallback<TFieldIds>) => () => void;
|
|
49
53
|
/** Register callbacks to run on form validation errors. Returns unsubscribe. */
|
|
50
54
|
onError: (callback: ErrorCallback) => () => void;
|
|
51
55
|
};
|
|
52
|
-
/** Reactive store of fields with current values, errors, touched state, and event handlers */
|
|
56
|
+
/** Reactive store of fields with current values, errors, touched state, and event handlers. */
|
|
53
57
|
fields: Store<FormField[]>;
|
|
54
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Extracts the current value from a form input event.
|
|
61
|
+
*
|
|
62
|
+
* @param {Event} e - The DOM event from an input, select, or textarea element.
|
|
63
|
+
* @returns {FieldValue | undefined} The field value, or undefined if the event target is not a recognised form element.
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* input.addEventListener('input', (e) => {
|
|
67
|
+
* const value = getEventValue(e)
|
|
68
|
+
* })
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
55
71
|
export declare function getEventValue(e: Event): FieldValue | undefined;
|
|
56
72
|
/**
|
|
57
73
|
* Creates a form instance tied to a set of field IDs.
|
|
@@ -61,6 +77,21 @@ export declare function getEventValue(e: Event): FieldValue | undefined;
|
|
|
61
77
|
* Framework-agnostic — framework wrappers (Svelte, React) inject
|
|
62
78
|
* client and experienceInstance via the deps parameter and handle
|
|
63
79
|
* callback cleanup lifecycle.
|
|
80
|
+
*
|
|
81
|
+
* @param {CreateFormDeps} deps - Client and experience instance injected by the framework wrapper.
|
|
82
|
+
* @param {string} formId - Unique identifier for this form instance.
|
|
83
|
+
* @param {Store<string>} title - Reactive store holding the form/step title.
|
|
84
|
+
* @param {Store<string[]>} fieldIds - Reactive store of field IDs that belong to this form.
|
|
85
|
+
* @returns {FormInstance} A form instance with reactive field stores, submission handlers, and callback registration.
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* const form = createForm(
|
|
89
|
+
* { client, experienceInstance },
|
|
90
|
+
* 'lead-capture',
|
|
91
|
+
* $title,
|
|
92
|
+
* $fieldIds,
|
|
93
|
+
* )
|
|
94
|
+
* ```
|
|
64
95
|
*/
|
|
65
96
|
export declare function createForm(deps: CreateFormDeps, formId: string, title: Store<string>, fieldIds: Store<string[]>): FormInstance;
|
|
66
97
|
//# sourceMappingURL=create-form.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-form.d.ts","sourceRoot":"","sources":["../../../src/form/create-form.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,KAAK,EAEX,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAA;AAC7F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAGvC,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,4BAA4B,EACjC,KAAK,eAAe,EACrB,MAAM,0BAA0B,CAAA;AAEjC,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG;IAC9B,KAAK,EAAE,UAAU,GAAG,SAAS,CAAA;IAC7B,8DAA8D;IAC9D,KAAK,EAAE,eAAe,GAAG,SAAS,CAAA;IAClC,OAAO,EAAE,OAAO,CAAA;IAChB,
|
|
1
|
+
{"version":3,"file":"create-form.d.ts","sourceRoot":"","sources":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EAAE,kBAAkB,CAAA;CACvC;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM;IAC7D,mDAAmD;IACnD,IAAI,EAAE;QACJ,0DAA0D;QAC1D,KAAK,EAAE;YACL,QAAQ,EAAE,aAAa,CAAC,4BAA4B,CAAC,CAAA;SACtD,CAAA;QACD,6EAA6E;QAC7E,MAAM,EAAE,KAAK,CAAC,eAAe,EAAE,CAAC,CAAA;QAChC,iEAAiE;QACjE,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;QAC1B,4FAA4F;QAC5F,cAAc,EAAE,CAAC,QAAQ,EAAE,cAAc,CAAC,SAAS,CAAC,KAAK,MAAM,IAAI,CAAA;QACnE,oFAAoF;QACpF,SAAS,EAAE,CAAC,QAAQ,EAAE,eAAe,CAAC,SAAS,CAAC,KAAK,MAAM,IAAI,CAAA;QAC/D,gFAAgF;QAChF,OAAO,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,MAAM,IAAI,CAAA;KACjD,CAAA;IACD,+FAA+F;IAC/F,MAAM,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAA;CAC3B;AAED;;;;;;;;;;;GAWG;AAEH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,GAAG,UAAU,GAAG,SAAS,CAW9D;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EACpB,QAAQ,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,GACxB,YAAY,CAoLd"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { Event, EventCallable, Store } from 'effector';
|
|
1
2
|
import { ExperienceInstance } from '../entities/experience-instance/experience-instance';
|
|
2
|
-
import { ExperienceStep } from '../entities/
|
|
3
|
+
import { ExperienceStep } from '../entities/step/step';
|
|
3
4
|
import { Field, FieldValue } from '../entities/field/field';
|
|
4
5
|
import { ValidationError } from '../entities/response/response';
|
|
5
6
|
import { Picked } from '../picked';
|
|
6
|
-
import { Event, EventCallable, Store } from 'effector';
|
|
7
7
|
export type SubmitEventWithCurrentTarget = SubmitEvent & {
|
|
8
8
|
currentTarget: EventTarget & HTMLFormElement;
|
|
9
9
|
};
|
|
@@ -25,7 +25,7 @@ export interface SubmitPipelineConfig {
|
|
|
25
25
|
export interface SubmitPipeline {
|
|
26
26
|
submitEvent: EventCallable<SubmitEventWithCurrentTarget>;
|
|
27
27
|
isFormSubmitting: Store<boolean>;
|
|
28
|
-
|
|
28
|
+
onBeforeSubmit: (callback: SubmitCallback) => () => void;
|
|
29
29
|
onSuccess: (callback: SuccessCallback) => () => void;
|
|
30
30
|
onError: (callback: ErrorCallback) => () => void;
|
|
31
31
|
/**
|
|
@@ -43,16 +43,28 @@ export interface SubmitPipeline {
|
|
|
43
43
|
/**
|
|
44
44
|
* Creates the submit pipeline for a form instance.
|
|
45
45
|
*
|
|
46
|
-
* Manages the full lifecycle of a form submission
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* - Committing responses to the client store
|
|
50
|
-
* - Running onSuccess/onError callbacks in parallel
|
|
51
|
-
* - Navigating to the next step (unless stopNavigation is called)
|
|
46
|
+
* Manages the full lifecycle of a form submission, including emitting event bus
|
|
47
|
+
* calls, running data-transform callbacks, committing responses, running
|
|
48
|
+
* success/error callbacks, and navigating to the next step.
|
|
52
49
|
*
|
|
53
50
|
* Returns coordination events (`submitStarted`, `validationErrorsReceived`) that the
|
|
54
51
|
* caller wires to the validation module to keep validation state in sync without
|
|
55
52
|
* the pipeline needing direct access to validation stores.
|
|
53
|
+
*
|
|
54
|
+
* @param config - The submit pipeline configuration.
|
|
55
|
+
* @param config.client - The Picked client instance.
|
|
56
|
+
* @param config.experienceInstance - The experience instance.
|
|
57
|
+
* @param config.formId - The form identifier.
|
|
58
|
+
* @param config.title - Store containing the form title.
|
|
59
|
+
* @param config.stepStore - Store containing the current step.
|
|
60
|
+
* @param config.fieldsStore - Store containing the form fields.
|
|
61
|
+
* @param config.goToNextStep - Event to trigger navigation to the next step.
|
|
62
|
+
* @returns The submit pipeline with events, stores, and callback registration.
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const pipeline = createSubmitPipeline(config)
|
|
66
|
+
* pipeline.onSuccess(({ data }) => console.log(data))
|
|
67
|
+
* ```
|
|
56
68
|
*/
|
|
57
69
|
export declare function createSubmitPipeline({ client, experienceInstance, formId, title, stepStore, fieldsStore, goToNextStep, }: SubmitPipelineConfig): SubmitPipeline;
|
|
58
70
|
//# sourceMappingURL=create-submit-pipeline.d.ts.map
|