@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,33 @@
1
+ import { highlightMatches } from '@molecule/app-client-search';
2
+ import type { UIClassMap } from '@molecule/app-ui';
3
+ import type { HighlightProps } from './types.js';
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * Highlight component.
7
+ *
8
+ * Text with the matched terms marked: each term is marked where it starts a
9
+ * word, case-insensitively, through the ClassMap's `resultMark`. React's root
10
+ * is a FRAGMENT (the segments, plain text and `<mark>` side by side), so the
11
+ * host is unwrapped (`data-parity-unwrap`, `display: contents`) and renders
12
+ * exactly React's node list. The text is an attribute of the element — pass
13
+ * `text` and `terms` as inputs, not as content.
14
+ */
15
+ export declare class Highlight implements HighlightProps {
16
+ /** The text to show. */
17
+ text: string;
18
+ /** The matched terms to mark (a hit's `terms`). */
19
+ terms: string[];
20
+ /**
21
+ * The current class map.
22
+ * @returns The UIClassMap.
23
+ */
24
+ cm(): UIClassMap;
25
+ /**
26
+ * The plain and matched segments, as React derives them per render.
27
+ * @returns The segments, in order.
28
+ */
29
+ segments(): ReturnType<typeof highlightMatches>;
30
+ static ɵfac: i0.ɵɵFactoryDeclaration<Highlight, never>;
31
+ static ɵcmp: i0.ɵɵComponentDeclaration<Highlight, "mol-highlight", never, { "text": { "alias": "text"; "required": false; }; "terms": { "alias": "terms"; "required": false; }; }, {}, never, never, true, never>;
32
+ }
33
+ //# sourceMappingURL=highlight.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"highlight.component.d.ts","sourceRoot":"","sources":["../src/highlight.component.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAGlD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;;AAEhD;;;;;;;;;GASG;AACH,qBAWa,SAAU,YAAW,cAAc;IAC9C,wBAAwB;IACxB,IAAI,SAAK;IACT,mDAAmD;IACnD,KAAK,EAAE,MAAM,EAAE,CAAK;IAEpB;;;OAGG;IACH,EAAE,IAAI,UAAU;IAIhB;;;OAGG;IACH,QAAQ,IAAI,UAAU,CAAC,OAAO,gBAAgB,CAAC;yCAlBpC,SAAS;2CAAT,SAAS;CAqBrB"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Highlight component (React parity).
3
+ *
4
+ * @module
5
+ */
6
+ import { Component } from '@angular/core';
7
+ import { highlightMatches } from '@molecule/app-client-search';
8
+ import { getClassMap } from '@molecule/app-ui';
9
+ import * as i0 from "@angular/core";
10
+ function Highlight_For_1_Conditional_0_Template(rf, ctx) { if (rf & 1) {
11
+ i0.ɵɵdomElementStart(0, "mark");
12
+ i0.ɵɵtext(1);
13
+ i0.ɵɵdomElementEnd();
14
+ } if (rf & 2) {
15
+ const seg_r1 = i0.ɵɵnextContext().$implicit;
16
+ const ctx_r1 = i0.ɵɵnextContext();
17
+ i0.ɵɵclassMap(ctx_r1.cm().cn(ctx_r1.cm().resultMark));
18
+ i0.ɵɵadvance();
19
+ i0.ɵɵtextInterpolate(seg_r1.text);
20
+ } }
21
+ function Highlight_For_1_Conditional_1_Template(rf, ctx) { if (rf & 1) {
22
+ i0.ɵɵtext(0);
23
+ } if (rf & 2) {
24
+ const seg_r1 = i0.ɵɵnextContext().$implicit;
25
+ i0.ɵɵtextInterpolate(seg_r1.text);
26
+ } }
27
+ function Highlight_For_1_Template(rf, ctx) { if (rf & 1) {
28
+ i0.ɵɵconditionalCreate(0, Highlight_For_1_Conditional_0_Template, 2, 3, "mark", 0)(1, Highlight_For_1_Conditional_1_Template, 1, 1);
29
+ } if (rf & 2) {
30
+ const seg_r1 = ctx.$implicit;
31
+ i0.ɵɵconditional(seg_r1.hit ? 0 : 1);
32
+ } }
33
+ /**
34
+ * Highlight component.
35
+ *
36
+ * Text with the matched terms marked: each term is marked where it starts a
37
+ * word, case-insensitively, through the ClassMap's `resultMark`. React's root
38
+ * is a FRAGMENT (the segments, plain text and `<mark>` side by side), so the
39
+ * host is unwrapped (`data-parity-unwrap`, `display: contents`) and renders
40
+ * exactly React's node list. The text is an attribute of the element — pass
41
+ * `text` and `terms` as inputs, not as content.
42
+ */
43
+ export class Highlight {
44
+ /** The text to show. */
45
+ text = '';
46
+ /** The matched terms to mark (a hit's `terms`). */
47
+ terms = [];
48
+ /**
49
+ * The current class map.
50
+ * @returns The UIClassMap.
51
+ */
52
+ cm() {
53
+ return getClassMap();
54
+ }
55
+ /**
56
+ * The plain and matched segments, as React derives them per render.
57
+ * @returns The segments, in order.
58
+ */
59
+ segments() {
60
+ return highlightMatches(this.text, this.terms);
61
+ }
62
+ static ɵfac = function Highlight_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || Highlight)(); };
63
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: Highlight, selectors: [["mol-highlight"]], hostAttrs: ["data-parity-unwrap", "", 2, "display", "contents"], inputs: { text: "text", terms: "terms" }, decls: 2, vars: 0, consts: [[3, "class"]], template: function Highlight_Template(rf, ctx) { if (rf & 1) {
64
+ i0.ɵɵrepeaterCreate(0, Highlight_For_1_Template, 2, 1, null, null, i0.ɵɵrepeaterTrackByIndex);
65
+ } if (rf & 2) {
66
+ i0.ɵɵrepeater(ctx.segments());
67
+ } }, encapsulation: 2 });
68
+ }
69
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(Highlight, [{
70
+ type: Component,
71
+ args: [{
72
+ selector: 'mol-highlight',
73
+ standalone: true,
74
+ inputs: ['text', 'terms'],
75
+ host: {
76
+ 'data-parity-unwrap': '',
77
+ style: 'display: contents',
78
+ },
79
+ // prettier-ignore
80
+ template: `@for (seg of segments(); track $index) {@if (seg.hit) {<mark [class]="cm().cn(cm().resultMark)">{{ seg.text }}</mark>} @else {{{ seg.text }}}}`,
81
+ }]
82
+ }], null, null); })();
83
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(Highlight, { className: "Highlight", filePath: "highlight.component.ts", lineNumber: 36 }); })();
84
+ //# sourceMappingURL=highlight.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"highlight.component.js","sourceRoot":"","sources":["../src/highlight.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAE9D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;;;IAuBsB,+BAAyC;IAAA,YAAc;IAAA,oBAAO;;;;IAAxD,qDAAkC;IAAC,cAAc;IAAd,iCAAc;;;IAAgB,YAAc;;;IAAd,iCAAc;;;IAArB,AAA/E,kFAAe,iDAAuE;;;IAAtF,oCAAqG;;AAnB1J;;;;;;;;;GASG;AAYH,MAAM,OAAO,SAAS;IACpB,wBAAwB;IACxB,IAAI,GAAG,EAAE,CAAA;IACT,mDAAmD;IACnD,KAAK,GAAa,EAAE,CAAA;IAEpB;;;OAGG;IACH,EAAE;QACA,OAAO,WAAW,EAAE,CAAA;IACtB,CAAC;IAED;;;OAGG;IACH,QAAQ;QACN,OAAO,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;IAChD,CAAC;mGApBU,SAAS;6DAAT,SAAS;YAFT,6FAA8I;;YAA9I,cAAA,cAAU,CAAoI;;;iFAE9I,SAAS;cAXrB,SAAS;eAAC;gBACT,QAAQ,EAAE,eAAe;gBACzB,UAAU,EAAE,IAAI;gBAChB,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;gBACzB,IAAI,EAAE;oBACJ,oBAAoB,EAAE,EAAE;oBACxB,KAAK,EAAE,mBAAmB;iBAC3B;gBACD,kBAAkB;gBAClB,QAAQ,EAAE,gJAAgJ;aAC3J;;kFACY,SAAS"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Angular search UI for `@molecule/app-client-search`.
3
+ *
4
+ * The Angular counterpart of `@molecule/app-search-ui-react` — the same props
5
+ * (React names) and the same DOM for the same input. Three pieces that fit a
6
+ * `useSearchSession` from `@molecule/app-client-search-angular`:
7
+ * {@link SearchBox} (the field, its clear button and shortcut cap, a help icon
8
+ * whose tooltip shows the search syntax, an `afterField` projection for the
9
+ * consumer's own tabs, the active filter chips and the hit count),
10
+ * {@link SearchResults} (ranked rows with the matched terms marked, hover
11
+ * prefetch, an optional action per row; the keyboard-active row is marked with
12
+ * `aria-current` and announced through a polite status region), and
13
+ * {@link QuickSearchDialog} (both in a `mod+k` dialog named for screen readers
14
+ * by its `label`, "Search" by default). Every class comes from
15
+ * the ClassMap's search tokens (`searchField`, `resultList`, …), so a UI bond
16
+ * restyles all of it at once.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import { Component } from '@angular/core'
21
+ * import { Link } from '@molecule/app-angular'
22
+ * import { useSearchSession } from '@molecule/app-client-search-angular'
23
+ * import { QuickSearchDialog, SearchBox, SearchResults } from '@molecule/app-search-ui-angular'
24
+ * import { useTranslation } from '@molecule/app-angular'
25
+ *
26
+ * @Component({
27
+ * selector: 'app-catalog',
28
+ * standalone: true,
29
+ * imports: [Link, SearchBox, SearchResults],
30
+ * template: `
31
+ * <div mol-search-box
32
+ * [value]="session.query()"
33
+ * [onChange]="session.setQuery"
34
+ * [onKeyDown]="session.onKeyDown"
35
+ * [inputRef]="session.inputRef"
36
+ * placeholder="Search packages"
37
+ * [count]="session.hits().length"
38
+ * [filters]="session.parsed().filters"
39
+ * [onRemoveFilter]="session.removeFilter"
40
+ * [onClear]="session.clear"
41
+ * [examples]="['category:auth', 'type:bond']"
42
+ * ></div>
43
+ * <mol-search-results
44
+ * [hits]="session.hits()"
45
+ * [view]="view"
46
+ * [activeIndex]="session.activeIndex()"
47
+ * [onActivate]="session.setActiveIndex"
48
+ * [onOpen]="session.open"
49
+ * [onPrefetch]="session.prefetch"
50
+ * [renderLink]="link"
51
+ * emptyText="Nothing matches"
52
+ * ></mol-search-results>
53
+ * <ng-template #link let-p>
54
+ * <a molLink [to]="p.href" [state]="p.state" [className]="p.className" (click)="p.onClick($event)">
55
+ * <ng-template [ngTemplateOutlet]="p.children" [ngTemplateOutletContext]="{ $implicit: hit }"></ng-template>
56
+ * </a>
57
+ * </ng-template>
58
+ * `,
59
+ * })
60
+ * export class Catalog {
61
+ * readonly t = useTranslation().t
62
+ * readonly session = useSearchSession({
63
+ * docs: packages,
64
+ * options: PACKAGE_INDEX_OPTIONS,
65
+ * rememberKey: 'catalog.search',
66
+ * onOpen: (p) => navigate(`/packages/${p.name}`),
67
+ * })
68
+ * readonly view = (p: Pkg) => ({ href: `/packages/${p.name}`, title: `@molecule/${p.name}`, description: p.description, meta: [p.type, p.category], mono: true })
69
+ * }
70
+ * ```
71
+ *
72
+ * (`searchPlaceholder` and `nothingMatches` are the app's own translated strings.)
73
+ *
74
+ * @remarks
75
+ * - **Pass a router link through `renderLink`**, or every row is a full page
76
+ * load: the list renders a plain `<a>` by default because it does not know
77
+ * your router. A plain click calls `onOpen` (which the session turns into
78
+ * navigation); a modified click is left to the browser so "open in new tab" works.
79
+ * - The box does not own the text: bind `value`/`onChange` to a session (or
80
+ * any state) and it stays mounted, with its text, across searches. Do not
81
+ * remount it per search.
82
+ * - `placeholder`, `emptyText` and the like are already-translated strings
83
+ * from the app; the package translates only its own chrome ("Clear
84
+ * search", "{{count}} results", "Search tips") through `@molecule/app-locales-search-ui`.
85
+ * - The quick dialog needs a session created with `syncUrl: false` and
86
+ * `onEscape: onClose`; the page's own session keeps the URL.
87
+ * - Node-valued React props are projected content: `afterField` is selected
88
+ * by `[slot=afterField]`, and a render function (`renderLink`, `action`) is
89
+ * a `TemplateRef` whose context carries its argument as `$implicit`.
90
+ *
91
+ * @module
92
+ */
93
+ export * from './highlight.component.js';
94
+ export * from './kbd.component.js';
95
+ export * from './quick-search-dialog.component.js';
96
+ export * from './search-box.component.js';
97
+ export * from './search-results.component.js';
98
+ export * from './types.js';
99
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AAEH,cAAc,0BAA0B,CAAA;AACxC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oCAAoC,CAAA;AAClD,cAAc,2BAA2B,CAAA;AACzC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Angular search UI for `@molecule/app-client-search`.
3
+ *
4
+ * The Angular counterpart of `@molecule/app-search-ui-react` — the same props
5
+ * (React names) and the same DOM for the same input. Three pieces that fit a
6
+ * `useSearchSession` from `@molecule/app-client-search-angular`:
7
+ * {@link SearchBox} (the field, its clear button and shortcut cap, a help icon
8
+ * whose tooltip shows the search syntax, an `afterField` projection for the
9
+ * consumer's own tabs, the active filter chips and the hit count),
10
+ * {@link SearchResults} (ranked rows with the matched terms marked, hover
11
+ * prefetch, an optional action per row; the keyboard-active row is marked with
12
+ * `aria-current` and announced through a polite status region), and
13
+ * {@link QuickSearchDialog} (both in a `mod+k` dialog named for screen readers
14
+ * by its `label`, "Search" by default). Every class comes from
15
+ * the ClassMap's search tokens (`searchField`, `resultList`, …), so a UI bond
16
+ * restyles all of it at once.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import { Component } from '@angular/core'
21
+ * import { Link } from '@molecule/app-angular'
22
+ * import { useSearchSession } from '@molecule/app-client-search-angular'
23
+ * import { QuickSearchDialog, SearchBox, SearchResults } from '@molecule/app-search-ui-angular'
24
+ * import { useTranslation } from '@molecule/app-angular'
25
+ *
26
+ * @Component({
27
+ * selector: 'app-catalog',
28
+ * standalone: true,
29
+ * imports: [Link, SearchBox, SearchResults],
30
+ * template: `
31
+ * <div mol-search-box
32
+ * [value]="session.query()"
33
+ * [onChange]="session.setQuery"
34
+ * [onKeyDown]="session.onKeyDown"
35
+ * [inputRef]="session.inputRef"
36
+ * placeholder="Search packages"
37
+ * [count]="session.hits().length"
38
+ * [filters]="session.parsed().filters"
39
+ * [onRemoveFilter]="session.removeFilter"
40
+ * [onClear]="session.clear"
41
+ * [examples]="['category:auth', 'type:bond']"
42
+ * ></div>
43
+ * <mol-search-results
44
+ * [hits]="session.hits()"
45
+ * [view]="view"
46
+ * [activeIndex]="session.activeIndex()"
47
+ * [onActivate]="session.setActiveIndex"
48
+ * [onOpen]="session.open"
49
+ * [onPrefetch]="session.prefetch"
50
+ * [renderLink]="link"
51
+ * emptyText="Nothing matches"
52
+ * ></mol-search-results>
53
+ * <ng-template #link let-p>
54
+ * <a molLink [to]="p.href" [state]="p.state" [className]="p.className" (click)="p.onClick($event)">
55
+ * <ng-template [ngTemplateOutlet]="p.children" [ngTemplateOutletContext]="{ $implicit: hit }"></ng-template>
56
+ * </a>
57
+ * </ng-template>
58
+ * `,
59
+ * })
60
+ * export class Catalog {
61
+ * readonly t = useTranslation().t
62
+ * readonly session = useSearchSession({
63
+ * docs: packages,
64
+ * options: PACKAGE_INDEX_OPTIONS,
65
+ * rememberKey: 'catalog.search',
66
+ * onOpen: (p) => navigate(`/packages/${p.name}`),
67
+ * })
68
+ * readonly view = (p: Pkg) => ({ href: `/packages/${p.name}`, title: `@molecule/${p.name}`, description: p.description, meta: [p.type, p.category], mono: true })
69
+ * }
70
+ * ```
71
+ *
72
+ * (`searchPlaceholder` and `nothingMatches` are the app's own translated strings.)
73
+ *
74
+ * @remarks
75
+ * - **Pass a router link through `renderLink`**, or every row is a full page
76
+ * load: the list renders a plain `<a>` by default because it does not know
77
+ * your router. A plain click calls `onOpen` (which the session turns into
78
+ * navigation); a modified click is left to the browser so "open in new tab" works.
79
+ * - The box does not own the text: bind `value`/`onChange` to a session (or
80
+ * any state) and it stays mounted, with its text, across searches. Do not
81
+ * remount it per search.
82
+ * - `placeholder`, `emptyText` and the like are already-translated strings
83
+ * from the app; the package translates only its own chrome ("Clear
84
+ * search", "{{count}} results", "Search tips") through `@molecule/app-locales-search-ui`.
85
+ * - The quick dialog needs a session created with `syncUrl: false` and
86
+ * `onEscape: onClose`; the page's own session keeps the URL.
87
+ * - Node-valued React props are projected content: `afterField` is selected
88
+ * by `[slot=afterField]`, and a render function (`renderLink`, `action`) is
89
+ * a `TemplateRef` whose context carries its argument as `$implicit`.
90
+ *
91
+ * @module
92
+ */
93
+ export * from './highlight.component.js';
94
+ export * from './kbd.component.js';
95
+ export * from './quick-search-dialog.component.js';
96
+ export * from './search-box.component.js';
97
+ export * from './search-results.component.js';
98
+ export * from './types.js';
99
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AAEH,cAAc,0BAA0B,CAAA;AACxC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oCAAoC,CAAA;AAClD,cAAc,2BAA2B,CAAA;AACzC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,YAAY,CAAA"}
@@ -0,0 +1,28 @@
1
+ import type { UIClassMap } from '@molecule/app-ui';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Kbd component.
5
+ *
6
+ * A key cap, for shortcut hints (`/` to focus, `↵` to open). The host IS the
7
+ * `<kbd>` React renders (`kbd[mol-kbd]`), and the key label is the projected
8
+ * content — the same children React's `Kbd` carries. The cap shows a key name,
9
+ * not prose (a physical key such as `esc` reads the same in every language), so
10
+ * the host carries HTML's own `translate="no"`.
11
+ */
12
+ export declare class Kbd {
13
+ /** Extra classes composed onto the cap. */
14
+ className?: string;
15
+ /**
16
+ * The current class map.
17
+ * @returns The UIClassMap.
18
+ */
19
+ cm(): UIClassMap;
20
+ /**
21
+ * The cap's class list (`cm.kbd` + `className`).
22
+ * @returns The class string.
23
+ */
24
+ classes(): string;
25
+ static ɵfac: i0.ɵɵFactoryDeclaration<Kbd, never>;
26
+ static ɵcmp: i0.ɵɵComponentDeclaration<Kbd, "kbd[mol-kbd]", never, { "className": { "alias": "className"; "required": false; }; }, {}, never, ["*"], true, never>;
27
+ }
28
+ //# sourceMappingURL=kbd.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kbd.component.d.ts","sourceRoot":"","sources":["../src/kbd.component.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;;AAGlD;;;;;;;;GAQG;AACH,qBAUa,GAAG;IACd,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;OAGG;IACH,EAAE,IAAI,UAAU;IAIhB;;;OAGG;IACH,OAAO,IAAI,MAAM;yCAhBN,GAAG;2CAAH,GAAG;CAmBf"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Kbd component (React parity).
3
+ *
4
+ * @module
5
+ */
6
+ import { Component } from '@angular/core';
7
+ import { getClassMap } from '@molecule/app-ui';
8
+ import * as i0 from "@angular/core";
9
+ const _c0 = ["*"];
10
+ /**
11
+ * Kbd component.
12
+ *
13
+ * A key cap, for shortcut hints (`/` to focus, `↵` to open). The host IS the
14
+ * `<kbd>` React renders (`kbd[mol-kbd]`), and the key label is the projected
15
+ * content — the same children React's `Kbd` carries. The cap shows a key name,
16
+ * not prose (a physical key such as `esc` reads the same in every language), so
17
+ * the host carries HTML's own `translate="no"`.
18
+ */
19
+ export class Kbd {
20
+ /** Extra classes composed onto the cap. */
21
+ className;
22
+ /**
23
+ * The current class map.
24
+ * @returns The UIClassMap.
25
+ */
26
+ cm() {
27
+ return getClassMap();
28
+ }
29
+ /**
30
+ * The cap's class list (`cm.kbd` + `className`).
31
+ * @returns The class string.
32
+ */
33
+ classes() {
34
+ return this.cm().cn(this.cm().kbd, this.className);
35
+ }
36
+ static ɵfac = function Kbd_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || Kbd)(); };
37
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: Kbd, selectors: [["kbd", "mol-kbd", ""]], hostAttrs: ["translate", "no"], hostVars: 2, hostBindings: function Kbd_HostBindings(rf, ctx) { if (rf & 2) {
38
+ i0.ɵɵclassMap(ctx.classes());
39
+ } }, inputs: { className: "className" }, ngContentSelectors: _c0, decls: 1, vars: 0, template: function Kbd_Template(rf, ctx) { if (rf & 1) {
40
+ i0.ɵɵprojectionDef();
41
+ i0.ɵɵprojection(0);
42
+ } }, encapsulation: 2 });
43
+ }
44
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(Kbd, [{
45
+ type: Component,
46
+ args: [{
47
+ selector: 'kbd[mol-kbd]',
48
+ standalone: true,
49
+ inputs: ['className'],
50
+ host: {
51
+ '[class]': 'classes()',
52
+ translate: 'no',
53
+ },
54
+ template: `<ng-content></ng-content>`,
55
+ }]
56
+ }], null, null); })();
57
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(Kbd, { className: "Kbd", filePath: "kbd.component.ts", lineNumber: 31 }); })();
58
+ //# sourceMappingURL=kbd.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kbd.component.js","sourceRoot":"","sources":["../src/kbd.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAGzC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;;;AAE9C;;;;;;;;GAQG;AAWH,MAAM,OAAO,GAAG;IACd,2CAA2C;IAC3C,SAAS,CAAS;IAElB;;;OAGG;IACH,EAAE;QACA,OAAO,WAAW,EAAE,CAAA;IACtB,CAAC;IAED;;;OAGG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;IACpD,CAAC;6FAlBU,GAAG;6DAAH,GAAG;YAAH,cAAA,aACV,CADa;;;YAFH,kBAAyB;;;iFAEzB,GAAG;cAVf,SAAS;eAAC;gBACT,QAAQ,EAAE,cAAc;gBACxB,UAAU,EAAE,IAAI;gBAChB,MAAM,EAAE,CAAC,WAAW,CAAC;gBACrB,IAAI,EAAE;oBACJ,SAAS,EAAE,WAAW;oBACtB,SAAS,EAAE,IAAI;iBAChB;gBACD,QAAQ,EAAE,2BAA2B;aACtC;;kFACY,GAAG"}
@@ -0,0 +1,131 @@
1
+ /**
2
+ * QuickSearchDialog component (React parity).
3
+ *
4
+ * @module
5
+ */
6
+ import type { Signal } from '@angular/core';
7
+ import { 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 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 after the first render, the way React's effect
114
+ * keyed on `open` and `session.inputRef` does. The move runs after the view
115
+ * check: focusing during it would fire the field's `focusin` listeners while
116
+ * Angular is still checking, and a state change they make would never render.
117
+ */
118
+ constructor();
119
+ /**
120
+ * Focuses after an open flip too; the field mounts within the same change
121
+ * detection pass, and the focus waits one microtask for it.
122
+ *
123
+ * @param changes - The changed inputs.
124
+ */
125
+ ngOnChanges(changes: SimpleChanges): void;
126
+ /** Focuses the session's input while the dialog is open. */
127
+ private focusField;
128
+ static ɵfac: i0.ɵɵFactoryDeclaration<QuickSearchDialog<any>, never>;
129
+ 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>;
130
+ }
131
+ //# 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,EAGL,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,CAC5B,CAAC,SAAS,oBAAoB,GAAG,oBAAoB,CACrD,YAAW,SAAS;IACpB,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,EAAE,CAAA;IACnB,gEAAgE;IAChE,SAAS,SAAK;IACd,sFAAsF;IACtF,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,oGAAoG;IACpG,UAAU,CAAC,EAAE,WAAW,CAAC;QAAE,SAAS,EAAE,qBAAqB,CAAA;KAAE,CAAC,CAAA;IAC9D;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd,iDAAiD;IACjD,QAAQ,CAAC,CAAC,8IAAqB;IAE/B;;;OAGG;IACH,EAAE,IAAI,UAAU;IAIhB;;;;;;OAMG;IACH,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAIhC;;;OAGG;IACH,EAAE,IAAI,MAAM;IAIZ;;;OAGG;IACH,UAAU,IAAI,MAAM;IAIpB;;;;OAIG;IACH,WAAW,IAAI,MAAM;IAIrB;;;OAGG;IACH,QAAQ,IAAI,MAAM;IAMlB;;;;OAIG;IACH,aAAa,IAAI,MAAM;IAIvB,gEAAgE;IAChE,QAAQ,IAAI,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI;IAInC,mEAAmE;IACnE,cAAc,IAAI,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI;IAIhD,sEAAsE;IACtE,YAAY,IAAI,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI;IAIvC,iEAAiE;IACjE,YAAY,IAAI,MAAM,IAAI;IAI1B,uEAAuE;IACvE,cAAc,IAAI,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI;IAIzC,gEAAgE;IAChE,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI;IAI3B,wEAAwE;IACxE,WAAW,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI;IAI/B,wDAAwD;IACxD,SAAS,IAAI,IAAI;IAIjB;;;;;OAKG;;IAKH;;;;;OAKG;IACH,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAIzC,4DAA4D;IAC5D,OAAO,CAAC,UAAU;yCA7JP,iBAAiB;2CAAjB,iBAAiB;CAgK7B"}