@picked/client 0.0.1-dev.1774231221701 → 0.0.1-dev.1774244905386
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-oudcFuUX.js → api-ENA5t36y.js} +1 -1
- package/dist/{api-BEXzPJHZ.cjs → api-dkMxUUe0.cjs} +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/experience-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
- package/dist/cjs/plugins/single-page-app/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/index.js +503 -426
- package/dist/esm/plugins/create-experience/index.js +329 -294
- package/dist/esm/plugins/dynamic-experiences/index.js +53 -30
- package/dist/esm/plugins/experience-browser-storage/index.js +1 -1
- package/dist/esm/plugins/history-browser-storage/index.js +1 -1
- package/dist/esm/plugins/responses-browser-storage/index.js +1 -1
- package/dist/esm/plugins/responses-indexeddb/index.js +9 -5
- package/dist/esm/plugins/single-page-app/index.js +4 -4
- package/dist/esm/plugins/web-components/index.js +1 -1
- package/dist/esm/server/index.js +1 -1
- package/dist/experience-instance-BODAwa-_.js +713 -0
- package/dist/experience-instance-DImQh64e.cjs +1 -0
- package/dist/object-BReQiaSS.cjs +1 -0
- package/dist/{object-C82v79xc.js → object-Clj5zVr1.js} +1 -2
- package/dist/storage-BFjb8azI.cjs +1 -0
- package/dist/{storage-6Xk0uAxB.js → storage-DyxpJ0pg.js} +1 -3
- package/dist/types/entities/action/action.d.ts.map +1 -1
- 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 +36 -59
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts +2 -2
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/entities/feature/feature.d.ts.map +1 -1
- package/dist/types/entities/field/field.d.ts +17 -12
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/entities/history/history.d.ts.map +1 -1
- package/dist/types/entities/project/project.d.ts +9 -0
- package/dist/types/entities/project/project.d.ts.map +1 -0
- package/dist/types/entities/response/response.d.ts +10 -7
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/entities/step/step.d.ts +38 -0
- package/dist/types/entities/step/step.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logic-engine.d.ts +8 -2
- package/dist/types/logic-engine.d.ts.map +1 -1
- package/dist/types/picked.d.ts +61 -52
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +61 -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/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 +47 -0
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts +1 -2
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/history-browser-storage/plugin.d.ts +0 -1
- package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/responses-browser-storage/plugin.d.ts +1 -2
- package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/responses-indexeddb/plugin.d.ts.map +1 -1
- package/dist/types/plugins/single-page-app/plugin.d.ts +1 -1
- package/dist/types/plugins/single-page-app/plugin.d.ts.map +1 -1
- package/dist/types/utils/dom.d.ts +3 -0
- package/dist/types/utils/dom.d.ts.map +1 -1
- package/dist/types/utils/events.d.ts +2 -2
- package/dist/types/utils/events.d.ts.map +1 -1
- package/dist/types/utils/global-obj.d.ts +1 -0
- package/dist/types/utils/global-obj.d.ts.map +1 -1
- package/dist/types/utils/indexed-db.d.ts +1 -2
- package/dist/types/utils/indexed-db.d.ts.map +1 -1
- package/dist/types/utils/key.d.ts +12 -0
- package/dist/types/utils/key.d.ts.map +1 -0
- package/dist/types/utils/logger.d.ts.map +1 -1
- package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts.map +1 -1
- package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts.map +1 -1
- package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts +3 -3
- package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
- package/dist/types/utils/nodes.d.ts +25 -2
- package/dist/types/utils/nodes.d.ts.map +1 -1
- package/dist/types/utils/object.d.ts +8 -0
- package/dist/types/utils/object.d.ts.map +1 -1
- package/dist/types/utils/picked-config.d.ts +1 -1
- package/dist/types/utils/picked-config.d.ts.map +1 -1
- package/dist/types/utils/search-params.d.ts.map +1 -1
- package/dist/types/utils/storage.d.ts.map +1 -1
- package/package.json +1 -11
- package/dist/cjs/form/index.js +0 -1
- package/dist/esm/form/index.js +0 -428
- package/dist/experience-instance-DZiAwXph.js +0 -481
- package/dist/experience-instance-Ddk4Jktn.cjs +0 -1
- package/dist/object-CUJOjanb.cjs +0 -1
- package/dist/rules-logic-B7vJrWyO.js +0 -231
- package/dist/rules-logic-CXr4wXcG.cjs +0 -1
- package/dist/storage-B6lQtc4-.cjs +0 -1
- package/dist/types/form/build-responses.d.ts +0 -14
- package/dist/types/form/build-responses.d.ts.map +0 -1
- package/dist/types/form/create-field-evaluator.d.ts +0 -19
- package/dist/types/form/create-field-evaluator.d.ts.map +0 -1
- package/dist/types/form/create-field-validation.d.ts +0 -44
- package/dist/types/form/create-field-validation.d.ts.map +0 -1
- package/dist/types/form/create-form.d.ts +0 -66
- package/dist/types/form/create-form.d.ts.map +0 -1
- package/dist/types/form/create-submit-pipeline.d.ts +0 -58
- package/dist/types/form/create-submit-pipeline.d.ts.map +0 -1
- package/dist/types/form/get-step-fields.d.ts +0 -5
- package/dist/types/form/get-step-fields.d.ts.map +0 -1
- package/dist/types/form/index.d.ts +0 -10
- package/dist/types/form/index.d.ts.map +0 -1
- package/dist/types/plugins/create-experience/serialization.d.ts +0 -6
- package/dist/types/plugins/create-experience/serialization.d.ts.map +0 -1
- /package/dist/{id-CRqy981z.js → id-BniPxOdF.js} +0 -0
- /package/dist/{id-Bv44ilEo.cjs → id-CIbS4P60.cjs} +0 -0
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./object-C82v79xc.js";
|
|
2
|
-
//#region src/logic-engine.ts
|
|
3
|
-
function t(e) {
|
|
4
|
-
return typeof e == "number" && !isNaN(e);
|
|
5
|
-
}
|
|
6
|
-
function n(e) {
|
|
7
|
-
return typeof e == "string";
|
|
8
|
-
}
|
|
9
|
-
function r(e) {
|
|
10
|
-
return Array.isArray(e);
|
|
11
|
-
}
|
|
12
|
-
function i(e) {
|
|
13
|
-
return e instanceof Promise;
|
|
14
|
-
}
|
|
15
|
-
function a(e) {
|
|
16
|
-
return typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === 1;
|
|
17
|
-
}
|
|
18
|
-
function o(e) {
|
|
19
|
-
if (t(e)) return e;
|
|
20
|
-
let n = parseFloat(`${e}`);
|
|
21
|
-
return isNaN(n) ? 0 : n;
|
|
22
|
-
}
|
|
23
|
-
function s(e) {
|
|
24
|
-
return `${e}`;
|
|
25
|
-
}
|
|
26
|
-
var c = {
|
|
27
|
-
"==": (e, t) => e == t,
|
|
28
|
-
"===": (e, t) => e === t,
|
|
29
|
-
"!=": (e, t) => e != t,
|
|
30
|
-
"!==": (e, t) => e !== t,
|
|
31
|
-
">": (e, t) => o(e) > o(t),
|
|
32
|
-
">=": (e, t) => o(e) >= o(t),
|
|
33
|
-
"<": (e, t, n) => {
|
|
34
|
-
let r = o(e), i = o(t);
|
|
35
|
-
if (n === void 0) return r < i;
|
|
36
|
-
let a = o(n);
|
|
37
|
-
return r < i && i < a;
|
|
38
|
-
},
|
|
39
|
-
"<=": (e, t, n) => {
|
|
40
|
-
let r = o(e), i = o(t);
|
|
41
|
-
if (n === void 0) return r <= i;
|
|
42
|
-
let a = o(n);
|
|
43
|
-
return r <= i && i <= a;
|
|
44
|
-
},
|
|
45
|
-
"!!": async (e) => await u(e),
|
|
46
|
-
"!": async (e) => !await u(e),
|
|
47
|
-
"%": (e, t) => o(e) % o(t),
|
|
48
|
-
log: (e) => (console.log(e), e),
|
|
49
|
-
in: (e, t) => t ? n(t) ? t.indexOf(s(e)) !== -1 : r(t) ? t.includes(e) : !1 : !1,
|
|
50
|
-
cat: (...e) => e.map(s).join(""),
|
|
51
|
-
substr: (e, t, n) => {
|
|
52
|
-
let r = s(e), i = o(t);
|
|
53
|
-
if (n === void 0) return r.substr(i);
|
|
54
|
-
let a = o(n);
|
|
55
|
-
if (a < 0) {
|
|
56
|
-
let e = r.substr(i);
|
|
57
|
-
return e.substr(0, e.length + a);
|
|
58
|
-
}
|
|
59
|
-
return r.substr(i, a);
|
|
60
|
-
},
|
|
61
|
-
"+": (...e) => e.reduce((e, t) => o(e) + o(t), 0),
|
|
62
|
-
"*": (...e) => e.reduce((e, t) => o(e) * o(t), 1),
|
|
63
|
-
"-": (e, t) => {
|
|
64
|
-
let n = o(e);
|
|
65
|
-
return t === void 0 ? -n : n - o(t);
|
|
66
|
-
},
|
|
67
|
-
"/": (e, t) => o(e) / o(t),
|
|
68
|
-
min: (...e) => Math.min(...e.map(o)),
|
|
69
|
-
max: (...e) => Math.max(...e.map(o)),
|
|
70
|
-
merge: (...e) => e.reduce((e, t) => r(t) ? e.concat(t) : e.concat([t]), []),
|
|
71
|
-
var(e, t) {
|
|
72
|
-
let n = arguments.length > 1 ? t : null;
|
|
73
|
-
if (e === "" || e === "." || e == null) return this;
|
|
74
|
-
if (typeof e == "number" && Array.isArray(this)) return e >= 0 && e < this.length ? this[e] : n;
|
|
75
|
-
let r = s(e);
|
|
76
|
-
if (r === "" || r === ".") return this;
|
|
77
|
-
let i = r.split("."), a = this;
|
|
78
|
-
for (let e of i) {
|
|
79
|
-
if (a == null) return n;
|
|
80
|
-
if (Array.isArray(a)) {
|
|
81
|
-
let t = parseInt(e, 10);
|
|
82
|
-
a = isNaN(t) ? a[e] : a[t];
|
|
83
|
-
} else a = a[e];
|
|
84
|
-
}
|
|
85
|
-
return a === void 0 ? n : a;
|
|
86
|
-
},
|
|
87
|
-
async missing(...e) {
|
|
88
|
-
let t = r(e[0]) ? e[0] : e, n = [];
|
|
89
|
-
for (let e of t) {
|
|
90
|
-
let t = await l({ var: e }, this);
|
|
91
|
-
(t === null || t === "") && n.push(`${e}`);
|
|
92
|
-
}
|
|
93
|
-
return n;
|
|
94
|
-
},
|
|
95
|
-
async missing_some(e, t) {
|
|
96
|
-
let i = await l({ missing: t }, this);
|
|
97
|
-
if (!r(i) || !r(t)) return [];
|
|
98
|
-
let a = i.filter(n);
|
|
99
|
-
return t.filter(n).length - a.length >= o(e) ? [] : a;
|
|
100
|
-
},
|
|
101
|
-
invoke(...e) {
|
|
102
|
-
let [t, ...n] = e;
|
|
103
|
-
return typeof t == "function" ? Reflect.apply(t, null, n) : null;
|
|
104
|
-
},
|
|
105
|
-
regexp_matches(e, t) {
|
|
106
|
-
let i = e, a = "";
|
|
107
|
-
if (r(e)) {
|
|
108
|
-
let [t, n] = e;
|
|
109
|
-
i = t, a = n;
|
|
110
|
-
}
|
|
111
|
-
return !n(i) || !n(a) ? !1 : new RegExp(i, a).test(s(t));
|
|
112
|
-
},
|
|
113
|
-
throw(e) {
|
|
114
|
-
throw Error(s(e));
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
async function l(e, t) {
|
|
118
|
-
if (!e) return e;
|
|
119
|
-
if (i(e)) return l(await e, t);
|
|
120
|
-
if (r(e)) return Promise.all(e.map((e) => l(e, t)));
|
|
121
|
-
if (!a(e)) return e;
|
|
122
|
-
let n = d(e), o = n ? e[n] ?? [] : [];
|
|
123
|
-
switch (r(o) || (o = [o]), n) {
|
|
124
|
-
case "if":
|
|
125
|
-
case "?:":
|
|
126
|
-
for (let e = 0; e < o.length - 1; e += 2) if (await u(await l(o[e], t))) return l(o[e + 1], t);
|
|
127
|
-
return o.length % 2 == 1 ? l(o[o.length - 1], t) : null;
|
|
128
|
-
case "and": {
|
|
129
|
-
let e = null;
|
|
130
|
-
for (let n of o) if (e = await l(n, t), !await u(e)) return e;
|
|
131
|
-
return e;
|
|
132
|
-
}
|
|
133
|
-
case "or": {
|
|
134
|
-
let e = null;
|
|
135
|
-
for (let n of o) if (e = await l(n, t), await u(e)) return e;
|
|
136
|
-
return e;
|
|
137
|
-
}
|
|
138
|
-
case "map": {
|
|
139
|
-
let e = await l(o[0], t);
|
|
140
|
-
return r(e) ? await Promise.all(e.map((e) => l(o[1], e))) : [];
|
|
141
|
-
}
|
|
142
|
-
case "filter": {
|
|
143
|
-
let e = await l(o[0], t);
|
|
144
|
-
return r(e) ? (await Promise.all(e.map(async (e) => ({
|
|
145
|
-
item: e,
|
|
146
|
-
shouldInclude: await u(await l(o[1], e))
|
|
147
|
-
})))).filter(({ shouldInclude: e }) => e).map(({ item: e }) => e) : [];
|
|
148
|
-
}
|
|
149
|
-
case "reduce": {
|
|
150
|
-
let e = await l(o[0], t);
|
|
151
|
-
if (!r(e)) return o.length > 2 ? await l(o[2], t) : null;
|
|
152
|
-
let n = o[1], i = o.length > 2 ? await l(o[2], t) : null;
|
|
153
|
-
for (let t of e) i = await l(n, {
|
|
154
|
-
current: t,
|
|
155
|
-
accumulator: i
|
|
156
|
-
});
|
|
157
|
-
return i;
|
|
158
|
-
}
|
|
159
|
-
case "all": {
|
|
160
|
-
let e = await l(o[0], t);
|
|
161
|
-
if (!r(e) || e.length === 0) return !1;
|
|
162
|
-
for (let t of e) if (!await u(await l(o[1], t))) return !1;
|
|
163
|
-
return !0;
|
|
164
|
-
}
|
|
165
|
-
case "some": {
|
|
166
|
-
let e = await l(o[0], t);
|
|
167
|
-
if (!r(e)) return !1;
|
|
168
|
-
for (let t of e) if (await u(await l(o[1], t))) return !0;
|
|
169
|
-
return !1;
|
|
170
|
-
}
|
|
171
|
-
case "none": {
|
|
172
|
-
let e = await l(o[0], t);
|
|
173
|
-
if (!r(e)) return !0;
|
|
174
|
-
for (let t of e) if (await u(await l(o[1], t))) return !1;
|
|
175
|
-
return !0;
|
|
176
|
-
}
|
|
177
|
-
case "catch": try {
|
|
178
|
-
return await l(o[0], t);
|
|
179
|
-
} catch (e) {
|
|
180
|
-
return a(e) ? await l(e, t) : o[1] ? await l(o[1], e) : e instanceof Error ? e.message : e;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
let s = await Promise.all(o.map((e) => l(e, t))), f = n ? c[n] : void 0;
|
|
184
|
-
if (!f) throw Error(`Unrecognized operation ${n}`);
|
|
185
|
-
return f.apply(t, s);
|
|
186
|
-
}
|
|
187
|
-
async function u(e) {
|
|
188
|
-
return i(e) ? u(await e) : !(Array.isArray(e) && e.length === 0) && !!e;
|
|
189
|
-
}
|
|
190
|
-
function d(e) {
|
|
191
|
-
return Object.keys(e)[0];
|
|
192
|
-
}
|
|
193
|
-
//#endregion
|
|
194
|
-
//#region src/utils/rules-logic.ts
|
|
195
|
-
function f(t) {
|
|
196
|
-
return !e(t);
|
|
197
|
-
}
|
|
198
|
-
async function p(e, t, n) {
|
|
199
|
-
let r = e.getStateSnapshot(), i = e.predicates.listStore.getState().reduce((e, t) => ({
|
|
200
|
-
...e,
|
|
201
|
-
[t.name]: (...e) => t.predicate({
|
|
202
|
-
...r,
|
|
203
|
-
args: e
|
|
204
|
-
})
|
|
205
|
-
}), {}), a = e.features.listStore.getState().reduce((e, t) => ({
|
|
206
|
-
...e,
|
|
207
|
-
[t.id]: async () => {
|
|
208
|
-
let { bucket: e } = await t.getBucket();
|
|
209
|
-
return e;
|
|
210
|
-
}
|
|
211
|
-
}), {});
|
|
212
|
-
return await l(t, {
|
|
213
|
-
...n,
|
|
214
|
-
responses: e.responses.getAllStore.getState(),
|
|
215
|
-
location: typeof r.location == "object" ? {
|
|
216
|
-
hash: r.location.hash,
|
|
217
|
-
host: r.location.host,
|
|
218
|
-
hostname: r.location.hostname,
|
|
219
|
-
href: r.location.href,
|
|
220
|
-
origin: r.location.origin,
|
|
221
|
-
pathname: r.location.pathname,
|
|
222
|
-
port: r.location.port,
|
|
223
|
-
protocol: r.location.protocol,
|
|
224
|
-
search: r.location.search
|
|
225
|
-
} : void 0,
|
|
226
|
-
predicates: i,
|
|
227
|
-
features: a
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
//#endregion
|
|
231
|
-
export { f as n, p as t };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require(`./object-CUJOjanb.cjs`);function t(e){return typeof e==`number`&&!isNaN(e)}function n(e){return typeof e==`string`}function r(e){return Array.isArray(e)}function i(e){return e instanceof Promise}function a(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===1}function o(e){if(t(e))return e;let n=parseFloat(`${e}`);return isNaN(n)?0:n}function s(e){return`${e}`}var c={"==":(e,t)=>e==t,"===":(e,t)=>e===t,"!=":(e,t)=>e!=t,"!==":(e,t)=>e!==t,">":(e,t)=>o(e)>o(t),">=":(e,t)=>o(e)>=o(t),"<":(e,t,n)=>{let r=o(e),i=o(t);if(n===void 0)return r<i;let a=o(n);return r<i&&i<a},"<=":(e,t,n)=>{let r=o(e),i=o(t);if(n===void 0)return r<=i;let a=o(n);return r<=i&&i<=a},"!!":async e=>await u(e),"!":async e=>!await u(e),"%":(e,t)=>o(e)%o(t),log:e=>(console.log(e),e),in:(e,t)=>t?n(t)?t.indexOf(s(e))!==-1:r(t)?t.includes(e):!1:!1,cat:(...e)=>e.map(s).join(``),substr:(e,t,n)=>{let r=s(e),i=o(t);if(n===void 0)return r.substr(i);let a=o(n);if(a<0){let e=r.substr(i);return e.substr(0,e.length+a)}return r.substr(i,a)},"+":(...e)=>e.reduce((e,t)=>o(e)+o(t),0),"*":(...e)=>e.reduce((e,t)=>o(e)*o(t),1),"-":(e,t)=>{let n=o(e);return t===void 0?-n:n-o(t)},"/":(e,t)=>o(e)/o(t),min:(...e)=>Math.min(...e.map(o)),max:(...e)=>Math.max(...e.map(o)),merge:(...e)=>e.reduce((e,t)=>r(t)?e.concat(t):e.concat([t]),[]),var(e,t){let n=arguments.length>1?t:null;if(e===``||e===`.`||e==null)return this;if(typeof e==`number`&&Array.isArray(this))return e>=0&&e<this.length?this[e]:n;let r=s(e);if(r===``||r===`.`)return this;let i=r.split(`.`),a=this;for(let e of i){if(a==null)return n;if(Array.isArray(a)){let t=parseInt(e,10);a=isNaN(t)?a[e]:a[t]}else a=a[e]}return a===void 0?n:a},async missing(...e){let t=r(e[0])?e[0]:e,n=[];for(let e of t){let t=await l({var:e},this);(t===null||t===``)&&n.push(`${e}`)}return n},async missing_some(e,t){let i=await l({missing:t},this);if(!r(i)||!r(t))return[];let a=i.filter(n);return t.filter(n).length-a.length>=o(e)?[]:a},invoke(...e){let[t,...n]=e;return typeof t==`function`?Reflect.apply(t,null,n):null},regexp_matches(e,t){let i=e,a=``;if(r(e)){let[t,n]=e;i=t,a=n}return!n(i)||!n(a)?!1:new RegExp(i,a).test(s(t))},throw(e){throw Error(s(e))}};async function l(e,t){if(!e)return e;if(i(e))return l(await e,t);if(r(e))return Promise.all(e.map(e=>l(e,t)));if(!a(e))return e;let n=d(e),o=n?e[n]??[]:[];switch(r(o)||(o=[o]),n){case`if`:case`?:`:for(let e=0;e<o.length-1;e+=2)if(await u(await l(o[e],t)))return l(o[e+1],t);return o.length%2==1?l(o[o.length-1],t):null;case`and`:{let e=null;for(let n of o)if(e=await l(n,t),!await u(e))return e;return e}case`or`:{let e=null;for(let n of o)if(e=await l(n,t),await u(e))return e;return e}case`map`:{let e=await l(o[0],t);return r(e)?await Promise.all(e.map(e=>l(o[1],e))):[]}case`filter`:{let e=await l(o[0],t);return r(e)?(await Promise.all(e.map(async e=>({item:e,shouldInclude:await u(await l(o[1],e))})))).filter(({shouldInclude:e})=>e).map(({item:e})=>e):[]}case`reduce`:{let e=await l(o[0],t);if(!r(e))return o.length>2?await l(o[2],t):null;let n=o[1],i=o.length>2?await l(o[2],t):null;for(let t of e)i=await l(n,{current:t,accumulator:i});return i}case`all`:{let e=await l(o[0],t);if(!r(e)||e.length===0)return!1;for(let t of e)if(!await u(await l(o[1],t)))return!1;return!0}case`some`:{let e=await l(o[0],t);if(!r(e))return!1;for(let t of e)if(await u(await l(o[1],t)))return!0;return!1}case`none`:{let e=await l(o[0],t);if(!r(e))return!0;for(let t of e)if(await u(await l(o[1],t)))return!1;return!0}case`catch`:try{return await l(o[0],t)}catch(e){return a(e)?await l(e,t):o[1]?await l(o[1],e):e instanceof Error?e.message:e}}let s=await Promise.all(o.map(e=>l(e,t))),f=n?c[n]:void 0;if(!f)throw Error(`Unrecognized operation ${n}`);return f.apply(t,s)}async function u(e){return i(e)?u(await e):!(Array.isArray(e)&&e.length===0)&&!!e}function d(e){return Object.keys(e)[0]}function f(t){return!e.t(t)}async function p(e,t,n){let r=e.getStateSnapshot(),i=e.predicates.listStore.getState().reduce((e,t)=>({...e,[t.name]:(...e)=>t.predicate({...r,args:e})}),{}),a=e.features.listStore.getState().reduce((e,t)=>({...e,[t.id]:async()=>{let{bucket:e}=await t.getBucket();return e}}),{});return await l(t,{...n,responses:e.responses.getAllStore.getState(),location:typeof r.location==`object`?{hash:r.location.hash,host:r.location.host,hostname:r.location.hostname,href:r.location.href,origin:r.location.origin,pathname:r.location.pathname,port:r.location.port,protocol:r.location.protocol,search:r.location.search}:void 0,predicates:i,features:a})}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return p}});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=e=>btoa([...e].map(e=>String.fromCharCode(e.charCodeAt(0)^7)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``);function t(t,n=`global`,r){let i=`pckd`;if(n===`experience`){if(!r)throw Error(`Experience instance is required to scope storage to an experience`);i=`${i}:${r.experienceId}`}return{_:`${i}:${e(t)}`,scope:n}}var n=new Map;function r(e,t){let r=n.get(e._);r&&r.forEach(n=>n(e,t))}function i(e,t,n,i){let a=n===`local`?localStorage:sessionStorage,o=typeof t==`string`?t:JSON.stringify(t);if(a.setItem(e._,o),typeof i==`number`){let t=new Date(Date.now()+i).toISOString();a.setItem(`${e._}:expires-at`,t)}r(e,n)}function a(e,t){let n=t===`local`?localStorage:sessionStorage;n.removeItem(e._),n.removeItem(`${e._}:expires-at`),r(e,t)}function o(e,t,r,i){let a=t===`local`?localStorage:sessionStorage;function o(t){t.storageArea===a&&t.key===e._&&i(r(e))}function s(e,n){n===t&&i(r(e))}window.addEventListener(`storage`,o),n.has(e._)||n.set(e._,new Set);let c=n.get(e._);return c&&c.add(s),function(){window.removeEventListener(`storage`,o);let t=n.get(e._);t&&(t.delete(s),t.size===0&&n.delete(e._))}}function s(e,t){let n=t===`local`?localStorage:sessionStorage,r=n.getItem(e._),c=n.getItem(`${e._}:expires-at`),l=(n,r)=>i(e,n,t,r),u=()=>a(e,t),d=n=>o(e,t,e=>s(e,t),n);return c&&new Date>new Date(c)?(a(e,t),{isSet:()=>!1,text:()=>null,json:()=>null,boolean:()=>null,set:l,remove:u,subscribe:d}):{isSet(){return r!==null},text(){return r},json(){return r?JSON.parse(r):null},boolean(){return r?r===`true`:null},set:l,remove:u,subscribe:d}}var c={get(e){return s(e,`session`)},set(e,t,n){i(e,t,`session`,n)},remove(e){a(e,`session`)},subscribe(e,t){return o(e,`session`,this.get,t)}},l={get(e){return s(e,`local`)},set(e,t,n){i(e,t,`local`,n)},remove(e){a(e,`local`)},subscribe(e,t){return o(e,`local`,this.get,t)}};Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { FieldBase, FieldValue } from '../entities/field/field';
|
|
2
|
-
type FieldLike = Pick<FieldBase, 'id' | 'type' | 'multiple'>;
|
|
3
|
-
/**
|
|
4
|
-
* Parses a FormData snapshot into a typed record of field responses.
|
|
5
|
-
*
|
|
6
|
-
* - Fields absent from FormData are mapped to `null`.
|
|
7
|
-
* - Empty string values are mapped to `null`.
|
|
8
|
-
* - Repeated entries for the same field (e.g. multi-select checkboxes) are
|
|
9
|
-
* merged into a typed array — matching the field's declared element type.
|
|
10
|
-
* - Values are coerced to the field's declared type (text -> string, number -> number, boolean -> boolean).
|
|
11
|
-
*/
|
|
12
|
-
export declare function buildResponsesFromFormData(fields: FieldLike[], formData: FormData): Record<string, FieldValue>;
|
|
13
|
-
export {};
|
|
14
|
-
//# sourceMappingURL=build-responses.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AAEpE,KAAK,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,GAAG,MAAM,GAAG,UAAU,CAAC,CAAA;AAgC5D;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,SAAS,EAAE,EACnB,QAAQ,EAAE,QAAQ,GACjB,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAsC5B"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Field, FieldValue } from '../entities/field/field';
|
|
2
|
-
import { Picked } from '../picked';
|
|
3
|
-
import { Store, StoreWritable } from 'effector';
|
|
4
|
-
/**
|
|
5
|
-
* Creates a reactive store of evaluated fields for a given set of field IDs.
|
|
6
|
-
*
|
|
7
|
-
* Fields are re-evaluated whenever:
|
|
8
|
-
* - The available field IDs change (e.g. a step is entered)
|
|
9
|
-
* - Any response is committed (options may depend on prior answers)
|
|
10
|
-
* - The global field registry changes (fields registered after init)
|
|
11
|
-
* - Staged values change (field visibility conditions may reference responses.*)
|
|
12
|
-
*
|
|
13
|
-
* Evaluation runs `getStepFields` with effective responses (committed + staged) as context,
|
|
14
|
-
* so visibility conditions see live in-session values rather than only committed responses.
|
|
15
|
-
*/
|
|
16
|
-
export declare function createFieldEvaluator(client: Picked, fieldIds: Store<string[]>, stagedValuesStore: StoreWritable<Record<string, FieldValue>>): {
|
|
17
|
-
fieldsStore: Store<Field[]>;
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=create-field-evaluator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-field-evaluator.d.ts","sourceRoot":"","sources":["../../../src/form/create-field-evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAEvC,OAAO,EAA6C,KAAK,KAAK,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAA;AAEpG;;;;;;;;;;;GAWG;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,CAwCjC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Field, FieldValue } from '../entities/field/field';
|
|
2
|
-
import { ValidationError } from '../entities/response/response';
|
|
3
|
-
import { Picked } from '../picked';
|
|
4
|
-
import { EventCallable, Store, StoreWritable } from 'effector';
|
|
5
|
-
export interface FieldValidation {
|
|
6
|
-
/** Dispatch when a field value changes — runs validation if the field has been touched. */
|
|
7
|
-
fieldChangeEvent: EventCallable<{
|
|
8
|
-
fieldId: string;
|
|
9
|
-
value: FieldValue;
|
|
10
|
-
}>;
|
|
11
|
-
/** Dispatch when a field loses focus — always runs full validation including required check. */
|
|
12
|
-
fieldBlurEvent: EventCallable<{
|
|
13
|
-
fieldId: string;
|
|
14
|
-
value: FieldValue;
|
|
15
|
-
}>;
|
|
16
|
-
/** Which fields have been interacted with — used by formFieldsStore to show/hide errors. */
|
|
17
|
-
touchedStore: StoreWritable<Partial<Record<string, boolean>>>;
|
|
18
|
-
/**
|
|
19
|
-
* Per-field validation errors — written by client-side validation and overwritten
|
|
20
|
-
* by server errors on commit failure. Exposed as writable so the submit pipeline
|
|
21
|
-
* can populate server errors and reset state on new submit attempts.
|
|
22
|
-
*/
|
|
23
|
-
fieldErrorsStore: StoreWritable<Partial<Record<string, ValidationError>>>;
|
|
24
|
-
/** Flat list of all current validation errors — derived from fieldErrorsStore. */
|
|
25
|
-
formErrorsStore: Store<ValidationError[]>;
|
|
26
|
-
/**
|
|
27
|
-
* Current in-session field values — updated on every onChange/onBlur before commit.
|
|
28
|
-
* Used as the responses context for condition evaluation so conditions react to
|
|
29
|
-
* live input without writing to client.responses prematurely.
|
|
30
|
-
*/
|
|
31
|
-
stagedValuesStore: StoreWritable<Record<string, FieldValue>>;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Creates the client-side validation slice for a form.
|
|
35
|
-
*
|
|
36
|
-
* 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
|
|
40
|
-
* - Maintains stagedValuesStore: current in-session values used as responses context for
|
|
41
|
-
* condition evaluation, avoiding premature writes to client.responses
|
|
42
|
-
*/
|
|
43
|
-
export declare function createFieldValidation(client: Picked, fieldsStore: Store<Field[]>, stagedValuesStore: StoreWritable<Record<string, FieldValue>>): FieldValidation;
|
|
44
|
-
//# sourceMappingURL=create-field-validation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AAEvC,OAAO,EAKL,KAAK,aAAa,EAClB,KAAK,KAAK,EACV,KAAK,aAAa,EACnB,MAAM,UAAU,CAAA;AAMjB,MAAM,WAAW,eAAe;IAC9B,2FAA2F;IAC3F,gBAAgB,EAAE,aAAa,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,UAAU,CAAA;KAAE,CAAC,CAAA;IACvE,gGAAgG;IAChG,cAAc,EAAE,aAAa,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,UAAU,CAAA;KAAE,CAAC,CAAA;IACrE,4FAA4F;IAC5F,YAAY,EAAE,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;IAC7D;;;;OAIG;IACH,gBAAgB,EAAE,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,CAAA;IACzE,kFAAkF;IAClF,eAAe,EAAE,KAAK,CAAC,eAAe,EAAE,CAAC,CAAA;IACzC;;;;OAIG;IACH,iBAAiB,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;CAC7D;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,EAC3B,iBAAiB,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,GAC3D,eAAe,CA0JjB"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { EventCallable, Store } from 'effector';
|
|
2
|
-
import { Field, FieldValue } from '../entities/field/field';
|
|
3
|
-
import { ExperienceInstance } from '../entities/experience-instance/experience-instance';
|
|
4
|
-
import { ValidationError } from '../entities/response/response';
|
|
5
|
-
import { Picked } from '../picked';
|
|
6
|
-
import { ErrorCallback, SubmitCallback, SubmitEventWithCurrentTarget, SuccessCallback } from './create-submit-pipeline';
|
|
7
|
-
export type FormField = Field & {
|
|
8
|
-
value: FieldValue | undefined;
|
|
9
|
-
/** Validation error for this field, or undefined if valid. */
|
|
10
|
-
error: ValidationError | undefined;
|
|
11
|
-
touched: boolean;
|
|
12
|
-
onChange: (e: Event) => void;
|
|
13
|
-
onBlur: (e: Event) => void;
|
|
14
|
-
/** HTML-safe attributes to spread onto an input element */
|
|
15
|
-
props: {
|
|
16
|
-
name: string;
|
|
17
|
-
id: string;
|
|
18
|
-
oninput: (e: Event) => void;
|
|
19
|
-
onblur: (e: Event) => void;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Dependencies that framework wrappers inject into createForm.
|
|
24
|
-
* Replaces Svelte's getPicked()/getExperience() context calls.
|
|
25
|
-
*/
|
|
26
|
-
export interface CreateFormDeps {
|
|
27
|
-
client: Picked;
|
|
28
|
-
experienceInstance: ExperienceInstance;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Return type for createForm()
|
|
32
|
-
* Provides form handlers, reactive stores, and callback registration.
|
|
33
|
-
*/
|
|
34
|
-
export interface FormInstance<TFieldIds extends string = string> {
|
|
35
|
-
/** Form element props (bind to <form>) */
|
|
36
|
-
form: {
|
|
37
|
-
/** HTML-safe attributes to spread onto a <form> element */
|
|
38
|
-
props: {
|
|
39
|
-
onsubmit: EventCallable<SubmitEventWithCurrentTarget>;
|
|
40
|
-
};
|
|
41
|
-
/** Flat list of all current validation errors — derived from fieldErrors */
|
|
42
|
-
errors: Store<ValidationError[]>;
|
|
43
|
-
/** Reactive store indicating if form is currently submitting */
|
|
44
|
-
submitting: Store<boolean>;
|
|
45
|
-
/** Register callbacks to transform/validate data before submission. Returns unsubscribe. */
|
|
46
|
-
onSubmit: (callback: SubmitCallback<TFieldIds>) => () => void;
|
|
47
|
-
/** Register callbacks to run on successful form submission. Returns unsubscribe. */
|
|
48
|
-
onSuccess: (callback: SuccessCallback<TFieldIds>) => () => void;
|
|
49
|
-
/** Register callbacks to run on form validation errors. Returns unsubscribe. */
|
|
50
|
-
onError: (callback: ErrorCallback) => () => void;
|
|
51
|
-
};
|
|
52
|
-
/** Reactive store of fields with current values, errors, touched state, and event handlers */
|
|
53
|
-
fields: Store<FormField[]>;
|
|
54
|
-
}
|
|
55
|
-
export declare function getEventValue(e: Event): FieldValue | undefined;
|
|
56
|
-
/**
|
|
57
|
-
* Creates a form instance tied to a set of field IDs.
|
|
58
|
-
* Handles field evaluation, form submission, data transformation,
|
|
59
|
-
* validation, event bus tracking, and step navigation.
|
|
60
|
-
*
|
|
61
|
-
* Framework-agnostic — framework wrappers (Svelte, React) inject
|
|
62
|
-
* client and experienceInstance via the deps parameter and handle
|
|
63
|
-
* callback cleanup lifecycle.
|
|
64
|
-
*/
|
|
65
|
-
export declare function createForm(deps: CreateFormDeps, formId: string, title: Store<string>, fieldIds: Store<string[]>): FormInstance;
|
|
66
|
-
//# sourceMappingURL=create-form.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAA;IAC5B,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAA;IAC1B,2DAA2D;IAC3D,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAA;QACZ,EAAE,EAAE,MAAM,CAAA;QACV,OAAO,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAA;QAC3B,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAA;KAC3B,CAAA;CACF,CAAA;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,kBAAkB,EAAE,kBAAkB,CAAA;CACvC;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM;IAC7D,0CAA0C;IAC1C,IAAI,EAAE;QACJ,2DAA2D;QAC3D,KAAK,EAAE;YACL,QAAQ,EAAE,aAAa,CAAC,4BAA4B,CAAC,CAAA;SACtD,CAAA;QACD,4EAA4E;QAC5E,MAAM,EAAE,KAAK,CAAC,eAAe,EAAE,CAAC,CAAA;QAChC,gEAAgE;QAChE,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;QAC1B,4FAA4F;QAC5F,QAAQ,EAAE,CAAC,QAAQ,EAAE,cAAc,CAAC,SAAS,CAAC,KAAK,MAAM,IAAI,CAAA;QAC7D,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,8FAA8F;IAC9F,MAAM,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAA;CAC3B;AAGD,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,GAAG,UAAU,GAAG,SAAS,CAW9D;AAED;;;;;;;;GAQG;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,CAoHd"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { ExperienceInstance } from '../entities/experience-instance/experience-instance';
|
|
2
|
-
import { ExperienceStep } from '../entities/experience/experience';
|
|
3
|
-
import { Field, FieldValue } from '../entities/field/field';
|
|
4
|
-
import { ValidationError } from '../entities/response/response';
|
|
5
|
-
import { Picked } from '../picked';
|
|
6
|
-
import { Event, EventCallable, Store } from 'effector';
|
|
7
|
-
export type SubmitEventWithCurrentTarget = SubmitEvent & {
|
|
8
|
-
currentTarget: EventTarget & HTMLFormElement;
|
|
9
|
-
};
|
|
10
|
-
export type SuccessCallback<TFieldIds extends string = string> = (options: {
|
|
11
|
-
data: Record<TFieldIds, FieldValue>;
|
|
12
|
-
stopNavigation: EventCallable<void>;
|
|
13
|
-
}) => void | Promise<void>;
|
|
14
|
-
export type ErrorCallback = (errors: ValidationError[]) => void | Promise<void>;
|
|
15
|
-
export type SubmitCallback<TFieldIds extends string = string> = (data: Record<TFieldIds, FieldValue>) => Record<TFieldIds, FieldValue> | void | Promise<Record<TFieldIds, FieldValue> | void>;
|
|
16
|
-
export interface SubmitPipelineConfig {
|
|
17
|
-
client: Picked;
|
|
18
|
-
experienceInstance: ExperienceInstance;
|
|
19
|
-
formId: string;
|
|
20
|
-
title: Store<string>;
|
|
21
|
-
stepStore: Store<ExperienceStep | null>;
|
|
22
|
-
fieldsStore: Store<Field[]>;
|
|
23
|
-
goToNextStep: EventCallable<void>;
|
|
24
|
-
}
|
|
25
|
-
export interface SubmitPipeline {
|
|
26
|
-
submitEvent: EventCallable<SubmitEventWithCurrentTarget>;
|
|
27
|
-
isFormSubmitting: Store<boolean>;
|
|
28
|
-
onSubmit: (callback: SubmitCallback) => () => void;
|
|
29
|
-
onSuccess: (callback: SuccessCallback) => () => void;
|
|
30
|
-
onError: (callback: ErrorCallback) => () => void;
|
|
31
|
-
/**
|
|
32
|
-
* Fired when a submit attempt starts — callers use this to clear validation state.
|
|
33
|
-
* Separating this from `submitEvent` keeps the pipeline decoupled from the
|
|
34
|
-
* validation module's internal stores.
|
|
35
|
-
*/
|
|
36
|
-
submitStarted: Event<void>;
|
|
37
|
-
/**
|
|
38
|
-
* Fired when commit returns validation errors — callers write these to
|
|
39
|
-
* `fieldErrorsStore` in the validation module.
|
|
40
|
-
*/
|
|
41
|
-
validationErrorsReceived: Event<ValidationError[]>;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Creates the submit pipeline for a form instance.
|
|
45
|
-
*
|
|
46
|
-
* Manages the full lifecycle of a form submission:
|
|
47
|
-
* - Emitting event bus calls (form_submit, form_submit_success, form_submit_error)
|
|
48
|
-
* - Running onSubmit data-transform callbacks in series
|
|
49
|
-
* - Committing responses to the client store
|
|
50
|
-
* - Running onSuccess/onError callbacks in parallel
|
|
51
|
-
* - Navigating to the next step (unless stopNavigation is called)
|
|
52
|
-
*
|
|
53
|
-
* Returns coordination events (`submitStarted`, `validationErrorsReceived`) that the
|
|
54
|
-
* caller wires to the validation module to keep validation state in sync without
|
|
55
|
-
* the pipeline needing direct access to validation stores.
|
|
56
|
-
*/
|
|
57
|
-
export declare function createSubmitPipeline({ client, experienceInstance, formId, title, stepStore, fieldsStore, goToNextStep, }: SubmitPipelineConfig): SubmitPipeline;
|
|
58
|
-
//# sourceMappingURL=create-submit-pipeline.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-submit-pipeline.d.ts","sourceRoot":"","sources":["../../../src/form/create-submit-pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAA;AAC7F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AACvE,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;AACvC,OAAO,EAOL,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,KAAK,EACX,MAAM,UAAU,CAAA;AAGjB,MAAM,MAAM,4BAA4B,GAAG,WAAW,GAAG;IACvD,aAAa,EAAE,WAAW,GAAG,eAAe,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,eAAe,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE;IACzE,IAAI,EAAE,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;IACnC,cAAc,EAAE,aAAa,CAAC,IAAI,CAAC,CAAA;CACpC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AAE1B,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AAE/E,MAAM,MAAM,cAAc,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM,IAAI,CAC9D,IAAI,EAAE,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,KAChC,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,IAAI,CAAC,CAAA;AAOzF,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,kBAAkB,EAAE,kBAAkB,CAAA;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACpB,SAAS,EAAE,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IACvC,WAAW,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAA;IAC3B,YAAY,EAAE,aAAa,CAAC,IAAI,CAAC,CAAA;CAClC;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,aAAa,CAAC,4BAA4B,CAAC,CAAA;IACxD,gBAAgB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;IAChC,QAAQ,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,MAAM,IAAI,CAAA;IAClD,SAAS,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,MAAM,IAAI,CAAA;IACpD,OAAO,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,MAAM,IAAI,CAAA;IAChD;;;;OAIG;IACH,aAAa,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;IAC1B;;;OAGG;IACH,wBAAwB,EAAE,KAAK,CAAC,eAAe,EAAE,CAAC,CAAA;CACnD;AAoCD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,MAAM,EACN,kBAAkB,EAClB,MAAM,EACN,KAAK,EACL,SAAS,EACT,WAAW,EACX,YAAY,GACb,EAAE,oBAAoB,GAAG,cAAc,CAgMvC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Field } from '../entities/field/field';
|
|
2
|
-
import { Picked } from '../picked';
|
|
3
|
-
import { evaluateRuleLogic } from '../utils/rules-logic';
|
|
4
|
-
export declare function getStepFields<T extends Field>(client: Picked, fields: T[], context?: Parameters<typeof evaluateRuleLogic>[2]): Promise<T[]>;
|
|
5
|
-
//# sourceMappingURL=get-step-fields.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-step-fields.d.ts","sourceRoot":"","sources":["../../../src/form/get-step-fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAUxD,wBAAsB,aAAa,CAAC,CAAC,SAAS,KAAK,EACjD,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,CAAC,EAAE,EACX,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC,CAAC,CAAC,GAChD,OAAO,CAAC,CAAC,EAAE,CAAC,CAoDd"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { buildResponsesFromFormData } from './build-responses';
|
|
2
|
-
export { getStepFields } from './get-step-fields';
|
|
3
|
-
export { createFieldEvaluator } from './create-field-evaluator';
|
|
4
|
-
export { createFieldValidation } from './create-field-validation';
|
|
5
|
-
export type { FieldValidation } from './create-field-validation';
|
|
6
|
-
export { createSubmitPipeline } from './create-submit-pipeline';
|
|
7
|
-
export type { SubmitPipelineConfig, SubmitPipeline, SubmitEventWithCurrentTarget, SuccessCallback, ErrorCallback, SubmitCallback, } from './create-submit-pipeline';
|
|
8
|
-
export { createForm, getEventValue } from './create-form';
|
|
9
|
-
export type { CreateFormDeps, FormField, FormInstance } from './create-form';
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/form/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AACjE,YAAY,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC/D,YAAY,EACV,oBAAoB,EACpB,cAAc,EACd,4BAA4B,EAC5B,eAAe,EACf,aAAa,EACb,cAAc,GACf,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACzD,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../../src/plugins/create-experience/serialization.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,MAAM,CAAA;AAElC,eAAO,MAAM,aAAa;cACd,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;gBAGvB,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC;CAGtC,CAAA"}
|
|
File without changes
|
|
File without changes
|