@molecule/app-search-ui-solid 0.0.0-stage → 0.0.1-stage
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +10 -2
- package/dist/Highlight.d.ts +17 -0
- package/dist/Highlight.d.ts.map +1 -0
- package/dist/Highlight.jsx +22 -0
- package/dist/Highlight.jsx.map +1 -0
- package/dist/Kbd.d.ts +17 -0
- package/dist/Kbd.d.ts.map +1 -0
- package/dist/Kbd.jsx +21 -0
- package/dist/Kbd.jsx.map +1 -0
- package/dist/QuickSearchDialog.d.ts +22 -0
- package/dist/QuickSearchDialog.d.ts.map +1 -0
- package/dist/QuickSearchDialog.jsx +68 -0
- package/dist/QuickSearchDialog.jsx.map +1 -0
- package/dist/SearchBox.d.ts +19 -0
- package/dist/SearchBox.d.ts.map +1 -0
- package/dist/SearchBox.jsx +168 -0
- package/dist/SearchBox.jsx.map +1 -0
- package/dist/SearchResults.d.ts +27 -0
- package/dist/SearchResults.d.ts.map +1 -0
- package/dist/SearchResults.jsx +177 -0
- package/dist/SearchResults.jsx.map +1 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +91 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +162 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +12 -0
- package/dist/types.js.map +1 -0
- package/package.json +70 -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-ui-solid
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Solid search UI for @molecule/app-client-search — a search box with filter chips and tips, a ranked results list with matched terms marked, and a quick-search dialog; styled through the ClassMap
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
npm install @molecule/app-search-ui-solid
|
|
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
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solid marked text — the counterpart of `@molecule/app-search-ui-react`'s
|
|
3
|
+
* `Highlight`.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import type { JSX } from 'solid-js';
|
|
8
|
+
import type { HighlightProps } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Text with the matched terms marked: each term is marked where it starts a
|
|
11
|
+
* word, case-insensitively, through the ClassMap's `resultMark`.
|
|
12
|
+
*
|
|
13
|
+
* @param props - See {@link HighlightProps}.
|
|
14
|
+
* @returns The text with `<mark>` around each match.
|
|
15
|
+
*/
|
|
16
|
+
export declare const Highlight: (props: HighlightProps) => JSX.Element;
|
|
17
|
+
//# sourceMappingURL=Highlight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Highlight.d.ts","sourceRoot":"","sources":["../src/Highlight.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAKnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,cAAc,KAAG,GAAG,CAAC,OASrD,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solid marked text — the counterpart of `@molecule/app-search-ui-react`'s
|
|
3
|
+
* `Highlight`.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { highlightMatches } from '@molecule/app-client-search';
|
|
8
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
9
|
+
/**
|
|
10
|
+
* Text with the matched terms marked: each term is marked where it starts a
|
|
11
|
+
* word, case-insensitively, through the ClassMap's `resultMark`.
|
|
12
|
+
*
|
|
13
|
+
* @param props - See {@link HighlightProps}.
|
|
14
|
+
* @returns The text with `<mark>` around each match.
|
|
15
|
+
*/
|
|
16
|
+
export const Highlight = (props) => {
|
|
17
|
+
const cm = getClassMap();
|
|
18
|
+
return (<>
|
|
19
|
+
{highlightMatches(props.text, props.terms).map((seg) => seg.hit ? <mark class={cm.resultMark}>{seg.text}</mark> : seg.text)}
|
|
20
|
+
</>);
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=Highlight.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Highlight.jsx","sourceRoot":"","sources":["../src/Highlight.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAI9C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAqB,EAAe,EAAE;IAC9D,MAAM,EAAE,GAAG,WAAW,EAAE,CAAA;IACxB,OAAO,CACL,EACE;MAAA,CAAC,gBAAgB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CACrD,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CACnE,CACH;IAAA,GAAG,CACJ,CAAA;AACH,CAAC,CAAA"}
|
package/dist/Kbd.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solid key cap — the counterpart of `@molecule/app-search-ui-react`'s `Kbd`.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type { JSX } from 'solid-js';
|
|
7
|
+
import type { KbdProps } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* A key cap, for shortcut hints (`/` to focus, `↵` to open). The cap shows a
|
|
10
|
+
* key name, not prose (a physical key such as `esc` reads the same in every
|
|
11
|
+
* language), so it carries HTML's own `translate="no"`.
|
|
12
|
+
*
|
|
13
|
+
* @param props - See {@link KbdProps}.
|
|
14
|
+
* @returns A `<kbd>` styled by the ClassMap.
|
|
15
|
+
*/
|
|
16
|
+
export declare const Kbd: (props: KbdProps) => JSX.Element;
|
|
17
|
+
//# sourceMappingURL=Kbd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Kbd.d.ts","sourceRoot":"","sources":["../src/Kbd.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAInC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG,GAAI,OAAO,QAAQ,KAAG,GAAG,CAAC,OAOzC,CAAA"}
|
package/dist/Kbd.jsx
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solid key cap — the counterpart of `@molecule/app-search-ui-react`'s `Kbd`.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
7
|
+
/**
|
|
8
|
+
* A key cap, for shortcut hints (`/` to focus, `↵` to open). The cap shows a
|
|
9
|
+
* key name, not prose (a physical key such as `esc` reads the same in every
|
|
10
|
+
* language), so it carries HTML's own `translate="no"`.
|
|
11
|
+
*
|
|
12
|
+
* @param props - See {@link KbdProps}.
|
|
13
|
+
* @returns A `<kbd>` styled by the ClassMap.
|
|
14
|
+
*/
|
|
15
|
+
export const Kbd = (props) => {
|
|
16
|
+
const cm = getClassMap();
|
|
17
|
+
return (<kbd class={cm.cn(cm.kbd, props.className)} translate="no">
|
|
18
|
+
{props.children}
|
|
19
|
+
</kbd>);
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=Kbd.jsx.map
|
package/dist/Kbd.jsx.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Kbd.jsx","sourceRoot":"","sources":["../src/Kbd.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAI9C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,KAAe,EAAe,EAAE;IAClD,MAAM,EAAE,GAAG,WAAW,EAAE,CAAA;IACxB,OAAO,CACL,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CACxD;MAAA,CAAC,KAAK,CAAC,QAAQ,CACjB;IAAA,EAAE,GAAG,CAAC,CACP,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solid quick-search dialog — the counterpart of
|
|
3
|
+
* `@molecule/app-search-ui-react`'s `QuickSearchDialog`.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { type JSX } from 'solid-js';
|
|
8
|
+
import type { ClientSearchDocument } from '@molecule/app-client-search';
|
|
9
|
+
import type { QuickSearchDialogProps } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* A search dialog for `mod+k`: the box on top with focus, the hits below in
|
|
12
|
+
* a scrolling pane, and the key hints in the footer. Before anything is
|
|
13
|
+
* typed the pane shows `idleText` rather than a browse list. Enter opens the active
|
|
14
|
+
* hit through the session (which closes the dialog by the caller's `onOpen`).
|
|
15
|
+
* The dialog is named for screen readers through `label` (or the translated
|
|
16
|
+
* "Search" default).
|
|
17
|
+
*
|
|
18
|
+
* @param props - See {@link QuickSearchDialogProps}.
|
|
19
|
+
* @returns The dialog, or nothing while closed.
|
|
20
|
+
*/
|
|
21
|
+
export declare const QuickSearchDialog: <T extends ClientSearchDocument>(props: QuickSearchDialogProps<T>) => JSX.Element;
|
|
22
|
+
//# sourceMappingURL=QuickSearchDialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QuickSearchDialog.d.ts","sourceRoot":"","sources":["../src/QuickSearchDialog.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAA+B,KAAK,GAAG,EAAQ,MAAM,UAAU,CAAA;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAQvE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAqBxD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,oBAAoB,EAC9D,OAAO,sBAAsB,CAAC,CAAC,CAAC,KAC/B,GAAG,CAAC,OA+DN,CAAA"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solid quick-search dialog — the counterpart of
|
|
3
|
+
* `@molecule/app-search-ui-react`'s `QuickSearchDialog`.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { createEffect, Show } from 'solid-js';
|
|
8
|
+
import { useTranslation } from '@molecule/app-solid';
|
|
9
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
10
|
+
import { Modal } from '@molecule/app-ui-solid';
|
|
11
|
+
import { Kbd } from './Kbd.jsx';
|
|
12
|
+
import { SearchBox } from './SearchBox.jsx';
|
|
13
|
+
import { SearchResults } from './SearchResults.jsx';
|
|
14
|
+
/**
|
|
15
|
+
* Whether a session field is an accessor (what a `useSearchSession` result
|
|
16
|
+
* holds) rather than a plain value.
|
|
17
|
+
*
|
|
18
|
+
* @param value - The session field.
|
|
19
|
+
* @returns True for an accessor.
|
|
20
|
+
*/
|
|
21
|
+
const isAccessor = (value) => typeof value === 'function';
|
|
22
|
+
/**
|
|
23
|
+
* Reads a session field, calling an accessor and passing a plain value
|
|
24
|
+
* through, so the dialog takes a session from `useSearchSession` or a plain
|
|
25
|
+
* object alike.
|
|
26
|
+
*
|
|
27
|
+
* @param value - The session field.
|
|
28
|
+
* @returns The value.
|
|
29
|
+
*/
|
|
30
|
+
const read = (value) => (isAccessor(value) ? value() : value);
|
|
31
|
+
/**
|
|
32
|
+
* A search dialog for `mod+k`: the box on top with focus, the hits below in
|
|
33
|
+
* a scrolling pane, and the key hints in the footer. Before anything is
|
|
34
|
+
* typed the pane shows `idleText` rather than a browse list. Enter opens the active
|
|
35
|
+
* hit through the session (which closes the dialog by the caller's `onOpen`).
|
|
36
|
+
* The dialog is named for screen readers through `label` (or the translated
|
|
37
|
+
* "Search" default).
|
|
38
|
+
*
|
|
39
|
+
* @param props - See {@link QuickSearchDialogProps}.
|
|
40
|
+
* @returns The dialog, or nothing while closed.
|
|
41
|
+
*/
|
|
42
|
+
export const QuickSearchDialog = (props) => {
|
|
43
|
+
const cm = getClassMap();
|
|
44
|
+
const { t } = useTranslation();
|
|
45
|
+
// React's default parameter: the ids carry the `quick-search` prefix unless overridden.
|
|
46
|
+
const molId = () => props.molId ?? 'quick-search';
|
|
47
|
+
// The dialog pattern: focus moves into the field when it opens. The input
|
|
48
|
+
// is mounted only while open, and the effect runs after the field exists.
|
|
49
|
+
createEffect(() => {
|
|
50
|
+
if (props.open)
|
|
51
|
+
props.session.inputRef.current?.focus();
|
|
52
|
+
});
|
|
53
|
+
return (<Show when={props.open}>
|
|
54
|
+
<Modal open={props.open} onClose={props.onClose} size="lg" closeOnEscape={false} showCloseButton={false} closeLabel={t('searchUi.close', undefined, { defaultValue: 'Close' })} aria-label={props.label ?? t('searchUi.dialogLabel', undefined, { defaultValue: 'Search' })} data-mol-id={molId()}>
|
|
55
|
+
<SearchBox value={read(props.session.query)} onChange={(value) => props.session.setQuery(value)} onKeyDown={(event) => props.session.onKeyDown(event)} inputRef={props.session.inputRef} placeholder={props.placeholder} count={read(props.session.active) ? read(props.session.hits).length : undefined} filters={read(props.session.parsed).filters} onRemoveFilter={(index) => props.session.removeFilter(index)} onClear={() => props.session.clear()} examples={props.examples} shortcut={null} molId={molId()}/>
|
|
56
|
+
<div class={cm.dialogBody} data-mol-id={`${molId()}-pane`}>
|
|
57
|
+
<SearchResults hits={read(props.session.active) ? read(props.session.hits) : []} view={props.view} activeIndex={read(props.session.activeIndex)} onActivate={(index) => props.session.setActiveIndex(index)} onOpen={(doc) => props.session.open(doc)} onPrefetch={(doc) => props.session.prefetch(doc)} renderLink={props.renderLink} emptyText={read(props.session.active) ? props.emptyText : (props.idleText ?? props.emptyText)} molId={molId()}/>
|
|
58
|
+
</div>
|
|
59
|
+
<p class={cm.cn(cm.dialogFooter, cm.resultMeta)} data-mol-id={`${molId()}-keys`}>
|
|
60
|
+
<Kbd>↑</Kbd> <Kbd>↓</Kbd> <Kbd>↵</Kbd> <Kbd>esc</Kbd>{' '}
|
|
61
|
+
{t('searchUi.dialogKeys', undefined, {
|
|
62
|
+
defaultValue: 'The arrow keys move through the results, Enter opens one, Escape closes.',
|
|
63
|
+
})}
|
|
64
|
+
</p>
|
|
65
|
+
</Modal>
|
|
66
|
+
</Show>);
|
|
67
|
+
};
|
|
68
|
+
//# s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B,SAAS,CAAC,CACR,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,SAAS,CACnF,CAAC,CACD,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,EAEnB;QAAA,EAAE,GAAG,CACL;QAAA,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,YAAY,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,KAAK,EAAE,OAAO,CAAC,CAC9E;UAAA,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAE,CAAA,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAE,CAAA,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAE,CAAA,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,CACzD;UAAA,CAAC,CAAC,CAAC,qBAAqB,EAAE,SAAS,EAAE;YACnC,YAAY,EACV,0EAA0E;SAC7E,CAAC,CACJ;QAAA,EAAE,CAAC,CACL;MAAA,EAAE,KAAK,CACT;IAAA,EAAE,IAAI,CAAC,CACR,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solid search field — the counterpart of `@molecule/app-search-ui-react`'s
|
|
3
|
+
* `SearchBox`.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { type JSX } from 'solid-js';
|
|
8
|
+
import type { SearchBoxProps } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* A search field: a leading icon, the input, a help icon that shows the
|
|
11
|
+
* syntax on hover, an × to clear, and the shortcut cap; under it, whatever
|
|
12
|
+
* `afterField` holds, then the active filters as removable chips and the
|
|
13
|
+
* hit count. The field stays mounted, and its text with it, across searches.
|
|
14
|
+
*
|
|
15
|
+
* @param props - See {@link SearchBoxProps}.
|
|
16
|
+
* @returns The field and its status row.
|
|
17
|
+
*/
|
|
18
|
+
export declare const SearchBox: (props: SearchBoxProps) => JSX.Element;
|
|
19
|
+
//# sourceMappingURL=SearchBox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchBox.d.ts","sourceRoot":"","sources":["../src/SearchBox.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAmC,KAAK,GAAG,EAAE,MAAM,UAAU,CAAA;AASpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAOhD;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,cAAc,KAAG,GAAG,CAAC,OA+MrD,CAAA"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solid search field — the counterpart of `@molecule/app-search-ui-react`'s
|
|
3
|
+
* `SearchBox`.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { createEffect, createSignal, For } from 'solid-js';
|
|
8
|
+
import { unwrap } from 'solid-js/store';
|
|
9
|
+
import { useTranslation } from '@molecule/app-solid';
|
|
10
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
11
|
+
import { Icon, Tooltip } from '@molecule/app-ui-solid';
|
|
12
|
+
import { Kbd } from './Kbd.jsx';
|
|
13
|
+
/**
|
|
14
|
+
* A search field: a leading icon, the input, a help icon that shows the
|
|
15
|
+
* syntax on hover, an × to clear, and the shortcut cap; under it, whatever
|
|
16
|
+
* `afterField` holds, then the active filters as removable chips and the
|
|
17
|
+
* hit count. The field stays mounted, and its text with it, across searches.
|
|
18
|
+
*
|
|
19
|
+
* @param props - See {@link SearchBoxProps}.
|
|
20
|
+
* @returns The field and its status row.
|
|
21
|
+
*/
|
|
22
|
+
export const SearchBox = (props) => {
|
|
23
|
+
const cm = getClassMap();
|
|
24
|
+
const { t } = useTranslation();
|
|
25
|
+
const [focused, setFocused] = createSignal(false);
|
|
26
|
+
// React's default parameters: the cap shows `/` unless hidden, and the ids
|
|
27
|
+
// carry the `search` prefix unless overridden.
|
|
28
|
+
const shortcut = () => (props.shortcut === undefined ? '/' : props.shortcut);
|
|
29
|
+
const molId = () => props.molId ?? 'search';
|
|
30
|
+
// Focus the input on mount and whenever the ask (or the ref) changes, the
|
|
31
|
+
// way React's effect keyed on `autoFocus` and `inputRef` does.
|
|
32
|
+
createEffect(() => {
|
|
33
|
+
if (props.autoFocus)
|
|
34
|
+
props.inputRef?.current?.focus();
|
|
35
|
+
});
|
|
36
|
+
/** The input element, held so the value sync and the clear button can reach it. */
|
|
37
|
+
let inputEl = null;
|
|
38
|
+
/**
|
|
39
|
+
* Assigns the input element into `inputRef`, as React's `ref` does, and
|
|
40
|
+
* clears it when the field unmounts. Written through the raw object, since
|
|
41
|
+
* a reactive props holder proxies the caller's ref and refuses direct
|
|
42
|
+
* mutation.
|
|
43
|
+
*
|
|
44
|
+
* @param el - The input element, or `null` as it unmounts.
|
|
45
|
+
*/
|
|
46
|
+
const inputRefFn = (el) => {
|
|
47
|
+
inputEl = el;
|
|
48
|
+
const ref = props.inputRef;
|
|
49
|
+
if (ref)
|
|
50
|
+
unwrap(ref).current = el;
|
|
51
|
+
};
|
|
52
|
+
// React keeps a controlled input's content attribute and API value in sync
|
|
53
|
+
// with the rendered value; Solid's `value` writes only the API value, so
|
|
54
|
+
// the attribute is set beside it on mount and on every change.
|
|
55
|
+
createEffect(() => {
|
|
56
|
+
const value = props.value;
|
|
57
|
+
if (inputEl) {
|
|
58
|
+
inputEl.setAttribute('value', value);
|
|
59
|
+
inputEl.value = value;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
/**
|
|
63
|
+
* Reports the typed text, then restores the field to the value the props
|
|
64
|
+
* still hold, the way React's controlled input renders it back when the
|
|
65
|
+
* caller keeps the old one.
|
|
66
|
+
*
|
|
67
|
+
* @param event - The input event.
|
|
68
|
+
*/
|
|
69
|
+
const onInput = (event) => {
|
|
70
|
+
const el = event.currentTarget;
|
|
71
|
+
props.onChange(el.value);
|
|
72
|
+
el.value = props.value;
|
|
73
|
+
el.setAttribute('value', props.value);
|
|
74
|
+
};
|
|
75
|
+
/** Clears the text and puts focus back in the field, as React's button does. */
|
|
76
|
+
const onClearClick = () => {
|
|
77
|
+
props.onClear?.();
|
|
78
|
+
props.inputRef?.current?.focus();
|
|
79
|
+
};
|
|
80
|
+
/** One stable record per chip key, so a re-passed or reordered array keeps the rendered chips per key. */
|
|
81
|
+
const chipRecords = new Map();
|
|
82
|
+
const keyedChips = () => {
|
|
83
|
+
const seen = new Set();
|
|
84
|
+
const chips = filters().map((f, i) => {
|
|
85
|
+
const key = `${f.field}:${f.values.join(',')}:${i}`;
|
|
86
|
+
seen.add(key);
|
|
87
|
+
let chip = chipRecords.get(key);
|
|
88
|
+
if (!chip) {
|
|
89
|
+
chip = { key };
|
|
90
|
+
chipRecords.set(key, chip);
|
|
91
|
+
}
|
|
92
|
+
return chip;
|
|
93
|
+
});
|
|
94
|
+
for (const key of [...chipRecords.keys()])
|
|
95
|
+
if (!seen.has(key))
|
|
96
|
+
chipRecords.delete(key);
|
|
97
|
+
return chips;
|
|
98
|
+
};
|
|
99
|
+
const showCount = () => props.count !== undefined && props.value.trim().length > 0;
|
|
100
|
+
const showHelp = () => Boolean(props.examples?.length);
|
|
101
|
+
const filters = () => props.filters ?? [];
|
|
102
|
+
/** The hit count text, or null while the text is blank or no count was given. */
|
|
103
|
+
const countText = () => {
|
|
104
|
+
const count = props.count;
|
|
105
|
+
if (count === undefined || props.value.trim().length === 0)
|
|
106
|
+
return null;
|
|
107
|
+
return t('searchUi.count', { count }, { defaultValue: '{{count}} results' });
|
|
108
|
+
};
|
|
109
|
+
return (<div data-mol-id={`${molId()}-box`}>
|
|
110
|
+
<div class={cm.cn(cm.searchField, props.className)}>
|
|
111
|
+
<span class={cm.searchFieldIcon} aria-hidden="true">
|
|
112
|
+
<Icon name="search" size={18}/>
|
|
113
|
+
</span>
|
|
114
|
+
<input ref={inputRefFn} type="search" onInput={onInput} onKeyDown={(event) => props.onKeyDown?.(event)} onFocusIn={() => setFocused(true)} onFocusOut={() => setFocused(false)} placeholder={props.placeholder} aria-label={props.label ?? props.placeholder} autocomplete="off" autocorrect="off" spellcheck="false" enterkeyhint="search" class={cm.searchFieldInput} data-mol-id={`${molId()}-input`}/>
|
|
115
|
+
<span class={cm.searchFieldActions}>
|
|
116
|
+
{showHelp() ? (
|
|
117
|
+
// The tooltip's content class keeps short labels on one line; the tips
|
|
118
|
+
// are a sentence or two, so the inner block wraps on its own.
|
|
119
|
+
<Tooltip content={<div class={cm.searchTips} style={{ 'white-space': 'normal', 'max-width': '360px' }}>
|
|
120
|
+
{t('searchUi.syntax', undefined, {
|
|
121
|
+
defaultValue: 'Narrow with a field, quote a phrase, or exclude a word:',
|
|
122
|
+
})}{' '}
|
|
123
|
+
{[
|
|
124
|
+
...(props.examples ?? []),
|
|
125
|
+
t('searchUi.examplePhrase', undefined, { defaultValue: '"exact phrase"' }),
|
|
126
|
+
t('searchUi.exampleExcluded', undefined, { defaultValue: '-word' }),
|
|
127
|
+
].map((ex, i) => (<span>
|
|
128
|
+
{i > 0 ? ' · ' : ''}
|
|
129
|
+
<code>{ex}</code>
|
|
130
|
+
</span>))}{' '}
|
|
131
|
+
{' · '}
|
|
132
|
+
<Kbd>↑</Kbd> <Kbd>↓</Kbd> <Kbd>↵</Kbd>{' '}
|
|
133
|
+
{t('searchUi.keys', undefined, {
|
|
134
|
+
defaultValue: 'The arrow keys move through the results and Enter opens one.',
|
|
135
|
+
})}
|
|
136
|
+
</div>} placement="bottom-end">
|
|
137
|
+
<button type="button" aria-label={t('searchUi.help', undefined, { defaultValue: 'Search tips' })} class={cm.searchFieldClear} data-mol-id={`${molId()}-help`}>
|
|
138
|
+
<Icon name="question" size={16}/>
|
|
139
|
+
</button>
|
|
140
|
+
</Tooltip>) : null}
|
|
141
|
+
{props.value && props.onClear ? (<button type="button" onClick={onClearClick} aria-label={t('searchUi.clear', undefined, { defaultValue: 'Clear search' })} class={cm.searchFieldClear} data-mol-id={`${molId()}-clear`}>
|
|
142
|
+
<span aria-hidden="true">×</span>
|
|
143
|
+
</button>) : null}
|
|
144
|
+
{shortcut() && !props.value && !focused() ? <Kbd>{shortcut()}</Kbd> : null}
|
|
145
|
+
</span>
|
|
146
|
+
</div>
|
|
147
|
+
{props.afterField}
|
|
148
|
+
{filters().length > 0 || showCount() ? (<div class={cm.searchStatusRow}>
|
|
149
|
+
<For each={keyedChips()}>
|
|
150
|
+
{(_chip, i) => {
|
|
151
|
+
const f = () => filters()[i()];
|
|
152
|
+
const text = () => `${f().negate ? '−' : ''}${f().field}: ${f().values.join(', ')}`;
|
|
153
|
+
return (<button type="button" onClick={() => props.onRemoveFilter?.(i())} aria-label={t('searchUi.removeFilter', { filter: text() }, {
|
|
154
|
+
defaultValue: 'Remove filter {{filter}}',
|
|
155
|
+
})} class={cm.cn(cm.filterChip, f().negate && cm.filterChipNegated)} data-mol-id={`${molId()}-filter`} data-filter-field={f().field}>
|
|
156
|
+
{text()}
|
|
157
|
+
<span class={cm.filterChipRemove} aria-hidden="true">
|
|
158
|
+
×
|
|
159
|
+
</span>
|
|
160
|
+
</button>);
|
|
161
|
+
}}
|
|
162
|
+
</For>
|
|
163
|
+
<span class={cm.mxAuto}/>
|
|
164
|
+
{countText() ? <span data-mol-id={`${molId()}-count`}>{countText()}</span> : null}
|
|
165
|
+
</div>) : null}
|
|
166
|
+
</div>);
|
|
167
|
+
};
|
|
168
|
+
//# sourceMappingURL=SearchBox.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchBox.jsx","sourceRoot":"","sources":["../src/SearchBox.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE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