feat: add scrollbar and fix selection on scroll

This commit is contained in:
Brooklyn Nicholson 2026-04-14 14:34:33 -05:00
parent 9804aa7443
commit 52c11d172a
10 changed files with 397 additions and 126 deletions

View file

@ -1,6 +1,7 @@
import type { ClickEvent } from './click-event.js'
import type { FocusEvent } from './focus-event.js'
import type { KeyboardEvent } from './keyboard-event.js'
import type { MouseEvent } from './mouse-event.js'
import type { PasteEvent } from './paste-event.js'
import type { ResizeEvent } from './resize-event.js'
@ -9,6 +10,7 @@ type FocusEventHandler = (event: FocusEvent) => void
type PasteEventHandler = (event: PasteEvent) => void
type ResizeEventHandler = (event: ResizeEvent) => void
type ClickEventHandler = (event: ClickEvent) => void
type MouseEventHandler = (event: MouseEvent) => void
type HoverEventHandler = () => void
/**
@ -33,6 +35,9 @@ export type EventHandlerProps = {
onResize?: ResizeEventHandler
onClick?: ClickEventHandler
onMouseDown?: MouseEventHandler
onMouseUp?: MouseEventHandler
onMouseDrag?: MouseEventHandler
onMouseEnter?: HoverEventHandler
onMouseLeave?: HoverEventHandler
}
@ -50,7 +55,10 @@ export const HANDLER_FOR_EVENT: Record<
blur: { bubble: 'onBlur', capture: 'onBlurCapture' },
paste: { bubble: 'onPaste', capture: 'onPasteCapture' },
resize: { bubble: 'onResize' },
click: { bubble: 'onClick' }
click: { bubble: 'onClick' },
mousedown: { bubble: 'onMouseDown' },
mouseup: { bubble: 'onMouseUp' },
mousedrag: { bubble: 'onMouseDrag' }
}
/**
@ -68,6 +76,9 @@ export const EVENT_HANDLER_PROPS = new Set<string>([
'onPasteCapture',
'onResize',
'onClick',
'onMouseDown',
'onMouseUp',
'onMouseDrag',
'onMouseEnter',
'onMouseLeave'
])

View file

@ -0,0 +1,18 @@
import { Event } from './event.js'
export class MouseEvent extends Event {
readonly col: number
readonly row: number
localCol = 0
localRow = 0
readonly cellIsBlank: boolean
readonly button: number
constructor(col: number, row: number, cellIsBlank: boolean, button: number) {
super()
this.col = col
this.row = row
this.cellIsBlank = cellIsBlank
this.button = button
}
}