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.
@@ -3603,13 +3603,20 @@ var AddonStepper = function AddonStepper(_ref) {
3603
3603
  var id = _ref.id,
3604
3604
  selectOptions = _ref.selectOptions,
3605
3605
  handleAddonChange = _ref.handleAddonChange,
3606
- classNamePrefix = _ref.classNamePrefix;
3606
+ classNamePrefix = _ref.classNamePrefix,
3607
+ _ref$siblingIds = _ref.siblingIds,
3608
+ siblingIds = _ref$siblingIds === void 0 ? [] : _ref$siblingIds;
3607
3609
  var _useFormikContext = useFormikContext(),
3608
3610
  values = _useFormikContext.values,
3609
3611
  setFieldValue = _useFormikContext.setFieldValue;
3610
3612
  var qty = Number((_values$id = values[id]) != null ? _values$id : 0);
3611
3613
  var max = (selectOptions == null ? void 0 : selectOptions.length) > 0 ? selectOptions[selectOptions.length - 1].value : 0;
3612
3614
  var change = function change(next) {
3615
+ if (next > 0) {
3616
+ siblingIds.forEach(function (siblingId) {
3617
+ return setFieldValue(siblingId, 0);
3618
+ });
3619
+ }
3613
3620
  setFieldValue(id, next);
3614
3621
  handleAddonChange(id, next);
3615
3622
  };
@@ -3648,6 +3655,8 @@ var AddonComponent = function AddonComponent(_ref2) {
3648
3655
  errors = _ref2.errors,
3649
3656
  _ref2$useStepperQty = _ref2.useStepperQty,
3650
3657
  useStepperQty = _ref2$useStepperQty === void 0 ? false : _ref2$useStepperQty,
3658
+ _ref2$siblingIds = _ref2.siblingIds,
3659
+ siblingIds = _ref2$siblingIds === void 0 ? [] : _ref2$siblingIds,
3651
3660
  _ref2$onCustomFieldCh = _ref2.onCustomFieldChange,
3652
3661
  onCustomFieldChange = _ref2$onCustomFieldCh === void 0 ? _identity : _ref2$onCustomFieldCh;
3653
3662
  var id = data.id,
@@ -3680,7 +3689,8 @@ var AddonComponent = function AddonComponent(_ref2) {
3680
3689
  id: id,
3681
3690
  selectOptions: selectOptions,
3682
3691
  handleAddonChange: handleAddonChange,
3683
- classNamePrefix: classNamePrefix
3692
+ classNamePrefix: classNamePrefix,
3693
+ siblingIds: siblingIds
3684
3694
  })) : React.createElement(Field, {
3685
3695
  name: id,
3686
3696
  selectOptions: selectOptions,
@@ -4402,6 +4412,11 @@ var AddonsContainter = function AddonsContainter(_ref) {
4402
4412
  data: variant,
4403
4413
  selectOptions: addonsOptions[variant.id],
4404
4414
  classNamePrefix: classNamePrefix,
4415
+ siblingIds: addon.variants.map(function (v) {
4416
+ return v.id;
4417
+ }).filter(function (vid) {
4418
+ return vid !== variant.id;
4419
+ }),
4405
4420
  handleAddonChange: function handleAddonChange(id, value) {
4406
4421
  onAddOnSelect(id, value, addon);
4407
4422
  onFieldChange(id, value, addon);
@@ -4724,6 +4739,11 @@ var SimpleAddonsContainer = function SimpleAddonsContainer(_ref) {
4724
4739
  data: variant,
4725
4740
  selectOptions: addonsOptions[variant.id],
4726
4741
  classNamePrefix: classNamePrefix,
4742
+ siblingIds: addon.variants.filter(function (v) {
4743
+ return v.id !== variant.id;
4744
+ }).map(function (v) {
4745
+ return v.id;
4746
+ }),
4727
4747
  handleAddonChange: function handleAddonChange(id, value) {
4728
4748
  console.log('handleAddonChange', id, value);
4729
4749
  onFieldChange(id, value, addon);