@molecule/app-search-ui-angular 0.0.0-stage → 0.0.1-stage
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/LICENSE +202 -0
- package/README.md +10 -2
- package/dist/highlight.component.d.ts +33 -0
- package/dist/highlight.component.d.ts.map +1 -0
- package/dist/highlight.component.js +84 -0
- package/dist/highlight.component.js.map +1 -0
- package/dist/index.d.ts +99 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +99 -0
- package/dist/index.js.map +1 -0
- package/dist/kbd.component.d.ts +28 -0
- package/dist/kbd.component.d.ts.map +1 -0
- package/dist/kbd.component.js +58 -0
- package/dist/kbd.component.js.map +1 -0
- package/dist/quick-search-dialog.component.d.ts +129 -0
- package/dist/quick-search-dialog.component.d.ts.map +1 -0
- package/dist/quick-search-dialog.component.js +295 -0
- package/dist/quick-search-dialog.component.js.map +1 -0
- package/dist/search-box.component.d.ts +258 -0
- package/dist/search-box.component.d.ts.map +1 -0
- package/dist/search-box.component.js +644 -0
- package/dist/search-box.component.js.map +1 -0
- package/dist/search-results.component.d.ts +174 -0
- package/dist/search-results.component.d.ts.map +1 -0
- package/dist/search-results.component.js +519 -0
- package/dist/search-results.component.js.map +1 -0
- package/dist/types.d.ts +172 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/package.json +77 -4
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QuickSearchDialog component (React parity).
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type { Signal } from '@angular/core';
|
|
7
|
+
import { type AfterViewInit, type OnChanges, type SimpleChanges, type TemplateRef } from '@angular/core';
|
|
8
|
+
import type { ClientSearchDocument } from '@molecule/app-client-search';
|
|
9
|
+
import type { SearchSession } from '@molecule/app-client-search-angular';
|
|
10
|
+
import type { UIClassMap } from '@molecule/app-ui';
|
|
11
|
+
import type { SearchResultLinkProps, SearchResultView } from './types.js';
|
|
12
|
+
import * as i0 from "@angular/core";
|
|
13
|
+
/**
|
|
14
|
+
* QuickSearchDialog component.
|
|
15
|
+
*
|
|
16
|
+
* A search dialog for `mod+k`: the box on top with focus, the hits below in
|
|
17
|
+
* a scrolling pane, and the key hints in the footer. Before anything is
|
|
18
|
+
* typed the pane shows `idleText` rather than a browse list. Enter opens the active
|
|
19
|
+
* hit through the session (which closes the dialog by the caller's `onOpen`).
|
|
20
|
+
* The dialog is named for screen readers through `label` (or the translated
|
|
21
|
+
* "Search" default). React renders `null` while closed, so the host is
|
|
22
|
+
* unwrapped (`data-parity-unwrap`, `display: contents`) and renders exactly
|
|
23
|
+
* React's node list — nothing at all while closed.
|
|
24
|
+
*/
|
|
25
|
+
export declare class QuickSearchDialog<T extends ClientSearchDocument = ClientSearchDocument> implements AfterViewInit, OnChanges {
|
|
26
|
+
/** Whether the dialog is open. Rendered only while open. */
|
|
27
|
+
open: boolean;
|
|
28
|
+
/** Close it (Escape with nothing typed, the overlay, or after opening a hit). */
|
|
29
|
+
onClose?: () => void;
|
|
30
|
+
/** The search session (from `useSearchSession`), created with `syncUrl: false` and `onEscape: onClose`. */
|
|
31
|
+
session: SearchSession<T>;
|
|
32
|
+
/** How a hit renders. */
|
|
33
|
+
view: (doc: T) => SearchResultView;
|
|
34
|
+
/** Placeholder for the box, already translated. */
|
|
35
|
+
placeholder: string;
|
|
36
|
+
/** Example tokens for the tips line. */
|
|
37
|
+
examples?: string[];
|
|
38
|
+
/** Shown while the text matches nothing, already translated. */
|
|
39
|
+
emptyText: string;
|
|
40
|
+
/** Shown before anything is typed, already translated. Defaults to the empty text. */
|
|
41
|
+
idleText?: string;
|
|
42
|
+
/** Renders each row's link; a `TemplateRef` whose context carries the link props as `$implicit`. */
|
|
43
|
+
renderLink?: TemplateRef<{
|
|
44
|
+
$implicit: SearchResultLinkProps;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* The dialog's accessible name, already translated (like `placeholder`, it
|
|
48
|
+
* names nothing visible). Defaults to `t('searchUi.dialogLabel')`
|
|
49
|
+
* ("Search"); the field's placeholder already names the field.
|
|
50
|
+
*/
|
|
51
|
+
label?: string;
|
|
52
|
+
/** `data-mol-id` prefix. Defaults to `quick-search`. */
|
|
53
|
+
molId?: string;
|
|
54
|
+
/** i18n handle, read in an injection context. */
|
|
55
|
+
readonly t: (key: string, values?: import("@molecule/app-i18n").InterpolationValues, options?: import("@molecule/app-i18n").TranslateOptions) => string;
|
|
56
|
+
/**
|
|
57
|
+
* The current class map.
|
|
58
|
+
* @returns The UIClassMap.
|
|
59
|
+
*/
|
|
60
|
+
cm(): UIClassMap;
|
|
61
|
+
/**
|
|
62
|
+
* Reads a session field, unwrapping a signal and passing a plain value
|
|
63
|
+
* through.
|
|
64
|
+
*
|
|
65
|
+
* @param value - The session field.
|
|
66
|
+
* @returns The value.
|
|
67
|
+
*/
|
|
68
|
+
read<V>(value: Signal<V> | V): V;
|
|
69
|
+
/**
|
|
70
|
+
* The `data-mol-id` prefix (React's default parameter).
|
|
71
|
+
* @returns The prefix.
|
|
72
|
+
*/
|
|
73
|
+
id(): string;
|
|
74
|
+
/**
|
|
75
|
+
* The Modal's close label, translated like React passes it.
|
|
76
|
+
* @returns The label.
|
|
77
|
+
*/
|
|
78
|
+
closeLabel(): string;
|
|
79
|
+
/**
|
|
80
|
+
* The dialog's accessible name when no `label` is passed, translated like
|
|
81
|
+
* React passes it.
|
|
82
|
+
* @returns The default name ("Search").
|
|
83
|
+
*/
|
|
84
|
+
dialogLabel(): string;
|
|
85
|
+
/**
|
|
86
|
+
* The keys sentence (the footer's last text).
|
|
87
|
+
* @returns The translated text.
|
|
88
|
+
*/
|
|
89
|
+
keysText(): string;
|
|
90
|
+
/**
|
|
91
|
+
* The pane's empty text: the empty text while the session is active, else
|
|
92
|
+
* the idle text (which falls back to the empty text).
|
|
93
|
+
* @returns The text.
|
|
94
|
+
*/
|
|
95
|
+
paneEmptyText(): string;
|
|
96
|
+
/** Reports the session's `setQuery` as the box's `onChange`. */
|
|
97
|
+
setQuery(): (value: string) => void;
|
|
98
|
+
/** Reports the session's `onKeyDown` as the box's key handling. */
|
|
99
|
+
sessionKeyDown(): (event: KeyboardEvent) => void;
|
|
100
|
+
/** Reports the session's `removeFilter` as the box's chip removal. */
|
|
101
|
+
removeFilter(): (index: number) => void;
|
|
102
|
+
/** Reports the session's `clear` as the box's clear callback. */
|
|
103
|
+
clearSession(): () => void;
|
|
104
|
+
/** Reports the session's `setActiveIndex` as the list's activation. */
|
|
105
|
+
setActiveIndex(): (index: number) => void;
|
|
106
|
+
/** Reports the session's `open` as the list's open callback. */
|
|
107
|
+
openDoc(): (doc: T) => void;
|
|
108
|
+
/** Reports the session's `prefetch` as the list's prefetch callback. */
|
|
109
|
+
prefetchDoc(): (doc: T) => void;
|
|
110
|
+
/** Closes the dialog through the caller's `onClose`. */
|
|
111
|
+
emitClose(): void;
|
|
112
|
+
/**
|
|
113
|
+
* Focus moves into the field when the dialog opens, the way React's effect
|
|
114
|
+
* keyed on `open` and `session.inputRef` does.
|
|
115
|
+
*/
|
|
116
|
+
ngAfterViewInit(): void;
|
|
117
|
+
/**
|
|
118
|
+
* Focuses after an open flip too; the field mounts within the same change
|
|
119
|
+
* detection pass, and the focus waits one microtask for it.
|
|
120
|
+
*
|
|
121
|
+
* @param changes - The changed inputs.
|
|
122
|
+
*/
|
|
123
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
124
|
+
/** Focuses the session's input while the dialog is open. */
|
|
125
|
+
private focusField;
|
|
126
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<QuickSearchDialog<any>, never>;
|
|
127
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<QuickSearchDialog<any>, "mol-quick-search-dialog", never, { "open": { "alias": "open"; "required": false; }; "onClose": { "alias": "onClose"; "required": false; }; "session": { "alias": "session"; "required": false; }; "view": { "alias": "view"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "examples": { "alias": "examples"; "required": false; }; "emptyText": { "alias": "emptyText"; "required": false; }; "idleText": { "alias": "idleText"; "required": false; }; "renderLink": { "alias": "renderLink"; "required": false; }; "label": { "alias": "label"; "required": false; }; "molId": { "alias": "molId"; "required": false; }; }, {}, never, never, true, never>;
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=quick-search-dialog.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quick-search-dialog.component.d.ts","sourceRoot":"","sources":["../src/quick-search-dialog.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,eAAe,CAAA;AAGtB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAOlD,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;;AAqBzE;;;;;;;;;;;GAWG;AACH,qBAmEa,iBAAiB,CAAC,CAAC,SAAS,oBAAoB,GAAG,oBAAoB,CAClF,YAAW,aAAa,EAAE,SAAS;IAEnC,4DAA4D;IAC5D,IAAI,UAAQ;IACZ,iFAAiF;IACjF,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,2GAA2G;IAC3G,OAAO,EAAG,aAAa,CAAC,CAAC,CAAC,CAAA;IAC1B,yBAAyB;IACzB,IAAI,EAAG,CAAC,GAAG,EAAE,CAAC,KAAK,gBAAgB,CAAA;IACnC,mDAAmD;IACnD,WAAW,SAAK;IAChB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,EAA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B;;;;;OAKG;IACH,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAIzC,4DAA4D;IAC5D,OAAO,CAAC,UAAU;yCA3JP,iBAAiB;2CAAjB,iBAAiB;CA8J7B"}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { Component, } from '@angular/core';
|
|
2
|
+
import { useTranslation } from '@molecule/app-angular';
|
|
3
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
4
|
+
import { Modal } from '@molecule/app-ui-angular';
|
|
5
|
+
import { Kbd } from './kbd.component.js';
|
|
6
|
+
import { SearchBox } from './search-box.component.js';
|
|
7
|
+
import { SearchResults } from './search-results.component.js';
|
|
8
|
+
import * as i0 from "@angular/core";
|
|
9
|
+
const _c0 = () => [];
|
|
10
|
+
function QuickSearchDialog_Conditional_0_Template(rf, ctx) { if (rf & 1) {
|
|
11
|
+
const _r1 = i0.ɵɵgetCurrentView();
|
|
12
|
+
i0.ɵɵelementStart(0, "mol-modal", 1);
|
|
13
|
+
i0.ɵɵlistener("close", function QuickSearchDialog_Conditional_0_Template_mol_modal_close_0_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.emitClose()); });
|
|
14
|
+
i0.ɵɵelement(1, "div", 2);
|
|
15
|
+
i0.ɵɵelementStart(2, "div");
|
|
16
|
+
i0.ɵɵelement(3, "mol-search-results", 3);
|
|
17
|
+
i0.ɵɵelementEnd();
|
|
18
|
+
i0.ɵɵelementStart(4, "p")(5, "kbd", 4);
|
|
19
|
+
i0.ɵɵtext(6, "\u2191");
|
|
20
|
+
i0.ɵɵelementEnd();
|
|
21
|
+
i0.ɵɵelementStart(7, "kbd", 4);
|
|
22
|
+
i0.ɵɵtext(8, "\u2193");
|
|
23
|
+
i0.ɵɵelementEnd();
|
|
24
|
+
i0.ɵɵelementStart(9, "kbd", 4);
|
|
25
|
+
i0.ɵɵtext(10, "\u21B5");
|
|
26
|
+
i0.ɵɵelementEnd();
|
|
27
|
+
i0.ɵɵelementStart(11, "kbd", 4);
|
|
28
|
+
i0.ɵɵtext(12, "esc");
|
|
29
|
+
i0.ɵɵelementEnd();
|
|
30
|
+
i0.ɵɵtext(13);
|
|
31
|
+
i0.ɵɵelementEnd()();
|
|
32
|
+
} if (rf & 2) {
|
|
33
|
+
const ctx_r1 = i0.ɵɵnextContext();
|
|
34
|
+
i0.ɵɵproperty("open", true)("size", "lg")("closeOnEscape", false)("showCloseButton", false)("closeLabel", ctx_r1.closeLabel());
|
|
35
|
+
i0.ɵɵattribute("aria-label", ctx_r1.label ?? ctx_r1.dialogLabel())("data-mol-id", ctx_r1.id());
|
|
36
|
+
i0.ɵɵadvance();
|
|
37
|
+
i0.ɵɵproperty("value", ctx_r1.read(ctx_r1.session.query))("onChange", ctx_r1.setQuery())("onKeyDown", ctx_r1.sessionKeyDown())("inputRef", ctx_r1.session.inputRef)("placeholder", ctx_r1.placeholder)("count", ctx_r1.read(ctx_r1.session.active) ? ctx_r1.read(ctx_r1.session.hits).length : undefined)("filters", ctx_r1.read(ctx_r1.session.parsed).filters)("onRemoveFilter", ctx_r1.removeFilter())("onClear", ctx_r1.clearSession())("examples", ctx_r1.examples)("shortcut", null)("molId", ctx_r1.id());
|
|
38
|
+
i0.ɵɵadvance();
|
|
39
|
+
i0.ɵɵclassMap(ctx_r1.cm().cn(ctx_r1.cm().dialogBody));
|
|
40
|
+
i0.ɵɵattribute("data-mol-id", ctx_r1.id() + "-pane");
|
|
41
|
+
i0.ɵɵadvance();
|
|
42
|
+
i0.ɵɵproperty("hits", ctx_r1.read(ctx_r1.session.active) ? ctx_r1.read(ctx_r1.session.hits) : i0.ɵɵpureFunction0(35, _c0))("view", ctx_r1.view)("activeIndex", ctx_r1.read(ctx_r1.session.activeIndex))("onActivate", ctx_r1.setActiveIndex())("onOpen", ctx_r1.openDoc())("onPrefetch", ctx_r1.prefetchDoc())("renderLink", ctx_r1.renderLink)("emptyText", ctx_r1.paneEmptyText())("molId", ctx_r1.id());
|
|
43
|
+
i0.ɵɵadvance();
|
|
44
|
+
i0.ɵɵclassMap(ctx_r1.cm().cn(ctx_r1.cm().dialogFooter, ctx_r1.cm().resultMeta));
|
|
45
|
+
i0.ɵɵattribute("data-mol-id", ctx_r1.id() + "-keys");
|
|
46
|
+
i0.ɵɵadvance(9);
|
|
47
|
+
i0.ɵɵtextInterpolate1(" ", ctx_r1.keysText(), " ");
|
|
48
|
+
} }
|
|
49
|
+
/**
|
|
50
|
+
* Whether a session field is a signal (what a `useSearchSession` result
|
|
51
|
+
* holds) rather than a plain value.
|
|
52
|
+
*
|
|
53
|
+
* @param value - The session field.
|
|
54
|
+
* @returns True for a signal.
|
|
55
|
+
*/
|
|
56
|
+
const isSignalValue = (value) => typeof value === 'function';
|
|
57
|
+
/**
|
|
58
|
+
* Reads a session field, calling a signal and passing a plain value through,
|
|
59
|
+
* so the dialog takes a session from `useSearchSession` or a plain object
|
|
60
|
+
* alike.
|
|
61
|
+
*
|
|
62
|
+
* @param value - The session field.
|
|
63
|
+
* @returns The value.
|
|
64
|
+
*/
|
|
65
|
+
const read = (value) => (isSignalValue(value) ? value() : value);
|
|
66
|
+
/**
|
|
67
|
+
* QuickSearchDialog component.
|
|
68
|
+
*
|
|
69
|
+
* A search dialog for `mod+k`: the box on top with focus, the hits below in
|
|
70
|
+
* a scrolling pane, and the key hints in the footer. Before anything is
|
|
71
|
+
* typed the pane shows `idleText` rather than a browse list. Enter opens the active
|
|
72
|
+
* hit through the session (which closes the dialog by the caller's `onOpen`).
|
|
73
|
+
* The dialog is named for screen readers through `label` (or the translated
|
|
74
|
+
* "Search" default). React renders `null` while closed, so the host is
|
|
75
|
+
* unwrapped (`data-parity-unwrap`, `display: contents`) and renders exactly
|
|
76
|
+
* React's node list — nothing at all while closed.
|
|
77
|
+
*/
|
|
78
|
+
export class QuickSearchDialog {
|
|
79
|
+
/** Whether the dialog is open. Rendered only while open. */
|
|
80
|
+
open = false;
|
|
81
|
+
/** Close it (Escape with nothing typed, the overlay, or after opening a hit). */
|
|
82
|
+
onClose;
|
|
83
|
+
/** The search session (from `useSearchSession`), created with `syncUrl: false` and `onEscape: onClose`. */
|
|
84
|
+
session;
|
|
85
|
+
/** How a hit renders. */
|
|
86
|
+
view;
|
|
87
|
+
/** Placeholder for the box, already translated. */
|
|
88
|
+
placeholder = '';
|
|
89
|
+
/** Example tokens for the tips line. */
|
|
90
|
+
examples;
|
|
91
|
+
/** Shown while the text matches nothing, already translated. */
|
|
92
|
+
emptyText = '';
|
|
93
|
+
/** Shown before anything is typed, already translated. Defaults to the empty text. */
|
|
94
|
+
idleText;
|
|
95
|
+
/** Renders each row's link; a `TemplateRef` whose context carries the link props as `$implicit`. */
|
|
96
|
+
renderLink;
|
|
97
|
+
/**
|
|
98
|
+
* The dialog's accessible name, already translated (like `placeholder`, it
|
|
99
|
+
* names nothing visible). Defaults to `t('searchUi.dialogLabel')`
|
|
100
|
+
* ("Search"); the field's placeholder already names the field.
|
|
101
|
+
*/
|
|
102
|
+
label;
|
|
103
|
+
/** `data-mol-id` prefix. Defaults to `quick-search`. */
|
|
104
|
+
molId;
|
|
105
|
+
/** i18n handle, read in an injection context. */
|
|
106
|
+
t = useTranslation().t;
|
|
107
|
+
/**
|
|
108
|
+
* The current class map.
|
|
109
|
+
* @returns The UIClassMap.
|
|
110
|
+
*/
|
|
111
|
+
cm() {
|
|
112
|
+
return getClassMap();
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Reads a session field, unwrapping a signal and passing a plain value
|
|
116
|
+
* through.
|
|
117
|
+
*
|
|
118
|
+
* @param value - The session field.
|
|
119
|
+
* @returns The value.
|
|
120
|
+
*/
|
|
121
|
+
read(value) {
|
|
122
|
+
return read(value);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The `data-mol-id` prefix (React's default parameter).
|
|
126
|
+
* @returns The prefix.
|
|
127
|
+
*/
|
|
128
|
+
id() {
|
|
129
|
+
return this.molId ?? 'quick-search';
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The Modal's close label, translated like React passes it.
|
|
133
|
+
* @returns The label.
|
|
134
|
+
*/
|
|
135
|
+
closeLabel() {
|
|
136
|
+
return this.t('searchUi.close', undefined, { defaultValue: 'Close' });
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The dialog's accessible name when no `label` is passed, translated like
|
|
140
|
+
* React passes it.
|
|
141
|
+
* @returns The default name ("Search").
|
|
142
|
+
*/
|
|
143
|
+
dialogLabel() {
|
|
144
|
+
return this.t('searchUi.dialogLabel', undefined, { defaultValue: 'Search' });
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The keys sentence (the footer's last text).
|
|
148
|
+
* @returns The translated text.
|
|
149
|
+
*/
|
|
150
|
+
keysText() {
|
|
151
|
+
return this.t('searchUi.dialogKeys', undefined, {
|
|
152
|
+
defaultValue: 'The arrow keys move through the results, Enter opens one, Escape closes.',
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* The pane's empty text: the empty text while the session is active, else
|
|
157
|
+
* the idle text (which falls back to the empty text).
|
|
158
|
+
* @returns The text.
|
|
159
|
+
*/
|
|
160
|
+
paneEmptyText() {
|
|
161
|
+
return read(this.session.active) ? this.emptyText : (this.idleText ?? this.emptyText);
|
|
162
|
+
}
|
|
163
|
+
/** Reports the session's `setQuery` as the box's `onChange`. */
|
|
164
|
+
setQuery() {
|
|
165
|
+
return (value) => this.session.setQuery(value);
|
|
166
|
+
}
|
|
167
|
+
/** Reports the session's `onKeyDown` as the box's key handling. */
|
|
168
|
+
sessionKeyDown() {
|
|
169
|
+
return (event) => this.session.onKeyDown(event);
|
|
170
|
+
}
|
|
171
|
+
/** Reports the session's `removeFilter` as the box's chip removal. */
|
|
172
|
+
removeFilter() {
|
|
173
|
+
return (index) => this.session.removeFilter(index);
|
|
174
|
+
}
|
|
175
|
+
/** Reports the session's `clear` as the box's clear callback. */
|
|
176
|
+
clearSession() {
|
|
177
|
+
return () => this.session.clear();
|
|
178
|
+
}
|
|
179
|
+
/** Reports the session's `setActiveIndex` as the list's activation. */
|
|
180
|
+
setActiveIndex() {
|
|
181
|
+
return (index) => this.session.setActiveIndex(index);
|
|
182
|
+
}
|
|
183
|
+
/** Reports the session's `open` as the list's open callback. */
|
|
184
|
+
openDoc() {
|
|
185
|
+
return (doc) => this.session.open(doc);
|
|
186
|
+
}
|
|
187
|
+
/** Reports the session's `prefetch` as the list's prefetch callback. */
|
|
188
|
+
prefetchDoc() {
|
|
189
|
+
return (doc) => this.session.prefetch(doc);
|
|
190
|
+
}
|
|
191
|
+
/** Closes the dialog through the caller's `onClose`. */
|
|
192
|
+
emitClose() {
|
|
193
|
+
this.onClose?.();
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Focus moves into the field when the dialog opens, the way React's effect
|
|
197
|
+
* keyed on `open` and `session.inputRef` does.
|
|
198
|
+
*/
|
|
199
|
+
ngAfterViewInit() {
|
|
200
|
+
this.focusField();
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Focuses after an open flip too; the field mounts within the same change
|
|
204
|
+
* detection pass, and the focus waits one microtask for it.
|
|
205
|
+
*
|
|
206
|
+
* @param changes - The changed inputs.
|
|
207
|
+
*/
|
|
208
|
+
ngOnChanges(changes) {
|
|
209
|
+
if (changes['open'] && this.open)
|
|
210
|
+
queueMicrotask(() => this.focusField());
|
|
211
|
+
}
|
|
212
|
+
/** Focuses the session's input while the dialog is open. */
|
|
213
|
+
focusField() {
|
|
214
|
+
if (this.open)
|
|
215
|
+
this.session.inputRef.current?.focus();
|
|
216
|
+
}
|
|
217
|
+
static ɵfac = function QuickSearchDialog_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || QuickSearchDialog)(); };
|
|
218
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: QuickSearchDialog, selectors: [["mol-quick-search-dialog"]], hostAttrs: ["data-parity-unwrap", "", 2, "display", "contents"], inputs: { open: "open", onClose: "onClose", session: "session", view: "view", placeholder: "placeholder", examples: "examples", emptyText: "emptyText", idleText: "idleText", renderLink: "renderLink", label: "label", molId: "molId" }, features: [i0.ɵɵNgOnChangesFeature], decls: 1, vars: 1, consts: [[3, "open", "size", "closeOnEscape", "showCloseButton", "closeLabel"], [3, "close", "open", "size", "closeOnEscape", "showCloseButton", "closeLabel"], ["mol-search-box", "", 3, "value", "onChange", "onKeyDown", "inputRef", "placeholder", "count", "filters", "onRemoveFilter", "onClear", "examples", "shortcut", "molId"], [3, "hits", "view", "activeIndex", "onActivate", "onOpen", "onPrefetch", "renderLink", "emptyText", "molId"], ["mol-kbd", ""]], template: function QuickSearchDialog_Template(rf, ctx) { if (rf & 1) {
|
|
219
|
+
i0.ɵɵconditionalCreate(0, QuickSearchDialog_Conditional_0_Template, 14, 36, "mol-modal", 0);
|
|
220
|
+
} if (rf & 2) {
|
|
221
|
+
i0.ɵɵconditional(ctx.open ? 0 : -1);
|
|
222
|
+
} }, dependencies: [Kbd, Modal, SearchBox, SearchResults], encapsulation: 2 });
|
|
223
|
+
}
|
|
224
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(QuickSearchDialog, [{
|
|
225
|
+
type: Component,
|
|
226
|
+
args: [{
|
|
227
|
+
selector: 'mol-quick-search-dialog',
|
|
228
|
+
standalone: true,
|
|
229
|
+
imports: [Kbd, Modal, SearchBox, SearchResults],
|
|
230
|
+
inputs: [
|
|
231
|
+
'open',
|
|
232
|
+
'onClose',
|
|
233
|
+
'session',
|
|
234
|
+
'view',
|
|
235
|
+
'placeholder',
|
|
236
|
+
'examples',
|
|
237
|
+
'emptyText',
|
|
238
|
+
'idleText',
|
|
239
|
+
'renderLink',
|
|
240
|
+
'label',
|
|
241
|
+
'molId',
|
|
242
|
+
],
|
|
243
|
+
host: {
|
|
244
|
+
'data-parity-unwrap': '',
|
|
245
|
+
style: 'display: contents',
|
|
246
|
+
},
|
|
247
|
+
template: `@if (open) {
|
|
248
|
+
<mol-modal
|
|
249
|
+
[open]="true"
|
|
250
|
+
(close)="emitClose()"
|
|
251
|
+
[size]="'lg'"
|
|
252
|
+
[closeOnEscape]="false"
|
|
253
|
+
[showCloseButton]="false"
|
|
254
|
+
[closeLabel]="closeLabel()"
|
|
255
|
+
[attr.aria-label]="label ?? dialogLabel()"
|
|
256
|
+
[attr.data-mol-id]="id()"
|
|
257
|
+
>
|
|
258
|
+
<div
|
|
259
|
+
mol-search-box
|
|
260
|
+
[value]="read(session.query)"
|
|
261
|
+
[onChange]="setQuery()"
|
|
262
|
+
[onKeyDown]="sessionKeyDown()"
|
|
263
|
+
[inputRef]="session.inputRef"
|
|
264
|
+
[placeholder]="placeholder"
|
|
265
|
+
[count]="read(session.active) ? read(session.hits).length : undefined"
|
|
266
|
+
[filters]="read(session.parsed).filters"
|
|
267
|
+
[onRemoveFilter]="removeFilter()"
|
|
268
|
+
[onClear]="clearSession()"
|
|
269
|
+
[examples]="examples"
|
|
270
|
+
[shortcut]="null"
|
|
271
|
+
[molId]="id()"
|
|
272
|
+
></div>
|
|
273
|
+
<div [class]="cm().cn(cm().dialogBody)" [attr.data-mol-id]="id() + '-pane'">
|
|
274
|
+
<mol-search-results
|
|
275
|
+
[hits]="read(session.active) ? read(session.hits) : []"
|
|
276
|
+
[view]="view"
|
|
277
|
+
[activeIndex]="read(session.activeIndex)"
|
|
278
|
+
[onActivate]="setActiveIndex()"
|
|
279
|
+
[onOpen]="openDoc()"
|
|
280
|
+
[onPrefetch]="prefetchDoc()"
|
|
281
|
+
[renderLink]="renderLink"
|
|
282
|
+
[emptyText]="paneEmptyText()"
|
|
283
|
+
[molId]="id()"
|
|
284
|
+
/>
|
|
285
|
+
</div>
|
|
286
|
+
<p [class]="cm().cn(cm().dialogFooter, cm().resultMeta)" [attr.data-mol-id]="id() + '-keys'">
|
|
287
|
+
<kbd mol-kbd>↑</kbd> <kbd mol-kbd>↓</kbd> <kbd mol-kbd>↵</kbd> <kbd mol-kbd>esc</kbd>
|
|
288
|
+
{{ keysText() }}
|
|
289
|
+
</p>
|
|
290
|
+
</mol-modal>
|
|
291
|
+
}`,
|
|
292
|
+
}]
|
|
293
|
+
}], null, null); })();
|
|
294
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(QuickSearchDialog, { className: "QuickSearchDialog", filePath: "quick-search-dialog.component.ts", lineNumber: 126 }); })();
|
|
295
|
+
//# sourceMappingURL=quick-search-dialog.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quick-search-dialog.component.js","sourceRoot":"","sources":["../src/quick-search-dialog.component.ts"],"names":[],"mappings":"AAOA,OAAO,EAEL,SAAS,GAIV,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAItD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAEhD,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;;;;;IAwDzD,oCASC;IAPC,wLAAS,kBAAW,KAAC;IAQrB,yBAcO;IACP,2BAA4E;IAC1E,wCAUE;IACJ,iBAAM;IAEJ,AADF,yBAA6F,aAC9E;IAAA,sBAAC;IAAA,iBAAM;IAAC,8BAAa;IAAA,sBAAC;IAAA,iBAAM;IAAC,8BAAa;IAAA,uBAAC;IAAA,iBAAM;IAAC,+BAAa;IAAA,oBAAG;IAAA,iBAAM;IACrF,aACF;IACF,AADE,iBAAI,EACM;;;IApCV,AADA,AADA,AADA,AAFA,2BAAa,cAEA,wBACU,0BACE,mCACE;;IAMzB,cAA6B;IAW7B,AADA,AADA,AADA,AADA,AADA,AADA,AADA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