///////////////////////////////////////////////////////////// // // pgAdmin 4 - PostgreSQL Tools // // Copyright (C) 2013 - 2022, The pgAdmin Development Team // This software is released under the PostgreSQL Licence // ////////////////////////////////////////////////////////////// import _ from 'lodash'; import { makeStyles, Grid, Typography, Box } from '@material-ui/core'; import React from 'react'; import { InputCheckbox, InputText } from './FormComponents'; import PropTypes from 'prop-types'; const useStyles = makeStyles((theme) => ({ inputLabel: { textAlign: 'center', padding: 2, paddingLeft: 10 }, inputCheckboxClass: { border: '1px solid', borderRadius: theme.shape.borderRadius, borderColor: theme.otherVars.inputBorderColor, padding: 3 } })); export default function KeyboardShortcuts({ value, onChange, fields }) { const classes = useStyles(); const keyCid = _.uniqueId('c'); const keyhelpid = `h${keyCid}`; const shiftCid = _.uniqueId('c'); const shifthelpid = `h${shiftCid}`; const ctrlCid = _.uniqueId('c'); const ctrlhelpid = `h${ctrlCid}`; const altCid = _.uniqueId('c'); const althelpid = `h${altCid}`; const keyLabel = _.uniqueId('c'); const onKeyDown = (e) => { let newVal = { ...value }; let _val = e.key; if (e.keyCode == 32) { _val = 'Space'; } newVal.key = { char: _val, key_code: e.keyCode }; onChange(newVal); }; const onShiftChange = (e) => { let newVal = { ...value }; newVal.shift = e.target.checked; onChange(newVal); }; const onCtrlChange = (e) => { let newVal = { ...value }; newVal.control = e.target.checked; onChange(newVal); }; const onAltChange = (e) => { let newVal = { ...value }; newVal.alt = e.target.checked; onChange(newVal); }; return ( {fields.map(element => { let ctrlProps = { label: element.label }; if (element.type == 'keyCode') { return {element.label} ; } else if (element.name == 'shift') { return ; } else if (element.name == 'control') { return ; } else if (element.name == 'alt') { return ; } })} ); } KeyboardShortcuts.propTypes = { value: PropTypes.object, onChange: PropTypes.func, controlProps: PropTypes.object, fields: PropTypes.array };