Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});

const tslib_1 = require("tslib");

const mobx_1 = require("xmobx/mobx");

const exotic_1 = require("exotic");

class PaymentWithBillingAddressFormState {
  constructor() {
    this.paymentWithBillingAddress = {};
    this.isValidForm = false;

    this.handleBlur = () => {
      const formInstance = this.paymentWithBillingAddress;
      const {
        state,
        props,
        validateForm
      } = formInstance;
      const {
        hasBlurValidation,
        onPaymentBlur
      } = props;

      if (hasBlurValidation === true) {
        this.isValidForm = validateForm();

        if (this.isValidForm === true && exotic_1.isFunction(onPaymentBlur)) {
          onPaymentBlur(state);
        }
      } else {
        console.warn('THIS FORM HAS NO ONBLUR VALIDATION SUPPORT ENABLED :: PASS IN THE FLAG hasBlurValidation={true}');
      }
    };
  }

  setPaymentForm(form) {
    this.paymentWithBillingAddress = form;
    console.log('[Payment with Billing Address] setPaymentForm()', this);
  }

  toggleBillingAddress(props) {
    const checkBoxState = props.state.get('billingAddressSameAsShipping');
    const isSelected = exotic_1.isSafe(checkBoxState) && checkBoxState.isSelected;

    const toList = state => exotic_1.isArray(state.inputsList) && state.inputsList;

    const inputStateList = toList(props.state);
    inputStateList.map(inputs => {
      if (inputs.name === 'billing-address') {
        inputs.isHidden = isSelected;
      }
    });
  }

}

tslib_1.__decorate([mobx_1.observable], PaymentWithBillingAddressFormState.prototype, "paymentWithBillingAddress", void 0);

tslib_1.__decorate([mobx_1.observable], PaymentWithBillingAddressFormState.prototype, "isValidForm", void 0);

tslib_1.__decorate([mobx_1.action], PaymentWithBillingAddressFormState.prototype, "setPaymentForm", null);

tslib_1.__decorate([mobx_1.action.bound], PaymentWithBillingAddressFormState.prototype, "handleBlur", void 0);

tslib_1.__decorate([mobx_1.action.bound], PaymentWithBillingAddressFormState.prototype, "toggleBillingAddress", null); // Object Creation


const paymentWithBillingAddressFormState = new PaymentWithBillingAddressFormState();
exports.paymentWithBillingAddressFormState = paymentWithBillingAddressFormState;
exports.default = paymentWithBillingAddressFormState; //# sourceMappingURL=state.js.map