@shopgate/engage
Version:
Shopgate's ENGAGE library.
43 lines (42 loc) • 1.11 kB
JavaScript
import React from 'react';
import PropTypes from 'prop-types';
import noop from 'lodash/noop';
import UnitQuantityPicker from "./UnitQuantityPicker";
import { small, big } from "./styles";
/**
* @param {Object} props The component props.
* @returns {JSX}
*/
import { jsx as _jsx } from "react/jsx-runtime";
const CartUnitQuantityPicker = ({
unit,
value,
onChange,
classNames,
hasCatchWeight
}) => {
const hasUnitWithDecimals = unit && hasCatchWeight || false;
const {
withDecimals,
withoutDecimals
} = classNames;
return /*#__PURE__*/_jsx(UnitQuantityPicker, {
className: !hasUnitWithDecimals ? withDecimals : withoutDecimals,
unit: hasUnitWithDecimals ? unit : null,
maxDecimals: hasUnitWithDecimals ? 2 : 0,
incrementStep: hasUnitWithDecimals ? 0.25 : 1,
decrementStep: hasUnitWithDecimals ? 0.25 : 1,
onChange: onChange,
value: value
});
};
CartUnitQuantityPicker.defaultProps = {
unit: null,
onChange: noop,
classNames: {
withDecimals: big,
withoutDecimals: small
},
hasCatchWeight: false
};
export default CartUnitQuantityPicker;