@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.js CHANGED
@@ -29400,12 +29400,29 @@ function takeTagsViewProperties(tags) {
29400
29400
  }
29401
29401
  };
29402
29402
  }
29403
- function takeProductCheckboxGroupViewProperties(checkboxGroup) {
29403
+ function makePaymentDefaultValue(options, paymentValidation) {
29404
+ const products = (paymentValidation == null ? void 0 : paymentValidation.products) ?? [];
29405
+ const result2 = options.filter((option) => option.default).map((option) => {
29406
+ var _product$fixedPriceOp;
29407
+ const product = products.find((p) => p.id === option.value);
29408
+ const price = (product == null ? void 0 : product.priceType) === PriceType4.FIXED_PRICE ? (_product$fixedPriceOp = product.fixedPriceOptions) == null ? void 0 : _product$fixedPriceOp.price : "0";
29409
+ return {
29410
+ productId: option.value,
29411
+ price: price ?? "0",
29412
+ quantity: 1
29413
+ };
29414
+ });
29415
+ return result2.length > 0 ? result2 : void 0;
29416
+ }
29417
+ function takeProductCheckboxGroupViewProperties(checkboxGroup, paymentValidation) {
29418
+ const defaultValue = makePaymentDefaultValue(checkboxGroup.options, paymentValidation);
29404
29419
  return {
29405
29420
  [HideLabelKey]: !checkboxGroup.showLabel,
29406
29421
  [ImageResizeKey]: checkboxGroup.imageFit === ImageFit3.CONTAIN ? "FIT" : "CROP",
29407
29422
  [OptionsKey]: checkboxGroup.options.map((option) => makeOptionView(option)),
29408
- [DefaultValueKey]: checkboxGroup.options.filter((option) => option.default).map((option) => option.value),
29423
+ ...defaultValue && {
29424
+ [DefaultValueKey]: defaultValue
29425
+ },
29409
29426
  ...checkboxGroup.description && {
29410
29427
  [DescriptionKey]: checkboxGroup.description
29411
29428
  },
@@ -29723,9 +29740,9 @@ function takeServiceDropdownViewProperties(servicesDropdownOptions) {
29723
29740
  function resolvePaymentComponent(paymentComponent) {
29724
29741
  switch (paymentComponent.componentType) {
29725
29742
  case PaymentComponentType.CHECKBOX_GROUP:
29726
- return takeProductCheckboxGroupViewProperties(paymentComponent.checkboxGroupOptions);
29743
+ return takeProductCheckboxGroupViewProperties(paymentComponent.checkboxGroupOptions, paymentComponent.validation);
29727
29744
  case PaymentComponentType.DONATION_INPUT:
29728
- return takeDonationsInputViewProperties(paymentComponent.donationInputOptions);
29745
+ return takeDonationsInputViewProperties(paymentComponent.donationInputOptions, paymentComponent.validation);
29729
29746
  case PaymentComponentType.FIXED_PAYMENT:
29730
29747
  return takeFixedPaymentViewProperties(paymentComponent.fixedPaymentOptions);
29731
29748
  case PaymentComponentType.PAYMENT_INPUT:
@@ -29844,9 +29861,9 @@ function transformFormatInfoToView(inPersonOptions, videoConferenceOptions, phon
29844
29861
  }
29845
29862
  return {};
29846
29863
  }
29847
- function takeDonationsInputViewProperties(donationInput) {
29848
- var _options$find3;
29864
+ function takeDonationsInputViewProperties(donationInput, paymentValidation) {
29849
29865
  const options = donationInput.options ?? [];
29866
+ const defaultValue = makePaymentDefaultValue(options, paymentValidation);
29850
29867
  return {
29851
29868
  [HideLabelKey]: !donationInput.showLabel,
29852
29869
  [AddOtherKey]: !!donationInput.customOption,
@@ -29862,8 +29879,8 @@ function takeDonationsInputViewProperties(donationInput) {
29862
29879
  [AddOtherLabelKey]: donationInput.customOption.label,
29863
29880
  [AddOtherPlaceholderKey]: donationInput.customOption.placeholder
29864
29881
  },
29865
- ...options.find((option) => option.default) && {
29866
- [DefaultValueKey]: (_options$find3 = options.find((option) => option.default)) == null ? void 0 : _options$find3.value
29882
+ ...defaultValue && {
29883
+ [DefaultValueKey]: defaultValue
29867
29884
  }
29868
29885
  };
29869
29886
  }
@@ -30180,6 +30197,12 @@ function createFormView(_ref) {
30180
30197
  } else if ("name" in form) {
30181
30198
  nameView = form.name ?? "";
30182
30199
  }
30200
+ if ((form.fields ?? []).some((field) => {
30201
+ var _field$view;
30202
+ return ((_field$view = field.view) == null ? void 0 : _field$view.fieldType) === FIELD_TYPES.APPOINTMENT;
30203
+ })) {
30204
+ useFieldsV2 = false;
30205
+ }
30183
30206
  const hasSmallLayout = (_layout$small = layout.small) == null ? void 0 : _layout$small.items;
30184
30207
  const isSmallBreakpoint = isMobile2 && hasSmallLayout;
30185
30208
  const fieldViews = (useFieldsV2 && platformizedFields ? platformizedFields : fields).filter((field) => includeHiddenFields || !field.hidden).filter((field) => {
@@ -30231,11 +30254,11 @@ function applyMobileLayout(form) {
30231
30254
  };
30232
30255
  }
30233
30256
  function createFieldView(field, layout, path, recursive, isMobile2, breakpoint) {
30234
- var _field$view;
30257
+ var _field$view2;
30235
30258
  if (breakpoint === void 0) {
30236
30259
  breakpoint = DEFAULT_BREAKPOINT;
30237
30260
  }
30238
- if (!(field.id && (_field$view = field.view) != null && _field$view.fieldType)) {
30261
+ if (!(field.id && (_field$view2 = field.view) != null && _field$view2.fieldType)) {
30239
30262
  return;
30240
30263
  }
30241
30264
  if (!layout) {