How to use rc-util - 10 common examples

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 / select / tests / Select.tags.spec.tsx View on Github external
it('filterOption is false', () => {
    const wrapper = mount<select>(
      </select>
        <option value="1">1</option>
        <option value="2">2</option>
      ,
    );
    // @HACK
    const input = wrapper.find('input') as any;
    input.instance().focus = jest.fn();
    input
      .simulate('change', { target: { value: 'a' } })
      .simulate('keyDown', { keyCode: KeyCode.ENTER });

    expect(wrapper.state().value).toEqual(['a']);
    expect(wrapper.find('.rc-select-selection__choice__content').text()).toBe('a');
  });
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 / RangeCalendar.spec.jsx View on Github external
};

    // 09-03 down 09-10
    keySimulateCheck(keyCode.DOWN, 'Sep', 10);

    // 09-03 left 09-09
    keySimulateCheck(keyCode.LEFT, 'Sep', 9);

    // 09-09 right 09-10
    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');
github react-component / calendar / tests / RangeCalendar.spec.jsx View on Github external
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',
    );
github react-component / calendar / tests / RangeCalendar.spec.jsx View on Github external
keySimulateCheck(keyCode.LEFT, 'Sep', 9);

    // 09-09 right 09-10
    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(
github react-component / input-number / tests / index.spec.js View on Github external
/* eslint-disable react/no-multi-comp */
const keyCode = require('rc-util').KeyCode;
const expect = require('expect.js');
const InputNum = require('../index');
const React = require('react');
const TestUtils = require('react-addons-test-utils');
const ReactDOM = require('react-dom');
const Simulate = TestUtils.Simulate;
require('../assets/index.less');

const defaultValue = 98;

describe('inputNumber', () => {
  const container = document.createElement('div');
  document.body.appendChild(container);

  const Component = React.createClass({
    getInitialState() {
github react-component / calendar / tests / RangeCalendar.spec.jsx View on Github external
keySimulateCheck(keyCode.DOWN, 'Sep', 10);

    // 09-03 left 09-09
    keySimulateCheck(keyCode.LEFT, 'Sep', 9);

    // 09-09 right 09-10
    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, {
github react-component / slider / src / common / createSlider.jsx View on Github external
addDocumentTouchEvents() {
      // just work for Chrome iOS Safari and Android Browser
      this.onTouchMoveListener = addEventListener(this.document, 'touchmove', this.onTouchMove);
      this.onTouchUpListener = addEventListener(this.document, 'touchend', this.onEnd);
    }
github react-component / trigger / src / index.tsx View on Github external
componentDidUpdate() {
      const { props } = this;
      const { state } = this;

      // We must listen to `mousedown` or `touchstart`, edge case:
      // https://github.com/ant-design/ant-design/issues/5804
      // https://github.com/react-component/calendar/issues/250
      // https://github.com/react-component/trigger/issues/50
      if (state.popupVisible) {
        let currentDocument;
        if (!this.clickOutsideHandler && (this.isClickToHide() || this.isContextMenuToShow())) {
          currentDocument = props.getDocument();
          this.clickOutsideHandler = addEventListener(
            currentDocument,
            'mousedown',
            this.onDocumentClick,
          );
        }
        // always hide on mobile
        if (!this.touchOutsideHandler) {
          currentDocument = currentDocument || props.getDocument();
          this.touchOutsideHandler = addEventListener(
            currentDocument,
            'touchstart',
            this.onDocumentClick,
          );
        }
        // close popup when trigger type contains 'onContextMenu' and document is scrolling.
        if (!this.contextMenuOutsideHandler1 && this.isContextMenuToShow()) {
github react-component / color-picker / src / Board.jsx View on Github external
onBoardMouseDown = e => {
    const buttons = e.buttons;

    // only work on left click
    // @see https://developer.mozilla.org/en-US/docs/Web/Events/mousedown
    if (buttons !== 1) return;

    const x = e.clientX;
    const y = e.clientY;
    this.pointMoveTo({
      x,
      y,
    });
    this.removeListeners();
    this.dragListener = addEventListener(window, 'mousemove', this.onBoardDrag);
    this.dragUpListener = addEventListener(window, 'mouseup', this.onBoardDragEnd);
  };