meraproject/lib/js/bws/react/form/contacts.js

90 lines
2.1 KiB
JavaScript
Raw Normal View History

var Contacts;
import './contact.js';
export default window.Contacts = Contacts = function () {
class Contacts extends React.Component {
constructor(props) {
var value;
super(props);
value = [];
if (Array.isArray(props.value)) {
value = props.value;
}
this.state = {
contacts: value
};
this.addContact = this.addContact.bind(this);
this.addButton = /*#__PURE__*/React.createElement("div", {
class: "label l-big",
onClick: this.addContact
}, /*#__PURE__*/React.createElement("button", {
class: "btn-icon btn-i-blue"
}, /*#__PURE__*/React.createElement("span", null, "\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0435\u0449\u0435 \u043C\u0435\u0442\u043E\u0434 \u0441\u0432\u044F\u0437\u0438")));
this.contacts = {};
}
getValue() {
var i, res, v;
res = [];
for (i in this.contacts) {
v = this.contacts[i];
if (v != null && !v.state.removed) {
res.push(v.getValue());
}
}
return res;
}
renderContact(item, index) {
var _this = this;
return /*#__PURE__*/React.createElement(Contact, {
data: item,
ref: function (i) {
return _this.contacts[index] = i;
}
});
}
addContact() {
var c;
c = this.state.contacts;
c.push({});
return this.setState({
contacts: c
});
}
render() {
var contacts, t;
t = this; //console.log 'this.state.contacts',this.state.contacts
contacts = this.state.contacts.map(t.renderContact.bind(t));
contacts.push(this.addButton);
return contacts;
}
}
;
Contacts.TYPES = [{
id: 1,
title: /*#__PURE__*/React.createElement("div", {
className: "icon ic-small ic-leftbar phone"
}),
placeholder: 'Телефон'
}, {
id: 4,
title: /*#__PURE__*/React.createElement("div", {
className: "icon ic-mail"
}),
placeholder: 'Email'
}];
return Contacts;
}.call(this);
//# sourceMappingURL=contacts.js.map