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    
@skava/ui-presets / dist / presets / ShoppingList / ShoppingListDropDown / ShoppingListDropDown.js
Size: Mime:
"use strict";

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

const tslib_1 = require("tslib");

const react_1 = tslib_1.__importDefault(require("react"));

const mobx_react_1 = require("xmobx/mobx-react");

const exotic_1 = require("exotic");

const SelectDropDown_1 = require("@skava/ui/dist/components/molecules/SelectDropDown");

const renderProps_1 = require("./renderProps");

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

let ShoppingListDropDown = class ShoppingListDropDown extends react_1.default.Component {
  constructor() {
    super(...arguments);

    this.renderActiveItem = (props, state) => {
      const {
        label = 'Move',
        onActiveItemClick
      } = this.props;

      const {
        onClick
      } = props,
            remainingProps = tslib_1.__rest(props, ["onClick"]);

      const handleClick = args => {
        onClick(args);

        if (exotic_1.isFunction(onActiveItemClick)) {
          onActiveItemClick(args);
        }
      };

      return react_1.default.createElement(SelectDropDown_1.ActiveOption, Object.assign({
        label: label,
        state: state,
        onClick: handleClick
      }, remainingProps));
    };

    this.handleSubmit = args => {
      const {
        onFormSubmit,
        productItemDetails,
        identifier: listIdentifier,
        onActiveItemClick
      } = this.props;

      if (exotic_1.isFunction(onActiveItemClick)) {
        onActiveItemClick(args);
      }

      if (exotic_1.isFunction(onFormSubmit)) {
        onFormSubmit(Object.assign({}, args, {
          listIdentifier,
          productItemDetails
        }));
      }
    };
  }

  render() {
    const _a = this.props,
          {
      renderList,
      className,
      onActiveItemClick
    } = _a,
          remainingProps = tslib_1.__rest(_a, ["renderList", "className", "onActiveItemClick"]);

    return react_1.default.createElement(styled_1.StyledSelectDropDown, Object.assign({
      className: className,
      renderActiveItem: this.renderActiveItem,
      renderList: renderList,
      shouldBeAbsolute: true,
      onSubmit: this.handleSubmit,
      onBlur: onActiveItemClick,
      renderCreateForm: renderProps_1.defaultRenderCreateForm,
      onActiveItemClick: onActiveItemClick
    }, remainingProps));
  }

};
ShoppingListDropDown.defaultProps = {
  className: '',
  list: exotic_1.EMPTY_ARRAY,
  // renderProps
  renderButtonGroup: renderProps_1.defaultRenderButtonGroup,
  renderItem: renderProps_1.defaultRenderItem,
  renderList: renderProps_1.defaultRenderList
};
ShoppingListDropDown = tslib_1.__decorate([mobx_react_1.observer], ShoppingListDropDown);
exports.ShoppingListDropDown = ShoppingListDropDown;
exports.default = ShoppingListDropDown;