@samline/autocomplete 1.0.0 → 2.0.0
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/CHANGELOG.md +29 -0
- package/LICENSE.md +1 -1
- package/README.md +208 -32
- package/dist/browser/global.global.js +505 -274
- package/dist/browser/global.global.js.map +1 -1
- package/dist/browser/index.cjs +663 -0
- package/dist/browser/index.cjs.map +1 -0
- package/dist/browser/index.d.cts +31 -0
- package/dist/browser/index.d.ts +31 -0
- package/dist/browser/index.js +24 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/chunk-4IPBCQDZ.js +218 -0
- package/dist/chunk-4IPBCQDZ.js.map +1 -0
- package/dist/chunk-5UZVFHB4.js +70 -0
- package/dist/chunk-5UZVFHB4.js.map +1 -0
- package/dist/chunk-AD7T42HJ.js +1 -0
- package/dist/chunk-AD7T42HJ.js.map +1 -0
- package/dist/chunk-PPDQPLPE.js +1 -0
- package/dist/chunk-PPDQPLPE.js.map +1 -0
- package/dist/chunk-U5JYDGKW.js +403 -0
- package/dist/chunk-U5JYDGKW.js.map +1 -0
- package/dist/core/index.cjs +181 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +31 -0
- package/dist/core/index.d.ts +31 -0
- package/dist/core/index.js +22 -0
- package/dist/core/index.js.map +1 -0
- package/dist/index.cjs +527 -274
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -69
- package/dist/index.d.ts +20 -69
- package/dist/index.js +54 -405
- package/dist/index.js.map +1 -1
- package/dist/render-B38UXYCT.d.ts +7 -0
- package/dist/render-WD69VMUs.d.cts +7 -0
- package/dist/styles.css +19 -9
- package/dist/types-CPvjhqjb.d.cts +118 -0
- package/dist/types-CPvjhqjb.d.ts +118 -0
- package/dist/vanilla/index.cjs +598 -0
- package/dist/vanilla/index.cjs.map +1 -0
- package/dist/vanilla/index.d.cts +11 -0
- package/dist/vanilla/index.d.ts +11 -0
- package/dist/vanilla/index.js +13 -0
- package/dist/vanilla/index.js.map +1 -0
- package/package.json +19 -4
- package/dist/browser/global.d.ts +0 -61
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { a as AutocompleteCacheOptions, A as AutocompleteCache, d as AutocompleteEndpointOptions, s as AutocompleteSourceFunction, o as AutocompleteResponseMapper, l as AutocompleteParser, j as AutocompleteMessages, f as AutocompleteHighlightPart } from '../types-CPvjhqjb.cjs';
|
|
2
|
+
export { b as AutocompleteController, c as AutocompleteEndpoint, e as AutocompleteErrorDetail, g as AutocompleteLoadDetail, h as AutocompleteMessage, i as AutocompleteMessageContext, k as AutocompleteOptions, m as AutocompleteRenderContext, n as AutocompleteRequestInit, p as AutocompleteSelectDetail, q as AutocompleteSource, r as AutocompleteSourceContext, t as AutocompleteTarget } from '../types-CPvjhqjb.cjs';
|
|
3
|
+
|
|
4
|
+
/** Least-recently-used cache of suggestions keyed by query. */
|
|
5
|
+
declare const createCache: <T>({ max, ttl }?: AutocompleteCacheOptions, now?: () => number) => AutocompleteCache<T>;
|
|
6
|
+
|
|
7
|
+
declare const parseJsonResponse: AutocompleteParser;
|
|
8
|
+
/** Accepts an array, or an object with a `suggestions`, `items` or `data` array. */
|
|
9
|
+
declare const mapCommonResponse: AutocompleteResponseMapper<unknown>;
|
|
10
|
+
/** Builds a source that fetches suggestions from an HTTP endpoint. */
|
|
11
|
+
declare const fromEndpoint: <T>({ endpoint, queryParam, requestInit, parseResponse, mapResponse, }: AutocompleteEndpointOptions<T>) => AutocompleteSourceFunction<T>;
|
|
12
|
+
|
|
13
|
+
declare const DEFAULT_MESSAGES: AutocompleteMessages;
|
|
14
|
+
|
|
15
|
+
type AutocompleteNormalizer = (value: string) => string;
|
|
16
|
+
interface FilterSuggestionsOptions<T> {
|
|
17
|
+
getText: (suggestion: T) => string;
|
|
18
|
+
normalize?: AutocompleteNormalizer;
|
|
19
|
+
}
|
|
20
|
+
/** Lowercases and removes diacritics, so `Cañón` and `canon` compare equal. */
|
|
21
|
+
declare const normalizeText: AutocompleteNormalizer;
|
|
22
|
+
/** Keeps the suggestions whose text contains every word of the query. */
|
|
23
|
+
declare const filterSuggestions: <T>(suggestions: readonly T[], query: string, { getText, normalize }: FilterSuggestionsOptions<T>) => T[];
|
|
24
|
+
/**
|
|
25
|
+
* Splits `text` into parts that match a word of `query` and parts that do
|
|
26
|
+
* not. Matching runs on normalized text but the parts keep the original
|
|
27
|
+
* characters, accents included.
|
|
28
|
+
*/
|
|
29
|
+
declare const highlight: (text: string, query: string, normalize?: AutocompleteNormalizer) => AutocompleteHighlightPart[];
|
|
30
|
+
|
|
31
|
+
export { AutocompleteCache, AutocompleteCacheOptions, AutocompleteEndpointOptions, AutocompleteHighlightPart, AutocompleteMessages, type AutocompleteNormalizer, AutocompleteParser, AutocompleteResponseMapper, AutocompleteSourceFunction, DEFAULT_MESSAGES, type FilterSuggestionsOptions, createCache, filterSuggestions, fromEndpoint, highlight, mapCommonResponse, normalizeText, parseJsonResponse };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { a as AutocompleteCacheOptions, A as AutocompleteCache, d as AutocompleteEndpointOptions, s as AutocompleteSourceFunction, o as AutocompleteResponseMapper, l as AutocompleteParser, j as AutocompleteMessages, f as AutocompleteHighlightPart } from '../types-CPvjhqjb.js';
|
|
2
|
+
export { b as AutocompleteController, c as AutocompleteEndpoint, e as AutocompleteErrorDetail, g as AutocompleteLoadDetail, h as AutocompleteMessage, i as AutocompleteMessageContext, k as AutocompleteOptions, m as AutocompleteRenderContext, n as AutocompleteRequestInit, p as AutocompleteSelectDetail, q as AutocompleteSource, r as AutocompleteSourceContext, t as AutocompleteTarget } from '../types-CPvjhqjb.js';
|
|
3
|
+
|
|
4
|
+
/** Least-recently-used cache of suggestions keyed by query. */
|
|
5
|
+
declare const createCache: <T>({ max, ttl }?: AutocompleteCacheOptions, now?: () => number) => AutocompleteCache<T>;
|
|
6
|
+
|
|
7
|
+
declare const parseJsonResponse: AutocompleteParser;
|
|
8
|
+
/** Accepts an array, or an object with a `suggestions`, `items` or `data` array. */
|
|
9
|
+
declare const mapCommonResponse: AutocompleteResponseMapper<unknown>;
|
|
10
|
+
/** Builds a source that fetches suggestions from an HTTP endpoint. */
|
|
11
|
+
declare const fromEndpoint: <T>({ endpoint, queryParam, requestInit, parseResponse, mapResponse, }: AutocompleteEndpointOptions<T>) => AutocompleteSourceFunction<T>;
|
|
12
|
+
|
|
13
|
+
declare const DEFAULT_MESSAGES: AutocompleteMessages;
|
|
14
|
+
|
|
15
|
+
type AutocompleteNormalizer = (value: string) => string;
|
|
16
|
+
interface FilterSuggestionsOptions<T> {
|
|
17
|
+
getText: (suggestion: T) => string;
|
|
18
|
+
normalize?: AutocompleteNormalizer;
|
|
19
|
+
}
|
|
20
|
+
/** Lowercases and removes diacritics, so `Cañón` and `canon` compare equal. */
|
|
21
|
+
declare const normalizeText: AutocompleteNormalizer;
|
|
22
|
+
/** Keeps the suggestions whose text contains every word of the query. */
|
|
23
|
+
declare const filterSuggestions: <T>(suggestions: readonly T[], query: string, { getText, normalize }: FilterSuggestionsOptions<T>) => T[];
|
|
24
|
+
/**
|
|
25
|
+
* Splits `text` into parts that match a word of `query` and parts that do
|
|
26
|
+
* not. Matching runs on normalized text but the parts keep the original
|
|
27
|
+
* characters, accents included.
|
|
28
|
+
*/
|
|
29
|
+
declare const highlight: (text: string, query: string, normalize?: AutocompleteNormalizer) => AutocompleteHighlightPart[];
|
|
30
|
+
|
|
31
|
+
export { AutocompleteCache, AutocompleteCacheOptions, AutocompleteEndpointOptions, AutocompleteHighlightPart, AutocompleteMessages, type AutocompleteNormalizer, AutocompleteParser, AutocompleteResponseMapper, AutocompleteSourceFunction, DEFAULT_MESSAGES, type FilterSuggestionsOptions, createCache, filterSuggestions, fromEndpoint, highlight, mapCommonResponse, normalizeText, parseJsonResponse };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import "../chunk-AD7T42HJ.js";
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_MESSAGES,
|
|
4
|
+
createCache,
|
|
5
|
+
filterSuggestions,
|
|
6
|
+
fromEndpoint,
|
|
7
|
+
highlight,
|
|
8
|
+
mapCommonResponse,
|
|
9
|
+
normalizeText,
|
|
10
|
+
parseJsonResponse
|
|
11
|
+
} from "../chunk-4IPBCQDZ.js";
|
|
12
|
+
export {
|
|
13
|
+
DEFAULT_MESSAGES,
|
|
14
|
+
createCache,
|
|
15
|
+
filterSuggestions,
|
|
16
|
+
fromEndpoint,
|
|
17
|
+
highlight,
|
|
18
|
+
mapCommonResponse,
|
|
19
|
+
normalizeText,
|
|
20
|
+
parseJsonResponse
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|