import React, { forwardRef, memo, useMemo } from "react";
import classNames from "classnames";
import "./index.less";
//#region src/pro/priceKeyboard/components/shortcuts/index.tsx
const Shortcuts = forwardRef((props, ref) => {
	const { presets, onChange, disabled, size = "default" } = props;
	const handleItemClick = (item) => {
		if (disabled || item.disabled) return;
		if (item.onClick) {
			const _next = () => onChange === null || onChange === void 0 ? void 0 : onChange(`${item.value}`);
			item.onClick(item, _next);
		} else onChange === null || onChange === void 0 || onChange(`${item.value}`);
	};
	return useMemo(() => {
		if (!(presets === null || presets === void 0 ? void 0 : presets.length)) return null;
		return /* @__PURE__ */ React.createElement("div", {
			ref,
			className: classNames("pisell-virtual-keyboard-shortcuts", { disabled: props.disabled })
		}, presets.map((item, index) => {
			var _item$render;
			const itemProps = {
				key: index,
				className: classNames("pisell-virtual-keyboard-shortcut", {
					disabled: item.disabled,
					large: size === "large"
				}),
				style: item.style,
				onClick: () => 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";
var shortcuts_default = memo(Shortcuts);
//#endregion
export { shortcuts_default as default };
