@searchcraft/javascript-sdk 0.1.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/dist/cjs/app-globals-3a1e7e63.js +7 -0
- package/dist/cjs/app-globals-3a1e7e63.js.map +1 -0
- package/dist/cjs/index-0c2339c7.js +1226 -0
- package/dist/cjs/index-0c2339c7.js.map +1 -0
- package/dist/cjs/index.cjs.js +12 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/loader.cjs.js +17 -0
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/cjs/sc-auto-search-form.cjs.entry.js +101 -0
- package/dist/cjs/sc-auto-search-form.cjs.entry.js.map +1 -0
- package/dist/cjs/sc-base-search-form_11.cjs.entry.js +471 -0
- package/dist/cjs/sc-base-search-form_11.cjs.entry.js.map +1 -0
- package/dist/cjs/sc-spinner-light-a3bfc8e6.js +20 -0
- package/dist/cjs/sc-spinner-light-a3bfc8e6.js.map +1 -0
- package/dist/cjs/sc-spinner-light.cjs.entry.js +12 -0
- package/dist/cjs/sc-spinner-light.cjs.entry.js.map +1 -0
- package/dist/cjs/searchcraft-javascript-sdk.cjs.js +27 -0
- package/dist/cjs/searchcraft-javascript-sdk.cjs.js.map +1 -0
- package/dist/cjs/store-6c259dd0.js +251 -0
- package/dist/cjs/store-6c259dd0.js.map +1 -0
- package/dist/collection/assets/ButtonIcons.js +3 -0
- package/dist/collection/assets/ButtonIcons.js.map +1 -0
- package/dist/collection/assets/ClearInputIcon.js +6 -0
- package/dist/collection/assets/ClearInputIcon.js.map +1 -0
- package/dist/collection/assets/SearchIcons.js +6 -0
- package/dist/collection/assets/SearchIcons.js.map +1 -0
- package/dist/collection/collection-manifest.json +24 -0
- package/dist/collection/components/sc-auto-search-form/sc-auto-search-form.js +275 -0
- package/dist/collection/components/sc-auto-search-form/sc-auto-search-form.js.map +1 -0
- package/dist/collection/components/sc-auto-search-form/sc-auto-search-form.module.css +16 -0
- package/dist/collection/components/sc-base-search-form/sc-base-search-form.js +168 -0
- package/dist/collection/components/sc-base-search-form/sc-base-search-form.js.map +1 -0
- package/dist/collection/components/sc-base-search-form/sc-base-search-form.module.css +14 -0
- package/dist/collection/components/sc-base-search-result/sc-base-search-result.js +242 -0
- package/dist/collection/components/sc-base-search-result/sc-base-search-result.js.map +1 -0
- package/dist/collection/components/sc-base-search-result/sc-base-search-result.module.css +170 -0
- package/dist/collection/components/sc-base-search-results/sc-base-search-results.js +58 -0
- package/dist/collection/components/sc-base-search-results/sc-base-search-results.js.map +1 -0
- package/dist/collection/components/sc-base-search-results/sc-base-search-results.module.css +20 -0
- package/dist/collection/components/sc-button/sc-button.js +137 -0
- package/dist/collection/components/sc-button/sc-button.js.map +1 -0
- package/dist/collection/components/sc-button/sc-button.module.css +82 -0
- package/dist/collection/components/sc-clear-input-button/sc-clear-input-button.js +99 -0
- package/dist/collection/components/sc-clear-input-button/sc-clear-input-button.js.map +1 -0
- package/dist/collection/components/sc-clear-input-button/sc-clear-input-button.module.css +31 -0
- package/dist/collection/components/sc-error-message/sc-error-message.js +64 -0
- package/dist/collection/components/sc-error-message/sc-error-message.js.map +1 -0
- package/dist/collection/components/sc-error-message/sc-error-message.module.css +21 -0
- package/dist/collection/components/sc-input/sc-input.js +251 -0
- package/dist/collection/components/sc-input/sc-input.js.map +1 -0
- package/dist/collection/components/sc-input/sc-input.module.css +224 -0
- package/dist/collection/components/sc-input-caption/sc-input-caption.js +122 -0
- package/dist/collection/components/sc-input-caption/sc-input-caption.js.map +1 -0
- package/dist/collection/components/sc-input-caption/sc-input-caption.module.css +79 -0
- package/dist/collection/components/sc-input-icon/sc-input-icon.js +72 -0
- package/dist/collection/components/sc-input-icon/sc-input-icon.js.map +1 -0
- package/dist/collection/components/sc-input-icon/sc-input-icon.module.css +19 -0
- package/dist/collection/components/sc-input-label/sc-input-label.js +74 -0
- package/dist/collection/components/sc-input-label/sc-input-label.js.map +1 -0
- package/dist/collection/components/sc-input-label/sc-input-label.module.css +21 -0
- package/dist/collection/components/sc-spinner-dark/sc-spinner-dark.js +19 -0
- package/dist/collection/components/sc-spinner-dark/sc-spinner-dark.js.map +1 -0
- package/dist/collection/components/sc-spinner-dark/sc-spinner-dark.module.css +35 -0
- package/dist/collection/components/sc-spinner-light/sc-spinner-light.js +19 -0
- package/dist/collection/components/sc-spinner-light/sc-spinner-light.js.map +1 -0
- package/dist/collection/components/sc-spinner-light/sc-spinner-light.module.css +26 -0
- package/dist/collection/index.js +12 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/provider/store.js +68 -0
- package/dist/collection/provider/store.js.map +1 -0
- package/dist/collection/utils/utils.js +1 -0
- package/dist/collection/utils/utils.js.map +1 -0
- package/dist/components/index.d.ts +33 -0
- package/dist/components/index.js +4 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/p-074239f9.js +34 -0
- package/dist/components/p-074239f9.js.map +1 -0
- package/dist/components/p-184d9504.js +61 -0
- package/dist/components/p-184d9504.js.map +1 -0
- package/dist/components/p-23bdbb1f.js +58 -0
- package/dist/components/p-23bdbb1f.js.map +1 -0
- package/dist/components/p-255a89f7.js +62 -0
- package/dist/components/p-255a89f7.js.map +1 -0
- package/dist/components/p-5410e357.js +108 -0
- package/dist/components/p-5410e357.js.map +1 -0
- package/dist/components/p-5b7b903a.js +71 -0
- package/dist/components/p-5b7b903a.js.map +1 -0
- package/dist/components/p-5cdc6210.js +82 -0
- package/dist/components/p-5cdc6210.js.map +1 -0
- package/dist/components/p-6f0eaec6.js +247 -0
- package/dist/components/p-6f0eaec6.js.map +1 -0
- package/dist/components/p-75be555b.js +54 -0
- package/dist/components/p-75be555b.js.map +1 -0
- package/dist/components/p-79564f07.js +41 -0
- package/dist/components/p-79564f07.js.map +1 -0
- package/dist/components/p-a912a224.js +1062 -0
- package/dist/components/p-a912a224.js.map +1 -0
- package/dist/components/p-b05f23e3.js +18 -0
- package/dist/components/p-b05f23e3.js.map +1 -0
- package/dist/components/p-c47cb37f.js +46 -0
- package/dist/components/p-c47cb37f.js.map +1 -0
- package/dist/components/p-c54fdecb.js +164 -0
- package/dist/components/p-c54fdecb.js.map +1 -0
- package/dist/components/p-dfb43eea.js +34 -0
- package/dist/components/p-dfb43eea.js.map +1 -0
- package/dist/components/sc-auto-search-form.d.ts +11 -0
- package/dist/components/sc-auto-search-form.js +152 -0
- package/dist/components/sc-auto-search-form.js.map +1 -0
- package/dist/components/sc-base-search-form.d.ts +11 -0
- package/dist/components/sc-base-search-form.js +135 -0
- package/dist/components/sc-base-search-form.js.map +1 -0
- package/dist/components/sc-base-search-result.d.ts +11 -0
- package/dist/components/sc-base-search-result.js +8 -0
- package/dist/components/sc-base-search-result.js.map +1 -0
- package/dist/components/sc-base-search-results.d.ts +11 -0
- package/dist/components/sc-base-search-results.js +83 -0
- package/dist/components/sc-base-search-results.js.map +1 -0
- package/dist/components/sc-button.d.ts +11 -0
- package/dist/components/sc-button.js +8 -0
- package/dist/components/sc-button.js.map +1 -0
- package/dist/components/sc-clear-input-button.d.ts +11 -0
- package/dist/components/sc-clear-input-button.js +8 -0
- package/dist/components/sc-clear-input-button.js.map +1 -0
- package/dist/components/sc-error-message.d.ts +11 -0
- package/dist/components/sc-error-message.js +8 -0
- package/dist/components/sc-error-message.js.map +1 -0
- package/dist/components/sc-input-caption.d.ts +11 -0
- package/dist/components/sc-input-caption.js +8 -0
- package/dist/components/sc-input-caption.js.map +1 -0
- package/dist/components/sc-input-icon.d.ts +11 -0
- package/dist/components/sc-input-icon.js +8 -0
- package/dist/components/sc-input-icon.js.map +1 -0
- package/dist/components/sc-input-label.d.ts +11 -0
- package/dist/components/sc-input-label.js +8 -0
- package/dist/components/sc-input-label.js.map +1 -0
- package/dist/components/sc-input.d.ts +11 -0
- package/dist/components/sc-input.js +8 -0
- package/dist/components/sc-input.js.map +1 -0
- package/dist/components/sc-spinner-dark.d.ts +11 -0
- package/dist/components/sc-spinner-dark.js +8 -0
- package/dist/components/sc-spinner-dark.js.map +1 -0
- package/dist/components/sc-spinner-light.d.ts +11 -0
- package/dist/components/sc-spinner-light.js +8 -0
- package/dist/components/sc-spinner-light.js.map +1 -0
- package/dist/esm/app-globals-0f993ce5.js +5 -0
- package/dist/esm/app-globals-0f993ce5.js.map +1 -0
- package/dist/esm/index-c97f8c28.js +1198 -0
- package/dist/esm/index-c97f8c28.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/loader.js +13 -0
- package/dist/esm/loader.js.map +1 -0
- package/dist/esm/sc-auto-search-form.entry.js +97 -0
- package/dist/esm/sc-auto-search-form.entry.js.map +1 -0
- package/dist/esm/sc-base-search-form_11.entry.js +457 -0
- package/dist/esm/sc-base-search-form_11.entry.js.map +1 -0
- package/dist/esm/sc-spinner-light-cdb79a33.js +18 -0
- package/dist/esm/sc-spinner-light-cdb79a33.js.map +1 -0
- package/dist/esm/sc-spinner-light.entry.js +4 -0
- package/dist/esm/sc-spinner-light.entry.js.map +1 -0
- package/dist/esm/searchcraft-javascript-sdk.js +22 -0
- package/dist/esm/searchcraft-javascript-sdk.js.map +1 -0
- package/dist/esm/store-2370857c.js +247 -0
- package/dist/esm/store-2370857c.js.map +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/loader/cdn.js +1 -0
- package/dist/loader/index.cjs.js +1 -0
- package/dist/loader/index.d.ts +24 -0
- package/dist/loader/index.es2017.js +1 -0
- package/dist/loader/index.js +2 -0
- package/dist/loader/package.json +11 -0
- package/dist/searchcraft-javascript-sdk/index.esm.js +2 -0
- package/dist/searchcraft-javascript-sdk/index.esm.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-6f0eaec6.js +11 -0
- package/dist/searchcraft-javascript-sdk/p-6f0eaec6.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-8e9ba2cf.js +3 -0
- package/dist/searchcraft-javascript-sdk/p-8e9ba2cf.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-94c68cce.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-94c68cce.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-9545c59a.entry.js +7 -0
- package/dist/searchcraft-javascript-sdk/p-9545c59a.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-c632f66c.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-c632f66c.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-e1255160.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-e1255160.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-f7dbb9a8.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-f7dbb9a8.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js +2 -0
- package/dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js.map +1 -0
- package/dist/types/assets/ButtonIcons.d.ts +1 -0
- package/dist/types/assets/ClearInputIcon.d.ts +4 -0
- package/dist/types/assets/SearchIcons.d.ts +4 -0
- package/dist/types/components/sc-auto-search-form/sc-auto-search-form.d.ts +41 -0
- package/dist/types/components/sc-base-search-form/sc-base-search-form.d.ts +20 -0
- package/dist/types/components/sc-base-search-result/sc-base-search-result.d.ts +16 -0
- package/dist/types/components/sc-base-search-results/sc-base-search-results.d.ts +9 -0
- package/dist/types/components/sc-button/sc-button.d.ts +13 -0
- package/dist/types/components/sc-clear-input-button/sc-clear-input-button.d.ts +10 -0
- package/dist/types/components/sc-error-message/sc-error-message.d.ts +11 -0
- package/dist/types/components/sc-input/sc-input.d.ts +22 -0
- package/dist/types/components/sc-input-caption/sc-input-caption.d.ts +9 -0
- package/dist/types/components/sc-input-icon/sc-input-icon.d.ts +7 -0
- package/dist/types/components/sc-input-label/sc-input-label.d.ts +7 -0
- package/dist/types/components/sc-spinner-dark/sc-spinner-dark.d.ts +3 -0
- package/dist/types/components/sc-spinner-light/sc-spinner-light.d.ts +3 -0
- package/dist/types/components.d.ts +386 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/provider/store.d.ts +18 -0
- package/dist/types/stencil-public-runtime.d.ts +1680 -0
- package/dist/types/utils/utils.d.ts +0 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/loader/package.json +11 -0
- package/package.json +47 -0
- package/readme.md +11 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { h, } from "@stencil/core";
|
|
2
|
+
import { CoreSDK as SearchcraftCore, } from "@searchcraft/core";
|
|
3
|
+
import { useSearchcraftStore } from "../../provider/store";
|
|
4
|
+
export class ScAutoSearchForm {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.debounceTimeout = null;
|
|
7
|
+
this.debounceDelay = 300; // 300ms debounce delay
|
|
8
|
+
this.componentDidLoad = () => {
|
|
9
|
+
const searchcraft = new SearchcraftCore(this.config);
|
|
10
|
+
this.searchStore.initialize(searchcraft, true);
|
|
11
|
+
};
|
|
12
|
+
// Initialize searchStore as a private field
|
|
13
|
+
this.searchStore = useSearchcraftStore.getState();
|
|
14
|
+
/**
|
|
15
|
+
* Handles the input change event from sc-input
|
|
16
|
+
*/
|
|
17
|
+
this.handleInputChange = (event) => {
|
|
18
|
+
console.log(event);
|
|
19
|
+
this.query = event.detail; // Update the query state with input value
|
|
20
|
+
if (this.debounceTimeout) {
|
|
21
|
+
clearTimeout(this.debounceTimeout); // Clear any existing timeout
|
|
22
|
+
}
|
|
23
|
+
// Emit querySubmit immediately for real-time updates
|
|
24
|
+
this.querySubmit.emit(this.query);
|
|
25
|
+
// Set a new debounce timeout to execute search after delay
|
|
26
|
+
this.debounceTimeout = setTimeout(() => {
|
|
27
|
+
this.runSearch(); // Execute search logic after typing stops
|
|
28
|
+
}, this.debounceDelay);
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Handles the clear input event from sc-input
|
|
32
|
+
*/
|
|
33
|
+
this.handleClearInput = () => {
|
|
34
|
+
this.query = '';
|
|
35
|
+
if (typeof this.clearInput === 'function') {
|
|
36
|
+
this.clearInput();
|
|
37
|
+
}
|
|
38
|
+
if (this.debounceTimeout) {
|
|
39
|
+
clearTimeout(this.debounceTimeout); // Clear the debounce timeout
|
|
40
|
+
}
|
|
41
|
+
// Reset error and search results
|
|
42
|
+
this.error = false;
|
|
43
|
+
this.searchResults = '';
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Runs the search logic
|
|
47
|
+
*/
|
|
48
|
+
this.runSearch = async () => {
|
|
49
|
+
if (this.query.trim() === '') {
|
|
50
|
+
this.error = true;
|
|
51
|
+
this.searchResults = '';
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this.error = false;
|
|
55
|
+
this.searchStore.setQuery(this.query); // Set the query in the searchStore
|
|
56
|
+
await this.searchStore.search(); // Perform the search
|
|
57
|
+
this.searchResults = JSON.stringify(this.searchStore.searchResults); // Store search results as JSON
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Handles the form submission logic
|
|
62
|
+
*/
|
|
63
|
+
this.handleFormSubmit = async (event) => {
|
|
64
|
+
event.preventDefault();
|
|
65
|
+
await this.runSearch(); // Trigger search logic on form submit
|
|
66
|
+
};
|
|
67
|
+
this.autoSearchFormClass = '';
|
|
68
|
+
this.clearInput = () => { };
|
|
69
|
+
this.config = {
|
|
70
|
+
apiKey: '',
|
|
71
|
+
endpointURL: '',
|
|
72
|
+
index: [],
|
|
73
|
+
};
|
|
74
|
+
this.inputCaptionValue = '';
|
|
75
|
+
this.labelForInput = 'Search';
|
|
76
|
+
this.placeholderValue = 'Search here';
|
|
77
|
+
this.rightToLeftOrientation = false;
|
|
78
|
+
this.searchContainerClass = '';
|
|
79
|
+
this.error = false;
|
|
80
|
+
this.query = '';
|
|
81
|
+
this.searchResults = '';
|
|
82
|
+
}
|
|
83
|
+
render() {
|
|
84
|
+
const formClass = this.rightToLeftOrientation ? 'formRTL' : 'formLTR';
|
|
85
|
+
return (h("form", { key: '9c467f62b6464d5976a6cdbb17071777829fcd65', class: `${formClass}`, onSubmit: this.handleFormSubmit }, h("label", { key: '0740487a130c5427a2e7c7c7bf9b112fdd2038f7' }, this.labelForInput), h("div", { key: '1b1816b4c1fa472f1227110d480fc3014782383b', class: 'searchContainer' }, h("sc-input", { key: '2e8bd731c91b75db17f0c177c4e57e04268cb0dd', "placeholder-value": this.placeholderValue, query: this.query, "input-caption-value": this.inputCaptionValue, "right-to-left-orientation": this.rightToLeftOrientation, onSearchInputChange: this.handleInputChange, onClearInput: this.handleClearInput })), this.error && h("p", { key: '82aa93fa1e009d49adf7ba4e6568298686b9b3ec', class: 'error' }, "Please enter a search query."), this.searchResults && h("pre", { key: '3c7e024e7d961418d2330d1ce9d117e2a7f24051', class: 'results' }, this.searchResults)));
|
|
86
|
+
}
|
|
87
|
+
static get is() { return "sc-auto-search-form"; }
|
|
88
|
+
static get encapsulation() { return "shadow"; }
|
|
89
|
+
static get originalStyleUrls() {
|
|
90
|
+
return {
|
|
91
|
+
"$": ["sc-auto-search-form.module.scss"]
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
static get styleUrls() {
|
|
95
|
+
return {
|
|
96
|
+
"$": ["sc-auto-search-form.module.css"]
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
static get properties() {
|
|
100
|
+
return {
|
|
101
|
+
"autoSearchFormClass": {
|
|
102
|
+
"type": "string",
|
|
103
|
+
"mutable": false,
|
|
104
|
+
"complexType": {
|
|
105
|
+
"original": "string",
|
|
106
|
+
"resolved": "string",
|
|
107
|
+
"references": {}
|
|
108
|
+
},
|
|
109
|
+
"required": false,
|
|
110
|
+
"optional": false,
|
|
111
|
+
"docs": {
|
|
112
|
+
"tags": [],
|
|
113
|
+
"text": ""
|
|
114
|
+
},
|
|
115
|
+
"attribute": "auto-search-form-class",
|
|
116
|
+
"reflect": false,
|
|
117
|
+
"defaultValue": "''"
|
|
118
|
+
},
|
|
119
|
+
"clearInput": {
|
|
120
|
+
"type": "unknown",
|
|
121
|
+
"mutable": false,
|
|
122
|
+
"complexType": {
|
|
123
|
+
"original": "() => void",
|
|
124
|
+
"resolved": "() => void",
|
|
125
|
+
"references": {}
|
|
126
|
+
},
|
|
127
|
+
"required": false,
|
|
128
|
+
"optional": false,
|
|
129
|
+
"docs": {
|
|
130
|
+
"tags": [],
|
|
131
|
+
"text": ""
|
|
132
|
+
},
|
|
133
|
+
"defaultValue": "() => {}"
|
|
134
|
+
},
|
|
135
|
+
"config": {
|
|
136
|
+
"type": "unknown",
|
|
137
|
+
"mutable": false,
|
|
138
|
+
"complexType": {
|
|
139
|
+
"original": "CoreConfigSDK",
|
|
140
|
+
"resolved": "CoreConfigSDK",
|
|
141
|
+
"references": {
|
|
142
|
+
"CoreConfigSDK": {
|
|
143
|
+
"location": "import",
|
|
144
|
+
"path": "@searchcraft/core",
|
|
145
|
+
"id": "../core-sdk/dist/index.d.ts::CoreConfigSDK"
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
"required": false,
|
|
150
|
+
"optional": false,
|
|
151
|
+
"docs": {
|
|
152
|
+
"tags": [],
|
|
153
|
+
"text": ""
|
|
154
|
+
},
|
|
155
|
+
"defaultValue": "{\n apiKey: '',\n endpointURL: '',\n index: [],\n }"
|
|
156
|
+
},
|
|
157
|
+
"inputCaptionValue": {
|
|
158
|
+
"type": "string",
|
|
159
|
+
"mutable": false,
|
|
160
|
+
"complexType": {
|
|
161
|
+
"original": "string",
|
|
162
|
+
"resolved": "string",
|
|
163
|
+
"references": {}
|
|
164
|
+
},
|
|
165
|
+
"required": false,
|
|
166
|
+
"optional": false,
|
|
167
|
+
"docs": {
|
|
168
|
+
"tags": [],
|
|
169
|
+
"text": ""
|
|
170
|
+
},
|
|
171
|
+
"attribute": "input-caption-value",
|
|
172
|
+
"reflect": false,
|
|
173
|
+
"defaultValue": "''"
|
|
174
|
+
},
|
|
175
|
+
"labelForInput": {
|
|
176
|
+
"type": "string",
|
|
177
|
+
"mutable": false,
|
|
178
|
+
"complexType": {
|
|
179
|
+
"original": "string",
|
|
180
|
+
"resolved": "string",
|
|
181
|
+
"references": {}
|
|
182
|
+
},
|
|
183
|
+
"required": false,
|
|
184
|
+
"optional": false,
|
|
185
|
+
"docs": {
|
|
186
|
+
"tags": [],
|
|
187
|
+
"text": ""
|
|
188
|
+
},
|
|
189
|
+
"attribute": "label-for-input",
|
|
190
|
+
"reflect": false,
|
|
191
|
+
"defaultValue": "'Search'"
|
|
192
|
+
},
|
|
193
|
+
"placeholderValue": {
|
|
194
|
+
"type": "string",
|
|
195
|
+
"mutable": false,
|
|
196
|
+
"complexType": {
|
|
197
|
+
"original": "string",
|
|
198
|
+
"resolved": "string",
|
|
199
|
+
"references": {}
|
|
200
|
+
},
|
|
201
|
+
"required": false,
|
|
202
|
+
"optional": false,
|
|
203
|
+
"docs": {
|
|
204
|
+
"tags": [],
|
|
205
|
+
"text": ""
|
|
206
|
+
},
|
|
207
|
+
"attribute": "placeholder-value",
|
|
208
|
+
"reflect": false,
|
|
209
|
+
"defaultValue": "'Search here'"
|
|
210
|
+
},
|
|
211
|
+
"rightToLeftOrientation": {
|
|
212
|
+
"type": "boolean",
|
|
213
|
+
"mutable": false,
|
|
214
|
+
"complexType": {
|
|
215
|
+
"original": "boolean",
|
|
216
|
+
"resolved": "boolean",
|
|
217
|
+
"references": {}
|
|
218
|
+
},
|
|
219
|
+
"required": false,
|
|
220
|
+
"optional": false,
|
|
221
|
+
"docs": {
|
|
222
|
+
"tags": [],
|
|
223
|
+
"text": ""
|
|
224
|
+
},
|
|
225
|
+
"attribute": "right-to-left-orientation",
|
|
226
|
+
"reflect": false,
|
|
227
|
+
"defaultValue": "false"
|
|
228
|
+
},
|
|
229
|
+
"searchContainerClass": {
|
|
230
|
+
"type": "string",
|
|
231
|
+
"mutable": false,
|
|
232
|
+
"complexType": {
|
|
233
|
+
"original": "string",
|
|
234
|
+
"resolved": "string",
|
|
235
|
+
"references": {}
|
|
236
|
+
},
|
|
237
|
+
"required": false,
|
|
238
|
+
"optional": false,
|
|
239
|
+
"docs": {
|
|
240
|
+
"tags": [],
|
|
241
|
+
"text": ""
|
|
242
|
+
},
|
|
243
|
+
"attribute": "search-container-class",
|
|
244
|
+
"reflect": false,
|
|
245
|
+
"defaultValue": "''"
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
static get states() {
|
|
250
|
+
return {
|
|
251
|
+
"error": {},
|
|
252
|
+
"query": {},
|
|
253
|
+
"searchResults": {}
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
static get events() {
|
|
257
|
+
return [{
|
|
258
|
+
"method": "querySubmit",
|
|
259
|
+
"name": "querySubmit",
|
|
260
|
+
"bubbles": true,
|
|
261
|
+
"cancelable": true,
|
|
262
|
+
"composed": true,
|
|
263
|
+
"docs": {
|
|
264
|
+
"tags": [],
|
|
265
|
+
"text": "Event emitted when the search query changes"
|
|
266
|
+
},
|
|
267
|
+
"complexType": {
|
|
268
|
+
"original": "string",
|
|
269
|
+
"resolved": "string",
|
|
270
|
+
"references": {}
|
|
271
|
+
}
|
|
272
|
+
}];
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
//# sourceMappingURL=sc-auto-search-form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sc-auto-search-form.js","sourceRoot":"","sources":["../../../src/components/sc-auto-search-form/sc-auto-search-form.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,IAAI,EACJ,KAAK,EACL,KAAK,EAEL,CAAC,GACF,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,OAAO,IAAI,eAAe,GAC3B,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAOtD,MAAM,OAAO,gBAAgB;;Q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AAK,EAAE,GAAG,SAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,gBAAgB;YAC1D,gEAAQ,IAAI,CAAC,aAAa,CAAS;YACnC,4DAAK,KAAK,EAAC,iBAAiB;gBAC1B,sFACqB,IAAI,CAAC,gBAAgB,EACxC,KAAK,EAAE,IAAI,CAAC,KAAK,yBACI,IAAI,CAAC,iBAAiB,+BAChB,IAAI,CAAC,sBAAsB,EACtD,mBAAmB,EAAE,IAAI,CAAC,iBAAiB,EAC3C,YAAY,EAAE,IAAI,CAAC,gBAAgB,GACnC,CACE;YACL,IAAI,CAAC,KAAK,IAAI,0DAAG,KAAK,EAAC,OAAO,mCAAiC;YAC/D,IAAI,CAAC,aAAa,IAAI,4DAAK,KAAK,EAAC,SAAS,IAAE,IAAI,CAAC,aAAa,CAAO,CACjE,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n Prop,\n State,\n Event,\n type EventEmitter,\n h,\n} from '@stencil/core';\nimport {\n type CoreConfigSDK,\n CoreSDK as SearchcraftCore,\n} from '@searchcraft/core';\n\nimport type { ScInputCustomEvent } from '@components/sc-input/sc-input';\nimport { useSearchcraftStore } from '@provider/store';\n\n@Component({\n tag: 'sc-auto-search-form',\n styleUrl: 'sc-auto-search-form.module.scss',\n shadow: true,\n})\nexport class ScAutoSearchForm {\n @Prop() autoSearchFormClass = '';\n @Prop() clearInput: () => void = () => {}; // Default assignment ensures no undefined error\n @Prop() config: CoreConfigSDK = {\n apiKey: '',\n endpointURL: '',\n index: [],\n };\n @Prop() inputCaptionValue = '';\n @Prop() labelForInput = 'Search';\n @Prop() placeholderValue = 'Search here';\n @Prop() rightToLeftOrientation = false;\n @Prop() searchContainerClass = '';\n\n /**\n * Event emitted when the search query changes\n */\n @Event() querySubmit: EventEmitter<string>;\n\n @State() error = false;\n @State() query = '';\n @State() searchResults = '';\n\n private debounceTimeout: ReturnType<typeof setTimeout> | null = null;\n private debounceDelay = 300; // 300ms debounce delay\n\n componentDidLoad = () => {\n const searchcraft = new SearchcraftCore(this.config);\n this.searchStore.initialize(searchcraft, true);\n };\n\n // Initialize searchStore as a private field\n private searchStore = useSearchcraftStore.getState();\n\n /**\n * Handles the input change event from sc-input\n */\n handleInputChange = (event: ScInputCustomEvent<string>) => {\n console.log(event);\n this.query = event.detail; // Update the query state with input value\n\n if (this.debounceTimeout) {\n clearTimeout(this.debounceTimeout); // Clear any existing timeout\n }\n\n // Emit querySubmit immediately for real-time updates\n this.querySubmit.emit(this.query);\n\n // Set a new debounce timeout to execute search after delay\n this.debounceTimeout = setTimeout(() => {\n this.runSearch(); // Execute search logic after typing stops\n }, this.debounceDelay);\n };\n\n /**\n * Handles the clear input event from sc-input\n */\n handleClearInput = () => {\n this.query = '';\n if (typeof this.clearInput === 'function') {\n this.clearInput();\n }\n\n if (this.debounceTimeout) {\n clearTimeout(this.debounceTimeout); // Clear the debounce timeout\n }\n\n // Reset error and search results\n this.error = false;\n this.searchResults = '';\n };\n\n /**\n * Runs the search logic\n */\n private runSearch = async () => {\n if (this.query.trim() === '') {\n this.error = true;\n this.searchResults = '';\n } else {\n this.error = false;\n this.searchStore.setQuery(this.query); // Set the query in the searchStore\n await this.searchStore.search(); // Perform the search\n this.searchResults = JSON.stringify(this.searchStore.searchResults); // Store search results as JSON\n }\n };\n\n /**\n * Handles the form submission logic\n */\n handleFormSubmit = async (event: Event) => {\n event.preventDefault();\n await this.runSearch(); // Trigger search logic on form submit\n };\n\n render() {\n const formClass = this.rightToLeftOrientation ? 'formRTL' : 'formLTR';\n\n return (\n <form class={`${formClass}`} onSubmit={this.handleFormSubmit}>\n <label>{this.labelForInput}</label>\n <div class='searchContainer'>\n <sc-input\n placeholder-value={this.placeholderValue}\n query={this.query}\n input-caption-value={this.inputCaptionValue}\n right-to-left-orientation={this.rightToLeftOrientation}\n onSearchInputChange={this.handleInputChange}\n onClearInput={this.handleClearInput}\n />\n </div>\n {this.error && <p class='error'>Please enter a search query.</p>}\n {this.searchResults && <pre class='results'>{this.searchResults}</pre>}\n </form>\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { CoreSDK as SearchcraftCore, } from "@searchcraft/core";
|
|
3
|
+
import { useSearchcraftStore, useThemeStore } from "../../provider/store";
|
|
4
|
+
export class ScBaseSearchForm {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.clearInput = () => { };
|
|
7
|
+
this.searchStore = useSearchcraftStore.getState();
|
|
8
|
+
this.themeStore = useThemeStore.getState();
|
|
9
|
+
this.componentDidLoad = () => {
|
|
10
|
+
const searchcraft = new SearchcraftCore(this.config);
|
|
11
|
+
this.searchStore.initialize(searchcraft, true);
|
|
12
|
+
};
|
|
13
|
+
this.handleFormSubmit = async (event) => {
|
|
14
|
+
event.preventDefault();
|
|
15
|
+
if (this.query.trim() === '') {
|
|
16
|
+
this.error = true;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
this.error = false;
|
|
20
|
+
this.searchStore.setQuery(this.query);
|
|
21
|
+
await this.searchStore.search();
|
|
22
|
+
this.searchResults = JSON.stringify(this.searchStore.searchResults);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
this.handleSearchInputChange = (event) => {
|
|
26
|
+
this.query = event.detail;
|
|
27
|
+
};
|
|
28
|
+
this.handleClearInput = () => {
|
|
29
|
+
this.query = '';
|
|
30
|
+
this === null || this === void 0 ? void 0 : this.clearInput();
|
|
31
|
+
};
|
|
32
|
+
this.toggleTheme = () => {
|
|
33
|
+
this.themeStore.toggleTheme();
|
|
34
|
+
};
|
|
35
|
+
this.config = {
|
|
36
|
+
apiKey: '',
|
|
37
|
+
endpointURL: '',
|
|
38
|
+
index: [],
|
|
39
|
+
};
|
|
40
|
+
this.errorMessage = 'Search was unsuccessful';
|
|
41
|
+
this.labelForInput = 'Search';
|
|
42
|
+
this.rightToLeftOrientation = false;
|
|
43
|
+
this.error = false;
|
|
44
|
+
this.query = '';
|
|
45
|
+
this.searchResults = null;
|
|
46
|
+
}
|
|
47
|
+
render() {
|
|
48
|
+
return (h("form", { key: '2f128025b9caa2ab8a888d461da9b162bbc30d2f', class: this.rightToLeftOrientation ? 'formRTL' : 'formLTR', onSubmit: this.handleFormSubmit }, h("sc-input-label", { key: '110f30f0bbd27a0a512d9461a141198b738cc945', label: this.labelForInput }), h("div", { key: '5ec54632aeb5595f76a769d99801c8b92745bb05', class: 'searchContainer' }, this.rightToLeftOrientation && h("sc-button", { key: '753746e7c6bab72006e5a866609934e4738cb096' }), h("sc-input", { key: '823cda15577d253db0f1c30e3c8aa64fc19520ff', onClearInput: this.handleClearInput, rightToLeftOrientation: this.rightToLeftOrientation, onSearchInputChange: this.handleSearchInputChange, query: this.query }), !this.rightToLeftOrientation && (h("sc-button", { key: '99474f1a9fe35c18de0d6cc8ba9e70a4f1471c55', onButtonClick: this.handleFormSubmit }))), this.error && h("sc-error-message", { key: '03da10c2d3c51da69db971a0bfdbc7edbe218e1c', errorMessage: this.errorMessage })));
|
|
49
|
+
}
|
|
50
|
+
static get is() { return "sc-base-search-form"; }
|
|
51
|
+
static get encapsulation() { return "shadow"; }
|
|
52
|
+
static get originalStyleUrls() {
|
|
53
|
+
return {
|
|
54
|
+
"$": ["sc-base-search-form.module.scss"]
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
static get styleUrls() {
|
|
58
|
+
return {
|
|
59
|
+
"$": ["sc-base-search-form.module.css"]
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
static get properties() {
|
|
63
|
+
return {
|
|
64
|
+
"config": {
|
|
65
|
+
"type": "unknown",
|
|
66
|
+
"mutable": false,
|
|
67
|
+
"complexType": {
|
|
68
|
+
"original": "CoreConfigSDK",
|
|
69
|
+
"resolved": "CoreConfigSDK",
|
|
70
|
+
"references": {
|
|
71
|
+
"CoreConfigSDK": {
|
|
72
|
+
"location": "import",
|
|
73
|
+
"path": "@searchcraft/core",
|
|
74
|
+
"id": "../core-sdk/dist/index.d.ts::CoreConfigSDK"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"required": false,
|
|
79
|
+
"optional": false,
|
|
80
|
+
"docs": {
|
|
81
|
+
"tags": [],
|
|
82
|
+
"text": ""
|
|
83
|
+
},
|
|
84
|
+
"defaultValue": "{\n apiKey: '',\n endpointURL: '',\n index: [],\n }"
|
|
85
|
+
},
|
|
86
|
+
"errorMessage": {
|
|
87
|
+
"type": "string",
|
|
88
|
+
"mutable": false,
|
|
89
|
+
"complexType": {
|
|
90
|
+
"original": "string",
|
|
91
|
+
"resolved": "string",
|
|
92
|
+
"references": {}
|
|
93
|
+
},
|
|
94
|
+
"required": false,
|
|
95
|
+
"optional": false,
|
|
96
|
+
"docs": {
|
|
97
|
+
"tags": [],
|
|
98
|
+
"text": ""
|
|
99
|
+
},
|
|
100
|
+
"attribute": "error-message",
|
|
101
|
+
"reflect": false,
|
|
102
|
+
"defaultValue": "'Search was unsuccessful'"
|
|
103
|
+
},
|
|
104
|
+
"labelForInput": {
|
|
105
|
+
"type": "string",
|
|
106
|
+
"mutable": false,
|
|
107
|
+
"complexType": {
|
|
108
|
+
"original": "string",
|
|
109
|
+
"resolved": "string",
|
|
110
|
+
"references": {}
|
|
111
|
+
},
|
|
112
|
+
"required": false,
|
|
113
|
+
"optional": false,
|
|
114
|
+
"docs": {
|
|
115
|
+
"tags": [],
|
|
116
|
+
"text": ""
|
|
117
|
+
},
|
|
118
|
+
"attribute": "label-for-input",
|
|
119
|
+
"reflect": false,
|
|
120
|
+
"defaultValue": "'Search'"
|
|
121
|
+
},
|
|
122
|
+
"rightToLeftOrientation": {
|
|
123
|
+
"type": "boolean",
|
|
124
|
+
"mutable": false,
|
|
125
|
+
"complexType": {
|
|
126
|
+
"original": "boolean",
|
|
127
|
+
"resolved": "boolean",
|
|
128
|
+
"references": {}
|
|
129
|
+
},
|
|
130
|
+
"required": false,
|
|
131
|
+
"optional": false,
|
|
132
|
+
"docs": {
|
|
133
|
+
"tags": [],
|
|
134
|
+
"text": ""
|
|
135
|
+
},
|
|
136
|
+
"attribute": "right-to-left-orientation",
|
|
137
|
+
"reflect": false,
|
|
138
|
+
"defaultValue": "false"
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
static get states() {
|
|
143
|
+
return {
|
|
144
|
+
"error": {},
|
|
145
|
+
"query": {},
|
|
146
|
+
"searchResults": {}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
static get events() {
|
|
150
|
+
return [{
|
|
151
|
+
"method": "clearInput",
|
|
152
|
+
"name": "clearInput",
|
|
153
|
+
"bubbles": true,
|
|
154
|
+
"cancelable": true,
|
|
155
|
+
"composed": true,
|
|
156
|
+
"docs": {
|
|
157
|
+
"tags": [],
|
|
158
|
+
"text": ""
|
|
159
|
+
},
|
|
160
|
+
"complexType": {
|
|
161
|
+
"original": "any",
|
|
162
|
+
"resolved": "any",
|
|
163
|
+
"references": {}
|
|
164
|
+
}
|
|
165
|
+
}];
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=sc-base-search-form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sc-base-search-form.js","sourceRoot":"","sources":["../../../src/components/sc-base-search-form/sc-base-search-form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAEL,OAAO,IAAI,eAAe,GAC3B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAA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AEF,gBAAW,GAAG,GAAG,EAAE;YACjB,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;QAChC,CAAC,CAAC;sBA9C8B;YAC9B,MAAM,EAAE,EAAE;YACV,WAAW,EAAE,EAAE;YACf,KAAK,EAAE,EAAE;SACV;4BACsB,yBAAyB;6BACxB,QAAQ;sCACC,KAAK;qBAIrB,KAAK;qBACL,EAAE;6BACqB,IAAI;;IAmC5C,MAAM;QACJ,OAAO,CACL,6DACE,KAAK,EAAE,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EAC1D,QAAQ,EAAE,IAAI,CAAC,gBAAgB;YAE/B,uEAAgB,KAAK,EAAE,IAAI,CAAC,aAAa,GAAI;YAC7C,4DAAK,KAAK,EAAC,iBAAiB;gBACzB,IAAI,CAAC,sBAAsB,IAAI,mEAAa;gBAC7C,iEACE,YAAY,EAAE,IAAI,CAAC,gBAAgB,EACnC,sBAAsB,EAAE,IAAI,CAAC,sBAAsB,EACnD,mBAAmB,EAAE,IAAI,CAAC,uBAAuB,EACjD,KAAK,EAAE,IAAI,CAAC,KAAK,GACjB;gBACD,CAAC,IAAI,CAAC,sBAAsB,IAAI,CAC/B,kEAAW,aAAa,EAAE,IAAI,CAAC,gBAAgB,GAAI,CACpD,CACG;YACL,IAAI,CAAC,KAAK,IAAI,yEAAkB,YAAY,EAAE,IAAI,CAAC,YAAY,GAAI,CAC/D,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Event, Prop, State } from '@stencil/core';\nimport {\n type CoreConfigSDK,\n CoreSDK as SearchcraftCore,\n} from '@searchcraft/core';\n\nimport { useSearchcraftStore, useThemeStore } from '@provider/store';\n\nimport type { ScInputCustomEvent } from '@components/sc-input/sc-input';\n\n@Component({\n tag: 'sc-base-search-form',\n styleUrl: 'sc-base-search-form.module.scss',\n shadow: true,\n})\nexport class ScBaseSearchForm {\n @Prop() config: CoreConfigSDK = {\n apiKey: '',\n endpointURL: '',\n index: [],\n };\n @Prop() errorMessage = 'Search was unsuccessful';\n @Prop() labelForInput = 'Search';\n @Prop() rightToLeftOrientation = false;\n\n @Event() clearInput = () => {};\n\n @State() error = false;\n @State() query = '';\n @State() searchResults: string | null = null;\n\n private searchStore = useSearchcraftStore.getState();\n private themeStore = useThemeStore.getState();\n\n componentDidLoad = () => {\n const searchcraft = new SearchcraftCore(this.config);\n this.searchStore.initialize(searchcraft, true);\n };\n\n handleFormSubmit = async (event) => {\n event.preventDefault();\n if (this.query.trim() === '') {\n this.error = true;\n } else {\n this.error = false;\n this.searchStore.setQuery(this.query);\n await this.searchStore.search();\n this.searchResults = JSON.stringify(this.searchStore.searchResults);\n }\n };\n\n handleSearchInputChange = (event: ScInputCustomEvent<string>) => {\n this.query = event.detail;\n };\n\n handleClearInput = () => {\n this.query = '';\n this?.clearInput();\n };\n\n toggleTheme = () => {\n this.themeStore.toggleTheme();\n };\n\n render() {\n return (\n <form\n class={this.rightToLeftOrientation ? 'formRTL' : 'formLTR'}\n onSubmit={this.handleFormSubmit}\n >\n <sc-input-label label={this.labelForInput} />\n <div class='searchContainer'>\n {this.rightToLeftOrientation && <sc-button />}\n <sc-input\n onClearInput={this.handleClearInput}\n rightToLeftOrientation={this.rightToLeftOrientation}\n onSearchInputChange={this.handleSearchInputChange}\n query={this.query}\n />\n {!this.rightToLeftOrientation && (\n <sc-button onButtonClick={this.handleFormSubmit} />\n )}\n </div>\n {this.error && <sc-error-message errorMessage={this.errorMessage} />}\n </form>\n );\n }\n}\n"]}
|