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 mobx_react_1 = require("xmobx/mobx-react"); // import { isFunction, isObj } from 'exotic'


const SwatchList_1 = require("../../../presets/SwatchList");

const deps_1 = require("../deps");

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

    this.handleOnChange = (event, item, state) => {
      deps_1.reusableOnChange({
        event,
        item,
        state,
        props: this.props
      }); // @todo isn't updating enough...

      this.forceUpdate();
    };

    this.SizeFilter = list => {
      const filterData = {
        extralarge: 'xl',
        extrasmall: 'xs',
        large: 'l',
        medium: 'm',
        small: 's'
      };

      const dataReconstruction = swatchItems => {
        const trimValue = swatchItems.label.replace(/ /g, '');
        const lowerCaseValue = trimValue.toLowerCase();

        if (filterData.hasOwnProperty(lowerCaseValue)) {
          swatchItems.label = filterData[lowerCaseValue];
          swatchItems.label = filterData[lowerCaseValue];
        }

        return swatchItems;
      };

      const view = list.map((item, index) => dataReconstruction(item));
      return view;
    };
  }

  componentWillMount() {
    this.list = deps_1.toOptions(this.props.list);
  }

  get attributes() {
    // @note onClick isn't used
    const {
      name
    } = this.props;
    const listItem = this.SizeFilter(this.list);
    return Object.assign({
      text: name
    }, this.props, {
      onChange: this.handleOnChange,
      list: listItem
    });
  }

  render() {
    // const type = this.props.type || 'size'
    // const isSquare = type === 'size' || type === 'size1'
    // console.log('[Square Options] attributes', this.attributes)
    const {
      attributes
    } = this;
    return react_1.default.createElement(SwatchList_1.SwatchList, Object.assign({}, attributes));
  }

};
SquareOption.defaultProps = {
  /**
   * value of this square
   * @see typings
   * @example skus: [{name: '6 pack'}]
   */
  name: 'googleblueshoetwo',
  isSelected: false,
  isDisabled: true,
  value: undefined,
  type: 'size'
};
SquareOption = tslib_1.__decorate([mobx_react_1.observer], SquareOption);
exports.SquareOption = SquareOption;
exports.default = SquareOption; //# sourceMappingURL=SquareOption.js.map