@molecule/app-search-autocomplete-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/index.d.ts +66 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -0
- package/dist/search-autocomplete.component.d.ts +238 -0
- package/dist/search-autocomplete.component.d.ts.map +1 -0
- package/dist/search-autocomplete.component.js +542 -0
- package/dist/search-autocomplete.component.js.map +1 -0
- package/dist/types.d.ts +49 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/package.json +69 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @molecule/app-search-autocomplete-angular
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Search input with typeahead suggestion popover
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
npm install @molecule/app-search-autocomplete-angular
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Part of the [Molecule](https://www.molecule.dev) package fleet. This page carries the manifest summary; the full generated documentation ships with the package's first committed version.
|
|
10
|
+
|
|
11
|
+
License: Apache-2.0
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search input with a typeahead suggestion popover.
|
|
3
|
+
*
|
|
4
|
+
* Exports `<SearchAutocomplete>` (an attribute-selector component:
|
|
5
|
+
* `div[mol-search-autocomplete]`, whose host is React's root `<div>`) and the
|
|
6
|
+
* `SuggestionItem<T>` type (`{ id, label, meta?, data? }`). Two data modes —
|
|
7
|
+
* pass ONE of: `onSearch(query)` (async fetch, debounced; default 200 ms) or
|
|
8
|
+
* `suggestions` (caller-controlled list). Other props: `value` / `onChange`
|
|
9
|
+
* (controlled input), `onSelect(item)`, `placeholder?` (defaults to the
|
|
10
|
+
* translated `search.placeholder`), `debounceMs?`, `minChars?` (default 1),
|
|
11
|
+
* `className?`.
|
|
12
|
+
*
|
|
13
|
+
* Angular counterpart of `@molecule/app-search-autocomplete-react`: the same
|
|
14
|
+
* exports, the same props (React names) and the same DOM for the same input.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { Component, signal } from '@angular/core'
|
|
19
|
+
* import {
|
|
20
|
+
* SearchAutocomplete,
|
|
21
|
+
* type SuggestionItem,
|
|
22
|
+
* } from '@molecule/app-search-autocomplete-angular'
|
|
23
|
+
*
|
|
24
|
+
* @Component({
|
|
25
|
+
* selector: 'app-user-search',
|
|
26
|
+
* standalone: true,
|
|
27
|
+
* imports: [SearchAutocomplete],
|
|
28
|
+
* template: `
|
|
29
|
+
* <div
|
|
30
|
+
* mol-search-autocomplete
|
|
31
|
+
* [value]="query()"
|
|
32
|
+
* [onChange]="setQuery"
|
|
33
|
+
* [onSearch]="fetchUsers"
|
|
34
|
+
* [onSelect]="pick"
|
|
35
|
+
* placeholder="Search users…"
|
|
36
|
+
* ></div>
|
|
37
|
+
* `,
|
|
38
|
+
* })
|
|
39
|
+
* export class UserSearch {
|
|
40
|
+
* readonly query = signal('')
|
|
41
|
+
* readonly setQuery = (next: string): void => this.query.set(next)
|
|
42
|
+
* readonly fetchUsers = (q: string): Promise<SuggestionItem<{ id: string }>[]> =>
|
|
43
|
+
* fetch(`/api/users?q=${encodeURIComponent(q)}`).then((r) => r.json())
|
|
44
|
+
* readonly pick = (item: SuggestionItem<{ id: string }>): void => console.log(item.data?.id)
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @remarks
|
|
49
|
+
* - Throws unless provided the binding's molecule providers (`@molecule/app-angular`)
|
|
50
|
+
* with a bonded ClassMap and i18n provider.
|
|
51
|
+
* - Full keyboard support: it's an ARIA combobox — ArrowDown/ArrowUp move the
|
|
52
|
+
* highlight (opening the popover), Enter selects the highlighted option, and
|
|
53
|
+
* Escape closes. `aria-activedescendant` tracks the active `role="option"`.
|
|
54
|
+
* - Stale-response safe: out-of-order `onSearch` responses are dropped (each
|
|
55
|
+
* request carries a token; only the latest applies), so a slow earlier fetch
|
|
56
|
+
* can't overwrite fresher results. `onSearch` needs no cancellation of its own.
|
|
57
|
+
* - The popover surface uses `var(--color-surface)` with a WHITE fallback
|
|
58
|
+
* and black-alpha borders — define `--color-surface` (dark themes) or the
|
|
59
|
+
* dropdown stays light.
|
|
60
|
+
* - Default placeholder translations: `@molecule/app-locales-search-autocomplete`.
|
|
61
|
+
*
|
|
62
|
+
* @module
|
|
63
|
+
*/
|
|
64
|
+
export * from './search-autocomplete.component.js';
|
|
65
|
+
export * from './types.js';
|
|
66
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAEH,cAAc,oCAAoC,CAAA;AAClD,cAAc,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search input with a typeahead suggestion popover.
|
|
3
|
+
*
|
|
4
|
+
* Exports `<SearchAutocomplete>` (an attribute-selector component:
|
|
5
|
+
* `div[mol-search-autocomplete]`, whose host is React's root `<div>`) and the
|
|
6
|
+
* `SuggestionItem<T>` type (`{ id, label, meta?, data? }`). Two data modes —
|
|
7
|
+
* pass ONE of: `onSearch(query)` (async fetch, debounced; default 200 ms) or
|
|
8
|
+
* `suggestions` (caller-controlled list). Other props: `value` / `onChange`
|
|
9
|
+
* (controlled input), `onSelect(item)`, `placeholder?` (defaults to the
|
|
10
|
+
* translated `search.placeholder`), `debounceMs?`, `minChars?` (default 1),
|
|
11
|
+
* `className?`.
|
|
12
|
+
*
|
|
13
|
+
* Angular counterpart of `@molecule/app-search-autocomplete-react`: the same
|
|
14
|
+
* exports, the same props (React names) and the same DOM for the same input.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { Component, signal } from '@angular/core'
|
|
19
|
+
* import {
|
|
20
|
+
* SearchAutocomplete,
|
|
21
|
+
* type SuggestionItem,
|
|
22
|
+
* } from '@molecule/app-search-autocomplete-angular'
|
|
23
|
+
*
|
|
24
|
+
* @Component({
|
|
25
|
+
* selector: 'app-user-search',
|
|
26
|
+
* standalone: true,
|
|
27
|
+
* imports: [SearchAutocomplete],
|
|
28
|
+
* template: `
|
|
29
|
+
* <div
|
|
30
|
+
* mol-search-autocomplete
|
|
31
|
+
* [value]="query()"
|
|
32
|
+
* [onChange]="setQuery"
|
|
33
|
+
* [onSearch]="fetchUsers"
|
|
34
|
+
* [onSelect]="pick"
|
|
35
|
+
* placeholder="Search users…"
|
|
36
|
+
* ></div>
|
|
37
|
+
* `,
|
|
38
|
+
* })
|
|
39
|
+
* export class UserSearch {
|
|
40
|
+
* readonly query = signal('')
|
|
41
|
+
* readonly setQuery = (next: string): void => this.query.set(next)
|
|
42
|
+
* readonly fetchUsers = (q: string): Promise<SuggestionItem<{ id: string }>[]> =>
|
|
43
|
+
* fetch(`/api/users?q=${encodeURIComponent(q)}`).then((r) => r.json())
|
|
44
|
+
* readonly pick = (item: SuggestionItem<{ id: string }>): void => console.log(item.data?.id)
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @remarks
|
|
49
|
+
* - Throws unless provided the binding's molecule providers (`@molecule/app-angular`)
|
|
50
|
+
* with a bonded ClassMap and i18n provider.
|
|
51
|
+
* - Full keyboard support: it's an ARIA combobox — ArrowDown/ArrowUp move the
|
|
52
|
+
* highlight (opening the popover), Enter selects the highlighted option, and
|
|
53
|
+
* Escape closes. `aria-activedescendant` tracks the active `role="option"`.
|
|
54
|
+
* - Stale-response safe: out-of-order `onSearch` responses are dropped (each
|
|
55
|
+
* request carries a token; only the latest applies), so a slow earlier fetch
|
|
56
|
+
* can't overwrite fresher results. `onSearch` needs no cancellation of its own.
|
|
57
|
+
* - The popover surface uses `var(--color-surface)` with a WHITE fallback
|
|
58
|
+
* and black-alpha borders — define `--color-surface` (dark themes) or the
|
|
59
|
+
* dropdown stays light.
|
|
60
|
+
* - Default placeholder translations: `@molecule/app-locales-search-autocomplete`.
|
|
61
|
+
*
|
|
62
|
+
* @module
|
|
63
|
+
*/
|
|
64
|
+
export * from './search-autocomplete.component.js';
|
|
65
|
+
export * from './types.js';
|
|
66
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAEH,cAAc,oCAAoC,CAAA;AAClD,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { type OnChanges, type OnDestroy, type OnInit, type SimpleChanges, type TemplateRef } from '@angular/core';
|
|
2
|
+
import type { UIClassMap } from '@molecule/app-ui';
|
|
3
|
+
import type { SuggestionItem } from './types.js';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
/**
|
|
6
|
+
* SearchAutocomplete component.
|
|
7
|
+
*
|
|
8
|
+
* Search input with a typeahead suggestions popover. The host IS React's root
|
|
9
|
+
* `<div>` (`div[mol-search-autocomplete]`), carrying React's class list; the
|
|
10
|
+
* input surface reproduces `@molecule/app-ui-angular`'s `Input` DOM (the
|
|
11
|
+
* wrapper, the inner row and the native `input`) so the combobox attributes
|
|
12
|
+
* land on the input itself, exactly where React spreads them.
|
|
13
|
+
*/
|
|
14
|
+
export declare class SearchAutocomplete implements OnInit, OnChanges, OnDestroy {
|
|
15
|
+
/** Current input value. */
|
|
16
|
+
value: string;
|
|
17
|
+
/** Called whenever the input changes (React's `onChange`). */
|
|
18
|
+
onChange?: (value: string) => void;
|
|
19
|
+
/** Async search function (React's `onSearch`). */
|
|
20
|
+
onSearch?: (query: string) => Promise<SuggestionItem[]> | SuggestionItem[];
|
|
21
|
+
/** Caller-controlled suggestion list (React's `suggestions`). */
|
|
22
|
+
suggestions?: SuggestionItem[];
|
|
23
|
+
/** Called when the user picks a suggestion (React's `onSelect`). */
|
|
24
|
+
onSelect?: (item: SuggestionItem) => void;
|
|
25
|
+
/** Placeholder (falls back to the translated `search.placeholder`). */
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Accessible name for the input (React's `aria-label`); falls back to the
|
|
29
|
+
* translated `search.aria.label`.
|
|
30
|
+
*/
|
|
31
|
+
ariaLabel?: string;
|
|
32
|
+
/** Debounce ms for `onSearch` (React's default 200). */
|
|
33
|
+
debounceMs?: number;
|
|
34
|
+
/** Min chars before suggestions appear (React's default 1). */
|
|
35
|
+
minChars?: number;
|
|
36
|
+
/** Extra classes on the wrapper. */
|
|
37
|
+
className?: string;
|
|
38
|
+
/** The native input (React's controlled-value restore targets it). */
|
|
39
|
+
private inputEl?;
|
|
40
|
+
/**
|
|
41
|
+
* Reactive translation, read in the injection context. Its `t` reads the
|
|
42
|
+
* locale, so the view re-renders the text on a locale switch.
|
|
43
|
+
*/
|
|
44
|
+
private readonly i18n;
|
|
45
|
+
private readonly cdr;
|
|
46
|
+
private readonly host;
|
|
47
|
+
/** The fetched suggestion rows (React's `useState<SuggestionItem[]>([])`). */
|
|
48
|
+
private readonly internal;
|
|
49
|
+
/** Whether the popover was opened (React's `open` state). */
|
|
50
|
+
private readonly open;
|
|
51
|
+
/** Index of the keyboard-highlighted option (-1 = none). */
|
|
52
|
+
private readonly activeIndex;
|
|
53
|
+
/** Monotonic id of the latest in-flight `onSearch` (the race guard). */
|
|
54
|
+
private request;
|
|
55
|
+
/** The pending debounce timer. */
|
|
56
|
+
private timer;
|
|
57
|
+
/** The per-instance id base (React's `useId()`). */
|
|
58
|
+
private readonly baseId;
|
|
59
|
+
/** The listbox id (React's `${baseId}-listbox`). */
|
|
60
|
+
readonly listId: string;
|
|
61
|
+
/** The popover's inline style (React's style object serialized). */
|
|
62
|
+
readonly listStyle = "position: absolute; top: 100%; left: 0px; right: 0px; z-index: 50; background: var(--color-surface, #fff); border: 1px solid rgba(0, 0, 0, 0.1); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); max-height: 320px; overflow-y: auto";
|
|
63
|
+
/**
|
|
64
|
+
* Starts the outside-mousedown listener and the initial search.
|
|
65
|
+
*/
|
|
66
|
+
ngOnInit(): void;
|
|
67
|
+
/**
|
|
68
|
+
* React's effects on `value`, `onSearch`, `debounceMs` and `minChars`: a
|
|
69
|
+
* change restarts the debounced search, and a new query resets the highlight.
|
|
70
|
+
*
|
|
71
|
+
* @param changes - The inputs that changed in this pass.
|
|
72
|
+
*/
|
|
73
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
74
|
+
/**
|
|
75
|
+
* Removes the document listener and the pending debounce timer.
|
|
76
|
+
*/
|
|
77
|
+
ngOnDestroy(): void;
|
|
78
|
+
/**
|
|
79
|
+
* The current class map.
|
|
80
|
+
* @returns The UIClassMap.
|
|
81
|
+
*/
|
|
82
|
+
cm(): UIClassMap;
|
|
83
|
+
/**
|
|
84
|
+
* The wrapper's class list (React's `cn(position('relative'), className)`).
|
|
85
|
+
* @returns The class string.
|
|
86
|
+
*/
|
|
87
|
+
classes(): string;
|
|
88
|
+
/**
|
|
89
|
+
* The native input's class list (React's Input root classes).
|
|
90
|
+
* @returns The class string.
|
|
91
|
+
*/
|
|
92
|
+
inputClasses(): string;
|
|
93
|
+
/**
|
|
94
|
+
* The listbox's class list.
|
|
95
|
+
* @returns The class string.
|
|
96
|
+
*/
|
|
97
|
+
listClasses(): string;
|
|
98
|
+
/**
|
|
99
|
+
* A row's label class (React's `fontWeight('medium')`).
|
|
100
|
+
* @returns The class string.
|
|
101
|
+
*/
|
|
102
|
+
labelClasses(): string;
|
|
103
|
+
/**
|
|
104
|
+
* A row's secondary line class (React's `textSize('xs')`).
|
|
105
|
+
* @returns The class string.
|
|
106
|
+
*/
|
|
107
|
+
metaClasses(): string;
|
|
108
|
+
/**
|
|
109
|
+
* One option row's class list, exactly as React composes it.
|
|
110
|
+
* @param index - The row's position.
|
|
111
|
+
* @returns The class string.
|
|
112
|
+
*/
|
|
113
|
+
optionClasses(index: number): string;
|
|
114
|
+
/**
|
|
115
|
+
* The native input's id (React's generated input id).
|
|
116
|
+
* @returns The id.
|
|
117
|
+
*/
|
|
118
|
+
get inputId(): string;
|
|
119
|
+
/**
|
|
120
|
+
* Stable DOM id for the option at `index` (referenced by aria-activedescendant).
|
|
121
|
+
* @param index - Option position.
|
|
122
|
+
* @returns The option id.
|
|
123
|
+
*/
|
|
124
|
+
optionId(index: number): string;
|
|
125
|
+
/**
|
|
126
|
+
* The placeholder React renders: the prop, else the translated default.
|
|
127
|
+
* @returns The placeholder text.
|
|
128
|
+
*/
|
|
129
|
+
placeholderText(): string;
|
|
130
|
+
/**
|
|
131
|
+
* The input's accessible name: the prop, else the translated default. A
|
|
132
|
+
* placeholder is not a label, so the name never rests on it.
|
|
133
|
+
* @returns The `aria-label` text.
|
|
134
|
+
*/
|
|
135
|
+
ariaLabelText(): string;
|
|
136
|
+
/**
|
|
137
|
+
* The suggestion list: the caller's controlled list wins over fetched results.
|
|
138
|
+
* @returns The rows to render.
|
|
139
|
+
*/
|
|
140
|
+
list(): SuggestionItem[];
|
|
141
|
+
/**
|
|
142
|
+
* The popover is only visible with open + at least one suggestion.
|
|
143
|
+
* @returns Whether the listbox renders.
|
|
144
|
+
*/
|
|
145
|
+
isExpanded(): boolean;
|
|
146
|
+
/**
|
|
147
|
+
* The highlight clamped to the current list: a list that shrinks below the
|
|
148
|
+
* highlighted index leaves the old option id pointing at nothing, so every
|
|
149
|
+
* read of the index (activedescendant, the highlighted option, Enter) sees
|
|
150
|
+
* -1 — nothing highlighted — instead of naming an option that is gone.
|
|
151
|
+
*
|
|
152
|
+
* @returns The active index, or -1 when nothing is highlighted.
|
|
153
|
+
*/
|
|
154
|
+
active(): number;
|
|
155
|
+
/**
|
|
156
|
+
* The highlighted option's id, or null when nothing is highlighted.
|
|
157
|
+
* @returns The id, or null.
|
|
158
|
+
*/
|
|
159
|
+
activeDescendant(): string | null;
|
|
160
|
+
/**
|
|
161
|
+
* Whether a node value is a template rather than text.
|
|
162
|
+
* @param value - The field value.
|
|
163
|
+
* @returns True when it renders through `ngTemplateOutlet`.
|
|
164
|
+
*/
|
|
165
|
+
isTemplate(value: unknown): value is TemplateRef<unknown>;
|
|
166
|
+
/**
|
|
167
|
+
* Narrows a node value to its template form.
|
|
168
|
+
* @param value - The field value.
|
|
169
|
+
* @returns The template.
|
|
170
|
+
*/
|
|
171
|
+
asTemplate(value: unknown): TemplateRef<unknown>;
|
|
172
|
+
/**
|
|
173
|
+
* A node value as text (React renders strings and numbers).
|
|
174
|
+
* @param value - The field value.
|
|
175
|
+
* @returns The text, or `''`.
|
|
176
|
+
*/
|
|
177
|
+
textOf(value: unknown): string;
|
|
178
|
+
/**
|
|
179
|
+
* React's `debounceMs = 200` default.
|
|
180
|
+
* @returns The debounce delay in ms.
|
|
181
|
+
*/
|
|
182
|
+
private debounce;
|
|
183
|
+
/**
|
|
184
|
+
* React's `minChars = 1` default.
|
|
185
|
+
* @returns The minimum query length.
|
|
186
|
+
*/
|
|
187
|
+
private threshold;
|
|
188
|
+
/**
|
|
189
|
+
* Runs React's debounced `onSearch` effect: a query shorter than `minChars`
|
|
190
|
+
* clears the results, and only the latest response may apply.
|
|
191
|
+
*/
|
|
192
|
+
private scheduleSearch;
|
|
193
|
+
/**
|
|
194
|
+
* React's text-input `onChange`: report the typed value, open the popover and
|
|
195
|
+
* restore the controlled value.
|
|
196
|
+
*
|
|
197
|
+
* @param event - The native input event.
|
|
198
|
+
*/
|
|
199
|
+
handleInput(event: Event): void;
|
|
200
|
+
/**
|
|
201
|
+
* React's `onFocus`: a query at least `minChars` long opens the popover.
|
|
202
|
+
*/
|
|
203
|
+
handleFocus(): void;
|
|
204
|
+
/**
|
|
205
|
+
* Full keyboard support for the combobox: ArrowDown/ArrowUp move the
|
|
206
|
+
* highlight (opening the popover if needed), Enter selects the highlighted
|
|
207
|
+
* option, Escape closes.
|
|
208
|
+
*
|
|
209
|
+
* @param event - The keyboard event from the input.
|
|
210
|
+
*/
|
|
211
|
+
handleKeydown(event: KeyboardEvent): void;
|
|
212
|
+
/**
|
|
213
|
+
* Highlights a row on pointer hover.
|
|
214
|
+
* @param index - The row's position.
|
|
215
|
+
*/
|
|
216
|
+
onOptionEnter(index: number): void;
|
|
217
|
+
/**
|
|
218
|
+
* Selects a row on press: preventDefault keeps DOM focus on the input, which
|
|
219
|
+
* owns the combobox.
|
|
220
|
+
*
|
|
221
|
+
* @param event - The mousedown event.
|
|
222
|
+
* @param suggestion - The pressed suggestion.
|
|
223
|
+
*/
|
|
224
|
+
onOptionDown(event: MouseEvent, suggestion: SuggestionItem): void;
|
|
225
|
+
/**
|
|
226
|
+
* Commits a suggestion selection and closes the popover.
|
|
227
|
+
* @param item - The chosen suggestion.
|
|
228
|
+
*/
|
|
229
|
+
private select;
|
|
230
|
+
/**
|
|
231
|
+
* Closes the dropdown when a click occurs outside the wrapper element.
|
|
232
|
+
* @param event - The document mousedown.
|
|
233
|
+
*/
|
|
234
|
+
private readonly onDoc;
|
|
235
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SearchAutocomplete, never>;
|
|
236
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SearchAutocomplete, "div[mol-search-autocomplete]", never, { "value": { "alias": "value"; "required": false; }; "onChange": { "alias": "onChange"; "required": false; }; "onSearch": { "alias": "onSearch"; "required": false; }; "suggestions": { "alias": "suggestions"; "required": false; }; "onSelect": { "alias": "onSelect"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; }; "debounceMs": { "alias": "debounceMs"; "required": false; }; "minChars": { "alias": "minChars"; "required": false; }; "className": { "alias": "className"; "required": false; }; }, {}, never, never, true, never>;
|
|
237
|
+
}
|
|
238
|
+
//# sourceMappingURL=search-autocomplete.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-autocomplete.component.d.ts","sourceRoot":"","sources":["../src/search-autocomplete.component.ts"],"names":[],"mappings":"AAOA,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,MAAM,EAEX,KAAK,aAAa,EAClB,KAAK,WAAW,EAEjB,MAAM,eAAe,CAAA;AAGtB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAGlD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;;AAmChD;;;;;;;;GAQG;AACH,qBAsBa,kBAAmB,YAAW,MAAM,EAAE,SAAS,EAAE,SAAS;IACrE,2BAA2B;IAC3B,KAAK,SAAK;IACV,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,kDAAkD;IAClD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,EAAE,CAAC,GAAG,cAAc,EAAE,CAAA;IAC1E,iEAAiE;IACjE,W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AAc,GAAG,IAAI;IAKjE;;;OAGG;IACH,OAAO,CAAC,MAAM;IAMd;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,KAAK,CAMrB;yCA5YU,kBAAkB;2CAAlB,kBAAkB;CA6Y9B"}
|
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SearchAutocomplete component (React parity).
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
7
|
+
import { ChangeDetectorRef, Component, ElementRef, inject, signal, ViewChild, } from '@angular/core';
|
|
8
|
+
import { useTranslation } from '@molecule/app-angular';
|
|
9
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
10
|
+
import * as i0 from "@angular/core";
|
|
11
|
+
const _c0 = ["inputEl"];
|
|
12
|
+
const _forTrack0 = ($index, $item) => $item.id;
|
|
13
|
+
function SearchAutocomplete_Conditional_4_For_2_Conditional_2_Template(rf, ctx) { if (rf & 1) {
|
|
14
|
+
i0.ɵɵelementContainer(0, 6);
|
|
15
|
+
} if (rf & 2) {
|
|
16
|
+
const suggestion_r4 = i0.ɵɵnextContext().$implicit;
|
|
17
|
+
const ctx_r2 = i0.ɵɵnextContext(2);
|
|
18
|
+
i0.ɵɵproperty("ngTemplateOutlet", ctx_r2.asTemplate(suggestion_r4.label));
|
|
19
|
+
} }
|
|
20
|
+
function SearchAutocomplete_Conditional_4_For_2_Conditional_3_Template(rf, ctx) { if (rf & 1) {
|
|
21
|
+
i0.ɵɵtext(0);
|
|
22
|
+
} if (rf & 2) {
|
|
23
|
+
const suggestion_r4 = i0.ɵɵnextContext().$implicit;
|
|
24
|
+
const ctx_r2 = i0.ɵɵnextContext(2);
|
|
25
|
+
i0.ɵɵtextInterpolate(ctx_r2.textOf(suggestion_r4.label));
|
|
26
|
+
} }
|
|
27
|
+
function SearchAutocomplete_Conditional_4_For_2_Conditional_4_Conditional_1_Template(rf, ctx) { if (rf & 1) {
|
|
28
|
+
i0.ɵɵelementContainer(0, 6);
|
|
29
|
+
} if (rf & 2) {
|
|
30
|
+
const suggestion_r4 = i0.ɵɵnextContext(2).$implicit;
|
|
31
|
+
const ctx_r2 = i0.ɵɵnextContext(2);
|
|
32
|
+
i0.ɵɵproperty("ngTemplateOutlet", ctx_r2.asTemplate(suggestion_r4.meta));
|
|
33
|
+
} }
|
|
34
|
+
function SearchAutocomplete_Conditional_4_For_2_Conditional_4_Conditional_2_Template(rf, ctx) { if (rf & 1) {
|
|
35
|
+
i0.ɵɵtext(0);
|
|
36
|
+
} if (rf & 2) {
|
|
37
|
+
const suggestion_r4 = i0.ɵɵnextContext(2).$implicit;
|
|
38
|
+
const ctx_r2 = i0.ɵɵnextContext(2);
|
|
39
|
+
i0.ɵɵtextInterpolate(ctx_r2.textOf(suggestion_r4.meta));
|
|
40
|
+
} }
|
|
41
|
+
function SearchAutocomplete_Conditional_4_For_2_Conditional_4_Template(rf, ctx) { if (rf & 1) {
|
|
42
|
+
i0.ɵɵelementStart(0, "div");
|
|
43
|
+
i0.ɵɵconditionalCreate(1, SearchAutocomplete_Conditional_4_For_2_Conditional_4_Conditional_1_Template, 1, 1, "ng-container", 6)(2, SearchAutocomplete_Conditional_4_For_2_Conditional_4_Conditional_2_Template, 1, 1);
|
|
44
|
+
i0.ɵɵelementEnd();
|
|
45
|
+
} if (rf & 2) {
|
|
46
|
+
const suggestion_r4 = i0.ɵɵnextContext().$implicit;
|
|
47
|
+
const ctx_r2 = i0.ɵɵnextContext(2);
|
|
48
|
+
i0.ɵɵclassMap(ctx_r2.metaClasses());
|
|
49
|
+
i0.ɵɵadvance();
|
|
50
|
+
i0.ɵɵconditional(ctx_r2.isTemplate(suggestion_r4.meta) ? 1 : 2);
|
|
51
|
+
} }
|
|
52
|
+
function SearchAutocomplete_Conditional_4_For_2_Template(rf, ctx) { if (rf & 1) {
|
|
53
|
+
const _r1 = i0.ɵɵgetCurrentView();
|
|
54
|
+
i0.ɵɵelementStart(0, "li", 5);
|
|
55
|
+
i0.ɵɵlistener("mouseenter", function SearchAutocomplete_Conditional_4_For_2_Template_li_mouseenter_0_listener() { const $index_r2 = i0.ɵɵrestoreView(_r1).$index; const ctx_r2 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r2.onOptionEnter($index_r2)); })("mousedown", function SearchAutocomplete_Conditional_4_For_2_Template_li_mousedown_0_listener($event) { const suggestion_r4 = i0.ɵɵrestoreView(_r1).$implicit; const ctx_r2 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r2.onOptionDown($event, suggestion_r4)); });
|
|
56
|
+
i0.ɵɵelementStart(1, "div");
|
|
57
|
+
i0.ɵɵconditionalCreate(2, SearchAutocomplete_Conditional_4_For_2_Conditional_2_Template, 1, 1, "ng-container", 6)(3, SearchAutocomplete_Conditional_4_For_2_Conditional_3_Template, 1, 1);
|
|
58
|
+
i0.ɵɵelementEnd();
|
|
59
|
+
i0.ɵɵconditionalCreate(4, SearchAutocomplete_Conditional_4_For_2_Conditional_4_Template, 3, 3, "div", 7);
|
|
60
|
+
i0.ɵɵelementEnd();
|
|
61
|
+
} if (rf & 2) {
|
|
62
|
+
const suggestion_r4 = ctx.$implicit;
|
|
63
|
+
const $index_r2 = ctx.$index;
|
|
64
|
+
const ctx_r2 = i0.ɵɵnextContext(2);
|
|
65
|
+
i0.ɵɵclassMap(ctx_r2.optionClasses($index_r2));
|
|
66
|
+
i0.ɵɵattribute("id", ctx_r2.optionId($index_r2))("aria-selected", $index_r2 === ctx_r2.active() ? "true" : "false");
|
|
67
|
+
i0.ɵɵadvance();
|
|
68
|
+
i0.ɵɵclassMap(ctx_r2.labelClasses());
|
|
69
|
+
i0.ɵɵadvance();
|
|
70
|
+
i0.ɵɵconditional(ctx_r2.isTemplate(suggestion_r4.label) ? 2 : 3);
|
|
71
|
+
i0.ɵɵadvance(2);
|
|
72
|
+
i0.ɵɵconditional(suggestion_r4.meta ? 4 : -1);
|
|
73
|
+
} }
|
|
74
|
+
function SearchAutocomplete_Conditional_4_Template(rf, ctx) { if (rf & 1) {
|
|
75
|
+
i0.ɵɵelementStart(0, "ul", 3);
|
|
76
|
+
i0.ɵɵrepeaterCreate(1, SearchAutocomplete_Conditional_4_For_2_Template, 5, 8, "li", 4, _forTrack0);
|
|
77
|
+
i0.ɵɵelementEnd();
|
|
78
|
+
} if (rf & 2) {
|
|
79
|
+
const ctx_r2 = i0.ɵɵnextContext();
|
|
80
|
+
i0.ɵɵclassMap(ctx_r2.listClasses());
|
|
81
|
+
i0.ɵɵattribute("id", ctx_r2.listId)("style", ctx_r2.listStyle, i0.ɵɵsanitizeStyle);
|
|
82
|
+
i0.ɵɵadvance();
|
|
83
|
+
i0.ɵɵrepeater(ctx_r2.list());
|
|
84
|
+
} }
|
|
85
|
+
/** Counter backing the per-instance ids (React's `useId()`). */
|
|
86
|
+
let nextGeneratedId = 0;
|
|
87
|
+
/**
|
|
88
|
+
* Whether a node-valued suggestion field is a template (a `TemplateRef`)
|
|
89
|
+
* rather than plain text. Checked structurally — `TemplateRef` is a type-only
|
|
90
|
+
* import in the emitted metadata, so `instanceof` is not dependable across
|
|
91
|
+
* bundles.
|
|
92
|
+
*
|
|
93
|
+
* @param value - The field value.
|
|
94
|
+
* @returns True when it renders through `ngTemplateOutlet`.
|
|
95
|
+
*/
|
|
96
|
+
const isTemplate = (value) => typeof value === 'object' &&
|
|
97
|
+
value !== null &&
|
|
98
|
+
typeof value.createEmbeddedView === 'function';
|
|
99
|
+
/**
|
|
100
|
+
* Renders a text value the way React renders a node string.
|
|
101
|
+
*
|
|
102
|
+
* @param value - The field value.
|
|
103
|
+
* @returns The text, or `''` when there is nothing.
|
|
104
|
+
*/
|
|
105
|
+
const textOf = (value) => value === null || value === undefined ? '' : String(value);
|
|
106
|
+
/**
|
|
107
|
+
* The popover's inline style, exactly the declaration text React serializes
|
|
108
|
+
* for the same style object.
|
|
109
|
+
*/
|
|
110
|
+
const LIST_STYLE = 'position: absolute; top: 100%; left: 0px; right: 0px; z-index: 50; background: var(--color-surface, #fff); border: 1px solid rgba(0, 0, 0, 0.1); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); max-height: 320px; overflow-y: auto';
|
|
111
|
+
/**
|
|
112
|
+
* SearchAutocomplete component.
|
|
113
|
+
*
|
|
114
|
+
* Search input with a typeahead suggestions popover. The host IS React's root
|
|
115
|
+
* `<div>` (`div[mol-search-autocomplete]`), carrying React's class list; the
|
|
116
|
+
* input surface reproduces `@molecule/app-ui-angular`'s `Input` DOM (the
|
|
117
|
+
* wrapper, the inner row and the native `input`) so the combobox attributes
|
|
118
|
+
* land on the input itself, exactly where React spreads them.
|
|
119
|
+
*/
|
|
120
|
+
export class SearchAutocomplete {
|
|
121
|
+
/** Current input value. */
|
|
122
|
+
value = '';
|
|
123
|
+
/** Called whenever the input changes (React's `onChange`). */
|
|
124
|
+
onChange;
|
|
125
|
+
/** Async search function (React's `onSearch`). */
|
|
126
|
+
onSearch;
|
|
127
|
+
/** Caller-controlled suggestion list (React's `suggestions`). */
|
|
128
|
+
suggestions;
|
|
129
|
+
/** Called when the user picks a suggestion (React's `onSelect`). */
|
|
130
|
+
onSelect;
|
|
131
|
+
/** Placeholder (falls back to the translated `search.placeholder`). */
|
|
132
|
+
placeholder;
|
|
133
|
+
/**
|
|
134
|
+
* Accessible name for the input (React's `aria-label`); falls back to the
|
|
135
|
+
* translated `search.aria.label`.
|
|
136
|
+
*/
|
|
137
|
+
ariaLabel;
|
|
138
|
+
/** Debounce ms for `onSearch` (React's default 200). */
|
|
139
|
+
debounceMs;
|
|
140
|
+
/** Min chars before suggestions appear (React's default 1). */
|
|
141
|
+
minChars;
|
|
142
|
+
/** Extra classes on the wrapper. */
|
|
143
|
+
className;
|
|
144
|
+
/** The native input (React's controlled-value restore targets it). */
|
|
145
|
+
inputEl;
|
|
146
|
+
/**
|
|
147
|
+
* Reactive translation, read in the injection context. Its `t` reads the
|
|
148
|
+
* locale, so the view re-renders the text on a locale switch.
|
|
149
|
+
*/
|
|
150
|
+
i18n = useTranslation();
|
|
151
|
+
cdr = inject(ChangeDetectorRef);
|
|
152
|
+
host = inject((ElementRef));
|
|
153
|
+
/** The fetched suggestion rows (React's `useState<SuggestionItem[]>([])`). */
|
|
154
|
+
internal = signal([], /* @ts-ignore */
|
|
155
|
+
...(ngDevMode ? [{ debugName: "internal" }] : /* istanbul ignore next */ []));
|
|
156
|
+
/** Whether the popover was opened (React's `open` state). */
|
|
157
|
+
open = signal(false, /* @ts-ignore */
|
|
158
|
+
...(ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []));
|
|
159
|
+
/** Index of the keyboard-highlighted option (-1 = none). */
|
|
160
|
+
activeIndex = signal(-1, /* @ts-ignore */
|
|
161
|
+
...(ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []));
|
|
162
|
+
/** Monotonic id of the latest in-flight `onSearch` (the race guard). */
|
|
163
|
+
request = 0;
|
|
164
|
+
/** The pending debounce timer. */
|
|
165
|
+
timer;
|
|
166
|
+
/** The per-instance id base (React's `useId()`). */
|
|
167
|
+
baseId = `mol-search-autocomplete-${nextGeneratedId++}`;
|
|
168
|
+
/** The listbox id (React's `${baseId}-listbox`). */
|
|
169
|
+
listId = `${this.baseId}-listbox`;
|
|
170
|
+
/** The popover's inline style (React's style object serialized). */
|
|
171
|
+
listStyle = LIST_STYLE;
|
|
172
|
+
/**
|
|
173
|
+
* Starts the outside-mousedown listener and the initial search.
|
|
174
|
+
*/
|
|
175
|
+
ngOnInit() {
|
|
176
|
+
document.addEventListener('mousedown', this.onDoc);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* React's effects on `value`, `onSearch`, `debounceMs` and `minChars`: a
|
|
180
|
+
* change restarts the debounced search, and a new query resets the highlight.
|
|
181
|
+
*
|
|
182
|
+
* @param changes - The inputs that changed in this pass.
|
|
183
|
+
*/
|
|
184
|
+
ngOnChanges(changes) {
|
|
185
|
+
if ('value' in changes)
|
|
186
|
+
this.activeIndex.set(-1);
|
|
187
|
+
if ('value' in changes ||
|
|
188
|
+
'onSearch' in changes ||
|
|
189
|
+
'debounceMs' in changes ||
|
|
190
|
+
'minChars' in changes)
|
|
191
|
+
this.scheduleSearch();
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Removes the document listener and the pending debounce timer.
|
|
195
|
+
*/
|
|
196
|
+
ngOnDestroy() {
|
|
197
|
+
document.removeEventListener('mousedown', this.onDoc);
|
|
198
|
+
clearTimeout(this.timer);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* The current class map.
|
|
202
|
+
* @returns The UIClassMap.
|
|
203
|
+
*/
|
|
204
|
+
cm() {
|
|
205
|
+
return getClassMap();
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* The wrapper's class list (React's `cn(position('relative'), className)`).
|
|
209
|
+
* @returns The class string.
|
|
210
|
+
*/
|
|
211
|
+
classes() {
|
|
212
|
+
return this.cm().cn(this.cm().position('relative'), this.className);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* The native input's class list (React's Input root classes).
|
|
216
|
+
* @returns The class string.
|
|
217
|
+
*/
|
|
218
|
+
inputClasses() {
|
|
219
|
+
return this.cm().input({ error: false, size: 'md', align: undefined });
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* The listbox's class list.
|
|
223
|
+
* @returns The class string.
|
|
224
|
+
*/
|
|
225
|
+
listClasses() {
|
|
226
|
+
return this.cm().cn(this.cm().stack(0), this.cm().sp('p', 1));
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* A row's label class (React's `fontWeight('medium')`).
|
|
230
|
+
* @returns The class string.
|
|
231
|
+
*/
|
|
232
|
+
labelClasses() {
|
|
233
|
+
return this.cm().fontWeight('medium');
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* A row's secondary line class (React's `textSize('xs')`).
|
|
237
|
+
* @returns The class string.
|
|
238
|
+
*/
|
|
239
|
+
metaClasses() {
|
|
240
|
+
return this.cm().textSize('xs');
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* One option row's class list, exactly as React composes it.
|
|
244
|
+
* @param index - The row's position.
|
|
245
|
+
* @returns The class string.
|
|
246
|
+
*/
|
|
247
|
+
optionClasses(index) {
|
|
248
|
+
return this.cm().cn(this.cm().sp('px', 2), this.cm().sp('py', 2), this.cm().textSize('sm'), this.cm().cursorPointer, index === this.active() && this.cm().surfaceSecondary);
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* The native input's id (React's generated input id).
|
|
252
|
+
* @returns The id.
|
|
253
|
+
*/
|
|
254
|
+
get inputId() {
|
|
255
|
+
return `${this.baseId}-input`;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Stable DOM id for the option at `index` (referenced by aria-activedescendant).
|
|
259
|
+
* @param index - Option position.
|
|
260
|
+
* @returns The option id.
|
|
261
|
+
*/
|
|
262
|
+
optionId(index) {
|
|
263
|
+
return `${this.baseId}-option-${index}`;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* The placeholder React renders: the prop, else the translated default.
|
|
267
|
+
* @returns The placeholder text.
|
|
268
|
+
*/
|
|
269
|
+
placeholderText() {
|
|
270
|
+
return this.placeholder ?? this.i18n.t('search.placeholder', {}, { defaultValue: 'Search…' });
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* The input's accessible name: the prop, else the translated default. A
|
|
274
|
+
* placeholder is not a label, so the name never rests on it.
|
|
275
|
+
* @returns The `aria-label` text.
|
|
276
|
+
*/
|
|
277
|
+
ariaLabelText() {
|
|
278
|
+
return this.ariaLabel ?? this.i18n.t('search.aria.label', undefined, { defaultValue: 'Search' });
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* The suggestion list: the caller's controlled list wins over fetched results.
|
|
282
|
+
* @returns The rows to render.
|
|
283
|
+
*/
|
|
284
|
+
list() {
|
|
285
|
+
return this.suggestions ?? this.internal();
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* The popover is only visible with open + at least one suggestion.
|
|
289
|
+
* @returns Whether the listbox renders.
|
|
290
|
+
*/
|
|
291
|
+
isExpanded() {
|
|
292
|
+
return this.open() && this.list().length > 0;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* The highlight clamped to the current list: a list that shrinks below the
|
|
296
|
+
* highlighted index leaves the old option id pointing at nothing, so every
|
|
297
|
+
* read of the index (activedescendant, the highlighted option, Enter) sees
|
|
298
|
+
* -1 — nothing highlighted — instead of naming an option that is gone.
|
|
299
|
+
*
|
|
300
|
+
* @returns The active index, or -1 when nothing is highlighted.
|
|
301
|
+
*/
|
|
302
|
+
active() {
|
|
303
|
+
const index = this.activeIndex();
|
|
304
|
+
return index < this.list().length ? index : -1;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* The highlighted option's id, or null when nothing is highlighted.
|
|
308
|
+
* @returns The id, or null.
|
|
309
|
+
*/
|
|
310
|
+
activeDescendant() {
|
|
311
|
+
return this.isExpanded() && this.active() >= 0 ? this.optionId(this.active()) : null;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Whether a node value is a template rather than text.
|
|
315
|
+
* @param value - The field value.
|
|
316
|
+
* @returns True when it renders through `ngTemplateOutlet`.
|
|
317
|
+
*/
|
|
318
|
+
isTemplate(value) {
|
|
319
|
+
return isTemplate(value);
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Narrows a node value to its template form.
|
|
323
|
+
* @param value - The field value.
|
|
324
|
+
* @returns The template.
|
|
325
|
+
*/
|
|
326
|
+
asTemplate(value) {
|
|
327
|
+
return value;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* A node value as text (React renders strings and numbers).
|
|
331
|
+
* @param value - The field value.
|
|
332
|
+
* @returns The text, or `''`.
|
|
333
|
+
*/
|
|
334
|
+
textOf(value) {
|
|
335
|
+
return textOf(value);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* React's `debounceMs = 200` default.
|
|
339
|
+
* @returns The debounce delay in ms.
|
|
340
|
+
*/
|
|
341
|
+
debounce() {
|
|
342
|
+
return this.debounceMs ?? 200;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* React's `minChars = 1` default.
|
|
346
|
+
* @returns The minimum query length.
|
|
347
|
+
*/
|
|
348
|
+
threshold() {
|
|
349
|
+
return this.minChars ?? 1;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Runs React's debounced `onSearch` effect: a query shorter than `minChars`
|
|
353
|
+
* clears the results, and only the latest response may apply.
|
|
354
|
+
*/
|
|
355
|
+
scheduleSearch() {
|
|
356
|
+
clearTimeout(this.timer);
|
|
357
|
+
const search = this.onSearch;
|
|
358
|
+
const query = this.value;
|
|
359
|
+
if (!search || query.length < this.threshold()) {
|
|
360
|
+
this.internal.set([]);
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
this.timer = setTimeout(() => {
|
|
364
|
+
const token = ++this.request;
|
|
365
|
+
Promise.resolve(search(query))
|
|
366
|
+
.then((result) => {
|
|
367
|
+
// Drop a response that lost the race: only the LATEST request may
|
|
368
|
+
// apply, so a slow earlier fetch can't clobber fresher results.
|
|
369
|
+
if (token === this.request)
|
|
370
|
+
this.internal.set(result);
|
|
371
|
+
this.cdr.markForCheck();
|
|
372
|
+
})
|
|
373
|
+
.catch((_error) => {
|
|
374
|
+
// Typeahead is best-effort — a failed suggestion fetch simply yields
|
|
375
|
+
// no suggestions for THIS query. Guard on the token so an
|
|
376
|
+
// out-of-order failure can't wipe a fresher successful result.
|
|
377
|
+
if (token === this.request)
|
|
378
|
+
this.internal.set([]);
|
|
379
|
+
this.cdr.markForCheck();
|
|
380
|
+
});
|
|
381
|
+
}, this.debounce());
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* React's text-input `onChange`: report the typed value, open the popover and
|
|
385
|
+
* restore the controlled value.
|
|
386
|
+
*
|
|
387
|
+
* @param event - The native input event.
|
|
388
|
+
*/
|
|
389
|
+
handleInput(event) {
|
|
390
|
+
this.onChange?.(event.target.value);
|
|
391
|
+
this.open.set(true);
|
|
392
|
+
const input = this.inputEl?.nativeElement;
|
|
393
|
+
if (input && input.value !== String(this.value))
|
|
394
|
+
input.value = String(this.value);
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* React's `onFocus`: a query at least `minChars` long opens the popover.
|
|
398
|
+
*/
|
|
399
|
+
handleFocus() {
|
|
400
|
+
if (this.value.length >= this.threshold())
|
|
401
|
+
this.open.set(true);
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Full keyboard support for the combobox: ArrowDown/ArrowUp move the
|
|
405
|
+
* highlight (opening the popover if needed), Enter selects the highlighted
|
|
406
|
+
* option, Escape closes.
|
|
407
|
+
*
|
|
408
|
+
* @param event - The keyboard event from the input.
|
|
409
|
+
*/
|
|
410
|
+
handleKeydown(event) {
|
|
411
|
+
const current = this.list();
|
|
412
|
+
if (event.key === 'ArrowDown') {
|
|
413
|
+
event.preventDefault();
|
|
414
|
+
if (!this.open()) {
|
|
415
|
+
if (current.length > 0)
|
|
416
|
+
this.open.set(true);
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
if (current.length === 0)
|
|
420
|
+
return;
|
|
421
|
+
this.activeIndex.update((index) => (index + 1) % current.length);
|
|
422
|
+
}
|
|
423
|
+
else if (event.key === 'ArrowUp') {
|
|
424
|
+
event.preventDefault();
|
|
425
|
+
if (!this.open()) {
|
|
426
|
+
if (current.length > 0)
|
|
427
|
+
this.open.set(true);
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
if (current.length === 0)
|
|
431
|
+
return;
|
|
432
|
+
this.activeIndex.update((index) => (index <= 0 ? current.length - 1 : index - 1));
|
|
433
|
+
}
|
|
434
|
+
else if (event.key === 'Enter') {
|
|
435
|
+
const index = this.active();
|
|
436
|
+
if (this.isExpanded() && index >= 0) {
|
|
437
|
+
event.preventDefault();
|
|
438
|
+
this.select(current[index]);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
else if (event.key === 'Escape') {
|
|
442
|
+
if (this.open()) {
|
|
443
|
+
event.preventDefault();
|
|
444
|
+
this.open.set(false);
|
|
445
|
+
this.activeIndex.set(-1);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Highlights a row on pointer hover.
|
|
451
|
+
* @param index - The row's position.
|
|
452
|
+
*/
|
|
453
|
+
onOptionEnter(index) {
|
|
454
|
+
this.activeIndex.set(index);
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Selects a row on press: preventDefault keeps DOM focus on the input, which
|
|
458
|
+
* owns the combobox.
|
|
459
|
+
*
|
|
460
|
+
* @param event - The mousedown event.
|
|
461
|
+
* @param suggestion - The pressed suggestion.
|
|
462
|
+
*/
|
|
463
|
+
onOptionDown(event, suggestion) {
|
|
464
|
+
event.preventDefault();
|
|
465
|
+
this.select(suggestion);
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Commits a suggestion selection and closes the popover.
|
|
469
|
+
* @param item - The chosen suggestion.
|
|
470
|
+
*/
|
|
471
|
+
select(item) {
|
|
472
|
+
this.onSelect?.(item);
|
|
473
|
+
this.open.set(false);
|
|
474
|
+
this.activeIndex.set(-1);
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Closes the dropdown when a click occurs outside the wrapper element.
|
|
478
|
+
* @param event - The document mousedown.
|
|
479
|
+
*/
|
|
480
|
+
onDoc = (event) => {
|
|
481
|
+
if (!this.open())
|
|
482
|
+
return;
|
|
483
|
+
if (this.host.nativeElement.contains(event.target))
|
|
484
|
+
return;
|
|
485
|
+
this.open.set(false);
|
|
486
|
+
this.activeIndex.set(-1);
|
|
487
|
+
this.cdr.markForCheck();
|
|
488
|
+
};
|
|
489
|
+
static ɵfac = function SearchAutocomplete_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || SearchAutocomplete)(); };
|
|
490
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SearchAutocomplete, selectors: [["div", "mol-search-autocomplete", ""]], viewQuery: function SearchAutocomplete_Query(rf, ctx) { if (rf & 1) {
|
|
491
|
+
i0.ɵɵviewQuery(_c0, 5);
|
|
492
|
+
} if (rf & 2) {
|
|
493
|
+
let _t;
|
|
494
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.inputEl = _t.first);
|
|
495
|
+
} }, hostVars: 2, hostBindings: function SearchAutocomplete_HostBindings(rf, ctx) { if (rf & 2) {
|
|
496
|
+
i0.ɵɵclassMap(ctx.classes());
|
|
497
|
+
} }, inputs: { value: "value", onChange: "onChange", onSearch: "onSearch", suggestions: "suggestions", onSelect: "onSelect", placeholder: "placeholder", ariaLabel: "ariaLabel", debounceMs: "debounceMs", minChars: "minChars", className: "className" }, features: [i0.ɵɵNgOnChangesFeature], decls: 5, vars: 14, consts: [["inputEl", ""], ["type", "search", "aria-invalid", "false", "role", "combobox", "aria-autocomplete", "list", 3, "input", "focusin", "keydown"], ["role", "listbox", 3, "class"], ["role", "listbox"], ["role", "option", "tabindex", "-1", "data-mol-id", "search-autocomplete-option", 3, "class"], ["role", "option", "tabindex", "-1", "data-mol-id", "search-autocomplete-option", 3, "mouseenter", "mousedown"], [3, "ngTemplateOutlet"], [3, "class"]], template: function SearchAutocomplete_Template(rf, ctx) { if (rf & 1) {
|
|
498
|
+
i0.ɵɵelementStart(0, "div")(1, "div")(2, "input", 1, 0);
|
|
499
|
+
i0.ɵɵlistener("input", function SearchAutocomplete_Template_input_input_2_listener($event) { return ctx.handleInput($event); })("focusin", function SearchAutocomplete_Template_input_focusin_2_listener() { return ctx.handleFocus(); })("keydown", function SearchAutocomplete_Template_input_keydown_2_listener($event) { return ctx.handleKeydown($event); });
|
|
500
|
+
i0.ɵɵelementEnd()()();
|
|
501
|
+
i0.ɵɵconditionalCreate(4, SearchAutocomplete_Conditional_4_Template, 3, 4, "ul", 2);
|
|
502
|
+
} if (rf & 2) {
|
|
503
|
+
i0.ɵɵclassMap(ctx.cm().inputWrapper);
|
|
504
|
+
i0.ɵɵadvance();
|
|
505
|
+
i0.ɵɵclassMap(ctx.cm().inputInner);
|
|
506
|
+
i0.ɵɵadvance();
|
|
507
|
+
i0.ɵɵclassMap(ctx.inputClasses());
|
|
508
|
+
i0.ɵɵattribute("id", ctx.inputId)("value", ctx.value)("placeholder", ctx.placeholderText())("aria-label", ctx.ariaLabelText())("aria-expanded", ctx.isExpanded() ? "true" : "false")("aria-controls", ctx.listId)("aria-activedescendant", ctx.activeDescendant());
|
|
509
|
+
i0.ɵɵadvance(2);
|
|
510
|
+
i0.ɵɵconditional(ctx.isExpanded() ? 4 : -1);
|
|
511
|
+
} }, dependencies: [NgTemplateOutlet], encapsulation: 2 });
|
|
512
|
+
}
|
|
513
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SearchAutocomplete, [{
|
|
514
|
+
type: Component,
|
|
515
|
+
args: [{
|
|
516
|
+
selector: 'div[mol-search-autocomplete]',
|
|
517
|
+
standalone: true,
|
|
518
|
+
imports: [NgTemplateOutlet],
|
|
519
|
+
inputs: [
|
|
520
|
+
'value',
|
|
521
|
+
'onChange',
|
|
522
|
+
'onSearch',
|
|
523
|
+
'suggestions',
|
|
524
|
+
'onSelect',
|
|
525
|
+
'placeholder',
|
|
526
|
+
'ariaLabel',
|
|
527
|
+
'debounceMs',
|
|
528
|
+
'minChars',
|
|
529
|
+
'className',
|
|
530
|
+
],
|
|
531
|
+
host: {
|
|
532
|
+
'[class]': 'classes()',
|
|
533
|
+
},
|
|
534
|
+
// prettier-ignore
|
|
535
|
+
template: `<div [class]="cm().inputWrapper"><div [class]="cm().inputInner"><input #inputEl type="search" [attr.id]="inputId" [attr.value]="value" [attr.placeholder]="placeholderText()" aria-invalid="false" [class]="inputClasses()" role="combobox" [attr.aria-label]="ariaLabelText()" aria-autocomplete="list" [attr.aria-expanded]="isExpanded() ? 'true' : 'false'" [attr.aria-controls]="listId" [attr.aria-activedescendant]="activeDescendant()" (input)="handleInput($event)" (focusin)="handleFocus()" (keydown)="handleKeydown($event)" /></div></div>@if (isExpanded()) {<ul role="listbox" [attr.id]="listId" [class]="listClasses()" [attr.style]="listStyle">@for (suggestion of list(); track suggestion.id) {<li [attr.id]="optionId($index)" role="option" [attr.aria-selected]="$index === active() ? 'true' : 'false'" tabindex="-1" data-mol-id="search-autocomplete-option" (mouseenter)="onOptionEnter($index)" (mousedown)="onOptionDown($event, suggestion)" [class]="optionClasses($index)"><div [class]="labelClasses()">@if (isTemplate(suggestion.label)) {<ng-container [ngTemplateOutlet]="asTemplate(suggestion.label)"></ng-container>}@else {{{ textOf(suggestion.label) }}}</div>@if (suggestion.meta) {<div [class]="metaClasses()">@if (isTemplate(suggestion.meta)) {<ng-container [ngTemplateOutlet]="asTemplate(suggestion.meta)"></ng-container>}@else {{{ textOf(suggestion.meta) }}}</div>}</li>}</ul>}`,
|
|
536
|
+
}]
|
|
537
|
+
}], null, { inputEl: [{
|
|
538
|
+
type: ViewChild,
|
|
539
|
+
args: ['inputEl']
|
|
540
|
+
}] }); })();
|
|
541
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(SearchAutocomplete, { className: "SearchAutocomplete", filePath: "search-autocomplete.component.ts", lineNumber: 92 }); })();
|
|
542
|
+
//# sourceMappingURL=search-autocomplete.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-autocomplete.component.js","sourceRoot":"","sources":["../src/search-autocomplete.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,UAAU,EACV,MAAM,E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
* counterpart of `@molecule/app-search-autocomplete-react`, the same props
|
|
4
|
+
* (React names) and the same DOM for the same input.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import type { TemplateRef } from '@angular/core';
|
|
9
|
+
/**
|
|
10
|
+
* A single suggestion entry returned by `onSearch` or passed via `suggestions`.
|
|
11
|
+
*/
|
|
12
|
+
export interface SuggestionItem<T = unknown> {
|
|
13
|
+
id: string;
|
|
14
|
+
/** Display label: text, or a template rendering any node (`TemplateRef`). */
|
|
15
|
+
label: string | TemplateRef<unknown>;
|
|
16
|
+
/** Optional secondary line / category: text, or a template rendering any node. */
|
|
17
|
+
meta?: string | TemplateRef<unknown>;
|
|
18
|
+
/** Original payload for the selection callback. */
|
|
19
|
+
data?: T;
|
|
20
|
+
}
|
|
21
|
+
/** Props accepted by the {@link SearchAutocomplete} component. */
|
|
22
|
+
export interface SearchAutocompleteProps<T = unknown> {
|
|
23
|
+
/** Current input value. */
|
|
24
|
+
value: string;
|
|
25
|
+
/** Called whenever the input changes (an input: pass a function, as React does). */
|
|
26
|
+
onChange: (value: string) => void;
|
|
27
|
+
/** Async search function — receives the query, returns suggestions. */
|
|
28
|
+
onSearch?: (query: string) => Promise<SuggestionItem<T>[]> | SuggestionItem<T>[];
|
|
29
|
+
/** Optional pre-computed suggestion list (when caller controls fetching). */
|
|
30
|
+
suggestions?: SuggestionItem<T>[];
|
|
31
|
+
/** Called when the user picks a suggestion. */
|
|
32
|
+
onSelect: (item: SuggestionItem<T>) => void;
|
|
33
|
+
/** Placeholder. */
|
|
34
|
+
placeholder?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Accessible name for the input, rendered as `aria-label`. Defaults to the
|
|
37
|
+
* translated `search.aria.label`: a placeholder is not a label, so an input
|
|
38
|
+
* named only by its placeholder (let alone an empty one) is nameless for
|
|
39
|
+
* assistive technology.
|
|
40
|
+
*/
|
|
41
|
+
ariaLabel?: string;
|
|
42
|
+
/** Debounce ms for `onSearch`. Defaults to 200. */
|
|
43
|
+
debounceMs?: number;
|
|
44
|
+
/** Min chars before suggestions appear. Defaults to 1. */
|
|
45
|
+
minChars?: number;
|
|
46
|
+
/** Extra classes on the wrapper. */
|
|
47
|
+
className?: string;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,OAAO;IACzC,EAAE,EAAE,MAAM,CAAA;IACV,6EAA6E;IAC7E,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,CAAA;IACpC,kFAAkF;IAClF,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,CAAA;IACpC,mDAAmD;IACnD,IAAI,CAAC,EAAE,CAAC,CAAA;CACT;AAED,kEAAkE;AAClE,MAAM,WAAW,uBAAuB,CAAC,CAAC,GAAG,OAAO;IAClD,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,oFAAoF;IACpF,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,uEAAuE;IACvE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,CAAA;IAChF,6EAA6E;IAC7E,WAAW,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,CAAA;IACjC,+CAA+C;IAC/C,QAAQ,EAAE,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;IAC3C,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,mDAAmD;IACnD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types of `@molecule/app-search-autocomplete-angular` — the Angular
|
|
3
|
+
* counterpart of `@molecule/app-search-autocomplete-react`, the same props
|
|
4
|
+
* (React names) and the same DOM for the same input.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,71 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-search-autocomplete-angular",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1-stage",
|
|
4
|
+
"description": "Search input with typeahead suggestion popover",
|
|
5
|
+
"homepage": "https://www.molecule.dev/packages/app-search-autocomplete-angular",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "ngc",
|
|
21
|
+
"dev": "ngc --watch",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"test:watch": "vitest"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"molecule",
|
|
27
|
+
"search-autocomplete",
|
|
28
|
+
"angular"
|
|
29
|
+
],
|
|
30
|
+
"author": "Molecule Dev, Inc. (https://molecule.dev)",
|
|
31
|
+
"license": "Apache-2.0",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/molecule-dev/molecule.git",
|
|
35
|
+
"directory": "packages/app/features/search-autocomplete-angular"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=20"
|
|
39
|
+
},
|
|
40
|
+
"bugs": "https://github.com/molecule-dev/molecule/issues",
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@angular/common": "^22.0.0",
|
|
46
|
+
"@angular/core": "^22.0.0",
|
|
47
|
+
"@angular/platform-browser": "^22.0.0",
|
|
48
|
+
"@molecule/app-angular": "^3.5.0",
|
|
49
|
+
"@molecule/app-ui": "^1.0.1",
|
|
50
|
+
"@molecule/app-ui-angular": "^1.1.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@angular/common": "22.2.3",
|
|
54
|
+
"@angular/compiler": "22.2.3",
|
|
55
|
+
"@angular/compiler-cli": "22.2.3",
|
|
56
|
+
"@angular/core": "22.2.3",
|
|
57
|
+
"@angular/platform-browser": "22.2.3",
|
|
58
|
+
"@molecule/app-angular": "3.7.2",
|
|
59
|
+
"@molecule/app-framework-conformance": "0.0.0",
|
|
60
|
+
"@molecule/app-i18n": "1.2.2",
|
|
61
|
+
"@molecule/app-icons": "1.0.4",
|
|
62
|
+
"@molecule/app-ui": "1.4.0",
|
|
63
|
+
"@molecule/app-ui-angular": "1.2.1",
|
|
64
|
+
"@types/node": "26.6.5",
|
|
65
|
+
"jsdom": "30.1.3",
|
|
66
|
+
"rxjs": "7.8.2",
|
|
67
|
+
"typescript": "6.0.3",
|
|
68
|
+
"vitest": "4.1.12",
|
|
69
|
+
"zone.js": "0.16.3"
|
|
70
|
+
}
|
|
71
|
+
}
|