@searchcraft/javascript-sdk 0.9.7 → 0.10.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/README.md +2 -2
- package/dist/components/defineCustomElements.js +6 -6
- package/dist/components/index.d.ts +2514 -68
- package/dist/components/index.js +45 -14
- package/dist/components/index.js.map +1 -1
- package/dist/components/{p-e55a7970.js → p-1adf78b9.js} +2 -2
- package/dist/components/p-1adf78b9.js.map +1 -0
- package/dist/components/{p-60f05735.js → p-34a32648.js} +4 -4
- package/dist/components/p-34a32648.js.map +1 -0
- package/dist/components/p-39e70a00.js +67 -0
- package/dist/components/p-39e70a00.js.map +1 -0
- package/dist/components/{p-e41b0f43.js → p-3f63fa14.js} +14 -21
- package/dist/components/p-3f63fa14.js.map +1 -0
- package/dist/components/{p-bf6a086a.js → p-73db9122.js} +3 -10
- package/dist/components/p-73db9122.js.map +1 -0
- package/dist/components/p-810a7850.js +17 -0
- package/dist/components/p-810a7850.js.map +1 -0
- package/dist/components/{p-8f854dec.js → p-8aa0fff5.js} +4 -3
- package/dist/components/p-8aa0fff5.js.map +1 -0
- package/dist/components/{p-5fdaf1e6.js → p-a64b4cba.js} +2 -145
- package/dist/components/p-a64b4cba.js.map +1 -0
- package/dist/components/{p-71cc28c1.js → p-acf23bab.js} +2 -2
- package/dist/components/p-acf23bab.js.map +1 -0
- package/dist/components/{p-bb12ab5a.js → p-bc9e0e40.js} +4 -3
- package/dist/components/p-bc9e0e40.js.map +1 -0
- package/dist/components/{p-4df578e4.js → p-c317a36a.js} +7 -7
- package/dist/components/p-c317a36a.js.map +1 -0
- package/dist/components/{p-e27a0dab.js → p-d361b781.js} +5 -7
- package/dist/components/p-d361b781.js.map +1 -0
- package/dist/components/p-e72d0167.js +147 -0
- package/dist/components/p-e72d0167.js.map +1 -0
- package/dist/components/{p-0e393fe1.js → p-f2585cdf.js} +3 -9
- package/dist/components/p-f2585cdf.js.map +1 -0
- package/dist/components/{p-580c09dc.js → p-f8df3d49.js} +143 -143
- package/dist/components/p-f8df3d49.js.map +1 -0
- package/dist/components/searchcraft-ad.js +1 -1
- package/dist/components/searchcraft-button.js +1 -1
- package/dist/components/searchcraft-error-message.js +1 -1
- package/dist/components/searchcraft-facet-list.js +1 -1
- package/dist/components/searchcraft-filter-panel.js +6 -5
- package/dist/components/searchcraft-filter-panel.js.map +1 -1
- package/dist/components/searchcraft-input-form.js +2 -2
- package/dist/components/searchcraft-input-label.js +1 -1
- package/dist/components/searchcraft-pagination.js +3 -9
- package/dist/components/searchcraft-pagination.js.map +1 -1
- package/dist/components/searchcraft-popover-button.js +2 -2
- package/dist/components/searchcraft-popover-button.js.map +1 -1
- package/dist/components/searchcraft-popover-form.js +14 -15
- package/dist/components/searchcraft-popover-form.js.map +1 -1
- package/dist/components/searchcraft-popover-list-item.js +1 -1
- package/dist/components/searchcraft-popover-list-view.js +1 -1
- package/dist/components/searchcraft-results-info.js +15 -19
- package/dist/components/searchcraft-results-info.js.map +1 -1
- package/dist/components/searchcraft-search-result.d.ts +11 -0
- package/dist/components/searchcraft-search-result.js +8 -0
- package/dist/components/searchcraft-search-result.js.map +1 -0
- package/dist/components/searchcraft-search-results-per-page.js +3 -10
- package/dist/components/searchcraft-search-results-per-page.js.map +1 -1
- package/dist/components/searchcraft-search-results.d.ts +11 -0
- package/dist/components/{searchcraft-base-search-results.js → searchcraft-search-results.js} +25 -71
- package/dist/components/searchcraft-search-results.js.map +1 -0
- package/dist/components/searchcraft-select.js +1 -1
- package/dist/components/searchcraft-slider.js +1 -1
- package/dist/components/searchcraft-theme.js +4 -42
- package/dist/components/searchcraft-theme.js.map +1 -1
- package/dist/components/searchcraft-toggle-button.js +1 -1
- package/dist/hydrate/index.d.ts +242 -0
- package/dist/hydrate/index.js +23290 -0
- package/dist/hydrate/index.mjs +23282 -0
- package/dist/hydrate/package.json +12 -0
- package/dist/types/components/searchcraft-ad/searchcraft-ad.d.ts +2 -0
- package/dist/types/components/searchcraft-button/searchcraft-button.d.ts +3 -2
- package/dist/types/components/searchcraft-error-message/searchcraft-error-message.d.ts +6 -7
- package/dist/types/components/searchcraft-facet-list/searchcraft-facet-list.d.ts +3 -1
- package/dist/types/components/searchcraft-filter-panel/searchcraft-filter-panel.d.ts +29 -1
- package/dist/types/components/searchcraft-input-form/searchcraft-input-form.d.ts +22 -14
- package/dist/types/components/searchcraft-input-label/searchcraft-input-label.d.ts +3 -2
- package/dist/types/components/searchcraft-pagination/searchcraft-pagination.d.ts +21 -8
- package/dist/types/components/searchcraft-popover-button/searchcraft-popover-button.d.ts +30 -0
- package/dist/types/components/searchcraft-popover-form/searchcraft-popover-form.d.ts +26 -15
- package/dist/types/components/searchcraft-popover-list-item/searchcraft-popover-list-item.d.ts +2 -0
- package/dist/types/components/searchcraft-popover-list-view/searchcraft-popover-list-view.d.ts +3 -2
- package/dist/types/components/searchcraft-results-info/searchcraft-results-info.d.ts +41 -15
- package/dist/types/components/searchcraft-search-result/searchcraft-search-result.d.ts +25 -0
- package/dist/types/components/searchcraft-search-results/searchcraft-search-results.d.ts +80 -0
- package/dist/types/components/searchcraft-search-results-per-page/searchcraft-search-results-per-page.d.ts +20 -5
- package/dist/types/components/searchcraft-select/searchcraft-select.d.ts +3 -5
- package/dist/types/components/searchcraft-slider/searchcraft-slider.d.ts +3 -3
- package/dist/types/components/searchcraft-theme/searchcraft-theme.d.ts +23 -16
- package/dist/types/components/searchcraft-toggle-button/searchcraft-toggle-button.d.ts +2 -1
- package/dist/types/components.d.ts +836 -612
- package/dist/types/index.d.ts +5 -4
- package/dist/types/utils/html.d.ts +6 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/package.json +9 -7
- package/dist/components/bundled.types.d.ts +0 -2275
- package/dist/components/p-0e393fe1.js.map +0 -1
- package/dist/components/p-19fe91f1.js +0 -136
- package/dist/components/p-19fe91f1.js.map +0 -1
- package/dist/components/p-4df578e4.js.map +0 -1
- package/dist/components/p-580c09dc.js.map +0 -1
- package/dist/components/p-5fdaf1e6.js.map +0 -1
- package/dist/components/p-60f05735.js.map +0 -1
- package/dist/components/p-71cc28c1.js.map +0 -1
- package/dist/components/p-8f854dec.js.map +0 -1
- package/dist/components/p-bb12ab5a.js.map +0 -1
- package/dist/components/p-bf6a086a.js.map +0 -1
- package/dist/components/p-d9551738.js +0 -25
- package/dist/components/p-d9551738.js.map +0 -1
- package/dist/components/p-e27a0dab.js.map +0 -1
- package/dist/components/p-e41b0f43.js.map +0 -1
- package/dist/components/p-e55a7970.js.map +0 -1
- package/dist/components/searchcraft-base-search-result.d.ts +0 -11
- package/dist/components/searchcraft-base-search-result.js +0 -8
- package/dist/components/searchcraft-base-search-result.js.map +0 -1
- package/dist/components/searchcraft-base-search-results.d.ts +0 -11
- package/dist/components/searchcraft-base-search-results.js.map +0 -1
- package/dist/types/components/searchcraft-base-search-result/searchcraft-base-search-result.d.ts +0 -55
- package/dist/types/components/searchcraft-base-search-results/searchcraft-base-search-results.d.ts +0 -89
package/dist/components/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export { g as getAssetPath, s as setAssetPath, a as setNonce, b as setPlatformOptions } from './p-5365011f.js';
|
|
2
|
-
import { v as ve } from './p-
|
|
3
|
-
export { s as searchcraftStore } from './p-
|
|
2
|
+
import { v as ve } from './p-f8df3d49.js';
|
|
3
|
+
export { v as SearchcraftCore, s as searchcraftStore } from './p-f8df3d49.js';
|
|
4
|
+
import './p-a64b4cba.js';
|
|
4
5
|
export { SearchcraftAd, defineCustomElement as defineCustomElementSearchcraftAd } from './searchcraft-ad.js';
|
|
5
|
-
export { SearchcraftBaseSearchResult, defineCustomElement as defineCustomElementSearchcraftBaseSearchResult } from './searchcraft-base-search-result.js';
|
|
6
|
-
export { SearchcraftBaseSearchResults, defineCustomElement as defineCustomElementSearchcraftBaseSearchResults } from './searchcraft-base-search-results.js';
|
|
7
6
|
export { SearchcraftButton, defineCustomElement as defineCustomElementSearchcraftButton } from './searchcraft-button.js';
|
|
8
7
|
export { SearchcraftErrorMessage, defineCustomElement as defineCustomElementSearchcraftErrorMessage } from './searchcraft-error-message.js';
|
|
9
8
|
export { SearchcraftFacetList, defineCustomElement as defineCustomElementSearchcraftFacetList } from './searchcraft-facet-list.js';
|
|
@@ -16,22 +15,21 @@ export { SearchcraftPopoverForm, defineCustomElement as defineCustomElementSearc
|
|
|
16
15
|
export { SearchcraftPopoverListItem, defineCustomElement as defineCustomElementSearchcraftPopoverListItem } from './searchcraft-popover-list-item.js';
|
|
17
16
|
export { SearchcraftPopoverListView, defineCustomElement as defineCustomElementSearchcraftPopoverListView } from './searchcraft-popover-list-view.js';
|
|
18
17
|
export { SearchcraftResultsInfo, defineCustomElement as defineCustomElementSearchcraftResultsInfo } from './searchcraft-results-info.js';
|
|
18
|
+
export { SearchcraftSearchResult, defineCustomElement as defineCustomElementSearchcraftSearchResult } from './searchcraft-search-result.js';
|
|
19
|
+
export { SearchcraftSearchResults, defineCustomElement as defineCustomElementSearchcraftSearchResults } from './searchcraft-search-results.js';
|
|
19
20
|
export { SearchcraftSearchResultsPerPage, defineCustomElement as defineCustomElementSearchcraftSearchResultsPerPage } from './searchcraft-search-results-per-page.js';
|
|
20
21
|
export { SearchcraftSelect, defineCustomElement as defineCustomElementSearchcraftSelect } from './searchcraft-select.js';
|
|
21
22
|
export { SearchcraftSlider, defineCustomElement as defineCustomElementSearchcraftSlider } from './searchcraft-slider.js';
|
|
22
23
|
export { SearchcraftTheme, defineCustomElement as defineCustomElementSearchcraftTheme } from './searchcraft-theme.js';
|
|
23
24
|
export { SearchcraftToggleButton, defineCustomElement as defineCustomElementSearchcraftToggleButton } from './searchcraft-toggle-button.js';
|
|
24
|
-
export { p as parseCustomStyles, s as serializeStyles } from './p-d9551738.js';
|
|
25
25
|
|
|
26
26
|
const name = "@searchcraft/javascript-sdk";
|
|
27
|
-
const version = "0.
|
|
27
|
+
const version = "0.10.0";
|
|
28
28
|
const description = "Searchcraft Javascript SDK";
|
|
29
|
-
const author = "Searchcraft";
|
|
29
|
+
const author = "Searchcraft Inc.";
|
|
30
30
|
const license = "Apache-2.0";
|
|
31
31
|
const module = "dist/components/index.js";
|
|
32
32
|
const types = "dist/components/index.d.ts";
|
|
33
|
-
const collection = "dist/collection/collection-manifest.json";
|
|
34
|
-
const unpkg = "dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js";
|
|
35
33
|
const exports = {
|
|
36
34
|
".": {
|
|
37
35
|
"import": "./dist/components/index.js",
|
|
@@ -40,6 +38,11 @@ const exports = {
|
|
|
40
38
|
"./dist/components/*": {
|
|
41
39
|
"import": "./dist/components/*",
|
|
42
40
|
types: "./dist/components/*"
|
|
41
|
+
},
|
|
42
|
+
"./hydrate": {
|
|
43
|
+
require: "./dist/hydrate/index.js",
|
|
44
|
+
"import": "./dist/hydrate/index.mjs",
|
|
45
|
+
types: "./dist/hydrate/index.d.ts"
|
|
43
46
|
}
|
|
44
47
|
};
|
|
45
48
|
const repository = {
|
|
@@ -63,7 +66,7 @@ const dependencies = {
|
|
|
63
66
|
nanoid: "^5.0.9"
|
|
64
67
|
};
|
|
65
68
|
const devDependencies = {
|
|
66
|
-
"@searchcraft/core": "^0.
|
|
69
|
+
"@searchcraft/core": "^0.10.0",
|
|
67
70
|
"@stencil/core": "^4.7.0",
|
|
68
71
|
"@stencil/react-output-target": "^0.8.2",
|
|
69
72
|
"@stencil/sass": "^3.0.12",
|
|
@@ -80,9 +83,6 @@ const packageJson = {
|
|
|
80
83
|
license: license,
|
|
81
84
|
module: module,
|
|
82
85
|
types: types,
|
|
83
|
-
collection: collection,
|
|
84
|
-
"collection:main": "dist/collection/index.js",
|
|
85
|
-
unpkg: unpkg,
|
|
86
86
|
exports: exports,
|
|
87
87
|
repository: repository,
|
|
88
88
|
files: files,
|
|
@@ -91,6 +91,37 @@ const packageJson = {
|
|
|
91
91
|
devDependencies: devDependencies
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
+
function parseCustomStyles(styles) {
|
|
95
|
+
if (typeof styles === 'string') {
|
|
96
|
+
try {
|
|
97
|
+
return JSON.parse(styles);
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
console.error('Invalid customStyles format:', styles);
|
|
101
|
+
return {};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return styles || {};
|
|
105
|
+
}
|
|
106
|
+
function serializeStyles(styles) {
|
|
107
|
+
try {
|
|
108
|
+
return JSON.stringify(styles);
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
console.error('Error serializing styles:', error);
|
|
112
|
+
return '{}';
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @fileoverview entry point for your component library
|
|
118
|
+
*
|
|
119
|
+
* This is the entry point for your component library. Use this file to export utilities,
|
|
120
|
+
* constants or data structure that accompany your components.
|
|
121
|
+
*
|
|
122
|
+
* DO NOT use this file to export your components. Instead, use the recommended approaches
|
|
123
|
+
* to consume components of this package as outlined in the `README.md`.
|
|
124
|
+
*/
|
|
94
125
|
/**
|
|
95
126
|
* The consumer-facing `Searchcraft` class.
|
|
96
127
|
*/
|
|
@@ -103,7 +134,7 @@ class Searchcraft extends ve {
|
|
|
103
134
|
}
|
|
104
135
|
}
|
|
105
136
|
|
|
106
|
-
export { Searchcraft };
|
|
137
|
+
export { Searchcraft, parseCustomStyles, serializeStyles };
|
|
107
138
|
|
|
108
139
|
//# sourceMappingURL=index.js.map
|
|
109
140
|
export { defineCustomElements } from './defineCustomElements.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"file":"index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAAgB,iBAAiB,CAC/B,MAAuC;IAEvC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,IAAI;YACF,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SAC3B;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,MAAM,CAAC,CAAC;YACtD,OAAO,EAAE,CAAC;SACX;KACF;IACD,OAAO,MAAM,IAAI,EAAE,CAAC;AACtB,CAAC;SAEe,eAAe,CAC7B,MAA8C;IAE9C,IAAI;QACF,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;KAC/B;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC;KACb;AACH;;ACnBA;;;;;;;;;AAUA;;;MAGa,WAAY,SAAQA,EAAe;IAC9C,YAAY,MAAyB;QACnC,KAAK,CAAC,MAAM,EAAE;YACZ,OAAO,EAAE,WAAW,CAAC,IAAI;YACzB,UAAU,EAAE,WAAW,CAAC,OAAO;SAChC,CAAC,CAAC;KACJ;;;;;","names":["SearchcraftCore"],"sources":["src/utils/styles.ts","src/index.ts"],"sourcesContent":["export function parseCustomStyles(\n styles: string | Record<string, string>,\n): Record<string, string> {\n if (typeof styles === 'string') {\n try {\n return JSON.parse(styles);\n } catch (error) {\n console.error('Invalid customStyles format:', styles);\n return {};\n }\n }\n return styles || {};\n}\n\nexport function serializeStyles(\n styles: Record<string, Record<string, string>>,\n): string {\n try {\n return JSON.stringify(styles);\n } catch (error) {\n console.error('Error serializing styles:', error);\n return '{}';\n }\n}\n","import { type SearchcraftConfig, SearchcraftCore } from '@searchcraft/core';\nimport { searchcraftStore } from '@store';\nimport packageJson from '../package.json';\n\n/**\n * @fileoverview entry point for your component library\n *\n * This is the entry point for your component library. Use this file to export utilities,\n * constants or data structure that accompany your components.\n *\n * DO NOT use this file to export your components. Instead, use the recommended approaches\n * to consume components of this package as outlined in the `README.md`.\n */\n\n/**\n * The consumer-facing `Searchcraft` class.\n */\nexport class Searchcraft extends SearchcraftCore {\n constructor(config: SearchcraftConfig) {\n super(config, {\n sdkName: packageJson.name,\n sdkVersion: packageJson.version,\n });\n }\n}\n\n/**\n * Exports the shared types that all SDKs need\n */\nexport {\n parseCustomStyles,\n serializeStyles,\n} from './utils';\nexport type { SearchcraftConfig };\nexport { searchcraftStore };\nexport type { Components, JSX } from './components';\nexport { SearchcraftCore };\nexport type * from '@searchcraft/core/dist/types/sdk-types';\n"],"version":3}
|
|
@@ -12,7 +12,7 @@ const SearchcraftInputLabel = /*@__PURE__*/ proxyCustomElement(class Searchcraft
|
|
|
12
12
|
inputLabelClassName = '';
|
|
13
13
|
label = '';
|
|
14
14
|
render() {
|
|
15
|
-
return (h("label", { key: '
|
|
15
|
+
return (h("label", { key: '3622c616d480e57b1dfaa2d61637a30b843cb968', class: classNames('searchcraft-input-label', this.inputLabelClassName), htmlFor: 'searchcraft-input-id' }, this.label));
|
|
16
16
|
}
|
|
17
17
|
}, [0, "searchcraft-input-label", {
|
|
18
18
|
"inputLabelClassName": [1, "input-label-class-name"],
|
|
@@ -34,4 +34,4 @@ function defineCustomElement() {
|
|
|
34
34
|
|
|
35
35
|
export { SearchcraftInputLabel as S, defineCustomElement as d };
|
|
36
36
|
|
|
37
|
-
//# sourceMappingURL=p-
|
|
37
|
+
//# sourceMappingURL=p-1adf78b9.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"p-1adf78b9.js","mappings":";;;MAiBa,qBAAqB;;;;;;;;IAIxB,mBAAmB,GAAI,EAAE,CAAC;IAC1B,KAAK,GAAG,EAAE,CAAC;IAEnB,MAAM;QACJ,QACE,8DACE,KAAK,EAAE,UAAU,CAAC,yBAAyB,EAAE,IAAI,CAAC,mBAAmB,CAAC,EACtE,OAAO,EAAC,sBAAsB,IAE7B,IAAI,CAAC,KAAK,CACL,EACR;KACH;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/searchcraft-input-label/searchcraft-input-label.tsx"],"sourcesContent":["import { Component, Prop, h } from '@stencil/core';\nimport classNames from 'classnames';\n\n/**\n * This web component serves as the input label for the searchcraft-input-form component.\n *\n * @js-example\n * ```html\n * <searchcraft-input-label label=\"Search\" />\n * ```\n *\n * @internal\n */\n@Component({\n tag: 'searchcraft-input-label',\n shadow: false,\n})\nexport class SearchcraftInputLabel {\n /**\n * The classname applied to the label element.\n */\n @Prop() inputLabelClassName? = '';\n @Prop() label = '';\n\n render() {\n return (\n <label\n class={classNames('searchcraft-input-label', this.inputLabelClassName)}\n htmlFor='searchcraft-input-id'\n >\n {this.label}\n </label>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { p as proxyCustomElement, H, h } from './p-5365011f.js';
|
|
2
|
-
import { n as nanoid, d as defineCustomElement$2 } from './p-
|
|
3
|
-
import { s as searchcraftStore } from './p-
|
|
4
|
-
import { d as defineCustomElement$1 } from './p-
|
|
2
|
+
import { n as nanoid, d as defineCustomElement$2 } from './p-e72d0167.js';
|
|
3
|
+
import { s as searchcraftStore } from './p-f8df3d49.js';
|
|
4
|
+
import { d as defineCustomElement$1 } from './p-8aa0fff5.js';
|
|
5
5
|
|
|
6
6
|
const SearchcraftPopoverListView = /*@__PURE__*/ proxyCustomElement(class SearchcraftPopoverListView extends H {
|
|
7
7
|
constructor() {
|
|
@@ -131,4 +131,4 @@ function defineCustomElement() {
|
|
|
131
131
|
|
|
132
132
|
export { SearchcraftPopoverListView as S, defineCustomElement as d };
|
|
133
133
|
|
|
134
|
-
//# sourceMappingURL=p-
|
|
134
|
+
//# sourceMappingURL=p-34a32648.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"p-34a32648.js","mappings":";;;;;MAyBa,0BAA0B;;;;;;;;;IAK7B,qBAAqB,CAAoC;;;;IAIzD,yBAAyB,CAA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,CAAC,qBAAqB,EACjD,gBAAgB,EACd,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC,GAAG,KAAK,GAElE,CACH,CAAC;SACH,CAAC,CAAC;;QAGH,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,EAAE,CAAC,EAAE,EAAE;YACtC,aAAa,CAAC,IAAI,CAChB,sBACE,QAAQ,EAAC,QAAQ,EACjB,aAAa,EAAE,MAAM,EAAE,EACvB,GAAG,EAAE,GAAG,CAAC,KAAK,GACd,CACH,CAAC;SACH;QAED,OAAO,WAAK,KAAK,EAAC,+BAA+B,IAAE,aAAa,CAAO,CAAC;KACzE;IAED,eAAe;QACb,QACE,WAAK,KAAK,EAAC,+BAA+B,IACvC,IAAI,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,MAC/C,qCACE,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,IAAI,CAAC,EAAE,EACZ,qBAAqB,EAAE,IAAI,CAAC,qBAAqB,EACjD,gBAAgB,EACd,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC,GAAG,KAAK,GAElE,CACH,CAAC,CACE,EACN;KACH;IAED,MAAM;QACJ,QAAQ,IAAI,CAAC,MAAM,EAAE,QAAQ,IAAI,MAAM;YACrC,KAAK,eAAe;gBAClB,OAAO,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACjC,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACpC,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACpC;gBACE,OAAO,IAAI,CAAC,eAAe,EAAE,CAAC;SACjC;KACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/searchcraft-popover-list-view/searchcraft-popover-list-view.tsx"],"sourcesContent":["import type {\n AdClientResponseItem,\n SearchClientResponseItem,\n} from '@searchcraft/core';\nimport { Component, h, Prop, type JSX } from '@stencil/core';\nimport { nanoid } from 'nanoid';\n\nimport type { PopoverResultMappings } from '@searchcraft/core';\nimport { searchcraftStore } from '@store';\n\n/**\n * This web component is designed to display a list of results within a popover interface.\n * It is consumed within the `searchcraft-popover-form` component.\n *\n * @js-example\n * ```html\n * <searchcraft-popover-list-view />\n * ```\n *\n * @internal\n */\n@Component({\n tag: 'searchcraft-popover-list-view',\n shadow: false,\n})\nexport class SearchcraftPopoverListView {\n /**\n * The mappings that define how the data in the documents are mapped to the\n * list-view-item elements.\n */\n @Prop() popoverResultMappings: PopoverResultMappings | undefined;\n /**\n * The items to render in the list view.\n */\n @Prop() searchClientResponseItems: SearchClientResponseItem[] | undefined;\n @Prop() adClientResponseItems: AdClientResponseItem[] | undefined;\n @Prop() searchResultsPage!: number;\n @Prop() searchResultsPerPage!: number;\n\n private config = searchcraftStore.getState().core?.config;\n\n renderWithADMAds() {\n return (\n <div class='searchcraft-popover-list-view'>\n {this.adClientResponseItems?.map((item) => (\n <searchcraft-ad\n adClientResponseItem={item}\n adContainerId={nanoid()}\n adSource='adMarketplace'\n key={item.id}\n />\n ))}\n {this.searchClientResponseItems?.map((item, index) => (\n <searchcraft-popover-list-item\n item={item}\n key={item.id}\n popoverResultMappings={this.popoverResultMappings}\n documentPosition={\n this.searchResultsPerPage * (this.searchResultsPage - 1) + index\n }\n />\n ))}\n </div>\n );\n }\n\n renderWithCustomAds() {\n const itemsToRender: JSX.Element[] = [];\n const interstitialInterval = this.config?.customAdInterstitialInterval || 0;\n const interstitialQuantity = this.config?.customAdInterstitialQuantity || 1;\n const adStartQuantity = this.config?.customAdStartQuantity || 0;\n const adEndQuantity = this.config?.customAdEndQuantity || 0;\n const searchItems = this.searchClientResponseItems || [];\n\n // Renders ads at beginning\n for (let n = 0; n < adStartQuantity; n++) {\n itemsToRender.push(\n <searchcraft-ad\n adSource='Custom'\n adContainerId={nanoid()}\n key={`${n}-ad`}\n />,\n );\n }\n\n // Renders search results + interstitial ads\n searchItems.forEach((item, index) => {\n if (\n interstitialInterval &&\n index % interstitialInterval === 0 &&\n index + interstitialInterval < searchItems.length &&\n index >= interstitialInterval\n ) {\n for (let n = 0; n < interstitialQuantity; n++) {\n itemsToRender.push(\n <searchcraft-ad\n adSource='Custom'\n adContainerId={nanoid()}\n key={`${item.id}-ad-${n}`}\n />,\n );\n }\n }\n\n itemsToRender.push(\n <searchcraft-popover-list-item\n item={item}\n key={item.id}\n popoverResultMappings={this.popoverResultMappings}\n documentPosition={\n this.searchResultsPerPage * (this.searchResultsPage - 1) + index\n }\n />,\n );\n });\n\n // Renders ads at end\n for (let n = 0; n < adEndQuantity; n++) {\n itemsToRender.push(\n <searchcraft-ad\n adSource='Custom'\n adContainerId={nanoid()}\n key={`${n}-ad`}\n />,\n );\n }\n\n return <div class='searchcraft-popover-list-view'>{itemsToRender}</div>;\n }\n\n renderWithNativoAds() {\n const itemsToRender: JSX.Element[] = [];\n const interstitialStartIndex =\n this.config?.nativoAdInterstialStartIndex || 0;\n const interstitialInterval = this.config?.nativoAdInterstitialInterval || 0;\n const interstitialQuantity = this.config?.nativoAdInterstitialQuantity || 1;\n const adStartQuantity = this.config?.nativoAdStartQuantity || 0;\n const adEndQuantity = this.config?.nativoAdEndQuantity || 0;\n const searchItems = this.searchClientResponseItems || [];\n\n // Renders ads at beginning\n for (let n = 0; n < adStartQuantity; n++) {\n itemsToRender.push(\n <searchcraft-ad\n adSource='Nativo'\n adContainerId={nanoid()}\n key={`${n}-ad`}\n />,\n );\n }\n\n // Renders search results + interstitial ads\n searchItems.forEach((item, index) => {\n if (\n interstitialInterval &&\n (index + interstitialStartIndex) % interstitialInterval === 0 &&\n index + interstitialInterval < searchItems.length &&\n index >= interstitialInterval\n ) {\n for (let n = 0; n < interstitialQuantity; n++) {\n itemsToRender.push(\n <searchcraft-ad\n adSource='Nativo'\n adContainerId={nanoid()}\n key={`${item.id}-ad-${n}`}\n />,\n );\n }\n }\n\n itemsToRender.push(\n <searchcraft-popover-list-item\n item={item}\n key={item.id}\n popoverResultMappings={this.popoverResultMappings}\n documentPosition={\n this.searchResultsPerPage * (this.searchResultsPage - 1) + index\n }\n />,\n );\n });\n\n // Renders ads at end\n for (let n = 0; n < adEndQuantity; n++) {\n itemsToRender.push(\n <searchcraft-ad\n adSource='Nativo'\n adContainerId={nanoid()}\n key={`${n}-ad`}\n />,\n );\n }\n\n return <div class='searchcraft-popover-list-view'>{itemsToRender}</div>;\n }\n\n renderWithNoAds() {\n return (\n <div class='searchcraft-popover-list-view'>\n {this.searchClientResponseItems?.map((item, index) => (\n <searchcraft-popover-list-item\n item={item}\n key={item.id}\n popoverResultMappings={this.popoverResultMappings}\n documentPosition={\n this.searchResultsPerPage * (this.searchResultsPage - 1) + index\n }\n />\n ))}\n </div>\n );\n }\n\n render() {\n switch (this.config?.adSource || 'None') {\n case 'adMarketplace':\n return this.renderWithADMAds();\n case 'Custom':\n return this.renderWithCustomAds();\n case 'Nativo':\n return this.renderWithNativoAds();\n default:\n return this.renderWithNoAds();\n }\n }\n}\n"],"version":3}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { p as proxyCustomElement, H, h } from './p-5365011f.js';
|
|
2
|
+
import { h as html } from './p-810a7850.js';
|
|
3
|
+
|
|
4
|
+
const SearchcraftSearchResult = /*@__PURE__*/ proxyCustomElement(class SearchcraftSearchResult extends H {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
this.__registerHost();
|
|
8
|
+
}
|
|
9
|
+
item;
|
|
10
|
+
/**
|
|
11
|
+
* The index.
|
|
12
|
+
*/
|
|
13
|
+
index;
|
|
14
|
+
/**
|
|
15
|
+
* The position in the document. Used with the "document_clicked" measure event.
|
|
16
|
+
*/
|
|
17
|
+
documentPosition = 0;
|
|
18
|
+
/**
|
|
19
|
+
* A callback function responsible for rendering a result.
|
|
20
|
+
*/
|
|
21
|
+
template;
|
|
22
|
+
templateHtml;
|
|
23
|
+
connectedCallback() {
|
|
24
|
+
if (this.item) {
|
|
25
|
+
try {
|
|
26
|
+
this.templateHtml = this.template?.(this.item.document, this.index, {
|
|
27
|
+
html,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
console.error(`Invalid search result template: ${error}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
render() {
|
|
36
|
+
if (!this.item) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (typeof this.template === 'undefined') {
|
|
40
|
+
return (h("div", { class: 'searchcraft-search-result searchcraft-search-result-no-template' }, Object.entries(this.item.document).map(([key, value]) => (h("p", { key: key }, h("strong", null, key), ": ", value)))));
|
|
41
|
+
}
|
|
42
|
+
return (h("div", { class: 'searchcraft-search-result', innerHTML: this.templateHtml }));
|
|
43
|
+
}
|
|
44
|
+
}, [0, "searchcraft-search-result", {
|
|
45
|
+
"item": [16],
|
|
46
|
+
"index": [2],
|
|
47
|
+
"documentPosition": [2, "document-position"],
|
|
48
|
+
"template": [16],
|
|
49
|
+
"templateHtml": [32]
|
|
50
|
+
}]);
|
|
51
|
+
function defineCustomElement() {
|
|
52
|
+
if (typeof customElements === "undefined") {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const components = ["searchcraft-search-result"];
|
|
56
|
+
components.forEach(tagName => { switch (tagName) {
|
|
57
|
+
case "searchcraft-search-result":
|
|
58
|
+
if (!customElements.get(tagName)) {
|
|
59
|
+
customElements.define(tagName, SearchcraftSearchResult);
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
} });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { SearchcraftSearchResult as S, defineCustomElement as d };
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=p-39e70a00.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"p-39e70a00.js","mappings":";;;MAkBa,uBAAuB;;;;;IAC1B,IAAI,CAA4B;;;;IAIhC,KAAK,CAAU;;;;IAIf,gBAAgB,GAAG,CAAC,CAAC;;;;IAIrB,QAAQ,CAAkD;IAEzD,YAAY,CAAqB;IAE1C,iBAAiB;QACf,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,IAAI;gBACF,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,EAAE;oBAClE,IAAI;iBACL,CAAC,CAAC;aACJ;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,CAAC,KAAK,CAAC,mCAAmC,KAAK,EAAE,CAAC,CAAC;aAC3D;SACF;KACF;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACd,OAAO;SACR;QAED,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,WAAW,EAAE;YACxC,QACE,WAAK,KAAK,EAAC,iEAAiE,IACzE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,MACnD,SAAG,GAAG,EAAE,GAAG,IACT,kBAAS,GAAG,CAAU,QAAG,KAAK,CAC5B,CACL,CAAC,CACE,EACN;SACH;QAED,QACE,WAAK,KAAK,EAAC,2BAA2B,EAAC,SAAS,EAAE,IAAI,CAAC,YAAY,GAAI,EACvE;KACH;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/searchcraft-search-result/searchcraft-search-result.tsx"],"sourcesContent":["import type {\n SearchClientResponseItem,\n SearchResultTemplate,\n SearchResultTemplateData,\n} from '@searchcraft/core';\nimport { Component, h, Prop, State } from '@stencil/core';\n\nimport { html } from '@utils';\n\n/**\n * This web component is designed to display detailed information for a single search result. Once a query is submitted, the component formats and presents the result.\n *\n * @internal\n */\n@Component({\n tag: 'searchcraft-search-result',\n shadow: false,\n})\nexport class SearchcraftSearchResult {\n @Prop() item?: SearchClientResponseItem;\n /**\n * The index.\n */\n @Prop() index!: number;\n /**\n * The position in the document. Used with the \"document_clicked\" measure event.\n */\n @Prop() documentPosition = 0;\n /**\n * A callback function responsible for rendering a result.\n */\n @Prop() template?: SearchResultTemplate<SearchResultTemplateData>;\n\n @State() templateHtml: string | undefined;\n\n connectedCallback() {\n if (this.item) {\n try {\n this.templateHtml = this.template?.(this.item.document, this.index, {\n html,\n });\n } catch (error) {\n console.error(`Invalid search result template: ${error}`);\n }\n }\n }\n\n render() {\n if (!this.item) {\n return;\n }\n\n if (typeof this.template === 'undefined') {\n return (\n <div class='searchcraft-search-result searchcraft-search-result-no-template'>\n {Object.entries(this.item.document).map(([key, value]) => (\n <p key={key}>\n <strong>{key}</strong>: {value}\n </p>\n ))}\n </div>\n );\n }\n\n return (\n <div class='searchcraft-search-result' innerHTML={this.templateHtml} />\n );\n }\n}\n"],"version":3}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { p as proxyCustomElement, H, c as createEvent, h } from './p-5365011f.js';
|
|
2
2
|
import { c as classNames } from './p-5cdc6210.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { d as defineCustomElement$
|
|
6
|
-
import { d as defineCustomElement$
|
|
7
|
-
import { d as defineCustomElement$1 } from './p-e55a7970.js';
|
|
3
|
+
import { s as searchcraftStore } from './p-f8df3d49.js';
|
|
4
|
+
import { d as defineCustomElement$3 } from './p-acf23bab.js';
|
|
5
|
+
import { d as defineCustomElement$2 } from './p-f2585cdf.js';
|
|
6
|
+
import { d as defineCustomElement$1 } from './p-1adf78b9.js';
|
|
8
7
|
|
|
9
|
-
const
|
|
8
|
+
const SearchcraftInputForm = /*@__PURE__*/ proxyCustomElement(class SearchcraftInputForm extends H {
|
|
10
9
|
constructor() {
|
|
11
10
|
super();
|
|
12
11
|
this.__registerHost();
|
|
@@ -30,10 +29,6 @@ const SearchcraftInput = /*@__PURE__*/ proxyCustomElement(class SearchcraftInput
|
|
|
30
29
|
* The label rendered above the input.
|
|
31
30
|
*/
|
|
32
31
|
inputLabel;
|
|
33
|
-
/**
|
|
34
|
-
* A custom styles object to be applied to the input element.
|
|
35
|
-
*/
|
|
36
|
-
customStyles = {};
|
|
37
32
|
/**
|
|
38
33
|
* The input element's placeholder value.
|
|
39
34
|
*/
|
|
@@ -102,20 +97,19 @@ const SearchcraftInput = /*@__PURE__*/ proxyCustomElement(class SearchcraftInput
|
|
|
102
97
|
await this.performSearch(this.searchTerm);
|
|
103
98
|
};
|
|
104
99
|
render() {
|
|
105
|
-
const validatedCustomStyles = parseCustomStyles(this.customStyles);
|
|
106
100
|
const isShowingClearButton = this.inputValue.length > 0;
|
|
107
|
-
const inputGridClassNames = classNames('searchcraft-input-grid', {
|
|
108
|
-
'searchcraft-input-grid-
|
|
109
|
-
'searchcraft-input-grid-
|
|
110
|
-
'searchcraft-input-grid-
|
|
101
|
+
const inputGridClassNames = classNames('searchcraft-input-form-grid', {
|
|
102
|
+
'searchcraft-input-form-grid-button-left': this.buttonPlacement === 'left',
|
|
103
|
+
'searchcraft-input-form-grid-button-right': this.buttonPlacement === 'right',
|
|
104
|
+
'searchcraft-input-form-grid-button-none': this.buttonPlacement === 'none',
|
|
111
105
|
});
|
|
112
106
|
const shouldHaveVerticalGap = this.inputLabel || this.error;
|
|
113
107
|
const inputGridStyles = {
|
|
114
108
|
gap: shouldHaveVerticalGap ? '4px 8px' : '0px 8px',
|
|
115
109
|
};
|
|
116
|
-
return (h("form", { key: '
|
|
110
|
+
return (h("form", { key: '862f8059b6eaae8d7ac9bd3c9de8109dd60fab8f', class: 'searchcraft-input-form', onSubmit: this.handleFormSubmit }, h("div", { key: '34ff1c3cff4011c9a5f0af0ff690e3a12ad80907', class: inputGridClassNames, style: inputGridStyles }, h("div", { key: '820506482aeea17534c4113e601f3ba2254e7fe6', class: 'searchcraft-input-form-button' }, h("searchcraft-button", { key: '377a6d8e9835c40379dbd0842a2f0f53638845e1', onButtonClick: this.handleFormSubmit, label: this.buttonLabel })), this.inputLabel && (h("div", { key: '84d100df3793599fd3f6773d26028e43e41d1ab7', class: 'searchcraft-input-form-label' }, h("searchcraft-input-label", { key: 'cfa7eca0b2ab3b82dd6c0a5104c19c88881f52b5', label: this.inputLabel }))), this.error && (h("div", { key: '62d0e29e46ac922469e48aa822239cd645ea9c8d', class: 'searchcraft-input-form-error-message' }, h("searchcraft-error-message", { key: '8a989b4a2e1196b01de9082433a69d86f55910fb' }, "Something went wrong."))), h("div", { key: 'a3c4cd8ef20f909eec2d9e2f9515a65525fe612e', class: 'searchcraft-input-form-input-wrapper' }, h("input", { key: 'af23902c7f7a79ced427da3aadaa30736b68c8a7', autoComplete: 'off', class: 'searchcraft-input-form-input', onFocus: () => this.inputFocus?.emit(), onBlur: () => this.inputBlur?.emit(), onInput: (event) => {
|
|
117
111
|
this.handleOnInput(event);
|
|
118
|
-
}, placeholder: this.placeholderValue,
|
|
112
|
+
}, placeholder: this.placeholderValue, type: 'text', value: this.inputValue }), h("div", { key: '66176081ef8da6bd3065ad0eeb61a397ab0fadfc', class: 'searchcraft-input-form-input-icon' }, h("svg", { key: 'baac2f051f04a411acba0d5683255e9a37a27833', class: 'searchcraft-input-form-input-search-icon', viewBox: '0 0 20 20', fill: 'none', xmlns: 'http://www.w3.org/2000/svg', "aria-labelledby": 'searchcraft-title' }, h("title", { key: '24230d00bd0b9466fb414246836c2477630ec254' }, "Search icon"), h("path", { key: '9f1446fd1885cc63c26fa5acfcdbdb775547c5ee', d: 'M17.5 17.5L13.875 13.875M15.8333 9.16667C15.8333 12.8486 12.8486 15.8333 9.16667 15.8333C5.48477 15.8333 2.5 12.8486 2.5 9.16667C2.5 5.48477 5.48477 2.5 9.16667 2.5C12.8486 2.5 15.8333 5.48477 15.8333 9.16667Z', stroke: 'currentColor', "stroke-width": '1.5', "stroke-linecap": 'round', "stroke-linejoin": 'round' }))), isShowingClearButton && (h("button", { key: 'b9a42b46f7d470f6f1bbba5b95fd4031db9a1ebd', type: 'button', class: 'searchcraft-input-form-clear-button', onClick: this.handleClearInput }, h("svg", { key: 'cda07c19eb77c2d2d343ce8d1cf8c55c484107f2', class: 'searchcraft-input-form-clear-button-icon', viewBox: '0 0 22 22', fill: 'none', xmlns: 'http://www.w3.org/2000/svg', "aria-labelledby": 'icon-title' }, h("title", { key: '43ba26388dc06b6ff3c5441387db9ba621bcc08e' }, "Clear icon"), h("path", { key: '5f33de1e306548f1cf504e4e6c6548d51eba93d3', d: 'M14 8L8 14M8 8L14 14M21 11C21 16.5228 16.5228 21 11 21C5.47715 21 1 16.5228 1 11C1 5.47715 5.47715 1 11 1C16.5228 1 21 5.47715 21 11Z', stroke: 'currentColor', "stroke-width": '1.5', "stroke-linecap": 'round', "stroke-linejoin": 'round' }))))))));
|
|
119
113
|
}
|
|
120
114
|
static get watchers() { return {
|
|
121
115
|
"core": ["onCoreChange"]
|
|
@@ -125,7 +119,6 @@ const SearchcraftInput = /*@__PURE__*/ proxyCustomElement(class SearchcraftInput
|
|
|
125
119
|
"buttonPlacement": [1, "button-placement"],
|
|
126
120
|
"buttonLabel": [1, "button-label"],
|
|
127
121
|
"inputLabel": [1, "input-label"],
|
|
128
|
-
"customStyles": [1, "custom-styles"],
|
|
129
122
|
"placeholderValue": [1, "placeholder-value"],
|
|
130
123
|
"core": [16],
|
|
131
124
|
"inputValue": [32],
|
|
@@ -142,7 +135,7 @@ function defineCustomElement() {
|
|
|
142
135
|
components.forEach(tagName => { switch (tagName) {
|
|
143
136
|
case "searchcraft-input-form":
|
|
144
137
|
if (!customElements.get(tagName)) {
|
|
145
|
-
customElements.define(tagName,
|
|
138
|
+
customElements.define(tagName, SearchcraftInputForm);
|
|
146
139
|
}
|
|
147
140
|
break;
|
|
148
141
|
case "searchcraft-button":
|
|
@@ -163,6 +156,6 @@ function defineCustomElement() {
|
|
|
163
156
|
} });
|
|
164
157
|
}
|
|
165
158
|
|
|
166
|
-
export {
|
|
159
|
+
export { SearchcraftInputForm as S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C,QAAQ,EACb,KAAK,EAAC,qCAAqC,EAC3C,OAAO,EAAE,IAAI,CAAC,gBAAgB,IAE9B,4DACE,KAAK,EAAC,0CAA0C,EAChD,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,qBAClB,YAAY,IAE5B,6EAAyB,EACzB,6DACE,CAAC,EAAC,uIAAuI,EACzI,MAAM,EAAC,cAAc,kBACR,KAAK,oBACH,OAAO,qBACN,OAAO,GACvB,CACE,CACC,CACV,CACG,CACF,CACD,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/searchcraft-input-form/searchcraft-input-form.tsx"],"sourcesContent":["import {\n Component,\n h,\n Prop,\n State,\n Event,\n type EventEmitter,\n Watch,\n} from '@stencil/core';\nimport classNames from 'classnames';\n\nimport type { SearchcraftCore } from '@searchcraft/core';\n\nimport { searchcraftStore } from '@store';\n\n/**\n * This web component provides a user-friendly interface for querying an indexed dataset, enabling users to easily search large collections of data.\n * It abstracts the complexities of index-based searching, making it accessible to users of all technical levels.\n *\n * @import\n * ```jsx\n * // react\n * import { SearchcraftInputForm } from \"@searchcraft/react-sdk\";\n *\n * // vue\n * import { SearchcraftInputForm } from \"@searchcraft/vue-sdk\";\n * ```\n *\n * @js-example\n * ```html\n * <searchcraft-input-form auto-search />\n * ```\n *\n * @react-example\n * ```jsx\n * <SearchcraftInputForm autoSearch />\n * ```\n *\n * @vue-example\n * ```jsx\n * <SearchcraftInputForm autoSearch />\n * ```\n */\n@Component({\n tag: 'searchcraft-input-form',\n shadow: false,\n})\nexport class SearchcraftInputForm {\n /**\n * Whether or not to automatically submit the search term when the input changes.\n */\n @Prop() autoSearch?: boolean = true;\n /**\n * Where to place the search button.\n */\n @Prop() buttonPlacement?: 'left' | 'right' | 'none' = 'none';\n /**\n * The label for the submit button.\n */\n @Prop() buttonLabel?: string;\n /**\n * The label rendered above the input.\n */\n @Prop() inputLabel?: string;\n /**\n * The input element's placeholder value.\n */\n @Prop() placeholderValue?: string = 'Enter Search';\n /**\n * When the input becomes focused.\n */\n @Event() inputFocus?: EventEmitter<void>;\n /**\n * When the input becomes unfocused.\n */\n @Event() inputBlur?: EventEmitter<void>;\n /**\n * Event emitted when input initializes.\n */\n @Event() inputInit?: EventEmitter<void>;\n\n @State() inputValue = '';\n @State() searchTerm = '';\n @State() error = false;\n\n @Prop() core?: SearchcraftCore;\n\n private searchStore = searchcraftStore.getState();\n\n init() {\n if (this.core) {\n this.searchStore.initialize(this.core);\n this.inputInit?.emit();\n }\n }\n\n connectedCallback() {\n this.init();\n }\n\n @Watch('core')\n onCoreChange() {\n this.init();\n }\n\n handleOnInput = (event: Event) => {\n const input = event.target as HTMLInputElement;\n this.inputValue = input.value;\n\n if (!this.autoSearch) {\n return;\n }\n\n this.performSearch(input.value);\n };\n\n private performSearch = async (value: string) => {\n if (value === searchcraftStore.getState().searchTerm) {\n return;\n }\n\n this.searchTerm = value.trim();\n this.error = false;\n this.searchStore.setSearchTerm(this.searchTerm);\n\n try {\n await this.searchStore.search();\n } catch (error) {\n console.log(error);\n this.error = true;\n }\n };\n\n handleClearInput = () => {\n this.inputValue = '';\n this.searchTerm = '';\n this.searchStore.setSearchTerm('');\n this.searchStore.setSearchClientResponseItems([]);\n this.error = false;\n };\n\n handleFormSubmit = async (event: Event) => {\n event.preventDefault();\n await this.performSearch(this.searchTerm);\n };\n\n render() {\n const isShowingClearButton = this.inputValue.length > 0;\n const inputGridClassNames = classNames('searchcraft-input-form-grid', {\n 'searchcraft-input-form-grid-button-left':\n this.buttonPlacement === 'left',\n 'searchcraft-input-form-grid-button-right':\n this.buttonPlacement === 'right',\n 'searchcraft-input-form-grid-button-none':\n this.buttonPlacement === 'none',\n });\n const shouldHaveVerticalGap = this.inputLabel || this.error;\n const inputGridStyles = {\n gap: shouldHaveVerticalGap ? '4px 8px' : '0px 8px',\n };\n\n return (\n <form class='searchcraft-input-form' onSubmit={this.handleFormSubmit}>\n <div class={inputGridClassNames} style={inputGridStyles}>\n <div class='searchcraft-input-form-button'>\n <searchcraft-button\n onButtonClick={this.handleFormSubmit}\n label={this.buttonLabel}\n />\n </div>\n {this.inputLabel && (\n <div class='searchcraft-input-form-label'>\n <searchcraft-input-label label={this.inputLabel} />\n </div>\n )}\n {this.error && (\n <div class='searchcraft-input-form-error-message'>\n <searchcraft-error-message>\n Something went wrong.\n </searchcraft-error-message>\n </div>\n )}\n <div class='searchcraft-input-form-input-wrapper'>\n <input\n autoComplete='off'\n class='searchcraft-input-form-input'\n onFocus={() => this.inputFocus?.emit()}\n onBlur={() => this.inputBlur?.emit()}\n onInput={(event) => {\n this.handleOnInput(event);\n }}\n placeholder={this.placeholderValue}\n type='text'\n value={this.inputValue}\n />\n <div class='searchcraft-input-form-input-icon'>\n <svg\n class='searchcraft-input-form-input-search-icon'\n viewBox='0 0 20 20'\n fill='none'\n xmlns='http://www.w3.org/2000/svg'\n aria-labelledby='searchcraft-title'\n >\n <title>Search icon</title>\n <path\n d='M17.5 17.5L13.875 13.875M15.8333 9.16667C15.8333 12.8486 12.8486 15.8333 9.16667 15.8333C5.48477 15.8333 2.5 12.8486 2.5 9.16667C2.5 5.48477 5.48477 2.5 9.16667 2.5C12.8486 2.5 15.8333 5.48477 15.8333 9.16667Z'\n stroke='currentColor'\n stroke-width='1.5'\n stroke-linecap='round'\n stroke-linejoin='round'\n />\n </svg>\n </div>\n {isShowingClearButton && (\n <button\n type='button'\n class='searchcraft-input-form-clear-button'\n onClick={this.handleClearInput}\n >\n <svg\n class='searchcraft-input-form-clear-button-icon'\n viewBox='0 0 22 22'\n fill='none'\n xmlns='http://www.w3.org/2000/svg'\n aria-labelledby='icon-title'\n >\n <title>Clear icon</title>\n <path\n d='M14 8L8 14M8 8L14 14M21 11C21 16.5228 16.5228 21 11 21C5.47715 21 1 16.5228 1 11C1 5.47715 5.47715 1 11 1C16.5228 1 21 5.47715 21 11Z'\n stroke='currentColor'\n stroke-width='1.5'\n stroke-linecap='round'\n stroke-linejoin='round'\n />\n </svg>\n </button>\n )}\n </div>\n </div>\n </form>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { p as proxyCustomElement, H, c as createEvent, h } from './p-5365011f.js';
|
|
2
|
-
import { c as classNames } from './p-5cdc6210.js';
|
|
3
|
-
import { p as parseCustomStyles } from './p-d9551738.js';
|
|
4
2
|
|
|
5
3
|
const SearchcraftSelect = /*@__PURE__*/ proxyCustomElement(class SearchcraftSelect extends H {
|
|
6
4
|
constructor() {
|
|
@@ -36,10 +34,6 @@ const SearchcraftSelect = /*@__PURE__*/ proxyCustomElement(class SearchcraftSele
|
|
|
36
34
|
* The options for the select input.
|
|
37
35
|
*/
|
|
38
36
|
options = [];
|
|
39
|
-
/**
|
|
40
|
-
* A custom styles object.
|
|
41
|
-
*/
|
|
42
|
-
customStyles;
|
|
43
37
|
/**
|
|
44
38
|
* The event fired when the select is changed.
|
|
45
39
|
*/
|
|
@@ -54,11 +48,11 @@ const SearchcraftSelect = /*@__PURE__*/ proxyCustomElement(class SearchcraftSele
|
|
|
54
48
|
this.setSearchResultsPage(page);
|
|
55
49
|
}
|
|
56
50
|
render() {
|
|
57
|
-
return (h("div", { key: '
|
|
51
|
+
return (h("div", { key: '15ecbf48c824a161cd83bdab99dace8e44f1ab39', class: 'searchcraft-select' }, this.label && (h("label", { key: 'aba433ae9c27c9405099cffcef923c3ad22d7fda', class: 'searchcraft-select-label', id: this.labelId || `${this.inputId}-label`, htmlFor: this.inputId }, this.label)), h("div", { key: '8df8a2ff05924c9c55cdd6e3827cd927cddab82a', class: 'searchcraft-select-input-wrapper' }, h("select", { key: '1d5f492c2255f8ca1b6ea5e04a2726dda2f2c52f', "aria-labelledby": this.label ? this.labelId || `${this.inputId}-label` : undefined, class: 'searchcraft-select-input', disabled: this.disabled, id: this.inputId, name: this.name, onChange: this.handleSelectChange }, (typeof this.options === 'string'
|
|
58
52
|
? JSON.parse(this.options)
|
|
59
53
|
: this.options).map(({ label, value, selected }) => {
|
|
60
54
|
return (h("option", { key: value, value: value, selected: selected }, label));
|
|
61
|
-
})), h("svg", { key: '
|
|
55
|
+
})), h("svg", { key: '0ec6892b529f2e70027aadea47208582a65a97b7', class: 'searchcraft-select-input-icon', width: '20', height: '20', viewBox: '0 0 20 20', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' }, h("title", { key: 'bced6b62378491d1d1c629b602d7d033d912c761' }, "Select dropdown icon"), h("path", { key: '659f8ebf9129e2e7941da949d29688c41c1472bb', d: 'M5 7.5L10 12.5L15 7.5', stroke: 'currentColor', "stroke-width": '1.5', "stroke-linecap": 'round', "stroke-linejoin": 'round' }))), this.caption && (h("p", { key: '51217d926f68f79b6c3514f5fd769b56549fdce9', class: 'searchcraft-select-caption' }, this.caption))));
|
|
62
56
|
}
|
|
63
57
|
}, [0, "searchcraft-select", {
|
|
64
58
|
"caption": [1],
|
|
@@ -68,7 +62,6 @@ const SearchcraftSelect = /*@__PURE__*/ proxyCustomElement(class SearchcraftSele
|
|
|
68
62
|
"labelId": [1, "label-id"],
|
|
69
63
|
"name": [1],
|
|
70
64
|
"options": [1],
|
|
71
|
-
"customStyles": [1, "custom-styles"],
|
|
72
65
|
"searchResultsPerPage": [32],
|
|
73
66
|
"setSearchResultsPage": [32],
|
|
74
67
|
"setSearchResultsPerPage": [32]
|
|
@@ -89,4 +82,4 @@ function defineCustomElement() {
|
|
|
89
82
|
|
|
90
83
|
export { SearchcraftSelect as S, defineCustomElement as d };
|
|
91
84
|
|
|
92
|
-
//# sourceMappingURL=p-
|
|
85
|
+
//# sourceMappingURL=p-73db9122.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"p-73db9122.js","mappings":";;MAkCa,iBAAiB;;;;;;;;;IAIpB,OAAO,CAAU;;;;IAIjB,QAAQ,GAAa,KAAK,CAAC;;;;IAI3B,OAAO,CAAU;;;;IAIjB,KAAK,CAAU;;;;I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AQ,EAAE,QAAQ,IACjD,KAAK,CACC,EACT;SACH,CAAC,CACK,EACT,4DACE,KAAK,EAAC,+BAA+B,EACrC,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,IAElC,uFAAmC,EACnC,6DACE,CAAC,EAAC,uBAAuB,EACzB,MAAM,EAAC,cAAc,kBACR,KAAK,oBACH,OAAO,qBACN,OAAO,GACvB,CACE,CACF,EACL,IAAI,CAAC,OAAO,KACX,0DAAG,KAAK,EAAC,4BAA4B,IAAE,IAAI,CAAC,OAAO,CAAK,CACzD,CACG,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/searchcraft-select/searchcraft-select.tsx"],"sourcesContent":["import {\n Component,\n h,\n State,\n Prop,\n type EventEmitter,\n Event,\n} from '@stencil/core';\n\nexport type SearchcraftSelectOption = {\n label: string;\n value: string | number;\n selected?: boolean;\n};\n\n/**\n * This web component is designed to allow users to select between a group of options.\n *\n * @js-example\n * ```html\n * <!-- index.html -->\n * <searchcraft-select\n * inputId=\"searchcraft-select\"\n * name=\"searchcraft-select\"\n * options=\"[{ label: 'label', value: 'value' }]\"\n * />\n * ```\n *\n * @internal\n */\n@Component({\n tag: 'searchcraft-select',\n shadow: false,\n})\nexport class SearchcraftSelect {\n /**\n * The caption displayed below the select input.\n */\n @Prop() caption?: string;\n /**\n * Whether the select input is disabled.\n */\n @Prop() disabled?: boolean = false;\n /**\n * The ID for the select input.\n */\n @Prop() inputId!: string;\n /**\n * The label of the select input.\n */\n @Prop() label?: string;\n /**\n * The ID for the label of the select input.\n */\n @Prop() labelId?: string;\n /**\n * The name of the select input.\n */\n @Prop() name!: string;\n /**\n * The options for the select input.\n */\n @Prop() options: SearchcraftSelectOption[] | string = [];\n /**\n * The event fired when the select is changed.\n */\n @Event() selectChange!: EventEmitter<string>;\n\n @State() searchResultsPerPage;\n\n @State() setSearchResultsPage: (page: number) => void = () => {};\n @State() setSearchResultsPerPage: (perPage: number) => void = () => {};\n\n private handleSelectChange = (event) => {\n this.selectChange.emit(event.target.value);\n };\n\n handleGoToPage(page: number) {\n this.setSearchResultsPage(page);\n }\n\n render() {\n return (\n <div class='searchcraft-select'>\n {this.label && (\n <label\n class='searchcraft-select-label'\n id={this.labelId || `${this.inputId}-label`}\n htmlFor={this.inputId}\n >\n {this.label}\n </label>\n )}\n <div class='searchcraft-select-input-wrapper'>\n <select\n aria-labelledby={\n this.label ? this.labelId || `${this.inputId}-label` : undefined\n }\n class='searchcraft-select-input'\n disabled={this.disabled}\n id={this.inputId}\n name={this.name}\n onChange={this.handleSelectChange}\n >\n {(typeof this.options === 'string'\n ? JSON.parse(this.options)\n : this.options\n ).map(({ label, value, selected }) => {\n return (\n <option key={value} value={value} selected={selected}>\n {label}\n </option>\n );\n })}\n </select>\n <svg\n class='searchcraft-select-input-icon'\n width='20'\n height='20'\n viewBox='0 0 20 20'\n fill='none'\n xmlns='http://www.w3.org/2000/svg'\n >\n <title>Select dropdown icon</title>\n <path\n d='M5 7.5L10 12.5L15 7.5'\n stroke='currentColor'\n stroke-width='1.5'\n stroke-linecap='round'\n stroke-linejoin='round'\n />\n </svg>\n </div>\n {this.caption && (\n <p class='searchcraft-select-caption'>{this.caption}</p>\n )}\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { D as DOMPurify } from './p-a64b4cba.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This allows you to parse a template string with a function.
|
|
5
|
+
*/
|
|
6
|
+
const html = (strings, ...values) => {
|
|
7
|
+
let result = strings[0];
|
|
8
|
+
for (let i = 0; i < values.length; i++) {
|
|
9
|
+
result +=
|
|
10
|
+
DOMPurify.sanitize(values[i] ? String(values[i]) : '') + strings[i + 1];
|
|
11
|
+
}
|
|
12
|
+
return result || '';
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { html as h };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=p-810a7850.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"p-810a7850.js","mappings":";;AAGA;;;MAGa,IAAI,GAAiB,CAAC,OAAO,EAAE,GAAG,MAAM;IACnD,IAAI,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAExB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,MAAM;YACJ,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;KAC3E;IAED,OAAO,MAAM,IAAI,EAAE,CAAC;AACtB;;;;","names":[],"sources":["src/utils/html.ts"],"sourcesContent":["import DOMPurify from 'dompurify';\n\nimport type { TemplateHtml } from '@searchcraft/core';\n/**\n * This allows you to parse a template string with a function.\n */\nexport const html: TemplateHtml = (strings, ...values) => {\n let result = strings[0];\n\n for (let i = 0; i < values.length; i++) {\n result +=\n DOMPurify.sanitize(values[i] ? String(values[i]) : '') + strings[i + 1];\n }\n\n return result || '';\n};\n"],"version":3}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { p as proxyCustomElement, H, h } from './p-5365011f.js';
|
|
2
|
-
import { s as searchcraftStore } from './p-
|
|
2
|
+
import { s as searchcraftStore } from './p-f8df3d49.js';
|
|
3
3
|
import { a as getDocumentValueFromSearchResultMapping } from './p-6104fe5d.js';
|
|
4
|
+
import './p-a64b4cba.js';
|
|
4
5
|
|
|
5
6
|
const SearchcraftPopoverListItem = /*@__PURE__*/ proxyCustomElement(class SearchcraftPopoverListItem extends H {
|
|
6
7
|
constructor() {
|
|
@@ -44,7 +45,7 @@ const SearchcraftPopoverListItem = /*@__PURE__*/ proxyCustomElement(class Search
|
|
|
44
45
|
}
|
|
45
46
|
};
|
|
46
47
|
render() {
|
|
47
|
-
return (h("a", { key: '
|
|
48
|
+
return (h("a", { key: 'c4a142be2b9993b8ad83eaaa59bdd9a047e4275e', class: 'searchcraft-popover-list-item', href: this.href, onClick: this.handleLinkClick.bind(this) }, this.imageSrc && (h("div", { key: '6a620203f4918b051835f557a00eb82c2397c56f', class: 'searchcraft-popover-list-item-image-wrapper' }, h("img", { key: '1a07c169119146f4f22e704098c493d67927ce82', alt: this.imageAlt, src: this.imageSrc, class: 'searchcraft-popover-list-item-image' }))), h("div", { key: 'd0b2faa1359c004cb5c38fd615e969a7614706cc', class: 'searchcraft-popover-list-item-info-wrapper' }, h("p", { key: '9b8c8ba1d5c62a5251db893f3604803f83f687d2', class: 'searchcraft-popover-list-item-title' }, this.titleContent), h("p", { key: '930699a84405d0ea2476eb91bf9ce77fed016bb8', class: 'searchcraft-popover-list-item-subtitle' }, this.subtitleContent))));
|
|
48
49
|
}
|
|
49
50
|
}, [0, "searchcraft-popover-list-item", {
|
|
50
51
|
"item": [16],
|
|
@@ -72,4 +73,4 @@ function defineCustomElement() {
|
|
|
72
73
|
|
|
73
74
|
export { SearchcraftPopoverListItem as S, defineCustomElement as d };
|
|
74
75
|
|
|
75
|
-
//# sourceMappingURL=p-
|
|
76
|
+
//# sourceMappingURL=p-8aa0fff5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"p-8aa0fff5.js","mappings":";;;;;MAkBa,0BAA0B;;;;;IAC7B,IAAI,CAAuC;IAC3C,qBAAqB,CAAoC;;IAEzD,gBAAgB,GAAG,CAAC,CAAC;IAEpB,IAAI,CAAU;IACd,QAAQ,CAAU;IAClB,QAAQ,CAAU;IAClB,YAAY,CAAU;IACtB,eAAe,CAAU;IAElC,qBAAqB,CAAC,QAAwB;QAC5C,IAAI,CAAC,YAAY,GAAG,uCAAuC,CACzD,QAAQ,EACR,IAAI,CAAC,qBAAqB,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,QAAQ,KACZ,4DAAK,KAAK,EAAC,6CAA6C,IACtD,4DACE,GAAG,EAAE,IAAI,CAAC,QAAQ,EAClB,GAAG,EAAE,IAAI,CAAC,QAAQ,EAClB,KAAK,EAAC,qCAAqC,GAC3C,CACE,CACP,EACD,4DAAK,KAAK,EAAC,4CAA4C,IACrD,0DAAG,KAAK,EAAC,qCAAqC,IAAE,IAAI,CAAC,YAAY,CAAK,EACtE,0DAAG,KAAK,EAAC,wCAAwC,IAC9C,IAAI,CAAC,eAAe,CACnB,CACA,CACJ,EACJ;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/searchcraft-popover-list-item/searchcraft-popover-list-item.tsx"],"sourcesContent":["import { searchcraftStore } from '@store';\nimport type {\n SearchDocument,\n SearchClientResponseItem,\n PopoverResultMappings,\n} from '@searchcraft/core';\nimport { Component, h, Prop, State } from '@stencil/core';\nimport { getDocumentValueFromSearchResultMapping } from '@utils';\n\n/**\n * A single list item rendered in a searchcraft-popover-list-view.\n *\n * @internal\n */\n@Component({\n tag: 'searchcraft-popover-list-item',\n shadow: false,\n})\nexport class SearchcraftPopoverListItem {\n @Prop() item: SearchClientResponseItem | undefined;\n @Prop() popoverResultMappings: PopoverResultMappings | undefined;\n /** The document position relative to the search results (For Measure) */\n @Prop() documentPosition = 0;\n\n @State() href?: string;\n @State() imageSrc?: string;\n @State() imageAlt?: string;\n @State() titleContent?: string;\n @State() subtitleContent?: string;\n\n mapValuesFromDocument(document: SearchDocument) {\n this.titleContent = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.title,\n );\n this.subtitleContent = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.subtitle,\n );\n this.href = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.href,\n );\n this.imageSrc = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.imageSource,\n );\n this.imageAlt = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.imageAlt,\n );\n }\n\n connectedCallback() {\n if (this.item) {\n this.mapValuesFromDocument(this.item.document);\n }\n }\n\n disconnectedCallback() {}\n\n handleLinkClick = () => {\n const state = searchcraftStore.getState();\n const searchcraft = state.getSearchcraftInstance();\n\n if (searchcraft) {\n const document_position = this.documentPosition;\n const search_term = state.searchTerm;\n const number_of_documents = state.searchClientResponseItems.length || 0;\n\n searchcraft.measureClient?.sendMeasureEvent('document_clicked', {\n document_position,\n number_of_documents,\n search_term,\n });\n }\n };\n\n render() {\n return (\n <a\n class='searchcraft-popover-list-item'\n href={this.href}\n onClick={this.handleLinkClick.bind(this)}\n >\n {this.imageSrc && (\n <div class='searchcraft-popover-list-item-image-wrapper'>\n <img\n alt={this.imageAlt}\n src={this.imageSrc}\n class='searchcraft-popover-list-item-image'\n />\n </div>\n )}\n <div class='searchcraft-popover-list-item-info-wrapper'>\n <p class='searchcraft-popover-list-item-title'>{this.titleContent}</p>\n <p class='searchcraft-popover-list-item-subtitle'>\n {this.subtitleContent}\n </p>\n </div>\n </a>\n );\n }\n}\n"],"version":3}
|