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 / dist / forms / views / CommentBox / Form / Form.js
Size: Mime:
"use strict";

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

const exotic_1 = require("exotic");

const forms_1 = require("../../..");

const fixture_1 = require("./fixture");

class FormStateCard extends forms_1.FormState {
  constructor() {
    super(...arguments);
    this.inputsList = fixture_1.inputList;
  }

}

const formStateCard = new FormStateCard();

class Form extends forms_1.ObserverForm {
  constructor(props) {
    super(props);
    this.isSubmitButtonNeeded = false;

    this.handleBlur = event => {
      const {
        onTextAreaBlur,
        identifier
      } = this.props;

      if (exotic_1.isFunction(onTextAreaBlur)) {
        onTextAreaBlur(Object.assign({}, this.state, {
          identifier
        }));
      }
    };

    this.onInputInit = inputState => {
      if (inputState.name === 'commentBox') {
        inputState.onBlur = this.handleBlur;
      }
    };

    this.state = new FormStateCard();
  }

  onPrefil(inputState) {
    const {
      value
    } = this.props;

    if (inputState.type === 'textarea' && exotic_1.isSafe(value)) {
      inputState.setValue(value);
    }
  }

  componentWillMount() {
    const {
      placeHolder,
      textAreaDataQa
    } = this.props;
    const inputList = this.state.get('commentBox');
    const passThroughProps = {
      placeholder: exotic_1.isSafe(placeHolder) ? placeHolder : fixture_1.wording.placeholderText,
      'data-qa': textAreaDataQa
    };
    Object.keys(passThroughProps).forEach(key => {
      inputList[key] = passThroughProps[key];
    });
  }

}

Form.defaultProps = {
  state: formStateCard
};
exports.Form = Form;
exports.default = Form; //# sourceMappingURL=Form.js.map