ultra-design
Version:
58 lines (49 loc) • 2.48 kB
JavaScript
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import _pt from 'prop-types';
import 'react';
import { useMergeProps } from '../utils/mergeProps.js';
import withStyle from '../utils/withStyle.js';
import { keyboardStyles } from './keyboard-styles.js';
import { jsxs, jsx } from '@emotion/react/jsx-runtime';
var _excluded = ["command", "shift", "option", "ctrl", "children", "className"];
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
var defaultProps = {};
var KeyboardComponent = function KeyboardComponent(p) {
var props = useMergeProps(defaultProps, p);
var command = props.command,
shift = props.shift,
option = props.option,
ctrl = props.ctrl,
children = props.children,
className = props.className,
rest = _objectWithoutProperties(props, _excluded);
return jsxs("kbd", _objectSpread(_objectSpread({
className: className
}, rest), {}, {
css: keyboardStyles(props),
children: [command && jsx("span", {
children: "\u2318"
}), shift && jsx("span", {
children: "\u21E7"
}), option && jsx("span", {
children: "\u2325"
}), ctrl && jsx("span", {
children: "\u2303"
}), children && jsx("span", {
children: children
})]
}));
};
KeyboardComponent.propTypes = {
command: _pt.bool,
shift: _pt.bool,
option: _pt.bool,
ctrl: _pt.bool,
className: _pt.string
};
KeyboardComponent.displayName = 'UltraKeyboard';
var Keyboard = withStyle(KeyboardComponent);
var Keyboard$1 = Keyboard;
export { Keyboard$1 as default };