@verbb/formie-core 1.0.9 → 1.0.11
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/CHANGELOG.md +11 -1
- package/dist/form-instance.d.ts.map +1 -1
- package/dist/index.js +79 -70
- package/dist/rest.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
-
## 1.0.
|
|
5
|
+
## 1.0.11 - 2026-06-26
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
- Send CSRF tokens from `session.tokens.csrf` on client REST `submit`, `refreshSession`, and `setPage` requests when guest CSRF validation is enabled on the server.
|
|
9
|
+
|
|
10
|
+
## 1.0.10 - 2026-06-26
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- Align headless client-side validation messages with server-side Formie copy, including field labels in required, email, number, min/max, URL, and match validation errors. ([#2907](https://github.com/verbb/formie/issues/2907))
|
|
14
|
+
|
|
15
|
+
## 1.0.9 - 2026-06-25
|
|
6
16
|
|
|
7
17
|
### Added
|
|
8
18
|
- Extend `FrontendSubmitResult` and `submitFormieClientForm` GraphQL selections with payment follow-up fields (`paymentStatus`, `paymentMessage`, `paymentRedirectUrl`, `paymentAction`, `paymentDecision`, `keepSubmitLoading`), plus `quizResult` and `clientEvents`. ([#1375](https://github.com/verbb/formie/issues/1375))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-instance.d.ts","sourceRoot":"","sources":["../src/form-instance.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAER,oBAAoB,EACpB,oBAAoB,EAIpB,iBAAiB,EACpB,MAAM,SAAS,CAAC;AAEjB,KAAK,iCAAiC,GAAG;IACrC,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,SAAS,EAAE,iBAAiB,CAAC;CAChC,CAAC;
|
|
1
|
+
{"version":3,"file":"form-instance.d.ts","sourceRoot":"","sources":["../src/form-instance.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAER,oBAAoB,EACpB,oBAAoB,EAIpB,iBAAiB,EACpB,MAAM,SAAS,CAAC;AAEjB,KAAK,iCAAiC,GAAG;IACrC,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,SAAS,EAAE,iBAAiB,CAAC;CAChC,CAAC;AAucF,wBAAgB,0BAA0B,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,iCAAiC,GAAG,oBAAoB,CA8R3H"}
|
package/dist/index.js
CHANGED
|
@@ -438,43 +438,47 @@ function Y(e) {
|
|
|
438
438
|
function he(e, t) {
|
|
439
439
|
return e.type === "checkboxes" ? !Array.isArray(t) || t.length === 0 : O(e) ? t !== !0 : E(e) || T(e) || D(e) ? !Array.isArray(t) || t.length === 0 : w(e) && t && typeof t == "object" ? Object.values(t).every((e) => e == null || typeof e == "string" && e.trim() === "") : t == null ? !0 : typeof t == "string" ? t.trim() === "" : !1;
|
|
440
440
|
}
|
|
441
|
+
function X(e) {
|
|
442
|
+
return e.label?.trim() || e.handle;
|
|
443
|
+
}
|
|
441
444
|
function ge(e, t, n, r, i) {
|
|
442
445
|
let a = new Set(e.validation.map((e) => e.type)), o = e.input;
|
|
443
446
|
if ((e.required || a.has("required")) && he(e, t)) {
|
|
444
|
-
i[r] = [
|
|
447
|
+
i[r] = [`${X(e)} cannot be blank.`];
|
|
445
448
|
return;
|
|
446
449
|
}
|
|
447
450
|
if ((te(e) || a.has("email")) && typeof t == "string" && t.trim() !== "" && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)) {
|
|
448
|
-
i[r] = [
|
|
451
|
+
i[r] = [`${X(e)} is not a valid email address.`];
|
|
449
452
|
return;
|
|
450
453
|
}
|
|
451
454
|
if ((k(e) || a.has("number")) && typeof t == "string" && t.trim() !== "") {
|
|
452
455
|
let n = Number.parseFloat(t);
|
|
453
456
|
if (!Number.isFinite(n)) {
|
|
454
|
-
i[r] = [
|
|
457
|
+
i[r] = [`${X(e)} is not a valid number.`];
|
|
455
458
|
return;
|
|
456
459
|
}
|
|
457
460
|
let a = e.validation.find((e) => e.type === "number"), s = Number(o.min ?? a?.min ?? NaN), c = Number(o.max ?? a?.max ?? NaN);
|
|
458
461
|
if (Number.isFinite(s) && n < s) {
|
|
459
|
-
i[r] = [
|
|
462
|
+
i[r] = [`${X(e)} must be no less than ${s}.`];
|
|
460
463
|
return;
|
|
461
464
|
}
|
|
462
465
|
if (Number.isFinite(c) && n > c) {
|
|
463
|
-
i[r] = [
|
|
466
|
+
i[r] = [`${X(e)} must be no greater than ${c}.`];
|
|
464
467
|
return;
|
|
465
468
|
}
|
|
466
469
|
}
|
|
467
470
|
if (a.has("url") && typeof t == "string" && t.trim() !== "") try {
|
|
468
471
|
new URL(t);
|
|
469
472
|
} catch {
|
|
470
|
-
i[r] = [
|
|
473
|
+
i[r] = [`${X(e)} is not a valid URL.`];
|
|
471
474
|
return;
|
|
472
475
|
}
|
|
473
476
|
let s = e.validation.find((e) => e.type === "match");
|
|
474
477
|
if (s && typeof t == "string" && t.trim() !== "") {
|
|
475
|
-
let
|
|
476
|
-
if (typeof
|
|
477
|
-
|
|
478
|
+
let a = (s.fieldId ? y(n.definition, s.fieldId) : void 0) || (s.fieldHandle ? b(n.definition, s.fieldHandle) : void 0), o = a ? n.values[a.id] : void 0;
|
|
479
|
+
if (typeof o == "string" && o !== t) {
|
|
480
|
+
let t = a ? X(a) : e.handle;
|
|
481
|
+
i[r] = [`${X(e)} must match ${t}.`];
|
|
478
482
|
return;
|
|
479
483
|
}
|
|
480
484
|
}
|
|
@@ -3323,79 +3327,84 @@ function ke(e, t, n) {
|
|
|
3323
3327
|
}
|
|
3324
3328
|
//#endregion
|
|
3325
3329
|
//#region src/rest.ts
|
|
3326
|
-
function
|
|
3330
|
+
function Z(e, t) {
|
|
3327
3331
|
if (t.startsWith("http://") || t.startsWith("https://")) return t;
|
|
3328
3332
|
if (e.startsWith("http://") || e.startsWith("https://")) return new URL(t, e).toString();
|
|
3329
3333
|
let n = e.trim();
|
|
3330
3334
|
return !n || n === "/" ? t : `${n.replace(/\/+$/, "")}${t}`;
|
|
3331
3335
|
}
|
|
3332
|
-
async function
|
|
3336
|
+
async function Q(e, t) {
|
|
3333
3337
|
let n = await fetch(e, t);
|
|
3334
3338
|
if (!n.ok) throw Error(`Request failed with status ${n.status}.`);
|
|
3335
3339
|
return n.json();
|
|
3336
3340
|
}
|
|
3337
|
-
|
|
3338
|
-
let
|
|
3341
|
+
function Ae(e, t) {
|
|
3342
|
+
let n = t?.tokens?.csrf;
|
|
3343
|
+
!n?.name || !n.value || (e[n.name] = n.value);
|
|
3344
|
+
}
|
|
3345
|
+
async function je(e) {
|
|
3346
|
+
let t = Z(e.endpoint, "/actions/formie/client/forms/load"), n = JSON.stringify({
|
|
3339
3347
|
handle: e.formHandle,
|
|
3340
3348
|
siteId: e.siteId
|
|
3341
3349
|
});
|
|
3342
|
-
return
|
|
3350
|
+
return Q(t, {
|
|
3343
3351
|
method: "POST",
|
|
3344
3352
|
credentials: e.credentials ?? "same-origin",
|
|
3345
3353
|
headers: { "Content-Type": "application/json" },
|
|
3346
3354
|
body: n
|
|
3347
3355
|
});
|
|
3348
3356
|
}
|
|
3349
|
-
function
|
|
3357
|
+
function Me(e) {
|
|
3350
3358
|
return {
|
|
3351
3359
|
async submit({ definition: t, session: n, values: r, action: i }) {
|
|
3352
|
-
let a =
|
|
3353
|
-
|
|
3360
|
+
let a = Z(e.endpoint, "/actions/formie/client/submissions/submit"), o = await R(t, r), s = {
|
|
3361
|
+
handle: e.formHandle,
|
|
3362
|
+
siteId: e.siteId,
|
|
3363
|
+
action: i,
|
|
3364
|
+
session: n,
|
|
3365
|
+
values: o
|
|
3366
|
+
};
|
|
3367
|
+
return Ae(s, n), Q(a, {
|
|
3354
3368
|
method: "POST",
|
|
3355
3369
|
credentials: e.credentials ?? "same-origin",
|
|
3356
3370
|
headers: { "Content-Type": "application/json" },
|
|
3357
|
-
body: JSON.stringify(
|
|
3358
|
-
handle: e.formHandle,
|
|
3359
|
-
siteId: e.siteId,
|
|
3360
|
-
action: i,
|
|
3361
|
-
session: n,
|
|
3362
|
-
values: o
|
|
3363
|
-
})
|
|
3371
|
+
body: JSON.stringify(s)
|
|
3364
3372
|
});
|
|
3365
3373
|
},
|
|
3366
3374
|
async refreshSession({ session: t }) {
|
|
3367
|
-
|
|
3375
|
+
let n = Z(e.endpoint, "/actions/formie/client/sessions/refresh"), r = {
|
|
3376
|
+
handle: e.formHandle,
|
|
3377
|
+
siteId: e.siteId,
|
|
3378
|
+
session: t
|
|
3379
|
+
};
|
|
3380
|
+
return Ae(r, t), Q(n, {
|
|
3368
3381
|
method: "POST",
|
|
3369
3382
|
credentials: e.credentials ?? "same-origin",
|
|
3370
3383
|
headers: { "Content-Type": "application/json" },
|
|
3371
|
-
body: JSON.stringify(
|
|
3372
|
-
handle: e.formHandle,
|
|
3373
|
-
siteId: e.siteId,
|
|
3374
|
-
session: t
|
|
3375
|
-
})
|
|
3384
|
+
body: JSON.stringify(r)
|
|
3376
3385
|
});
|
|
3377
3386
|
},
|
|
3378
3387
|
async setPage({ definition: t, session: n, values: r, currentPageId: i, targetPageId: a }) {
|
|
3379
|
-
let o =
|
|
3380
|
-
|
|
3388
|
+
let o = Z(e.endpoint, "/actions/formie/client/forms/page"), s = await R(t, r), c = {
|
|
3389
|
+
handle: e.formHandle,
|
|
3390
|
+
siteId: e.siteId,
|
|
3391
|
+
currentPageId: i,
|
|
3392
|
+
targetPageId: a,
|
|
3393
|
+
session: n,
|
|
3394
|
+
values: s
|
|
3395
|
+
};
|
|
3396
|
+
return Ae(c, n), Q(o, {
|
|
3381
3397
|
method: "POST",
|
|
3382
3398
|
credentials: e.credentials ?? "same-origin",
|
|
3383
3399
|
headers: { "Content-Type": "application/json" },
|
|
3384
|
-
body: JSON.stringify(
|
|
3385
|
-
handle: e.formHandle,
|
|
3386
|
-
siteId: e.siteId,
|
|
3387
|
-
currentPageId: i,
|
|
3388
|
-
targetPageId: a,
|
|
3389
|
-
session: n,
|
|
3390
|
-
values: s
|
|
3391
|
-
})
|
|
3400
|
+
body: JSON.stringify(c)
|
|
3392
3401
|
});
|
|
3393
3402
|
}
|
|
3394
3403
|
};
|
|
3395
3404
|
}
|
|
3396
3405
|
//#endregion
|
|
3397
3406
|
//#region src/graphql.ts
|
|
3398
|
-
var
|
|
3407
|
+
var $ = "\n id\n currentPageId\n tokens\n continuation\n", Ne = `
|
|
3399
3408
|
success
|
|
3400
3409
|
submissionUid
|
|
3401
3410
|
currentPageId
|
|
@@ -3412,17 +3421,17 @@ var Q = "\n id\n currentPageId\n tokens\n continuation\n", Me = `
|
|
|
3412
3421
|
paymentDecision
|
|
3413
3422
|
keepSubmitLoading
|
|
3414
3423
|
session {
|
|
3415
|
-
${
|
|
3424
|
+
${$}
|
|
3416
3425
|
}
|
|
3417
3426
|
quizResult
|
|
3418
3427
|
`;
|
|
3419
|
-
function
|
|
3428
|
+
function Pe(e) {
|
|
3420
3429
|
if (e.startsWith("http://") || e.startsWith("https://")) return e;
|
|
3421
3430
|
let t = e.trim();
|
|
3422
3431
|
return !t || t === "/" ? "/api" : t;
|
|
3423
3432
|
}
|
|
3424
|
-
async function
|
|
3425
|
-
let r = await fetch(
|
|
3433
|
+
async function Fe(e, t, n) {
|
|
3434
|
+
let r = await fetch(Pe(e.endpoint), {
|
|
3426
3435
|
method: "POST",
|
|
3427
3436
|
credentials: e.credentials ?? "same-origin",
|
|
3428
3437
|
headers: {
|
|
@@ -3440,14 +3449,14 @@ async function $(e, t, n) {
|
|
|
3440
3449
|
if (!i.data) throw Error("GraphQL returned no data.");
|
|
3441
3450
|
return i.data;
|
|
3442
3451
|
}
|
|
3443
|
-
async function
|
|
3444
|
-
let t = await
|
|
3452
|
+
async function Ie(e) {
|
|
3453
|
+
let t = await Fe(e, `
|
|
3445
3454
|
query ClientForm($handle: String!, $siteId: Int) {
|
|
3446
3455
|
formieClientForm(handle: $handle, siteId: $siteId) {
|
|
3447
3456
|
schemaVersion
|
|
3448
3457
|
definition
|
|
3449
3458
|
session {
|
|
3450
|
-
${
|
|
3459
|
+
${$}
|
|
3451
3460
|
}
|
|
3452
3461
|
}
|
|
3453
3462
|
}
|
|
@@ -3458,15 +3467,15 @@ async function Pe(e) {
|
|
|
3458
3467
|
if (!t.formieClientForm) throw Error("No client form definition was returned.");
|
|
3459
3468
|
return t.formieClientForm;
|
|
3460
3469
|
}
|
|
3461
|
-
function
|
|
3470
|
+
function Le(e) {
|
|
3462
3471
|
return {
|
|
3463
3472
|
async submit({ definition: t, session: n, values: r, action: i }) {
|
|
3464
|
-
let a = await R(t, r), o = await
|
|
3473
|
+
let a = await R(t, r), o = await Fe(e, `
|
|
3465
3474
|
mutation SubmitFormieClientForm(
|
|
3466
3475
|
$input: FormieClientSubmitInput!
|
|
3467
3476
|
) {
|
|
3468
3477
|
submitFormieClientForm(input: $input) {
|
|
3469
|
-
${
|
|
3478
|
+
${Ne}
|
|
3470
3479
|
}
|
|
3471
3480
|
}
|
|
3472
3481
|
`, { input: {
|
|
@@ -3480,12 +3489,12 @@ function Fe(e) {
|
|
|
3480
3489
|
return o.submitFormieClientForm;
|
|
3481
3490
|
},
|
|
3482
3491
|
async refreshSession({ session: t }) {
|
|
3483
|
-
let n = await
|
|
3492
|
+
let n = await Fe(e, `
|
|
3484
3493
|
mutation RefreshFormieClientSession(
|
|
3485
3494
|
$input: FormieClientSessionRefreshInput!
|
|
3486
3495
|
) {
|
|
3487
3496
|
refreshFormieClientSession(input: $input) {
|
|
3488
|
-
${
|
|
3497
|
+
${$}
|
|
3489
3498
|
}
|
|
3490
3499
|
}
|
|
3491
3500
|
`, { input: {
|
|
@@ -3497,12 +3506,12 @@ function Fe(e) {
|
|
|
3497
3506
|
return n.refreshFormieClientSession;
|
|
3498
3507
|
},
|
|
3499
3508
|
async setPage({ definition: t, session: n, values: r, currentPageId: i, targetPageId: a }) {
|
|
3500
|
-
let o = await R(t, r), s = await
|
|
3509
|
+
let o = await R(t, r), s = await Fe(e, `
|
|
3501
3510
|
mutation SetFormieClientPage(
|
|
3502
3511
|
$input: FormieClientSetPageInput!
|
|
3503
3512
|
) {
|
|
3504
3513
|
setFormieClientPage(input: $input) {
|
|
3505
|
-
${
|
|
3514
|
+
${$}
|
|
3506
3515
|
}
|
|
3507
3516
|
}
|
|
3508
3517
|
`, { input: {
|
|
@@ -3520,31 +3529,31 @@ function Fe(e) {
|
|
|
3520
3529
|
}
|
|
3521
3530
|
//#endregion
|
|
3522
3531
|
//#region src/text.ts
|
|
3523
|
-
var
|
|
3532
|
+
var Re = (() => {
|
|
3524
3533
|
let e = Intl.Segmenter;
|
|
3525
3534
|
return e ? new e(void 0, { granularity: "grapheme" }) : null;
|
|
3526
|
-
})(),
|
|
3527
|
-
function Re(e) {
|
|
3528
|
-
return typeof DOMParser < "u" ? new DOMParser().parseFromString(e, "text/html").body.textContent || "" : e.replace(/<[^>]*>/g, " ");
|
|
3529
|
-
}
|
|
3530
|
-
function ze(e) {
|
|
3531
|
-
return Re(e);
|
|
3532
|
-
}
|
|
3535
|
+
})(), ze = /[\p{L}\p{N}\p{M}]+(?:['’._-][\p{L}\p{N}\p{M}]+)*/gu;
|
|
3533
3536
|
function Be(e) {
|
|
3534
|
-
return
|
|
3537
|
+
return typeof DOMParser < "u" ? new DOMParser().parseFromString(e, "text/html").body.textContent || "" : e.replace(/<[^>]*>/g, " ");
|
|
3535
3538
|
}
|
|
3536
3539
|
function Ve(e) {
|
|
3537
|
-
return
|
|
3540
|
+
return Be(e);
|
|
3538
3541
|
}
|
|
3539
3542
|
function He(e) {
|
|
3540
|
-
return e.
|
|
3543
|
+
return Ve(e).replace(/[\s\t\n\r]+/g, " ").trim();
|
|
3541
3544
|
}
|
|
3542
3545
|
function Ue(e) {
|
|
3543
|
-
|
|
3546
|
+
return Re ? Array.from(Re.segment(e)).length : Array.from(e).length;
|
|
3547
|
+
}
|
|
3548
|
+
function We(e) {
|
|
3549
|
+
return e.match(ze)?.length || 0;
|
|
3550
|
+
}
|
|
3551
|
+
function Ge(e) {
|
|
3552
|
+
let t = Ve(e), n = He(e);
|
|
3544
3553
|
return {
|
|
3545
|
-
graphemeCount:
|
|
3546
|
-
wordCount:
|
|
3554
|
+
graphemeCount: Ue(t),
|
|
3555
|
+
wordCount: We(n)
|
|
3547
3556
|
};
|
|
3548
3557
|
}
|
|
3549
3558
|
//#endregion
|
|
3550
|
-
export { ye as FRONTEND_CLIENT_EVENT_NAMES, v as allFields, Ee as coerceCalculationVariables, A as compositePartDefinitions,
|
|
3559
|
+
export { ye as FRONTEND_CLIENT_EVENT_NAMES, v as allFields, Ee as coerceCalculationVariables, A as compositePartDefinitions, Ue as countGraphemes, ve as createFrontendFormInstance, Le as createGraphqlFrontendTransport, ne as createRepeaterRowValue, Me as createRestFrontendTransport, N as defaultValueForField, ke as evaluateCalculationExpression, h as evaluateConditionDefinition, P as fieldValueAsStrings, S as fieldValueContract, C as fieldValueStructure, g as finalizeConditionEvaluation, b as findFieldByHandle, y as findFieldById, De as formatCalculationValue, we as getCalculationFormula, Te as getCalculationVariableEntries, Ge as getTextLimitMetrics, We as getWordCount, O as isBooleanField, w as isCompositeField, te as isEmailField, E as isFileField, ee as isKnownFrontendFieldType, D as isMultiValueField, k as isNumericField, T as isRepeatableField, je as loadFrontendEnvelope, Ie as loadGraphqlFrontendEnvelope, He as normalizeText, Oe as readCalculationVariableValue, M as repeaterFieldDefinitions, j as repeaterRowDefinitions, x as serializeFieldValues, R as serializeTransportFieldValues };
|
package/dist/rest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../src/rest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAER,oBAAoB,EAGpB,iBAAiB,EACpB,MAAM,SAAS,CAAC;AAGjB,MAAM,MAAM,4BAA4B,GAAG;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,kBAAkB,CAAC;CACpC,CAAC;
|
|
1
|
+
{"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../src/rest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAER,oBAAoB,EAGpB,iBAAiB,EACpB,MAAM,SAAS,CAAC;AAGjB,MAAM,MAAM,4BAA4B,GAAG;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,kBAAkB,CAAC;CACpC,CAAC;AAwCF,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,4BAA4B,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAe/G;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,4BAA4B,GAAG,iBAAiB,CAmEpG"}
|