Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
keySimulateCheck(keyCode.RIGHT, 'Sep', 10);
// 09-10 right 09-03
keySimulateCheck(keyCode.UP, 'Sep', 3);
// 09-10 home 09-01
keySimulateCheck(keyCode.HOME, 'Sep', 1);
// 09-10 end 09-30
keySimulateCheck(keyCode.END, 'Sep', 30);
// 09-30 page up 08-30
keySimulateCheck(keyCode.PAGE_UP, 'Aug', 30);
// 08-30 page down 09-30
keySimulateCheck(keyCode.PAGE_DOWN, 'Sep', 30);
keyDown(keyCode.BACKSLASH);
expect(keyDownEvent).toEqual(1);
keyDown(keyCode.ENTER);
expect(onChange.mock.calls[0][0][0].format(format)).toEqual('2000-09-30');
// 2000-09-30 ctrl+right 2001-09-30
keySimulateCheck(keyCode.RIGHT, 'Sep', 30, {
ctrlKey: true,
});
expect(wrapper.find('.rc-calendar-range-right .rc-calendar-year-select').text()).toEqual(
'2001',
);
}
return;
case KeyCode.RIGHT:
if (ctrlKey) {
updateHoverPoint(time => goTime(time, 1, 'years'));
} else {
updateHoverPoint(time => goTime(time, 1, 'days'));
}
return;
case KeyCode.HOME:
updateHoverPoint(time => goStartMonth(time));
return;
case KeyCode.END:
updateHoverPoint(time => goEndMonth(time));
return;
case KeyCode.PAGE_DOWN:
updateHoverPoint(time => goTime(time, 1, 'month'));
return;
case KeyCode.PAGE_UP:
updateHoverPoint(time => goTime(time, -1, 'month'));
return;
case KeyCode.ENTER: {
let lastValue: Moment;
if (hoverValue.length === 0) {
lastValue = updateHoverPoint(time => time);
} else if (hoverValue.length === 1) {
// eslint-disable-next-line prefer-destructuring
lastValue = hoverValue[0];
} else {
lastValue = hoverValue[0].isSame(firstSelectedValue, 'day')
? hoverValue[1]
: hoverValue[0];
it('pageDown works', () => {
const original = calendar.state().value;
const expected = original.clone();
expected.add(1, 'month');
calendar.simulate('keyDown', { keyCode: keyCode.PAGE_DOWN });
expect(calendar.state().value.month()).toBe(expected.month());
expect(input.getDOMNode().value).toBe('');
});
}
event.preventDefault();
return 1;
case KeyCode.HOME:
this.setValue(
goStartMonth(this.state.value),
);
event.preventDefault();
return 1;
case KeyCode.END:
this.setValue(
goEndMonth(this.state.value),
);
event.preventDefault();
return 1;
case KeyCode.PAGE_DOWN:
this.goTime(1, 'month');
event.preventDefault();
return 1;
case KeyCode.PAGE_UP:
this.goTime(-1, 'month');
event.preventDefault();
return 1;
case KeyCode.ENTER:
if (!disabledDate || !disabledDate(value)) {
this.onSelect(value, {
source: 'keyboard',
});
}
event.preventDefault();
return 1;
}
const decrease = 'decrease';
let method = increase;
switch (e.keyCode) {
case keyCode.UP:
method = vertical && reverse ? decrease: increase; break;
case keyCode.RIGHT:
method = !vertical && reverse ? decrease: increase; break;
case keyCode.DOWN:
method = vertical && reverse ? increase: decrease; break;
case keyCode.LEFT:
method = !vertical && reverse ? increase: decrease; break;
case keyCode.END: return (value, props) => props.max;
case keyCode.HOME: return (value, props) => props.min;
case keyCode.PAGE_UP: return (value, props) => value + props.step * 2;
case keyCode.PAGE_DOWN: return (value, props) => value - props.step * 2;
default: return undefined;
}
return (value, props) => calculateNextValue(method, value, props);
}
break
case keys.UP:
direction = -1
break
case keys.DOWN:
direction = 1
break
case keys.PAGE_UP:
direction = -1
distance = containerSize
break
case keys.PAGE_DOWN:
direction = 1
distance = containerSize
break
default:
return
}
}
e.preventDefault()
this.triggerCallback(this.props.scrollPosition + distance! * direction)
}
}
return;
case KeyCode.RIGHT:
if (ctrlKey) {
updateHoverPoint((time) => goTime(time, 1, 'years'));
} else {
updateHoverPoint((time) => goTime(time, 1, 'days'));
}
return;
case KeyCode.HOME:
updateHoverPoint((time) => goStartMonth(time));
return;
case KeyCode.END:
updateHoverPoint((time) => goEndMonth(time));
return;
case KeyCode.PAGE_DOWN:
updateHoverPoint((time) => goTime(time, 1, 'month'));
return;
case KeyCode.PAGE_UP:
updateHoverPoint((time) => goTime(time, -1, 'month'));
return;
case KeyCode.ENTER: {
let lastValue;
if (hoverValue.length === 0) {
lastValue = updateHoverPoint(time => time);
} else if (hoverValue.length === 1) {
lastValue = hoverValue[0];
} else {
lastValue = hoverValue[0].isSame(firstSelectedValue, 'day') ?
hoverValue[1] : hoverValue[0];
}
if (lastValue && (!disabledDate || !disabledDate(lastValue))) {
switch (e.keyCode) {
case keyCode.UP:
case keyCode.RIGHT:
return (value, props) => calculateNextValue('increase', value, props)
case keyCode.DOWN:
case keyCode.LEFT:
return (value, props) => calculateNextValue('decrease', value, props)
case keyCode.END:
return (value, props) => props.max
case keyCode.HOME:
return (value, props) => props.min
case keyCode.PAGE_UP:
return (value, props) => value + props.step * 2
case keyCode.PAGE_DOWN:
return (value, props) => value - props.step * 2
default:
return undefined
}
}
}
event.preventDefault();
return 1;
case KeyCode.HOME:
this.setValue(
goStartMonth(this.state.value),
);
event.preventDefault();
return 1;
case KeyCode.END:
this.setValue(
goEndMonth(this.state.value),
);
event.preventDefault();
return 1;
case KeyCode.PAGE_DOWN:
this.goTime(1, 'month');
event.preventDefault();
return 1;
case KeyCode.PAGE_UP:
this.goTime(-1, 'month');
event.preventDefault();
return 1;
case KeyCode.ENTER:
if (!disabledDate || !disabledDate(value)) {
this.onSelect(value, {
source: 'keyboard',
});
}
event.preventDefault();
return 1;
default: