Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentWillReceiveProps(nextProps) {
const hasMonthChanged = !isSameMonth(this.props.month, nextProps.month);
if (hasMonthChanged) {
const reverse = isRTL();
if (differenceInCalendarMonths(nextProps.month, this.props.month) === 1) {
// Transition to next month
this.setState({
transitionValue: reverse
? transitionValues.previous
: transitionValues.next,
isTransitioning: true,
});
return;
}
if (
differenceInCalendarMonths(nextProps.month, this.props.month) === -1
) {
// Transition to previous month
const lastIndex = (views || []).length - 1;
return (
<div>
{Children.map(views, (view, idx) => (
</div>
const applyMarginRTLTransform = obj => {
if (!isRTL()) {
return obj;
}
const { left, right, ...rest } = obj;
return {
left: right,
right: left,
...rest,
};
};
const computeScrollIndicatorClassName = (
scrollerEl: ?HTMLElement,
leadingIndicatorClassName: ?string = null,
trailingIndicatorClassName: ?string = null,
) => {
if (!scrollerEl) {
return null;
}
const classNames = [];
const { scrollLeft, scrollWidth, offsetWidth } = scrollerEl;
const rtl = isRTL();
const scrollValue = rtl ? -scrollLeft : scrollLeft;
const showLeadingIndicator = scrollValue > 0;
const showTrailingIndicator = scrollValue < scrollWidth - offsetWidth;
const showLeftIndicator = rtl ? showTrailingIndicator : showLeadingIndicator;
const showRightIndicator = rtl ? showLeadingIndicator : showTrailingIndicator;
if (showLeftIndicator) {
classNames.push(
getClassName('bpk-mobile-scroll-container--left-indicator'),
);
}
if (showRightIndicator) {
classNames.push(
getClassName('bpk-mobile-scroll-container--right-indicator'),
);
}
const BpkSlider = props => {
const { large, className, ...rest } = props;
const invert = isRTL();
const classNames = [getClassName('bpk-slider')];
const thumbClassNames = [getClassName('bpk-slider__handle')];
const trackClassNames = [getClassName('bpk-slider__bar')];
const isRange = (rest.value || rest.defaultValue || []).length > 1;
if (isRange) {
classNames.push(getClassName('bpk-slider--range'));
}
if (className) {
classNames.push(getClassName(className));
}
if (large) {
classNames.push(getClassName('bpk-slider--large'));
thumbClassNames.push(getClassName('bpk-slider__handle--large'));
}