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