File tree Expand file tree Collapse file tree 6 files changed +12
-12
lines changed
Expand file tree Collapse file tree 6 files changed +12
-12
lines changed Original file line number Diff line number Diff line change 7474 commands ,
7575 storeMethods ,
7676 actionMap ,
77- activeCommandId: commands ?.[ 0 ]?. actionId || ' ' ,
77+ activeCommandId: null ,
7878 results: commands
7979 }));
8080 };
8484 const unsubscribePaletteStore = paletteStore .subscribe ((value : storeParams ) => {
8585 isPaletteVisible = value .isVisible ;
8686 actions = value .commands ;
87- activeCommand = value .activeCommandId ?? actions ?.[ 0 ]?. actionId ;
87+ activeCommand = value .activeCommandId ?? null ;
8888 searchResults = getNonEmptyArray (value .results , value .commands , []);
8989 });
9090
125125 if (searchResults .length ) {
126126 // get currently seleted item
127127 let activeCommandIndex = searchResults .findIndex ((a ) => a .actionId === activeCommand ) ?? 0 ;
128- activeCommandIndex = activeCommandIndex === - 1 ? 0 : activeCommandIndex ;
128+ activeCommandIndex = activeCommandIndex === - 1 ? - 1 : activeCommandIndex ;
129129 const totalCommands = searchResults .length ;
130130 const nextCommand = (activeCommandIndex + 1 ) % totalCommands ;
131131 const indexToSet = searchResults [nextCommand ] ? nextCommand : activeCommandIndex ;
136136 const handleEnterKey = (event : KeyboardEvent ) => {
137137 event .preventDefault ();
138138 // get active command and execute
139- const action = actionMap [activeCommand ];
139+ const action = actionMap [activeCommand as string ];
140140 runAction ({ action });
141141 };
142142
Original file line number Diff line number Diff line change 99
1010 let actions: commands = [];
1111 const unsubscribe = paletteStore .subscribe ((value : storeParams ) => {
12- actions = getNonEmptyArray (value .results );
12+ actions =
13+ value .results .length > 0 ? getNonEmptyArray (value .results ) : getNonEmptyArray (value .commands );
1314 });
1415
1516 const themeContext = getContext (THEME_CONTEXT ) as Writable <themeContext >;
Original file line number Diff line number Diff line change 11import type createActionMap from '$lib/utils/createActionMap' ;
22import type createStoreMethods from '$lib/utils/createStoreMethods' ;
33
4- export type ActionId = number | string ;
4+ export type ActionId = number | string | null ;
55export type onRunParams = {
66 action : action ;
77 storeProps : storeParams ;
@@ -22,7 +22,7 @@ export type commands = Array<action>;
2222
2323export interface storeParams {
2424 isVisible : boolean ;
25- textInput : '' ;
25+ textInput : string ;
2626 commands : commands ;
2727 storeMethods : ReturnType < typeof createStoreMethods > ;
2828 actionMap : ReturnType < typeof createActionMap > ;
Original file line number Diff line number Diff line change @@ -7,15 +7,14 @@ const createStoreMethods = () => {
77 const storeProps : storeParams = get ( paletteStore ) ;
88
99 const resetPaletteStore = ( ) => {
10- paletteStore . update ( ( n ) => ( { ...n , defaultAppState } ) ) ;
10+ paletteStore . update ( ( n ) => ( { ...n , ... defaultAppState } ) ) ;
1111 } ;
1212
1313 const openPalette = ( ) => {
1414 paletteStore . update ( ( n ) => ( { ...n , isVisible : true } ) ) ;
1515 } ;
1616
1717 const closePalette = ( ) => {
18- paletteStore . update ( ( n ) => ( { ...n , isVisible : false } ) ) ;
1918 resetPaletteStore ( ) ;
2019 } ;
2120
Original file line number Diff line number Diff line change @@ -41,8 +41,8 @@ const updatePaletteStoreAfterActionExec = (actionId: ActionId) => {
4141 ...n ,
4242 isVisible : false ,
4343 textInput : '' ,
44- activeCommandId : actionId ,
45- selectedCommandId : actionId ,
44+ activeCommandId : null ,
45+ selectedCommandId : null ,
4646 calledActions : [ ...n . calledActions , actionId ]
4747 } ;
4848 } ) ;
Original file line number Diff line number Diff line change 66<svelte:head >
77 <script >
88 const getThemeFromLocalStorage = () => {
9- const theme = localStorage .getItem (' theme' ) || ' dark ' ;
9+ const theme = localStorage .getItem (' theme' ) || ' light ' ;
1010 return theme;
1111 };
1212
You can’t perform that action at this time.
0 commit comments