import React, { useMemo, forwardRef, memo } from 'react';
import classNames from 'classnames';
import "./index.less";
var Shortcuts = /*#__PURE__*/forwardRef(function (props, ref) {
  var presets = props.presets,
    onChange = props.onChange,
    disabled = props.disabled,
    _props$size = props.size,
    size = _props$size === void 0 ? 'default' : _props$size;
  var handleItemClick = function handleItemClick(item) {
    if (disabled || item.disabled) {
      return;
    }
    if (item.onClick) {
      var _next2 = function _next2() {
        return onChange === null || onChange === void 0 ? void 0 : onChange("".concat(item.value));
      };
      item.onClick(item, _next2);
    } else {
      onChange === null || onChange === void 0 || onChange("".concat(item.value));
    }
  };
  return useMemo(function () {
    if (!(presets !== null && presets !== void 0 && presets.length)) {
      return null;
    }
    return /*#__PURE__*/React.createElement("div", {
      ref: ref,
      className: classNames('pisell-virtual-keyboard-shortcuts', {
        disabled: props.disabled
      })
    }, presets.map(function (item, index) {
      var _item$render;
      var itemProps = {
        key: index,
        className: classNames('pisell-virtual-keyboard-shortcut', {
          disabled: item.disabled,
          large: size === 'large'
        }),
        style: item.style,
        onClick: function onClick() {
          return handleItemClick(item);
        }
      };
      return /*#__PURE__*/React.createElement("div", itemProps, ((_item$render = item.render) === null || _item$render === void 0 ? void 0 : _item$render.call(item, item)) || item.label);
    }));
  }, [presets, onChange, ref]);
});
Shortcuts.displayName = 'Shortcuts';
export default /*#__PURE__*/memo(Shortcuts);