@lightningjs/solid-primitives
Advanced tools
Comparing version 0.4.3 to 0.4.4
@@ -33,4 +33,5 @@ import type { ElementNode } from '@lightningjs/solid'; | ||
onFocusChange?: DebounceWithFlushFunction<ElementNode[]>; | ||
refresh: (depth?: number) => void; | ||
} | ||
export declare const Announcer: Announcer; | ||
export {}; |
@@ -17,4 +17,6 @@ /* | ||
*/ | ||
import { untrack } from 'solid-js'; | ||
import SpeechEngine, {} from './speech.js'; | ||
import { debounce } from '@solid-primitives/scheduled'; | ||
import { focusPath } from '../useFocusManager.js'; | ||
let resetFocusPathTimer; | ||
@@ -39,3 +41,2 @@ let prevFocusPath = []; | ||
} | ||
; | ||
function getElmName(elm) { | ||
@@ -115,7 +116,8 @@ return elm.id || elm.name; | ||
voiceOutDisabled = true; | ||
currentlySpeaking?.series.finally(() => { | ||
currentlySpeaking?.series | ||
.finally(() => { | ||
voiceOutDisabled = false; | ||
// TODO: Implement refresh | ||
// Announcer.refresh(); | ||
}).catch(console.error); | ||
Announcer.refresh(); | ||
}) | ||
.catch(console.error); | ||
} | ||
@@ -125,2 +127,7 @@ } | ||
}, | ||
refresh: function (depth = 0) { | ||
Announcer.clearPrevFocus(depth); | ||
Announcer.onFocusChange && | ||
Announcer.onFocusChange(untrack(() => focusPath())); | ||
}, | ||
setupTimers: function ({ focusDebounce = 400, focusChangeTimeout = fiveMinutes, } = {}) { | ||
@@ -127,0 +134,0 @@ Announcer.onFocusChange = debounceWithFlush(onFocusChangeCore, focusDebounce); |
@@ -22,2 +22,7 @@ /* | ||
const down = handleNavigation('down'); | ||
const defaultStyle = { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
justifyContent: 'flexStart', | ||
}; | ||
return <node onUp={up} onDown={down} onFocus={props.onFocus || (elm => { | ||
@@ -30,4 +35,4 @@ if (!elm || !elm.selected) | ||
child.setFocus(); | ||
})} selected={0} {...props}>{props.children}</node>; | ||
})} selected={props.selected || 0} style={props.style || defaultStyle} {...props}>{props.children}</node>; | ||
} | ||
//# sourceMappingURL=Column.jsx.map |
@@ -22,3 +22,7 @@ /* | ||
const right = handleNavigation('right'); | ||
return <node onLeft={left} onRight={right} selected={0} onFocus={props.onFocus || (elm => { | ||
const defaultStyle = { | ||
display: 'flex', | ||
justifyContent: 'flexStart', | ||
}; | ||
return <node onLeft={left} onRight={right} selected={props.selected || 0} onFocus={props.onFocus || (elm => { | ||
if (!elm || !elm.selected) | ||
@@ -30,4 +34,4 @@ return; | ||
child.setFocus(); | ||
})} {...props}>{props.children}</node>; | ||
})} style={props.style || defaultStyle} {...props}>{props.children}</node>; | ||
} | ||
//# sourceMappingURL=Row.jsx.map |
@@ -54,10 +54,9 @@ /* | ||
} | ||
el.height = | ||
el.children.reduce((acc, c) => { | ||
c.y = (c.y || 0) + top; | ||
c.marginTop = top; | ||
return acc + (c.height || 0); | ||
}, 0) + | ||
top + | ||
bottom; | ||
let maxHeight = 0; | ||
el.children.forEach((c) => { | ||
c.y = (c.y || 0) + top; | ||
c.marginTop = top; | ||
maxHeight = Math.max(maxHeight, c.height || 0); | ||
}); | ||
el.height = maxHeight + top + bottom; | ||
} | ||
@@ -64,0 +63,0 @@ }; |
{ | ||
"name": "@lightningjs/solid-primitives", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"description": "Lightning Primitives for Solid Lightning", | ||
@@ -73,2 +73,3 @@ "type": "module", | ||
"dist", | ||
"src", | ||
"packages", | ||
@@ -75,0 +76,0 @@ "LICENSE", |
@@ -19,4 +19,6 @@ /* | ||
import type { ElementNode } from '@lightningjs/solid'; | ||
import { untrack } from 'solid-js'; | ||
import SpeechEngine, { type SeriesResult, type SpeechType } from './speech.js'; | ||
import { debounce } from '@solid-primitives/scheduled'; | ||
import { focusPath } from '../useFocusManager.js'; | ||
@@ -48,3 +50,6 @@ type DebounceWithFlushFunction<T> = { | ||
function debounceWithFlush<T>(callback: (newValue: T) => void, time?: number): DebounceWithFlushFunction<T> { | ||
function debounceWithFlush<T>( | ||
callback: (newValue: T) => void, | ||
time?: number, | ||
): DebounceWithFlushFunction<T> { | ||
const trigger = debounce(callback, time); | ||
@@ -66,3 +71,3 @@ let scopedValue: T; | ||
return debounced; | ||
}; | ||
} | ||
@@ -91,14 +96,17 @@ function getElmName(elm: ElementNode) { | ||
const toAnnounceText: SpeechType[] = []; | ||
const toAnnounce = focusDiff.reduce((acc: [string, string, SpeechType][], elm) => { | ||
if (elm.announce) { | ||
acc.push([getElmName(elm), 'Announce', elm.announce]); | ||
toAnnounceText.push(elm.announce); | ||
} else if (elm.title) { | ||
acc.push([getElmName(elm), 'Title', elm.title]); | ||
toAnnounceText.push(elm.title); | ||
} else { | ||
acc.push([getElmName(elm), 'No Announce', '']); | ||
} | ||
return acc; | ||
}, []); | ||
const toAnnounce = focusDiff.reduce( | ||
(acc: [string, string, SpeechType][], elm) => { | ||
if (elm.announce) { | ||
acc.push([getElmName(elm), 'Announce', elm.announce]); | ||
toAnnounceText.push(elm.announce); | ||
} else if (elm.title) { | ||
acc.push([getElmName(elm), 'Title', elm.title]); | ||
toAnnounceText.push(elm.title); | ||
} else { | ||
acc.push([getElmName(elm), 'No Announce', '']); | ||
} | ||
return acc; | ||
}, | ||
[], | ||
); | ||
@@ -138,5 +146,12 @@ focusDiff.reverse().reduce((acc, elm) => { | ||
clearPrevFocus: (depth?: number) => void; | ||
speak: (text: SpeechType, options?: { append?: boolean; notification?: boolean }) => SeriesResult; | ||
setupTimers: (options?: { focusDebounce?: number; focusChangeTimeout?: number }) => void; | ||
speak: ( | ||
text: SpeechType, | ||
options?: { append?: boolean; notification?: boolean }, | ||
) => SeriesResult; | ||
setupTimers: (options?: { | ||
focusDebounce?: number; | ||
focusChangeTimeout?: number; | ||
}) => void; | ||
onFocusChange?: DebounceWithFlushFunction<ElementNode[]>; | ||
refresh: (depth?: number) => void; | ||
} | ||
@@ -165,7 +180,8 @@ | ||
voiceOutDisabled = true; | ||
currentlySpeaking?.series.finally(() => { | ||
voiceOutDisabled = false; | ||
// TODO: Implement refresh | ||
// Announcer.refresh(); | ||
}).catch(console.error); | ||
currentlySpeaking?.series | ||
.finally(() => { | ||
voiceOutDisabled = false; | ||
Announcer.refresh(); | ||
}) | ||
.catch(console.error); | ||
} | ||
@@ -176,2 +192,7 @@ } | ||
}, | ||
refresh: function (depth = 0) { | ||
Announcer.clearPrevFocus(depth); | ||
Announcer.onFocusChange && | ||
Announcer.onFocusChange(untrack(() => focusPath())); | ||
}, | ||
setupTimers: function ({ | ||
@@ -178,0 +199,0 @@ focusDebounce = 400, |
@@ -70,12 +70,11 @@ /* | ||
el.height = | ||
el.children.reduce((acc, c) => { | ||
c.y = (c.y || 0) + top; | ||
c.marginTop = top; | ||
return acc + (c.height || 0); | ||
}, 0) + | ||
top + | ||
bottom; | ||
let maxHeight = 0; | ||
el.children.forEach((c) => { | ||
c.y = (c.y || 0) + top; | ||
c.marginTop = top; | ||
maxHeight = Math.max(maxHeight, c.height || 0); | ||
}); | ||
el.height = maxHeight + top + bottom; | ||
} | ||
}; | ||
} |
@@ -36,5 +36,5 @@ <p> | ||
useFocusManager({ | ||
m: 'Menu', | ||
t: 'Text', | ||
b: 'Buttons', | ||
Menu: 'm', | ||
Text: 't', | ||
Buttons: 'b', | ||
}); | ||
@@ -41,0 +41,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
142057
52
1802