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 react_1 = tslib_1.__importDefault(require("react"));

const exotic_1 = require("exotic");

const utils_1 = require("@skava/utils");

const ShippingAddressCard_1 = require("../../../ShippingAddressCard");

const styled_1 = require("./styled");

function defaultRenderHeaderView(props, state) {
  const {
    buttonLabel,
    buttonDataQa,
    shippingAddressOptionList,
    handleToggleChange,
    handleFormBlur
  } = props,
        remainingProps = tslib_1.__rest(props, ["buttonLabel", "buttonDataQa", "shippingAddressOptionList", "handleToggleChange", "handleFormBlur"]);

  const {
    handleToggle,
    address
  } = state;
  const attributes = {
    buttonLabel,
    address,
    buttonDataQa
  };
  return react_1.default.createElement(ShippingAddressCard_1.ShippingAddressCard, Object.assign({
    onChangeAddress: handleToggle,
    onToggleChange: handleToggleChange,
    onFormBlur: handleFormBlur,
    singleShippingState: state,
    list: shippingAddressOptionList
  }, attributes, remainingProps));
}

exports.defaultRenderHeaderView = defaultRenderHeaderView;

const defaultHandleToggleChange = (event, item, selectionStateThis) => {
  const {
    onShippingAddressChange,
    singleShippingState
  } = selectionStateThis.props;
  singleShippingState.address = utils_1.fromStringToAddress(item.value);
  console.log('[Single Shipping] handleToggleChange ', item, selectionStateThis);

  if (exotic_1.isFunction(onShippingAddressChange)) {
    onShippingAddressChange({
      address: singleShippingState.address,
      identifier: selectionStateThis.props.productIdentifier
    });
  }
};

exports.defaultHandleToggleChange = defaultHandleToggleChange;

const defaultHandleFormBlur = args => {
  const {
    props,
    state
  } = args;
  const {
    onShippingAddressChange,
    singleShippingState
  } = props;
  console.log('[Single Shipping] handleFormBlur ', singleShippingState.address, props);
  singleShippingState.address = state.toSerialized();

  if (exotic_1.isFunction(onShippingAddressChange)) {
    onShippingAddressChange(singleShippingState.address);
  }
};

exports.defaultHandleFormBlur = defaultHandleFormBlur;

function defaultRenderExpandableView(props, state) {
  const {
    shippingAddressOptionList,
    handleToggleChange,
    onViewToggle,
    handleFormBlur,
    identifier
  } = props,
        remainingProps = tslib_1.__rest(props, ["shippingAddressOptionList", "handleToggleChange", "onViewToggle", "handleFormBlur", "identifier"]);

  const handleViewToggleChange = onViewToggle;
  return react_1.default.createElement(styled_1.StyledAddressToggle, Object.assign({
    list: shippingAddressOptionList,
    singleShippingState: state,
    onToggleChange: handleToggleChange,
    onFormBlur: handleFormBlur,
    onViewToggleChange: handleViewToggleChange,
    productIdentifier: identifier
  }, remainingProps));
}

exports.defaultRenderExpandableView = defaultRenderExpandableView; //# sourceMappingURL=renderProps.js.map