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 styled_1 = require("./styled");

const handleDynamicClick = buttonClickProps => {
  const {
    onActionButtonClick,
    item,
    buttonProps
  } = buttonClickProps;

  if (exotic_1.isObj(buttonProps) && !buttonProps.navigationURL) {
    if (exotic_1.isFunction(onActionButtonClick)) {
      onActionButtonClick({
        label: buttonProps.value,
        item
      });
    }
  }
};

function defaultRenderButton(props, index, state) {
  const handleClick = () => handleDynamicClick(props);

  const {
    buttonProps
  } = props;
  const label = exotic_1.isObj(buttonProps) && buttonProps.label;
  const color = exotic_1.isObj(buttonProps) && buttonProps.color;
  const dataQa = exotic_1.isObj(buttonProps) && buttonProps['data-qa'];
  return react_1.default.createElement(styled_1.StyledButton, {
    key: index,
    text: label,
    onClick: label === 'return' || label === 'cancel' ? state.handleShow : handleClick,
    color: color,
    "data-qa": dataQa
  });
}

exports.defaultRenderButton = defaultRenderButton;

function defaultRenderLinkButton(item, index) {
  return react_1.default.createElement(styled_1.StyledLinkButton, {
    href: item.navigationURL,
    color: item.color,
    "data-qa": item['data-qa'],
    key: index
  }, item.label);
}

exports.defaultRenderLinkButton = defaultRenderLinkButton;

function defaultRenderActionButtons(props, state) {
  const {
    renderLinkButton,
    renderButton
  } = props,
        remainingProps = tslib_1.__rest(props, ["renderLinkButton", "renderButton"]);

  return exotic_1.isArray(props.item.actionButtonList) && props.item.actionButtonList.map((buttonProps, index) => {
    const buttonView = buttonProps.navigationURL ? exotic_1.isFunction(renderLinkButton) && renderLinkButton(buttonProps, index) : exotic_1.isFunction(renderButton) && renderButton(Object.assign({
      buttonProps
    }, remainingProps), index, state);
    return buttonView;
  });
}

exports.defaultRenderActionButtons = defaultRenderActionButtons;