@lightningjs/solid-primitives
Advanced tools
Comparing version 0.5.3 to 0.5.4
@@ -14,3 +14,3 @@ import { type Accessor } from 'solid-js'; | ||
export type KeyHandlerReturn = boolean | void; | ||
export type KeyHandler = (this: ElementNode, e: KeyboardEvent, target: ElementNode) => KeyHandlerReturn; | ||
export type KeyHandler = (this: ElementNode, e: KeyboardEvent, target: ElementNode, handlerElm: ElementNode) => KeyHandlerReturn; | ||
/** | ||
@@ -30,3 +30,3 @@ * Generates a map of event handlers for each key in the KeyMap | ||
onBlur?: (currentFocusedElm: ElementNode | undefined, prevFocusedElm: ElementNode | undefined) => void; | ||
onKeyPress?: (this: ElementNode, e: KeyboardEvent, mappedKeyEvent: string | undefined, currentFocusedElm: ElementNode) => KeyHandlerReturn; | ||
onKeyPress?: (this: ElementNode, e: KeyboardEvent, mappedKeyEvent: string | undefined, handlerElm: ElementNode, currentFocusedElm: ElementNode) => KeyHandlerReturn; | ||
onSelectedChanged?: (container: ElementNode, activeElm: ElementNode, selectedIndex: number | undefined, lastSelectedIndex: number | undefined) => void; | ||
@@ -33,0 +33,0 @@ skipFocus?: boolean; |
@@ -88,7 +88,9 @@ /* | ||
const fp = focusPath(); | ||
let finalFocusElm = undefined; | ||
for (const elm of fp) { | ||
finalFocusElm = finalFocusElm || elm; | ||
if (mappedKeyEvent) { | ||
const onKeyHandler = elm[`on${mappedKeyEvent}`]; | ||
if (isFunc(onKeyHandler)) { | ||
if (onKeyHandler.call(elm, e, elm) === true) { | ||
if (onKeyHandler.call(elm, e, elm, finalFocusElm) === true) { | ||
break; | ||
@@ -102,3 +104,3 @@ } | ||
if (isFunc(elm.onKeyPress)) { | ||
if (elm.onKeyPress.call(elm, e, mappedKeyEvent, elm) === true) { | ||
if (elm.onKeyPress.call(elm, e, mappedKeyEvent, elm, finalFocusElm) === true) { | ||
break; | ||
@@ -105,0 +107,0 @@ } |
{ | ||
"name": "@lightningjs/solid-primitives", | ||
"version": "0.5.3", | ||
"version": "0.5.4", | ||
"description": "Lightning Primitives for Solid Lightning", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -46,2 +46,3 @@ /* | ||
target: ElementNode, | ||
handlerElm: ElementNode, | ||
) => KeyHandlerReturn; | ||
@@ -74,2 +75,3 @@ | ||
mappedKeyEvent: string | undefined, | ||
handlerElm: ElementNode, | ||
currentFocusedElm: ElementNode, | ||
@@ -186,3 +188,5 @@ ) => KeyHandlerReturn; | ||
const fp = focusPath(); | ||
let finalFocusElm: ElementNode | undefined = undefined; | ||
for (const elm of fp) { | ||
finalFocusElm = finalFocusElm || elm; | ||
if (mappedKeyEvent) { | ||
@@ -192,3 +196,3 @@ const onKeyHandler = | ||
if (isFunc(onKeyHandler)) { | ||
if (onKeyHandler.call(elm, e, elm) === true) { | ||
if (onKeyHandler.call(elm, e, elm, finalFocusElm) === true) { | ||
break; | ||
@@ -202,3 +206,11 @@ } | ||
if (isFunc(elm.onKeyPress)) { | ||
if (elm.onKeyPress.call(elm, e, mappedKeyEvent, elm) === true) { | ||
if ( | ||
elm.onKeyPress.call( | ||
elm, | ||
e, | ||
mappedKeyEvent, | ||
elm, | ||
finalFocusElm, | ||
) === true | ||
) { | ||
break; | ||
@@ -205,0 +217,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
432054
6650