How to use the rc-util/lib/KeyCode.RIGHT function in rc-util

To help you get started, we’ve selected a few rc-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github react-component / calendar / tests / RangeCalendar.spec.jsx View on Github external
// 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',
    );

    // 2001-09-30 ctrl+right 2000-09-30
    keySimulateCheck(keyCode.LEFT, 'Sep', 30, {
      ctrlKey: true,
    });

    keyDown(keyCode.ENTER);
    expect(onChange.mock.calls[1][0][0].format(format)).toEqual('2000-09-30');
    expect(onChange.mock.calls[1][0][1].format(format)).toEqual('2000-09-30');

    expect(onSelect.mock.calls[0][0][0].format(format)).toEqual('2000-09-30');
github react-component / calendar / tests / Calendar.spec.jsx View on Github external
it('right works', () => {
        const original = calendar.state().value;
        const expected = original.clone();
        expected.add(1, 'day');
        calendar.simulate('keyDown', { keyCode: keyCode.RIGHT });
        expect(calendar.state().value.date()).toBe(expected.date());
        expect(input.getDOMNode().value).toBe('');
      });
github react-component / cascader / tests / keyboard.spec.js View on Github external
it('should have keyboard support', () => {
    wrapper.find('input').simulate('keyDown', { keyCode: KeyCode.DOWN });
    menus = wrapper.find('.rc-cascader-menu');
    expect(wrapper.find('.rc-cascader-menus-hidden').length).toBe(0);
    expect(menus.length).toBe(1);
    wrapper.find('input').simulate('keyDown', { keyCode: KeyCode.DOWN });
    menus = wrapper.find('.rc-cascader-menu');
    expect(menus.length).toBe(2);
    wrapper.find('input').simulate('keyDown', { keyCode: KeyCode.RIGHT });
    menus = wrapper.find('.rc-cascader-menu');
    expect(menus.length).toBe(3);
    wrapper.find('input').simulate('keyDown', { keyCode: KeyCode.RIGHT });
    menus = wrapper.find('.rc-cascader-menu');
    expect(menus.length).toBe(3);
    wrapper.find('input').simulate('keyDown', { keyCode: KeyCode.LEFT });
    menus = wrapper.find('.rc-cascader-menu');
    expect(menus.length).toBe(3);
    wrapper.find('input').simulate('keyDown', { keyCode: KeyCode.QUESTION_MARK });
    menus = wrapper.find('.rc-cascader-menu');
    expect(menus.length).toBe(3);
    wrapper.find('input').simulate('keyDown', { keyCode: KeyCode.LEFT });
    menus = wrapper.find('.rc-cascader-menu');
    expect(menus.length).toBe(2);
    expect(
      wrapper
github react-component / cascader / tests / keyboard.spec.js View on Github external
).toBe(false);
    wrapper.find('input').simulate('keyDown', { keyCode: KeyCode.BACKSPACE });
    expect(
      wrapper
        .find('.rc-cascader-menus')
        .hostNodes()
        .hasClass('rc-cascader-menus-hidden'),
    ).toBe(true);
    wrapper.find('input').simulate('keyDown', { keyCode: KeyCode.DOWN });
    expect(
      wrapper
        .find('.rc-cascader-menus')
        .hostNodes()
        .hasClass('rc-cascader-menus-hidden'),
    ).toBe(false);
    wrapper.find('input').simulate('keyDown', { keyCode: KeyCode.RIGHT });
    wrapper.find('input').simulate('keyDown', { keyCode: KeyCode.ESC });
    expect(
      wrapper
        .find('.rc-cascader-menus')
        .hostNodes()
        .hasClass('rc-cascader-menus-hidden'),
    ).toBe(true);
  });
github react-component / calendar / src / MonthCalendar.tsx View on Github external
value = stateValue.clone();
        value.add(3, 'months');
        break;
      case KeyCode.UP:
        value = stateValue.clone();
        value.add(-3, 'months');
        break;
      case KeyCode.LEFT:
        value = stateValue.clone();
        if (ctrlKey) {
          value.add(-1, 'years');
        } else {
          value.add(-1, 'months');
        }
        break;
      case KeyCode.RIGHT:
        value = stateValue.clone();
        if (ctrlKey) {
          value.add(1, 'years');
        } else {
          value.add(1, 'months');
        }
        break;
      case KeyCode.ENTER:
        if (!disabledDate || !disabledDate(stateValue)) {
          this.onSelect(stateValue);
        }
        event.preventDefault();
        return 1;
      default:
        return undefined;
    }
github iuap-design / bee.tinper.org / tinper-bee / bee-datepicker / src / rc-calendar / MonthCalendar.jsx View on Github external
value = stateValue.clone();
        value.add(3, 'months');
        break;
      case KeyCode.UP:
        value = stateValue.clone();
        value.add(-3, 'months');
        break;
      case KeyCode.LEFT:
        value = stateValue.clone();
        if (ctrlKey) {
          value.add(-1, 'years');
        } else {
          value.add(-1, 'months');
        }
        break;
      case KeyCode.RIGHT:
        value = stateValue.clone();
        if (ctrlKey) {
          value.add(1, 'years');
        } else {
          value.add(1, 'months');
        }
        break;
      case KeyCode.ENTER:
        if (!disabledDate || !disabledDate(stateValue)) {
          this.onSelect(stateValue);
        }
        event.preventDefault();
        return 1;
      default:
        return undefined;
    }
github react-component / calendar / src / Calendar.jsx View on Github external
this.goTime(1, 'weeks');
        event.preventDefault();
        return 1;
      case KeyCode.UP:
        this.goTime(-1, 'weeks');
        event.preventDefault();
        return 1;
      case KeyCode.LEFT:
        if (ctrlKey) {
          this.goTime(-1, 'years');
        } else {
          this.goTime(-1, 'days');
        }
        event.preventDefault();
        return 1;
      case KeyCode.RIGHT:
        if (ctrlKey) {
          this.goTime(1, 'years');
        } else {
          this.goTime(1, 'days');
        }
        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),
github react-component / cascader / src / Cascader.tsx View on Github external
if (nextIndex !== -1) {
        if (e.keyCode === KeyCode.DOWN) {
          nextIndex += 1;
          nextIndex = nextIndex >= currentOptions.length ? 0 : nextIndex;
        } else {
          nextIndex -= 1;
          nextIndex = nextIndex < 0 ? currentOptions.length - 1 : nextIndex;
        }
      } else {
        nextIndex = 0;
      }
      activeValue[currentLevel] = currentOptions[nextIndex][this.getFieldName('value')];
    } else if (e.keyCode === KeyCode.LEFT || e.keyCode === KeyCode.BACKSPACE) {
      e.preventDefault();
      activeValue.splice(activeValue.length - 1, 1);
    } else if (e.keyCode === KeyCode.RIGHT) {
      e.preventDefault();
      if (
        currentOptions[currentIndex] &&
        currentOptions[currentIndex][this.getFieldName('children')]
      ) {
        activeValue.push(
          currentOptions[currentIndex][this.getFieldName('children')][0][
            this.getFieldName('value')
          ],
        );
      }
    } else if (e.keyCode === KeyCode.ESC || e.keyCode === KeyCode.TAB) {
      this.setPopupVisible(false);
      return;
    }
    if (!activeValue || activeValue.length === 0) {
github priceline / design-system / packages / slider / src / rc-slider / utils.js View on Github external
export function getKeyboardValueMutator(e) {
  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: