How to use the rc-util/lib/KeyCode.ENTER 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 / 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 / src / RangeCalendar.tsx View on Github external
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];
        }
        if (lastValue && (!disabledDate || !disabledDate(lastValue))) {
          this.onSelect(lastValue);
        }
        event.preventDefault();
        return;
github react-component / calendar / tests / Picker.spec.jsx View on Github external
it('not close on enter if disabled date', () => {
      const picker = renderPicker({ value: moment() }, { disabledDate: () => true });
      picker.find('.rc-calendar-picker-input').simulate('click');
      picker.find('.rc-calendar-input').simulate('keyDown', {
        keyCode: keyCode.ENTER,
      });
      expect(picker.state().open).toBe(true);
    });
  });
github react-component / select / tests / Select.tags.spec.tsx View on Github external
it('allow user input tags', () =&gt; {
    const wrapper = mount<select>(</select>);

    wrapper
      .find('input')
      .simulate('change', { target: { value: 'foo' } })
      .simulate('keyDown', { keyCode: KeyCode.ENTER });

    expect(wrapper.state().value).toEqual(['foo']);
    expect(
      wrapper
        .update()
        .find('.rc-select-selection__choice__content')
        .text(),
    ).toBe('foo');
  });
github react-component / calendar / tests / RangeCalendar.spec.jsx View on Github external
wrapper
      .find('input')
      .at(0)
      .simulate('change', {
        target: {
          value: '1/1/2000',
        },
      });

    expect(onSelect.mock.calls[0][1].source).toEqual('dateInput');

    wrapper
      .find('input')
      .at(0)
      .simulate('keyDown', {
        keyCode: keyCode.ENTER,
      });
    expect(onSelect.mock.calls[1][1].source).toEqual('dateInputSelect');
  });
github react-component / menu / src / MenuItem.jsx View on Github external
onKeyDown = (e) => {
    const keyCode = e.keyCode;
    if (keyCode === KeyCode.ENTER) {
      this.onClick(e);
      return true;
    }
  };
github react-component / calendar / src / date / DateInput.tsx View on Github external
onKeyDown = event => {
    const { keyCode } = event;
    const { onSelect, value, disabledDate } = this.props;
    if (keyCode === KeyCode.ENTER && onSelect) {
      const validateDate = !disabledDate || !disabledDate(value);
      if (validateDate) {
        onSelect(value.clone());
      }
      event.preventDefault();
    }
  };
github iuap-design / bee.tinper.org / tinper-bee / bee-datepicker / src / rc-calendar / RangeCalendar.js View on Github external
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))) {
          this.onSelect(lastValue);
        }
        event.preventDefault();
        return;
      }
      default:
github pingcap / tidb-dashboard / ui / lib / components / BaseSelect / index.tsx View on Github external
(ev: React.KeyboardEvent) =&gt; {
      if (ev.which === KeyCode.ENTER) {
        toggleDropdownVisible()
      } else if (ev.which === KeyCode.ESC) {
        setDropdownVisible(false)
      }
      onKeyDown &amp;&amp; onKeyDown(ev)
    },
    [toggleDropdownVisible, onKeyDown]
github iuap-design / bee.tinper.org / tinper-bee / bee-datepicker / src / rc-calendar / Calendar.jsx View on Github external
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;
    }
  }