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_1 = require("xmobx/mobx");

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

const ColorSwatchList_1 = require("../../../presets/ColorSwatchList");

const deps_1 = require("../deps");
/**
 * @todo ui goes here
 */


let RadioOption = class RadioOption extends react_1.default.Component {
  /**
   * @todo ui goes here
   */
  constructor() {
    super(...arguments);

    this.renderItem = (item, index, ...remain) => {
      const {
        image,
        value
      } = item,
            props = tslib_1.__rest(item, ["image", "value"]);

      return react_1.default.createElement(ColorSwatchList_1.ColorSwatchItem, Object.assign({
        key: item.label,
        value: image
      }, props));
    };

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

      this.forceUpdate();
    };
  } // @todo - didMount
  // @todo no need to do state here with new ColorSwatchlist from ui-component-library
  // state = new RadioGroupState()


  componentWillMount() {
    // console.event('props receive', this.props.list)
    // const removeDisabled = option => !option.isDisabled
    // const list = this.props.list.filter(removeDisabled).map(convertToOption)
    // this.state.updateFrom(list)
    // !!! TODO !!! THIS SHOULD BE OBSERVABLE FROM 1PRODUCT, OTHERWISE WE LOSE REFERENCE
    // we can observe(this.props.list) though
    const list = this.props.list.map(deps_1.convertToOption);
    this.list = mobx_1.observable(list);
  }

  get attributes() {
    // @note onClick isn't used
    return {
      list: this.list,
      renderItem: this.renderItem,
      // state: this.state,
      onChange: this.handleOnChange
    };
  }

  render() {
    const {
      attributes
    } = this;
    return react_1.default.createElement(ColorSwatchList_1.ColorSwatchList, Object.assign({}, attributes));
  }

};
RadioOption.defaultProps = {
  onClick: deps_1.defaultOnClickAndOnChangeRadioOption,
  onChange: deps_1.defaultOnClickAndOnChangeRadioOption,
  // @todo EMPTY_LIST as long as we don't mutate
  list: [],
  type: ''
};
RadioOption = tslib_1.__decorate([mobx_react_1.observer], RadioOption);
exports.default = RadioOption; //# sourceMappingURL=RadioOption.js.map