@verbb/formie-browser 1.0.3 → 1.0.5
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 +65 -17
- 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-CgVJcQ2P.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-CZ3FU5QO.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-BF5GU3_9.js +2674 -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-Cv8ADyk-.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-CpgqHCEx.js +463 -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-B09elPDB.js +125 -0
- package/dist/chunks/theme-classes-Tv7q7ToE.js +44 -0
- package/dist/chunks/turnstile-D_Pi1CKM.js +58 -0
- package/dist/chunks/utils-Vqp8i_RM.js +49401 -0
- package/dist/css/formie-theme.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/index.js +2447 -39
- package/dist/js/core/create-formie-client.d.ts.map +1 -1
- package/dist/js/core/field-error-container.d.ts +4 -0
- package/dist/js/core/field-error-container.d.ts.map +1 -0
- package/dist/js/core/submit-result-state.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/checkbox-radio.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/file-upload.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/text-limit.d.ts.map +1 -1
- 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/dist/js/utils/i18n.d.ts.map +1 -1
- package/dist/js/validation/rules/email.d.ts.map +1 -1
- package/dist/js/validation/rules/number.d.ts.map +1 -1
- package/dist/js/validation/validator.d.ts.map +1 -1
- package/package.json +6 -3
- package/src/css/formie-theme.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/js/core/create-formie-client.ts +27 -0
- package/src/js/core/field-error-container.ts +39 -0
- package/src/js/core/submit-result-state.ts +12 -2
- package/src/js/core/submit-result-ui.ts +7 -13
- 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/checkbox-radio.ts +21 -15
- 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/file-upload.ts +12 -9
- package/src/js/modules/fields/index.ts +6 -0
- package/src/js/modules/fields/phone-country.ts +6 -0
- package/src/js/modules/fields/text-limit.ts +87 -22
- 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/js/utils/i18n.ts +184 -5
- package/src/js/validation/rules/email.ts +3 -2
- package/src/js/validation/rules/match.ts +2 -2
- package/src/js/validation/rules/minmax.ts +4 -4
- package/src/js/validation/rules/number.ts +9 -5
- package/src/js/validation/rules/pattern.ts +4 -4
- package/src/js/validation/rules/required.ts +1 -1
- package/src/js/validation/rules/url.ts +1 -1
- package/src/js/validation/validator.ts +7 -7
- package/dist/chunks/address-finder-BjMuEiwF.js +0 -37
- package/dist/chunks/bpoint-KudsBCo2.js +0 -26
- package/dist/chunks/calculations-DlGSkQ3W.js +0 -147
- package/dist/chunks/captcha-eu-CterYFok.js +0 -34
- package/dist/chunks/checkbox-radio-CBvgk3hR.js +0 -136
- package/dist/chunks/conditions-DYy1-Hwt.js +0 -459
- package/dist/chunks/date-picker-BlD--zfe.js +0 -4994
- package/dist/chunks/eway-qwc-B5Us.js +0 -74
- package/dist/chunks/file-upload-CIgHrXfp.js +0 -316
- package/dist/chunks/friendly-captcha-v1-EDFac33c.js +0 -33
- package/dist/chunks/friendly-captcha-v2-BDpSvFGR.js +0 -38
- package/dist/chunks/go-cardless-DuDMVsnz.js +0 -24
- package/dist/chunks/google-address-Bmjp01pH.js +0 -181
- package/dist/chunks/hcaptcha-BTQ6An6g.js +0 -56
- package/dist/chunks/hidden-DbPdOxKb.js +0 -31
- package/dist/chunks/index-BEsfee-D.js +0 -1839
- package/dist/chunks/index-BP7Unm5Y.js +0 -863
- package/dist/chunks/index-BcqwpPNE.js +0 -4314
- package/dist/chunks/loqate-BdNGv93o.js +0 -55
- package/dist/chunks/mollie-DFOjTuGX.js +0 -24
- package/dist/chunks/moneris-BbFfl-EL.js +0 -101
- package/dist/chunks/opayo-CmgYa9ya.js +0 -122
- package/dist/chunks/paddle-BUi7w1_o.js +0 -60
- package/dist/chunks/paypal-A-ePfh6k.js +0 -100
- package/dist/chunks/payway-BqFCbhyo.js +0 -56
- package/dist/chunks/phone-country-DPMiqk4L.js +0 -3765
- package/dist/chunks/place-kit-CX7tamAg.js +0 -42
- package/dist/chunks/placekit-autocomplete.esm-LAwfbPZl.js +0 -1299
- package/dist/chunks/recaptcha-enterprise-DxF6cW95.js +0 -71
- package/dist/chunks/recaptcha-shared-DhGcbiaq.js +0 -15
- package/dist/chunks/recaptcha-v2-checkbox-R9EfbZ4k.js +0 -41
- package/dist/chunks/recaptcha-v2-invisible-DV9hswAp.js +0 -59
- package/dist/chunks/recaptcha-v3-V0xc-Edh.js +0 -28
- package/dist/chunks/repeater-DKUT6TGI.js +0 -124
- package/dist/chunks/rich-text-SH7KiaKH.js +0 -304
- package/dist/chunks/scripts-D9N2d5rN.js +0 -36
- package/dist/chunks/sdk-3SicTWby.js +0 -1559
- package/dist/chunks/shared-BmntPmnW.js +0 -80
- package/dist/chunks/signature-BA3tQsGT.js +0 -550
- package/dist/chunks/snaptcha-DV7p6J9k.js +0 -8
- package/dist/chunks/square-Bs-ndqYK.js +0 -46
- package/dist/chunks/stripe-DkZAHxtn.js +0 -202
- package/dist/chunks/styles-C3aqgtek.js +0 -21
- package/dist/chunks/summary-Dq2i9TQk.js +0 -126
- package/dist/chunks/table-Cu4WfVcw.js +0 -95
- package/dist/chunks/text-limit-2ycmB-Ae.js +0 -135
- package/dist/chunks/turnstile-CId90tRr.js +0 -59
- package/dist/chunks/utils-BntI3W4S.js +0 -6149
package/src/js/utils/i18n.ts
CHANGED
|
@@ -79,18 +79,197 @@ export function mergeFormieTranslations(translations: Record<string, string>): R
|
|
|
79
79
|
return getFormieTranslations();
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
function parsePluralBranches(body: string): Record<string, string> {
|
|
83
|
+
const branches: Record<string, string> = {};
|
|
84
|
+
let index = 0;
|
|
85
|
+
|
|
86
|
+
while (index < body.length) {
|
|
87
|
+
while (index < body.length && /\s/.test(body[index])) {
|
|
88
|
+
index++;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (index >= body.length) {
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const branchMatch = body.slice(index).match(/^(\w+|=\d+)\{/);
|
|
96
|
+
|
|
97
|
+
if (!branchMatch) {
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const key = branchMatch[1];
|
|
102
|
+
index += branchMatch[0].length;
|
|
103
|
+
|
|
104
|
+
let depth = 1;
|
|
105
|
+
const contentStart = index;
|
|
106
|
+
|
|
107
|
+
while (index < body.length && depth > 0) {
|
|
108
|
+
if (body[index] === '{') {
|
|
109
|
+
depth++;
|
|
110
|
+
} else if (body[index] === '}') {
|
|
111
|
+
depth--;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (depth > 0) {
|
|
115
|
+
index++;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
branches[key] = body.slice(contentStart, index);
|
|
120
|
+
index++;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return branches;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function selectPluralBranch(count: number, branches: Record<string, string>): string {
|
|
127
|
+
const exactKey = `=${count}`;
|
|
128
|
+
|
|
129
|
+
if (Object.prototype.hasOwnProperty.call(branches, exactKey)) {
|
|
130
|
+
return branches[exactKey];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (typeof Intl !== 'undefined' && typeof Intl.PluralRules === 'function') {
|
|
134
|
+
const category = new Intl.PluralRules().select(count);
|
|
135
|
+
|
|
136
|
+
if (Object.prototype.hasOwnProperty.call(branches, category)) {
|
|
137
|
+
return branches[category];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (count === 1 && Object.prototype.hasOwnProperty.call(branches, 'one')) {
|
|
142
|
+
return branches.one;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (Object.prototype.hasOwnProperty.call(branches, 'other')) {
|
|
146
|
+
return branches.other;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const firstKey = Object.keys(branches)[0];
|
|
150
|
+
|
|
151
|
+
return firstKey ? branches[firstKey] : '';
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function parsePluralExpression(message: string, startIndex: number): { param: string; body: string; endIndex: number } | null {
|
|
155
|
+
const headerMatch = message.slice(startIndex).match(/^\{(\w+),\s*plural,\s*/);
|
|
156
|
+
|
|
157
|
+
if (!headerMatch) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const param = headerMatch[1];
|
|
162
|
+
const bodyStart = startIndex + headerMatch[0].length;
|
|
163
|
+
let index = bodyStart;
|
|
164
|
+
|
|
165
|
+
while (index < message.length) {
|
|
166
|
+
while (index < message.length && /\s/.test(message[index])) {
|
|
167
|
+
index++;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (index >= message.length || message[index] === '}') {
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const branchMatch = message.slice(index).match(/^(\w+|=\d+)\{/);
|
|
84
175
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
176
|
+
if (!branchMatch) {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
index += branchMatch[0].length;
|
|
181
|
+
|
|
182
|
+
let depth = 1;
|
|
183
|
+
|
|
184
|
+
while (index < message.length && depth > 0) {
|
|
185
|
+
if (message[index] === '{') {
|
|
186
|
+
depth++;
|
|
187
|
+
} else if (message[index] === '}') {
|
|
188
|
+
depth--;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (depth > 0) {
|
|
192
|
+
index++;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
index++;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (index >= message.length || message[index] !== '}') {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return {
|
|
204
|
+
param,
|
|
205
|
+
body: message.slice(bodyStart, index),
|
|
206
|
+
endIndex: index,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function formatPluralBlocks(message: string, replacements: TranslationReplacements): string {
|
|
211
|
+
let output = '';
|
|
212
|
+
let index = 0;
|
|
213
|
+
|
|
214
|
+
while (index < message.length) {
|
|
215
|
+
if (message[index] !== '{') {
|
|
216
|
+
output += message[index];
|
|
217
|
+
index++;
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const parsed = parsePluralExpression(message, index);
|
|
222
|
+
|
|
223
|
+
if (!parsed) {
|
|
224
|
+
output += message[index];
|
|
225
|
+
index++;
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const rawValue = replacements[parsed.param];
|
|
230
|
+
const count = typeof rawValue === 'number'
|
|
231
|
+
? rawValue
|
|
232
|
+
: Number.parseInt(String(rawValue ?? ''), 10) || 0;
|
|
233
|
+
const branches = parsePluralBranches(parsed.body);
|
|
234
|
+
let selected = selectPluralBranch(count, branches);
|
|
235
|
+
|
|
236
|
+
selected = selected.replace(/#/g, String(count));
|
|
237
|
+
|
|
238
|
+
output += selected;
|
|
239
|
+
index = parsed.endIndex + 1;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return output;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function formatNumberBlocks(message: string, replacements: TranslationReplacements): string {
|
|
246
|
+
return message.replace(/\{(\w+),\s*number\}/g, (match, key) => {
|
|
247
|
+
if (!Object.prototype.hasOwnProperty.call(replacements, key)) {
|
|
248
|
+
return match;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const value = replacements[key];
|
|
252
|
+
|
|
253
|
+
return typeof value === 'number' ? value.toLocaleString() : String(value);
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function replaceSimpleTokens(message: string, replacements: TranslationReplacements): string {
|
|
258
|
+
return message.replace(/\{(\w+)\}/g, (match, key) => {
|
|
88
259
|
if (Object.prototype.hasOwnProperty.call(replacements, key)) {
|
|
89
260
|
return String(replacements[key]);
|
|
90
261
|
}
|
|
91
262
|
|
|
92
263
|
return match;
|
|
93
264
|
});
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export function t(message: string, replacements: TranslationReplacements = {}): string {
|
|
268
|
+
let output = getTranslationStore()[message] || message;
|
|
269
|
+
|
|
270
|
+
output = formatPluralBlocks(output, replacements);
|
|
271
|
+
output = formatNumberBlocks(output, replacements);
|
|
272
|
+
output = replaceSimpleTokens(output, replacements);
|
|
94
273
|
|
|
95
274
|
return output;
|
|
96
275
|
}
|
|
@@ -9,9 +9,10 @@ const email: ValidationRuleDefinition = {
|
|
|
9
9
|
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(input.value);
|
|
10
10
|
},
|
|
11
11
|
message: ({ input, label, t }) => {
|
|
12
|
-
return input.getAttribute('data-formie-
|
|
12
|
+
return input.getAttribute('data-formie-validation-email-message')
|
|
13
|
+
?? input.getAttribute('data-formie-pattern-email-message')
|
|
13
14
|
?? input.getAttribute('data-pattern-email-message')
|
|
14
|
-
?? t('{
|
|
15
|
+
?? t('{label} is not a valid email address.', { label });
|
|
15
16
|
},
|
|
16
17
|
};
|
|
17
18
|
|
|
@@ -16,8 +16,8 @@ const match: ValidationRuleDefinition = {
|
|
|
16
16
|
const sourceField = sourceInput?.closest('[data-formie-field-handle]') as HTMLElement | null;
|
|
17
17
|
const sourceLabel = getLabelText(sourceField);
|
|
18
18
|
|
|
19
|
-
return ctx.t('{
|
|
20
|
-
|
|
19
|
+
return ctx.t('{label} must match {value}.', {
|
|
20
|
+
label: ctx.label,
|
|
21
21
|
value: sourceLabel,
|
|
22
22
|
});
|
|
23
23
|
},
|
|
@@ -29,18 +29,18 @@ const minmax: ValidationRuleDefinition = {
|
|
|
29
29
|
const max = input.hasAttribute('max') ? parseFloat(input.getAttribute('max') || '') : null;
|
|
30
30
|
|
|
31
31
|
if (min !== null && max !== null) {
|
|
32
|
-
return t('{
|
|
32
|
+
return t('{label} must be between {min} and {max}.', { label, min, max });
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
if (min !== null) {
|
|
36
|
-
return t('{
|
|
36
|
+
return t('{label} must be no less than {min}.', { label, min });
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
if (max !== null) {
|
|
40
|
-
return t('{
|
|
40
|
+
return t('{label} must be no greater than {max}.', { label, max });
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
return t('{
|
|
43
|
+
return t('{label} has an invalid value.', { label });
|
|
44
44
|
},
|
|
45
45
|
};
|
|
46
46
|
|
|
@@ -35,20 +35,24 @@ const number: ValidationRuleDefinition = {
|
|
|
35
35
|
const max = rule !== true && rule && typeof rule === 'object' && typeof rule.max === 'number' ? rule.max : null;
|
|
36
36
|
|
|
37
37
|
if (min !== null && max !== null) {
|
|
38
|
-
return
|
|
38
|
+
return input.getAttribute('data-formie-validation-number-min-message')
|
|
39
|
+
?? t('{label} must be between {min} and {max}.', { label, min, max });
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
if (min !== null) {
|
|
42
|
-
return
|
|
43
|
+
return input.getAttribute('data-formie-validation-number-min-message')
|
|
44
|
+
?? t('{label} must be no less than {min}.', { label, min });
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
if (max !== null) {
|
|
46
|
-
return
|
|
48
|
+
return input.getAttribute('data-formie-validation-number-max-message')
|
|
49
|
+
?? t('{label} must be no greater than {max}.', { label, max });
|
|
47
50
|
}
|
|
48
51
|
|
|
49
|
-
return input.getAttribute('data-formie-
|
|
52
|
+
return input.getAttribute('data-formie-validation-number-message')
|
|
53
|
+
?? input.getAttribute('data-formie-pattern-number-message')
|
|
50
54
|
?? input.getAttribute('data-pattern-number-message')
|
|
51
|
-
?? t('{
|
|
55
|
+
?? t('{label} is not a valid number.', { label });
|
|
52
56
|
},
|
|
53
57
|
};
|
|
54
58
|
|
|
@@ -13,10 +13,10 @@ const pattern: ValidationRuleDefinition = {
|
|
|
13
13
|
},
|
|
14
14
|
message: ({ input, label, t }) => {
|
|
15
15
|
const messages = {
|
|
16
|
-
email: t('{
|
|
17
|
-
url: t('{
|
|
18
|
-
number: t('{
|
|
19
|
-
default: t('{
|
|
16
|
+
email: t('{label} is not a valid email address.', { label }),
|
|
17
|
+
url: t('{label} is not a valid URL.', { label }),
|
|
18
|
+
number: t('{label} is not a valid number.', { label }),
|
|
19
|
+
default: t('{label} is not a valid format.', { label }),
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
return input.getAttribute(`data-formie-pattern-${input.type}-message`)
|
|
@@ -23,7 +23,7 @@ const required: ValidationRuleDefinition = {
|
|
|
23
23
|
message: ({ input, label, t }) => {
|
|
24
24
|
return input.getAttribute('data-formie-required-message')
|
|
25
25
|
?? input.getAttribute('data-required-message')
|
|
26
|
-
?? t('{
|
|
26
|
+
?? t('{label} cannot be blank.', { label });
|
|
27
27
|
},
|
|
28
28
|
};
|
|
29
29
|
|
|
@@ -16,7 +16,7 @@ const url: ValidationRuleDefinition = {
|
|
|
16
16
|
message: ({ input, label, t }) => {
|
|
17
17
|
return input.getAttribute('data-formie-pattern-url-message')
|
|
18
18
|
?? input.getAttribute('data-pattern-url-message')
|
|
19
|
-
?? t('{
|
|
19
|
+
?? t('{label} is not a valid URL.', { label });
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
22
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ensureFieldErrorContainer } from '#core/field-error-container';
|
|
1
2
|
import { syncPageTabErrors } from '#core/page-tab-errors';
|
|
2
3
|
import rules from '#validation/rules';
|
|
3
4
|
import type {
|
|
@@ -320,12 +321,11 @@ export class FormieValidator {
|
|
|
320
321
|
let errorMessages = fieldContainer.querySelector('[data-formie-field-errors]') as HTMLElement | null;
|
|
321
322
|
|
|
322
323
|
if (!errorMessages) {
|
|
323
|
-
errorMessages =
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
}
|
|
328
|
-
fieldContainer.appendChild(errorMessages);
|
|
324
|
+
errorMessages = ensureFieldErrorContainer(fieldContainer, (container) => {
|
|
325
|
+
if (this.config.messagesClass.length) {
|
|
326
|
+
container.classList.add(...this.config.messagesClass);
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
329
|
}
|
|
330
330
|
|
|
331
331
|
if (this.config.messagesClass.length) {
|
|
@@ -402,7 +402,7 @@ export class FormieValidator {
|
|
|
402
402
|
|
|
403
403
|
getErrorMessage(input: ValidationInput, validatorName: string, validator: ValidatorDefinition, opts: ValidationContext): string {
|
|
404
404
|
const errorMessage = typeof validator.errorMessage === 'function' ? validator.errorMessage(opts) : validator.errorMessage;
|
|
405
|
-
return errorMessage ?? t('{
|
|
405
|
+
return errorMessage ?? t('{label} is invalid.', { label: opts.label });
|
|
406
406
|
}
|
|
407
407
|
|
|
408
408
|
getErrors(): ValidationError[] {
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { d as p, g as a } from "./index-BcqwpPNE.js";
|
|
2
|
-
import { l as _ } from "./scripts-D9N2d5rN.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 { u as c } from "./index-BcqwpPNE.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-BmntPmnW.js";
|
|
3
|
-
import { h as R, i as k, n as U, j as V, r as _ } from "./index-BcqwpPNE.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-BcqwpPNE.js";
|
|
2
|
-
import { l as s } from "./scripts-D9N2d5rN.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
|
-
};
|