@@ -12,7 +12,7 @@ import {
12
12
13
13
import { PreviewCodeExample } from '../../../_components/preview-code-example/preview-code-example' ;
14
14
15
- const trainers = [
15
+ const stringsExample = [
16
16
'Caleb' ,
17
17
'Olivia' ,
18
18
'James' ,
@@ -25,13 +25,13 @@ const trainers = [
25
25
'Elizabeth' ,
26
26
] ;
27
27
28
- interface Trainer {
28
+ type Trainer = {
29
29
testValue : string ;
30
30
testLabel : string ;
31
31
disabled : boolean ;
32
- }
32
+ } ;
33
33
34
- const ALL_OPTIONS : Array < Trainer > = [
34
+ const objectExample : Array < Trainer > = [
35
35
{ testValue : 'alice' , testLabel : 'Alice' , disabled : false } ,
36
36
{ testValue : 'joana' , testLabel : 'Joana' , disabled : false } ,
37
37
{ testValue : 'malcolm' , testLabel : 'Malcolm' , disabled : false } ,
@@ -40,41 +40,39 @@ const ALL_OPTIONS: Array<Trainer> = [
40
40
] ;
41
41
42
42
export const Example01 = component$ ( ( ) => {
43
- // const trainersSig = useSignal(trainers );
44
- const optionsSig = useSignal ( ALL_OPTIONS ) ;
45
- const showExample = useSignal ( true ) ;
43
+ const stringsExampleSig = useSignal ( stringsExample ) ;
44
+ const objectExampleSig = useSignal ( objectExample ) ;
45
+ const isComboboxVisibleSig = useSignal ( true ) ;
46
46
47
47
const onInputChange$ = $ ( ( value : string ) => {
48
- optionsSig . value = ALL_OPTIONS . filter ( ( option ) => {
48
+ objectExampleSig . value = objectExample . filter ( ( option ) => {
49
49
return option . testLabel . toLowerCase ( ) . includes ( value . toLowerCase ( ) ) ;
50
50
} ) ;
51
-
52
- console . log ( optionsSig . value ) ;
53
51
} ) ;
54
52
55
53
return (
56
54
< PreviewCodeExample >
57
55
< div class = "flex flex-col gap-4" q :slot = "actualComponent" >
58
56
< button
59
57
onClick$ = { ( ) => {
60
- showExample . value = ! showExample . value ;
58
+ isComboboxVisibleSig . value = ! isComboboxVisibleSig . value ;
61
59
} }
62
60
>
63
- Show them
61
+ Toggle Client Side
64
62
</ button >
65
- { showExample . value === true && (
63
+ { isComboboxVisibleSig . value && (
66
64
< Combobox
67
- options = { optionsSig }
65
+ options = { objectExampleSig }
68
66
onInputChange$ = { onInputChange$ }
69
67
optionValueKey = "testValue"
70
68
optionLabelKey = "testLabel"
71
- optionComponent$ = { $ ( ( option : string | Trainer , index : number ) => (
69
+ optionComponent$ = { $ ( ( option : Trainer , index : number ) => (
72
70
< ComboboxOption
73
71
index = { index }
74
72
option = { option }
75
73
class = "rounded-sm px-2 hover:bg-[#496080] focus:bg-[#496080]"
76
74
>
77
- { typeof option === 'string' ? option : option . testLabel }
75
+ { option . testLabel }
78
76
</ ComboboxOption >
79
77
) ) }
80
78
class = "relative"
@@ -103,13 +101,6 @@ export const Example01 = component$(() => {
103
101
</ ComboboxPortal >
104
102
</ Combobox >
105
103
) }
106
- < button
107
- // onClick$={() => {
108
- // trainersSig.value = ['One', 'Two', 'Three', 'Four', 'Five'];
109
- // }}
110
- >
111
- Change them
112
- </ button >
113
104
</ div >
114
105
115
106
< div q :slot = "codeExample" >
0 commit comments