@wix/form-public 0.197.0 → 0.199.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 +33 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -10
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -29426,12 +29426,29 @@ function takeTagsViewProperties(tags) {
|
|
|
29426
29426
|
}
|
|
29427
29427
|
};
|
|
29428
29428
|
}
|
|
29429
|
-
function
|
|
29429
|
+
function makePaymentDefaultValue(options, paymentValidation) {
|
|
29430
|
+
const products = (paymentValidation == null ? void 0 : paymentValidation.products) ?? [];
|
|
29431
|
+
const result2 = options.filter((option) => option.default).map((option) => {
|
|
29432
|
+
var _product$fixedPriceOp;
|
|
29433
|
+
const product = products.find((p) => p.id === option.value);
|
|
29434
|
+
const price = (product == null ? void 0 : product.priceType) === PriceType4.FIXED_PRICE ? (_product$fixedPriceOp = product.fixedPriceOptions) == null ? void 0 : _product$fixedPriceOp.price : "0";
|
|
29435
|
+
return {
|
|
29436
|
+
productId: option.value,
|
|
29437
|
+
price: price ?? "0",
|
|
29438
|
+
quantity: 1
|
|
29439
|
+
};
|
|
29440
|
+
});
|
|
29441
|
+
return result2.length > 0 ? result2 : void 0;
|
|
29442
|
+
}
|
|
29443
|
+
function takeProductCheckboxGroupViewProperties(checkboxGroup, paymentValidation) {
|
|
29444
|
+
const defaultValue = makePaymentDefaultValue(checkboxGroup.options, paymentValidation);
|
|
29430
29445
|
return {
|
|
29431
29446
|
[HideLabelKey]: !checkboxGroup.showLabel,
|
|
29432
29447
|
[ImageResizeKey]: checkboxGroup.imageFit === ImageFit3.CONTAIN ? "FIT" : "CROP",
|
|
29433
29448
|
[OptionsKey]: checkboxGroup.options.map((option) => makeOptionView(option)),
|
|
29434
|
-
|
|
29449
|
+
...defaultValue && {
|
|
29450
|
+
[DefaultValueKey]: defaultValue
|
|
29451
|
+
},
|
|
29435
29452
|
...checkboxGroup.description && {
|
|
29436
29453
|
[DescriptionKey]: checkboxGroup.description
|
|
29437
29454
|
},
|
|
@@ -29749,9 +29766,9 @@ function takeServiceDropdownViewProperties(servicesDropdownOptions) {
|
|
|
29749
29766
|
function resolvePaymentComponent(paymentComponent) {
|
|
29750
29767
|
switch (paymentComponent.componentType) {
|
|
29751
29768
|
case PaymentComponentType.CHECKBOX_GROUP:
|
|
29752
|
-
return takeProductCheckboxGroupViewProperties(paymentComponent.checkboxGroupOptions);
|
|
29769
|
+
return takeProductCheckboxGroupViewProperties(paymentComponent.checkboxGroupOptions, paymentComponent.validation);
|
|
29753
29770
|
case PaymentComponentType.DONATION_INPUT:
|
|
29754
|
-
return takeDonationsInputViewProperties(paymentComponent.donationInputOptions);
|
|
29771
|
+
return takeDonationsInputViewProperties(paymentComponent.donationInputOptions, paymentComponent.validation);
|
|
29755
29772
|
case PaymentComponentType.FIXED_PAYMENT:
|
|
29756
29773
|
return takeFixedPaymentViewProperties(paymentComponent.fixedPaymentOptions);
|
|
29757
29774
|
case PaymentComponentType.PAYMENT_INPUT:
|
|
@@ -29870,9 +29887,9 @@ function transformFormatInfoToView(inPersonOptions, videoConferenceOptions, phon
|
|
|
29870
29887
|
}
|
|
29871
29888
|
return {};
|
|
29872
29889
|
}
|
|
29873
|
-
function takeDonationsInputViewProperties(donationInput) {
|
|
29874
|
-
var _options$find3;
|
|
29890
|
+
function takeDonationsInputViewProperties(donationInput, paymentValidation) {
|
|
29875
29891
|
const options = donationInput.options ?? [];
|
|
29892
|
+
const defaultValue = makePaymentDefaultValue(options, paymentValidation);
|
|
29876
29893
|
return {
|
|
29877
29894
|
[HideLabelKey]: !donationInput.showLabel,
|
|
29878
29895
|
[AddOtherKey]: !!donationInput.customOption,
|
|
@@ -29888,8 +29905,8 @@ function takeDonationsInputViewProperties(donationInput) {
|
|
|
29888
29905
|
[AddOtherLabelKey]: donationInput.customOption.label,
|
|
29889
29906
|
[AddOtherPlaceholderKey]: donationInput.customOption.placeholder
|
|
29890
29907
|
},
|
|
29891
|
-
...
|
|
29892
|
-
[DefaultValueKey]:
|
|
29908
|
+
...defaultValue && {
|
|
29909
|
+
[DefaultValueKey]: defaultValue
|
|
29893
29910
|
}
|
|
29894
29911
|
};
|
|
29895
29912
|
}
|
|
@@ -30206,6 +30223,12 @@ function createFormView(_ref) {
|
|
|
30206
30223
|
} else if ("name" in form) {
|
|
30207
30224
|
nameView = form.name ?? "";
|
|
30208
30225
|
}
|
|
30226
|
+
if ((form.fields ?? []).some((field) => {
|
|
30227
|
+
var _field$view;
|
|
30228
|
+
return ((_field$view = field.view) == null ? void 0 : _field$view.fieldType) === FIELD_TYPES.APPOINTMENT;
|
|
30229
|
+
})) {
|
|
30230
|
+
useFieldsV2 = false;
|
|
30231
|
+
}
|
|
30209
30232
|
const hasSmallLayout = (_layout$small = layout.small) == null ? void 0 : _layout$small.items;
|
|
30210
30233
|
const isSmallBreakpoint = isMobile2 && hasSmallLayout;
|
|
30211
30234
|
const fieldViews = (useFieldsV2 && platformizedFields ? platformizedFields : fields).filter((field) => includeHiddenFields || !field.hidden).filter((field) => {
|
|
@@ -30257,11 +30280,11 @@ function applyMobileLayout(form) {
|
|
|
30257
30280
|
};
|
|
30258
30281
|
}
|
|
30259
30282
|
function createFieldView(field, layout, path, recursive, isMobile2, breakpoint) {
|
|
30260
|
-
var _field$
|
|
30283
|
+
var _field$view2;
|
|
30261
30284
|
if (breakpoint === void 0) {
|
|
30262
30285
|
breakpoint = DEFAULT_BREAKPOINT;
|
|
30263
30286
|
}
|
|
30264
|
-
if (!(field.id && (_field$
|
|
30287
|
+
if (!(field.id && (_field$view2 = field.view) != null && _field$view2.fieldType)) {
|
|
30265
30288
|
return;
|
|
30266
30289
|
}
|
|
30267
30290
|
if (!layout) {
|