Repository URL to install this package:
|
Version:
2.1.14 ▾
|
@skava/ui-presets
/
dist
/
presets
/
B2B
/
UserManagement
/
UserStatus
/
Form
/
SearchUser
/
SearchUser.js
|
|---|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const exotic_1 = require("exotic");
const mobx_react_1 = require("xmobx/mobx-react");
const forms_1 = require("@skava/ui/dist/forms");
const fixture_1 = require("../fixture");
const styled_1 = require("./styled");
class FormStateCard extends forms_1.FormState {
constructor() {
super(...arguments);
this.inputsList = fixture_1.searchInputList;
}
}
const formStateCard = new FormStateCard();
let SearchForm = class SearchForm extends forms_1.ObserverForm {
constructor() {
super(...arguments);
this.isSubmitButtonNeeded = false;
this.handleChange = args => {
const {
value,
state
} = args;
state.setValue(value);
this.handleSearch();
};
this.handleSearch = () => {
const {
onSearch
} = this.props;
console.log('[Search form] state value', this.state.toSerialized());
if (exotic_1.isFunction(onSearch)) {
onSearch(this.state);
}
};
this.onInputInit = inputState => {
if (inputState.type === 'select') {
inputState.onDropdownChange = this.handleChange;
} else if (inputState.name === 'search') {
inputState.onIconClick = this.handleSearch;
}
};
}
componentWillMount() {
const toList = state => exotic_1.isArray(state.inputsList) && state.inputsList;
const list = toList(this.state);
this.onInputInit(list);
}
};
SearchForm.FormState = formStateCard;
SearchForm.defaultProps = {
state: formStateCard
};
SearchForm = tslib_1.__decorate([mobx_react_1.observer], SearchForm);
class SearchUser extends react_1.default.PureComponent {
render() {
return react_1.default.createElement(styled_1.Wrapper, null, react_1.default.createElement(SearchForm, Object.assign({}, this.props)));
}
}
exports.SearchUser = SearchUser;
exports.default = SearchUser;