@radarlabs/plugin-autocomplete 5.0.0-beta.5 → 5.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/radar-autocomplete.js +114 -22
- package/cdn/radar-autocomplete.min.js +1 -1
- package/dist/autocomplete.d.ts +94 -6
- package/dist/errors.d.ts +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +114 -22
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +32 -5
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/autocomplete.ts +114 -32
- package/src/errors.ts +1 -0
- package/src/index.ts +11 -0
- package/src/types.ts +40 -13
- package/src/version.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RadarError } from 'radar-sdk-js';
|
|
2
2
|
|
|
3
|
+
/** error thrown when the autocomplete container element is not found in the DOM */
|
|
3
4
|
class RadarAutocompleteContainerNotFound extends RadarError {
|
|
4
5
|
constructor(message) {
|
|
5
6
|
super(message);
|
|
@@ -64,6 +65,7 @@ const getMarkerIcon = (color = "#ACBDC8") => {
|
|
|
64
65
|
</svg>`.trim();
|
|
65
66
|
return `data:image/svg+xml;charset=utf-8,${svg}`;
|
|
66
67
|
};
|
|
68
|
+
/** address autocomplete UI widget with keyboard navigation and result display */
|
|
67
69
|
class AutocompleteUI {
|
|
68
70
|
constructor(options, ctx) {
|
|
69
71
|
this.ctx = ctx;
|
|
@@ -71,7 +73,7 @@ class AutocompleteUI {
|
|
|
71
73
|
this.config = Object.assign({}, defaultAutocompleteOptions, options);
|
|
72
74
|
// setup state
|
|
73
75
|
this.isOpen = false;
|
|
74
|
-
this.debouncedFetchResults = this.debounce(this.fetchResults, this.config.debounceMS);
|
|
76
|
+
this.debouncedFetchResults = this.debounce(this.fetchResults.bind(this), this.config.debounceMS);
|
|
75
77
|
this.results = [];
|
|
76
78
|
this.highlightedIndex = -1;
|
|
77
79
|
// set threshold alias
|
|
@@ -118,7 +120,7 @@ class AutocompleteUI {
|
|
|
118
120
|
this.inputField = containerEL;
|
|
119
121
|
// append to dom
|
|
120
122
|
this.wrapper.appendChild(this.resultsList);
|
|
121
|
-
containerEL.parentNode
|
|
123
|
+
containerEL.parentNode?.appendChild(this.wrapper);
|
|
122
124
|
}
|
|
123
125
|
else {
|
|
124
126
|
// if container is not an input, create new input and append to container
|
|
@@ -154,6 +156,7 @@ class AutocompleteUI {
|
|
|
154
156
|
}
|
|
155
157
|
Logger.debug('AutocompleteUI initialized with options', this.config);
|
|
156
158
|
}
|
|
159
|
+
/** handle input field changes and trigger debounced search */
|
|
157
160
|
handleInput() {
|
|
158
161
|
const { Logger } = this.ctx;
|
|
159
162
|
// Fetch autocomplete results and display them
|
|
@@ -179,25 +182,18 @@ class AutocompleteUI {
|
|
|
179
182
|
}
|
|
180
183
|
debounce(fn, delay) {
|
|
181
184
|
let timeoutId;
|
|
182
|
-
let resolveFn;
|
|
183
|
-
let rejectFn;
|
|
185
|
+
let resolveFn = null;
|
|
186
|
+
let rejectFn = null;
|
|
184
187
|
return (...args) => {
|
|
185
188
|
clearTimeout(timeoutId);
|
|
186
189
|
timeoutId = setTimeout(() => {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
})
|
|
195
|
-
.catch((error) => {
|
|
196
|
-
if (rejectFn) {
|
|
197
|
-
rejectFn(error);
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
}
|
|
190
|
+
fn(...args)
|
|
191
|
+
.then((value) => {
|
|
192
|
+
resolveFn?.(value);
|
|
193
|
+
})
|
|
194
|
+
.catch((error) => {
|
|
195
|
+
rejectFn?.(error);
|
|
196
|
+
});
|
|
201
197
|
}, delay);
|
|
202
198
|
return new Promise((resolve, reject) => {
|
|
203
199
|
resolveFn = resolve;
|
|
@@ -205,6 +201,11 @@ class AutocompleteUI {
|
|
|
205
201
|
});
|
|
206
202
|
};
|
|
207
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* fetch autocomplete results from the Radar API
|
|
206
|
+
* @param query - the search query string
|
|
207
|
+
* @returns matching addresses
|
|
208
|
+
*/
|
|
208
209
|
async fetchResults(query) {
|
|
209
210
|
const { apis } = this.ctx;
|
|
210
211
|
const { limit, layers, countryCode, expandUnits, mailable, lang, postalCode, onRequest } = this.config;
|
|
@@ -227,6 +228,10 @@ class AutocompleteUI {
|
|
|
227
228
|
const { addresses } = await apis.Search.autocomplete(params, 'autocomplete-ui');
|
|
228
229
|
return addresses;
|
|
229
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* render autocomplete results in the dropdown
|
|
233
|
+
* @param results - array of address results to display
|
|
234
|
+
*/
|
|
230
235
|
displayResults(results) {
|
|
231
236
|
// Clear the previous results
|
|
232
237
|
this.clearResultsList();
|
|
@@ -245,7 +250,7 @@ class AutocompleteUI {
|
|
|
245
250
|
li.setAttribute('id', `${CLASSNAMES.RESULTS_ITEM}}-${index}`);
|
|
246
251
|
// construct result with bolded label
|
|
247
252
|
let listContent;
|
|
248
|
-
if (result.formattedAddress
|
|
253
|
+
if (result.formattedAddress?.includes(result.addressLabel) && result.layer !== 'postalCode') {
|
|
249
254
|
// if addressLabel is contained in the formatted address, bold the address label
|
|
250
255
|
const regex = new RegExp(`(${result.addressLabel}),?`);
|
|
251
256
|
listContent = result.formattedAddress.replace(regex, '<b>$1</b>');
|
|
@@ -291,6 +296,7 @@ class AutocompleteUI {
|
|
|
291
296
|
this.resultsList.appendChild(noResultsText);
|
|
292
297
|
}
|
|
293
298
|
}
|
|
299
|
+
/** open the results dropdown */
|
|
294
300
|
open() {
|
|
295
301
|
if (this.isOpen) {
|
|
296
302
|
return;
|
|
@@ -299,6 +305,7 @@ class AutocompleteUI {
|
|
|
299
305
|
this.resultsList.removeAttribute('hidden');
|
|
300
306
|
this.isOpen = true;
|
|
301
307
|
}
|
|
308
|
+
/** close the results dropdown and clear highlighted state */
|
|
302
309
|
close(e) {
|
|
303
310
|
if (!this.isOpen) {
|
|
304
311
|
return;
|
|
@@ -315,6 +322,10 @@ class AutocompleteUI {
|
|
|
315
322
|
this.clearResultsList();
|
|
316
323
|
}, linkClick ? 100 : 0);
|
|
317
324
|
}
|
|
325
|
+
/**
|
|
326
|
+
* highlight a result by index with wrap-around navigation
|
|
327
|
+
* @param index - the result index to highlight
|
|
328
|
+
*/
|
|
318
329
|
goTo(index) {
|
|
319
330
|
if (!this.isOpen || !this.results.length) {
|
|
320
331
|
return;
|
|
@@ -369,6 +380,10 @@ class AutocompleteUI {
|
|
|
369
380
|
break;
|
|
370
381
|
}
|
|
371
382
|
}
|
|
383
|
+
/**
|
|
384
|
+
* select a result by index and populate the input field
|
|
385
|
+
* @param index - the result index to select
|
|
386
|
+
*/
|
|
372
387
|
select(index) {
|
|
373
388
|
const { Logger } = this.ctx;
|
|
374
389
|
const result = this.results[index];
|
|
@@ -377,7 +392,7 @@ class AutocompleteUI {
|
|
|
377
392
|
return;
|
|
378
393
|
}
|
|
379
394
|
let inputValue;
|
|
380
|
-
if (result.formattedAddress
|
|
395
|
+
if (result.formattedAddress?.includes(result.addressLabel)) {
|
|
381
396
|
inputValue = result.formattedAddress;
|
|
382
397
|
}
|
|
383
398
|
else {
|
|
@@ -392,11 +407,12 @@ class AutocompleteUI {
|
|
|
392
407
|
// clear results list
|
|
393
408
|
this.close();
|
|
394
409
|
}
|
|
410
|
+
/** clear the results list DOM and reset results array */
|
|
395
411
|
clearResultsList() {
|
|
396
412
|
this.resultsList.innerHTML = '';
|
|
397
413
|
this.results = [];
|
|
398
414
|
}
|
|
399
|
-
|
|
415
|
+
/** remove the autocomplete widget from the DOM */
|
|
400
416
|
remove() {
|
|
401
417
|
const { Logger } = this.ctx;
|
|
402
418
|
Logger.debug('AutocompleteUI removed.');
|
|
@@ -404,6 +420,11 @@ class AutocompleteUI {
|
|
|
404
420
|
this.resultsList.remove();
|
|
405
421
|
this.wrapper.remove();
|
|
406
422
|
}
|
|
423
|
+
/**
|
|
424
|
+
* set the `near` location bias for autocomplete requests
|
|
425
|
+
* @param near - location string, Location object, or null to clear
|
|
426
|
+
* @returns this instance for chaining
|
|
427
|
+
*/
|
|
407
428
|
setNear(near) {
|
|
408
429
|
if (near === undefined || near === null) {
|
|
409
430
|
this.near = undefined;
|
|
@@ -416,21 +437,41 @@ class AutocompleteUI {
|
|
|
416
437
|
}
|
|
417
438
|
return this;
|
|
418
439
|
}
|
|
440
|
+
/**
|
|
441
|
+
* set the input placeholder text
|
|
442
|
+
* @param placeholder - new placeholder string
|
|
443
|
+
* @returns this instance for chaining
|
|
444
|
+
*/
|
|
419
445
|
setPlaceholder(placeholder) {
|
|
420
446
|
this.config.placeholder = placeholder;
|
|
421
447
|
this.inputField.placeholder = placeholder;
|
|
422
448
|
return this;
|
|
423
449
|
}
|
|
450
|
+
/**
|
|
451
|
+
* set the disabled state of the input
|
|
452
|
+
* @param disabled - whether to disable the input
|
|
453
|
+
* @returns this instance for chaining
|
|
454
|
+
*/
|
|
424
455
|
setDisabled(disabled) {
|
|
425
456
|
this.config.disabled = disabled;
|
|
426
457
|
this.inputField.disabled = disabled;
|
|
427
458
|
return this;
|
|
428
459
|
}
|
|
460
|
+
/**
|
|
461
|
+
* toggle responsive width mode
|
|
462
|
+
* @param responsive - whether to use responsive layout
|
|
463
|
+
* @returns this instance for chaining
|
|
464
|
+
*/
|
|
429
465
|
setResponsive(responsive) {
|
|
430
466
|
this.config.responsive = responsive;
|
|
431
467
|
setWidth(this.wrapper, this.config);
|
|
432
468
|
return this;
|
|
433
469
|
}
|
|
470
|
+
/**
|
|
471
|
+
* set the widget width
|
|
472
|
+
* @param width - width in px, CSS string, or null to reset
|
|
473
|
+
* @returns this instance for chaining
|
|
474
|
+
*/
|
|
434
475
|
setWidth(width) {
|
|
435
476
|
if (width === null) {
|
|
436
477
|
this.config.width = undefined;
|
|
@@ -441,6 +482,11 @@ class AutocompleteUI {
|
|
|
441
482
|
setWidth(this.wrapper, this.config);
|
|
442
483
|
return this;
|
|
443
484
|
}
|
|
485
|
+
/**
|
|
486
|
+
* set the max height of the results dropdown
|
|
487
|
+
* @param height - height in px, CSS string, or null to reset
|
|
488
|
+
* @returns this instance for chaining
|
|
489
|
+
*/
|
|
444
490
|
setMaxHeight(height) {
|
|
445
491
|
if (height === null) {
|
|
446
492
|
this.config.maxHeight = undefined;
|
|
@@ -451,15 +497,30 @@ class AutocompleteUI {
|
|
|
451
497
|
setHeight(this.resultsList, this.config);
|
|
452
498
|
return this;
|
|
453
499
|
}
|
|
500
|
+
/**
|
|
501
|
+
* set the minimum character count to trigger autocomplete
|
|
502
|
+
* @param minCharacters - character threshold
|
|
503
|
+
* @returns this instance for chaining
|
|
504
|
+
*/
|
|
454
505
|
setMinCharacters(minCharacters) {
|
|
455
506
|
this.config.minCharacters = minCharacters;
|
|
456
507
|
this.config.threshold = minCharacters;
|
|
457
508
|
return this;
|
|
458
509
|
}
|
|
510
|
+
/**
|
|
511
|
+
* set the maximum number of results
|
|
512
|
+
* @param limit - result count limit
|
|
513
|
+
* @returns this instance for chaining
|
|
514
|
+
*/
|
|
459
515
|
setLimit(limit) {
|
|
460
516
|
this.config.limit = limit;
|
|
461
517
|
return this;
|
|
462
518
|
}
|
|
519
|
+
/**
|
|
520
|
+
* set the language for autocomplete results
|
|
521
|
+
* @param lang - language code or null to clear
|
|
522
|
+
* @returns this instance for chaining
|
|
523
|
+
*/
|
|
463
524
|
setLang(lang) {
|
|
464
525
|
if (lang === null) {
|
|
465
526
|
this.config.lang = undefined;
|
|
@@ -469,6 +530,11 @@ class AutocompleteUI {
|
|
|
469
530
|
}
|
|
470
531
|
return this;
|
|
471
532
|
}
|
|
533
|
+
/**
|
|
534
|
+
* set a postal code bias for autocomplete requests
|
|
535
|
+
* @param postalCode - postal code string or null to clear
|
|
536
|
+
* @returns this instance for chaining
|
|
537
|
+
*/
|
|
472
538
|
setPostalCode(postalCode) {
|
|
473
539
|
if (postalCode === null) {
|
|
474
540
|
this.config.postalCode = undefined;
|
|
@@ -478,6 +544,11 @@ class AutocompleteUI {
|
|
|
478
544
|
}
|
|
479
545
|
return this;
|
|
480
546
|
}
|
|
547
|
+
/**
|
|
548
|
+
* toggle marker icons in result items
|
|
549
|
+
* @param showMarkers - whether to show markers
|
|
550
|
+
* @returns this instance for chaining
|
|
551
|
+
*/
|
|
481
552
|
setShowMarkers(showMarkers) {
|
|
482
553
|
this.config.showMarkers = showMarkers;
|
|
483
554
|
if (showMarkers) {
|
|
@@ -503,6 +574,11 @@ class AutocompleteUI {
|
|
|
503
574
|
}
|
|
504
575
|
return this;
|
|
505
576
|
}
|
|
577
|
+
/**
|
|
578
|
+
* set the color of marker icons in result items
|
|
579
|
+
* @param color - CSS color string
|
|
580
|
+
* @returns this instance for chaining
|
|
581
|
+
*/
|
|
506
582
|
setMarkerColor(color) {
|
|
507
583
|
this.config.markerColor = color;
|
|
508
584
|
const marker = this.resultsList.getElementsByClassName(CLASSNAMES.RESULTS_MARKER);
|
|
@@ -511,6 +587,11 @@ class AutocompleteUI {
|
|
|
511
587
|
}
|
|
512
588
|
return this;
|
|
513
589
|
}
|
|
590
|
+
/**
|
|
591
|
+
* toggle hiding results when input loses focus
|
|
592
|
+
* @param hideResultsOnBlur - whether to hide on blur
|
|
593
|
+
* @returns this instance for chaining
|
|
594
|
+
*/
|
|
514
595
|
setHideResultsOnBlur(hideResultsOnBlur) {
|
|
515
596
|
this.config.hideResultsOnBlur = hideResultsOnBlur;
|
|
516
597
|
if (hideResultsOnBlur) {
|
|
@@ -523,8 +604,19 @@ class AutocompleteUI {
|
|
|
523
604
|
}
|
|
524
605
|
}
|
|
525
606
|
|
|
526
|
-
var version = '5.0.0-beta.
|
|
607
|
+
var version = '5.0.0-beta.6';
|
|
527
608
|
|
|
609
|
+
/**
|
|
610
|
+
* create the Radar autocomplete plugin
|
|
611
|
+
*
|
|
612
|
+
* @returns a plugin that adds `Radar.ui.autocomplete()` method
|
|
613
|
+
*
|
|
614
|
+
* @example
|
|
615
|
+
* ```ts
|
|
616
|
+
* import { createAutocompletePlugin } from '@radarlabs/plugin-autocomplete';
|
|
617
|
+
* Radar.registerPlugin(createAutocompletePlugin());
|
|
618
|
+
* ```
|
|
619
|
+
*/
|
|
528
620
|
function createAutocompletePlugin() {
|
|
529
621
|
return {
|
|
530
622
|
name: 'autocomplete',
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/errors.ts","../src/autocomplete.ts","../src/version.ts","../src/index.ts"],"sourcesContent":["import { RadarError } from 'radar-sdk-js';\n\nexport class RadarAutocompleteContainerNotFound extends RadarError {\n constructor(message: string) {\n super(message);\n this.name = 'RadarAutocompleteContainerNotFound';\n this.status = 'CONTAINER_NOT_FOUND';\n }\n}\n","import { RadarAutocompleteContainerNotFound } from './errors';\nimport type { RadarAutocompleteUIOptions, RadarAutocompleteConfig } from './types';\nimport type { RadarAutocompleteParams, Location, RadarPluginContext } from 'radar-sdk-js';\n\nconst CLASSNAMES = {\n WRAPPER: 'radar-autocomplete-wrapper',\n INPUT: 'radar-autocomplete-input',\n SEARCH_ICON: 'radar-autocomplete-search-icon',\n RESULTS_LIST: 'radar-autocomplete-results-list',\n RESULTS_ITEM: 'radar-autocomplete-results-item',\n RESULTS_MARKER: 'radar-autocomplete-results-marker',\n SELECTED_ITEM: 'radar-autocomplete-results-item-selected',\n POWERED_BY_RADAR: 'radar-powered',\n NO_RESULTS: 'radar-no-results',\n};\n\nconst defaultAutocompleteOptions: RadarAutocompleteUIOptions = {\n container: 'autocomplete',\n debounceMS: 200, // Debounce time in milliseconds\n minCharacters: 3, // Minimum number of characters to trigger autocomplete\n limit: 8, // Maximum number of autocomplete results\n placeholder: 'Search address', // Placeholder text for the input field\n responsive: true,\n disabled: false,\n showMarkers: true,\n hideResultsOnBlur: true,\n};\n\n// determine whether to use px or CSS string\nconst formatCSSValue = (value: string | number) => {\n if (typeof value === 'number') {\n return `${value}px`;\n }\n return value;\n};\n\nconst DEFAULT_WIDTH = 400;\nconst setWidth = (input: HTMLElement, options: RadarAutocompleteUIOptions) => {\n // if responsive and width is provided, treat it as maxWidth\n if (options.responsive) {\n input.style.width = '100%';\n if (options.width) {\n input.style.maxWidth = formatCSSValue(options.width);\n }\n return;\n }\n\n // if not responsive, set fixed width and unset maxWidth\n input.style.width = formatCSSValue(options.width || DEFAULT_WIDTH);\n input.style.removeProperty('max-width');\n};\n\nconst setHeight = (resultsList: HTMLElement, options: RadarAutocompleteUIOptions) => {\n if (options.maxHeight) {\n resultsList.style.maxHeight = formatCSSValue(options.maxHeight);\n resultsList.style.overflowY = 'auto'; /* allow overflow when maxHeight is applied */\n }\n};\n\nconst getMarkerIcon = (color: string = \"#ACBDC8\") => {\n const fill = color.replace('#', '%23');\n const svg = `<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M12.5704 6.57036C12.5704 4.11632 10.6342 2.11257 8.21016 2C8.14262 2 8.06757 2 8.00003 2C7.93249 2 7.85744 2 7.7899 2C5.35838 2.11257 3.42967 4.11632 3.42967 6.57036C3.42967 6.60037 3.42967 6.6379 3.42967 6.66792C3.42967 6.69794 3.42967 6.73546 3.42967 6.76548C3.42967 9.46717 7.09196 13.3621 7.4672 13.7598C7.61729 13.9174 7.84994 14 8.00003 14C8.15012 14 8.38277 13.9174 8.53286 13.7598C8.9156 13.3621 12.5704 9.46717 12.5704 6.76548C12.5704 6.72795 12.5704 6.69794 12.5704 6.66792C12.5704 6.6379 12.5704 6.60037 12.5704 6.57036ZM7.99252 8.28893C7.04693 8.28893 6.27395 7.52345 6.27395 6.57036C6.27395 5.61726 7.03943 4.85178 7.99252 4.85178C8.94562 4.85178 9.7111 5.61726 9.7111 6.57036C9.7111 7.52345 8.94562 8.28893 7.99252 8.28893Z\" fill=\"${fill}\"/>\n </svg>`.trim();\n return `data:image/svg+xml;charset=utf-8,${svg}`;\n};\n\n\nclass AutocompleteUI {\n private ctx: RadarPluginContext;\n config: RadarAutocompleteConfig;\n isOpen: boolean;\n results: any[];\n highlightedIndex: number;\n debouncedFetchResults: (...args: any[]) => Promise<any>;\n near?: string;\n\n // DOM elements\n container: HTMLElement;\n inputField: HTMLInputElement;\n resultsList: HTMLElement;\n wrapper: HTMLElement;\n poweredByLink?: HTMLElement;\n\n constructor(options: Partial<RadarAutocompleteUIOptions>, ctx: RadarPluginContext) {\n this.ctx = ctx;\n const { Logger } = this.ctx;\n this.config = Object.assign({}, defaultAutocompleteOptions, options) as RadarAutocompleteConfig;\n\n // setup state\n this.isOpen = false;\n this.debouncedFetchResults = this.debounce(this.fetchResults, this.config.debounceMS);\n this.results = [];\n this.highlightedIndex = -1;\n\n // set threshold alias\n if (this.config.threshold !== undefined) {\n this.config.minCharacters = this.config.threshold;\n Logger.warn('AutocompleteUI option \"threshold\" is deprecated, use \"minCharacters\" instead.');\n }\n\n if (options.near) {\n if (typeof options.near === 'string') {\n this.near = options.near;\n } else {\n this.near = `${options.near.latitude},${options.near.longitude}`;\n }\n }\n\n // get container element\n let containerEL;\n if (typeof this.config.container === 'string') { // lookup container element by ID\n containerEL = document.getElementById(this.config.container);\n } else { // use provided element\n containerEL = this.config.container; // HTMLElement\n }\n if (!containerEL) {\n throw new RadarAutocompleteContainerNotFound(`Could not find container element: ${this.config.container}`);\n }\n this.container = containerEL;\n\n // create wrapper for input and result list\n this.wrapper = document.createElement('div');\n this.wrapper.classList.add(CLASSNAMES.WRAPPER);\n this.wrapper.style.display = this.config.responsive ? 'block' : 'inline-block';\n setWidth(this.wrapper, this.config);\n\n // result list element\n this.resultsList = document.createElement('ul');\n this.resultsList.classList.add(CLASSNAMES.RESULTS_LIST);\n this.resultsList.setAttribute('id', CLASSNAMES.RESULTS_LIST);\n this.resultsList.setAttribute('role', 'listbox');\n this.resultsList.setAttribute('aria-live', 'polite');\n this.resultsList.setAttribute('aria-label', 'Search results');\n setHeight(this.resultsList, this.config);\n\n if (containerEL.nodeName === 'INPUT') {\n // if an <input> element is provided, use that as the inputField,\n // and append the resultList to it's parent container\n this.inputField = containerEL as HTMLInputElement;\n\n // append to dom\n this.wrapper.appendChild(this.resultsList);\n (containerEL.parentNode as any).appendChild(this.wrapper);\n\n } else {\n // if container is not an input, create new input and append to container\n\n // create new input\n this.inputField = document.createElement('input');\n this.inputField.classList.add(CLASSNAMES.INPUT);\n this.inputField.placeholder = this.config.placeholder;\n this.inputField.type = 'text';\n this.inputField.disabled = this.config.disabled;\n\n // search icon\n const searchIcon = document.createElement('div');\n searchIcon.classList.add(CLASSNAMES.SEARCH_ICON);\n\n // append to DOM\n this.wrapper.appendChild(this.inputField);\n this.wrapper.appendChild(this.resultsList);\n this.wrapper.appendChild(searchIcon);\n this.container.appendChild(this.wrapper);\n }\n\n // disable browser autofill\n this.inputField.setAttribute('autocomplete', 'off');\n\n // set aria roles\n this.inputField.setAttribute('role', 'combobox');\n this.inputField.setAttribute('aria-controls', CLASSNAMES.RESULTS_LIST);\n this.inputField.setAttribute('aria-expanded', 'false');\n this.inputField.setAttribute('aria-haspopup', 'listbox');\n this.inputField.setAttribute('aria-autocomplete', 'list');\n this.inputField.setAttribute('aria-activedescendant', '');\n\n // setup event listeners\n this.inputField.addEventListener('input', this.handleInput.bind(this));\n this.inputField.addEventListener('keydown', this.handleKeyboardNavigation.bind(this));\n if (this.config.hideResultsOnBlur) {\n this.inputField.addEventListener('blur', this.close.bind(this), true);\n }\n\n Logger.debug('AutocompleteUI initialized with options', this.config);\n }\n\n public handleInput() {\n const { Logger } = this.ctx;\n\n // Fetch autocomplete results and display them\n const query = this.inputField.value;\n if (query.length < this.config.minCharacters) {\n return;\n }\n\n this.debouncedFetchResults(query)\n .then((results: any[]) => {\n const onResults = this.config.onResults;\n if (onResults) {\n onResults(results);\n }\n this.displayResults(results);\n })\n .catch((error) => {\n Logger.warn(`Autocomplete ui error: ${error.message}`);\n const onError = this.config.onError;\n if (onError) {\n onError(error);\n }\n });\n }\n\n public debounce(fn: Function, delay: number) {\n let timeoutId: any;\n let resolveFn: any;\n let rejectFn: any;\n\n return (...args: any[]) => {\n clearTimeout(timeoutId);\n\n timeoutId = setTimeout(() => {\n const result = fn.apply(this, args);\n\n if (result instanceof Promise) {\n result\n .then((value) => {\n if (resolveFn) {\n resolveFn(value);\n }\n })\n .catch((error) => {\n if (rejectFn) {\n rejectFn(error);\n }\n });\n }\n }, delay);\n\n return new Promise((resolve, reject) => {\n resolveFn = resolve;\n rejectFn = reject;\n });\n };\n }\n\n public async fetchResults(query: string) {\n const { apis } = this.ctx;\n const { limit, layers, countryCode, expandUnits, mailable, lang, postalCode, onRequest } = this.config;\n\n const params: RadarAutocompleteParams = {\n query,\n limit,\n layers,\n countryCode,\n expandUnits,\n mailable,\n lang,\n postalCode,\n }\n\n if (this.near) {\n params.near = this.near;\n }\n\n if (onRequest) {\n onRequest(params);\n }\n\n const { addresses } = await apis.Search.autocomplete(params, 'autocomplete-ui');\n return addresses;\n }\n\n public displayResults(results: any[]) {\n // Clear the previous results\n this.clearResultsList();\n this.results = results;\n\n let marker: HTMLElement;\n if (this.config.showMarkers) {\n marker = document.createElement('img');\n marker.classList.add(CLASSNAMES.RESULTS_MARKER);\n marker.setAttribute('src', getMarkerIcon(this.config.markerColor));\n }\n\n // Create and append list items for each result\n results.forEach((result, index) => {\n const li = document.createElement('li');\n li.classList.add(CLASSNAMES.RESULTS_ITEM);\n li.setAttribute('role', 'option');\n li.setAttribute('id', `${CLASSNAMES.RESULTS_ITEM}}-${index}`);\n\n // construct result with bolded label\n let listContent;\n if (result.formattedAddress.includes(result.addressLabel) && result.layer !== 'postalCode') {\n // if addressLabel is contained in the formatted address, bold the address label\n const regex = new RegExp(`(${result.addressLabel}),?`);\n listContent = result.formattedAddress.replace(regex, '<b>$1</b>');\n } else {\n // otherwise append the address or place label to formatted address\n const label = result.placeLabel || result.addressLabel;\n listContent = `<b>${label}</b> ${result.formattedAddress}`;\n }\n li.innerHTML = listContent;\n\n // prepend marker if enabled\n if (marker) {\n li.prepend(marker.cloneNode());\n }\n\n // add click handler to each result, use mousedown to fire before blur event\n li.addEventListener('mousedown', () => {\n this.select(index);\n });\n\n this.resultsList.appendChild(li);\n });\n\n this.open();\n\n if (results.length > 0) {\n const link = document.createElement('a');\n link.href = 'https://radar.com?ref=powered_by_radar';\n link.target = '_blank';\n this.poweredByLink = link;\n\n const poweredByText = document.createElement('span');\n poweredByText.textContent = 'Powered by';\n link.appendChild(poweredByText);\n\n const radarLogo = document.createElement('span');\n radarLogo.id = 'radar-powered-logo';\n radarLogo.textContent = 'Radar';\n link.appendChild(radarLogo);\n\n const poweredByContainer = document.createElement('div');\n poweredByContainer.classList.add(CLASSNAMES.POWERED_BY_RADAR);\n poweredByContainer.appendChild(link);\n this.resultsList.appendChild(poweredByContainer);\n } else {\n const noResultsText = document.createElement('div');\n noResultsText.classList.add(CLASSNAMES.NO_RESULTS);\n noResultsText.textContent = 'No results';\n\n this.resultsList.appendChild(noResultsText);\n }\n }\n\n public open() {\n if (this.isOpen) {\n return;\n }\n\n this.inputField.setAttribute('aria-expanded', 'true');\n this.resultsList.removeAttribute('hidden');\n this.isOpen = true;\n }\n\n public close(e?: FocusEvent) {\n if (!this.isOpen) {\n return;\n }\n\n // run this code async to allow link click to propagate before blur\n // (add 100ms delay if closed from link click)\n const linkClick = e && (e.relatedTarget === this.poweredByLink);\n setTimeout(() => {\n this.inputField.setAttribute('aria-expanded', 'false');\n this.inputField.setAttribute('aria-activedescendant', '');\n this.resultsList.setAttribute('hidden', '');\n this.highlightedIndex = -1;\n this.isOpen = false;\n this.clearResultsList();\n }, linkClick ? 100 : 0);\n }\n\n public goTo(index: number) {\n if (!this.isOpen || !this.results.length) {\n return;\n }\n\n // wrap around\n if (index < 0) {\n index = this.results.length - 1;\n } else if (index >= this.results.length) {\n index = 0;\n }\n\n const resultItems = this.resultsList.getElementsByTagName('li');\n\n if (this.highlightedIndex > -1) {\n // clear class names on previously highlighted item\n resultItems[this.highlightedIndex].classList.remove(CLASSNAMES.SELECTED_ITEM);\n }\n\n // add class name to newly highlighted item\n resultItems[index].classList.add(CLASSNAMES.SELECTED_ITEM);\n\n // set aria active descendant\n this.inputField.setAttribute('aria-activedescendant', `${CLASSNAMES.RESULTS_ITEM}-${index}`);\n\n this.highlightedIndex = index;\n }\n\n public handleKeyboardNavigation(event: KeyboardEvent) {\n let key = event.key;\n\n // allow event to propagate if result list is not open\n if (!this.isOpen) {\n return;\n }\n\n // treat shift+tab as up key\n if (key === 'Tab' && event.shiftKey) {\n key = 'ArrowUp';\n };\n\n switch (key) {\n // Next item\n case 'Tab':\n case 'ArrowDown':\n event.preventDefault();\n this.goTo(this.highlightedIndex + 1);\n break;\n\n // Prev item\n case 'ArrowUp':\n event.preventDefault();\n this.goTo(this.highlightedIndex - 1);\n break;\n\n // Select\n case 'Enter':\n this.select(this.highlightedIndex);\n break;\n\n // Close\n case 'Esc':\n this.close();\n break;\n }\n }\n\n public select(index: number) {\n const { Logger } = this.ctx;\n const result = this.results[index];\n if (!result) {\n Logger.warn(`No autocomplete result found at index: ${index}`);\n return;\n }\n\n let inputValue;\n if (result.formattedAddress.includes(result.addressLabel)) {\n inputValue = result.formattedAddress;\n } else {\n const label = result.placeLabel || result.addressLabel;\n inputValue = `${label}, ${result.formattedAddress}`;\n }\n this.inputField.value = inputValue;\n\n const onSelection = this.config.onSelection;\n if (onSelection) {\n onSelection(result);\n }\n\n // clear results list\n this.close();\n }\n\n public clearResultsList() {\n this.resultsList.innerHTML = '';\n this.results = [];\n }\n\n // remove elements from DOM\n public remove() {\n const { Logger } = this.ctx;\n Logger.debug('AutocompleteUI removed.');\n this.inputField.remove();\n this.resultsList.remove();\n this.wrapper.remove();\n }\n\n public setNear(near: string | Location | undefined | null) {\n if (near === undefined || near === null) {\n this.near = undefined;\n } else if (typeof near === 'string') {\n this.near = near;\n } else {\n this.near = `${near.latitude},${near.longitude}`;\n }\n return this;\n }\n\n public setPlaceholder(placeholder: string) {\n this.config.placeholder = placeholder;\n this.inputField.placeholder = placeholder;\n return this;\n }\n\n public setDisabled(disabled: boolean) {\n this.config.disabled = disabled;\n this.inputField.disabled = disabled;\n return this;\n }\n\n public setResponsive(responsive: boolean) {\n this.config.responsive = responsive;\n setWidth(this.wrapper, this.config);\n return this;\n }\n\n public setWidth(width: number | string | null) {\n if (width === null) {\n this.config.width = undefined;\n } else if (typeof width === 'string' || typeof width === 'number') {\n this.config.width = width;\n }\n setWidth(this.wrapper, this.config);\n return this;\n }\n\n public setMaxHeight(height: number | string | null) {\n if (height === null) {\n this.config.maxHeight = undefined;\n } else if (typeof height === 'string' || typeof height === 'number') {\n this.config.maxHeight = height;\n }\n setHeight(this.resultsList, this.config);\n return this;\n }\n\n public setMinCharacters(minCharacters: number) {\n this.config.minCharacters = minCharacters;\n this.config.threshold = minCharacters;\n return this;\n }\n\n public setLimit(limit: number) {\n this.config.limit = limit;\n return this;\n }\n\n public setLang(lang: string | null) {\n if (lang === null) {\n this.config.lang = undefined;\n } else if (typeof lang === 'string') {\n this.config.lang = lang;\n }\n return this;\n }\n\n public setPostalCode(postalCode: string | null) {\n if (postalCode === null) {\n this.config.postalCode = undefined;\n } else if (typeof postalCode === 'string') {\n this.config.postalCode = postalCode;\n }\n return this;\n }\n\n public setShowMarkers(showMarkers: boolean) {\n this.config.showMarkers = showMarkers;\n if (showMarkers) {\n const marker = document.createElement('img');\n marker.classList.add(CLASSNAMES.RESULTS_MARKER);\n marker.setAttribute('src', getMarkerIcon(this.config.markerColor));\n const resultItems = this.resultsList.getElementsByTagName('li');\n for (let i = 0; i < resultItems.length; i++) {\n const currentMarker = resultItems[i].getElementsByClassName(CLASSNAMES.RESULTS_MARKER)[0];\n if (!currentMarker) {\n resultItems[i].prepend(marker.cloneNode());\n }\n }\n } else {\n const resultItems = this.resultsList.getElementsByTagName('li');\n for (let i = 0; i < resultItems.length; i++) {\n const marker = resultItems[i].getElementsByClassName(CLASSNAMES.RESULTS_MARKER)[0];\n if (marker) {\n marker.remove();\n }\n }\n }\n return this;\n }\n\n public setMarkerColor(color: string) {\n this.config.markerColor = color;\n const marker = this.resultsList.getElementsByClassName(CLASSNAMES.RESULTS_MARKER);\n for (let i = 0; i < marker.length; i++) {\n marker[i].setAttribute('src', getMarkerIcon(color));\n }\n return this;\n }\n\n public setHideResultsOnBlur(hideResultsOnBlur: boolean) {\n this.config.hideResultsOnBlur = hideResultsOnBlur;\n if (hideResultsOnBlur) {\n this.inputField.addEventListener('blur', this.close.bind(this), true);\n } else {\n this.inputField.removeEventListener('blur', this.close.bind(this), true);\n }\n return this;\n }\n}\n\nexport default AutocompleteUI;\n","export default '5.0.0-beta.5';\n","import type { RadarPlugin } from 'radar-sdk-js';\n\nimport AutocompleteUI from './autocomplete';\nimport version from './version';\nimport type { RadarAutocompleteUIOptions } from './types';\n\nimport '../styles/radar-autocomplete.css';\n\nexport type { RadarAutocompleteUIOptions, RadarAutocompleteConfig } from './types';\n\ndeclare module 'radar-sdk-js' {\n interface RadarUI {\n autocomplete(options: Partial<RadarAutocompleteUIOptions>): AutocompleteUI;\n }\n namespace Radar {\n let ui: RadarUI;\n }\n}\n\nexport function createAutocompletePlugin(): RadarPlugin {\n return {\n name: 'autocomplete',\n version,\n install(ctx) {\n const existing = ctx.Radar.ui || {};\n // NOTE(jasonl): we're merging with the existing ui namespace since other plugins also add to it like maps\n ctx.Radar.ui = {\n ...existing,\n autocomplete: (options: Partial<RadarAutocompleteUIOptions>) => new AutocompleteUI(options, ctx),\n };\n },\n };\n}\n"],"names":[],"mappings":";;AAEM,MAAO,kCAAmC,SAAQ,UAAU,CAAA;AAChE,IAAA,WAAA,CAAY,OAAe,EAAA;QACzB,KAAK,CAAC,OAAO,CAAC;AACd,QAAA,IAAI,CAAC,IAAI,GAAG,oCAAoC;AAChD,QAAA,IAAI,CAAC,MAAM,GAAG,qBAAqB;IACrC;AACD;;ACJD,MAAM,UAAU,GAAG;AACjB,IAAA,O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/index.ts"],"sourcesContent":["import { RadarError } from 'radar-sdk-js';\n\n/** error thrown when the autocomplete container element is not found in the DOM */\nexport class RadarAutocompleteContainerNotFound extends RadarError {\n constructor(message: string) {\n super(message);\n this.name = 'RadarAutocompleteContainerNotFound';\n this.status = 'CONTAINER_NOT_FOUND';\n }\n}\n","import { RadarAutocompleteContainerNotFound } from './errors';\nimport type { RadarAutocompleteUIOptions, RadarAutocompleteConfig } from './types';\nimport type { RadarAutocompleteAddress, RadarAutocompleteParams, Location, RadarPluginContext } from 'radar-sdk-js';\n\nconst CLASSNAMES = {\n WRAPPER: 'radar-autocomplete-wrapper',\n INPUT: 'radar-autocomplete-input',\n SEARCH_ICON: 'radar-autocomplete-search-icon',\n RESULTS_LIST: 'radar-autocomplete-results-list',\n RESULTS_ITEM: 'radar-autocomplete-results-item',\n RESULTS_MARKER: 'radar-autocomplete-results-marker',\n SELECTED_ITEM: 'radar-autocomplete-results-item-selected',\n POWERED_BY_RADAR: 'radar-powered',\n NO_RESULTS: 'radar-no-results',\n};\n\nconst defaultAutocompleteOptions: RadarAutocompleteUIOptions = {\n container: 'autocomplete',\n debounceMS: 200, // Debounce time in milliseconds\n minCharacters: 3, // Minimum number of characters to trigger autocomplete\n limit: 8, // Maximum number of autocomplete results\n placeholder: 'Search address', // Placeholder text for the input field\n responsive: true,\n disabled: false,\n showMarkers: true,\n hideResultsOnBlur: true,\n};\n\n// determine whether to use px or CSS string\nconst formatCSSValue = (value: string | number) => {\n if (typeof value === 'number') {\n return `${value}px`;\n }\n return value;\n};\n\nconst DEFAULT_WIDTH = 400;\nconst setWidth = (input: HTMLElement, options: RadarAutocompleteUIOptions) => {\n // if responsive and width is provided, treat it as maxWidth\n if (options.responsive) {\n input.style.width = '100%';\n if (options.width) {\n input.style.maxWidth = formatCSSValue(options.width);\n }\n return;\n }\n\n // if not responsive, set fixed width and unset maxWidth\n input.style.width = formatCSSValue(options.width || DEFAULT_WIDTH);\n input.style.removeProperty('max-width');\n};\n\nconst setHeight = (resultsList: HTMLElement, options: RadarAutocompleteUIOptions) => {\n if (options.maxHeight) {\n resultsList.style.maxHeight = formatCSSValue(options.maxHeight);\n resultsList.style.overflowY = 'auto'; /* allow overflow when maxHeight is applied */\n }\n};\n\nconst getMarkerIcon = (color: string = \"#ACBDC8\") => {\n const fill = color.replace('#', '%23');\n const svg = `<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M12.5704 6.57036C12.5704 4.11632 10.6342 2.11257 8.21016 2C8.14262 2 8.06757 2 8.00003 2C7.93249 2 7.85744 2 7.7899 2C5.35838 2.11257 3.42967 4.11632 3.42967 6.57036C3.42967 6.60037 3.42967 6.6379 3.42967 6.66792C3.42967 6.69794 3.42967 6.73546 3.42967 6.76548C3.42967 9.46717 7.09196 13.3621 7.4672 13.7598C7.61729 13.9174 7.84994 14 8.00003 14C8.15012 14 8.38277 13.9174 8.53286 13.7598C8.9156 13.3621 12.5704 9.46717 12.5704 6.76548C12.5704 6.72795 12.5704 6.69794 12.5704 6.66792C12.5704 6.6379 12.5704 6.60037 12.5704 6.57036ZM7.99252 8.28893C7.04693 8.28893 6.27395 7.52345 6.27395 6.57036C6.27395 5.61726 7.03943 4.85178 7.99252 4.85178C8.94562 4.85178 9.7111 5.61726 9.7111 6.57036C9.7111 7.52345 8.94562 8.28893 7.99252 8.28893Z\" fill=\"${fill}\"/>\n </svg>`.trim();\n return `data:image/svg+xml;charset=utf-8,${svg}`;\n};\n\n\n/** address autocomplete UI widget with keyboard navigation and result display */\nclass AutocompleteUI {\n private ctx: RadarPluginContext;\n config: RadarAutocompleteConfig;\n isOpen: boolean;\n results: RadarAutocompleteAddress[];\n highlightedIndex: number;\n debouncedFetchResults: (query: string) => Promise<RadarAutocompleteAddress[]>;\n near?: string;\n\n // DOM elements\n container: HTMLElement;\n inputField: HTMLInputElement;\n resultsList: HTMLElement;\n wrapper: HTMLElement;\n poweredByLink?: HTMLElement;\n\n constructor(options: Partial<RadarAutocompleteUIOptions>, ctx: RadarPluginContext) {\n this.ctx = ctx;\n const { Logger } = this.ctx;\n this.config = Object.assign({}, defaultAutocompleteOptions, options) as RadarAutocompleteConfig;\n\n // setup state\n this.isOpen = false;\n this.debouncedFetchResults = this.debounce(this.fetchResults.bind(this), this.config.debounceMS);\n this.results = [];\n this.highlightedIndex = -1;\n\n // set threshold alias\n if (this.config.threshold !== undefined) {\n this.config.minCharacters = this.config.threshold;\n Logger.warn('AutocompleteUI option \"threshold\" is deprecated, use \"minCharacters\" instead.');\n }\n\n if (options.near) {\n if (typeof options.near === 'string') {\n this.near = options.near;\n } else {\n this.near = `${options.near.latitude},${options.near.longitude}`;\n }\n }\n\n // get container element\n let containerEL;\n if (typeof this.config.container === 'string') { // lookup container element by ID\n containerEL = document.getElementById(this.config.container);\n } else { // use provided element\n containerEL = this.config.container; // HTMLElement\n }\n if (!containerEL) {\n throw new RadarAutocompleteContainerNotFound(`Could not find container element: ${this.config.container}`);\n }\n this.container = containerEL;\n\n // create wrapper for input and result list\n this.wrapper = document.createElement('div');\n this.wrapper.classList.add(CLASSNAMES.WRAPPER);\n this.wrapper.style.display = this.config.responsive ? 'block' : 'inline-block';\n setWidth(this.wrapper, this.config);\n\n // result list element\n this.resultsList = document.createElement('ul');\n this.resultsList.classList.add(CLASSNAMES.RESULTS_LIST);\n this.resultsList.setAttribute('id', CLASSNAMES.RESULTS_LIST);\n this.resultsList.setAttribute('role', 'listbox');\n this.resultsList.setAttribute('aria-live', 'polite');\n this.resultsList.setAttribute('aria-label', 'Search results');\n setHeight(this.resultsList, this.config);\n\n if (containerEL.nodeName === 'INPUT') {\n // if an <input> element is provided, use that as the inputField,\n // and append the resultList to it's parent container\n this.inputField = containerEL as HTMLInputElement;\n\n // append to dom\n this.wrapper.appendChild(this.resultsList);\n containerEL.parentNode?.appendChild(this.wrapper);\n\n } else {\n // if container is not an input, create new input and append to container\n\n // create new input\n this.inputField = document.createElement('input');\n this.inputField.classList.add(CLASSNAMES.INPUT);\n this.inputField.placeholder = this.config.placeholder;\n this.inputField.type = 'text';\n this.inputField.disabled = this.config.disabled;\n\n // search icon\n const searchIcon = document.createElement('div');\n searchIcon.classList.add(CLASSNAMES.SEARCH_ICON);\n\n // append to DOM\n this.wrapper.appendChild(this.inputField);\n this.wrapper.appendChild(this.resultsList);\n this.wrapper.appendChild(searchIcon);\n this.container.appendChild(this.wrapper);\n }\n\n // disable browser autofill\n this.inputField.setAttribute('autocomplete', 'off');\n\n // set aria roles\n this.inputField.setAttribute('role', 'combobox');\n this.inputField.setAttribute('aria-controls', CLASSNAMES.RESULTS_LIST);\n this.inputField.setAttribute('aria-expanded', 'false');\n this.inputField.setAttribute('aria-haspopup', 'listbox');\n this.inputField.setAttribute('aria-autocomplete', 'list');\n this.inputField.setAttribute('aria-activedescendant', '');\n\n // setup event listeners\n this.inputField.addEventListener('input', this.handleInput.bind(this));\n this.inputField.addEventListener('keydown', this.handleKeyboardNavigation.bind(this));\n if (this.config.hideResultsOnBlur) {\n this.inputField.addEventListener('blur', this.close.bind(this), true);\n }\n\n Logger.debug('AutocompleteUI initialized with options', this.config);\n }\n\n /** handle input field changes and trigger debounced search */\n public handleInput() {\n const { Logger } = this.ctx;\n\n // Fetch autocomplete results and display them\n const query = this.inputField.value;\n if (query.length < this.config.minCharacters) {\n return;\n }\n\n this.debouncedFetchResults(query)\n .then((results) => {\n const onResults = this.config.onResults;\n if (onResults) {\n onResults(results);\n }\n this.displayResults(results);\n })\n .catch((error: Error) => {\n Logger.warn(`Autocomplete ui error: ${error.message}`);\n const onError = this.config.onError;\n if (onError) {\n onError(error);\n }\n });\n }\n\n public debounce<TArgs extends unknown[], TReturn>(\n fn: (...args: TArgs) => Promise<TReturn>,\n delay: number,\n ): (...args: TArgs) => Promise<TReturn> {\n let timeoutId: ReturnType<typeof setTimeout>;\n let resolveFn: ((value: TReturn) => void) | null = null;\n let rejectFn: ((reason: unknown) => void) | null = null;\n\n return (...args: TArgs) => {\n clearTimeout(timeoutId);\n\n timeoutId = setTimeout(() => {\n fn(...args)\n .then((value) => {\n resolveFn?.(value);\n })\n .catch((error) => {\n rejectFn?.(error);\n });\n }, delay);\n\n return new Promise<TReturn>((resolve, reject) => {\n resolveFn = resolve;\n rejectFn = reject;\n });\n };\n }\n\n /**\n * fetch autocomplete results from the Radar API\n * @param query - the search query string\n * @returns matching addresses\n */\n public async fetchResults(query: string) {\n const { apis } = this.ctx;\n const { limit, layers, countryCode, expandUnits, mailable, lang, postalCode, onRequest } = this.config;\n\n const params: RadarAutocompleteParams = {\n query,\n limit,\n layers,\n countryCode,\n expandUnits,\n mailable,\n lang,\n postalCode,\n }\n\n if (this.near) {\n params.near = this.near;\n }\n\n if (onRequest) {\n onRequest(params);\n }\n\n const { addresses } = await apis.Search.autocomplete(params, 'autocomplete-ui');\n return addresses;\n }\n\n /**\n * render autocomplete results in the dropdown\n * @param results - array of address results to display\n */\n public displayResults(results: RadarAutocompleteAddress[]) {\n // Clear the previous results\n this.clearResultsList();\n this.results = results;\n\n let marker: HTMLElement;\n if (this.config.showMarkers) {\n marker = document.createElement('img');\n marker.classList.add(CLASSNAMES.RESULTS_MARKER);\n marker.setAttribute('src', getMarkerIcon(this.config.markerColor));\n }\n\n // Create and append list items for each result\n results.forEach((result, index) => {\n const li = document.createElement('li');\n li.classList.add(CLASSNAMES.RESULTS_ITEM);\n li.setAttribute('role', 'option');\n li.setAttribute('id', `${CLASSNAMES.RESULTS_ITEM}}-${index}`);\n\n // construct result with bolded label\n let listContent;\n if (result.formattedAddress?.includes(result.addressLabel!) && result.layer !== 'postalCode') {\n // if addressLabel is contained in the formatted address, bold the address label\n const regex = new RegExp(`(${result.addressLabel}),?`);\n listContent = result.formattedAddress.replace(regex, '<b>$1</b>');\n } else {\n // otherwise append the address or place label to formatted address\n const label = result.placeLabel || result.addressLabel;\n listContent = `<b>${label}</b> ${result.formattedAddress}`;\n }\n li.innerHTML = listContent;\n\n // prepend marker if enabled\n if (marker) {\n li.prepend(marker.cloneNode());\n }\n\n // add click handler to each result, use mousedown to fire before blur event\n li.addEventListener('mousedown', () => {\n this.select(index);\n });\n\n this.resultsList.appendChild(li);\n });\n\n this.open();\n\n if (results.length > 0) {\n const link = document.createElement('a');\n link.href = 'https://radar.com?ref=powered_by_radar';\n link.target = '_blank';\n this.poweredByLink = link;\n\n const poweredByText = document.createElement('span');\n poweredByText.textContent = 'Powered by';\n link.appendChild(poweredByText);\n\n const radarLogo = document.createElement('span');\n radarLogo.id = 'radar-powered-logo';\n radarLogo.textContent = 'Radar';\n link.appendChild(radarLogo);\n\n const poweredByContainer = document.createElement('div');\n poweredByContainer.classList.add(CLASSNAMES.POWERED_BY_RADAR);\n poweredByContainer.appendChild(link);\n this.resultsList.appendChild(poweredByContainer);\n } else {\n const noResultsText = document.createElement('div');\n noResultsText.classList.add(CLASSNAMES.NO_RESULTS);\n noResultsText.textContent = 'No results';\n\n this.resultsList.appendChild(noResultsText);\n }\n }\n\n /** open the results dropdown */\n public open() {\n if (this.isOpen) {\n return;\n }\n\n this.inputField.setAttribute('aria-expanded', 'true');\n this.resultsList.removeAttribute('hidden');\n this.isOpen = true;\n }\n\n /** close the results dropdown and clear highlighted state */\n public close(e?: FocusEvent) {\n if (!this.isOpen) {\n return;\n }\n\n // run this code async to allow link click to propagate before blur\n // (add 100ms delay if closed from link click)\n const linkClick = e && (e.relatedTarget === this.poweredByLink);\n setTimeout(() => {\n this.inputField.setAttribute('aria-expanded', 'false');\n this.inputField.setAttribute('aria-activedescendant', '');\n this.resultsList.setAttribute('hidden', '');\n this.highlightedIndex = -1;\n this.isOpen = false;\n this.clearResultsList();\n }, linkClick ? 100 : 0);\n }\n\n /**\n * highlight a result by index with wrap-around navigation\n * @param index - the result index to highlight\n */\n public goTo(index: number) {\n if (!this.isOpen || !this.results.length) {\n return;\n }\n\n // wrap around\n if (index < 0) {\n index = this.results.length - 1;\n } else if (index >= this.results.length) {\n index = 0;\n }\n\n const resultItems = this.resultsList.getElementsByTagName('li');\n\n if (this.highlightedIndex > -1) {\n // clear class names on previously highlighted item\n resultItems[this.highlightedIndex].classList.remove(CLASSNAMES.SELECTED_ITEM);\n }\n\n // add class name to newly highlighted item\n resultItems[index].classList.add(CLASSNAMES.SELECTED_ITEM);\n\n // set aria active descendant\n this.inputField.setAttribute('aria-activedescendant', `${CLASSNAMES.RESULTS_ITEM}-${index}`);\n\n this.highlightedIndex = index;\n }\n\n public handleKeyboardNavigation(event: KeyboardEvent) {\n let key = event.key;\n\n // allow event to propagate if result list is not open\n if (!this.isOpen) {\n return;\n }\n\n // treat shift+tab as up key\n if (key === 'Tab' && event.shiftKey) {\n key = 'ArrowUp';\n };\n\n switch (key) {\n // Next item\n case 'Tab':\n case 'ArrowDown':\n event.preventDefault();\n this.goTo(this.highlightedIndex + 1);\n break;\n\n // Prev item\n case 'ArrowUp':\n event.preventDefault();\n this.goTo(this.highlightedIndex - 1);\n break;\n\n // Select\n case 'Enter':\n this.select(this.highlightedIndex);\n break;\n\n // Close\n case 'Esc':\n this.close();\n break;\n }\n }\n\n /**\n * select a result by index and populate the input field\n * @param index - the result index to select\n */\n public select(index: number) {\n const { Logger } = this.ctx;\n const result = this.results[index];\n if (!result) {\n Logger.warn(`No autocomplete result found at index: ${index}`);\n return;\n }\n\n let inputValue;\n if (result.formattedAddress?.includes(result.addressLabel!)) {\n inputValue = result.formattedAddress;\n } else {\n const label = result.placeLabel || result.addressLabel;\n inputValue = `${label}, ${result.formattedAddress}`;\n }\n this.inputField.value = inputValue;\n\n const onSelection = this.config.onSelection;\n if (onSelection) {\n onSelection(result);\n }\n\n // clear results list\n this.close();\n }\n\n /** clear the results list DOM and reset results array */\n public clearResultsList() {\n this.resultsList.innerHTML = '';\n this.results = [];\n }\n\n /** remove the autocomplete widget from the DOM */\n public remove() {\n const { Logger } = this.ctx;\n Logger.debug('AutocompleteUI removed.');\n this.inputField.remove();\n this.resultsList.remove();\n this.wrapper.remove();\n }\n\n /**\n * set the `near` location bias for autocomplete requests\n * @param near - location string, Location object, or null to clear\n * @returns this instance for chaining\n */\n public setNear(near: string | Location | undefined | null) {\n if (near === undefined || near === null) {\n this.near = undefined;\n } else if (typeof near === 'string') {\n this.near = near;\n } else {\n this.near = `${near.latitude},${near.longitude}`;\n }\n return this;\n }\n\n /**\n * set the input placeholder text\n * @param placeholder - new placeholder string\n * @returns this instance for chaining\n */\n public setPlaceholder(placeholder: string) {\n this.config.placeholder = placeholder;\n this.inputField.placeholder = placeholder;\n return this;\n }\n\n /**\n * set the disabled state of the input\n * @param disabled - whether to disable the input\n * @returns this instance for chaining\n */\n public setDisabled(disabled: boolean) {\n this.config.disabled = disabled;\n this.inputField.disabled = disabled;\n return this;\n }\n\n /**\n * toggle responsive width mode\n * @param responsive - whether to use responsive layout\n * @returns this instance for chaining\n */\n public setResponsive(responsive: boolean) {\n this.config.responsive = responsive;\n setWidth(this.wrapper, this.config);\n return this;\n }\n\n /**\n * set the widget width\n * @param width - width in px, CSS string, or null to reset\n * @returns this instance for chaining\n */\n public setWidth(width: number | string | null) {\n if (width === null) {\n this.config.width = undefined;\n } else if (typeof width === 'string' || typeof width === 'number') {\n this.config.width = width;\n }\n setWidth(this.wrapper, this.config);\n return this;\n }\n\n /**\n * set the max height of the results dropdown\n * @param height - height in px, CSS string, or null to reset\n * @returns this instance for chaining\n */\n public setMaxHeight(height: number | string | null) {\n if (height === null) {\n this.config.maxHeight = undefined;\n } else if (typeof height === 'string' || typeof height === 'number') {\n this.config.maxHeight = height;\n }\n setHeight(this.resultsList, this.config);\n return this;\n }\n\n /**\n * set the minimum character count to trigger autocomplete\n * @param minCharacters - character threshold\n * @returns this instance for chaining\n */\n public setMinCharacters(minCharacters: number) {\n this.config.minCharacters = minCharacters;\n this.config.threshold = minCharacters;\n return this;\n }\n\n /**\n * set the maximum number of results\n * @param limit - result count limit\n * @returns this instance for chaining\n */\n public setLimit(limit: number) {\n this.config.limit = limit;\n return this;\n }\n\n /**\n * set the language for autocomplete results\n * @param lang - language code or null to clear\n * @returns this instance for chaining\n */\n public setLang(lang: string | null) {\n if (lang === null) {\n this.config.lang = undefined;\n } else if (typeof lang === 'string') {\n this.config.lang = lang;\n }\n return this;\n }\n\n /**\n * set a postal code bias for autocomplete requests\n * @param postalCode - postal code string or null to clear\n * @returns this instance for chaining\n */\n public setPostalCode(postalCode: string | null) {\n if (postalCode === null) {\n this.config.postalCode = undefined;\n } else if (typeof postalCode === 'string') {\n this.config.postalCode = postalCode;\n }\n return this;\n }\n\n /**\n * toggle marker icons in result items\n * @param showMarkers - whether to show markers\n * @returns this instance for chaining\n */\n public setShowMarkers(showMarkers: boolean) {\n this.config.showMarkers = showMarkers;\n if (showMarkers) {\n const marker = document.createElement('img');\n marker.classList.add(CLASSNAMES.RESULTS_MARKER);\n marker.setAttribute('src', getMarkerIcon(this.config.markerColor));\n const resultItems = this.resultsList.getElementsByTagName('li');\n for (let i = 0; i < resultItems.length; i++) {\n const currentMarker = resultItems[i].getElementsByClassName(CLASSNAMES.RESULTS_MARKER)[0];\n if (!currentMarker) {\n resultItems[i].prepend(marker.cloneNode());\n }\n }\n } else {\n const resultItems = this.resultsList.getElementsByTagName('li');\n for (let i = 0; i < resultItems.length; i++) {\n const marker = resultItems[i].getElementsByClassName(CLASSNAMES.RESULTS_MARKER)[0];\n if (marker) {\n marker.remove();\n }\n }\n }\n return this;\n }\n\n /**\n * set the color of marker icons in result items\n * @param color - CSS color string\n * @returns this instance for chaining\n */\n public setMarkerColor(color: string) {\n this.config.markerColor = color;\n const marker = this.resultsList.getElementsByClassName(CLASSNAMES.RESULTS_MARKER);\n for (let i = 0; i < marker.length; i++) {\n marker[i].setAttribute('src', getMarkerIcon(color));\n }\n return this;\n }\n\n /**\n * toggle hiding results when input loses focus\n * @param hideResultsOnBlur - whether to hide on blur\n * @returns this instance for chaining\n */\n public setHideResultsOnBlur(hideResultsOnBlur: boolean) {\n this.config.hideResultsOnBlur = hideResultsOnBlur;\n if (hideResultsOnBlur) {\n this.inputField.addEventListener('blur', this.close.bind(this), true);\n } else {\n this.inputField.removeEventListener('blur', this.close.bind(this), true);\n }\n return this;\n }\n}\n\nexport default AutocompleteUI;\n","export default '5.0.0-beta.6';\n","import type { RadarPlugin } from 'radar-sdk-js';\n\nimport AutocompleteUI from './autocomplete';\nimport version from './version';\nimport type { RadarAutocompleteUIOptions } from './types';\n\nimport '../styles/radar-autocomplete.css';\n\nexport type { RadarAutocompleteUIOptions, RadarAutocompleteConfig } from './types';\n\ndeclare module 'radar-sdk-js' {\n interface RadarUI {\n autocomplete(options: Partial<RadarAutocompleteUIOptions>): AutocompleteUI;\n }\n namespace Radar {\n let ui: RadarUI;\n }\n}\n\n/**\n * create the Radar autocomplete plugin\n *\n * @returns a plugin that adds `Radar.ui.autocomplete()` method\n *\n * @example\n * ```ts\n * import { createAutocompletePlugin } from '@radarlabs/plugin-autocomplete';\n * Radar.registerPlugin(createAutocompletePlugin());\n * ```\n */\nexport function createAutocompletePlugin(): RadarPlugin {\n return {\n name: 'autocomplete',\n version,\n install(ctx) {\n const existing = ctx.Radar.ui || {};\n // NOTE(jasonl): we're merging with the existing ui namespace since other plugins also add to it like maps\n ctx.Radar.ui = {\n ...existing,\n autocomplete: (options: Partial<RadarAutocompleteUIOptions>) => new AutocompleteUI(options, ctx),\n };\n },\n };\n}\n"],"names":[],"mappings":";;AAEA;AACM,MAAO,kCAAmC,SAAQ,UAAU,CAAA;AAChE,IAAA,WAAA,CAAY,OAAe,EAAA;QACzB,KAAK,CAAC,OAAO,CAAC;AACd,QAAA,IAAI,CAAC,IAAI,GAAG,oCAAoC;AAChD,QAAA,IAAI,CAAC,MAAM,GAAG,qBAAqB;IACrC;AACD;;ACLD,MAAM,UAAU,GAAG;AACjB,IAAA,OAAO,EAAE,4BAA4B;AACrC,IAAA,KAAK,EAAE,0BAA0B;AACjC,IAAA,WAAW,EAAE,gCAAgC;AAC7C,IAAA,YAAY,EAAE,iCAAiC;AAC/C,IAAA,YAAY,EAAE,iCAAi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
|
1
|
-
import type { RadarAutocompleteParams } from 'radar-sdk-js';
|
|
1
|
+
import type { RadarAutocompleteAddress, RadarAutocompleteParams } from 'radar-sdk-js';
|
|
2
|
+
/** configuration options for the autocomplete UI widget */
|
|
2
3
|
export interface RadarAutocompleteUIOptions extends Omit<RadarAutocompleteParams, 'query'> {
|
|
4
|
+
/** element ID or HTMLElement to mount the widget into */
|
|
3
5
|
container: string | HTMLElement;
|
|
6
|
+
/** debounce delay in milliseconds before fetching results */
|
|
4
7
|
debounceMS?: number;
|
|
5
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated use minCharacters instead
|
|
10
|
+
*/
|
|
6
11
|
threshold?: number;
|
|
12
|
+
/** minimum number of characters to trigger autocomplete */
|
|
7
13
|
minCharacters?: number;
|
|
14
|
+
/** placeholder text for the input field */
|
|
8
15
|
placeholder?: string;
|
|
9
|
-
|
|
16
|
+
/** callback invoked when a result is selected */
|
|
17
|
+
onSelection?: (selection: RadarAutocompleteAddress) => void;
|
|
18
|
+
/** callback invoked before each autocomplete request */
|
|
10
19
|
onRequest?: (params: RadarAutocompleteParams) => void;
|
|
11
|
-
|
|
12
|
-
|
|
20
|
+
/** callback invoked when results are returned */
|
|
21
|
+
onResults?: (results: RadarAutocompleteAddress[]) => void;
|
|
22
|
+
/** callback invoked on autocomplete errors */
|
|
23
|
+
onError?: (error: Error) => void;
|
|
24
|
+
/** whether the input is disabled */
|
|
13
25
|
disabled?: boolean;
|
|
26
|
+
/** whether to use responsive width (100% with optional max-width) */
|
|
14
27
|
responsive?: boolean;
|
|
28
|
+
/** fixed width or max-width (px number or CSS string) */
|
|
15
29
|
width?: string | number;
|
|
30
|
+
/** max height of the results dropdown (px number or CSS string) */
|
|
16
31
|
maxHeight?: string | number;
|
|
32
|
+
/** whether to show marker icons in results */
|
|
17
33
|
showMarkers?: boolean;
|
|
34
|
+
/** color for marker icons in results */
|
|
18
35
|
markerColor?: string;
|
|
36
|
+
/** whether to hide results when the input loses focus */
|
|
19
37
|
hideResultsOnBlur?: boolean;
|
|
20
38
|
}
|
|
39
|
+
/** resolved configuration with required defaults */
|
|
21
40
|
export interface RadarAutocompleteConfig extends RadarAutocompleteUIOptions {
|
|
41
|
+
/** debounce delay in milliseconds */
|
|
22
42
|
debounceMS: number;
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated use minCharacters instead
|
|
45
|
+
*/
|
|
23
46
|
threshold: number;
|
|
47
|
+
/** minimum characters to trigger autocomplete */
|
|
24
48
|
minCharacters: number;
|
|
49
|
+
/** maximum number of autocomplete results */
|
|
25
50
|
limit: number;
|
|
51
|
+
/** placeholder text for the input field */
|
|
26
52
|
placeholder: string;
|
|
53
|
+
/** whether the input is disabled */
|
|
27
54
|
disabled: boolean;
|
|
28
55
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "5.0.0-beta.
|
|
1
|
+
declare const _default: "5.0.0-beta.6";
|
|
2
2
|
export default _default;
|