@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,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SearchBox component (React parity).
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { type AfterViewInit, type ElementRef, type OnChanges, type SimpleChanges, type WritableSignal } from '@angular/core';
|
|
7
|
+
import type { ClientSearchFilter } from '@molecule/app-client-search';
|
|
8
|
+
import type { UIClassMap } from '@molecule/app-ui';
|
|
9
|
+
import * as i0 from "@angular/core";
|
|
10
|
+
/** One stable record per chip key, so the rendered chips follow React's keyed reuse. */
|
|
11
|
+
interface ChipRecord {
|
|
12
|
+
/** The chip's composite key (React's). */
|
|
13
|
+
key: string;
|
|
14
|
+
/** The chip's filter. */
|
|
15
|
+
filter: ClientSearchFilter;
|
|
16
|
+
/** The chip's index. */
|
|
17
|
+
index: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* SearchBox component.
|
|
21
|
+
*
|
|
22
|
+
* A search field: a leading icon, the input, a help icon that shows the
|
|
23
|
+
* syntax on hover, an × to clear, and the shortcut cap; under it, whatever
|
|
24
|
+
* `afterField` holds (projected as `[slot=afterField]`), then the active
|
|
25
|
+
* filters as removable chips and the hit count. The field stays mounted, and
|
|
26
|
+
* its text with it, across searches. The host IS the outer `<div>` React
|
|
27
|
+
* renders (`div[mol-search-box]`).
|
|
28
|
+
*/
|
|
29
|
+
export declare class SearchBox implements AfterViewInit, OnChanges {
|
|
30
|
+
/** The text. */
|
|
31
|
+
value: string;
|
|
32
|
+
/** Called with the new text on every keystroke. */
|
|
33
|
+
onChange?: (value: string) => void;
|
|
34
|
+
/** Key handling for the input (arrows, Enter, Escape), usually a session's `onKeyDown`. */
|
|
35
|
+
onKeyDown?: (event: KeyboardEvent) => void;
|
|
36
|
+
/** A ref to the input, so a shortcut can focus it. */
|
|
37
|
+
inputRef?: {
|
|
38
|
+
current: HTMLInputElement | null;
|
|
39
|
+
};
|
|
40
|
+
/** Placeholder, already translated. Also the accessible name unless `label` is given. */
|
|
41
|
+
placeholder: string;
|
|
42
|
+
/** Accessible name for the input, already translated. Defaults to `placeholder`. */
|
|
43
|
+
label?: string;
|
|
44
|
+
/** How many hits the current text has. Omit to show no count. */
|
|
45
|
+
count?: number;
|
|
46
|
+
/** Active `field:value` filters, shown as removable chips. */
|
|
47
|
+
filters?: ClientSearchFilter[];
|
|
48
|
+
/** Removes the i-th filter. */
|
|
49
|
+
onRemoveFilter?: (index: number) => void;
|
|
50
|
+
/** Clears the text. Shown as an × while there is text. */
|
|
51
|
+
onClear?: () => void;
|
|
52
|
+
/**
|
|
53
|
+
* Example tokens for the search tips, e.g. `['category:auth', 'type:bond']`.
|
|
54
|
+
* Given, a help icon sits inside the field and shows the syntax on hover or
|
|
55
|
+
* focus. Omit for no help icon.
|
|
56
|
+
*/
|
|
57
|
+
examples?: string[];
|
|
58
|
+
/** The key that focuses the box, shown as a cap while it is empty. `null` hides it. Defaults to `/`. */
|
|
59
|
+
shortcut?: string | null;
|
|
60
|
+
/** Focus the input on mount. */
|
|
61
|
+
autoFocus?: boolean;
|
|
62
|
+
/** `data-mol-id` prefix: `<molId>-input`, `-clear`, `-help`, `-filter`, `-count`. */
|
|
63
|
+
molId?: string;
|
|
64
|
+
/** Extra classes composed onto the field. */
|
|
65
|
+
className?: string;
|
|
66
|
+
/** Whether the field holds focus (React's `focused` state). */
|
|
67
|
+
readonly focused: WritableSignal<boolean>;
|
|
68
|
+
/** The input element, read for the ref and the focus requests. */
|
|
69
|
+
searchInput?: ElementRef<HTMLInputElement>;
|
|
70
|
+
/** i18n handle, read in an injection context. */
|
|
71
|
+
readonly t: (key: string, values?: import("@molecule/app-i18n").InterpolationValues, options?: import("@molecule/app-i18n").TranslateOptions) => string;
|
|
72
|
+
/**
|
|
73
|
+
* The current class map.
|
|
74
|
+
* @returns The UIClassMap.
|
|
75
|
+
*/
|
|
76
|
+
cm(): UIClassMap;
|
|
77
|
+
/**
|
|
78
|
+
* The `data-mol-id` prefix (React's default parameter).
|
|
79
|
+
* @returns The prefix.
|
|
80
|
+
*/
|
|
81
|
+
id(): string;
|
|
82
|
+
/**
|
|
83
|
+
* The active filters (React's default parameter: `[]`).
|
|
84
|
+
* @returns The filters.
|
|
85
|
+
*/
|
|
86
|
+
filterList(): ClientSearchFilter[];
|
|
87
|
+
/**
|
|
88
|
+
* The field's class list (`cm.searchField` + `className`).
|
|
89
|
+
* @returns The class string.
|
|
90
|
+
*/
|
|
91
|
+
fieldClasses(): string;
|
|
92
|
+
/**
|
|
93
|
+
* The input's accessible name (`label`, else the placeholder).
|
|
94
|
+
* @returns The accessible name.
|
|
95
|
+
*/
|
|
96
|
+
ariaLabel(): string;
|
|
97
|
+
/**
|
|
98
|
+
* Whether the text is not blank, the branch that shows the count.
|
|
99
|
+
* @returns True while the text has content.
|
|
100
|
+
*/
|
|
101
|
+
hasText(): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Whether the count shows: a count was given and the text is not blank.
|
|
104
|
+
* @returns True to show the count.
|
|
105
|
+
*/
|
|
106
|
+
showCount(): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Whether the status row (chips and count) renders.
|
|
109
|
+
* @returns True when a chip or the count renders.
|
|
110
|
+
*/
|
|
111
|
+
hasStatus(): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Whether the help icon renders (examples were given).
|
|
114
|
+
* @returns True to show the help icon.
|
|
115
|
+
*/
|
|
116
|
+
showHelp(): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* The example tokens plus the two always-present tokens, as React builds them.
|
|
119
|
+
* @returns The tips' example list.
|
|
120
|
+
*/
|
|
121
|
+
exampleList(): string[];
|
|
122
|
+
/**
|
|
123
|
+
* Whether the clear button shows: text present and `onClear` given.
|
|
124
|
+
* @returns True to show the clear button.
|
|
125
|
+
*/
|
|
126
|
+
showClear(): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* The shortcut cap's key, or null while hidden (React's default `/`).
|
|
129
|
+
* @returns The cap key or null.
|
|
130
|
+
*/
|
|
131
|
+
capKey(): string | null;
|
|
132
|
+
/**
|
|
133
|
+
* Whether the cap shows: a key, no text, and the field not focused.
|
|
134
|
+
* @returns True to show the cap.
|
|
135
|
+
*/
|
|
136
|
+
showCap(): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* The cap's key text (a template may not bind a nullable value).
|
|
139
|
+
* @returns The key, or the empty string while hidden.
|
|
140
|
+
*/
|
|
141
|
+
shortcutText(): string;
|
|
142
|
+
/**
|
|
143
|
+
* The tips line's inline style (React's `whiteSpace`/`maxWidth`).
|
|
144
|
+
* @returns The style string.
|
|
145
|
+
*/
|
|
146
|
+
tipsStyle(): string;
|
|
147
|
+
/**
|
|
148
|
+
* A tips example's leading separator (' · ' from the second on), as React
|
|
149
|
+
* builds it.
|
|
150
|
+
*
|
|
151
|
+
* @param index - The example's index.
|
|
152
|
+
* @returns The separator text.
|
|
153
|
+
*/
|
|
154
|
+
separator(index: number): string;
|
|
155
|
+
/**
|
|
156
|
+
* The help icon's accessible label.
|
|
157
|
+
* @returns The translated label.
|
|
158
|
+
*/
|
|
159
|
+
helpLabel(): string;
|
|
160
|
+
/**
|
|
161
|
+
* The clear button's accessible label.
|
|
162
|
+
* @returns The translated label.
|
|
163
|
+
*/
|
|
164
|
+
clearLabel(): string;
|
|
165
|
+
/**
|
|
166
|
+
* The syntax sentence (the tips' first span).
|
|
167
|
+
* @returns The translated text.
|
|
168
|
+
*/
|
|
169
|
+
syntaxText(): string;
|
|
170
|
+
/**
|
|
171
|
+
* The keys sentence (the tips' last span).
|
|
172
|
+
* @returns The translated text.
|
|
173
|
+
*/
|
|
174
|
+
keysText(): string;
|
|
175
|
+
/**
|
|
176
|
+
* The hit-count text, or null while blank or without a count.
|
|
177
|
+
* @returns The translated count, or null.
|
|
178
|
+
*/
|
|
179
|
+
countText(): string | null;
|
|
180
|
+
/**
|
|
181
|
+
* A chip's text: a negation mark, the field and the accepted values.
|
|
182
|
+
*
|
|
183
|
+
* @param f - The filter.
|
|
184
|
+
* @returns The chip text.
|
|
185
|
+
*/
|
|
186
|
+
chipText(f: ClientSearchFilter): string;
|
|
187
|
+
/**
|
|
188
|
+
* A chip's accessible label (the removal announcement).
|
|
189
|
+
*
|
|
190
|
+
* @param f - The filter.
|
|
191
|
+
* @returns The translated label.
|
|
192
|
+
*/
|
|
193
|
+
chipLabel(f: ClientSearchFilter): string;
|
|
194
|
+
/**
|
|
195
|
+
* A chip's tracking key, React's composite key.
|
|
196
|
+
*
|
|
197
|
+
* @param f - The filter.
|
|
198
|
+
* @param index - The chip's index.
|
|
199
|
+
* @returns The key.
|
|
200
|
+
*/
|
|
201
|
+
chipKey(f: ClientSearchFilter, index: number): string;
|
|
202
|
+
/** The cached chip records and the key signature they were built from. */
|
|
203
|
+
private chipCache;
|
|
204
|
+
/**
|
|
205
|
+
* The chip records the template iterates: one stable wrapper per chip while
|
|
206
|
+
* the key sequence is unchanged, and fresh wrappers whenever it changes.
|
|
207
|
+
* React keys each chip by its composite key, so an unchanged key keeps the
|
|
208
|
+
* rendered chip (and everything stamped on it) while a changed key replaces
|
|
209
|
+
* it; Angular's keyed loop recomputes keys with the new indices and would
|
|
210
|
+
* reuse a view across a reorder, so the records — and the reuse they drive
|
|
211
|
+
* — are built here instead.
|
|
212
|
+
*
|
|
213
|
+
* @returns The chip records, in order.
|
|
214
|
+
*/
|
|
215
|
+
chipRecords(): ChipRecord[];
|
|
216
|
+
/**
|
|
217
|
+
* A chip's class list (`cm.filterChip`, negated when the filter negates).
|
|
218
|
+
*
|
|
219
|
+
* @param f - The filter.
|
|
220
|
+
* @returns The class string.
|
|
221
|
+
*/
|
|
222
|
+
chipClasses(f: ClientSearchFilter): string;
|
|
223
|
+
/**
|
|
224
|
+
* The value the controlled input restores after a keystroke the caller did
|
|
225
|
+
* not adopt, the way React renders its controlled input back.
|
|
226
|
+
* @returns The current prop value.
|
|
227
|
+
*/
|
|
228
|
+
restoreValue(): string;
|
|
229
|
+
/**
|
|
230
|
+
* Reports the typed text, then restores the field to the value the props
|
|
231
|
+
* still hold, the way React's controlled input renders it back when the
|
|
232
|
+
* caller keeps the old one.
|
|
233
|
+
*
|
|
234
|
+
* @param event - The input event.
|
|
235
|
+
*/
|
|
236
|
+
onType(event: Event): void;
|
|
237
|
+
/** Clears the text and puts focus back in the field, as React's button does. */
|
|
238
|
+
onClearClick(): void;
|
|
239
|
+
/**
|
|
240
|
+
* Assigns the input element into `inputRef`, as React's `ref` does.
|
|
241
|
+
*/
|
|
242
|
+
ngAfterViewInit(): void;
|
|
243
|
+
/**
|
|
244
|
+
* Re-assigns the ref and re-runs the focus request when their inputs change,
|
|
245
|
+
* the way React's effect keyed on `autoFocus` and `inputRef` does.
|
|
246
|
+
*
|
|
247
|
+
* @param changes - The changed inputs.
|
|
248
|
+
*/
|
|
249
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
250
|
+
/** Writes the input element into `inputRef`, as React's `ref` does. */
|
|
251
|
+
private captureRef;
|
|
252
|
+
/** Focuses the input when `autoFocus` asks and the element exists. */
|
|
253
|
+
private focusIfAsked;
|
|
254
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SearchBox, never>;
|
|
255
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SearchBox, "div[mol-search-box]", never, { "value": { "alias": "value"; "required": false; }; "onChange": { "alias": "onChange"; "required": false; }; "onKeyDown": { "alias": "onKeyDown"; "required": false; }; "inputRef": { "alias": "inputRef"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "label": { "alias": "label"; "required": false; }; "count": { "alias": "count"; "required": false; }; "filters": { "alias": "filters"; "required": false; }; "onRemoveFilter": { "alias": "onRemoveFilter"; "required": false; }; "onClear": { "alias": "onClear"; "required": false; }; "examples": { "alias": "examples"; "required": false; }; "shortcut": { "alias": "shortcut"; "required": false; }; "autoFocus": { "alias": "autoFocus"; "required": false; }; "molId": { "alias": "molId"; "required": false; }; "className": { "alias": "className"; "required": false; }; }, {}, never, ["[slot=afterField]"], true, never>;
|
|
256
|
+
}
|
|
257
|
+
export {};
|
|
258
|
+
//# sourceMappingURL=search-box.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-box.component.d.ts","sourceRoot":"","sources":["../src/search-box.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,UAAU,EACf,KAAK,SAAS,EAEd,KAAK,aAAa,EAElB,KAAK,cAAc,EACpB,MAAM,eAAe,CAAA;AAGtB,OAAO,KAAK,EAAE,kBAAkB,E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