@@ -15,19 +15,24 @@ const ARROW_DOWN_KEY = 'ArrowDown';
15
15
const ARROW_UP_KEY = ' ArrowUp' ;
16
16
const TAB_KEY = ' Tab' ;
17
17
18
- export let display = false ;
19
- let inputElement: HTMLInputElement | HTMLTextAreaElement | undefined = undefined ;
20
- let outerDiv: HTMLDivElement | undefined = undefined ;
21
- let inputValue: string | undefined = ' ' ;
22
- let scrollElements: HTMLLIElement [] = [];
23
-
24
- let commandInfoItems: CommandInfo [] = [];
25
- let filteredCommandInfoItems: CommandInfo [] = [];
18
+ interface Props {
19
+ display? : boolean ;
20
+ }
21
+
22
+ let { display = false }: Props = $props ();
23
+ let inputElement: HTMLInputElement | HTMLTextAreaElement | undefined = $state (undefined );
24
+ let outerDiv: HTMLDivElement | undefined = $state (undefined );
25
+ let inputValue: string | undefined = $state (' ' );
26
+ let scrollElements: HTMLLIElement [] = $state ([]);
27
+
28
+ let commandInfoItems: CommandInfo [] = $state ([]);
26
29
let globalContext: ContextUI ;
27
30
28
- $ : filteredCommandInfoItems = commandInfoItems
29
- .filter (property => isPropertyValidInContext (property .enablement , globalContext ))
30
- .filter (item => (inputValue ? item .title ?.toLowerCase ().includes (inputValue .toLowerCase ()) : true ));
31
+ let filteredCommandInfoItems: CommandInfo [] = $derived (
32
+ commandInfoItems
33
+ .filter (property => isPropertyValidInContext (property .enablement , globalContext ))
34
+ .filter (item => (inputValue ? item .title ?.toLowerCase ().includes (inputValue .toLowerCase ()) : true )),
35
+ );
31
36
32
37
let contextsUnsubscribe: Unsubscriber ;
33
38
@@ -45,7 +50,7 @@ onDestroy(() => {
45
50
contextsUnsubscribe ?.();
46
51
});
47
52
48
- let selectedFilteredIndex = 0 ;
53
+ let selectedFilteredIndex = $state ( 0 ) ;
49
54
let selectedIndex = 0 ;
50
55
51
56
async function handleKeydown(e : KeyboardEvent ): Promise <void > {
@@ -178,14 +183,15 @@ async function onInputChange(): Promise<void> {
178
183
aria-label =" Command palette command input"
179
184
type =" text"
180
185
bind:value ={inputValue }
181
- on:input ={onInputChange }
186
+ oninput ={onInputChange }
182
187
class =" px-1 w-full text-[var(--pd-input-field-focused-text)] bg-[var(--pd-input-field-focused-bg)] border border-[var(--pd-input-field-stroke)] focus:outline-hidden" />
183
188
</div >
184
189
<ul class =" max-h-[50vh] overflow-y-auto flex flex-col" >
185
190
{#each filteredCommandInfoItems as item , i (item .id )}
186
191
<li class ="flex w-full flex-row" bind:this ={scrollElements [i ]} aria-label ={item .id }>
187
192
<button
188
- on:click ={(): Promise <void > => clickOnItem (i )}
193
+ onclick ={(): Promise <void > => clickOnItem (i )}
194
+ aria-label ={item .title }
189
195
class ="text-[var(--pd-dropdown-item-text)] text-left relative my-0.5 mr-2 w-full {i === selectedFilteredIndex
190
196
? ' bg-[var(--pd-modal-dropdown-highlight)] selected'
191
197
: ' hover:bg-[var(--pd-dropdown-bg)]' } px-1" >
0 commit comments