@wix/form-public 0.198.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 CHANGED
@@ -29426,12 +29426,29 @@ function takeTagsViewProperties(tags) {
29426
29426
  }
29427
29427
  };
29428
29428
  }
29429
- function takeProductCheckboxGroupViewProperties(checkboxGroup) {
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
- [DefaultValueKey]: checkboxGroup.options.filter((option) => option.default).map((option) => option.value),
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
- ...options.find((option) => option.default) && {
29892
- [DefaultValueKey]: (_options$find3 = options.find((option) => option.default)) == null ? void 0 : _options$find3.value
29908
+ ...defaultValue && {
29909
+ [DefaultValueKey]: defaultValue
29893
29910
  }
29894
29911
  };
29895
29912
  }