@wix/form-public 0.170.0 → 0.172.0
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/index.cjs +57 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +57 -47
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -20276,19 +20276,73 @@ var init_validate_premium_restrictions = __esm({
|
|
|
20276
20276
|
}
|
|
20277
20277
|
});
|
|
20278
20278
|
|
|
20279
|
+
// ../form-validator/dist/esm/lib/schema-validation/default-value-utils.js
|
|
20280
|
+
function getDefaultValue(field) {
|
|
20281
|
+
switch (field?.inputType) {
|
|
20282
|
+
case InputFieldInputType.STRING:
|
|
20283
|
+
return getDefaultStringComponentValue(field.stringOptions) ?? void 0;
|
|
20284
|
+
case InputFieldInputType.NUMBER:
|
|
20285
|
+
return getDefaultNumberComponentValue(field.numberOptions) ?? void 0;
|
|
20286
|
+
case InputFieldInputType.PAYMENT:
|
|
20287
|
+
return getDefaultPaymentComponentValue(field.paymentOptions) ?? void 0;
|
|
20288
|
+
default:
|
|
20289
|
+
return void 0;
|
|
20290
|
+
}
|
|
20291
|
+
}
|
|
20292
|
+
function getDefaultStringComponentValue(stringOptions) {
|
|
20293
|
+
switch (stringOptions?.componentType) {
|
|
20294
|
+
case InputFieldStringComponentType.DATE_TIME:
|
|
20295
|
+
return stringOptions?.dateTimeOptions?.default;
|
|
20296
|
+
case InputFieldStringComponentType.DATE_INPUT:
|
|
20297
|
+
return stringOptions?.dateInputOptions?.default;
|
|
20298
|
+
case InputFieldStringComponentType.DATE_PICKER:
|
|
20299
|
+
return stringOptions?.datePickerOptions?.default;
|
|
20300
|
+
case InputFieldStringComponentType.TEXT_INPUT:
|
|
20301
|
+
return stringOptions?.textInputOptions?.default;
|
|
20302
|
+
case InputFieldStringComponentType.TIME_INPUT:
|
|
20303
|
+
return stringOptions?.timeInputOptions?.default;
|
|
20304
|
+
default:
|
|
20305
|
+
return void 0;
|
|
20306
|
+
}
|
|
20307
|
+
}
|
|
20308
|
+
function getDefaultNumberComponentValue(numberOptions) {
|
|
20309
|
+
switch (numberOptions?.componentType) {
|
|
20310
|
+
case InputFieldNumberComponentType.NUMBER_INPUT:
|
|
20311
|
+
return numberOptions?.numberInputOptions?.default;
|
|
20312
|
+
case InputFieldNumberComponentType.RATING_INPUT:
|
|
20313
|
+
return numberOptions?.ratingInputOptions?.defaultValue;
|
|
20314
|
+
default:
|
|
20315
|
+
return void 0;
|
|
20316
|
+
}
|
|
20317
|
+
}
|
|
20318
|
+
function getDefaultPaymentComponentValue(paymentOptions) {
|
|
20319
|
+
switch (paymentOptions?.componentType) {
|
|
20320
|
+
case InputFieldPaymentComponentType.PAYMENT_INPUT:
|
|
20321
|
+
return paymentOptions?.paymentInputOptions?.default;
|
|
20322
|
+
default:
|
|
20323
|
+
return void 0;
|
|
20324
|
+
}
|
|
20325
|
+
}
|
|
20326
|
+
var init_default_value_utils = __esm({
|
|
20327
|
+
"../form-validator/dist/esm/lib/schema-validation/default-value-utils.js"() {
|
|
20328
|
+
init_types_impl();
|
|
20329
|
+
}
|
|
20330
|
+
});
|
|
20331
|
+
|
|
20279
20332
|
// ../form-validator/dist/esm/lib/schema-validation/form-schema-validator.js
|
|
20280
20333
|
var FormSchemaValidator;
|
|
20281
20334
|
var init_form_schema_validator = __esm({
|
|
20282
20335
|
"../form-validator/dist/esm/lib/schema-validation/form-schema-validator.js"() {
|
|
20283
20336
|
init_types_impl();
|
|
20284
20337
|
init_string_format_options_mapper();
|
|
20338
|
+
init_default_value_utils();
|
|
20285
20339
|
FormSchemaValidator = class {
|
|
20286
20340
|
constructor(submissionValidator) {
|
|
20287
20341
|
this.submissionValidator = submissionValidator;
|
|
20288
20342
|
}
|
|
20289
20343
|
validate(form, timezone) {
|
|
20290
20344
|
const submission = form.formFields?.reduce((acc, { inputOptions }) => {
|
|
20291
|
-
const defaultValue =
|
|
20345
|
+
const defaultValue = getDefaultValue(inputOptions);
|
|
20292
20346
|
const target = inputOptions?.target;
|
|
20293
20347
|
if (defaultValue && target) {
|
|
20294
20348
|
acc[target] = this.buildSubmissionValue(defaultValue, inputOptions, timezone);
|
|
@@ -20300,52 +20354,6 @@ var init_form_schema_validator = __esm({
|
|
|
20300
20354
|
}
|
|
20301
20355
|
return { errors: [] };
|
|
20302
20356
|
}
|
|
20303
|
-
getDefaultValue(field) {
|
|
20304
|
-
switch (field?.inputType) {
|
|
20305
|
-
case InputFieldInputType.STRING:
|
|
20306
|
-
return this.getDefaultStringComponentValue(field.stringOptions) ?? void 0;
|
|
20307
|
-
case InputFieldInputType.NUMBER:
|
|
20308
|
-
return this.getDefaultNumberComponentValue(field.numberOptions) ?? void 0;
|
|
20309
|
-
case InputFieldInputType.PAYMENT:
|
|
20310
|
-
return this.getDefaultPaymentComponentValue(field.paymentOptions) ?? void 0;
|
|
20311
|
-
default:
|
|
20312
|
-
return void 0;
|
|
20313
|
-
}
|
|
20314
|
-
}
|
|
20315
|
-
getDefaultStringComponentValue(stringOptions) {
|
|
20316
|
-
switch (stringOptions?.componentType) {
|
|
20317
|
-
case InputFieldStringComponentType.DATE_TIME:
|
|
20318
|
-
return stringOptions?.dateTimeOptions?.default;
|
|
20319
|
-
case InputFieldStringComponentType.DATE_INPUT:
|
|
20320
|
-
return stringOptions?.dateInputOptions?.default;
|
|
20321
|
-
case InputFieldStringComponentType.DATE_PICKER:
|
|
20322
|
-
return stringOptions?.datePickerOptions?.default;
|
|
20323
|
-
case InputFieldStringComponentType.TEXT_INPUT:
|
|
20324
|
-
return stringOptions?.textInputOptions?.default;
|
|
20325
|
-
case InputFieldStringComponentType.TIME_INPUT:
|
|
20326
|
-
return stringOptions?.timeInputOptions?.default;
|
|
20327
|
-
default:
|
|
20328
|
-
return void 0;
|
|
20329
|
-
}
|
|
20330
|
-
}
|
|
20331
|
-
getDefaultNumberComponentValue(numberOptions) {
|
|
20332
|
-
switch (numberOptions?.componentType) {
|
|
20333
|
-
case InputFieldNumberComponentType.NUMBER_INPUT:
|
|
20334
|
-
return numberOptions?.numberInputOptions?.default;
|
|
20335
|
-
case InputFieldNumberComponentType.RATING_INPUT:
|
|
20336
|
-
return numberOptions?.ratingInputOptions?.defaultValue;
|
|
20337
|
-
default:
|
|
20338
|
-
return void 0;
|
|
20339
|
-
}
|
|
20340
|
-
}
|
|
20341
|
-
getDefaultPaymentComponentValue(paymentOptions) {
|
|
20342
|
-
switch (paymentOptions?.componentType) {
|
|
20343
|
-
case InputFieldPaymentComponentType.PAYMENT_INPUT:
|
|
20344
|
-
return paymentOptions?.paymentInputOptions?.default;
|
|
20345
|
-
default:
|
|
20346
|
-
return void 0;
|
|
20347
|
-
}
|
|
20348
|
-
}
|
|
20349
20357
|
buildSubmissionValue(defaultValue, inputField, timezone) {
|
|
20350
20358
|
switch (inputField.inputType) {
|
|
20351
20359
|
case InputFieldInputType.PAYMENT:
|
|
@@ -20381,6 +20389,7 @@ __export(esm_exports, {
|
|
|
20381
20389
|
FormValidator: () => FormValidator,
|
|
20382
20390
|
ValidationMode: () => ValidationMode,
|
|
20383
20391
|
compareSchemaBackwardCompatibility: () => compareSchemaBackwardCompatibility,
|
|
20392
|
+
getDefaultValue: () => getDefaultValue,
|
|
20384
20393
|
groupErrorsByTarget: () => groupErrorsByTarget,
|
|
20385
20394
|
validatePremiumRestrictions: () => validatePremiumRestrictions
|
|
20386
20395
|
});
|
|
@@ -20390,6 +20399,7 @@ var init_esm2 = __esm({
|
|
|
20390
20399
|
init_compare_shema_backward_compatibility();
|
|
20391
20400
|
init_validate_premium_restrictions();
|
|
20392
20401
|
init_form_schema_validator();
|
|
20402
|
+
init_default_value_utils();
|
|
20393
20403
|
init_errors();
|
|
20394
20404
|
init_calling_country_codes();
|
|
20395
20405
|
init_error_derivation();
|