Compare commits

..

No commits in common. "e4657cc69222af14f1c061a1298fd9a3bd12927b" and "a2a1c5be5bf00d3769b0fefc11eac9ee3449ad5b" have entirely different histories.

46 changed files with 139 additions and 228 deletions

View File

@ -170,7 +170,7 @@ const InvoiceInfo = () => {
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={invoiceId}
objectType='invoice'
showEndingDivider={true}

View File

@ -163,7 +163,7 @@ const PaymentInfo = () => {
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={paymentId}
objectType='payment'
showEndingDivider={true}

View File

@ -123,13 +123,11 @@ const TaxRecordInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={taxRecordId}
objectType='taxRecord'
showEndingDivider={true}

View File

@ -127,7 +127,7 @@ const FilamentStockInfo = () => {
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={filamentStockId}
objectType='filamentStock'
showEndingDivider={true}

View File

@ -122,13 +122,11 @@ const OrderItemInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={orderItemId}
objectType='orderItem'
showEndingDivider={true}

View File

@ -137,7 +137,7 @@ const PartStockInfo = () => {
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={partStockId}
objectType='partStock'
showEndingDivider={true}

View File

@ -164,7 +164,7 @@ const ProductStockInfo = () => {
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={productStockId}
objectType='productStock'
showEndingDivider={true}

View File

@ -197,7 +197,7 @@ const PurchaseOrderInfo = () => {
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={purchaseOrderId}
objectType='purchaseOrder'
showEndingDivider={true}

View File

@ -158,13 +158,11 @@ const PurchaseOrderInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={purchaseOrderId}
objectType='purchaseOrder'
showEndingDivider={true}

View File

@ -147,13 +147,11 @@ const ShipmentInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={shipmentId}
objectType='shipment'
showEndingDivider={true}

View File

@ -125,13 +125,11 @@ const StockAuditInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={stockAuditId}
objectType='stockAudit'
showEndingDivider={true}

View File

@ -126,13 +126,11 @@ const StockLocationInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={stockLocationId}
objectType='stockLocation'
showEndingDivider={true}

View File

@ -152,7 +152,7 @@ const StockTransferInfo = () => {
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={stockTransferId}
objectType='stockTransfer'
showEndingDivider={true}

View File

@ -134,7 +134,7 @@ const AppPasswordInfo = () => {
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={appPasswordId}
objectType='appPassword'
showEndingDivider={true}

View File

@ -125,13 +125,11 @@ const CourierServiceInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={courierServiceId}
objectType='courierService'
showEndingDivider={true}

View File

@ -121,13 +121,11 @@ const CourierInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={courierId}
objectType='courier'
showEndingDivider={true}

View File

@ -122,13 +122,11 @@ const DocumentJobInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={documentJobId}
objectType='documentJob'
showEndingDivider={true}

View File

@ -136,7 +136,7 @@ const DocumentPrinterInfo = () => {
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={documentPrinterId}
objectType='documentPrinter'
showEndingDivider={true}

View File

@ -128,7 +128,7 @@ const DocumentSizeInfo = () => {
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={documentSizeId}
objectType='documentSize'
showEndingDivider={true}

View File

@ -133,7 +133,7 @@ const DocumentTemplateInfo = () => {
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={documentTemplateId}
objectType='documentTemplate'
showEndingDivider={true}

View File

@ -120,13 +120,11 @@ const FilamentSkuInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={filamentSkuId}
objectType='filamentSku'
showEndingDivider={true}

View File

@ -141,13 +141,11 @@ const FilamentInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={filamentId}
objectType='filament'
showEndingDivider={true}

View File

@ -142,7 +142,7 @@ const FileInfo = () => {
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={fileId}
objectType='file'
showEndingDivider={true}

View File

@ -137,13 +137,11 @@ const HostInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={hostId}
objectType='host'
showEndingDivider={true}

View File

@ -123,13 +123,11 @@ const MaterialInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={materialId}
objectType='material'
showEndingDivider={true}

View File

@ -111,13 +111,11 @@ const NoteTypeInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={noteTypeId}
objectType='noteType'
showEndingDivider={true}

View File

@ -126,13 +126,11 @@ const NoteInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={noteId}
objectType='note'
showEndingDivider={true}

View File

@ -115,13 +115,11 @@ const PartSkuInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={partSkuId}
objectType='partSku'
showEndingDivider={true}

View File

@ -121,13 +121,11 @@ const PartInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={partId}
objectType='part'
showEndingDivider={true}

View File

@ -120,13 +120,11 @@ const ProductCategoryInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={productCategoryId}
objectType='productCategory'
showEndingDivider={true}

View File

@ -123,13 +123,11 @@ const ProductSkuInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={productSkuId}
objectType='productSku'
showEndingDivider={true}

View File

@ -121,13 +121,11 @@ const ProductInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={productId}
objectType='product'
showEndingDivider={true}

View File

@ -120,13 +120,11 @@ const TaxRateInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={taxRateId}
objectType='taxRate'
showEndingDivider={true}

View File

@ -126,13 +126,11 @@ const UserInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={userId}
objectType='user'
showEndingDivider={true}

View File

@ -120,13 +120,11 @@ const VendorInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={vendorId}
objectType='vendor'
showEndingDivider={true}

View File

@ -129,13 +129,11 @@ const GCodeFileInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={gcodeFileId}
objectType='gcodeFile'
showEndingDivider={true}

View File

@ -147,7 +147,7 @@ const JobInfo = () => {
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={jobId}
objectType='job'
showEndingDivider={true}

View File

@ -137,7 +137,7 @@ const PrinterInfo = () => {
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={printerId}
objectType='printer'
showEndingDivider={true}

View File

@ -117,7 +117,7 @@ const SubJobInfo = () => {
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={subJobId}
objectType='subJob'
showEndingDivider={true}

View File

@ -120,13 +120,11 @@ const ClientInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={clientId}
objectType='client'
showEndingDivider={true}

View File

@ -137,13 +137,11 @@ const ListingVarientInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={listingVarientId}
objectType='listingVarient'
showEndingDivider={true}

View File

@ -142,13 +142,11 @@ const ListingInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={listingId}
objectType='listing'
showEndingDivider={true}

View File

@ -210,13 +210,11 @@ const MarketplaceInfo = () => {
}}
editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid}
disabled={
objectFormState.beingEditedByOther || objectFormState.loading
}
disabled={objectFormState.beingEditedByOther || objectFormState.loading}
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={marketplaceId}
objectType='marketplace'
showEndingDivider={true}

View File

@ -194,7 +194,7 @@ const SalesOrderInfo = () => {
loading={objectFormState.editLoading}
/>
<ObjectTableNavigationButtons
disabled={objectFormState.loading || objectFormState.isEditing}
disabled={objectFormState.loading}
_id={salesOrderId}
objectType='salesOrder'
showEndingDivider={true}

View File

@ -1,76 +1,62 @@
import { useEffect, useRef, cloneElement, useMemo, useState } from 'react'
import { useEffect, useRef, cloneElement, useCallback } from 'react'
import PropTypes from 'prop-types'
import { Popover, Typography } from 'antd'
const MODIFIER_ALIASES = {
cmd: 'meta',
meta: 'meta',
ctrl: 'control',
control: 'control',
alt: 'alt',
option: 'alt',
shift: 'shift'
}
// Utility to parse shortcut string like 'cmd+shift+p' or 'ctrl+s'
function parseShortcut(shortcut) {
return shortcut
.toLowerCase()
.split('+')
.map((part) => MODIFIER_ALIASES[part] ?? part)
}
function getPressedKey(event) {
if (
event.key === 'Meta' ||
event.key === 'Control' ||
event.key === 'Alt' ||
event.key === 'Shift'
) {
return event.key.toLowerCase()
const parts = shortcut.toLowerCase().split('+')
return {
meta: parts.includes('cmd') || parts.includes('meta') || false,
ctrl: parts.includes('ctrl') || parts.includes('control') || false,
alt: parts.includes('alt') || parts.includes('option') || false,
shift: parts.includes('shift') || false,
key: parts.find(
(p) =>
!['cmd', 'meta', 'ctrl', 'control', 'alt', 'option', 'shift'].includes(
p
)
)[0]
}
if (event.code) {
const code = event.code.toLowerCase()
if (code.startsWith('key')) {
return code.slice(3)
}
return code
}
return null
}
const { Text } = Typography
const KeyboardShortcut = ({
shortcut,
children,
hint,
onTrigger,
log = false
}) => {
const KeyboardShortcut = ({ shortcut, children, hint, onTrigger }) => {
const childRef = useRef()
const pressedKeysRef = useRef(new Set())
const shortcutKeys = useMemo(() => parseShortcut(shortcut), [shortcut])
const [pressedKeys, setPressedKeys] = useState([])
const shortcutObj = parseShortcut(shortcut)
// Helper to get the set of keys required for the shortcut
const getShortcutKeySet = useCallback((shortcutObj) => {
const keys = []
if (shortcutObj.meta) keys.push('Meta')
if (shortcutObj.ctrl) keys.push('Control')
if (shortcutObj.alt) keys.push('Alt')
if (shortcutObj.shift) keys.push('Shift')
// shortcutObj.code is like 'keyp', so extract the last char
if (shortcutObj.key) {
keys.push('Key' + shortcutObj.key.toUpperCase())
}
return new Set(keys)
}, [])
const shortcutKeySet = getShortcutKeySet(shortcutObj)
useEffect(() => {
const syncPressedKeys = () => {
setPressedKeys([...pressedKeysRef.current])
}
const pressedKeys = new Set()
const handleKeyDown = (event) => {
const key = getPressedKey(event)
if (key) {
pressedKeysRef.current.add(key)
syncPressedKeys()
}
if (log) {
console.log('Key Down:', key, 'Pressed Keys:', [...pressedKeysRef.current])
}
if (
shortcutKeys.length &&
shortcutKeys.every((k) => pressedKeysRef.current.has(k))
event.key === 'Meta' ||
event.key === 'Control' ||
event.key === 'Alt' ||
event.key === 'Shift'
) {
pressedKeys.add(event.key)
} else if (event.code && event.code.startsWith('Key')) {
pressedKeys.add(event.code)
}
if (
shortcutKeySet.size &&
[...shortcutKeySet].every((k) => pressedKeys.has(k))
) {
if (typeof onTrigger === 'function') {
onTrigger(event)
@ -78,24 +64,27 @@ const KeyboardShortcut = ({
event.preventDefault()
}
}
const handleKeyUp = (event) => {
const key = getPressedKey(event)
if (key) {
pressedKeysRef.current.delete(key)
syncPressedKeys()
if (
event.key === 'Meta' ||
event.key === 'Control' ||
event.key === 'Alt' ||
event.key === 'Shift'
) {
pressedKeys.delete(event.key)
} else if (event.code && event.code.startsWith('Key')) {
pressedKeys.delete(event.key.toUpperCase())
}
}
window.addEventListener('keydown', handleKeyDown)
window.addEventListener('keyup', handleKeyUp)
return () => {
window.removeEventListener('keydown', handleKeyDown)
window.removeEventListener('keyup', handleKeyUp)
}
}, [shortcutKeys, onTrigger, log])
}, [shortcut, shortcutObj, onTrigger, shortcutKeySet])
// Clone the child to attach a ref
const element = cloneElement(children, { ref: childRef })
if (hint) {
@ -119,8 +108,7 @@ KeyboardShortcut.propTypes = {
shortcut: PropTypes.string.isRequired, // e.g. 'cmd+shift+p'
onTrigger: PropTypes.func.isRequired,
children: PropTypes.element.isRequired,
hint: PropTypes.string, // Optional, e.g. ' P'
log: PropTypes.bool // Optional, e.g. true
hint: PropTypes.string // Optional, e.g. ' P'
}
export default KeyboardShortcut

View File

@ -7,7 +7,6 @@ import PropTypes from 'prop-types'
import { ApiServerContext } from '../context/ApiServerContext'
import { AuthContext } from '../context/AuthContext'
import { useTableStatePersistence } from '../context/TableStateContext'
import KeyboardShortcut from './KeyboardShortcut.jsx'
const ObjectTableNavigationButtons = ({
disabled,
@ -96,36 +95,16 @@ const ObjectTableNavigationButtons = ({
<Divider type='vertical' style={{ margin: '0 4px', height: '18px' }} />
)}
<Space size='small'>
<KeyboardShortcut
shortcut='alt+arrowleft'
hint='ALT LEFT'
onTrigger={useCallback(() => {
if (!disabled && !loading && neighbors.previous?._id) {
handlePrevious()
}
}, [disabled, loading, neighbors.previous?._id])}
>
<Button
icon={<ArrowLeftIcon />}
onClick={handlePrevious}
disabled={disabled || loading || !neighbors.previous?._id}
/>
</KeyboardShortcut>
<KeyboardShortcut
shortcut='alt+arrowright'
hint='ALT RIGHT'
onTrigger={useCallback(() => {
if (!disabled && !loading && neighbors.next?._id) {
handleNext()
}
}, [disabled, loading, neighbors.next?._id])}
>
<Button
icon={<ArrowRightIcon />}
onClick={handleNext}
disabled={disabled || loading || !neighbors.next?._id}
/>
</KeyboardShortcut>
<Button
icon={<ArrowLeftIcon />}
onClick={handlePrevious}
disabled={disabled || loading || !neighbors.previous?._id}
/>
<Button
icon={<ArrowRightIcon />}
onClick={handleNext}
disabled={disabled || loading || !neighbors.next?._id}
/>
</Space>
</Flex>
)