tf-checkout-react 1.7.19 → 1.7.20

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.
@@ -9,7 +9,8 @@ interface IAddonComponentProps {
9
9
  values: any;
10
10
  errors: any;
11
11
  useStepperQty?: boolean;
12
+ siblingIds?: string[];
12
13
  onCustomFieldChange?: (addon: any, groupId: string | number, fieldName: string, value: any) => void;
13
14
  }
14
- declare const AddonComponent: ({ classNamePrefix, data, selectOptions, handleAddonChange, addOnDataWithCustomFields, configs, values, errors, useStepperQty, onCustomFieldChange, }: IAddonComponentProps) => JSX.Element;
15
+ declare const AddonComponent: ({ classNamePrefix, data, selectOptions, handleAddonChange, addOnDataWithCustomFields, configs, values, errors, useStepperQty, siblingIds, onCustomFieldChange, }: IAddonComponentProps) => JSX.Element;
15
16
  export default AddonComponent;
@@ -3610,13 +3610,20 @@ var AddonStepper = function AddonStepper(_ref) {
3610
3610
  var id = _ref.id,
3611
3611
  selectOptions = _ref.selectOptions,
3612
3612
  handleAddonChange = _ref.handleAddonChange,
3613
- classNamePrefix = _ref.classNamePrefix;
3613
+ classNamePrefix = _ref.classNamePrefix,
3614
+ _ref$siblingIds = _ref.siblingIds,
3615
+ siblingIds = _ref$siblingIds === void 0 ? [] : _ref$siblingIds;
3614
3616
  var _useFormikContext = formik.useFormikContext(),
3615
3617
  values = _useFormikContext.values,
3616
3618
  setFieldValue = _useFormikContext.setFieldValue;
3617
3619
  var qty = Number((_values$id = values[id]) != null ? _values$id : 0);
3618
3620
  var max = (selectOptions == null ? void 0 : selectOptions.length) > 0 ? selectOptions[selectOptions.length - 1].value : 0;
3619
3621
  var change = function change(next) {
3622
+ if (next > 0) {
3623
+ siblingIds.forEach(function (siblingId) {
3624
+ return setFieldValue(siblingId, 0);
3625
+ });
3626
+ }
3620
3627
  setFieldValue(id, next);
3621
3628
  handleAddonChange(id, next);
3622
3629
  };
@@ -3655,6 +3662,8 @@ var AddonComponent = function AddonComponent(_ref2) {
3655
3662
  errors = _ref2.errors,
3656
3663
  _ref2$useStepperQty = _ref2.useStepperQty,
3657
3664
  useStepperQty = _ref2$useStepperQty === void 0 ? false : _ref2$useStepperQty,
3665
+ _ref2$siblingIds = _ref2.siblingIds,
3666
+ siblingIds = _ref2$siblingIds === void 0 ? [] : _ref2$siblingIds,
3658
3667
  _ref2$onCustomFieldCh = _ref2.onCustomFieldChange,
3659
3668
  onCustomFieldChange = _ref2$onCustomFieldCh === void 0 ? _identity : _ref2$onCustomFieldCh;
3660
3669
  var id = data.id,
@@ -3687,7 +3696,8 @@ var AddonComponent = function AddonComponent(_ref2) {
3687
3696
  id: id,
3688
3697
  selectOptions: selectOptions,
3689
3698
  handleAddonChange: handleAddonChange,
3690
- classNamePrefix: classNamePrefix
3699
+ classNamePrefix: classNamePrefix,
3700
+ siblingIds: siblingIds
3691
3701
  })) : React__default.createElement(formik.Field, {
3692
3702
  name: id,
3693
3703
  selectOptions: selectOptions,
@@ -4409,6 +4419,11 @@ var AddonsContainter = function AddonsContainter(_ref) {
4409
4419
  data: variant,
4410
4420
  selectOptions: addonsOptions[variant.id],
4411
4421
  classNamePrefix: classNamePrefix,
4422
+ siblingIds: addon.variants.map(function (v) {
4423
+ return v.id;
4424
+ }).filter(function (vid) {
4425
+ return vid !== variant.id;
4426
+ }),
4412
4427
  handleAddonChange: function handleAddonChange(id, value) {
4413
4428
  onAddOnSelect(id, value, addon);
4414
4429
  onFieldChange(id, value, addon);
@@ -4731,6 +4746,11 @@ var SimpleAddonsContainer = function SimpleAddonsContainer(_ref) {
4731
4746
  data: variant,
4732
4747
  selectOptions: addonsOptions[variant.id],
4733
4748
  classNamePrefix: classNamePrefix,
4749
+ siblingIds: addon.variants.filter(function (v) {
4750
+ return v.id !== variant.id;
4751
+ }).map(function (v) {
4752
+ return v.id;
4753
+ }),
4734
4754
  handleAddonChange: function handleAddonChange(id, value) {
4735
4755
  console.log('handleAddonChange', id, value);
4736
4756
  onFieldChange(id, value, addon);