@molecule/app-search-ui-vue 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 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
- # Temporary Holding Version
1
+ # @molecule/app-search-ui-vue
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Vue 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-vue
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,34 @@
1
+ /**
2
+ * Vue marked text — the counterpart of `@molecule/app-search-ui-react`'s
3
+ * `Highlight`.
4
+ *
5
+ * @module
6
+ */
7
+ import { type PropType, type VNodeChild } from 'vue';
8
+ /**
9
+ * Text with the matched terms marked: each term is marked where it starts a
10
+ * word, case-insensitively, through the ClassMap's `resultMark`.
11
+ *
12
+ * @param props - See {@link HighlightProps}.
13
+ * @returns The marked text component.
14
+ */
15
+ export declare const Highlight: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
16
+ text: {
17
+ type: StringConstructor;
18
+ required: true;
19
+ };
20
+ terms: {
21
+ type: PropType<string[]>;
22
+ required: true;
23
+ };
24
+ }>, () => VNodeChild[], {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
25
+ text: {
26
+ type: StringConstructor;
27
+ required: true;
28
+ };
29
+ terms: {
30
+ type: PropType<string[]>;
31
+ required: true;
32
+ };
33
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
34
+ //# sourceMappingURL=Highlight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Highlight.d.ts","sourceRoot":"","sources":["../src/Highlight.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAsB,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,KAAK,CAAA;AAKxE;;;;;;GAMG;AACH,eAAO,MAAM,SAAS;;;;;;cAIM,QAAQ,CAAC,MAAM,EAAE,CAAC;;;UAG/B,UAAU,EAAE;;;;;;cAHC,QAAQ,CAAC,MAAM,EAAE,CAAC;;;iGAU5C,CAAA"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Vue marked text — the counterpart of `@molecule/app-search-ui-react`'s
3
+ * `Highlight`.
4
+ *
5
+ * @module
6
+ */
7
+ import { defineComponent, h } from 'vue';
8
+ import { highlightMatches } from '@molecule/app-client-search';
9
+ import { getClassMap } from '@molecule/app-ui';
10
+ /**
11
+ * Text with the matched terms marked: each term is marked where it starts a
12
+ * word, case-insensitively, through the ClassMap's `resultMark`.
13
+ *
14
+ * @param props - See {@link HighlightProps}.
15
+ * @returns The marked text component.
16
+ */
17
+ export const Highlight = defineComponent({
18
+ name: 'Highlight',
19
+ props: {
20
+ text: { type: String, required: true },
21
+ terms: { type: Array, required: true },
22
+ },
23
+ setup(props) {
24
+ return () => {
25
+ const cm = getClassMap();
26
+ return highlightMatches(props.text, props.terms).map((seg) => seg.hit ? h('mark', { class: cm.resultMark }, [seg.text]) : seg.text);
27
+ };
28
+ },
29
+ });
30
+ //# sourceMappingURL=Highlight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Highlight.js","sourceRoot":"","sources":["../src/Highlight.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,CAAC,EAAkC,MAAM,KAAK,CAAA;AAExE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,eAAe,CAAC;IACvC,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE;QACL,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;QACtC,KAAK,EAAE,EAAE,IAAI,EAAE,KAA2B,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC7D;IACD,KAAK,CAAC,KAAK;QACT,OAAO,GAAiB,EAAE;YACxB,MAAM,EAAE,GAAG,WAAW,EAAE,CAAA;YACxB,OAAO,gBAAgB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAC3D,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CACrE,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
package/dist/Kbd.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Vue key cap — the counterpart of `@molecule/app-search-ui-react`'s `Kbd`.
3
+ *
4
+ * @module
5
+ */
6
+ import { type VNode } from 'vue';
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 The key cap component.
14
+ */
15
+ export declare const Kbd: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
16
+ children: null;
17
+ className: StringConstructor;
18
+ }>, () => VNode, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
19
+ children: null;
20
+ className: StringConstructor;
21
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
22
+ //# sourceMappingURL=Kbd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Kbd.d.ts","sourceRoot":"","sources":["../src/Kbd.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAsB,KAAK,KAAK,EAAmB,MAAM,KAAK,CAAA;AAqBrE;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG;;;UAOD,KAAK;;;iGASlB,CAAA"}
package/dist/Kbd.js ADDED
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Vue key cap — the counterpart of `@molecule/app-search-ui-react`'s `Kbd`.
3
+ *
4
+ * @module
5
+ */
6
+ import { defineComponent, h } from 'vue';
7
+ import { getClassMap } from '@molecule/app-ui';
8
+ /**
9
+ * Resolves a node-valued prop that may also arrive as the default slot: the
10
+ * slot wins, and an absent pair contributes nothing.
11
+ *
12
+ * @param slot - The default slot's render function, when the caller passed it.
13
+ * @param prop - The prop value, when the caller passed the prop.
14
+ * @returns The children to render.
15
+ */
16
+ const childrenOf = (slot, prop) => {
17
+ if (slot)
18
+ return slot();
19
+ if (prop === undefined || prop === null || prop === false)
20
+ return [];
21
+ return Array.isArray(prop) ? prop : [prop];
22
+ };
23
+ /**
24
+ * A key cap, for shortcut hints (`/` to focus, `↵` to open). The cap shows a
25
+ * key name, not prose (a physical key such as `esc` reads the same in every
26
+ * language), so it carries HTML's own `translate="no"`.
27
+ *
28
+ * @param props - See {@link KbdProps}.
29
+ * @returns The key cap component.
30
+ */
31
+ export const Kbd = defineComponent({
32
+ name: 'Kbd',
33
+ props: {
34
+ children: null,
35
+ className: String,
36
+ },
37
+ setup(props, { slots }) {
38
+ return () => {
39
+ const cm = getClassMap();
40
+ return h('kbd', { class: cm.cn(cm.kbd, props.className), translate: 'no' }, childrenOf(slots.default, props.children));
41
+ };
42
+ },
43
+ });
44
+ //# sourceMappingURL=Kbd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Kbd.js","sourceRoot":"","sources":["../src/Kbd.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,CAAC,EAA+B,MAAM,KAAK,CAAA;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C;;;;;;;GAOG;AACH,MAAM,UAAU,GAAG,CACjB,IAAsC,EACtC,IAAmC,EACrB,EAAE;IAChB,IAAI,IAAI;QAAE,OAAO,IAAI,EAAE,CAAA;IACvB,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK;QAAE,OAAO,EAAE,CAAA;IACpE,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;AAC5C,CAAC,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC;IACjC,IAAI,EAAE,KAAK;IACX,KAAK,EAAE;QACL,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,MAAM;KAClB;IACD,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE;QACpB,OAAO,GAAU,EAAE;YACjB,MAAM,EAAE,GAAG,WAAW,EAAE,CAAA;YACxB,OAAO,CAAC,CACN,KAAK,EACL,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,EAC1D,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,CAC1C,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Vue quick-search dialog — the counterpart of
3
+ * `@molecule/app-search-ui-react`'s `QuickSearchDialog`.
4
+ *
5
+ * @module
6
+ */
7
+ import { type PropType, type VNodeChild } from 'vue';
8
+ import type { ClientSearchDocument } from '@molecule/app-client-search';
9
+ import type { SearchSession } from '@molecule/app-client-search-vue';
10
+ import type { SearchResultLinkProps, SearchResultView } from './types.js';
11
+ /**
12
+ * A search dialog for `mod+k`: the box on top with focus, the hits below in
13
+ * a scrolling pane, and the key hints in the footer. Before anything is
14
+ * typed the pane shows `idleText` rather than a browse list. Enter opens the active
15
+ * hit through the session (which closes the dialog by the caller's `onOpen`).
16
+ * The dialog is named for screen readers through `label` (or the translated
17
+ * "Search" default).
18
+ *
19
+ * @param props - See {@link QuickSearchDialogProps}.
20
+ * @returns The dialog component.
21
+ */
22
+ export declare const QuickSearchDialog: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
23
+ open: {
24
+ type: BooleanConstructor;
25
+ required: true;
26
+ };
27
+ onClose: {
28
+ type: PropType<() => void>;
29
+ required: true;
30
+ };
31
+ session: {
32
+ type: PropType<SearchSession<ClientSearchDocument>>;
33
+ required: true;
34
+ };
35
+ view: {
36
+ type: PropType<(doc: unknown) => SearchResultView>;
37
+ required: true;
38
+ };
39
+ placeholder: {
40
+ type: StringConstructor;
41
+ required: true;
42
+ };
43
+ examples: {
44
+ type: PropType<string[]>;
45
+ default: undefined;
46
+ };
47
+ emptyText: {
48
+ type: StringConstructor;
49
+ required: true;
50
+ };
51
+ idleText: {
52
+ type: StringConstructor;
53
+ default: undefined;
54
+ };
55
+ renderLink: {
56
+ type: PropType<((linkProps: SearchResultLinkProps) => VNodeChild) | undefined>;
57
+ default: undefined;
58
+ };
59
+ label: {
60
+ type: StringConstructor;
61
+ default: undefined;
62
+ };
63
+ molId: {
64
+ type: StringConstructor;
65
+ default: string;
66
+ };
67
+ }>, () => VNodeChild, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
68
+ open: {
69
+ type: BooleanConstructor;
70
+ required: true;
71
+ };
72
+ onClose: {
73
+ type: PropType<() => void>;
74
+ required: true;
75
+ };
76
+ session: {
77
+ type: PropType<SearchSession<ClientSearchDocument>>;
78
+ required: true;
79
+ };
80
+ view: {
81
+ type: PropType<(doc: unknown) => SearchResultView>;
82
+ required: true;
83
+ };
84
+ placeholder: {
85
+ type: StringConstructor;
86
+ required: true;
87
+ };
88
+ examples: {
89
+ type: PropType<string[]>;
90
+ default: undefined;
91
+ };
92
+ emptyText: {
93
+ type: StringConstructor;
94
+ required: true;
95
+ };
96
+ idleText: {
97
+ type: StringConstructor;
98
+ default: undefined;
99
+ };
100
+ renderLink: {
101
+ type: PropType<((linkProps: SearchResultLinkProps) => VNodeChild) | undefined>;
102
+ default: undefined;
103
+ };
104
+ label: {
105
+ type: StringConstructor;
106
+ default: undefined;
107
+ };
108
+ molId: {
109
+ type: StringConstructor;
110
+ default: string;
111
+ };
112
+ }>> & Readonly<{}>, {
113
+ label: string;
114
+ examples: string[];
115
+ molId: string;
116
+ renderLink: ((linkProps: SearchResultLinkProps) => VNodeChild) | undefined;
117
+ idleText: string;
118
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
119
+ //# sourceMappingURL=QuickSearchDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QuickSearchDialog.d.ts","sourceRoot":"","sources":["../src/QuickSearchDialog.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAKL,KAAK,QAAQ,EAGb,KAAK,UAAU,EAEhB,MAAM,KAAK,CAAA;AAEZ,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAQpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAsBzE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB;;;;;;cAIG,QAAQ,CAAC,MAAM,IAAI,CAAC;;;;cAE/B,QAAQ,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC;;;;cAI3C,QAAQ,CAAC,CAAC,GAAG,EAAE,OAAO,KAAK,gBAAgB,CAAC;;;;;;;;cAIrC,QAAQ,CAAC,MAAM,EAAE,CAAC;;;;;;;;;;;;cAIzB,QAAQ,CAAC,CAAC,CAAC,SAAS,EAAE,qBAAqB,KAAK,UAAU,CAAC,GAAG,SAAS,CAAC;;;;;;;;;;;UAwBjF,UAAU;;;;;;cAtCQ,QAAQ,CAAC,MAAM,IAAI,CAAC;;;;cAE/B,QAAQ,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC;;;;cAI3C,QAAQ,CAAC,CAAC,GAAG,EAAE,OAAO,KAAK,gBAAgB,CAAC;;;;;;;;cAIrC,QAAQ,CAAC,MAAM,EAAE,CAAC;;;;;;;;;;;;cAIzB,QAAQ,CAAC,CAAC,CAAC,SAAS,EAAE,qBAAqB,KAAK,UAAU,CAAC,GAAG,SAAS,CAAC;;;;;;;;;;;;;;;6BAAlD,qBAAqB,KAAK,UAAU;;4EAoGhF,CAAA"}
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Vue quick-search dialog — the counterpart of
3
+ * `@molecule/app-search-ui-react`'s `QuickSearchDialog`.
4
+ *
5
+ * @module
6
+ */
7
+ import { defineComponent, h, nextTick, onMounted, toValue, watch, } from 'vue';
8
+ import { getClassMap } from '@molecule/app-ui';
9
+ import { Modal } from '@molecule/app-ui-vue';
10
+ import { useTranslation } from '@molecule/app-vue';
11
+ import { Kbd } from './Kbd.js';
12
+ import { SearchBox } from './SearchBox.js';
13
+ import { SearchResults } from './SearchResults.js';
14
+ /**
15
+ * Reads a session field, unwrapping the reactive container a Vue session
16
+ * holds it in (`Ref`/`ComputedRef`) and passing a plain value through, so the
17
+ * dialog takes a session from `useSearchSession` or a plain object alike.
18
+ *
19
+ * @param value - The session field.
20
+ * @returns The value.
21
+ */
22
+ const read = (value) => toValue(value);
23
+ /**
24
+ * Whether a value is a search document, so a hit handed back by the list can
25
+ * reach the session's typed `open`/`prefetch` without a cast.
26
+ *
27
+ * @param value - The hit's document.
28
+ * @returns True for a record, which is what a `ClientSearchDocument` is.
29
+ */
30
+ const isDocument = (value) => typeof value === 'object' && value !== null;
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 component.
41
+ */
42
+ export const QuickSearchDialog = defineComponent({
43
+ name: 'QuickSearchDialog',
44
+ props: {
45
+ open: { type: Boolean, required: true },
46
+ onClose: { type: Function, required: true },
47
+ session: {
48
+ type: Object,
49
+ required: true,
50
+ },
51
+ view: {
52
+ type: Function,
53
+ required: true,
54
+ },
55
+ placeholder: { type: String, required: true },
56
+ examples: { type: Array, default: undefined },
57
+ emptyText: { type: String, required: true },
58
+ idleText: { type: String, default: undefined },
59
+ renderLink: {
60
+ type: Function,
61
+ default: undefined,
62
+ },
63
+ label: { type: String, default: undefined },
64
+ molId: { type: String, default: 'quick-search' },
65
+ },
66
+ setup(props) {
67
+ const cm = getClassMap();
68
+ const { t } = useTranslation();
69
+ // The dialog pattern: focus moves into the field when it opens. The input
70
+ // is mounted only while open, so the focus waits one tick for the field
71
+ // to exist (React's effect runs after the child mounts).
72
+ const focusField = () => {
73
+ if (props.open)
74
+ props.session.inputRef.current?.focus();
75
+ };
76
+ onMounted(focusField);
77
+ watch(() => props.open, () => {
78
+ nextTick(focusField);
79
+ });
80
+ return () => {
81
+ if (!props.open)
82
+ return null;
83
+ const active = read(props.session.active);
84
+ const hits = read(props.session.hits);
85
+ return h(Modal, {
86
+ open: props.open,
87
+ onClose: props.onClose,
88
+ size: 'lg',
89
+ closeOnEscape: false,
90
+ showCloseButton: false,
91
+ closeLabel: t('searchUi.close', undefined, { defaultValue: 'Close' }),
92
+ 'aria-label': props.label ?? t('searchUi.dialogLabel', undefined, { defaultValue: 'Search' }),
93
+ 'data-mol-id': props.molId,
94
+ }, {
95
+ default: () => [
96
+ h(SearchBox, {
97
+ value: read(props.session.query),
98
+ onChange: (value) => props.session.setQuery(value),
99
+ onKeyDown: (event) => props.session.onKeyDown(event),
100
+ inputRef: props.session.inputRef,
101
+ placeholder: props.placeholder,
102
+ count: active ? hits.length : undefined,
103
+ filters: read(props.session.parsed).filters,
104
+ onRemoveFilter: (index) => props.session.removeFilter(index),
105
+ onClear: () => props.session.clear(),
106
+ examples: props.examples,
107
+ shortcut: null,
108
+ molId: props.molId,
109
+ }),
110
+ h('div', { class: cm.dialogBody, 'data-mol-id': `${props.molId}-pane` }, [
111
+ h(SearchResults, {
112
+ hits: active ? hits : [],
113
+ view: props.view,
114
+ activeIndex: read(props.session.activeIndex),
115
+ onActivate: (index) => props.session.setActiveIndex(index),
116
+ onOpen: (doc) => {
117
+ if (isDocument(doc))
118
+ props.session.open(doc);
119
+ },
120
+ onPrefetch: (doc) => {
121
+ if (isDocument(doc))
122
+ props.session.prefetch(doc);
123
+ },
124
+ renderLink: props.renderLink,
125
+ emptyText: active ? props.emptyText : (props.idleText ?? props.emptyText),
126
+ molId: props.molId,
127
+ }),
128
+ ]),
129
+ h('p', {
130
+ class: cm.cn(cm.dialogFooter, cm.resultMeta),
131
+ 'data-mol-id': `${props.molId}-keys`,
132
+ }, [
133
+ h(Kbd, () => ['↑']),
134
+ ' ',
135
+ h(Kbd, () => ['↓']),
136
+ ' ',
137
+ h(Kbd, () => ['↵']),
138
+ ' ',
139
+ h(Kbd, () => ['esc']),
140
+ ' ',
141
+ t('searchUi.dialogKeys', undefined, {
142
+ defaultValue: 'The arrow keys move through the results, Enter opens one, Escape closes.',
143
+ }),
144
+ ]),
145
+ ],
146
+ });
147
+ };
148
+ },
149
+ });
150
+ //# sourceMappingURL=QuickSearchDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QuickSearchDialog.js","sourceRoot":"","sources":["../src/QuickSearchDialog.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,eAAe,EACf,CAAC,EACD,QAAQ,EACR,SAAS,EAGT,OAAO,EAEP,KAAK,GACN,MAAM,KAAK,CAAA;AAIZ,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGlD;;;;;;;GAOG;AACH,MAAM,IAAI,GAAG,CAAI,KAAiB,EAAK,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAExD;;;;;;GAMG;AACH,MAAM,UAAU,GAAG,CAAC,KAAc,EAAiC,EAAE,CACnE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAA;AAE7C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC;IAC/C,IAAI,EAAE,mBAAmB;IACzB,KAAK,EAAE;QACL,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE;QACvC,OAAO,EAAE,EAAE,IAAI,EAAE,QAAgC,EAAE,QAAQ,EAAE,IAAI,EAAE;QACnE,OAAO,EAAE;YACP,IAAI,EAAE,MAAuD;YAC7D,QAAQ,EAAE,I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