Repository URL to install this package:
|
Version:
3.1.1 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const React = require("react");
const exotic_1 = require("exotic");
const styled_1 = require("./styled");
function defaultOnIncrement(props, state) {
return state.incrementCount(props);
}
function defaultOnDecrement(props, state) {
return state.decrementCount(props);
}
function defaultHandleChange(props, state, event) {
return state.handleChange(props, event);
}
function defaultHandleBlur(props, state, event) {
return state.handleBlur(props, event);
}
function defaultRenderBox(props, state) {
const { onChange } = props;
const handleOnChangeQuantity = () => {
if (exotic_1.isFunction(onChange)) {
props.onChange(state.count);
}
};
const increment = event => {
defaultOnIncrement(props, state);
handleOnChangeQuantity();
};
const decrement = event => {
defaultOnDecrement(props, state);
handleOnChangeQuantity();
};
const handleChange = event => {
defaultHandleChange(props, state, event);
handleOnChangeQuantity();
};
const handleBlur = event => defaultHandleBlur(props, state, event);
return (React.createElement(styled_1.InnerWrapper, null,
React.createElement(styled_1.StyledButton, { onClick: decrement, isDisabled: !state.shouldDecrement },
React.createElement(styled_1.StyledMinusIcon, null)),
React.createElement(styled_1.InputBoxWrapper, null,
React.createElement(styled_1.StyledInput, { type: "text", value: state.count, onChange: handleChange, onBlur: handleBlur })),
React.createElement(styled_1.StyledButton, { onClick: increment, isDisabled: !state.shouldIncrement },
React.createElement(styled_1.StyledPlusIcon, null))));
}
exports.defaultRenderBox = defaultRenderBox;
function defaultRenderWrapper(props) {
const { children, nowrap, className } = props;
if (nowrap) {
return React.createElement(React.Fragment, null, children);
}
else {
return React.createElement(styled_1.IncrementerWrapper, { className: className }, children);
}
}
exports.defaultRenderWrapper = defaultRenderWrapper;
//# sourceMappingURL=renderProps.js.map