@molecule/app-search-ui-angular 0.0.0-stage → 1.1.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.
@@ -0,0 +1,519 @@
1
+ /**
2
+ * SearchResults component (React parity).
3
+ *
4
+ * @module
5
+ */
6
+ import { NgTemplateOutlet } from '@angular/common';
7
+ import { Component, ElementRef, inject, ViewChild, } from '@angular/core';
8
+ import { useTranslation } from '@molecule/app-angular';
9
+ import { getClassMap } from '@molecule/app-ui';
10
+ import { Highlight } from './highlight.component.js';
11
+ import * as i0 from "@angular/core";
12
+ const _c0 = ["listEl"];
13
+ const _c1 = ["rowBody"];
14
+ const _c2 = () => ({ defaultValue: "Search results" });
15
+ const _c3 = a0 => ({ $implicit: a0 });
16
+ const _c4 = () => ({ align: "baseline", wrap: "wrap", gap: 2 });
17
+ const _forTrack0 = ($index, $item) => $item.id;
18
+ function SearchResults_Conditional_0_Template(rf, ctx) { if (rf & 1) {
19
+ i0.ɵɵelementStart(0, "p");
20
+ i0.ɵɵtext(1);
21
+ i0.ɵɵelementEnd();
22
+ i0.ɵɵelement(2, "p", 2);
23
+ } if (rf & 2) {
24
+ const ctx_r0 = i0.ɵɵnextContext();
25
+ i0.ɵɵclassMap(ctx_r0.cm().cn(ctx_r0.cm().resultEmpty));
26
+ i0.ɵɵattribute("data-mol-id", ctx_r0.id() + "-empty");
27
+ i0.ɵɵadvance();
28
+ i0.ɵɵtextInterpolate(ctx_r0.emptyText);
29
+ i0.ɵɵadvance();
30
+ i0.ɵɵclassMap(ctx_r0.cm().cn(ctx_r0.cm().srOnly));
31
+ i0.ɵɵattribute("data-mol-id", ctx_r0.id() + "-active");
32
+ } }
33
+ function SearchResults_Conditional_1_For_3_Conditional_1_Template(rf, ctx) { if (rf & 1) {
34
+ i0.ɵɵelementContainer(0, 5);
35
+ } if (rf & 2) {
36
+ const hit_r4 = i0.ɵɵnextContext().$implicit;
37
+ const ctx_r0 = i0.ɵɵnextContext(2);
38
+ i0.ɵɵproperty("ngTemplateOutlet", ctx_r0.renderLink)("ngTemplateOutletContext", ctx_r0.renderContext(ctx_r0.linkProps(hit_r4)));
39
+ } }
40
+ function SearchResults_Conditional_1_For_3_Conditional_2_Template(rf, ctx) { if (rf & 1) {
41
+ const _r6 = i0.ɵɵgetCurrentView();
42
+ i0.ɵɵelementStart(0, "a", 6);
43
+ i0.ɵɵlistener("click", function SearchResults_Conditional_1_For_3_Conditional_2_Template_a_click_0_listener($event) { i0.ɵɵrestoreView(_r6); const hit_r4 = i0.ɵɵnextContext().$implicit; const ctx_r0 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r0.openFromLink($event, hit_r4)); });
44
+ i0.ɵɵelementContainer(1, 5);
45
+ i0.ɵɵelementEnd();
46
+ } if (rf & 2) {
47
+ const hit_r4 = i0.ɵɵnextContext().$implicit;
48
+ const ctx_r0 = i0.ɵɵnextContext(2);
49
+ const rowBody_r7 = i0.ɵɵreference(3);
50
+ i0.ɵɵclassMap(ctx_r0.cm().cn(ctx_r0.cm().resultBody));
51
+ i0.ɵɵattribute("href", ctx_r0.viewOf(hit_r4).href, i0.ɵɵsanitizeUrl)("data-mol-id", ctx_r0.id() + "-link");
52
+ i0.ɵɵadvance();
53
+ i0.ɵɵproperty("ngTemplateOutlet", rowBody_r7)("ngTemplateOutletContext", i0.ɵɵpureFunction1(6, _c3, hit_r4));
54
+ } }
55
+ function SearchResults_Conditional_1_For_3_Conditional_3_Template(rf, ctx) { if (rf & 1) {
56
+ i0.ɵɵelementStart(0, "span");
57
+ i0.ɵɵelementContainer(1, 5);
58
+ i0.ɵɵelementEnd();
59
+ } if (rf & 2) {
60
+ const hit_r4 = i0.ɵɵnextContext().$implicit;
61
+ const ctx_r0 = i0.ɵɵnextContext(2);
62
+ i0.ɵɵclassMap(ctx_r0.cm().cn(ctx_r0.cm().resultAction));
63
+ i0.ɵɵadvance();
64
+ i0.ɵɵproperty("ngTemplateOutlet", ctx_r0.action)("ngTemplateOutletContext", ctx_r0.renderContext(hit_r4.doc));
65
+ } }
66
+ function SearchResults_Conditional_1_For_3_Template(rf, ctx) { if (rf & 1) {
67
+ const _r2 = i0.ɵɵgetCurrentView();
68
+ i0.ɵɵelementStart(0, "li", 4);
69
+ i0.ɵɵlistener("pointerover", function SearchResults_Conditional_1_For_3_Template_li_pointerover_0_listener() { const ctx_r2 = i0.ɵɵrestoreView(_r2); const hit_r4 = ctx_r2.$implicit; const ɵ$index_10_r5 = ctx_r2.$index; const ctx_r0 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r0.onPointerOver(ɵ$index_10_r5, hit_r4)); })("focusin", function SearchResults_Conditional_1_For_3_Template_li_focusin_0_listener() { const hit_r4 = i0.ɵɵrestoreView(_r2).$implicit; const ctx_r0 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r0.onPrefetch?.(hit_r4.doc)); })("touchstart", function SearchResults_Conditional_1_For_3_Template_li_touchstart_0_listener() { const hit_r4 = i0.ɵɵrestoreView(_r2).$implicit; const ctx_r0 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r0.onPrefetch?.(hit_r4.doc)); });
70
+ i0.ɵɵconditionalCreate(1, SearchResults_Conditional_1_For_3_Conditional_1_Template, 1, 2, "ng-container", 5)(2, SearchResults_Conditional_1_For_3_Conditional_2_Template, 2, 8, "a", 3);
71
+ i0.ɵɵconditionalCreate(3, SearchResults_Conditional_1_For_3_Conditional_3_Template, 2, 4, "span", 3);
72
+ i0.ɵɵelementEnd();
73
+ } if (rf & 2) {
74
+ const hit_r4 = ctx.$implicit;
75
+ const ɵ$index_10_r5 = ctx.$index;
76
+ const ctx_r0 = i0.ɵɵnextContext(2);
77
+ i0.ɵɵclassMap(ctx_r0.itemClasses(ɵ$index_10_r5));
78
+ i0.ɵɵattribute("aria-current", ɵ$index_10_r5 === ctx_r0.activeIndex ? "true" : null)("data-index", ɵ$index_10_r5)("data-mol-id", ctx_r0.id() + "-hit")("data-hit-id", hit_r4.id);
79
+ i0.ɵɵadvance();
80
+ i0.ɵɵconditional(ctx_r0.renderLink ? 1 : 2);
81
+ i0.ɵɵadvance(2);
82
+ i0.ɵɵconditional(ctx_r0.action ? 3 : -1);
83
+ } }
84
+ function SearchResults_Conditional_1_Template(rf, ctx) { if (rf & 1) {
85
+ i0.ɵɵelementStart(0, "ul", null, 1);
86
+ i0.ɵɵrepeaterCreate(2, SearchResults_Conditional_1_For_3_Template, 4, 8, "li", 3, _forTrack0);
87
+ i0.ɵɵelementEnd();
88
+ i0.ɵɵelementStart(4, "p", 2);
89
+ i0.ɵɵtext(5);
90
+ i0.ɵɵelementEnd();
91
+ } if (rf & 2) {
92
+ const ctx_r0 = i0.ɵɵnextContext();
93
+ i0.ɵɵclassMap(ctx_r0.listClasses());
94
+ i0.ɵɵattribute("aria-label", ctx_r0.t("searchUi.results", undefined, i0.ɵɵpureFunction0(8, _c2)))("data-mol-id", ctx_r0.id() + "-results");
95
+ i0.ɵɵadvance(2);
96
+ i0.ɵɵrepeater(ctx_r0.hits);
97
+ i0.ɵɵadvance(2);
98
+ i0.ɵɵclassMap(ctx_r0.cm().cn(ctx_r0.cm().srOnly));
99
+ i0.ɵɵattribute("data-mol-id", ctx_r0.id() + "-active");
100
+ i0.ɵɵadvance();
101
+ i0.ɵɵtextInterpolate1(" ", ctx_r0.activeText(), " ");
102
+ } }
103
+ function SearchResults_ng_template_2_Conditional_3_Template(rf, ctx) { if (rf & 1) {
104
+ i0.ɵɵelementStart(0, "span");
105
+ i0.ɵɵtext(1);
106
+ i0.ɵɵelementEnd();
107
+ } if (rf & 2) {
108
+ const hit_r8 = i0.ɵɵnextContext().$implicit;
109
+ const ctx_r0 = i0.ɵɵnextContext();
110
+ i0.ɵɵclassMap(ctx_r0.cm().cn(ctx_r0.cm().resultMeta));
111
+ i0.ɵɵadvance();
112
+ i0.ɵɵtextInterpolate(ctx_r0.metaOf(hit_r8).join(" \u00B7 "));
113
+ } }
114
+ function SearchResults_ng_template_2_Conditional_4_Template(rf, ctx) { if (rf & 1) {
115
+ i0.ɵɵelementStart(0, "span");
116
+ i0.ɵɵtext(1);
117
+ i0.ɵɵelementEnd();
118
+ } if (rf & 2) {
119
+ const ctx_r0 = i0.ɵɵnextContext(2);
120
+ i0.ɵɵclassMap(ctx_r0.cm().cn(ctx_r0.cm().resultMeta));
121
+ i0.ɵɵattribute("data-mol-id", ctx_r0.id() + "-related")("title", ctx_r0.relatedTitle());
122
+ i0.ɵɵadvance();
123
+ i0.ɵɵtextInterpolate(ctx_r0.relatedText());
124
+ } }
125
+ function SearchResults_ng_template_2_Conditional_5_Template(rf, ctx) { if (rf & 1) {
126
+ i0.ɵɵelementStart(0, "span");
127
+ i0.ɵɵelement(1, "mol-highlight", 7);
128
+ i0.ɵɵelementEnd();
129
+ } if (rf & 2) {
130
+ const hit_r8 = i0.ɵɵnextContext().$implicit;
131
+ const ctx_r0 = i0.ɵɵnextContext();
132
+ i0.ɵɵclassMap(ctx_r0.cm().cn(ctx_r0.cm().resultDescription, ctx_r0.cm().displayBlock));
133
+ i0.ɵɵadvance();
134
+ i0.ɵɵproperty("text", ctx_r0.viewOf(hit_r8).description)("terms", hit_r8.terms);
135
+ } }
136
+ function SearchResults_ng_template_2_Template(rf, ctx) { if (rf & 1) {
137
+ i0.ɵɵelementStart(0, "span")(1, "span");
138
+ i0.ɵɵelement(2, "mol-highlight", 7);
139
+ i0.ɵɵelementEnd();
140
+ i0.ɵɵconditionalCreate(3, SearchResults_ng_template_2_Conditional_3_Template, 2, 3, "span", 3);
141
+ i0.ɵɵconditionalCreate(4, SearchResults_ng_template_2_Conditional_4_Template, 2, 5, "span", 3);
142
+ i0.ɵɵelementEnd();
143
+ i0.ɵɵconditionalCreate(5, SearchResults_ng_template_2_Conditional_5_Template, 2, 4, "span", 3);
144
+ } if (rf & 2) {
145
+ const hit_r8 = ctx.$implicit;
146
+ const ctx_r0 = i0.ɵɵnextContext();
147
+ i0.ɵɵclassMap(ctx_r0.cm().flex(i0.ɵɵpureFunction0(9, _c4)));
148
+ i0.ɵɵadvance();
149
+ i0.ɵɵclassMap(ctx_r0.titleClasses(hit_r8));
150
+ i0.ɵɵadvance();
151
+ i0.ɵɵproperty("text", ctx_r0.viewOf(hit_r8).title)("terms", hit_r8.terms);
152
+ i0.ɵɵadvance();
153
+ i0.ɵɵconditional(ctx_r0.metaOf(hit_r8).length > 0 ? 3 : -1);
154
+ i0.ɵɵadvance();
155
+ i0.ɵɵconditional(hit_r8.related ? 4 : -1);
156
+ i0.ɵɵadvance();
157
+ i0.ɵɵconditional(ctx_r0.viewOf(hit_r8).description ? 5 : -1);
158
+ } }
159
+ /**
160
+ * The default row link is a plain anchor; the row body renders through the
161
+ * `rowBody` template. React's root is a FRAGMENT of two nodes (the `<ul>` and
162
+ * a visually hidden status `<p>`, or the empty text `<p>` and the status `<p>`),
163
+ * so the host is unwrapped (`data-parity-unwrap`, `display: contents`) and
164
+ * renders exactly React's root.
165
+ *
166
+ * The ranked hits: title and description with the matched terms marked, the
167
+ * meta line, hover making a row active and warming its page. The whole row is
168
+ * the link, so the list is a plain list of links (no listbox roles: an option's
169
+ * children are presentational and would hide the row's link and action); the
170
+ * active row is marked with `aria-current` on its `<li>` and announced through
171
+ * a polite, visually hidden status region after the list.
172
+ */
173
+ export class SearchResults {
174
+ /** The hits to render. */
175
+ hits = [];
176
+ /** How a hit renders. */
177
+ view;
178
+ /** The keyboard- or pointer-active row, or `-1`. */
179
+ activeIndex = -1;
180
+ /** The pointer moved onto a row. */
181
+ onActivate;
182
+ /** A row was chosen (a plain click, or Enter elsewhere). Navigation is the caller's. */
183
+ onOpen;
184
+ /** The person is about to open a row (hover, focus, touch): warm its page. */
185
+ onPrefetch;
186
+ /**
187
+ * Renders the row's link. Defaults to a plain `<a>`; a `TemplateRef` whose
188
+ * context carries the link props as `$implicit`.
189
+ */
190
+ renderLink;
191
+ /** Something at the row's end (an action button); a `TemplateRef` over the hit's document. */
192
+ action;
193
+ /** Shown when there are no hits. */
194
+ emptyText = '';
195
+ /** `data-mol-id` prefix: `<molId>-results`, `-hit`, `-link`, `-related`, `-empty`, `-active`. */
196
+ molId;
197
+ /** Extra classes composed onto the list. */
198
+ className;
199
+ /** The list element, read to keep the active row in view. */
200
+ listEl;
201
+ /** The row body template, handed to a custom `renderLink` as its children. */
202
+ rowBodyTpl;
203
+ /** i18n handle, read in an injection context. */
204
+ t = useTranslation().t;
205
+ /**
206
+ * The current class map.
207
+ * @returns The UIClassMap.
208
+ */
209
+ cm() {
210
+ return getClassMap();
211
+ }
212
+ /**
213
+ * The `data-mol-id` prefix (React's default parameter).
214
+ * @returns The prefix.
215
+ */
216
+ id() {
217
+ return this.molId ?? 'search';
218
+ }
219
+ /**
220
+ * A hit's view (the caller's `view` over the hit's document).
221
+ *
222
+ * @param hit - The hit.
223
+ * @returns The view.
224
+ */
225
+ viewOf(hit) {
226
+ return this.view(hit.doc);
227
+ }
228
+ /**
229
+ * A hit's meta facts (a copy, as React makes).
230
+ *
231
+ * @param hit - The hit.
232
+ * @returns The meta list.
233
+ */
234
+ metaOf(hit) {
235
+ return [...(this.viewOf(hit).meta ?? [])];
236
+ }
237
+ /**
238
+ * The context a render template reads: the render function's first argument
239
+ * as and , as the kit's adapter templates declare it.
240
+ *
241
+ * @param arg - The render function's first argument.
242
+ * @returns The template context.
243
+ */
244
+ renderContext(arg) {
245
+ return { $implicit: arg, a0: arg, a1: undefined, a2: undefined };
246
+ }
247
+ /**
248
+ * The list's class list (`cm.resultList` + `className`).
249
+ * @returns The class string.
250
+ */
251
+ listClasses() {
252
+ return this.cm().cn(this.cm().resultList, this.className);
253
+ }
254
+ /**
255
+ * A row's class list (`cm.resultItem`, active when the row is).
256
+ *
257
+ * @param index - The row's index.
258
+ * @returns The class string.
259
+ */
260
+ itemClasses(index) {
261
+ return this.cm().cn(this.cm().resultItem, index === this.activeIndex && this.cm().resultItemActive);
262
+ }
263
+ /**
264
+ * The related badge's text, translated like React renders it.
265
+ * @returns The text.
266
+ */
267
+ relatedText() {
268
+ return this.t('searchUi.related', undefined, { defaultValue: 'related' });
269
+ }
270
+ /**
271
+ * The related badge's tooltip, translated like React renders it.
272
+ * @returns The title text.
273
+ */
274
+ relatedTitle() {
275
+ return this.t('searchUi.relatedTitle', undefined, {
276
+ defaultValue: 'Matches the meaning of your search, not its words',
277
+ });
278
+ }
279
+ /**
280
+ * The active row's announcement (title, position, count), empty when no row
281
+ * is keyboard-active, translated like React renders it.
282
+ * @returns The status text.
283
+ */
284
+ activeText() {
285
+ const hit = this.activeIndex >= 0 ? this.hits[this.activeIndex] : undefined;
286
+ if (!hit)
287
+ return '';
288
+ return this.t('searchUi.activeResult', {
289
+ title: this.viewOf(hit).title,
290
+ position: this.activeIndex + 1,
291
+ count: this.hits.length,
292
+ }, { defaultValue: '{{title}}, {{position}} of {{count}}' });
293
+ }
294
+ /**
295
+ * A row title's class list (`cm.resultTitle`, monospace when the view asks).
296
+ *
297
+ * @param hit - The hit.
298
+ * @returns The class string.
299
+ */
300
+ titleClasses(hit) {
301
+ const v = this.viewOf(hit);
302
+ return this.cm().cn(this.cm().resultTitle, v.mono && this.cm().resultTitleMono);
303
+ }
304
+ /**
305
+ * The link props one row's link gets. `children` is the row body as a
306
+ * `TemplateRef`: render it with the hit as its `$implicit` context (the
307
+ * ready node a React `renderLink` receives has no Angular equivalent).
308
+ *
309
+ * @param hit - The hit.
310
+ * @returns The link props.
311
+ */
312
+ linkProps(hit) {
313
+ const v = this.viewOf(hit);
314
+ return {
315
+ href: v.href,
316
+ state: v.state,
317
+ className: this.cm().resultBody,
318
+ 'data-mol-id': `${this.id()}-link`,
319
+ children: this.rowBodyTpl,
320
+ onClick: (event) => {
321
+ // A modified click opens a new tab; the router handles the rest.
322
+ if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0)
323
+ return;
324
+ event.preventDefault();
325
+ this.onOpen(hit.doc);
326
+ },
327
+ };
328
+ }
329
+ /**
330
+ * Opens a hit for a plain click on the default anchor.
331
+ *
332
+ * @param event - The click event.
333
+ * @param hit - The hit.
334
+ */
335
+ openFromLink(event, hit) {
336
+ // A modified click opens a new tab; the router handles the rest.
337
+ if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0)
338
+ return;
339
+ event.preventDefault();
340
+ this.onOpen(hit.doc);
341
+ }
342
+ /**
343
+ * A pointer moving onto a row makes it active and warms its page, as
344
+ * React's `onPointerEnter` does.
345
+ *
346
+ * @param index - The row's index.
347
+ * @param hit - The hit.
348
+ */
349
+ onPointerOver(index, hit) {
350
+ this.onActivate?.(index);
351
+ this.onPrefetch?.(hit.doc);
352
+ }
353
+ /**
354
+ * Keeps the keyboard-active row in view, the way React's effect keyed on
355
+ * `activeIndex` does.
356
+ *
357
+ * @param changes - The changed inputs.
358
+ */
359
+ ngOnChanges(changes) {
360
+ if (changes['activeIndex'])
361
+ this.keepInView();
362
+ }
363
+ /** Keeps the active row in view after the list first renders, and adopts the rendered root. */
364
+ ngAfterViewInit() {
365
+ this.adopt();
366
+ this.keepInView();
367
+ }
368
+ /**
369
+ * Adopts the rendered root beside the host on every check (a props step may
370
+ * re-render it), the way the kit's session gate and the UI kit's Tooltip
371
+ * adopt theirs: React's root is a fragment, so the focus path and the real
372
+ * DOM must not carry the host between the app and the list.
373
+ */
374
+ ngDoCheck() {
375
+ this.adopt();
376
+ }
377
+ /** The host element (the unwrapped wrapper holding React's root). */
378
+ hostEl = inject((ElementRef)).nativeElement;
379
+ /** Moves the rendered root beside the host, so the host stays empty. */
380
+ adopt() {
381
+ const parent = this.hostEl.parentNode;
382
+ if (!parent)
383
+ return;
384
+ for (const node of Array.from(this.hostEl.childNodes))
385
+ parent.insertBefore(node, this.hostEl);
386
+ }
387
+ /** Scrolls the active row into view when there is one. */
388
+ keepInView() {
389
+ const index = this.activeIndex;
390
+ if (index < 0)
391
+ return;
392
+ const el = this.listEl?.nativeElement.querySelector(`[data-index="${index}"]`);
393
+ el?.scrollIntoView?.({ block: 'nearest' });
394
+ }
395
+ static ɵfac = function SearchResults_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || SearchResults)(); };
396
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SearchResults, selectors: [["mol-search-results"]], viewQuery: function SearchResults_Query(rf, ctx) { if (rf & 1) {
397
+ i0.ɵɵviewQuery(_c0, 5)(_c1, 5);
398
+ } if (rf & 2) {
399
+ let _t;
400
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.listEl = _t.first);
401
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.rowBodyTpl = _t.first);
402
+ } }, hostAttrs: ["data-parity-unwrap", "", 2, "display", "contents"], inputs: { hits: "hits", view: "view", activeIndex: "activeIndex", onActivate: "onActivate", onOpen: "onOpen", onPrefetch: "onPrefetch", renderLink: "renderLink", action: "action", emptyText: "emptyText", molId: "molId", className: "className" }, features: [i0.ɵɵNgOnChangesFeature], decls: 4, vars: 1, consts: [["rowBody", ""], ["listEl", ""], ["role", "status"], [3, "class"], [3, "pointerover", "focusin", "touchstart"], [3, "ngTemplateOutlet", "ngTemplateOutletContext"], [3, "click"], [3, "text", "terms"]], template: function SearchResults_Template(rf, ctx) { if (rf & 1) {
403
+ i0.ɵɵconditionalCreate(0, SearchResults_Conditional_0_Template, 3, 7)(1, SearchResults_Conditional_1_Template, 6, 9);
404
+ i0.ɵɵtemplate(2, SearchResults_ng_template_2_Template, 6, 10, "ng-template", null, 0, i0.ɵɵtemplateRefExtractor);
405
+ } if (rf & 2) {
406
+ i0.ɵɵconditional(ctx.hits.length === 0 ? 0 : 1);
407
+ } }, dependencies: [Highlight, NgTemplateOutlet], encapsulation: 2 });
408
+ }
409
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SearchResults, [{
410
+ type: Component,
411
+ args: [{
412
+ selector: 'mol-search-results',
413
+ standalone: true,
414
+ imports: [Highlight, NgTemplateOutlet],
415
+ inputs: [
416
+ 'hits',
417
+ 'view',
418
+ 'activeIndex',
419
+ 'onActivate',
420
+ 'onOpen',
421
+ 'onPrefetch',
422
+ 'renderLink',
423
+ 'action',
424
+ 'emptyText',
425
+ 'molId',
426
+ 'className',
427
+ ],
428
+ host: {
429
+ 'data-parity-unwrap': '',
430
+ style: 'display: contents',
431
+ },
432
+ // prettier-ignore
433
+ template: `@if (hits.length === 0) {
434
+ <p [class]="cm().cn(cm().resultEmpty)" [attr.data-mol-id]="id() + '-empty'">{{ emptyText }}</p>
435
+ <!-- The status region exists before results arrive, so it is live. -->
436
+ <p role="status" [class]="cm().cn(cm().srOnly)" [attr.data-mol-id]="id() + '-active'"></p>
437
+ } @else {
438
+ <ul
439
+ #listEl
440
+ [attr.aria-label]="t('searchUi.results', undefined, { defaultValue: 'Search results' })"
441
+ [class]="listClasses()"
442
+ [attr.data-mol-id]="id() + '-results'"
443
+ >
444
+ @for (hit of hits; track hit.id; let i = $index) {
445
+ <li
446
+ [attr.aria-current]="i === activeIndex ? 'true' : null"
447
+ [attr.data-index]="i"
448
+ [attr.data-mol-id]="id() + '-hit'"
449
+ [attr.data-hit-id]="hit.id"
450
+ [class]="itemClasses(i)"
451
+ (pointerover)="onPointerOver(i, hit)"
452
+ (focusin)="onPrefetch?.(hit.doc)"
453
+ (touchstart)="onPrefetch?.(hit.doc)"
454
+ >
455
+ @if (renderLink) {
456
+ <ng-container
457
+ [ngTemplateOutlet]="renderLink"
458
+ [ngTemplateOutletContext]="renderContext(linkProps(hit))"
459
+ ></ng-container>
460
+ } @else {
461
+ <a
462
+ [attr.href]="viewOf(hit).href"
463
+ [class]="cm().cn(cm().resultBody)"
464
+ [attr.data-mol-id]="id() + '-link'"
465
+ (click)="openFromLink($event, hit)"
466
+ ><ng-container
467
+ [ngTemplateOutlet]="rowBody"
468
+ [ngTemplateOutletContext]="{ $implicit: hit }"
469
+ ></ng-container
470
+ ></a>
471
+ }
472
+ @if (action) {
473
+ <span [class]="cm().cn(cm().resultAction)"
474
+ ><ng-container
475
+ [ngTemplateOutlet]="action"
476
+ [ngTemplateOutletContext]="renderContext(hit.doc)"
477
+ ></ng-container
478
+ ></span>
479
+ }
480
+ </li>
481
+ }
482
+ </ul>
483
+ <p role="status" [class]="cm().cn(cm().srOnly)" [attr.data-mol-id]="id() + '-active'">
484
+ {{ activeText() }}
485
+ </p>
486
+ }
487
+ <ng-template #rowBody let-hit>
488
+ <span [class]="cm().flex({ align: 'baseline', wrap: 'wrap', gap: 2 })">
489
+ <span [class]="titleClasses(hit)">
490
+ <mol-highlight [text]="viewOf(hit).title" [terms]="hit.terms"></mol-highlight>
491
+ </span>
492
+ @if (metaOf(hit).length > 0) {
493
+ <span [class]="cm().cn(cm().resultMeta)">{{ metaOf(hit).join(' · ') }}</span>
494
+ }
495
+ @if (hit.related) {
496
+ <span
497
+ [class]="cm().cn(cm().resultMeta)"
498
+ [attr.data-mol-id]="id() + '-related'"
499
+ [attr.title]="relatedTitle()"
500
+ >{{ relatedText() }}</span
501
+ >
502
+ }
503
+ </span>
504
+ @if (viewOf(hit).description) {
505
+ <span [class]="cm().cn(cm().resultDescription, cm().displayBlock)">
506
+ <mol-highlight [text]="viewOf(hit).description!" [terms]="hit.terms"></mol-highlight>
507
+ </span>
508
+ }
509
+ </ng-template>`,
510
+ }]
511
+ }], null, { listEl: [{
512
+ type: ViewChild,
513
+ args: ['listEl']
514
+ }], rowBodyTpl: [{
515
+ type: ViewChild,
516
+ args: ['rowBody']
517
+ }] }); })();
518
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(SearchResults, { className: "SearchResults", filePath: "search-results.component.ts", lineNumber: 145 }); })();
519
+ //# sourceMappingURL=search-results.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-results.component.js","sourceRoot":"","sources":["../src/search-results.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD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