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 74
74
commands ,
75
75
storeMethods ,
76
76
actionMap ,
77
- activeCommandId: commands ?.[ 0 ]?. actionId || ' ' ,
77
+ activeCommandId: null ,
78
78
results: commands
79
79
}));
80
80
};
84
84
const unsubscribePaletteStore = paletteStore .subscribe ((value : storeParams ) => {
85
85
isPaletteVisible = value .isVisible ;
86
86
actions = value .commands ;
87
- activeCommand = value .activeCommandId ?? actions ?.[ 0 ]?. actionId ;
87
+ activeCommand = value .activeCommandId ?? null ;
88
88
searchResults = getNonEmptyArray (value .results , value .commands , []);
89
89
});
90
90
125
125
if (searchResults .length ) {
126
126
// get currently seleted item
127
127
let activeCommandIndex = searchResults .findIndex ((a ) => a .actionId === activeCommand ) ?? 0 ;
128
- activeCommandIndex = activeCommandIndex === - 1 ? 0 : activeCommandIndex ;
128
+ activeCommandIndex = activeCommandIndex === - 1 ? - 1 : activeCommandIndex ;
129
129
const totalCommands = searchResults .length ;
130
130
const nextCommand = (activeCommandIndex + 1 ) % totalCommands ;
131
131
const indexToSet = searchResults [nextCommand ] ? nextCommand : activeCommandIndex ;
136
136
const handleEnterKey = (event : KeyboardEvent ) => {
137
137
event .preventDefault ();
138
138
// get active command and execute
139
- const action = actionMap [activeCommand ];
139
+ const action = actionMap [activeCommand as string ];
140
140
runAction ({ action });
141
141
};
142
142
Original file line number Diff line number Diff line change 9
9
10
10
let actions: commands = [];
11
11
const unsubscribe = paletteStore .subscribe ((value : storeParams ) => {
12
- actions = getNonEmptyArray (value .results );
12
+ actions =
13
+ value .results .length > 0 ? getNonEmptyArray (value .results ) : getNonEmptyArray (value .commands );
13
14
});
14
15
15
16
const themeContext = getContext (THEME_CONTEXT ) as Writable <themeContext >;
Original file line number Diff line number Diff line change 1
1
import type createActionMap from '$lib/utils/createActionMap' ;
2
2
import type createStoreMethods from '$lib/utils/createStoreMethods' ;
3
3
4
- export type ActionId = number | string ;
4
+ export type ActionId = number | string | null ;
5
5
export type onRunParams = {
6
6
action : action ;
7
7
storeProps : storeParams ;
@@ -22,7 +22,7 @@ export type commands = Array<action>;
22
22
23
23
export interface storeParams {
24
24
isVisible : boolean ;
25
- textInput : '' ;
25
+ textInput : string ;
26
26
commands : commands ;
27
27
storeMethods : ReturnType < typeof createStoreMethods > ;
28
28
actionMap : ReturnType < typeof createActionMap > ;
Original file line number Diff line number Diff line change @@ -7,15 +7,14 @@ const createStoreMethods = () => {
7
7
const storeProps : storeParams = get ( paletteStore ) ;
8
8
9
9
const resetPaletteStore = ( ) => {
10
- paletteStore . update ( ( n ) => ( { ...n , defaultAppState } ) ) ;
10
+ paletteStore . update ( ( n ) => ( { ...n , ... defaultAppState } ) ) ;
11
11
} ;
12
12
13
13
const openPalette = ( ) => {
14
14
paletteStore . update ( ( n ) => ( { ...n , isVisible : true } ) ) ;
15
15
} ;
16
16
17
17
const closePalette = ( ) => {
18
- paletteStore . update ( ( n ) => ( { ...n , isVisible : false } ) ) ;
19
18
resetPaletteStore ( ) ;
20
19
} ;
21
20
Original file line number Diff line number Diff line change @@ -41,8 +41,8 @@ const updatePaletteStoreAfterActionExec = (actionId: ActionId) => {
41
41
...n ,
42
42
isVisible : false ,
43
43
textInput : '' ,
44
- activeCommandId : actionId ,
45
- selectedCommandId : actionId ,
44
+ activeCommandId : null ,
45
+ selectedCommandId : null ,
46
46
calledActions : [ ...n . calledActions , actionId ]
47
47
} ;
48
48
} ) ;
Original file line number Diff line number Diff line change 6
6
<svelte:head >
7
7
<script >
8
8
const getThemeFromLocalStorage = () => {
9
- const theme = localStorage .getItem (' theme' ) || ' dark ' ;
9
+ const theme = localStorage .getItem (' theme' ) || ' light ' ;
10
10
return theme;
11
11
};
12
12
You can’t perform that action at this time.
0 commit comments