-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
833 lines (766 loc) · 47.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="An adaptable framework for building accessible comboboxes. Built as a web component">
<!-- fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
<!-- end -->
<link rel="stylesheet" href="/src/styles/style.css" />
<title>Combobox Framework</title>
<!-- highlightjs -->
<link rel="preconnect" href="https://cdnjs.cloudflare.com">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/atom-one-dark.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/xml.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/css.min.js"></script>
<!-- end -->
</head>
<body>
<script type="module" src="/src/combobox-framework.ts"></script>
<article>
<header>
<h1>Combobox framework documentation</h1>
<nav>
<a href="#installation">Installation</a>
<a href="#examples">Examples</a>
<a href="#styling">Styling</a>
<a href="https://github.com/klovaaxel/combobox-framework">GitHub</a>
<a href="https://www.npmjs.com/package/combobox-framework">NPM</a>
<a href="https://www.webcomponents.org/element/combobox-framework">WebComponents</a>
</nav>
<p>
An adaptable framework for building accessible comboboxes. Built as a web component, it can be used
in any framework or vanilla HTML/CSS/JS.
</p>
<section class="features">
<h2>Key features</h2>
<ul>
<li class="accessible">
Accessible! Built to follow the WAI-ARIA combobox design pattern. Built for keyboard
navigation, screen readers, and other assistive technologies.
</li>
<li class="styling">
Easy to style! Bind your own elements to the framework slots, and style them however you
want. Easy to integrate into any design system.
</li>
</ul>
</section>
<p>What follows are examples of how to use/implement the combobox-framework component</p>
</header>
<section>
<h2 id="installation">Installation</h2>
<section>
<h3>Link in from CDN</h3>
<pre><code><script type="module" src="https://unpkg.com/combobox-framework"></script></code></pre>
</section>
<section>
<h3>Install from npm</h3>
<p>Install the combobox-framework from npm</p>
<pre><code>npm install combobox-framework</code></pre>
<p>Import the combobox-framework into your project</p>
<pre><code>import 'combobox-framework';</code></pre>
</section>
</section>
<section>
<h2>Demo</h2>
<p>
A "real world" example of how the combobox-framework can be used.
Meant to show how the search functionality can be used with a larger dataset (91 options).
</p>
<p>
The example is a combobox-framework with a input and a table of cast members from the movie The
Shawshank Redemption. The input is used to search for a cast member, and the table is used to show
the cast members.
</p>
<p>
<em>Note:</em> The focus of this demo is not on the styling, but on the functionality of the combobox-framework.
</p>
<label style="display: block;" for="demo-input">Select a cast member:</label>
<combobox-framework data-limit="20" data-fuse-options='{ "includeScore": true, "keys": ["dataset.search"]}'>
<input id="demo-input" placeholder="Click me" type="text" slot="input" size="50" />
<table anchor="demo-input" slot="list">
<thead>
<tr>
<th>Name</th>
<th>Role</th>
</tr>
</thead>
<tbody data-list>
<tr data-value="1" data-display="Tim Robbins" data-search="Tim Robbins Andy Dufresne">
<td>Tim Robbins</td>
<td>Andy Dufresne</td>
</tr>
<tr data-value="2" data-display="Morgan Freeman" data-search='Morgan Freeman Ellis Boyd "Red" Redding'>
<td>Morgan Freeman</td>
<td>Ellis Boyd "Red" Redding</td>
</tr>
<tr data-value="3" data-display="Bob Gunton" data-search="Bob Gunton Warden Samuel Norton">
<td>Bob Gunton</td>
<td>Warden Samuel Norton</td>
</tr>
<tr data-value="4" data-display="William Sadler" data-search="William Sadler Heywood">
<td>William Sadler</td>
<td>Heywood</td>
</tr>
<tr data-value="5" data-display="Clancy Brown" data-search="Clancy Brown Byron Hadley">
<td>Clancy Brown</td>
<td>Byron Hadley</td>
</tr>
<tr data-value="6" data-display="Gil Bellows" data-search="Gil Bellows Tommy Williams">
<td>Gil Bellows</td>
<td>Tommy Williams</td>
</tr>
<tr data-value="7" data-display="James Whitmore" data-search="James Whitmore Brooks Hatlen">
<td>James Whitmore</td>
<td>Brooks Hatlen</td>
</tr>
<tr data-value="8" data-display="Mark Rolston" data-search="Mark Rolston Bogs Diamond">
<td>Mark Rolston</td>
<td>Bogs Diamond</td>
</tr>
<tr data-value="9" data-display="Jeffrey DeMunn" data-search="Jeffrey DeMunn 1946 D.A.">
<td>Jeffrey DeMunn</td>
<td>1946 D.A.</td>
</tr>
<tr data-value="10" data-display="Larry Brandenburg" data-search="Larry Brandenburg Skeet">
<td>Larry Brandenburg</td>
<td>Skeet</td>
</tr>
<tr data-value="11" data-display="Neil Giuntoli" data-search="Neil Giunt Jigger">
<td>Neil Giuntoli</td>
<td>Jigger</td>
</tr>
<tr data-value="12" data-display="Brian Libby" data-search="Brian Libby Floyd">
<td>Brian Libby</td>
<td>Floyd</td>
</tr>
<tr data-value="13" data-display="David Proval" data-search="David Proval Snooze">
<td>David Proval</td>
<td>Snooze</td>
</tr>
<tr data-value="14" data-display="Joseph Ragno" data-search="Joseph Ragno Ernie">
<td>Joseph Ragno</td>
<td>Ernie</td>
</tr>
<tr data-value="15" data-display="Jude Ciccolella" data-search="Jude Ciccolella Guard Mert">
<td>Jude Ciccolella</td>
<td>Guard Mert</td>
</tr>
<tr data-value="16" data-display="Paul McCrane" data-search="Paul McCrane Guard Trout">
<td>Paul McCrane</td>
<td>Guard Trout</td>
</tr>
<tr data-value="17" data-display="Renee Blaine" data-search="Renee Blaine Linda Dufresne (Andy Dufresne's Wife)">
<td>Renee Blaine</td>
<td>Linda Dufresne (Andy Dufresne's Wife)</td>
</tr>
<tr data-value="18" data-display="Scott Mann" data-search="Scott Mann Glenn Quentin">
<td>Scott Mann</td>
<td>Glenn Quentin</td>
</tr>
<tr data-value="19" data-display="John Horton" data-search="John Horton Lloyd Henreid (Judge)">
<td>John Horton</td>
<td>Lloyd Henreid (Judge)</td>
</tr>
<tr data-value="20" data-display="Gordon Greene" data-search="Gordon Greene 1947 Parole Hearings Man">
<td>Gordon Greene</td>
<td>1947 Parole Hearings Man</td>
</tr>
<tr data-value="21" data-display="Alfonso Freeman" data-search="Alfonso Freeman Fresh Fish Con">
<td>Alfonso Freeman</td>
<td>Fresh Fish Con</td>
</tr>
<tr data-value="22" data-display="V.J. Foster" data-search="V.J. Foster Hungry Fish Con (as V.J. Foster)">
<td>V.J. Foster</td>
<td>Hungry Fish Con (as V.J. Foster)</td>
</tr>
<tr data-value="23" data-display="John E. Summers" data-search="John E. Summers New Fish Guard">
<td>John E. Summers</td>
<td>New Fish Guard</td>
</tr>
<tr data-value="24" data-display="Frank Medrano" data-search="Frank Medr Fat Ass">
<td>Frank Medrano</td>
<td>Fat Ass</td>
</tr>
<tr data-value="25" data-display="Mack Miles" data-search="Mack Miles Tyrell">
<td>Mack Miles</td>
<td>Tyrell</td>
</tr>
<tr data-value="26" data-display="Alan R. Kessler" data-search="Alan R. Kessler Laundry Bob">
<td>Alan R. Kessler</td>
<td>Laundry Bob</td>
</tr>
<tr data-value="27" data-display="Morgan Lund" data-search="Morgan Lund Laundry Truck Driver">
<td>Morgan Lund</td>
<td>Laundry Truck Driver</td>
</tr>
<tr data-value="28" data-display="Cornell Wallace" data-search="Cornell Wallace Laundry Leonard">
<td>Cornell Wallace</td>
<td>Laundry Leonard</td>
</tr>
<tr data-value="29" data-display="Gary Lee Davis" data-search="Gary Lee Davis Rooster">
<td>Gary Lee Davis</td>
<td>Rooster</td>
</tr>
<tr data-value="30" data-display="Neil Summers" data-search="Neil Summers Pete">
<td>Neil Summers</td>
<td>Pete</td>
</tr>
<tr data-value="31" data-display="Ned Bellamy" data-search="Ned Bellamy Guard Youngblood">
<td>Ned Bellamy</td>
<td>Guard Youngblood</td>
</tr>
<tr data-value="32" data-display="Joe Pecoraro" data-search="Joe Pecoraro Projectionist">
<td>Joe Pecoraro</td>
<td>Projectionist</td>
</tr>
<tr data-value="33" data-display="Harold E. Cope Jr." data-search="Harold E. Cope Jr. Hole Guard">
<td>Harold E. Cope Jr.</td>
<td>Hole Guard</td>
</tr>
<tr data-value="34" data-display="Brian Delate" data-search="Brian Delate Guard Dekins">
<td>Brian Delate</td>
<td>Guard Dekins</td>
</tr>
<tr data-value="35" data-display="Don McManus" data-search="Don McManus Guard Wiley">
<td>Don McManus</td>
<td>Guard Wiley</td>
</tr>
<tr data-value="36" data-display="Dorothy Silver" data-search="Dorothy Silver Landlady">
<td>Dorothy Silver</td>
<td>Landlady</td>
</tr>
<tr data-value="37" data-display="Donald Zinn" data-search="Donald Zinn Moresby Batter">
<td>Donald Zinn</td>
<td>Moresby Batter</td>
</tr>
<tr data-value="38" data-display="Robert Haley" data-search="Robert Haley 1954 Food-Way Manager">
<td>Robert Haley</td>
<td>1954 Food-Way Manager</td>
</tr>
<tr data-value="39" data-display="Dana Snyder" data-search="Dana Snyder 1954 Food-Way Proprietor">
<td>Dana Snyder</td>
<td>1954 Food-Way Proprietor</td>
</tr>
<tr data-value="40" data-display="John D. Craig" data-search="John D. Craig 1954 Food-Way Customer">
<td>John D. Craig</td>
<td>1954 Food-Way Customer</td>
</tr>
<tr data-value="41" data-display="Ken Magee" data-search="Ken Magee Ned Grimes">
<td>Ken Magee</td>
<td>Ned Grimes</td>
</tr>
<tr data-value="42" data-display="Eugene C. DePasquale" data-search="Eugene C. DePasquale Mail Caller">
<td>Eugene C. DePasquale</td>
<td>Mail Caller</td>
</tr>
<tr data-value="43" data-display="Bill Bolender" data-search="Bill Bolender Elmo Blatch">
<td>Bill Bolender</td>
<td>Elmo Blatch</td>
</tr>
<tr data-value="44" data-display="Ron Newell" data-search="Ron Newell Elderly Hole Guard">
<td>Ron Newell</td>
<td>Elderly Hole Guard</td>
</tr>
<tr data-value="45" data-display="John R. Woodward" data-search="John R. Woodward Bullhorn Tower Guard">
<td>John R. Woodward</td>
<td>Bullhorn Tower Guard</td>
</tr>
<tr data-value="46" data-display="Chuck Brauchler" data-search="Chuck Brauchler Man Missing Guard">
<td>Chuck Brauchler</td>
<td>Man Missing Guard</td>
</tr>
<tr data-value="47" data-display="Dion Anderson" data-search="Dion Anderson Head Bull Haig">
<td>Dion Anderson</td>
<td>Head Bull Haig</td>
</tr>
<tr data-value="48" data-display="Claire Slemmer" data-search="Claire Slemmer Bank Teller">
<td>Claire Slemmer</td>
<td>Bank Teller</td>
</tr>
<tr data-value="49" data-display="James Kisicki" data-search="James Kisicki Bank Manager">
<td>James Kisicki</td>
<td>Bank Manager</td>
</tr>
<tr data-value="50" data-display="Rohn Thomas" data-search="Rohn Thomas Bugle Editor">
<td>Rohn Thomas</td>
<td>Bugle Editor</td>
</tr>
<tr data-value="51" data-display="Charlie Kearns" data-search="Charlie Kearns 1966 D.A">
<td>Charlie Kearns</td>
<td>1966 D.A</td>
</tr>
<tr data-value="52" data-display="Rob Reider" data-search="Rob Reider Duty Guard">
<td>Rob Reider</td>
<td>Duty Guard</td>
</tr>
<tr data-value="53" data-display="Brian Brophy" data-search="Brian Brophy 1967 Parole Hearings Man">
<td>Brian Brophy</td>
<td>1967 Parole Hearings Man</td>
</tr>
<tr data-value="54" data-display="Paul Kennedy" data-search="Paul Kennedy 1967 Food-Way Manager">
<td>Paul Kennedy</td>
<td>1967 Food-Way Manager</td>
</tr>
<tr data-value="55" data-display="Dennis Baker" data-search="Dennis Baker Old Man on Bus (uncredited)">
<td>John D. Craig</td>
<td>Old Man on Bus (uncredited)</td>
</tr>
<tr data-value="56" data-display="Fred Culbertson" data-search="Fred Culbertson Police Officer (uncredited)">
<td>Fred Culbertson</td>
<td>Police Officer (uncredited)</td>
</tr>
<tr data-value="57" data-display="Richard Doone" data-search="Richard Doone Con (uncredited)">
<td>Richard Doone</td>
<td>Con (uncredited)</td>
</tr>
<tr data-value="58" data-display="Samantha Goldberg" data-search="Samantha Goldberg Bank Employee (uncredited)">
<td>Samantha Goldberg</td>
<td>Bank Employee (uncredited)</td>
</tr>
<tr data-value="59" data-display="Shane Grove" data-search="Shane Grove Inmate (uncredited)">
<td>Shane Grove</td>
<td>Inmate (uncredited)</td>
</tr>
<tr data-value="60" data-display="Rita Hayworth" data-search="Rita Hayworth Gilda Mundson Farrell (archive footage) (uncredited)">
<td>Rita Hayworth</td>
<td>Gilda Mundson Farrell (archive footage) (uncredited)</td>
</tr>
<tr data-value="61" data-display="David Hecht" data-search="David Hecht Bank Teller">
<td>Bill McKinney</td>
<td>Bank Teller</td>
</tr>
<tr data-value="62" data-display="Alonzo F. Jones" data-search="Alonzo F. Jones Inmate (uncredited)">
<td>Alonzo F. Jones</td>
<td>Inmate (uncredited)</td>
</tr>
<tr data-value="63" data-display="Gary Jones" data-search="Gary Jones Convict (uncredited)">
<td>Gary Jones</td>
<td>Convict (uncredited)</td>
</tr>
<tr data-value="64" data-display="Sergio Kato" data-search="Sergio Kato Inmate II (uncredited)">
<td>Sergio Kato</td>
<td>Inmate II (uncredited)</td>
</tr>
<tr data-value="65" data-display="Michael Lightsey" data-search="Michael Lightsey Con (uncredited)">
<td>Michael Lightsey</td>
<td>Con (uncredited)</td>
</tr>
<tr data-value="66" data-display="Tracy Love" data-search="Tracy Love Court Spectator (uncredited)">
<td>Tracy Love</td>
<td>Court Spectator (uncredited)</td>
</tr>
<tr data-value="67" data-display="George Macready" data-search="George Macready Ballin Mundson (archive footage) (uncredited)">
<td>George Macready</td>
<td>Ballin Mundson (archive footage) (uncredited)</td>
</tr>
<tr data-value="68" data-display="Christopher Page" data-search="Christopher Page Traffic (driver) (uncredited)">
<td>Christopher Page</td>
<td>Traffic (driver) (uncredited)</td>
</tr>
<tr data-value="69" data-display="Neil Riddaway" data-search="Neil Riddaway Con (uncredited)">
<td>Neil Riddaway</td>
<td>Con (uncredited)</td>
</tr>
<tr data-value="70" data-display="Brad Spencer" data-search="Brad Spencer 1957 Parole Hearings Guard (uncredited)">
<td>Brad Spencer</td>
<td>1957 Parole Hearings Guard (uncredited)</td>
</tr>
<tr data-value="71" data-display="Jodiviah Stepp" data-search="Jodiviah Stepp New Fish Con (uncredited)">
<td>Jodiviah Stepp</td>
<td>New Fish Con (uncredited)</td>
</tr>
<tr data-value="72" data-display="Mark A. Strain" data-search="Mark A. Strain Yard Inmate (uncredited)">
<td>Mark A. Strain</td>
<td>Yard Inmate (uncredited)</td>
</tr>
<tr data-value="73" data-display="James Babson" data-search="James Babson Con (uncredited)">
<td>James Babson</td>
<td>Con (uncredited)</td>
</tr>
<tr data-value="74" data-display="Dennis Baker" data-search="Dennis Baker Old Man on Bus (uncredited)">
<td>Dennis Baker</td>
<td>Old Man on Bus (uncredited)</td>
</tr>
<tr data-value="75" data-display="Fred Culbertson" data-search="Fred Culbertson Police Officer (uncredited)">
<td>Fred Culbertson</td>
<td>Police Officer (uncredited)</td>
</tr>
<tr data-value="76" data-display="Richard Doone" data-search="Richard Doone Con (uncredited)">
<td>Richard Doone</td>
<td>Con (uncredited)</td>
</tr>
<tr data-value="77" data-display="Samantha Goldberg" data-search="Samantha Goldberg Bank Employee (uncredited)">
<td>Samantha Goldberg</td>
<td>Bank Employee (uncredited)</td>
</tr>
<tr data-value="78" data-display="Shane Grove" data-search="Shane Grove Inmate (uncredited)">
<td>Shane Grove</td>
<td>Inmate (uncredited)</td>
</tr>
<tr data-value="79" data-display="Rita Hayworth" data-search="Rita Hayworth Gilda Mundson Farrell (archive footage) (uncredited)">
<td>Rita Hayworth</td>
<td>Gilda Mundson Farrell (archive footage) (uncredited)</td>
</tr>
<tr data-value="80" data-display="David Hecht" data-search="David Hecht Bank Teller">
<td>David Hecht</td>
<td>Bank Teller</td>
</tr>
<tr data-value="81" data-display="Alonzo F. Jones" data-search="Alonzo F. Jones Inmate (uncredited)">
<td>Alonzo F. Jones</td>
<td>Inmate (uncredited)</td>
</tr>
<tr data-value="82" data-display="Gary Jones" data-search="Gary Jones Convict (uncredited)">
<td>Gary Jones</td>
<td>Convict (uncredited)</td>
</tr>
<tr data-value="83" data-display="Sergio Kato" data-search="Sergio Kato Inmate II (uncredited)">
<td>Sergio Kato</td>
<td>Inmate II (uncredited)</td>
</tr>
<tr data-value="84" data-display="Michael Lightsey" data-search="Michael Lightsey Con (uncredited)">
<td>Michael Lightsey</td>
<td>Con (uncredited)</td>
</tr>
<tr data-value="85" data-display="Tracy Love" data-search="Tracy Love Court Spectator (uncredited)">
<td>Tracy Love</td>
<td>Court Spectator (uncredited)</td>
</tr>
<tr data-value="86" data-display="George Macready" data-search="George Macready Ballin Mundson (archive footage) (uncredited)">
<td>George Macready</td>
<td>Ballin Mundson (archive footage) (uncredited)</td>
</tr>
<tr data-value="87" data-display="Christopher Page" data-search="Christopher Page Traffic (driver) (uncredited)">
<td>Christopher Page</td>
<td>Traffic (driver) (uncredited)</td>
</tr>
<tr data-value="88" data-display="Neil Riddaway" data-search="Neil Riddaway Con (uncredited)">
<td>Neil Riddaway</td>
<td>Con (uncredited)</td>
</tr>
<tr data-value="89" data-display="Brad Spencer" data-search="Brad Spencer 1957 Parole Hearings Guard (uncredited)">
<td>Brad Spencer</td>
<td>1957 Parole Hearings Guard (uncredited)</td>
</tr>
<tr data-value="90" data-display="Jodiviah Stepp" data-search="Jodiviah Stepp New Fish Con (uncredited)">
<td>Jodiviah Stepp</td>
<td>New Fish Con (uncredited)</td>
</tr>
<tr data-value="91" data-display="Mark A. Strain" data-search="Mark A. Strain Yard Inmate (uncredited)">
<td>Mark A. Strain</td>
<td>Yard Inmate (uncredited)</td>
</tr>
</tbody>
</table>
</combobox-framework>
</section>
<section>
<h2 id="examples">Examples</h2>
<nav>
<a href="#simple-list">Simple list</a>
<a href="#simple-list-with-custom-display-data">Simple list with custom display data</a>
<a href="#list-with-nested-elements">List with nested elements</a>
<a href="#tabular-data">Tabular data</a>
<a href="#preselected-option">Preselected option</a>
<a href="#custom-fusefuzzy-search-options">Custom Fuse/Fuzzy search options</a>
<a href="#force-valuelistbox">Force value/Listbox</a>
<a href="#limit-suggested-options">Limit suggested options</a>
<a href="#weighted-item-search">Weighted item search</a>
<a href="#change-events">Change events</a>
</nav>
<section id="simple-list">
<h3>Simple list</h3>
<p>
To use the combobox-framework, you need to add a <code>input</code> element and a list of items.
The <code>input</code> element needs to be placed in a <code>slot="input"</code> attribute and
the list of items needs to be placed in a <code>slot="list"</code> attribute.
</p>
<p>
The <code>li</code> elements needs to have a <code>data-value</code> attribute. This is the
value that will be set on the <code>combobox-framework</code> element as the
<code>data-value</code> when a option is selected.
</p>
<div data-example>
<combobox-framework>
<input id="simple-list-input" placeholder="Click me" type="text" slot="input" />
<ul anchor="simple-list-input" slot="list">
<li data-value="1">Item 1</li>
<li data-value="2">Item 2</li>
<li data-value="3">Item 3</li>
<li data-value="4">Item 4</li>
</ul>
</combobox-framework>
</div>
</section>
<section id="simple-list-with-custom-display-data">
<h3>Simple list with custom display data</h3>
<p>
To show diffrent data in the input than in the list, you need to add the
<code>data-display</code> attribute to the <code>li</code> element. This is the value that will
be shown in the input when a option is selected.
</p>
<div data-example>
<combobox-framework>
<input id="custom-display-data-input" placeholder="Click me" type="text" slot="input" />
<ul anchor="custom-display-data-input" slot="list">
<li data-value="1" data-display="Item 1">1</li>
<li data-value="2" data-display="Item 2">2</li>
<li data-value="3" data-display="Item 3">3</li>
<li data-value="4" data-display="Item 4">4</li>
</ul>
</combobox-framework>
</div>
</section>
<section id="list-with-nested-elements">
<h3>List with nested elements</h3>
<p>
To use nested elements, you need to add the <code>data-display</code> attribute to the
<code>li</code> element. This is the value that will be shown in the input when a option is
selected.
</p>
<div data-example>
<combobox-framework>
<input id="nested-elements-input" placeholder="Click me" type="text" slot="input" />
<ul anchor="nested-elements-input" slot="list">
<li data-value="1" data-display="Item 1">
<div>Item 1</div>
</li>
<li data-value="2" data-display="Item 2">
<div>Item 2</div>
</li>
<li data-value="3" data-display="Item 3">
<div>Item 3</div>
</li>
<li data-value="4" data-display="Item 4">
<div>Item 4</div>
</li>
</ul>
</combobox-framework>
</div>
</section>
<section id="tabular-data">
<h3>Tabular data</h3>
<p>
To use tabular data, you need to add the <code>data-list</code> attribute to the
<code>tbody</code> element. This will tell the combobox-framework to use the
<code>tbody</code> element as the list of items and not the table itself.
</p>
<div data-example>
<combobox-framework>
<input id="tabular-data-input" placeholder="Click me" type="text" slot="input" />
<table anchor="tabular-data-input" slot="list">
<thead>
<th>Name</th>
<th>Number</th>
</thead>
<tbody data-list>
<tr data-value="1" data-display="Item 1">
<td>Item</td>
<td>1</td>
</tr>
<tr data-value="2" data-display="Item 2">
<td>Item</td>
<td>2</td>
</tr>
<tr data-value="3" data-display="Item 3">
<td>Item</td>
<td>3</td>
</tr>
<tr data-value="4" data-display="Item 4">
<td>Item</td>
<td>4</td>
</tr>
</tbody>
</table>
</combobox-framework>
</div>
</section>
<section id="preselected-option">
<h3>Preselected option</h3>
<p>
To preselect a option, you need to add the <code>data-value</code> attribute to the
<code>combobox-framework</code> element. This will tell the combobox-framework to select the
option with the matching <code>data-value</code> attribute.
</p>
<div data-example>
<combobox-framework data-value="1">
<input id="preselected-option-input" placeholder="Click me" type="text" slot="input" />
<ul anchor="preselected-option-input" slot="list">
<li data-value="1">Item 1</li>
<li data-value="2">Item 2</li>
<li data-value="3">Item 3</li>
<li data-value="4">Item 4</li>
</ul>
</combobox-framework>
</div>
</section>
<section id="custom-fusefuzzy-search-options">
<h3>Custom Fuse/Fuzzy search options</h3>
<p>
To use custom fuse/fuzzy search options, you need to add the
<code>data-fuse-options</code> attribute to the <code>combobox-framework</code> element, and
pass in a JSON string of the settings object. This will tell the combobox-framework to use the
custom options when searching for a option.
</p>
<p>
For what options are available, see the
<a href="https://www.fusejs.io/api/options.html">Fuse.js documentation</a>
</p>
<div data-example>
<combobox-framework data-fuse-options='{ "includeScore": true, "keys": ["dataset.value"]}'>
<input id="fuse-options-input" placeholder="Click me" type="text" slot="input" />
<ul anchor="fuse-options-input" slot="list">
<li data-value="1">Item 1</li>
<li data-value="2">Item 2</li>
<li data-value="3">Item 3</li>
<li data-value="4">Item 4</li>
</ul>
</combobox-framework>
</div>
</section>
<section id="force-valuelistbox">
<h3>Force value/Listbox</h3>
<p>
To force the combobox-framework to act as a searchable listbox, you need to add the
<code>data-listbox</code> attribute to the <code>combobox-framework</code> element. This will
tell the combobox-framework to act as a searchable listbox instead of a combobox. And only allow
the <code>value</code> to be one of the options in the list or <code>null</code>.
</p>
<div data-example>
<combobox-framework data-listbox="true">
<input id="force-valuelistbox-input" placeholder="Click me" type="text" slot="input" />
<ul anchor="force-valuelistbox-input" slot="list">
<li data-value="1">Item 1</li>
<li data-value="2">Item 2</li>
<li data-value="3">Item 3</li>
<li data-value="4">Item 4</li>
</ul>
</combobox-framework>
</div>
</section>
<section id="limit-suggested-options">
<h3>Limit suggested options</h3>
<p>
To limit the number of suggested options, you need to add the <code>data-limit</code> attribute
to the <code>combobox-framework</code> element. This will tell the combobox-framework to only
show the number of options specified in the <code>data-limit</code> attribute.
</p>
<div data-example>
<combobox-framework data-limit="2">
<input id="limit-suggested-options-input" placeholder="Click me" type="text" slot="input" />
<ul anchor="limit-suggested-options-input" slot="list">
<li data-value="1">Item 1</li>
<li data-value="2">Item 2</li>
<li data-value="3">Item 3</li>
<li data-value="4">Item 4</li>
</ul>
</combobox-framework>
</div>
</section>
<section>
<h3 id="weighted-item-search">Weighted item search</h3>
<p>
To use weighted item search, you need to add the <code>data-weight</code> attribute to the
<code>li</code> element. This is the value that will be used to sort the options when searching
for a option.
</p>
<p>
<em>NOTE: Fuse options must have <code>includeScore</code> set to <code>true</code> for weighted search to work.</em>
<code>includeScore</code> is true by default, if you have not set custom fuse options.
</p>
<p>
<em>NOTE: The <code>data-weight</code> attribute is a number, and the higher the number the higher the weight.</em>
</p>
<div data-example>
<combobox-framework>
<input id="weighted-item-search-input" placeholder="Click me" type="text" slot="input" />
<ul anchor="weighted-item-search-input" slot="list">
<li data-value="1" data-display="Item 1" data-weight="5">Item 1</li>
<li data-value="2" data-display="Item 2" data-weight="1">Item 2</li>
<li data-value="3" data-display="Item 3" data-weight="1">Item 3</li>
<li data-value="4" data-display="Item 4" data-weight="10">Item 4</li>
</ul>
</combobox-framework>
</div>
</section>
<section>
<h3 id="change-events">Change events</h3>
<p>
To add a change event, you need to add the <code>onchange</code> attribute to the
<code>combobox-framework</code> element. This will tell the combobox-framework to run the
function when the value of the combobox changes.
</p>
<div data-example>
<combobox-framework onchange="console.log('Changed')">
<input id="change-events-input" placeholder="Click me" type="text" slot="input" />
<ul anchor="change-events-input" slot="list">
<li data-value="1">Item 1</li>
<li data-value="2">Item 2</li>
<li data-value="3">Item 3</li>
<li data-value="4">Item 4</li>
</ul>
</combobox-framework>
</div>
</section>
</section>
<section>
<h2 id="styling">Styling</h2>
<p>This is the styling thats being used on this demo page. Hopefully it gives a good starting point</p>
<div data-example>
<style>
combobox-framework [slot="list"] {
color: var(--background-color);
background-color: var(--text-color);
position: absolute;
top: anchor(bottom);
left: anchor(left);
right: anchor(right);
list-style: none;
margin: 0;
padding: 0;
border: 1px solid black;
border-radius: 0 0 0.2rem 0.2rem;
}
combobox-framework [slot="list"] > * {
padding: 0.2rem;
cursor: pointer;
}
combobox-framework [slot="list"] li:hover,
combobox-framework [slot="list"] tr:hover td {
background-color: var(--primary-color);
}
</style>
</div>
</section>
</article>
<script>
const examples = document.querySelectorAll("[data-example]");
for (const example of examples) {
let exampleContent = example.innerHTML.trimEnd();
// Remove leading and ending newlines
if(exampleContent.startsWith('\n')) exampleContent = exampleContent.slice(1);
if(exampleContent.endsWith('\n')) exampleContent = exampleContent.slice(exampleContent.length, 1);
// end - Remove leading and ending newlines
// Replace < and > with < and >
exampleContent = exampleContent.replace(/</g, "<").replace(/>/g, ">");
// end - Replace < and > with < and >
// Remove leading spaces
leadingSpaces = exampleContent.match(/^\s+/);
if(leadingSpaces) {
exampleContent = exampleContent.replace(new RegExp(`^${leadingSpaces[0]}`, "gm"), "");
}
// end - Remove leading spaces
// Add pre and code tags
pre = document.createElement("pre");
pre.innerHTML = `<code>${exampleContent}</code>`;
example.appendChild(pre);
// end - Add pre and code tags
}
</script>
<script>hljs.highlightAll();</script>
</body>
</html>