@picked/client 0.0.69 → 0.0.70-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{api-DcI1c_wT.js → api-6xq5wVtp.js} +1 -1
- package/dist/api-CGaBTtfd.cjs +1 -0
- package/dist/cjs/form/index.js +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/preview/index.js +1 -0
- package/dist/cjs/server/index.js +1 -1
- package/dist/docs/image-optimisation-service.md +8 -0
- package/dist/docs/sdk/steps.md +86 -65
- package/dist/esm/form/index.js +143 -70
- package/dist/esm/index.js +243 -211
- package/dist/esm/plugins/dynamic-experiences/index.js +2 -2
- package/dist/esm/preview/index.js +2 -0
- package/dist/esm/server/index.js +1 -1
- package/dist/inert-script-report-B_bMPRzp.js +18 -0
- package/dist/inert-script-report-ijRHPtcY.cjs +1 -0
- package/dist/{plugin-BX2AR2mb.js → plugin-GGRZMJr7.js} +3 -3
- package/dist/{plugin-LQ7Pcc6M.cjs → plugin-p0c8ECxA.cjs} +1 -1
- package/dist/preview-channel-Cx0e6fye.cjs +1 -0
- package/dist/preview-channel-DW9J8t4B.js +98 -0
- package/dist/protocol-Bb_vpLKE.cjs +1 -0
- package/dist/protocol-DSqOlW2r.js +84 -0
- package/dist/types/entities/content/content.d.ts +10 -0
- package/dist/types/entities/content/content.d.ts.map +1 -1
- package/dist/types/exports.d.ts +2 -0
- package/dist/types/exports.d.ts.map +1 -1
- package/dist/types/form/create-submit-pipeline.d.ts +25 -9
- package/dist/types/form/create-submit-pipeline.d.ts.map +1 -1
- package/dist/types/form/index.d.ts +2 -1
- package/dist/types/form/index.d.ts.map +1 -1
- package/dist/types/picked.d.ts +39 -7
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +6 -0
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/preview/index.d.ts +18 -0
- package/dist/types/preview/index.d.ts.map +1 -0
- package/dist/types/preview-channel.d.ts +12 -0
- package/dist/types/preview-channel.d.ts.map +1 -0
- package/dist/types/preview-receiver/apply-ops.d.ts +32 -0
- package/dist/types/preview-receiver/apply-ops.d.ts.map +1 -0
- package/dist/types/preview-receiver/index.d.ts +15 -0
- package/dist/types/preview-receiver/index.d.ts.map +1 -0
- package/dist/types/preview-receiver/protocol.d.ts +60 -0
- package/dist/types/preview-receiver/protocol.d.ts.map +1 -0
- package/dist/types/utils/content-path.d.ts +37 -0
- package/dist/types/utils/content-path.d.ts.map +1 -0
- package/dist/types/utils/events.d.ts +25 -0
- package/dist/types/utils/events.d.ts.map +1 -1
- package/dist/types/utils/inert-script-report.d.ts +40 -0
- package/dist/types/utils/inert-script-report.d.ts.map +1 -0
- package/dist/types/utils/preview-session.d.ts +12 -0
- package/dist/types/utils/preview-session.d.ts.map +1 -0
- package/package.json +14 -2
- package/dist/api-u-1KqkBB.cjs +0 -1
- package/dist/preview-bridge-CpX1BkSA.cjs +0 -1
- package/dist/preview-bridge-D76l-dPy.js +0 -33
package/dist/esm/form/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { t as e } from "../../rules-logic-HesIUCu6.js";
|
|
2
|
+
import "../../logger-DMN6TxJJ.js";
|
|
2
3
|
import { attach as t, combine as n, createEffect as r, createEvent as i, createStore as a, sample as o, split as s } from "effector";
|
|
3
4
|
//#region src/form/build-responses.ts
|
|
4
5
|
function c(e, t, n) {
|
|
@@ -221,33 +222,71 @@ function g(n, r, s) {
|
|
|
221
222
|
}
|
|
222
223
|
//#endregion
|
|
223
224
|
//#region src/form/create-submit-pipeline.ts
|
|
224
|
-
|
|
225
|
+
var _ = 25, v = "Error";
|
|
226
|
+
function y(e, t) {
|
|
227
|
+
return t instanceof Error ? {
|
|
228
|
+
phase: e,
|
|
229
|
+
error: {
|
|
230
|
+
name: t.name,
|
|
231
|
+
message: t.message
|
|
232
|
+
}
|
|
233
|
+
} : typeof t == "string" ? {
|
|
234
|
+
phase: e,
|
|
235
|
+
error: {
|
|
236
|
+
name: v,
|
|
237
|
+
message: t
|
|
238
|
+
}
|
|
239
|
+
} : typeof t == "object" && t && "message" in t && typeof t.message == "string" ? {
|
|
240
|
+
phase: e,
|
|
241
|
+
error: {
|
|
242
|
+
name: "name" in t && typeof t.name == "string" ? t.name : v,
|
|
243
|
+
message: t.message
|
|
244
|
+
}
|
|
245
|
+
} : {
|
|
246
|
+
phase: e,
|
|
247
|
+
error: {
|
|
248
|
+
name: v,
|
|
249
|
+
message: "Unknown callback error"
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
async function b(e, t) {
|
|
254
|
+
return (await Promise.all(t.map(async (t) => {
|
|
255
|
+
try {
|
|
256
|
+
await t();
|
|
257
|
+
return;
|
|
258
|
+
} catch (t) {
|
|
259
|
+
return y(e, t);
|
|
260
|
+
}
|
|
261
|
+
}))).flatMap((e) => e === void 0 ? [] : [e]);
|
|
262
|
+
}
|
|
263
|
+
function x(e) {
|
|
225
264
|
let t = [];
|
|
226
265
|
return {
|
|
227
|
-
executeFx: r(async (...n) => await e(t, ...n)),
|
|
228
|
-
register: (e) =>
|
|
229
|
-
|
|
230
|
-
|
|
266
|
+
executeFx: r(async (...n) => await e(t.map((e) => e.callback), ...n)),
|
|
267
|
+
register: (e) => {
|
|
268
|
+
let n = { callback: e };
|
|
269
|
+
return t.push(n), t.length > _ && `${t.length}`, () => {
|
|
270
|
+
let e = t.indexOf(n);
|
|
271
|
+
e !== -1 && t.splice(e, 1);
|
|
272
|
+
};
|
|
273
|
+
}
|
|
231
274
|
};
|
|
232
275
|
}
|
|
233
|
-
function
|
|
234
|
-
let m = i(), h = i(), g = i(), v = i(),
|
|
235
|
-
|
|
236
|
-
let
|
|
237
|
-
await Promise.all(e.map((e) => Promise.resolve(e(t))));
|
|
238
|
-
}), w = _(async (e, t) => {
|
|
239
|
-
await Promise.all(e.map((e) => Promise.resolve(e(t))));
|
|
240
|
-
}), T = _(async (e, t) => {
|
|
276
|
+
function S({ client: e, experienceInstance: n, formId: c, title: u, stepStore: d, fieldsStore: f, goToNextStep: p }) {
|
|
277
|
+
let m = i(), h = i(), g = i(), _ = i(), v = i(), S = i(), C = a(!1), w = a(!1);
|
|
278
|
+
w.on(_, () => !0).on(m, () => !1);
|
|
279
|
+
let T = m.map(() => void 0), E = x(async (e, t) => b("success", e.map((e) => () => e(t)))), D = x(async (e, t) => b("error", e.map((e) => () => e(t)))), O = x(async (e, t) => {
|
|
241
280
|
let n = t;
|
|
242
281
|
for (let t of e) {
|
|
243
282
|
let e = await Promise.resolve(t(n));
|
|
244
283
|
e !== void 0 && (n = e);
|
|
245
284
|
}
|
|
246
285
|
return n;
|
|
247
|
-
}),
|
|
286
|
+
}), k = r(async (t) => ({
|
|
248
287
|
data: t,
|
|
249
288
|
errors: (await e.responses.commit(t)).errors
|
|
250
|
-
})),
|
|
289
|
+
})), A = t({
|
|
251
290
|
source: {
|
|
252
291
|
step: d,
|
|
253
292
|
title: u
|
|
@@ -266,7 +305,7 @@ function v({ client: e, experienceInstance: n, formId: c, title: u, stepStore: d
|
|
|
266
305
|
experience: n,
|
|
267
306
|
step: t ?? void 0
|
|
268
307
|
}), i))
|
|
269
|
-
}),
|
|
308
|
+
}), j = t({
|
|
270
309
|
source: {
|
|
271
310
|
step: d,
|
|
272
311
|
title: u
|
|
@@ -293,11 +332,25 @@ function v({ client: e, experienceInstance: n, formId: c, title: u, stepStore: d
|
|
|
293
332
|
step: t ?? void 0
|
|
294
333
|
});
|
|
295
334
|
}), i))
|
|
335
|
+
}), M = r(({ step: t, title: r, failures: i }) => {
|
|
336
|
+
i.forEach(({ phase: i, error: a }) => {
|
|
337
|
+
e.eventBus({
|
|
338
|
+
type: "form_submit_callback_error",
|
|
339
|
+
form: {
|
|
340
|
+
id: c,
|
|
341
|
+
title: r
|
|
342
|
+
},
|
|
343
|
+
phase: i,
|
|
344
|
+
error: a,
|
|
345
|
+
experience: n,
|
|
346
|
+
step: t ?? void 0
|
|
347
|
+
});
|
|
348
|
+
});
|
|
296
349
|
});
|
|
297
350
|
return o({
|
|
298
351
|
clock: m,
|
|
299
352
|
fn: () => !0,
|
|
300
|
-
target:
|
|
353
|
+
target: C
|
|
301
354
|
}), o({
|
|
302
355
|
clock: m,
|
|
303
356
|
source: {
|
|
@@ -324,97 +377,117 @@ function v({ client: e, experienceInstance: n, formId: c, title: u, stepStore: d
|
|
|
324
377
|
clock: m,
|
|
325
378
|
source: { stepFields: f },
|
|
326
379
|
fn: ({ stepFields: e }, t) => (t.preventDefault(), l(e, new FormData(t.currentTarget))),
|
|
327
|
-
target:
|
|
380
|
+
target: O.executeFx
|
|
328
381
|
}), o({
|
|
329
|
-
clock:
|
|
330
|
-
target:
|
|
382
|
+
clock: O.executeFx.doneData,
|
|
383
|
+
target: k
|
|
331
384
|
}), s({
|
|
332
|
-
source:
|
|
385
|
+
source: k.doneData,
|
|
333
386
|
match: { hasErrors: ({ errors: e }) => e.length > 0 },
|
|
334
387
|
cases: {
|
|
335
|
-
hasErrors:
|
|
336
|
-
__:
|
|
388
|
+
hasErrors: j,
|
|
389
|
+
__: A
|
|
337
390
|
}
|
|
338
391
|
}), o({
|
|
339
|
-
clock:
|
|
392
|
+
clock: A.doneData,
|
|
340
393
|
target: h
|
|
341
394
|
}), o({
|
|
342
395
|
clock: h,
|
|
343
396
|
fn: (e) => ({
|
|
344
397
|
data: e,
|
|
345
|
-
stopNavigation:
|
|
398
|
+
stopNavigation: _
|
|
346
399
|
}),
|
|
347
|
-
target:
|
|
400
|
+
target: E.executeFx
|
|
348
401
|
}), o({
|
|
349
|
-
clock:
|
|
350
|
-
|
|
402
|
+
clock: [E.executeFx.doneData, D.executeFx.doneData],
|
|
403
|
+
filter: (e) => e.length > 0,
|
|
404
|
+
target: S
|
|
351
405
|
}), o({
|
|
352
|
-
clock:
|
|
353
|
-
|
|
406
|
+
clock: O.executeFx.failData,
|
|
407
|
+
fn: (e) => [y("before-submit", e)],
|
|
408
|
+
target: S
|
|
409
|
+
}), o({
|
|
410
|
+
clock: S,
|
|
411
|
+
source: {
|
|
412
|
+
step: d,
|
|
413
|
+
title: u
|
|
414
|
+
},
|
|
415
|
+
fn: ({ step: e, title: t }, n) => ({
|
|
416
|
+
step: e,
|
|
417
|
+
title: t,
|
|
418
|
+
failures: n
|
|
419
|
+
}),
|
|
420
|
+
target: M
|
|
421
|
+
}), o({
|
|
422
|
+
clock: E.executeFx.done,
|
|
423
|
+
target: v
|
|
424
|
+
}), o({
|
|
425
|
+
clock: v,
|
|
426
|
+
source: w,
|
|
354
427
|
filter: (e) => !e,
|
|
355
428
|
target: p
|
|
356
429
|
}), o({
|
|
357
|
-
clock:
|
|
430
|
+
clock: j.doneData,
|
|
358
431
|
target: g
|
|
359
432
|
}), o({
|
|
360
433
|
clock: g,
|
|
361
|
-
target:
|
|
434
|
+
target: D.executeFx
|
|
362
435
|
}), o({
|
|
363
436
|
clock: [
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
437
|
+
v,
|
|
438
|
+
D.executeFx.done,
|
|
439
|
+
O.executeFx.fail,
|
|
440
|
+
k.fail,
|
|
441
|
+
A.fail,
|
|
442
|
+
j.fail,
|
|
443
|
+
E.executeFx.fail,
|
|
444
|
+
D.executeFx.fail
|
|
372
445
|
],
|
|
373
446
|
fn: () => !1,
|
|
374
|
-
target:
|
|
447
|
+
target: C
|
|
375
448
|
}), {
|
|
376
449
|
submitEvent: m,
|
|
377
|
-
isFormSubmitting:
|
|
378
|
-
onBeforeSubmit:
|
|
379
|
-
onSuccess:
|
|
380
|
-
onError:
|
|
381
|
-
submitStarted:
|
|
450
|
+
isFormSubmitting: C,
|
|
451
|
+
onBeforeSubmit: O.register,
|
|
452
|
+
onSuccess: E.register,
|
|
453
|
+
onError: D.register,
|
|
454
|
+
submitStarted: T,
|
|
382
455
|
validationErrorsReceived: g
|
|
383
456
|
};
|
|
384
457
|
}
|
|
385
458
|
//#endregion
|
|
386
459
|
//#region src/form/create-form.ts
|
|
387
|
-
function
|
|
460
|
+
function C(e) {
|
|
388
461
|
let t = e.currentTarget;
|
|
389
462
|
if (t instanceof HTMLInputElement) return t.type === "checkbox" ? t.checked : t.value;
|
|
390
463
|
if (t instanceof HTMLSelectElement || t instanceof HTMLTextAreaElement) return t.value;
|
|
391
464
|
}
|
|
392
|
-
function
|
|
465
|
+
function w(e, t, n) {
|
|
393
466
|
let r = e.currentTarget;
|
|
394
467
|
if (t.multiple) {
|
|
395
|
-
if (r instanceof HTMLInputElement && r.type === "checkbox") return
|
|
468
|
+
if (r instanceof HTMLInputElement && r.type === "checkbox") return T(e, r, n);
|
|
396
469
|
if (r instanceof HTMLSelectElement && r.multiple) return Array.from(r.selectedOptions, (e) => e.value);
|
|
397
470
|
}
|
|
398
|
-
return
|
|
471
|
+
return C(e);
|
|
399
472
|
}
|
|
400
|
-
function
|
|
473
|
+
function T(e, t, n) {
|
|
401
474
|
if (e.type === "input") return;
|
|
402
475
|
let r = Array.isArray(n) ? n.map(String) : [];
|
|
403
|
-
return e.type === "change" ?
|
|
476
|
+
return e.type === "change" ? E(r, String(t.value)) : r;
|
|
404
477
|
}
|
|
405
|
-
function
|
|
478
|
+
function E(e, t) {
|
|
406
479
|
return e.includes(t) ? e.filter((e) => e !== t) : [...e, t];
|
|
407
480
|
}
|
|
408
|
-
function
|
|
481
|
+
function D(e, t, n) {
|
|
409
482
|
return (r) => {
|
|
410
|
-
let i =
|
|
483
|
+
let i = w(r, e, t);
|
|
411
484
|
i !== void 0 && n({
|
|
412
485
|
fieldKey: e.key,
|
|
413
486
|
value: i
|
|
414
487
|
});
|
|
415
488
|
};
|
|
416
489
|
}
|
|
417
|
-
function
|
|
490
|
+
function O(e, t, r, i) {
|
|
418
491
|
let { client: s, experienceInstance: c } = e, { currentStepStore: l, goToNextStep: u } = c, d = n(l, c, (e, t) => ({
|
|
419
492
|
stepId: e?.id,
|
|
420
493
|
experienceId: t.id
|
|
@@ -429,15 +502,15 @@ function w(e, t, r, i) {
|
|
|
429
502
|
},
|
|
430
503
|
target: f
|
|
431
504
|
});
|
|
432
|
-
let { fieldInputEvent: h, fieldChangeEvent: _, fieldBlurEvent:
|
|
505
|
+
let { fieldInputEvent: h, fieldChangeEvent: _, fieldBlurEvent: v, touchedStore: y, fieldErrorsStore: b, formErrorsStore: x } = g(s, p, f), C = n({
|
|
433
506
|
fields: p,
|
|
434
507
|
responses: s.responses.listStore,
|
|
435
508
|
staged: f,
|
|
436
|
-
fieldErrors:
|
|
437
|
-
touched:
|
|
509
|
+
fieldErrors: b,
|
|
510
|
+
touched: y,
|
|
438
511
|
experienceAndStepId: d
|
|
439
512
|
}, ({ fields: e, responses: t, staged: n, fieldErrors: r, touched: i, experienceAndStepId: a }) => e.map((e) => {
|
|
440
|
-
let o = n[e.key] ?? t.find((t) => t.fieldKey === e.key)?.value ?? e.defaultValue, s =
|
|
513
|
+
let o = n[e.key] ?? t.find((t) => t.fieldKey === e.key)?.value ?? e.defaultValue, s = D(e, o, h), c = D(e, o, _), l = D(e, o, v), u = r[e.key], d = e.type === "number" ? "number" : "text", f = e.type === "boolean" ? "checkbox" : d, { experienceId: p, stepId: m } = a, g = `${p}-${m ?? "step"}-${e.id}`;
|
|
441
514
|
return {
|
|
442
515
|
...e,
|
|
443
516
|
value: o,
|
|
@@ -456,7 +529,7 @@ function w(e, t, r, i) {
|
|
|
456
529
|
onblur: l
|
|
457
530
|
}
|
|
458
531
|
};
|
|
459
|
-
})), { submitEvent:
|
|
532
|
+
})), { submitEvent: w, isFormSubmitting: T, onBeforeSubmit: E, onSuccess: O, onError: k, submitStarted: A, validationErrorsReceived: j } = S({
|
|
460
533
|
client: s,
|
|
461
534
|
experienceInstance: c,
|
|
462
535
|
formId: t,
|
|
@@ -468,27 +541,27 @@ function w(e, t, r, i) {
|
|
|
468
541
|
return o({
|
|
469
542
|
clock: A,
|
|
470
543
|
fn: () => ({}),
|
|
471
|
-
target:
|
|
544
|
+
target: y
|
|
472
545
|
}), o({
|
|
473
546
|
clock: A,
|
|
474
547
|
fn: () => ({}),
|
|
475
|
-
target:
|
|
548
|
+
target: b
|
|
476
549
|
}), o({
|
|
477
550
|
clock: j,
|
|
478
551
|
source: p,
|
|
479
552
|
fn: (e, t) => Object.fromEntries(t.map((t) => [e.find((e) => e.key === t.fieldKey)?.key ?? t.fieldKey, t])),
|
|
480
|
-
target:
|
|
553
|
+
target: b
|
|
481
554
|
}), {
|
|
482
555
|
form: {
|
|
483
|
-
props: { onsubmit:
|
|
484
|
-
errors:
|
|
485
|
-
submitting:
|
|
486
|
-
onBeforeSubmit:
|
|
556
|
+
props: { onsubmit: w },
|
|
557
|
+
errors: x,
|
|
558
|
+
submitting: T,
|
|
559
|
+
onBeforeSubmit: E,
|
|
487
560
|
onSuccess: O,
|
|
488
561
|
onError: k
|
|
489
562
|
},
|
|
490
|
-
fields:
|
|
563
|
+
fields: C
|
|
491
564
|
};
|
|
492
565
|
}
|
|
493
566
|
//#endregion
|
|
494
|
-
export { l as buildResponsesFromFormData, m as createFieldEvaluator, g as createFieldValidation,
|
|
567
|
+
export { l as buildResponsesFromFormData, m as createFieldEvaluator, g as createFieldValidation, O as createForm, S as createSubmitPipeline, C as getEventValue, p as getStepFields };
|