@searchcraft/vue-sdk 0.11.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +123 -117
- package/dist/index.d.ts +31 -2
- package/dist/index.es.js +2009 -1962
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +31 -31
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 Searchcraft, Inc.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -22,91 +22,97 @@ $ npm install @searchcraft/vue-sdk
|
|
|
22
22
|
|
|
23
23
|
The Vue SDK provides the following prebuilt components for use in your application:
|
|
24
24
|
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
<
|
|
28
|
-
<
|
|
29
|
-
<
|
|
30
|
-
<
|
|
31
|
-
<
|
|
32
|
-
|
|
25
|
+
```vue
|
|
26
|
+
<SearchcraftInputForm />
|
|
27
|
+
<SearchcraftPopoverForm />
|
|
28
|
+
<SearchcraftPopoverButton />
|
|
29
|
+
<SearchcraftFilterPanel />
|
|
30
|
+
<SearchcraftResultsInfo />
|
|
31
|
+
<SearchcraftSearchResults />
|
|
32
|
+
<SearchcraftPagination />
|
|
33
|
+
<SearchcraftSearchResultsPerPage />
|
|
34
|
+
<SearchcraftSummaryBox />
|
|
35
|
+
<SearchcraftTheme />
|
|
33
36
|
```
|
|
34
37
|
|
|
35
38
|
These components can be added to your Vue app and customized with configurations as needed.
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
### Themes & Styles
|
|
41
|
+
|
|
42
|
+
**Note** To apply Searchcraft's built-in CSS theme to the components, which is highly recommended, please make sure that the `<SearchcraftTheme>` component is placed somewhere in your Vue template. This component adds the necessary styles for the Searchcraft components. Without this component, the searchcraft theme will _not_ be applied, and the components will render without styles.
|
|
38
43
|
|
|
39
44
|
#### Example Setup
|
|
40
45
|
|
|
41
46
|
As early as possible in the app lifecycle, initialize the Searchcraft object:
|
|
42
|
-
```jsx
|
|
43
|
-
import { Searchcraft } from '@searchcraft/react-sdk';
|
|
44
47
|
|
|
48
|
+
```js
|
|
49
|
+
import { Searchcraft } from '@searchcraft/vue-sdk';
|
|
50
|
+
|
|
51
|
+
// Index Search Configuration
|
|
45
52
|
const searchcraft = new Searchcraft({
|
|
46
|
-
|
|
53
|
+
indexName: 'your_index_from_vektron',
|
|
47
54
|
readKey: 'your_read_key_from_vektron',
|
|
48
55
|
endpointURL: 'your_searchcraft_endpoint_url',
|
|
49
56
|
searchDebounceDelay: 50, // Optional debounce delay in milliseconds
|
|
50
57
|
})
|
|
51
58
|
|
|
59
|
+
// Alternatively, you can create a Federation Search Configuration which searches across multiple indices
|
|
60
|
+
const federatedSearchcraft = new Searchcraft({
|
|
61
|
+
federationName: 'your_federation_name',
|
|
62
|
+
readKey: 'your_read_key_from_vektron',
|
|
63
|
+
endpointURL: 'your_searchcraft_endpoint_url',
|
|
64
|
+
searchDebounceDelay: 50, // Optional debounce delay in milliseconds
|
|
65
|
+
})
|
|
52
66
|
```
|
|
53
67
|
|
|
54
68
|
Add components to your application:
|
|
55
69
|
|
|
56
|
-
```
|
|
57
|
-
|
|
70
|
+
```vue
|
|
58
71
|
<template>
|
|
59
|
-
<
|
|
60
|
-
|
|
61
|
-
|
|
72
|
+
<div>
|
|
73
|
+
<SearchcraftTheme />
|
|
74
|
+
<SearchcraftInputForm />
|
|
75
|
+
<SearchcraftFilterPanel :items="filterPanelItems" />
|
|
76
|
+
<SearchcraftResultsInfo />
|
|
77
|
+
<SearchcraftSearchResults />
|
|
78
|
+
<SearchcraftPagination />
|
|
79
|
+
</div>
|
|
62
80
|
</template>
|
|
63
81
|
|
|
64
|
-
<script>
|
|
82
|
+
<script setup>
|
|
65
83
|
import {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
84
|
+
SearchcraftTheme,
|
|
85
|
+
SearchcraftInputForm,
|
|
86
|
+
SearchcraftFilterPanel,
|
|
87
|
+
SearchcraftResultsInfo,
|
|
88
|
+
SearchcraftSearchResults,
|
|
89
|
+
SearchcraftPagination,
|
|
70
90
|
} from '@searchcraft/vue-sdk';
|
|
71
91
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
92
|
+
const filterPanelItems = [
|
|
93
|
+
{
|
|
94
|
+
type: 'mostRecentToggle',
|
|
95
|
+
label: 'Most Recent',
|
|
96
|
+
options: {
|
|
97
|
+
subLabel: 'Show the most recently published articles first.',
|
|
98
|
+
},
|
|
78
99
|
},
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
options: {
|
|
86
|
-
subLabel: 'Show the most recently published articles first.',
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
type: 'exactMatchToggle',
|
|
91
|
-
label: 'Exact Match',
|
|
92
|
-
options: {
|
|
93
|
-
subLabel: 'Only show results that precisely match your search.',
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
};
|
|
100
|
+
{
|
|
101
|
+
type: 'exactMatchToggle',
|
|
102
|
+
label: 'Exact Match',
|
|
103
|
+
options: {
|
|
104
|
+
subLabel: 'Only show results that precisely match your search.',
|
|
105
|
+
},
|
|
98
106
|
},
|
|
99
|
-
|
|
107
|
+
];
|
|
100
108
|
</script>
|
|
101
|
-
|
|
102
109
|
```
|
|
103
110
|
|
|
104
|
-
Example Filter Configuration
|
|
111
|
+
### Example Filter Configuration
|
|
105
112
|
|
|
106
113
|
Below is an example of a filter panel configuration object. It specifies the filters to be displayed in the filter panel and maps them to the corresponding index fields.
|
|
107
114
|
|
|
108
|
-
```
|
|
109
|
-
|
|
115
|
+
```js
|
|
110
116
|
const today = new Date();
|
|
111
117
|
const pastDate = new Date(today);
|
|
112
118
|
pastDate.setFullYear(today.getFullYear() - 10);
|
|
@@ -128,7 +134,7 @@ export const filterPanelItems = [
|
|
|
128
134
|
},
|
|
129
135
|
{
|
|
130
136
|
type: 'dateRange',
|
|
131
|
-
|
|
137
|
+
field: 'date_published',
|
|
132
138
|
label: 'Filter by Year',
|
|
133
139
|
options: {
|
|
134
140
|
minDate: pastDate,
|
|
@@ -138,85 +144,85 @@ export const filterPanelItems = [
|
|
|
138
144
|
},
|
|
139
145
|
{
|
|
140
146
|
type: 'facets',
|
|
141
|
-
|
|
147
|
+
field: 'section',
|
|
142
148
|
label: 'Filter by Section',
|
|
149
|
+
options: {
|
|
150
|
+
subLabel: 'Filter by content section',
|
|
151
|
+
maxItems: 10,
|
|
152
|
+
},
|
|
143
153
|
},
|
|
144
154
|
];
|
|
145
|
-
|
|
146
155
|
```
|
|
147
156
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
157
|
+
### Search Result Templates
|
|
158
|
+
|
|
159
|
+
The Vue SDK supports custom search result templates using template functions. You can customize the appearance and behavior of search results by providing a template function:
|
|
160
|
+
|
|
161
|
+
```js
|
|
162
|
+
import { html } from '@searchcraft/vue-sdk';
|
|
163
|
+
|
|
164
|
+
export const customSearchResultTemplate = (data, index, { html }) => {
|
|
165
|
+
return html`
|
|
166
|
+
<a href="${data.canonical_link}" target="_blank" rel="noreferrer">
|
|
167
|
+
<div class="search-result-content">
|
|
168
|
+
<h3 class="search-result-content-subtitle">${data.section_name}</h3>
|
|
169
|
+
<h2 class="search-result-content-title">${data.headline}</h2>
|
|
170
|
+
<p class="search-result-content-body">${data.sub_headline}</p>
|
|
171
|
+
<footer class="search-result-content-footer">
|
|
172
|
+
<time>
|
|
173
|
+
${new Intl.DateTimeFormat("en-US", {
|
|
174
|
+
day: "numeric",
|
|
175
|
+
month: "short",
|
|
176
|
+
year: "numeric",
|
|
177
|
+
}).format(new Date(data.date_published))}
|
|
178
|
+
</time>
|
|
179
|
+
•
|
|
180
|
+
<p>${data.author_name}</p>
|
|
181
|
+
</footer>
|
|
182
|
+
</div>
|
|
183
|
+
<div class="search-result-image">
|
|
184
|
+
<img src="${data.medium_image}" alt="${data.headline}" />
|
|
185
|
+
</div>
|
|
186
|
+
</a>
|
|
187
|
+
`;
|
|
188
|
+
};
|
|
189
|
+
```
|
|
151
190
|
|
|
152
|
-
|
|
191
|
+
Then apply the template to your search results component:
|
|
153
192
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
fieldName: 'canonical_link',
|
|
159
|
-
dataType: 'text',
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
},
|
|
163
|
-
footer: {
|
|
164
|
-
fieldNames: [
|
|
165
|
-
{
|
|
166
|
-
fieldName: 'date_published',
|
|
167
|
-
dataType: 'date',
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
fieldName: 'author_name',
|
|
171
|
-
dataType: 'text',
|
|
172
|
-
},
|
|
173
|
-
],
|
|
174
|
-
delimiter: ' • ',
|
|
175
|
-
},
|
|
176
|
-
imageSource: {
|
|
177
|
-
fieldNames: [
|
|
178
|
-
{
|
|
179
|
-
fieldName: 'medium_image',
|
|
180
|
-
dataType: 'text',
|
|
181
|
-
},
|
|
182
|
-
],
|
|
183
|
-
},
|
|
184
|
-
body: {
|
|
185
|
-
fieldNames: [{ fieldName: 'sub_headline', dataType: 'text' }],
|
|
186
|
-
},
|
|
187
|
-
title: {
|
|
188
|
-
fieldNames: [{ fieldName: 'section_name', dataType: 'text' }],
|
|
189
|
-
},
|
|
190
|
-
subtitle: {
|
|
191
|
-
fieldNames: [{ fieldName: 'headline', dataType: 'text' }],
|
|
192
|
-
},
|
|
193
|
-
};
|
|
193
|
+
```vue
|
|
194
|
+
<template>
|
|
195
|
+
<SearchcraftSearchResults :template="customSearchResultTemplate" />
|
|
196
|
+
</template>
|
|
194
197
|
|
|
198
|
+
<script setup>
|
|
199
|
+
import { SearchcraftSearchResults } from '@searchcraft/vue-sdk';
|
|
200
|
+
import { customSearchResultTemplate } from './searchResultTemplate';
|
|
201
|
+
</script>
|
|
195
202
|
```
|
|
196
203
|
|
|
197
|
-
|
|
198
|
-
You can subscribe to various events within Searchcraft:
|
|
204
|
+
### Event Handling
|
|
199
205
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
const searchcraft = new Searchcraft({
|
|
203
|
-
index: ['your_index_from_vektron'],
|
|
204
|
-
readKey: 'your_read_key_from_vektron',
|
|
205
|
-
endpointURL: 'your_searchcraft_endpoint_url',
|
|
206
|
-
});
|
|
206
|
+
You can subscribe to various events within Searchcraft:
|
|
207
207
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
```js
|
|
209
|
+
const searchcraft = new Searchcraft({
|
|
210
|
+
indexName: 'your_index_from_vektron',
|
|
211
|
+
readKey: 'your_read_key_from_vektron',
|
|
212
|
+
endpointURL: 'your_searchcraft_endpoint_url',
|
|
213
|
+
});
|
|
211
214
|
|
|
215
|
+
const unsubscribeCallback = searchcraft.subscribe('query_submitted', (event) => {
|
|
216
|
+
// Do something in your application when a query has been submitted
|
|
217
|
+
});
|
|
212
218
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
219
|
+
const unsubscribeCallback2 = searchcraft.subscribe('ad_container_rendered', (event) => {
|
|
220
|
+
// Do something when a new ad container has been rendered
|
|
221
|
+
});
|
|
216
222
|
```
|
|
217
223
|
|
|
218
|
-
For a complete listing of event subscriptions, refer to the
|
|
224
|
+
For a complete listing of event subscriptions, refer to the API reference.
|
|
219
225
|
|
|
220
|
-
Additional Information
|
|
226
|
+
## Additional Information
|
|
221
227
|
|
|
222
|
-
For more advanced use cases and component-specific documentation, refer to the official [Searchcraft Vue SDK documentation](https://docs.searchcraft.io/).
|
|
228
|
+
For more advanced use cases and component-specific documentation, refer to the official [Searchcraft Vue SDK documentation](https://docs.searchcraft.io/).
|
package/dist/index.d.ts
CHANGED
|
@@ -90,6 +90,7 @@ export interface MeasureRequestProperties {
|
|
|
90
90
|
searchcraft_organization_id?: string;
|
|
91
91
|
searchcraft_application_id?: string;
|
|
92
92
|
searchcraft_index_names: string[];
|
|
93
|
+
searchcraft_federation_name?: string;
|
|
93
94
|
search_term?: string;
|
|
94
95
|
number_of_documents?: number;
|
|
95
96
|
external_document_id?: string;
|
|
@@ -333,8 +334,16 @@ export interface SearchcraftConfig {
|
|
|
333
334
|
endpointURL: string;
|
|
334
335
|
/**
|
|
335
336
|
* Name of the Searchcraft search index to search for results within. If you are using Searchcraft Cloud, this value can be found within the Vektron dashboard in the Code Snippets section when configuring a search index.
|
|
337
|
+
*
|
|
338
|
+
* Note: Either `indexName` or `federationName` must be provided, but not both.
|
|
336
339
|
*/
|
|
337
|
-
indexName
|
|
340
|
+
indexName?: string;
|
|
341
|
+
/**
|
|
342
|
+
* Name of the Searchcraft federation to search across multiple indices. Federation search allows you to search across all indices defined in a federation with a single query.
|
|
343
|
+
*
|
|
344
|
+
* Note: Either `indexName` or `federationName` must be provided, but not both.
|
|
345
|
+
*/
|
|
346
|
+
federationName?: string;
|
|
338
347
|
/**
|
|
339
348
|
* The initial search query to call when Searchcraft is first initialized in your front-end application. This parameter can be used when you want to populate a page with an initial set of search results based on a query.
|
|
340
349
|
*
|
|
@@ -601,6 +610,7 @@ declare class SearchClient {
|
|
|
601
610
|
constructor(parent: SearchcraftCore, config: SearchcraftConfig, userId: string);
|
|
602
611
|
/**
|
|
603
612
|
* Getter for the base url used by the /search endpoint.
|
|
613
|
+
* Supports both index and federation search endpoints.
|
|
604
614
|
*/
|
|
605
615
|
private get baseSearchUrl();
|
|
606
616
|
/**
|
|
@@ -640,7 +650,9 @@ export interface SearchcraftStateFunctions {
|
|
|
640
650
|
removeFacetPathsForIndexField: (fieldName: string) => void;
|
|
641
651
|
removeRangeValueForIndexField: (fieldName: string) => void;
|
|
642
652
|
resetSearchValues: () => void;
|
|
643
|
-
search: (
|
|
653
|
+
search: (options?: {
|
|
654
|
+
skipSummary?: boolean;
|
|
655
|
+
}) => Promise<void>;
|
|
644
656
|
setPopoverVisibility: (isVisible: boolean) => void;
|
|
645
657
|
setSearchResultsCount: (count: number) => void;
|
|
646
658
|
setSearchResultsPage: (page: number) => void;
|
|
@@ -684,6 +696,7 @@ export interface SearchcraftStateValues {
|
|
|
684
696
|
hasSummaryBox: boolean;
|
|
685
697
|
isSummaryLoading: boolean;
|
|
686
698
|
summaryClient?: SummaryClient;
|
|
699
|
+
isSummaryNotEnabled: boolean;
|
|
687
700
|
}
|
|
688
701
|
export interface SearchcraftState extends SearchcraftStateFunctions, SearchcraftStateValues {
|
|
689
702
|
}
|
|
@@ -1048,6 +1061,14 @@ export namespace Components {
|
|
|
1048
1061
|
* The hotkey modifier that activates the popover. Used together with the `hotkey` prop.
|
|
1049
1062
|
*/
|
|
1050
1063
|
"hotkeyModifier"?: "ctrl" | "meta" | "alt" | "option";
|
|
1064
|
+
/**
|
|
1065
|
+
* The placeholder's render behavior. 'hide-on-focus' - Hide the placeholder text immediately when the input form gains focus. 'hide-on-text-entered' - Only hide the placeholder when the input form has text entered into it.
|
|
1066
|
+
*/
|
|
1067
|
+
"placeholderBehavior"?: "hide-on-focus" | "hide-on-text-entered";
|
|
1068
|
+
/**
|
|
1069
|
+
* The input element's placeholder value.
|
|
1070
|
+
*/
|
|
1071
|
+
"placeholderValue"?: string;
|
|
1051
1072
|
/**
|
|
1052
1073
|
* Formats the content rendered for each result.
|
|
1053
1074
|
*/
|
|
@@ -2303,6 +2324,14 @@ declare namespace LocalJSX {
|
|
|
2303
2324
|
* The hotkey modifier that activates the popover. Used together with the `hotkey` prop.
|
|
2304
2325
|
*/
|
|
2305
2326
|
"hotkeyModifier"?: "ctrl" | "meta" | "alt" | "option";
|
|
2327
|
+
/**
|
|
2328
|
+
* The placeholder's render behavior. 'hide-on-focus' - Hide the placeholder text immediately when the input form gains focus. 'hide-on-text-entered' - Only hide the placeholder when the input form has text entered into it.
|
|
2329
|
+
*/
|
|
2330
|
+
"placeholderBehavior"?: "hide-on-focus" | "hide-on-text-entered";
|
|
2331
|
+
/**
|
|
2332
|
+
* The input element's placeholder value.
|
|
2333
|
+
*/
|
|
2334
|
+
"placeholderValue"?: string;
|
|
2306
2335
|
/**
|
|
2307
2336
|
* Formats the content rendered for each result.
|
|
2308
2337
|
*/
|