@cloudflare/ai-search-snippet 0.0.25 → 0.0.26
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/dist/main.d.ts +6 -2
- package/dist/search-snippet.es.js +102 -53
- package/dist/search-snippet.es.js.map +1 -1
- package/dist/search-snippet.umd.js +80 -39
- package/dist/search-snippet.umd.js.map +1 -1
- package/package.json +9 -21
- package/README.md +0 -574
- package/dist/clouds.json +0 -417
- package/dist/favicon.ico +0 -0
- package/dist/vite.svg +0 -1
package/dist/main.d.ts
CHANGED
|
@@ -206,7 +206,7 @@ declare class SearchBarSnippet extends HTMLElement {
|
|
|
206
206
|
private handleInputKeydownEnter;
|
|
207
207
|
private handleInputKeydownEscape;
|
|
208
208
|
private handleSearchButtonClick;
|
|
209
|
-
static get observedAttributes(): readonly ["api-url", "placeholder", "max-results", "debounce-ms", "theme", "hide-branding", "show-url"];
|
|
209
|
+
static get observedAttributes(): readonly ["api-url", "placeholder", "max-results", "debounce-ms", "theme", "hide-branding", "show-url", "hide-thumbnails", "see-more"];
|
|
210
210
|
constructor();
|
|
211
211
|
connectedCallback(): void;
|
|
212
212
|
disconnectedCallback(): void;
|
|
@@ -262,7 +262,7 @@ export declare class SearchModalSnippet extends HTMLElement {
|
|
|
262
262
|
private handleBackdropClick;
|
|
263
263
|
private savedBodyStyles;
|
|
264
264
|
private savedHtmlOverflow;
|
|
265
|
-
static get observedAttributes(): readonly ["api-url", "placeholder", "max-results", "theme", "shortcut", "use-meta-key", "debounce-ms", "hide-branding", "show-url"];
|
|
265
|
+
static get observedAttributes(): readonly ["api-url", "placeholder", "max-results", "theme", "shortcut", "use-meta-key", "debounce-ms", "hide-branding", "show-url", "hide-thumbnails", "see-more"];
|
|
266
266
|
constructor();
|
|
267
267
|
connectedCallback(): void;
|
|
268
268
|
disconnectedCallback(): void;
|
|
@@ -358,6 +358,10 @@ export declare interface SearchSnippetProps {
|
|
|
358
358
|
hideBranding?: boolean;
|
|
359
359
|
/** Show URL in search results (default: false) */
|
|
360
360
|
showUrl?: boolean;
|
|
361
|
+
/** Hide thumbnails in search results (default: false) */
|
|
362
|
+
hideThumbnails?: boolean;
|
|
363
|
+
/** URL template for "See more" link. The search query is appended URL-encoded. Example: "https://example.com/search?q=" */
|
|
364
|
+
seeMore?: string;
|
|
361
365
|
}
|
|
362
366
|
|
|
363
367
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var R = Object.defineProperty;
|
|
2
2
|
var H = (o, i, e) => i in o ? R(o, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[i] = e;
|
|
3
3
|
var a = (o, i, e) => H(o, typeof i != "symbol" ? i + "" : i, e);
|
|
4
|
-
const
|
|
4
|
+
const p = [
|
|
5
5
|
"Searching...",
|
|
6
6
|
"Digging through results...",
|
|
7
7
|
"Scanning the knowledge base...",
|
|
@@ -51,7 +51,7 @@ function N(o) {
|
|
|
51
51
|
function E(o = "id") {
|
|
52
52
|
return `${o}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function d(o, i) {
|
|
55
55
|
return o !== null ? o : i;
|
|
56
56
|
}
|
|
57
57
|
function m(o, i) {
|
|
@@ -143,10 +143,10 @@ class P extends _ {
|
|
|
143
143
|
(l) => ({
|
|
144
144
|
type: "result",
|
|
145
145
|
id: l.id,
|
|
146
|
-
title: S(l.item.metadata
|
|
147
|
-
description: l.item.metadata
|
|
146
|
+
title: S(l.item.metadata?.title),
|
|
147
|
+
description: l.item.metadata?.description ? S(l.item.metadata?.description) : "",
|
|
148
148
|
url: l.item.key,
|
|
149
|
-
image: l.item.metadata
|
|
149
|
+
image: l.item.metadata?.image || void 0,
|
|
150
150
|
metadata: l.item.metadata
|
|
151
151
|
})
|
|
152
152
|
);
|
|
@@ -248,7 +248,7 @@ class P extends _ {
|
|
|
248
248
|
const V = `<svg width="32" height="10" viewBox="0 0 412 186" xmlns="http://www.w3.org/2000/svg" aria-label="Cloudflare" role="img">
|
|
249
249
|
<path fill="#f38020" d="m280.8395,183.31456c11,-26 -4,-38 -19,-38l-148,-2c-4,0 -4,-6 1,-7l150,-2c17,-1 37,-15 43,-33c0,0 10,-21 9,-24a97,97 0 0 0 -187,-11c-38,-25 -78,9 -69,46c-48,3 -65,46 -60,72c0,1 1,2 3,2l274,0c1,0 3,-1 3,-3z"/>
|
|
250
250
|
<path fill="#faae40" d="m330.8395,81.31456c-4,0 -6,-1 -7,1l-5,21c-5,16 3,30 20,31l32,2c4,0 4,6 -1,7l-33,1c-36,4 -46,39 -46,39c0,2 0,3 2,3l113,0l3,-2a81,81 0 0 0 -78,-103"/>
|
|
251
|
-
</svg>`,
|
|
251
|
+
</svg>`, j = "https://search.ai.cloudflare.com", y = `Powered by <a href="${j}" target="_blank" rel="noopener noreferrer">Cloudflare AI Search ${V}</a>`, $ = `
|
|
252
252
|
/* Chat container */
|
|
253
253
|
.chat-container {
|
|
254
254
|
display: flex;
|
|
@@ -1000,9 +1000,9 @@ const V = `<svg width="32" height="10" viewBox="0 0 412 186" xmlns="http://www.w
|
|
|
1000
1000
|
text-align: center;
|
|
1001
1001
|
}
|
|
1002
1002
|
`;
|
|
1003
|
-
function
|
|
1003
|
+
function D(o) {
|
|
1004
1004
|
let i = o;
|
|
1005
|
-
i =
|
|
1005
|
+
i = O(i), i = i.replace(/```([\s\S]*?)```/g, (n, c) => `<pre><code>${c.trim()}</code></pre>`);
|
|
1006
1006
|
const e = i.split(`
|
|
1007
1007
|
`), t = [];
|
|
1008
1008
|
let s = !1, r = "";
|
|
@@ -1048,7 +1048,7 @@ function v(o) {
|
|
|
1048
1048
|
'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'
|
|
1049
1049
|
), i;
|
|
1050
1050
|
}
|
|
1051
|
-
function
|
|
1051
|
+
function O(o) {
|
|
1052
1052
|
const i = {
|
|
1053
1053
|
"&": "&",
|
|
1054
1054
|
"<": "<",
|
|
@@ -1229,8 +1229,8 @@ class q {
|
|
|
1229
1229
|
<div class="chat-message-avatar">${s}</div>
|
|
1230
1230
|
<div class="chat-message-content">
|
|
1231
1231
|
<div class="chat-message-bubble">
|
|
1232
|
-
${i.content ? `<div class="chat-message-text">${
|
|
1233
|
-
${e ? `<div class="chat-streaming"><span class="chat-streaming-dot"></span><span class="chat-streaming-dot"></span><span class="chat-streaming-dot"></span><span class="loading-text">${
|
|
1232
|
+
${i.content ? `<div class="chat-message-text">${D(i.content)}</div>` : ""}
|
|
1233
|
+
${e ? `<div class="chat-streaming"><span class="chat-streaming-dot"></span><span class="chat-streaming-dot"></span><span class="chat-streaming-dot"></span><span class="loading-text">${p[this.loadingMessageIndex]}</span></div>` : ""}
|
|
1234
1234
|
</div>
|
|
1235
1235
|
<div class="chat-message-metadata">
|
|
1236
1236
|
<span class="chat-message-time">${N(i.timestamp)}</span>
|
|
@@ -1254,8 +1254,8 @@ class q {
|
|
|
1254
1254
|
this.isStreaming = i, this.inputElement && (this.inputElement.disabled = i), this.sendButton && (this.sendButton.disabled = i, this.sendButton.innerHTML = i ? '<div class="loading"></div>' : "<span>Send</span>"), i ? this.startLoadingMessages() : this.clearLoadingMessages();
|
|
1255
1255
|
}
|
|
1256
1256
|
startLoadingMessages() {
|
|
1257
|
-
this.loadingMessageIndex = Math.floor(Math.random() *
|
|
1258
|
-
this.loadingMessageIndex = (this.loadingMessageIndex + 1) %
|
|
1257
|
+
this.loadingMessageIndex = Math.floor(Math.random() * p.length), this.loadingMessageInterval = setInterval(() => {
|
|
1258
|
+
this.loadingMessageIndex = (this.loadingMessageIndex + 1) % p.length, this.isStreaming && this.renderMessages(!0);
|
|
1259
1259
|
}, 2500);
|
|
1260
1260
|
}
|
|
1261
1261
|
clearLoadingMessages() {
|
|
@@ -1317,9 +1317,9 @@ class K extends HTMLElement {
|
|
|
1317
1317
|
}
|
|
1318
1318
|
getProps() {
|
|
1319
1319
|
return {
|
|
1320
|
-
apiUrl:
|
|
1321
|
-
placeholder:
|
|
1322
|
-
theme:
|
|
1320
|
+
apiUrl: d(this.getAttribute("api-url"), "http://localhost:3000"),
|
|
1321
|
+
placeholder: d(this.getAttribute("placeholder"), "Type a message..."),
|
|
1322
|
+
theme: d(this.getAttribute("theme"), "auto"),
|
|
1323
1323
|
hideBranding: m(this.getAttribute("hide-branding"), !1)
|
|
1324
1324
|
};
|
|
1325
1325
|
}
|
|
@@ -1603,9 +1603,9 @@ class U extends HTMLElement {
|
|
|
1603
1603
|
}
|
|
1604
1604
|
getProps() {
|
|
1605
1605
|
return {
|
|
1606
|
-
apiUrl:
|
|
1607
|
-
placeholder:
|
|
1608
|
-
theme:
|
|
1606
|
+
apiUrl: d(this.getAttribute("api-url"), "http://localhost:3000"),
|
|
1607
|
+
placeholder: d(this.getAttribute("placeholder"), "Type a message..."),
|
|
1608
|
+
theme: d(this.getAttribute("theme"), "auto"),
|
|
1609
1609
|
hideBranding: m(this.getAttribute("hide-branding"), !1)
|
|
1610
1610
|
};
|
|
1611
1611
|
}
|
|
@@ -2260,15 +2260,13 @@ a.search-result-item {
|
|
|
2260
2260
|
height: 64px;
|
|
2261
2261
|
border-radius: calc(var(--search-snippet-border-radius) - 4px);
|
|
2262
2262
|
overflow: hidden;
|
|
2263
|
-
background: var(--search-snippet-surface);
|
|
2264
|
-
border: var(--search-snippet-border-width) solid var(--search-snippet-border-color);
|
|
2265
2263
|
position: relative;
|
|
2266
2264
|
}
|
|
2267
2265
|
|
|
2268
2266
|
.search-result-image {
|
|
2269
2267
|
width: 100%;
|
|
2270
2268
|
height: 100%;
|
|
2271
|
-
object-fit:
|
|
2269
|
+
object-fit: contain;
|
|
2272
2270
|
opacity: 0;
|
|
2273
2271
|
transition: opacity var(--search-snippet-transition);
|
|
2274
2272
|
}
|
|
@@ -2381,13 +2379,29 @@ a.search-result-item:focus-visible {
|
|
|
2381
2379
|
/* Search footer */
|
|
2382
2380
|
.search-footer {
|
|
2383
2381
|
padding: var(--search-snippet-spacing-md);
|
|
2384
|
-
|
|
2382
|
+
padding-bottom: var(--search-snippet-spacing-xs);
|
|
2385
2383
|
display: flex;
|
|
2386
2384
|
align-items: center;
|
|
2387
2385
|
justify-content: center;
|
|
2388
2386
|
gap: var(--search-snippet-spacing-sm);
|
|
2389
2387
|
}
|
|
2390
2388
|
|
|
2389
|
+
/* See more link */
|
|
2390
|
+
.search-see-more {
|
|
2391
|
+
display: inline-flex;
|
|
2392
|
+
align-items: center;
|
|
2393
|
+
gap: var(--search-snippet-spacing-xs);
|
|
2394
|
+
font-size: var(--search-snippet-font-size-sm);
|
|
2395
|
+
color: var(--search-snippet-primary-color);
|
|
2396
|
+
text-decoration: none;
|
|
2397
|
+
font-weight: var(--search-snippet-font-weight-medium);
|
|
2398
|
+
transition: color var(--search-snippet-transition-fast);
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
.search-see-more:hover {
|
|
2402
|
+
text-decoration: underline;
|
|
2403
|
+
}
|
|
2404
|
+
|
|
2391
2405
|
/* Loading state for search */
|
|
2392
2406
|
.search-loading {
|
|
2393
2407
|
display: flex;
|
|
@@ -2464,7 +2478,9 @@ class F extends HTMLElement {
|
|
|
2464
2478
|
"debounce-ms",
|
|
2465
2479
|
"theme",
|
|
2466
2480
|
"hide-branding",
|
|
2467
|
-
"show-url"
|
|
2481
|
+
"show-url",
|
|
2482
|
+
"hide-thumbnails",
|
|
2483
|
+
"see-more"
|
|
2468
2484
|
];
|
|
2469
2485
|
}
|
|
2470
2486
|
connectedCallback() {
|
|
@@ -2478,13 +2494,15 @@ class F extends HTMLElement {
|
|
|
2478
2494
|
}
|
|
2479
2495
|
getProps() {
|
|
2480
2496
|
return {
|
|
2481
|
-
apiUrl:
|
|
2482
|
-
placeholder:
|
|
2497
|
+
apiUrl: d(this.getAttribute("api-url"), "http://localhost:3000"),
|
|
2498
|
+
placeholder: d(this.getAttribute("placeholder"), "Search..."),
|
|
2483
2499
|
maxResults: f(this.getAttribute("max-results"), 10),
|
|
2484
2500
|
debounceMs: f(this.getAttribute("debounce-ms"), 300),
|
|
2485
|
-
theme:
|
|
2501
|
+
theme: d(this.getAttribute("theme"), "auto"),
|
|
2486
2502
|
hideBranding: m(this.getAttribute("hide-branding"), !1),
|
|
2487
|
-
showUrl: m(this.getAttribute("show-url"), !1)
|
|
2503
|
+
showUrl: m(this.getAttribute("show-url"), !1),
|
|
2504
|
+
hideThumbnails: m(this.getAttribute("hide-thumbnails"), !1),
|
|
2505
|
+
seeMore: d(this.getAttribute("see-more"), "")
|
|
2488
2506
|
};
|
|
2489
2507
|
}
|
|
2490
2508
|
initializeClient() {
|
|
@@ -2571,7 +2589,12 @@ ${G}`, this.container = document.createElement("div"), this.container.className
|
|
|
2571
2589
|
this.showNoResultsState(t);
|
|
2572
2590
|
return;
|
|
2573
2591
|
}
|
|
2574
|
-
const
|
|
2592
|
+
const s = this.getProps(), r = s.hideBranding ? "" : `<div class="powered-by-inline">${y}</div>`, n = s.seeMore ? `<div class="search-footer">
|
|
2593
|
+
<a href="${h(s.seeMore + encodeURIComponent(t))}" class="search-see-more">
|
|
2594
|
+
<span>See more results</span>
|
|
2595
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg>
|
|
2596
|
+
</a>
|
|
2597
|
+
</div>` : "", c = `
|
|
2575
2598
|
<div class="search-header">
|
|
2576
2599
|
<div class="search-count">
|
|
2577
2600
|
Found ${e.length} result${e.length === 1 ? "" : "s"}
|
|
@@ -2579,13 +2602,14 @@ ${G}`, this.container = document.createElement("div"), this.container.className
|
|
|
2579
2602
|
${r}
|
|
2580
2603
|
</div>
|
|
2581
2604
|
<div class="search-results">
|
|
2582
|
-
${e.map((
|
|
2605
|
+
${e.map((l) => this.renderResult(l)).join("")}
|
|
2583
2606
|
</div>
|
|
2607
|
+
${n}
|
|
2584
2608
|
`;
|
|
2585
|
-
this.resultsContainer.innerHTML =
|
|
2609
|
+
this.resultsContainer.innerHTML = c, this.attachResultHandlers();
|
|
2586
2610
|
}
|
|
2587
2611
|
renderResult(e) {
|
|
2588
|
-
const t = this.getProps(), s = this.renderResultImage(e.image, e.title);
|
|
2612
|
+
const t = this.getProps(), s = t.hideThumbnails ? "" : this.renderResultImage(e.image, e.title);
|
|
2589
2613
|
return `
|
|
2590
2614
|
<a href="${e.url ? h(e.url) : "#"}" class="search-result-item" data-result-id="${h(e.url || "")}">
|
|
2591
2615
|
${s}
|
|
@@ -2637,18 +2661,18 @@ ${G}`, this.container = document.createElement("div"), this.container.className
|
|
|
2637
2661
|
});
|
|
2638
2662
|
}
|
|
2639
2663
|
showLoadingState() {
|
|
2640
|
-
this.resultsContainer && (this.clearLoadingInterval(), this.loadingMessageIndex = Math.floor(Math.random() *
|
|
2664
|
+
this.resultsContainer && (this.clearLoadingInterval(), this.loadingMessageIndex = Math.floor(Math.random() * p.length), this.resultsContainer.innerHTML = `
|
|
2641
2665
|
<div class="search-loading">
|
|
2642
2666
|
<div class="loading" aria-label="Loading"></div>
|
|
2643
|
-
<div class="loading-text loading-text-animate">${
|
|
2667
|
+
<div class="loading-text loading-text-animate">${p[this.loadingMessageIndex]}</div>
|
|
2644
2668
|
</div>
|
|
2645
2669
|
`, this.startLoadingInterval());
|
|
2646
2670
|
}
|
|
2647
2671
|
startLoadingInterval() {
|
|
2648
2672
|
this.loadingMessageInterval = setInterval(() => {
|
|
2649
|
-
this.loadingMessageIndex = (this.loadingMessageIndex + 1) %
|
|
2673
|
+
this.loadingMessageIndex = (this.loadingMessageIndex + 1) % p.length;
|
|
2650
2674
|
const e = this.resultsContainer?.querySelector(".loading-text");
|
|
2651
|
-
e && (e.classList.remove("loading-text-animate"), e.offsetWidth, e.textContent =
|
|
2675
|
+
e && (e.classList.remove("loading-text-animate"), e.offsetWidth, e.textContent = p[this.loadingMessageIndex], e.classList.add("loading-text-animate"));
|
|
2652
2676
|
}, 2500);
|
|
2653
2677
|
}
|
|
2654
2678
|
clearLoadingInterval() {
|
|
@@ -2859,15 +2883,13 @@ a.modal-result-item {
|
|
|
2859
2883
|
height: 48px;
|
|
2860
2884
|
border-radius: 6px;
|
|
2861
2885
|
overflow: hidden;
|
|
2862
|
-
background: var(--search-snippet-surface);
|
|
2863
|
-
border: var(--search-snippet-border-width) solid var(--search-snippet-border-color);
|
|
2864
2886
|
position: relative;
|
|
2865
2887
|
}
|
|
2866
2888
|
|
|
2867
2889
|
.modal-result-image {
|
|
2868
2890
|
width: 100%;
|
|
2869
2891
|
height: 100%;
|
|
2870
|
-
object-fit:
|
|
2892
|
+
object-fit: contain;
|
|
2871
2893
|
opacity: 0;
|
|
2872
2894
|
transition: opacity var(--search-snippet-transition);
|
|
2873
2895
|
}
|
|
@@ -3073,6 +3095,26 @@ a.modal-result-item:focus-visible {
|
|
|
3073
3095
|
color: var(--search-snippet-primary-color);
|
|
3074
3096
|
}
|
|
3075
3097
|
|
|
3098
|
+
/* See more link */
|
|
3099
|
+
.modal-see-more {
|
|
3100
|
+
display: flex;
|
|
3101
|
+
align-items: center;
|
|
3102
|
+
justify-content: center;
|
|
3103
|
+
gap: var(--search-snippet-spacing-xs);
|
|
3104
|
+
padding: var(--search-snippet-spacing-md);
|
|
3105
|
+
font-size: var(--search-snippet-font-size-sm);
|
|
3106
|
+
color: var(--search-snippet-primary-color);
|
|
3107
|
+
text-decoration: none;
|
|
3108
|
+
font-weight: var(--search-snippet-font-weight-medium);
|
|
3109
|
+
transition: background var(--search-snippet-transition-fast);
|
|
3110
|
+
padding-bottom: var(--search-snippet-spacing-xs);
|
|
3111
|
+
}
|
|
3112
|
+
|
|
3113
|
+
.modal-see-more:hover {
|
|
3114
|
+
background: var(--search-snippet-hover);
|
|
3115
|
+
text-decoration: underline;
|
|
3116
|
+
}
|
|
3117
|
+
|
|
3076
3118
|
/* Responsive adjustments */
|
|
3077
3119
|
@media (max-width: 640px) {
|
|
3078
3120
|
.modal-container {
|
|
@@ -3139,7 +3181,9 @@ class W extends HTMLElement {
|
|
|
3139
3181
|
"use-meta-key",
|
|
3140
3182
|
"debounce-ms",
|
|
3141
3183
|
"hide-branding",
|
|
3142
|
-
"show-url"
|
|
3184
|
+
"show-url",
|
|
3185
|
+
"hide-thumbnails",
|
|
3186
|
+
"see-more"
|
|
3143
3187
|
];
|
|
3144
3188
|
}
|
|
3145
3189
|
connectedCallback() {
|
|
@@ -3153,15 +3197,17 @@ class W extends HTMLElement {
|
|
|
3153
3197
|
}
|
|
3154
3198
|
getProps() {
|
|
3155
3199
|
return {
|
|
3156
|
-
apiUrl:
|
|
3157
|
-
placeholder:
|
|
3200
|
+
apiUrl: d(this.getAttribute("api-url"), "http://localhost:3000"),
|
|
3201
|
+
placeholder: d(this.getAttribute("placeholder"), "Search..."),
|
|
3158
3202
|
maxResults: f(this.getAttribute("max-results"), 10),
|
|
3159
3203
|
debounceMs: f(this.getAttribute("debounce-ms"), 300),
|
|
3160
|
-
theme:
|
|
3161
|
-
shortcut:
|
|
3204
|
+
theme: d(this.getAttribute("theme"), "auto"),
|
|
3205
|
+
shortcut: d(this.getAttribute("shortcut"), "k"),
|
|
3162
3206
|
useMetaKey: this.getAttribute("use-meta-key") !== "false",
|
|
3163
3207
|
hideBranding: m(this.getAttribute("hide-branding"), !1),
|
|
3164
|
-
showUrl: m(this.getAttribute("show-url"), !1)
|
|
3208
|
+
showUrl: m(this.getAttribute("show-url"), !1),
|
|
3209
|
+
hideThumbnails: m(this.getAttribute("hide-thumbnails"), !1),
|
|
3210
|
+
seeMore: d(this.getAttribute("see-more"), "")
|
|
3165
3211
|
};
|
|
3166
3212
|
}
|
|
3167
3213
|
initializeClient() {
|
|
@@ -3313,11 +3359,14 @@ ${Y}`;
|
|
|
3313
3359
|
this.showNoResultsState(t);
|
|
3314
3360
|
return;
|
|
3315
3361
|
}
|
|
3316
|
-
const s = e.map((
|
|
3317
|
-
|
|
3362
|
+
const s = this.getProps(), r = e.map((c, l) => this.renderResult(c, l)).join(""), n = s.seeMore ? `<a href="${h(s.seeMore + encodeURIComponent(t))}" class="modal-see-more">
|
|
3363
|
+
<span>See more results</span>
|
|
3364
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg>
|
|
3365
|
+
</a>` : "";
|
|
3366
|
+
this.resultsContainer.innerHTML = r + n, this.footerCount && (this.footerCount.textContent = `${e.length} result${e.length === 1 ? "" : "s"}`), this.inputElement && this.inputElement.setAttribute("aria-expanded", "true"), this.attachResultHandlers(), this.updateActiveResult();
|
|
3318
3367
|
}
|
|
3319
3368
|
renderResult(e, t) {
|
|
3320
|
-
const s = this.getProps(), r = this.renderResultImage(e.image, e.title);
|
|
3369
|
+
const s = this.getProps(), r = s.hideThumbnails ? "" : this.renderResultImage(e.image, e.title);
|
|
3321
3370
|
return `
|
|
3322
3371
|
<a
|
|
3323
3372
|
href="${e.url ? h(e.url) : "#"}"
|
|
@@ -3394,18 +3443,18 @@ ${Y}`;
|
|
|
3394
3443
|
this.clearLoadingInterval(), this.resultsContainer && (this.resultsContainer.innerHTML = this.renderEmptyState(), this.footerCount && (this.footerCount.textContent = ""), this.inputElement && this.inputElement.setAttribute("aria-expanded", "false"));
|
|
3395
3444
|
}
|
|
3396
3445
|
showLoadingState() {
|
|
3397
|
-
this.resultsContainer && (this.clearLoadingInterval(), this.loadingMessageIndex = Math.floor(Math.random() *
|
|
3446
|
+
this.resultsContainer && (this.clearLoadingInterval(), this.loadingMessageIndex = Math.floor(Math.random() * p.length), this.resultsContainer.innerHTML = `
|
|
3398
3447
|
<div class="modal-loading">
|
|
3399
3448
|
<div class="loading" aria-label="Loading"></div>
|
|
3400
|
-
<div class="loading-text loading-text-animate">${
|
|
3449
|
+
<div class="loading-text loading-text-animate">${p[this.loadingMessageIndex]}</div>
|
|
3401
3450
|
</div>
|
|
3402
|
-
`, this.footerCount && (this.footerCount.textContent =
|
|
3451
|
+
`, this.footerCount && (this.footerCount.textContent = p[this.loadingMessageIndex]), this.startLoadingInterval());
|
|
3403
3452
|
}
|
|
3404
3453
|
startLoadingInterval() {
|
|
3405
3454
|
this.loadingMessageInterval = setInterval(() => {
|
|
3406
|
-
this.loadingMessageIndex = (this.loadingMessageIndex + 1) %
|
|
3455
|
+
this.loadingMessageIndex = (this.loadingMessageIndex + 1) % p.length;
|
|
3407
3456
|
const e = this.resultsContainer?.querySelector(".loading-text");
|
|
3408
|
-
e && (e.classList.remove("loading-text-animate"), e.offsetWidth, e.textContent =
|
|
3457
|
+
e && (e.classList.remove("loading-text-animate"), e.offsetWidth, e.textContent = p[this.loadingMessageIndex], e.classList.add("loading-text-animate")), this.footerCount && (this.footerCount.textContent = p[this.loadingMessageIndex]);
|
|
3409
3458
|
}, 2500);
|
|
3410
3459
|
}
|
|
3411
3460
|
clearLoadingInterval() {
|