govuk_publishing_components 43.4.0 → 43.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/lib/govuk_publishing_components/version.rb +1 -1
  3. data/node_modules/accessible-autocomplete/CHANGELOG.md +390 -0
  4. data/node_modules/accessible-autocomplete/CODEOWNERS +2 -0
  5. data/node_modules/accessible-autocomplete/CONTRIBUTING.md +161 -0
  6. data/node_modules/accessible-autocomplete/LICENSE.txt +20 -0
  7. data/node_modules/accessible-autocomplete/Procfile +1 -0
  8. data/node_modules/accessible-autocomplete/README.md +490 -0
  9. data/node_modules/accessible-autocomplete/accessibility-criteria.md +42 -0
  10. data/node_modules/accessible-autocomplete/app.json +15 -0
  11. data/node_modules/accessible-autocomplete/babel.config.js +29 -0
  12. data/node_modules/accessible-autocomplete/dist/accessible-autocomplete.min.css +3 -0
  13. data/node_modules/accessible-autocomplete/dist/accessible-autocomplete.min.css.map +1 -0
  14. data/node_modules/accessible-autocomplete/dist/accessible-autocomplete.min.js +2 -0
  15. data/node_modules/accessible-autocomplete/dist/accessible-autocomplete.min.js.map +1 -0
  16. data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.preact.min.js +2 -0
  17. data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.preact.min.js.map +1 -0
  18. data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.react.min.js +2 -0
  19. data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.react.min.js.map +1 -0
  20. data/node_modules/accessible-autocomplete/examples/form-single.html +379 -0
  21. data/node_modules/accessible-autocomplete/examples/form.html +673 -0
  22. data/node_modules/accessible-autocomplete/examples/index.html +738 -0
  23. data/node_modules/accessible-autocomplete/examples/preact/index.html +346 -0
  24. data/node_modules/accessible-autocomplete/examples/react/index.html +347 -0
  25. data/node_modules/accessible-autocomplete/package.json +93 -0
  26. data/node_modules/accessible-autocomplete/postcss.config.js +16 -0
  27. data/node_modules/accessible-autocomplete/preact.js +1 -0
  28. data/node_modules/accessible-autocomplete/react.js +1 -0
  29. data/node_modules/accessible-autocomplete/scripts/check-staged.mjs +16 -0
  30. data/node_modules/accessible-autocomplete/src/autocomplete.css +167 -0
  31. data/node_modules/accessible-autocomplete/src/autocomplete.js +608 -0
  32. data/node_modules/accessible-autocomplete/src/dropdown-arrow-down.js +11 -0
  33. data/node_modules/accessible-autocomplete/src/status.js +125 -0
  34. data/node_modules/accessible-autocomplete/src/wrapper.js +60 -0
  35. data/node_modules/accessible-autocomplete/test/functional/dropdown-arrow-down.js +46 -0
  36. data/node_modules/accessible-autocomplete/test/functional/index.js +793 -0
  37. data/node_modules/accessible-autocomplete/test/functional/wrapper.js +339 -0
  38. data/node_modules/accessible-autocomplete/test/integration/index.js +309 -0
  39. data/node_modules/accessible-autocomplete/test/karma.config.js +46 -0
  40. data/node_modules/accessible-autocomplete/test/wdio.config.js +123 -0
  41. data/node_modules/accessible-autocomplete/webpack.config.mjs +244 -0
  42. metadata +40 -1
@@ -0,0 +1,738 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Accessible Autocomplete examples</title>
7
+ <style>
8
+ /* Example page specific styling. */
9
+ html {
10
+ color: #111;
11
+ background: #FFF;
12
+ font-family: -apple-system, BlinkMacSystemFont, 'avenir next', avenir, 'helvetica neue', helvetica, ubuntu, roboto, noto, 'segoe ui', arial, sans-serif;
13
+ font-size: 16px;
14
+ line-height: 1.5;
15
+ }
16
+
17
+ body {
18
+ padding-left: 1rem;
19
+ padding-right: 1rem;
20
+ }
21
+
22
+ h1, h2, h3, h4, h5, h6 {
23
+ line-height: normal;
24
+ }
25
+
26
+ label {
27
+ display: block;
28
+ margin-bottom: .5rem;
29
+ }
30
+
31
+ code {
32
+ padding-left: .5em;
33
+ padding-right: .5em;
34
+ background: #EFEFEF;
35
+ font-weight: normal;
36
+ font-family: monospace;
37
+ }
38
+
39
+ main {
40
+ max-width: 40em;
41
+ margin-left: auto;
42
+ margin-right: auto;
43
+ }
44
+
45
+ .autocomplete-wrapper {
46
+ max-width: 20em;
47
+ margin-bottom: 4rem;
48
+ }
49
+
50
+ /* Custom classes for the `XYZClasses` props with visual changes to see their effect without inspecting */
51
+ .app-input {
52
+ /* Adjust the font to check that both hint and input get the class by default,
53
+ to ensure the hint suggestion exactly aligns with the typed input text */
54
+ font-family: serif;
55
+ }
56
+
57
+ .app-hint {
58
+ box-shadow: inset 0 0 0 5px #44952e;
59
+ }
60
+
61
+ .custom-menu-class {
62
+ box-shadow: 0 3px 0 0 #fd0, 3px 3px 0 0 #fd0, -3px 3px 0 0 #fd0;
63
+ }
64
+ </style>
65
+ <link rel="stylesheet" href="../dist/accessible-autocomplete.min.css">
66
+ </head>
67
+ <body>
68
+ <main>
69
+ <h1>Accessible Autocomplete examples</h1>
70
+
71
+ <p><a href="form.html">Example in a real HTML form that you can submit</a></p>
72
+
73
+ <h2>Options</h2>
74
+
75
+ <h3><code>{ element, id, source }</code></h3>
76
+ <p>This illustrates usage with only the required arguments.</p>
77
+ <label for="autocomplete-default">Country</label>
78
+ <div id="tt-default" class="autocomplete-wrapper"></div>
79
+
80
+ <h3><code>{ minLength: 2 }</code></h3>
81
+ <p>
82
+ This option will prevent displaying suggestions if less than 2 characters are
83
+ typed in.
84
+ </p>
85
+ <label for="autocomplete-minLength">Country</label>
86
+ <div id="tt-minLength" class="autocomplete-wrapper"></div>
87
+
88
+ <h3><code>{ displayMenu: 'overlay' }</code></h3>
89
+ <p>This option will display the menu as an absolutely positioned overlay.</p>
90
+ <label for="autocomplete-overlay">Country</label>
91
+ <div id="tt-overlay" class="autocomplete-wrapper"></div>
92
+
93
+ <h3><code>{ autoselect: true }</code></h3>
94
+ <p>This option will automatically select the first suggestion.</p>
95
+ <label for="autocomplete-autoselect">Country</label>
96
+ <div id="tt-autoselect" class="autocomplete-wrapper"></div>
97
+
98
+ <h3><code>{ defaultValue: 'Germany' }</code></h3>
99
+ <p>This option will prefill the input with a value.</p>
100
+ <label for="autocomplete-defaultValue">Country</label>
101
+ <div id="tt-defaultValue" class="autocomplete-wrapper"></div>
102
+
103
+ <h3><code>{ confirmOnBlur: false }</code></h3>
104
+ <p>
105
+ This option will toggle automatically confirming a selection on blur. In the other
106
+ examples, if you select an option using the arrow keys and then click out, it will
107
+ confirm the selection.
108
+ </p>
109
+ <label for="autocomplete-confirmOnBlur">Country</label>
110
+ <div id="tt-confirmOnBlur" class="autocomplete-wrapper"></div>
111
+
112
+ <h3><code>{ placeholder: 'Search for a country' }</code></h3>
113
+ <p>This option will populate the placeholder attribute on the input element.</p>
114
+ <label for="autocomplete-placeholder">Country</label>
115
+ <div id="tt-placeholder" class="autocomplete-wrapper"></div>
116
+
117
+ <h3><code>{ showNoOptionsFound: false }</code></h3>
118
+ <p>This option will toggle displaying the "No results found" message.</p>
119
+ <label for="autocomplete-showNoOptionsFound">Country</label>
120
+ <div id="tt-showNoOptionsFound" class="autocomplete-wrapper"></div>
121
+
122
+ <h3><code>{ showAllValues: true }</code></h3>
123
+ <p>
124
+ This option will toggle showing all values when the input is clicked, like a
125
+ default dropdown.
126
+ </p>
127
+ <label for="autocomplete-showAllValues">Country</label>
128
+ <div id="tt-showAllValues" class="autocomplete-wrapper"></div>
129
+
130
+ <h3><code>{ showAllValues: true, dropdownArrow: () => '' }</code></h3>
131
+ <p>
132
+ When <code>showAllValues</code> is <code>true</code> a dropdown arrow
133
+ will be displayed. It can be customized using a function that receives a
134
+ `{ className: string }` object and returns a string or (P)React component.
135
+ </p>
136
+ <label for="autocomplete-customDropdownArrow">Country</label>
137
+ <div id="tt-customDropdownArrow" class="autocomplete-wrapper"></div>
138
+
139
+ <h3><code>{ inputClasses: 'app-input'}</code></h3>
140
+ <p>
141
+ The classes provided in <code>inputClasses</code> are added to
142
+ the component's <code>&lt;input&gt;</code>.
143
+ </p>
144
+ <label for="autocomplete-inputClasses">Country</label>
145
+ <div id="tt-inputClasses" class="autocomplete-wrapper"></div>
146
+
147
+ <h3><code>{ hintClasses: 'app-hint'}</code></h3>
148
+ <p>
149
+ The classes provided in <code>hintClasses</code> are added to
150
+ the component's hint that appears when the value matches the start of a suggestion.
151
+ </p>
152
+ <label for="autocomplete-hintClasses">Country</label>
153
+ <div id="tt-hintClasses" class="autocomplete-wrapper"></div>
154
+
155
+ <h3><code>{ menuClasses: 'custom-menu-class'}</code></h3>
156
+ <p>
157
+ The classes provided in <code>menuClasses</code> are added to
158
+ the menu displaying the suggestions.
159
+ </p>
160
+ <label for="autocomplete-menuClasses">Country</label>
161
+ <div id="tt-menuClasses" class="autocomplete-wrapper"></div>
162
+
163
+ <h2>Advanced features</h2>
164
+
165
+ <h3>Progressive enhancement</h3>
166
+ <p>
167
+ This example demonstrates how to turn a server-rendered <code>&lt;select&gt;</code> element
168
+ into a autocomplete. Turn off JavaScript to see the <code>&lt;select&gt;</code> element.
169
+ </p>
170
+ <p>Uses <code>accessibleAutocomplete.enhanceSelectElement</code>.</p>
171
+ <label for="autocomplete-progressiveEnhancement">Country</label>
172
+ <div class="autocomplete-wrapper">
173
+ <select id="autocomplete-progressiveEnhancement">
174
+ <option value="fr">France</option>
175
+ <option value="de">Germany</option>
176
+ <option value="gb" selected>United Kingdom</option>
177
+ </select>
178
+ </div>
179
+
180
+ <h3>Custom results</h3>
181
+ <p>
182
+ <p>This example demonstrates how to allow users to search for a country by either:</p>
183
+ <ul>
184
+ <li>its English name</li>
185
+ <li>the name by which a group of people refer to their country</li>
186
+ </ul>
187
+ <p>The suggestions are user-defined objects and they are displayed using a user-defined template. Confirming a suggestion will populate the input with the English country name.</p>
188
+ </p>
189
+ <p>Uses the <code>{ templates: { inputValue, suggestion } }</code> options.</p>
190
+ <label for="autocomplete-customTemplates">Country</label>
191
+ <div id="tt-customTemplates" class="autocomplete-wrapper"></div>
192
+
193
+ <h3>Translating texts</h3>
194
+ <p>
195
+ This example demonstrates how to translate the texts emitted by the component.
196
+ </p>
197
+ <p>Uses the <code>{ tStatusQueryTooShort: (minQueryLength) => '',
198
+ tStatusNoResults: () => '',
199
+ tStatusSelectedOption: (selectedOption, length) => '',
200
+ tStatusResults: () => '' }</code> options.</p>
201
+ <label for="autocomplete-i18n">Country</label>
202
+ <div id="tt-i18n" class="autocomplete-wrapper"></div>
203
+ </main>
204
+
205
+ <script type="text/javascript" src="../dist/accessible-autocomplete.min.js"></script>
206
+ <script type="text/javascript">
207
+ var countries = [
208
+ 'Afghanistan',
209
+ 'Akrotiri',
210
+ 'Albania',
211
+ 'Algeria',
212
+ 'American Samoa',
213
+ 'Andorra',
214
+ 'Angola',
215
+ 'Anguilla',
216
+ 'Antarctica',
217
+ 'Antigua and Barbuda',
218
+ 'Argentina',
219
+ 'Armenia',
220
+ 'Aruba',
221
+ 'Ashmore and Cartier Islands',
222
+ 'Australia',
223
+ 'Austria',
224
+ 'Azerbaijan',
225
+ 'Bahamas, The',
226
+ 'Bahrain',
227
+ 'Bangladesh',
228
+ 'Barbados',
229
+ 'Bassas da India',
230
+ 'Belarus',
231
+ 'Belgium',
232
+ 'Belize',
233
+ 'Benin',
234
+ 'Bermuda',
235
+ 'Bhutan',
236
+ 'Bolivia',
237
+ 'Bosnia and Herzegovina',
238
+ 'Botswana',
239
+ 'Bouvet Island',
240
+ 'Brazil',
241
+ 'British Indian Ocean Territory',
242
+ 'British Virgin Islands',
243
+ 'Brunei',
244
+ 'Bulgaria',
245
+ 'Burkina Faso',
246
+ 'Burma',
247
+ 'Burundi',
248
+ 'Cambodia',
249
+ 'Cameroon',
250
+ 'Canada',
251
+ 'Cape Verde',
252
+ 'Cayman Islands',
253
+ 'Central African Republic',
254
+ 'Chad',
255
+ 'Chile',
256
+ 'China',
257
+ 'Christmas Island',
258
+ 'Clipperton Island',
259
+ 'Cocos (Keeling) Islands',
260
+ 'Colombia',
261
+ 'Comoros',
262
+ 'Congo',
263
+ 'Cook Islands',
264
+ 'Coral Sea Islands',
265
+ 'Costa Rica',
266
+ 'Cote d\'Ivoire',
267
+ 'Croatia',
268
+ 'Cuba',
269
+ 'Cyprus',
270
+ 'Czech Republic',
271
+ 'Denmark',
272
+ 'Dhekelia',
273
+ 'Djibouti',
274
+ 'Dominica',
275
+ 'Dominican Republic',
276
+ 'Ecuador',
277
+ 'Egypt',
278
+ 'El Salvador',
279
+ 'Equatorial Guinea',
280
+ 'Eritrea',
281
+ 'Estonia',
282
+ 'Ethiopia',
283
+ 'Europa Island',
284
+ 'Falkland Islands',
285
+ 'Faroe Islands',
286
+ 'Fiji',
287
+ 'Finland',
288
+ 'France',
289
+ 'French Guiana',
290
+ 'French Polynesia',
291
+ 'French Southern and Antarctic Lands',
292
+ 'Gabon',
293
+ 'Gambia,',
294
+ 'Gaza Strip',
295
+ 'Georgia',
296
+ 'Germany',
297
+ 'Ghana',
298
+ 'Gibraltar',
299
+ 'Glorioso Islands',
300
+ 'Greece',
301
+ 'Greenland',
302
+ 'Grenada',
303
+ 'Guadeloupe',
304
+ 'Guam',
305
+ 'Guatemala',
306
+ 'Guernsey',
307
+ 'Guinea',
308
+ 'Guinea-Bissau',
309
+ 'Guyana',
310
+ 'Haiti',
311
+ 'Heard Island and McDonald Islands',
312
+ 'Holy See (Vatican City)',
313
+ 'Honduras',
314
+ 'Hong Kong',
315
+ 'Hungary',
316
+ 'Iceland',
317
+ 'India',
318
+ 'Indonesia',
319
+ 'Iran',
320
+ 'Iraq',
321
+ 'Ireland',
322
+ 'Isle of Man',
323
+ 'Israel',
324
+ 'Italy',
325
+ 'Jamaica',
326
+ 'Jan Mayen',
327
+ 'Japan',
328
+ 'Jersey',
329
+ 'Jordan',
330
+ 'Juan de Nova Island',
331
+ 'Kazakhstan',
332
+ 'Kenya',
333
+ 'Kiribati',
334
+ 'Korea, North',
335
+ 'Korea, South',
336
+ 'Kuwait',
337
+ 'Kyrgyzstan',
338
+ 'Laos',
339
+ 'Latvia',
340
+ 'Lebanon',
341
+ 'Lesotho',
342
+ 'Liberia',
343
+ 'Libya',
344
+ 'Liechtenstein',
345
+ 'Lithuania',
346
+ 'Luxembourg',
347
+ 'Macau',
348
+ 'Macedonia',
349
+ 'Madagascar',
350
+ 'Malawi',
351
+ 'Malaysia',
352
+ 'Maldives',
353
+ 'Mali',
354
+ 'Malta',
355
+ 'Marshall Islands',
356
+ 'Martinique',
357
+ 'Mauritania',
358
+ 'Mauritius',
359
+ 'Mayotte',
360
+ 'Mexico',
361
+ 'Micronesia, Federated States of',
362
+ 'Moldova',
363
+ 'Monaco',
364
+ 'Mongolia',
365
+ 'Montserrat',
366
+ 'Morocco',
367
+ 'Mozambique',
368
+ 'Namibia',
369
+ 'Nauru',
370
+ 'Navassa Island',
371
+ 'Nepal',
372
+ 'Netherlands',
373
+ 'Netherlands Antilles',
374
+ 'New Caledonia',
375
+ 'New Zealand',
376
+ 'Nicaragua',
377
+ 'Niger',
378
+ 'Nigeria',
379
+ 'Niue',
380
+ 'Norfolk Island',
381
+ 'Northern Mariana Islands',
382
+ 'Norway',
383
+ 'Oman',
384
+ 'Pakistan',
385
+ 'Palau',
386
+ 'Panama',
387
+ 'Papua New Guinea',
388
+ 'Paracel Islands',
389
+ 'Paraguay',
390
+ 'Peru',
391
+ 'Philippines',
392
+ 'Pitcairn Islands',
393
+ 'Poland',
394
+ 'Portugal',
395
+ 'Puerto Rico',
396
+ 'Qatar',
397
+ 'Reunion',
398
+ 'Romania',
399
+ 'Russia',
400
+ 'Rwanda',
401
+ 'Saint Helena',
402
+ 'Saint Kitts and Nevis',
403
+ 'Saint Lucia',
404
+ 'Saint Pierre and Miquelon',
405
+ 'Saint Vincent and the Grenadines',
406
+ 'Samoa',
407
+ 'San Marino',
408
+ 'Sao Tome and Principe',
409
+ 'Saudi Arabia',
410
+ 'Senegal',
411
+ 'Serbia and Montenegro',
412
+ 'Seychelles',
413
+ 'Sierra Leone',
414
+ 'Singapore',
415
+ 'Slovakia',
416
+ 'Slovenia',
417
+ 'Solomon Islands',
418
+ 'Somalia',
419
+ 'South Africa',
420
+ 'South Georgia and the South Sandwich Islands',
421
+ 'Spain',
422
+ 'Spratly Islands',
423
+ 'Sri Lanka',
424
+ 'Sudan',
425
+ 'Suriname',
426
+ 'Svalbard',
427
+ 'Swaziland',
428
+ 'Sweden',
429
+ 'Switzerland',
430
+ 'Syria',
431
+ 'Taiwan',
432
+ 'Tajikistan',
433
+ 'Tanzania',
434
+ 'Thailand',
435
+ 'Timor-Leste',
436
+ 'Togo',
437
+ 'Tokelau',
438
+ 'Tonga',
439
+ 'Trinidad and Tobago',
440
+ 'Tromelin Island',
441
+ 'Tunisia',
442
+ 'Turkey',
443
+ 'Turkmenistan',
444
+ 'Turks and Caicos Islands',
445
+ 'Tuvalu',
446
+ 'Uganda',
447
+ 'Ukraine',
448
+ 'United Arab Emirates',
449
+ 'United Kingdom',
450
+ 'United States',
451
+ 'Uruguay',
452
+ 'Uzbekistan',
453
+ 'Vanuatu',
454
+ 'Venezuela',
455
+ 'Vietnam',
456
+ 'Virgin Islands',
457
+ 'Wake Island',
458
+ 'Wallis and Futuna',
459
+ 'West Bank',
460
+ 'Western Sahara',
461
+ 'Yemen',
462
+ 'Zambia',
463
+ 'Zimbabwe'
464
+ ]
465
+ </script>
466
+
467
+ <script type="text/javascript">
468
+ var element = document.querySelector('#tt-default')
469
+ var id = 'autocomplete-default'
470
+ accessibleAutocomplete({
471
+ element: element,
472
+ id: id,
473
+ source: countries,
474
+ menuAttributes: {
475
+ "aria-labelledby": id
476
+ }
477
+ })
478
+ </script>
479
+
480
+ <script type="text/javascript">
481
+ element = document.querySelector('#tt-minLength')
482
+ id = 'autocomplete-minLength'
483
+ accessibleAutocomplete({
484
+ element: element,
485
+ id: id,
486
+ minLength: 2,
487
+ source: countries,
488
+ menuAttributes: {
489
+ "aria-labelledby": id
490
+ }
491
+ })
492
+ </script>
493
+
494
+ <script type="text/javascript">
495
+ element = document.querySelector('#tt-autoselect')
496
+ id = 'autocomplete-autoselect'
497
+ accessibleAutocomplete({
498
+ autoselect: true,
499
+ element: element,
500
+ id: id,
501
+ source: countries,
502
+ menuAttributes: {
503
+ "aria-labelledby": id
504
+ }
505
+ })
506
+ </script>
507
+
508
+ <script type="text/javascript">
509
+ element = document.querySelector('#tt-overlay')
510
+ id = 'autocomplete-overlay'
511
+ accessibleAutocomplete({
512
+ displayMenu: 'overlay',
513
+ element: element,
514
+ id: id,
515
+ source: countries,
516
+ menuAttributes: {
517
+ "aria-labelledby": id
518
+ }
519
+ })
520
+ </script>
521
+
522
+ <script type="text/javascript">
523
+ element = document.querySelector('#tt-defaultValue')
524
+ id = 'autocomplete-defaultValue'
525
+ accessibleAutocomplete({
526
+ defaultValue: 'Germany',
527
+ element: element,
528
+ id: id,
529
+ source: countries,
530
+ menuAttributes: {
531
+ "aria-labelledby": id
532
+ }
533
+ })
534
+ </script>
535
+
536
+ <script type="text/javascript">
537
+ element = document.querySelector('#tt-inputClasses')
538
+ id = 'autocomplete-inputClasses'
539
+ accessibleAutocomplete({
540
+ element: element,
541
+ id: id,
542
+ source: countries,
543
+ menuAttributes: {
544
+ "aria-labelledby": id
545
+ },
546
+ autoselect: true,
547
+ inputClasses: 'app-input'
548
+ })
549
+ </script>
550
+
551
+ <script type="text/javascript">
552
+ element = document.querySelector('#tt-hintClasses')
553
+ id = 'autocomplete-hintClasses'
554
+ accessibleAutocomplete({
555
+ element: element,
556
+ id: id,
557
+ source: countries,
558
+ menuAttributes: {
559
+ "aria-labelledby": id
560
+ },
561
+ autoselect: true,
562
+ hintClasses: 'app-hint'
563
+ })
564
+ </script>
565
+
566
+ <script type="text/javascript">
567
+ element = document.querySelector('#tt-menuClasses')
568
+ id = 'autocomplete-menuClasses'
569
+ accessibleAutocomplete({
570
+ element: element,
571
+ id: id,
572
+ source: countries,
573
+ menuAttributes: {
574
+ "aria-labelledby": id
575
+ },
576
+ autoselect: true,
577
+ menuClasses: 'custom-menu-class'
578
+ })
579
+ </script>
580
+
581
+ <script type="text/javascript">
582
+ element = document.querySelector('#autocomplete-progressiveEnhancement')
583
+ accessibleAutocomplete.enhanceSelectElement({
584
+ selectElement: element
585
+ })
586
+ </script>
587
+
588
+ <script type="text/javascript">
589
+ function customSuggest (query, syncResults) {
590
+ var results = [
591
+ { endonymLang: 'fr', endonym: 'République Française', name: 'France' },
592
+ { endonymLang: 'de', endonym: 'Deutschland', name: 'Germany' },
593
+ { endonymLang: 'en', endonym: 'Great Britain', name: 'United Kingdom' }
594
+ ]
595
+ syncResults(query
596
+ ? results.filter(function (result) {
597
+ var resultContains = result.name.toLowerCase().indexOf(query.toLowerCase()) !== -1
598
+ var endonymContains = result.endonym.toLowerCase().indexOf(query.toLowerCase()) !== -1
599
+ return resultContains || endonymContains
600
+ })
601
+ : []
602
+ )
603
+ }
604
+
605
+ function inputValueTemplate (result) {
606
+ return result && result.name
607
+ }
608
+
609
+ function suggestionTemplate (result) {
610
+ return result && '<strong>' + result.name + '</strong>' +
611
+ ' (<span lang=' + result.endonymLang + '>' + result.endonym + '</span>)'
612
+ }
613
+
614
+ element = document.querySelector('#tt-customTemplates')
615
+ id = 'autocomplete-customTemplates'
616
+ accessibleAutocomplete({
617
+ element: element,
618
+ id: id,
619
+ source: customSuggest,
620
+ menuAttributes: {
621
+ "aria-labelledby": id
622
+ },
623
+ templates: {
624
+ inputValue: inputValueTemplate,
625
+ suggestion: suggestionTemplate
626
+ }
627
+ })
628
+ </script>
629
+
630
+ <script type="text/javascript">
631
+ element = document.querySelector('#tt-confirmOnBlur')
632
+ id = 'autocomplete-confirmOnBlur'
633
+ accessibleAutocomplete({
634
+ element: element,
635
+ id: id,
636
+ confirmOnBlur: false,
637
+ source: countries,
638
+ menuAttributes: {
639
+ "aria-labelledby": id
640
+ }
641
+ })
642
+ </script>
643
+
644
+ <script type="text/javascript">
645
+ element = document.querySelector('#tt-placeholder')
646
+ id = 'autocomplete-placeholder'
647
+ accessibleAutocomplete({
648
+ element: element,
649
+ id: id,
650
+ placeholder: 'Search for a country',
651
+ source: countries,
652
+ menuAttributes: {
653
+ "aria-labelledby": id
654
+ }
655
+ })
656
+ </script>
657
+
658
+ <script type="text/javascript">
659
+ element = document.querySelector('#tt-showNoOptionsFound')
660
+ id = 'autocomplete-showNoOptionsFound'
661
+ accessibleAutocomplete({
662
+ element: element,
663
+ id: id,
664
+ showNoOptionsFound: false,
665
+ source: countries,
666
+ menuAttributes: {
667
+ "aria-labelledby": id
668
+ }
669
+ })
670
+ </script>
671
+
672
+ <script type="text/javascript">
673
+ element = document.querySelector('#tt-showAllValues')
674
+ id = 'autocomplete-showAllValues'
675
+ accessibleAutocomplete({
676
+ element: element,
677
+ id: id,
678
+ showAllValues: true,
679
+ source: countries,
680
+ menuAttributes: {
681
+ "aria-labelledby": id
682
+ }
683
+ })
684
+ </script>
685
+
686
+ <script type="text/javascript">
687
+ element = document.querySelector('#tt-i18n')
688
+ id = 'autocomplete-i18n'
689
+ accessibleAutocomplete({
690
+ element: element,
691
+ id: id,
692
+ showAllValues: false,
693
+ menuAttributes: {
694
+ "aria-labelledby": id
695
+ },
696
+ source: countries,
697
+ tStatusQueryTooShort: function (minQueryLength) {
698
+ return 'Tippe mindestens ' + minQueryLength + ' Zeichen ein für Resultate.'
699
+ },
700
+ tStatusNoResults: function () {
701
+ return 'Keine Resultate.'
702
+ },
703
+ tStatusSelectedOption: function (selectedOption, length) {
704
+ return selectedOption + ' (1 von ' + length + ') ist ausgewählt.'
705
+ },
706
+ tStatusResults: function (length, contentSelectedOption) {
707
+ var words = {
708
+ result: (length === 1) ? 'Resultat' : 'Resultate',
709
+ is: (length === 1) ? 'ist' : 'sind'
710
+ }
711
+
712
+ return length + ' ' + words.result + ' ' + words.is + ' verfügbar. ' + contentSelectedOption
713
+ },
714
+ tNoResults: function () {
715
+ return 'Keine Resultate'
716
+ }
717
+ })
718
+ </script>
719
+
720
+ <script type="text/javascript">
721
+ element = document.querySelector('#tt-customDropdownArrow')
722
+ id = 'autocomplete-customDropdownArrow'
723
+ accessibleAutocomplete({
724
+ element: element,
725
+ id: id,
726
+ showAllValues: true,
727
+ source: countries,
728
+ menuAttributes: {
729
+ "aria-labelledby": id
730
+ },
731
+ dropdownArrow: function (config) {
732
+ return '<svg class="' + config.className + '" style="top: 8px;" viewBox="0 0 512 512" ><path d="M256,298.3L256,298.3L256,298.3l174.2-167.2c4.3-4.2,11.4-4.1,15.8,0.2l30.6,29.9c4.4,4.3,4.5,11.3,0.2,15.5L264.1,380.9 c-2.2,2.2-5.2,3.2-8.1,3c-3,0.1-5.9-0.9-8.1-3L35.2,176.7c-4.3-4.2-4.2-11.2,0.2-15.5L66,131.3c4.4-4.3,11.5-4.4,15.8-0.2L256,298.3 z"/></svg>'
733
+ }
734
+ })
735
+ </script>
736
+
737
+ </body>
738
+ </html>