Repository URL to install this package:
|
Version:
3.5.7 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const exotic_1 = require("exotic");
const forms_1 = require("../forms");
const OneFormState_1 = require("./OneFormState");
/**
* @todo renderProps
*/
function fromObserverFormPropsToState(props) {
const obj = {
state: props.state,
inputsList: props.inputsList,
};
if (!exotic_1.isObj(props.state) && !exotic_1.isArray(props.inputsList)) {
throw new TypeError('cannot use @skava/form without .inputsList &| .state props!');
}
else if (exotic_1.isObj(props.state) && !exotic_1.isArray(props.state.inputsList)) {
throw new TypeError('using @skava/form without inputsList');
}
else if (props.state instanceof OneFormState_1.OneFormState) {
// @todo may need to make it into a `FormState` instead
// obj.state = props.state.formState || props.state
const { formState } = props.state;
obj.state = formState;
// could check inputs length is diff, then update
}
else if (props.state instanceof forms_1.FormState) {
// not really needing to check this since I moved the default above
obj.state = props.state;
}
else {
throw new TypeError('why using @skava/form without FormState?');
}
return obj;
}
exports.fromObserverFormPropsToState = fromObserverFormPropsToState;
//# sourceMappingURL=fromObserverFormPropsToState.js.map