@verbb/formie-browser 1.0.4 → 1.0.6
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 +76 -22
- package/dist/chunks/address-country-Rx6GQTND.js +68 -0
- package/dist/chunks/address-finder-yXU5yMjG.js +30 -0
- package/dist/chunks/address-state-BQ0xGV9n.js +344 -0
- package/dist/chunks/api-CmwLRq_n.js +780 -0
- package/dist/chunks/api-DMK8NSUI.js +407 -0
- package/dist/chunks/api-sPqGbOww.js +125 -0
- package/dist/chunks/async-nPFRNQ06.js +25 -0
- package/dist/chunks/bpoint-DSjqRv63.js +24 -0
- package/dist/chunks/calculations-CeDgB9jt.js +299 -0
- package/dist/chunks/captcha-eu-CWJb64_j.js +31 -0
- package/dist/chunks/checkbox-radio-DQ0H67Tj.js +125 -0
- package/dist/chunks/chunk-3b4jIN3o.js +13 -0
- package/dist/chunks/combobox-D-2b42wn.js +1954 -0
- package/dist/chunks/conditions-DjZOtHfS.js +412 -0
- package/dist/chunks/constants-DVcJAvc5.js +38 -0
- package/dist/chunks/country-from-ip-BwxKaBuJ.js +26 -0
- package/dist/chunks/custom-google-maps-BsaSirEZ.js +194 -0
- package/dist/chunks/custom-link-CJ1-FjEM.js +46 -0
- package/dist/chunks/custom-maps-DYW_pBid.js +161 -0
- package/dist/chunks/date-picker-5CA_-zGb.js +5311 -0
- package/dist/chunks/debug-BV0DvdHx.js +41 -0
- package/dist/chunks/dist-BQ4a9hmy.js +2659 -0
- package/dist/chunks/event-names-BCI2FLD8.js +51 -0
- package/dist/chunks/eway-D3ctTbEk.js +70 -0
- package/dist/chunks/field-references.keys-58ZSTrCW.js +21 -0
- package/dist/chunks/field-references.resolver-CHwn0G0L.js +145 -0
- package/dist/chunks/file-upload-D49m8-DR.js +287 -0
- package/dist/chunks/friendly-captcha-v1-ByXzENYZ.js +31 -0
- package/dist/chunks/friendly-captcha-v2-BPdlmhQu.js +36 -0
- package/dist/chunks/friendly-challenge-8uPatWqk.js +832 -0
- package/dist/chunks/go-cardless-BwASSYSK.js +23 -0
- package/dist/chunks/google-address-OhKilPWE.js +161 -0
- package/dist/chunks/hcaptcha-CdCd9oEi.js +54 -0
- package/dist/chunks/hidden-D7_Ch-QN.js +26 -0
- package/dist/chunks/http-D-JExro7.js +27 -0
- package/dist/chunks/i18n-BY1ds1BL.js +121 -0
- package/dist/chunks/leaflet-src-j-lHNmhR.js +4585 -0
- package/dist/chunks/loqate-Cp2zvwpE.js +76 -0
- package/dist/chunks/mollie-COG-ko2D.js +23 -0
- package/dist/chunks/moneris-CMH8PlRc.js +117 -0
- package/dist/chunks/opayo-D2jsR5vh.js +113 -0
- package/dist/chunks/paddle-DxF88RfC.js +55 -0
- package/dist/chunks/paypal-b5pnwrA2.js +95 -0
- package/dist/chunks/payway-BJYu9DIR.js +55 -0
- package/dist/chunks/phone-country-D3ayr60L.js +2645 -0
- package/dist/chunks/place-kit-BGHklIZ-.js +48 -0
- package/dist/chunks/placekit-autocomplete.esm-DWVabQlq.js +1236 -0
- package/dist/chunks/recaptcha-enterprise-BSwi8IVX.js +65 -0
- package/dist/chunks/recaptcha-shared-B4zAescW.js +15 -0
- package/dist/chunks/recaptcha-v2-checkbox-CnDQmsKa.js +40 -0
- package/dist/chunks/recaptcha-v2-invisible-Cz5uIlp-.js +53 -0
- package/dist/chunks/recaptcha-v3-BtbbP111.js +27 -0
- package/dist/chunks/repeater-B5leVxZU.js +102 -0
- package/dist/chunks/rich-text-D0sb8bmX.js +349 -0
- package/dist/chunks/scripts-6CYSUGKQ.js +24 -0
- package/dist/chunks/sdk-BhHAYgga.js +1397 -0
- package/dist/chunks/shared-Bx9s0i0P.js +100 -0
- package/dist/chunks/signature-xz4QO7CR.js +536 -0
- package/dist/chunks/snaptcha-vz1RnZ15.js +8 -0
- package/dist/chunks/square-BP8RWAKB.js +40 -0
- package/dist/chunks/stripe-MihN63uC.js +184 -0
- package/dist/chunks/styles-BfoIZwJp.js +19 -0
- package/dist/chunks/summary-D3AjxpYN.js +114 -0
- package/dist/chunks/table-C-lkQN6I.js +78 -0
- package/dist/chunks/text-limit-DbgEFHLO.js +125 -0
- package/dist/chunks/theme-classes-Tv7q7ToE.js +44 -0
- package/dist/chunks/turnstile-D_Pi1CKM.js +58 -0
- package/dist/chunks/upload-manager-BpqWSHmU.js +2558 -0
- package/dist/chunks/utils-Vqp8i_RM.js +49401 -0
- package/dist/css/formie-theme.css +2 -0
- package/dist/css/theme/_buttons.css +16 -0
- package/dist/css/theme/_tokens.css +2 -0
- package/dist/css/theme/fields/_address-state.css +94 -0
- package/dist/css/theme/fields/_combobox.css +246 -0
- package/dist/css/theme/fields/_select.css +13 -0
- package/dist/css/theme/fields/_signature.css +19 -0
- package/dist/css/theme/fields/_upload-manager.css +279 -0
- package/dist/index.js +2448 -39
- package/dist/js/core/create-formie-client.d.ts.map +1 -1
- package/dist/js/core/submit-result-ui.d.ts.map +1 -1
- package/dist/js/core/validation-focus.d.ts +4 -0
- package/dist/js/core/validation-focus.d.ts.map +1 -0
- package/dist/js/modules/address/api.d.ts +1 -0
- package/dist/js/modules/address/api.d.ts.map +1 -1
- package/dist/js/modules/address/constants.d.ts +22 -1
- package/dist/js/modules/address/constants.d.ts.map +1 -1
- package/dist/js/modules/address/host.d.ts +2 -2
- package/dist/js/modules/address/host.d.ts.map +1 -1
- package/dist/js/modules/address/loqate.d.ts.map +1 -1
- package/dist/js/modules/fields/address-country.d.ts +3 -0
- package/dist/js/modules/fields/address-country.d.ts.map +1 -0
- package/dist/js/modules/fields/address-state.d.ts +3 -0
- package/dist/js/modules/fields/address-state.d.ts.map +1 -0
- package/dist/js/modules/fields/calculations.d.ts.map +1 -1
- package/dist/js/modules/fields/combobox.d.ts +17 -0
- package/dist/js/modules/fields/combobox.d.ts.map +1 -0
- package/dist/js/modules/fields/custom-google-maps.d.ts +64 -0
- package/dist/js/modules/fields/custom-google-maps.d.ts.map +1 -0
- package/dist/js/modules/fields/custom-link.d.ts +3 -0
- package/dist/js/modules/fields/custom-link.d.ts.map +1 -0
- package/dist/js/modules/fields/custom-maps.d.ts +3 -0
- package/dist/js/modules/fields/custom-maps.d.ts.map +1 -0
- package/dist/js/modules/fields/date-picker.d.ts.map +1 -1
- package/dist/js/modules/fields/index.d.ts.map +1 -1
- package/dist/js/modules/fields/phone-country.d.ts.map +1 -1
- package/dist/js/modules/fields/signature.d.ts.map +1 -1
- package/dist/js/modules/fields/upload-manager.d.ts +3 -0
- package/dist/js/modules/fields/upload-manager.d.ts.map +1 -0
- package/dist/js/submit/pipeline.d.ts.map +1 -1
- package/dist/js/utils/country-from-ip.d.ts +7 -0
- package/dist/js/utils/country-from-ip.d.ts.map +1 -0
- package/dist/js/utils/field-references.d.ts +1 -0
- package/dist/js/utils/field-references.d.ts.map +1 -1
- package/dist/js/utils/field-references.row-scope.d.ts +11 -0
- package/dist/js/utils/field-references.row-scope.d.ts.map +1 -0
- package/package.json +8 -3
- package/src/css/formie-theme.css +2 -0
- package/src/css/theme/_buttons.css +16 -0
- package/src/css/theme/_tokens.css +2 -0
- package/src/css/theme/fields/_address-state.css +94 -0
- package/src/css/theme/fields/_combobox.css +246 -0
- package/src/css/theme/fields/_select.css +13 -0
- package/src/css/theme/fields/_signature.css +19 -0
- package/src/css/theme/fields/_upload-manager.css +279 -0
- package/src/js/core/create-formie-client.ts +27 -0
- package/src/js/core/submit-result-ui.ts +4 -4
- package/src/js/core/validation-focus.ts +117 -0
- package/src/js/modules/address/api.ts +7 -0
- package/src/js/modules/address/constants.ts +82 -2
- package/src/js/modules/address/host.ts +16 -6
- package/src/js/modules/address/loqate.ts +3 -17
- package/src/js/modules/fields/address-country.ts +156 -0
- package/src/js/modules/fields/address-state.ts +946 -0
- package/src/js/modules/fields/calculations.ts +32 -0
- package/src/js/modules/fields/combobox.ts +188 -0
- package/src/js/modules/fields/custom-google-maps.ts +416 -0
- package/src/js/modules/fields/custom-link.ts +95 -0
- package/src/js/modules/fields/custom-maps.ts +339 -0
- package/src/js/modules/fields/date-picker.ts +96 -3
- package/src/js/modules/fields/index.ts +7 -0
- package/src/js/modules/fields/phone-country.ts +6 -0
- package/src/js/modules/fields/signature.ts +199 -15
- package/src/js/modules/fields/upload-manager.ts +1277 -0
- package/src/js/submit/pipeline.ts +11 -1
- package/src/js/utils/country-from-ip.ts +54 -0
- package/src/js/utils/field-references.row-scope.ts +303 -0
- package/src/js/utils/field-references.ts +1 -0
- package/src/vendor.d.ts +1 -1
- package/dist/chunks/address-finder-BU4roxT6.js +0 -37
- package/dist/chunks/bpoint-uNg5j6rt.js +0 -26
- package/dist/chunks/calculations-C9t6Zop9.js +0 -147
- package/dist/chunks/captcha-eu-BAPzHNts.js +0 -34
- package/dist/chunks/checkbox-radio-CHeLNVIK.js +0 -141
- package/dist/chunks/conditions-DKxVCsjD.js +0 -459
- package/dist/chunks/date-picker-B3iQ797Z.js +0 -4994
- package/dist/chunks/eway-DCielIML.js +0 -74
- package/dist/chunks/file-upload-DP2TOUYV.js +0 -316
- package/dist/chunks/friendly-captcha-v1-DdlcGiFY.js +0 -33
- package/dist/chunks/friendly-captcha-v2-76w-YnFm.js +0 -38
- package/dist/chunks/go-cardless-rwCkzbNK.js +0 -24
- package/dist/chunks/google-address-BD8IZ86V.js +0 -181
- package/dist/chunks/hcaptcha-BNNTL6uf.js +0 -56
- package/dist/chunks/hidden-CW6Rcf1N.js +0 -31
- package/dist/chunks/index-BEsfee-D.js +0 -1839
- package/dist/chunks/index-BP7Unm5Y.js +0 -863
- package/dist/chunks/index-D6npYxvr.js +0 -4423
- package/dist/chunks/loqate-B-ZNS65B.js +0 -55
- package/dist/chunks/mollie-BDAZ-1X4.js +0 -24
- package/dist/chunks/moneris-B1b0uEtY.js +0 -101
- package/dist/chunks/opayo-CC5hraHo.js +0 -122
- package/dist/chunks/paddle-B4GmrDsq.js +0 -60
- package/dist/chunks/paypal-BFS6XsIS.js +0 -100
- package/dist/chunks/payway-DekoJead.js +0 -56
- package/dist/chunks/phone-country-Cm5YUeXI.js +0 -3765
- package/dist/chunks/place-kit-DizZWV_e.js +0 -42
- package/dist/chunks/placekit-autocomplete.esm-LAwfbPZl.js +0 -1299
- package/dist/chunks/recaptcha-enterprise-BbOvO7JZ.js +0 -71
- package/dist/chunks/recaptcha-shared-Dwg1eVFS.js +0 -15
- package/dist/chunks/recaptcha-v2-checkbox-SY3ti5iQ.js +0 -41
- package/dist/chunks/recaptcha-v2-invisible-DSmQnn6c.js +0 -59
- package/dist/chunks/recaptcha-v3-DNh7YCnR.js +0 -28
- package/dist/chunks/repeater-DM0vuFNQ.js +0 -124
- package/dist/chunks/rich-text-C8aGYp70.js +0 -304
- package/dist/chunks/scripts-CKTFtxPO.js +0 -36
- package/dist/chunks/sdk-3SicTWby.js +0 -1559
- package/dist/chunks/shared--BU5CFoL.js +0 -80
- package/dist/chunks/signature-pFhZfH7d.js +0 -550
- package/dist/chunks/snaptcha-VuOUOaLj.js +0 -8
- package/dist/chunks/square-BR9pvToy.js +0 -46
- package/dist/chunks/stripe-OHUwoV9g.js +0 -202
- package/dist/chunks/styles-C3aqgtek.js +0 -21
- package/dist/chunks/summary-Da7Ktg3N.js +0 -126
- package/dist/chunks/table-C0PmR9bI.js +0 -95
- package/dist/chunks/text-limit-mLEwZDIa.js +0 -144
- package/dist/chunks/turnstile-9tM7q_LK.js +0 -59
- package/dist/chunks/utils-BntI3W4S.js +0 -6149
|
@@ -250,7 +250,17 @@ export async function runSubmitPipeline(
|
|
|
250
250
|
const errors = options.validator.submit(final ? ctx.form : scope, { final });
|
|
251
251
|
|
|
252
252
|
if (errors.length > 0) {
|
|
253
|
-
errors[0]?.input
|
|
253
|
+
const firstErrorInput = errors[0]?.input;
|
|
254
|
+
|
|
255
|
+
if (firstErrorInput) {
|
|
256
|
+
firstErrorInput.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
257
|
+
|
|
258
|
+
try {
|
|
259
|
+
firstErrorInput.focus({ preventScroll: true });
|
|
260
|
+
} catch {
|
|
261
|
+
firstErrorInput.focus();
|
|
262
|
+
}
|
|
263
|
+
}
|
|
254
264
|
|
|
255
265
|
return {
|
|
256
266
|
ok: false,
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export type CountryFromIpResponse = {
|
|
2
|
+
countryCode?: string | null;
|
|
3
|
+
countryName?: string | null;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
const DEFAULT_COUNTRY_FROM_IP_ACTION = 'formie/address/country-from-ip';
|
|
7
|
+
|
|
8
|
+
let cachedLookup: Promise<CountryFromIpResponse | null> | null = null;
|
|
9
|
+
|
|
10
|
+
function buildActionUrl(action: string): string {
|
|
11
|
+
return new URL(action.startsWith('/') ? action : `/actions/${action}`, window.location.origin).toString();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function fetchCountryFromIp(
|
|
15
|
+
action: string = DEFAULT_COUNTRY_FROM_IP_ACTION,
|
|
16
|
+
): Promise<CountryFromIpResponse | null> {
|
|
17
|
+
if (!cachedLookup) {
|
|
18
|
+
cachedLookup = (async () => {
|
|
19
|
+
try {
|
|
20
|
+
const response = await fetch(buildActionUrl(action), {
|
|
21
|
+
headers: {
|
|
22
|
+
Accept: 'application/json',
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (!response.ok) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const data = await response.json() as CountryFromIpResponse;
|
|
31
|
+
|
|
32
|
+
if (!data?.countryCode) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return data;
|
|
37
|
+
} catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
})();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return cachedLookup;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function createGeoIpLookup(
|
|
47
|
+
action: string = DEFAULT_COUNTRY_FROM_IP_ACTION,
|
|
48
|
+
): (callback: (countryCode: string) => void) => void {
|
|
49
|
+
return (callback) => {
|
|
50
|
+
void fetchCountryFromIp(action).then((data) => {
|
|
51
|
+
callback(data?.countryCode?.toLowerCase() || '');
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { fieldKeyToInputName, normalizeFieldKey } from '#utils/field-references.keys';
|
|
2
|
+
import { resolveFieldReferenceLive } from '#utils/field-references.resolver';
|
|
3
|
+
import type { FieldValueRegistry, ResolveFieldValueResult } from '#utils/field-references.types';
|
|
4
|
+
|
|
5
|
+
export type RowScopeParams = {
|
|
6
|
+
scope?: string;
|
|
7
|
+
index?: string | number;
|
|
8
|
+
rows?: string;
|
|
9
|
+
fieldKind?: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const ROW_SCOPE_VALUES = new Set(['first', 'last', 'index', 'all', 'count', 'rows']);
|
|
13
|
+
|
|
14
|
+
function escapeRegExp(value: string): string {
|
|
15
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function parseRowsExpression(expression: string, rowCount: number): number[] {
|
|
19
|
+
const normalized = String(expression || '').trim().toLowerCase();
|
|
20
|
+
|
|
21
|
+
if (!normalized || rowCount <= 0) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (normalized === 'even') {
|
|
26
|
+
const indices: number[] = [];
|
|
27
|
+
|
|
28
|
+
for (let row = 1; row <= rowCount; row++) {
|
|
29
|
+
if (row % 2 === 0) {
|
|
30
|
+
indices.push(row - 1);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return indices;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (normalized === 'odd') {
|
|
38
|
+
const indices: number[] = [];
|
|
39
|
+
|
|
40
|
+
for (let row = 1; row <= rowCount; row++) {
|
|
41
|
+
if (row % 2 === 1) {
|
|
42
|
+
indices.push(row - 1);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return indices;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const everyMatch = normalized.match(/^every:(\d+)$/);
|
|
50
|
+
|
|
51
|
+
if (everyMatch) {
|
|
52
|
+
const step = Math.max(1, Number.parseInt(everyMatch[1] || '1', 10));
|
|
53
|
+
const indices: number[] = [];
|
|
54
|
+
|
|
55
|
+
for (let row = 1; row <= rowCount; row += step) {
|
|
56
|
+
indices.push(row - 1);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return indices;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const indices: number[] = [];
|
|
63
|
+
|
|
64
|
+
normalized.split(/\s*,\s*/).forEach((segment) => {
|
|
65
|
+
const trimmed = segment.trim();
|
|
66
|
+
|
|
67
|
+
if (!trimmed) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const rangeMatch = trimmed.match(/^(\d+)\s*-\s*(\d+)$/);
|
|
72
|
+
|
|
73
|
+
if (rangeMatch) {
|
|
74
|
+
let start = Number.parseInt(rangeMatch[1] || '0', 10);
|
|
75
|
+
let end = Number.parseInt(rangeMatch[2] || '0', 10);
|
|
76
|
+
|
|
77
|
+
if (start > end) {
|
|
78
|
+
[start, end] = [end, start];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
for (let row = start; row <= end; row++) {
|
|
82
|
+
if (row >= 1 && row <= rowCount) {
|
|
83
|
+
indices.push(row - 1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const row = Number.parseInt(trimmed, 10);
|
|
91
|
+
|
|
92
|
+
if (Number.isFinite(row) && row >= 1 && row <= rowCount) {
|
|
93
|
+
indices.push(row - 1);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return [...new Set(indices)].sort((left, right) => left - right);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function resolveColumnSelector(sourceKey: string): { fieldKey: string; columnKey: string } {
|
|
101
|
+
const normalized = normalizeFieldKey(sourceKey);
|
|
102
|
+
const parts = normalized.split('.').filter(Boolean);
|
|
103
|
+
|
|
104
|
+
if (parts.length < 2) {
|
|
105
|
+
return {
|
|
106
|
+
fieldKey: normalized,
|
|
107
|
+
columnKey: parts[parts.length - 1] || '',
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (parts.length >= 3 && /^\d+$/.test(parts[1] || '')) {
|
|
112
|
+
return {
|
|
113
|
+
fieldKey: parts[0] || '',
|
|
114
|
+
columnKey: parts.slice(2).join('.'),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
fieldKey: parts[0] || '',
|
|
120
|
+
columnKey: parts.slice(1).join('.'),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function listColumnCellKeys(fieldKey: string, columnKey: string, registry: FieldValueRegistry): string[] {
|
|
125
|
+
const pattern = new RegExp(`^${escapeRegExp(fieldKey)}\\.(\\d+)\\.${escapeRegExp(columnKey)}$`);
|
|
126
|
+
|
|
127
|
+
return [...registry.keys()]
|
|
128
|
+
.filter((key) => pattern.test(key))
|
|
129
|
+
.sort((left, right) => {
|
|
130
|
+
const leftRow = Number.parseInt(left.split('.')[1] || '0', 10);
|
|
131
|
+
const rightRow = Number.parseInt(right.split('.')[1] || '0', 10);
|
|
132
|
+
|
|
133
|
+
return leftRow - rightRow;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function readCellValue(key: string, registry: FieldValueRegistry): string | string[] {
|
|
138
|
+
return resolveFieldReferenceLive(key, registry).value;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function getRowScopedWatchNames(
|
|
142
|
+
sourceKey: string,
|
|
143
|
+
params: RowScopeParams,
|
|
144
|
+
registry: FieldValueRegistry,
|
|
145
|
+
): Set<string> {
|
|
146
|
+
const watchNames = new Set<string>();
|
|
147
|
+
const { fieldKey, columnKey } = resolveColumnSelector(sourceKey);
|
|
148
|
+
const scope = String(params.scope || '').trim().toLowerCase();
|
|
149
|
+
|
|
150
|
+
if (!fieldKey || !columnKey || !ROW_SCOPE_VALUES.has(scope)) {
|
|
151
|
+
const fallback = fieldKeyToInputName(sourceKey);
|
|
152
|
+
|
|
153
|
+
if (fallback) {
|
|
154
|
+
watchNames.add(fallback);
|
|
155
|
+
watchNames.add(`${fallback}[]`);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return watchNames;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const cellKeys = listColumnCellKeys(fieldKey, columnKey, registry);
|
|
162
|
+
|
|
163
|
+
cellKeys.forEach((cellKey) => {
|
|
164
|
+
const entry = registry.get(cellKey);
|
|
165
|
+
|
|
166
|
+
if (entry?.names?.length) {
|
|
167
|
+
entry.names.forEach((name) => {
|
|
168
|
+
watchNames.add(name);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const fallback = fieldKeyToInputName(cellKey);
|
|
175
|
+
|
|
176
|
+
if (fallback) {
|
|
177
|
+
watchNames.add(fallback);
|
|
178
|
+
watchNames.add(`${fallback}[]`);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
return watchNames;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export function resolveRowScopedFieldReference(
|
|
186
|
+
sourceKey: string,
|
|
187
|
+
params: RowScopeParams,
|
|
188
|
+
registry: FieldValueRegistry,
|
|
189
|
+
): ResolveFieldValueResult {
|
|
190
|
+
const scope = String(params.scope || '').trim().toLowerCase();
|
|
191
|
+
|
|
192
|
+
if (!scope || !ROW_SCOPE_VALUES.has(scope)) {
|
|
193
|
+
return resolveFieldReferenceLive(sourceKey, registry);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const { fieldKey, columnKey } = resolveColumnSelector(sourceKey);
|
|
197
|
+
|
|
198
|
+
if (!fieldKey || !columnKey) {
|
|
199
|
+
return resolveFieldReferenceLive(sourceKey, registry);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const cellKeys = listColumnCellKeys(fieldKey, columnKey, registry);
|
|
203
|
+
const rowValues = cellKeys.map((cellKey) => readCellValue(cellKey, registry));
|
|
204
|
+
|
|
205
|
+
if (scope === 'count') {
|
|
206
|
+
return {
|
|
207
|
+
key: `${fieldKey}.${columnKey}`,
|
|
208
|
+
value: String(cellKeys.length),
|
|
209
|
+
found: true,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (scope === 'first') {
|
|
214
|
+
const key = cellKeys[0] || `${fieldKey}.0.${columnKey}`;
|
|
215
|
+
|
|
216
|
+
return {
|
|
217
|
+
key,
|
|
218
|
+
value: rowValues[0] ?? '',
|
|
219
|
+
found: cellKeys.length > 0,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (scope === 'last') {
|
|
224
|
+
const key = cellKeys[cellKeys.length - 1] || `${fieldKey}.0.${columnKey}`;
|
|
225
|
+
|
|
226
|
+
return {
|
|
227
|
+
key,
|
|
228
|
+
value: rowValues[rowValues.length - 1] ?? '',
|
|
229
|
+
found: cellKeys.length > 0,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (scope === 'index') {
|
|
234
|
+
const index = Number.parseInt(String(params.index ?? '0'), 10);
|
|
235
|
+
const key = `${fieldKey}.${index}.${columnKey}`;
|
|
236
|
+
|
|
237
|
+
return resolveFieldReferenceLive(key, registry);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (scope === 'all') {
|
|
241
|
+
const values = rowValues.flatMap((value) => {
|
|
242
|
+
if (Array.isArray(value)) {
|
|
243
|
+
return value;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (value === '') {
|
|
247
|
+
return [];
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return [value];
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
return {
|
|
254
|
+
key: `${fieldKey}.${columnKey}`,
|
|
255
|
+
value: values,
|
|
256
|
+
found: values.length > 0,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (scope === 'rows') {
|
|
261
|
+
const indices = parseRowsExpression(String(params.rows || ''), cellKeys.length);
|
|
262
|
+
|
|
263
|
+
if (indices.length === 0) {
|
|
264
|
+
return {
|
|
265
|
+
key: `${fieldKey}.${columnKey}`,
|
|
266
|
+
value: '',
|
|
267
|
+
found: false,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if (indices.length === 1) {
|
|
272
|
+
const key = cellKeys[indices[0]] || `${fieldKey}.${indices[0]}.${columnKey}`;
|
|
273
|
+
|
|
274
|
+
return {
|
|
275
|
+
key,
|
|
276
|
+
value: rowValues[indices[0]] ?? '',
|
|
277
|
+
found: true,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
const values = indices.flatMap((index) => {
|
|
282
|
+
const value = rowValues[index];
|
|
283
|
+
|
|
284
|
+
if (Array.isArray(value)) {
|
|
285
|
+
return value;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (value === '') {
|
|
289
|
+
return [];
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return [value];
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
return {
|
|
296
|
+
key: `${fieldKey}.${columnKey}`,
|
|
297
|
+
value: values,
|
|
298
|
+
found: values.length > 0,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return resolveFieldReferenceLive(sourceKey, registry);
|
|
303
|
+
}
|
|
@@ -2,6 +2,7 @@ export { normalizeFieldKey, fieldKeyToInputName, inputNameToFieldKey } from '#ut
|
|
|
2
2
|
export { parseFieldReference } from '#utils/field-references.parser';
|
|
3
3
|
export { buildFieldValueRegistry } from '#utils/field-references.registry';
|
|
4
4
|
export { resolveFieldReferenceLive, resolveFieldReferenceFromFormData } from '#utils/field-references.resolver';
|
|
5
|
+
export { getRowScopedWatchNames, parseRowsExpression, resolveRowScopedFieldReference } from '#utils/field-references.row-scope';
|
|
5
6
|
export type {
|
|
6
7
|
FieldReferenceTransform,
|
|
7
8
|
FieldValueRegistry,
|
package/src/vendor.d.ts
CHANGED
|
@@ -94,7 +94,7 @@ declare module 'signature_pad' {
|
|
|
94
94
|
on(): void;
|
|
95
95
|
removeEventListener(eventName: string, listener: EventListener): void;
|
|
96
96
|
toDataURL(type?: string, encoderOptions?: number): string;
|
|
97
|
-
fromDataURL(dataUrl: string): void
|
|
97
|
+
fromDataURL(dataUrl: string, options?: Record<string, unknown>): Promise<void>;
|
|
98
98
|
isEmpty(): boolean;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { d as p, g as a } from "./index-D6npYxvr.js";
|
|
2
|
-
import { l as _ } from "./scripts-CKTFtxPO.js";
|
|
3
|
-
const f = "FORMIE_ADDRESS_FINDER_SCRIPT", g = p({
|
|
4
|
-
id: "address-finder",
|
|
5
|
-
load: async () => _("AddressFinder", {
|
|
6
|
-
id: f,
|
|
7
|
-
src: "https://api.addressfinder.io/assets/v3/widget.js",
|
|
8
|
-
async: !0,
|
|
9
|
-
defer: !0
|
|
10
|
-
}),
|
|
11
|
-
mount: ({ api: t, field: u, services: e, provider: s }) => {
|
|
12
|
-
const n = e.input.getAutocomplete();
|
|
13
|
-
if (!n || typeof t > "u" || !t.Widget)
|
|
14
|
-
throw new Error("AddressFinder API not ready");
|
|
15
|
-
const i = s.apiKey || "", r = s.countryCode || "au", o = new t.Widget(
|
|
16
|
-
n,
|
|
17
|
-
i,
|
|
18
|
-
r,
|
|
19
|
-
s.widgetOptions
|
|
20
|
-
);
|
|
21
|
-
return o.on("result:select", (l, d) => {
|
|
22
|
-
d.address_line_2 ? (e.input.setValue("address1", d.address_line_2), e.input.setValue("address2", d.address_line_1)) : (e.input.setValue("address1", d.address_line_1 || ""), e.input.setValue("address2", "")), e.input.setValue("city", d.locality_name || ""), e.input.setValue("zip", d.postcode || ""), e.input.setValue("state", d.state_territory || ""), e.input.setValue("country", r), u.dispatchEvent(
|
|
23
|
-
new CustomEvent(a("address-finder", "populate"), {
|
|
24
|
-
bubbles: !0,
|
|
25
|
-
detail: {
|
|
26
|
-
addressProvider: "address-finder",
|
|
27
|
-
fullAddress: l,
|
|
28
|
-
metaData: d
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
);
|
|
32
|
-
}), o;
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
export {
|
|
36
|
-
g as addressFinderModule
|
|
37
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { v as c } from "./index-D6npYxvr.js";
|
|
2
|
-
const p = c({
|
|
3
|
-
id: "bpoint",
|
|
4
|
-
defaultRequiredInputSuffixes: ["bpointToken"],
|
|
5
|
-
load: async () => null,
|
|
6
|
-
onBeforeAuthorize: async ({ field: e, services: t }) => {
|
|
7
|
-
if ((e.querySelector('input[name$="[bpointToken]"]')?.value || "").trim() !== "")
|
|
8
|
-
return !0;
|
|
9
|
-
const o = e.querySelector('[data-bpoint-card="cardholder-name"]')?.value?.trim() || "", r = e.querySelector('[data-bpoint-card="card-number"]')?.value?.replace(/\s+/g, "") || "", u = e.querySelector('[data-bpoint-card="expiry-date"]')?.value || "", a = e.querySelector('[data-bpoint-card="security-code"]')?.value?.trim() || "", n = (u.match(/\d/g) || []).join("").slice(0, 4);
|
|
10
|
-
if (!r || n.length !== 4 || !a)
|
|
11
|
-
return t.addError("Please provide valid card details to continue."), !1;
|
|
12
|
-
const i = {
|
|
13
|
-
cardholderName: o,
|
|
14
|
-
cardNumber: r,
|
|
15
|
-
expiryDate: n,
|
|
16
|
-
cvn: a
|
|
17
|
-
};
|
|
18
|
-
return t.updateInputs("bpointToken", JSON.stringify(i)), !0;
|
|
19
|
-
},
|
|
20
|
-
onAfterSubmit: async ({ services: e }) => {
|
|
21
|
-
e.updateInputs("bpointToken", "");
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
export {
|
|
25
|
-
p as bpointModule
|
|
26
|
-
};
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { j as H, _ as A, $ as D, U as N, F as T } from "./index-BEsfee-D.js";
|
|
2
|
-
import { g as K, d as L } from "./shared--BU5CFoL.js";
|
|
3
|
-
import { h as R, i as k, n as U, j as V, r as _ } from "./index-D6npYxvr.js";
|
|
4
|
-
const S = "input[data-formie-calculation-input]", y = "calculations", g = R("fields", "calculations");
|
|
5
|
-
function j(e, r, t) {
|
|
6
|
-
const a = k(e), o = {};
|
|
7
|
-
return r.forEach(([u, i]) => {
|
|
8
|
-
const d = _(i.sourceKey || "", a);
|
|
9
|
-
o[u] = N(i, d.value);
|
|
10
|
-
}), T(o, t.formatting);
|
|
11
|
-
}
|
|
12
|
-
function z(e, r) {
|
|
13
|
-
const t = k(e), a = /* @__PURE__ */ new Set();
|
|
14
|
-
return r.forEach(([, o]) => {
|
|
15
|
-
const u = U(o.sourceKey || ""), i = t.get(u);
|
|
16
|
-
if (i?.names?.length) {
|
|
17
|
-
i.names.forEach((f) => {
|
|
18
|
-
a.add(f);
|
|
19
|
-
});
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const d = V(u);
|
|
23
|
-
d && (a.add(d), a.add(`${d}[]`));
|
|
24
|
-
}), a;
|
|
25
|
-
}
|
|
26
|
-
function B(e, r, t, a) {
|
|
27
|
-
const o = H(a), u = A(a), i = /* @__PURE__ */ new Map();
|
|
28
|
-
let d = null, f = !1, v = !1, h = !1;
|
|
29
|
-
const p = () => {
|
|
30
|
-
i.forEach((s, m) => {
|
|
31
|
-
s.forEach((n, l) => {
|
|
32
|
-
m.removeEventListener(l, n);
|
|
33
|
-
});
|
|
34
|
-
}), i.clear();
|
|
35
|
-
}, b = (s) => {
|
|
36
|
-
!s || f || queueMicrotask(() => {
|
|
37
|
-
f || (t.dispatchEvent(new Event("input", { bubbles: !0 })), t.dispatchEvent(new Event("change", { bubbles: !0 })));
|
|
38
|
-
});
|
|
39
|
-
}, w = (s = !1) => {
|
|
40
|
-
const m = j(e, u, a);
|
|
41
|
-
g.log("Evaluate requested.", {
|
|
42
|
-
fieldHandle: r.getAttribute("data-formie-field-handle") || null,
|
|
43
|
-
isInit: s
|
|
44
|
-
});
|
|
45
|
-
const n = {
|
|
46
|
-
calculations: t,
|
|
47
|
-
init: s,
|
|
48
|
-
formula: o,
|
|
49
|
-
variables: m
|
|
50
|
-
};
|
|
51
|
-
if (L(r, y, "before-evaluate", n), !n.formula) {
|
|
52
|
-
const l = t.value !== "";
|
|
53
|
-
t.value = "", b(l);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
try {
|
|
57
|
-
const l = D(n.formula, n.variables, a), c = {
|
|
58
|
-
calculations: t,
|
|
59
|
-
init: s,
|
|
60
|
-
formula: n.formula,
|
|
61
|
-
variables: n.variables,
|
|
62
|
-
result: l
|
|
63
|
-
};
|
|
64
|
-
L(r, y, "after-evaluate", c);
|
|
65
|
-
const E = typeof c.result == "string" || typeof c.result == "number" ? String(c.result) : "", F = t.value !== E;
|
|
66
|
-
t.value = E, g.log("Evaluate complete.", {
|
|
67
|
-
fieldHandle: r.getAttribute("data-formie-field-handle") || null,
|
|
68
|
-
valueChanged: F,
|
|
69
|
-
nextValue: E
|
|
70
|
-
}), b(F);
|
|
71
|
-
} catch (l) {
|
|
72
|
-
const c = t.value !== "";
|
|
73
|
-
console.error("[formie] Failed to evaluate calculation.", l), g.warn("Evaluate failed.", {
|
|
74
|
-
fieldHandle: r.getAttribute("data-formie-field-handle") || null,
|
|
75
|
-
error: l instanceof Error ? l.message : l
|
|
76
|
-
}), t.value = "", b(c);
|
|
77
|
-
}
|
|
78
|
-
}, M = (s = !1) => {
|
|
79
|
-
v || f || (v = !0, queueMicrotask(() => {
|
|
80
|
-
v = !1, w(s);
|
|
81
|
-
}));
|
|
82
|
-
}, C = () => {
|
|
83
|
-
p();
|
|
84
|
-
const s = z(e, u);
|
|
85
|
-
if (g.log("Binding variable watchers.", {
|
|
86
|
-
fieldHandle: r.getAttribute("data-formie-field-handle") || null,
|
|
87
|
-
watchCount: s.size
|
|
88
|
-
}), !s.size)
|
|
89
|
-
return;
|
|
90
|
-
const m = (n) => {
|
|
91
|
-
const c = n.target?.name || "";
|
|
92
|
-
!c || !s.has(c) || (g.log("Source change detected.", {
|
|
93
|
-
fieldHandle: r.getAttribute("data-formie-field-handle") || null,
|
|
94
|
-
sourceName: c,
|
|
95
|
-
eventType: n.type
|
|
96
|
-
}), M(!1));
|
|
97
|
-
};
|
|
98
|
-
["input", "change"].forEach((n) => {
|
|
99
|
-
e.addEventListener(n, m);
|
|
100
|
-
const l = i.get(e) || /* @__PURE__ */ new Map();
|
|
101
|
-
l.set(n, m), i.set(e, l);
|
|
102
|
-
});
|
|
103
|
-
}, q = () => {
|
|
104
|
-
h || f || (h = !0, queueMicrotask(() => {
|
|
105
|
-
h = !1, C(), M(!1);
|
|
106
|
-
}));
|
|
107
|
-
};
|
|
108
|
-
return C(), d = new MutationObserver(() => {
|
|
109
|
-
q();
|
|
110
|
-
}), d.observe(e, {
|
|
111
|
-
childList: !0,
|
|
112
|
-
subtree: !0
|
|
113
|
-
}), w(!0), () => {
|
|
114
|
-
f = !0, d?.disconnect(), p();
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
const Q = {
|
|
118
|
-
id: y,
|
|
119
|
-
kind: "field",
|
|
120
|
-
match: (e) => !!e.target.querySelector(S),
|
|
121
|
-
setup: async (e) => {
|
|
122
|
-
const r = e.options || {}, t = K(e);
|
|
123
|
-
g.log("Module setup.", {
|
|
124
|
-
fieldCount: t.length,
|
|
125
|
-
formatting: r.formatting || null
|
|
126
|
-
});
|
|
127
|
-
const a = t.map((o) => {
|
|
128
|
-
const u = o.querySelector(S);
|
|
129
|
-
return u instanceof HTMLInputElement ? B(e.root, o, u, r) : () => {
|
|
130
|
-
};
|
|
131
|
-
});
|
|
132
|
-
return await e.emit("formie:module:calculations:init", {
|
|
133
|
-
count: a.length
|
|
134
|
-
}), {
|
|
135
|
-
destroy: () => {
|
|
136
|
-
g.log("Module destroy.", {
|
|
137
|
-
fieldCount: a.length
|
|
138
|
-
}), a.forEach((o) => {
|
|
139
|
-
o();
|
|
140
|
-
}), e.emit("formie:module:calculations:destroy", {});
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
export {
|
|
146
|
-
Q as calculationsModule
|
|
147
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { a as l, C as n } from "./index-D6npYxvr.js";
|
|
2
|
-
import { l as s } from "./scripts-CKTFtxPO.js";
|
|
3
|
-
async function c(e) {
|
|
4
|
-
const t = String(e.endPoint || "https://www.captcha.eu").trim().replace(/\/+$/, "");
|
|
5
|
-
return s("KROT", {
|
|
6
|
-
id: "FORMIE_CAPTCHA_EU_SCRIPT",
|
|
7
|
-
src: `${t}/sdk.js`,
|
|
8
|
-
async: !0,
|
|
9
|
-
defer: !0,
|
|
10
|
-
timeoutMs: n
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
const h = l({
|
|
14
|
-
id: "captcha-eu",
|
|
15
|
-
defaultPlaceholderSelector: "[data-captcha-eu-placeholder]",
|
|
16
|
-
defaultTokenFieldNames: ["captcha-eu-token"],
|
|
17
|
-
load: ({ options: e }) => c(e.provider),
|
|
18
|
-
mount: ({ api: e, container: t, provider: o, services: a }) => (e.init(), e.setup(String(o.publicKey || "")), e.WidgetV2.render(t), e.on("CPT_OK", (r) => {
|
|
19
|
-
a.tokens.write(JSON.stringify(r.detail || {}), {
|
|
20
|
-
container: t
|
|
21
|
-
}), a.errors.clear();
|
|
22
|
-
}, t), e.on("CPT_EXPIRED", () => {
|
|
23
|
-
a.tokens.clear(), a.errors.clear();
|
|
24
|
-
}, t), t),
|
|
25
|
-
screen: async ({ placeholder: e, services: t, stageCtx: o }) => {
|
|
26
|
-
if (!await t.tokens.wait()) {
|
|
27
|
-
const r = t.errors.getDefaultMessage();
|
|
28
|
-
t.errors.show(r, e), o.abort(r);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
export {
|
|
33
|
-
h as captchaEuModule
|
|
34
|
-
};
|