@searchcraft/javascript-sdk 0.10.3 → 0.10.5
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/dist/components/index.d.ts +50 -20
- package/dist/components/index.js +4 -4
- package/dist/components/p-4dd1995c.js +193 -0
- package/dist/components/p-4dd1995c.js.map +1 -0
- package/dist/components/{p-6717ab82.js → p-6c471ee0.js} +3 -3
- package/dist/components/{p-6717ab82.js.map → p-6c471ee0.js.map} +1 -1
- package/dist/components/{p-d4558d44.js → p-7c10ca44.js} +273 -260
- package/dist/components/p-7c10ca44.js.map +1 -0
- package/dist/components/{p-da1fb5c0.js → p-8a4cfe99.js} +2 -2
- package/dist/components/{p-da1fb5c0.js.map → p-8a4cfe99.js.map} +1 -1
- package/dist/components/{p-508ee769.js → p-b72015a6.js} +2 -2
- package/dist/components/{p-508ee769.js.map → p-b72015a6.js.map} +1 -1
- package/dist/components/p-bb700499.js +338 -0
- package/dist/components/p-bb700499.js.map +1 -0
- package/dist/components/{p-5a4be632.js → p-bfad84c6.js} +13 -4
- package/dist/components/p-bfad84c6.js.map +1 -0
- package/dist/components/p-d54771ef.js +182 -0
- package/dist/components/p-d54771ef.js.map +1 -0
- package/dist/components/{p-fd564261.js → p-d9222264.js} +4 -4
- package/dist/components/{p-fd564261.js.map → p-d9222264.js.map} +1 -1
- package/dist/components/{p-ad569b01.js → p-f1afb299.js} +2 -2
- package/dist/components/{p-ad569b01.js.map → p-f1afb299.js.map} +1 -1
- package/dist/components/{p-06bac1fc.js → p-f4b0ff45.js} +3 -3
- package/dist/components/{p-06bac1fc.js.map → p-f4b0ff45.js.map} +1 -1
- package/dist/components/searchcraft-ad.js +1 -1
- package/dist/components/searchcraft-facet-list.js +1 -1
- package/dist/components/searchcraft-filter-panel.js +13 -18
- package/dist/components/searchcraft-filter-panel.js.map +1 -1
- package/dist/components/searchcraft-input-form.js +1 -1
- package/dist/components/searchcraft-pagination.js +1 -1
- package/dist/components/searchcraft-popover-button.js +1 -1
- package/dist/components/searchcraft-popover-footer.js +1 -1
- package/dist/components/searchcraft-popover-form.js +6 -6
- 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 +2 -2
- package/dist/components/searchcraft-search-result.js +1 -1
- package/dist/components/searchcraft-search-results-per-page.js +1 -1
- package/dist/components/searchcraft-search-results.js +3 -3
- package/dist/components/searchcraft-slider.js +1 -1
- package/dist/components/searchcraft-theme.js +1 -1
- package/dist/components/searchcraft-theme.js.map +1 -1
- package/dist/components/searchcraft-toggle-button.js +1 -1
- package/dist/hydrate/index.js +613 -386
- package/dist/hydrate/index.mjs +613 -386
- package/dist/themes/hologram.css +1 -1
- package/dist/themes/hologram.css.map +1 -1
- package/dist/types/components/searchcraft-facet-list/searchcraft-facet-list.d.ts +21 -13
- package/dist/types/components/searchcraft-filter-panel/searchcraft-filter-panel.d.ts +2 -2
- package/dist/types/components/searchcraft-input-form/searchcraft-input-form.d.ts +6 -0
- package/dist/types/components/searchcraft-slider/searchcraft-slider.d.ts +10 -4
- package/dist/types/components.d.ts +23 -7
- package/dist/types/store/SearchcraftStore.types.d.ts +3 -2
- package/dist/types/utils/facets.d.ts +20 -3
- package/dist/types/utils/throttle.d.ts +14 -0
- package/dist/types/utils/units.d.ts +33 -0
- package/package.json +3 -3
- package/dist/components/p-4d37616e.js +0 -105
- package/dist/components/p-4d37616e.js.map +0 -1
- package/dist/components/p-53c795bd.js +0 -279
- package/dist/components/p-53c795bd.js.map +0 -1
- package/dist/components/p-5a4be632.js.map +0 -1
- package/dist/components/p-7c650118.js +0 -110
- package/dist/components/p-7c650118.js.map +0 -1
- package/dist/components/p-d4558d44.js.map +0 -1
|
@@ -277,21 +277,33 @@ export interface ADMAd {
|
|
|
277
277
|
sale_price?: number;
|
|
278
278
|
term: string;
|
|
279
279
|
}
|
|
280
|
+
export type Facet = {
|
|
281
|
+
/**
|
|
282
|
+
* The path of the facet. The path represents where in the facet tree structure
|
|
283
|
+
* this facet exists. There is an arbitrary number of levels in a facet tree.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
*
|
|
287
|
+
* '/sports/college' - Represents that this is the facet node exists at [root] -> [sports] -> [college] in the facet tree.
|
|
288
|
+
* '/weather' - Represents that this facet exists at [root] -> [weather] in the facet tree
|
|
289
|
+
* '/news/local' - [root] -> [news] -> [local]
|
|
290
|
+
*/
|
|
291
|
+
path: string;
|
|
292
|
+
/**
|
|
293
|
+
* The count value just represents an arbitrary `count` metadata for this facet node.
|
|
294
|
+
*/
|
|
295
|
+
count: number;
|
|
296
|
+
};
|
|
297
|
+
export type FacetWithChildrenArray = Facet & {
|
|
298
|
+
children: FacetWithChildrenArray[] | null | undefined;
|
|
299
|
+
};
|
|
280
300
|
/**
|
|
281
301
|
* A Facet object returned in a search response.
|
|
282
302
|
*/
|
|
283
303
|
export type FacetRoot = {
|
|
284
|
-
[key: string]:
|
|
304
|
+
[key: string]: FacetWithChildrenArray[];
|
|
285
305
|
};
|
|
286
306
|
export type FacetPrime = FacetRoot[];
|
|
287
|
-
/**
|
|
288
|
-
* Represents the structure of facets, which group search results into categories.
|
|
289
|
-
*/
|
|
290
|
-
export interface FacetChild {
|
|
291
|
-
count: number;
|
|
292
|
-
path: string;
|
|
293
|
-
children?: FacetChild[];
|
|
294
|
-
}
|
|
295
307
|
/**
|
|
296
308
|
* Types of measure requests that can be sent to the /measure/event endpoint.
|
|
297
309
|
*/
|
|
@@ -538,9 +550,10 @@ declare class SearchClient {
|
|
|
538
550
|
/**
|
|
539
551
|
* Make the request to get the search results.
|
|
540
552
|
* @param {properties} properties - The properties for the search.
|
|
553
|
+
* @param sendTelemetry - Whether or not to emit measure and subscription events for this search.
|
|
541
554
|
* @returns
|
|
542
555
|
*/
|
|
543
|
-
getSearchResponseItems: (properties: SearchClientRequestProperties | string) => Promise<SearchcraftResponse>;
|
|
556
|
+
getSearchResponseItems: (properties: SearchClientRequestProperties | string, sendTelemetry?: boolean) => Promise<SearchcraftResponse>;
|
|
544
557
|
private handleGetSearchResponseItemsWithString;
|
|
545
558
|
private handleGetSearchResponseItemsWithObject;
|
|
546
559
|
/**
|
|
@@ -592,7 +605,7 @@ export declare class SearchcraftCore {
|
|
|
592
605
|
* Perform various actions when the input is cleared
|
|
593
606
|
*/
|
|
594
607
|
handleInputCleared(): void;
|
|
595
|
-
getResponseItems: (properties: SearchClientRequestProperties | string, searchCallback: (response: SearchcraftResponse, items: SearchClientResponseItem[]) => void, adCallback: (items: AdClientResponseItem[]) => void) => void;
|
|
608
|
+
getResponseItems: (properties: SearchClientRequestProperties | string, searchCallback: (response: SearchcraftResponse, items: SearchClientResponseItem[], supplementalResponse: SearchcraftResponse | undefined) => void, adCallback: (items: AdClientResponseItem[]) => void) => void;
|
|
596
609
|
}
|
|
597
610
|
/**
|
|
598
611
|
* Callable functions made available by the SearchcraftStore.
|
|
@@ -608,7 +621,7 @@ export interface SearchcraftStateFunctions {
|
|
|
608
621
|
search: () => Promise<void>;
|
|
609
622
|
set: (state: Partial<SearchcraftState> | ((state: SearchcraftState) => Partial<SearchcraftState>)) => SearchcraftState;
|
|
610
623
|
setAdClientResponseItems: (items: AdClientResponseItem[]) => void;
|
|
611
|
-
setSearchClientResponseItemsFromResponse: (response: SearchcraftResponse, items: SearchClientResponseItem[]) => void;
|
|
624
|
+
setSearchClientResponseItemsFromResponse: (response: SearchcraftResponse, items: SearchClientResponseItem[], supplementalResponse: SearchcraftResponse | undefined) => void;
|
|
612
625
|
setInitialSearchClientResponseItemsFromResponse: (response: SearchcraftResponse, items: SearchClientResponseItem[]) => void;
|
|
613
626
|
setInitialQuery: (query: string) => void;
|
|
614
627
|
setPopoverVisibility: (isVisible: boolean) => void;
|
|
@@ -642,7 +655,8 @@ export interface SearchcraftStateValues {
|
|
|
642
655
|
searchMode: "fuzzy" | "exact";
|
|
643
656
|
searchClientResponseItems: SearchClientResponseItem[];
|
|
644
657
|
searchResponseTimeTaken: number | undefined;
|
|
645
|
-
searchResponseFacetPrime: FacetPrime | undefined;
|
|
658
|
+
searchResponseFacetPrime: FacetPrime | undefined | null;
|
|
659
|
+
supplementalFacetPrime: FacetPrime | undefined | null;
|
|
646
660
|
searchResultsCount: number;
|
|
647
661
|
searchResultsPage: number;
|
|
648
662
|
searchResultsPerPage: number;
|
|
@@ -802,6 +816,10 @@ export namespace Components {
|
|
|
802
816
|
* The label rendered above the input.
|
|
803
817
|
*/
|
|
804
818
|
"inputLabel"?: string;
|
|
819
|
+
/**
|
|
820
|
+
* The placeholder's render behavior. 'hide-on-focus' - Hide the placeholder text immediately when the input form gains focus. 'hide-on-text-entered' - Only hide the placeholder when the input form has text entered into it.
|
|
821
|
+
*/
|
|
822
|
+
"placeholderBehavior"?: "hide-on-focus" | "hide-on-text-entered";
|
|
805
823
|
/**
|
|
806
824
|
* The input element's placeholder value.
|
|
807
825
|
*/
|
|
@@ -1148,13 +1166,13 @@ export namespace Components {
|
|
|
1148
1166
|
*/
|
|
1149
1167
|
interface SearchcraftSlider {
|
|
1150
1168
|
/**
|
|
1151
|
-
* The type of data
|
|
1169
|
+
* The type of data the sliders are using.
|
|
1152
1170
|
*/
|
|
1153
1171
|
"dataType": "number" | "date";
|
|
1154
1172
|
/**
|
|
1155
|
-
* The granularity
|
|
1173
|
+
* The date granularity to use. Used to format date labels.
|
|
1156
1174
|
*/
|
|
1157
|
-
"
|
|
1175
|
+
"dateGranularity"?: "year" | "month" | "day" | "hour";
|
|
1158
1176
|
/**
|
|
1159
1177
|
* The maximum value allowed.
|
|
1160
1178
|
*/
|
|
@@ -1163,6 +1181,10 @@ export namespace Components {
|
|
|
1163
1181
|
* The minimum value allowed.
|
|
1164
1182
|
*/
|
|
1165
1183
|
"min": number;
|
|
1184
|
+
/**
|
|
1185
|
+
* The step amount for the slider inputs.
|
|
1186
|
+
*/
|
|
1187
|
+
"step": number;
|
|
1166
1188
|
}
|
|
1167
1189
|
/**
|
|
1168
1190
|
* This web component adds Searchcraft's built-in css theme to your page. It does not render anything visible, its only function is to manage the css styles on the page.'
|
|
@@ -1829,7 +1851,7 @@ declare namespace LocalJSX {
|
|
|
1829
1851
|
*/
|
|
1830
1852
|
"fieldName"?: string;
|
|
1831
1853
|
/**
|
|
1832
|
-
*
|
|
1854
|
+
* Emitted when the facets are updated.
|
|
1833
1855
|
*/
|
|
1834
1856
|
"onFacetSelectionUpdated"?: (event: SearchcraftFacetListCustomEvent<{
|
|
1835
1857
|
paths: string[];
|
|
@@ -1916,6 +1938,10 @@ declare namespace LocalJSX {
|
|
|
1916
1938
|
* Event emitted when input initializes.
|
|
1917
1939
|
*/
|
|
1918
1940
|
"onInputInit"?: (event: SearchcraftInputFormCustomEvent<void>) => void;
|
|
1941
|
+
/**
|
|
1942
|
+
* The placeholder's render behavior. 'hide-on-focus' - Hide the placeholder text immediately when the input form gains focus. 'hide-on-text-entered' - Only hide the placeholder when the input form has text entered into it.
|
|
1943
|
+
*/
|
|
1944
|
+
"placeholderBehavior"?: "hide-on-focus" | "hide-on-text-entered";
|
|
1919
1945
|
/**
|
|
1920
1946
|
* The input element's placeholder value.
|
|
1921
1947
|
*/
|
|
@@ -2266,13 +2292,13 @@ declare namespace LocalJSX {
|
|
|
2266
2292
|
*/
|
|
2267
2293
|
interface SearchcraftSlider {
|
|
2268
2294
|
/**
|
|
2269
|
-
* The type of data
|
|
2295
|
+
* The type of data the sliders are using.
|
|
2270
2296
|
*/
|
|
2271
2297
|
"dataType"?: "number" | "date";
|
|
2272
2298
|
/**
|
|
2273
|
-
* The granularity
|
|
2299
|
+
* The date granularity to use. Used to format date labels.
|
|
2274
2300
|
*/
|
|
2275
|
-
"
|
|
2301
|
+
"dateGranularity"?: "year" | "month" | "day" | "hour";
|
|
2276
2302
|
/**
|
|
2277
2303
|
* The maximum value allowed.
|
|
2278
2304
|
*/
|
|
@@ -2285,6 +2311,10 @@ declare namespace LocalJSX {
|
|
|
2285
2311
|
* When the range has changed.
|
|
2286
2312
|
*/
|
|
2287
2313
|
"onRangeChanged"?: (event: SearchcraftSliderCustomEvent<any>) => void;
|
|
2314
|
+
/**
|
|
2315
|
+
* The step amount for the slider inputs.
|
|
2316
|
+
*/
|
|
2317
|
+
"step"?: number;
|
|
2288
2318
|
}
|
|
2289
2319
|
/**
|
|
2290
2320
|
* This web component adds Searchcraft's built-in css theme to your page. It does not render anything visible, its only function is to manage the css styles on the page.'
|
package/dist/components/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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 { v as SearchcraftCore, s as searchcraftStore } from './p-
|
|
2
|
+
import { v as ve } from './p-7c10ca44.js';
|
|
3
|
+
export { v as SearchcraftCore, s as searchcraftStore } from './p-7c10ca44.js';
|
|
4
4
|
export { SearchcraftAd, defineCustomElement as defineCustomElementSearchcraftAd } from './searchcraft-ad.js';
|
|
5
5
|
export { SearchcraftButton, defineCustomElement as defineCustomElementSearchcraftButton } from './searchcraft-button.js';
|
|
6
6
|
export { SearchcraftErrorMessage, defineCustomElement as defineCustomElementSearchcraftErrorMessage } from './searchcraft-error-message.js';
|
|
@@ -24,7 +24,7 @@ export { SearchcraftTheme, defineCustomElement as defineCustomElementSearchcraft
|
|
|
24
24
|
export { SearchcraftToggleButton, defineCustomElement as defineCustomElementSearchcraftToggleButton } from './searchcraft-toggle-button.js';
|
|
25
25
|
|
|
26
26
|
const name = "@searchcraft/javascript-sdk";
|
|
27
|
-
const version = "0.10.
|
|
27
|
+
const version = "0.10.5";
|
|
28
28
|
const description = "Searchcraft Javascript SDK";
|
|
29
29
|
const author = "Searchcraft Inc.";
|
|
30
30
|
const license = "Apache-2.0";
|
|
@@ -67,7 +67,7 @@ const dependencies = {
|
|
|
67
67
|
nanoid: "^5.0.9"
|
|
68
68
|
};
|
|
69
69
|
const devDependencies = {
|
|
70
|
-
"@searchcraft/core": "^0.10.
|
|
70
|
+
"@searchcraft/core": "^0.10.5",
|
|
71
71
|
"@stencil/core": "^4.7.0",
|
|
72
72
|
"@stencil/react-output-target": "^0.8.2",
|
|
73
73
|
"@stencil/sass": "^3.0.12",
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { p as proxyCustomElement, H, c as createEvent, h } from './p-5365011f.js';
|
|
2
|
+
import { a as getDifferenceInUnits, b as getStartOf, c as getFormattedDateString } from './p-d54771ef.js';
|
|
3
|
+
import './p-a64b4cba.js';
|
|
4
|
+
import { c as classNames } from './p-5cdc6210.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates a throttled version of the given function that only invokes
|
|
8
|
+
* the original function at most once every specified number of milliseconds.
|
|
9
|
+
*
|
|
10
|
+
* The logic is written in a way that the last invocation is always called, after the
|
|
11
|
+
* throttle cooldown period has ended.
|
|
12
|
+
*
|
|
13
|
+
* @template Arguments - The argument types for the function to throttle
|
|
14
|
+
* @param callback - The function to throttle
|
|
15
|
+
* @param delayInMilliseconds - The number of milliseconds to wait before allowing the next invocation
|
|
16
|
+
* @returns A throttled version of the original function
|
|
17
|
+
*/
|
|
18
|
+
function throttle(callback, delayInMilliseconds) {
|
|
19
|
+
let isThrottleOnCooldown = false;
|
|
20
|
+
let trailingCallArgs = null;
|
|
21
|
+
const invokeAction = (args) => {
|
|
22
|
+
callback(...args);
|
|
23
|
+
isThrottleOnCooldown = true;
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
isThrottleOnCooldown = false;
|
|
26
|
+
if (trailingCallArgs) {
|
|
27
|
+
const nextArgs = trailingCallArgs;
|
|
28
|
+
trailingCallArgs = null;
|
|
29
|
+
invokeAction(nextArgs);
|
|
30
|
+
}
|
|
31
|
+
}, delayInMilliseconds);
|
|
32
|
+
};
|
|
33
|
+
return (...args) => {
|
|
34
|
+
if (!isThrottleOnCooldown) {
|
|
35
|
+
invokeAction(args);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
trailingCallArgs = args;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const SearchcraftSlider = /*@__PURE__*/ proxyCustomElement(class SearchcraftSlider extends H {
|
|
44
|
+
constructor() {
|
|
45
|
+
super();
|
|
46
|
+
this.__registerHost();
|
|
47
|
+
this.rangeChanged = createEvent(this, "rangeChanged", 7);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The maximum value allowed.
|
|
51
|
+
*/
|
|
52
|
+
max = 100;
|
|
53
|
+
/**
|
|
54
|
+
* The minimum value allowed.
|
|
55
|
+
*/
|
|
56
|
+
min = 0;
|
|
57
|
+
/**
|
|
58
|
+
* The step amount for the slider inputs.
|
|
59
|
+
*/
|
|
60
|
+
step = 1;
|
|
61
|
+
/** The type of data the sliders are using. */
|
|
62
|
+
dataType = 'number';
|
|
63
|
+
/** The date granularity to use. Used to format date labels. */
|
|
64
|
+
dateGranularity;
|
|
65
|
+
lowerBound = 0;
|
|
66
|
+
upperBound = 1;
|
|
67
|
+
endValue = 0;
|
|
68
|
+
startValue = 0;
|
|
69
|
+
lastFocusedHandle = 'max';
|
|
70
|
+
throttledEmitUpdate = () => { };
|
|
71
|
+
/**
|
|
72
|
+
* When the range has changed.
|
|
73
|
+
* */
|
|
74
|
+
rangeChanged;
|
|
75
|
+
connectedCallback() {
|
|
76
|
+
switch (this.dataType) {
|
|
77
|
+
case 'number':
|
|
78
|
+
this.startValue = this.min;
|
|
79
|
+
this.endValue = this.max;
|
|
80
|
+
this.lowerBound = this.min;
|
|
81
|
+
this.upperBound = this.max;
|
|
82
|
+
break;
|
|
83
|
+
case 'date': {
|
|
84
|
+
this.startValue = 0;
|
|
85
|
+
this.endValue = getDifferenceInUnits(this.dateGranularity || 'year', this.min, this.max);
|
|
86
|
+
this.lowerBound = 0;
|
|
87
|
+
this.upperBound = this.endValue;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
this.throttledEmitUpdate = throttle(this.emitUpdate, 120);
|
|
92
|
+
}
|
|
93
|
+
emitUpdate = async () => {
|
|
94
|
+
switch (this.dataType) {
|
|
95
|
+
case 'number':
|
|
96
|
+
this.rangeChanged?.emit({
|
|
97
|
+
startValue: this.startValue,
|
|
98
|
+
endValue: this.endValue,
|
|
99
|
+
});
|
|
100
|
+
break;
|
|
101
|
+
case 'date': {
|
|
102
|
+
const granularity = this.dateGranularity || 'year';
|
|
103
|
+
const startTimestamp = getStartOf(this.min, granularity, this.lowerBound + this.startValue);
|
|
104
|
+
const endTimestamp = getStartOf(this.min, granularity, this.lowerBound + this.endValue + 1);
|
|
105
|
+
this.rangeChanged?.emit({
|
|
106
|
+
startValue: startTimestamp,
|
|
107
|
+
endValue: endTimestamp,
|
|
108
|
+
});
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
handleStartValueChange = (event) => {
|
|
114
|
+
const inputElement = event.target;
|
|
115
|
+
const value = Number.parseInt(inputElement.value, 10);
|
|
116
|
+
this.lastFocusedHandle = 'min';
|
|
117
|
+
if (value <= this.endValue) {
|
|
118
|
+
this.startValue = value;
|
|
119
|
+
this.throttledEmitUpdate();
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
this.startValue = this.endValue;
|
|
123
|
+
inputElement.value = `${this.endValue}`;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
handleEndValueChange = (event) => {
|
|
127
|
+
const inputElement = event.target;
|
|
128
|
+
const value = Number.parseInt(inputElement.value, 10);
|
|
129
|
+
this.lastFocusedHandle = 'max';
|
|
130
|
+
if (value >= this.startValue) {
|
|
131
|
+
this.endValue = value;
|
|
132
|
+
this.throttledEmitUpdate();
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
this.endValue = this.startValue;
|
|
136
|
+
inputElement.value = `${this.startValue}`;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
getLabel = (value) => {
|
|
140
|
+
switch (this.dataType) {
|
|
141
|
+
case 'number':
|
|
142
|
+
return `${this.startValue}`;
|
|
143
|
+
case 'date': {
|
|
144
|
+
const granularity = this.dateGranularity || 'year';
|
|
145
|
+
const dateOffset = this.lowerBound + value;
|
|
146
|
+
const timestamp = getStartOf(this.min, granularity, dateOffset);
|
|
147
|
+
return getFormattedDateString(this.dateGranularity || 'year', new Date(timestamp));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
render() {
|
|
152
|
+
const startPercent = ((this.startValue - this.lowerBound) /
|
|
153
|
+
(this.upperBound - this.lowerBound)) *
|
|
154
|
+
100;
|
|
155
|
+
const endPercent = ((this.endValue - this.lowerBound) /
|
|
156
|
+
(this.upperBound - this.lowerBound)) *
|
|
157
|
+
100;
|
|
158
|
+
const startLabel = this.getLabel(this.startValue);
|
|
159
|
+
const endLabel = this.getLabel(this.endValue);
|
|
160
|
+
return (h("div", { key: '3b2e8576d64826f123d40deff3b0df9316649a03', class: 'searchcraft-slider' }, h("div", { key: 'ecaa546b96855aad4e839c5e34e995da0925e0b6', class: 'searchcraft-slider-range' }, h("div", { key: 'f37fc0329249857a29f77d9e3739d10f05f6bf62', class: 'searchcraft-slider-active-range', style: {
|
|
161
|
+
left: `${startPercent}%`,
|
|
162
|
+
width: `${endPercent - startPercent}%`,
|
|
163
|
+
} }), h("input", { key: '7b5e6f3983b7c109ea0a3f2b248c35d0e225400b', class: classNames('searchcraft-slider-input', 'searchcraft-slider-input-min-handle'), max: this.upperBound, min: this.lowerBound, onInput: this.handleStartValueChange.bind(this), step: this.step, style: { zIndex: this.lastFocusedHandle === 'min' ? '2' : '1' }, type: 'range', value: this.startValue }), h("input", { key: 'b5bb628b73c8b582a31453e73cb3ef38579eeea5', class: classNames('searchcraft-slider-input', 'searchcraft-slider-input-max-handle'), max: this.upperBound, min: this.lowerBound, onInput: this.handleEndValueChange.bind(this), step: this.step, style: { zIndex: this.lastFocusedHandle === 'max' ? '2' : '1' }, type: 'range', value: this.endValue })), h("div", { key: 'ecb379babd244e3205f30d45628506566fbeff3c', class: 'searchcraft-slider-label' }, h("span", { key: '2be886d05c323f7da1059be88c0cb8ede2e1e98b', class: 'searchcraft-slider-start-label' }, startLabel), h("span", { key: 'bf66fcab3fae565980a4637cb13b14589ffcb5ba', class: 'searchcraft-slider-end-label' }, endLabel))));
|
|
164
|
+
}
|
|
165
|
+
}, [0, "searchcraft-slider", {
|
|
166
|
+
"max": [2],
|
|
167
|
+
"min": [2],
|
|
168
|
+
"step": [2],
|
|
169
|
+
"dataType": [1, "data-type"],
|
|
170
|
+
"dateGranularity": [1, "date-granularity"],
|
|
171
|
+
"lowerBound": [32],
|
|
172
|
+
"upperBound": [32],
|
|
173
|
+
"endValue": [32],
|
|
174
|
+
"startValue": [32],
|
|
175
|
+
"lastFocusedHandle": [32]
|
|
176
|
+
}]);
|
|
177
|
+
function defineCustomElement() {
|
|
178
|
+
if (typeof customElements === "undefined") {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const components = ["searchcraft-slider"];
|
|
182
|
+
components.forEach(tagName => { switch (tagName) {
|
|
183
|
+
case "searchcraft-slider":
|
|
184
|
+
if (!customElements.get(tagName)) {
|
|
185
|
+
customElements.define(tagName, SearchcraftSlider);
|
|
186
|
+
}
|
|
187
|
+
break;
|
|
188
|
+
} });
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export { SearchcraftSlider as S, defineCustomElement as d };
|
|
192
|
+
|
|
193
|
+
//# sourceMappingURL=p-4dd1995c.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"p-4dd1995c.js","mappings":";;;;;AAAA;;;;;;;;;;;;SAYgB,QAAQ,CAItB,QAAsC,EACtC,mBAA2B;IAE3B,IAAI,oBAAoB,GAAG,KAAK,CAAC;IACjC,IAAI,gBAAgB,GAAqB,IAAI,CAAC;IAE9C,MAAM,YAAY,GAAG,CAAC,IAAe;QACnC,QAAQ,CAA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ACf,0BAA0B,EAC1B,qCAAqC,CACtC,EACD,GAAG,EAAE,IAAI,CAAC,UAAU,EACpB,GAAG,EAAE,IAAI,CAAC,UAAU,EACpB,OAAO,EAAE,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,EAC7C,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,iBAAiB,KAAK,KAAK,GAAG,GAAG,GAAG,GAAG,EAAE,EAC/D,IAAI,EAAC,OAAO,EACZ,KAAK,EAAE,IAAI,CAAC,QAAQ,GACpB,CACE,EACN,4DAAK,KAAK,EAAC,0BAA0B,IACnC,6DAAM,KAAK,EAAC,gCAAgC,IAAE,UAAU,CAAQ,EAChE,6DAAM,KAAK,EAAC,8BAA8B,IAAE,QAAQ,CAAQ,CACxD,CACF,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/utils/throttle.ts","src/components/searchcraft-slider/searchcraft-slider.tsx"],"sourcesContent":["/**\n * Creates a throttled version of the given function that only invokes\n * the original function at most once every specified number of milliseconds.\n *\n * The logic is written in a way that the last invocation is always called, after the\n * throttle cooldown period has ended.\n *\n * @template Arguments - The argument types for the function to throttle\n * @param callback - The function to throttle\n * @param delayInMilliseconds - The number of milliseconds to wait before allowing the next invocation\n * @returns A throttled version of the original function\n */\nexport function throttle<\n // biome-ignore lint/suspicious/noExplicitAny: To be an effective util, this needs to be flexibile enough allow any type of arguments.\n Arguments extends any[],\n>(\n callback: (...args: Arguments) => void,\n delayInMilliseconds: number,\n): (...args: Arguments) => void {\n let isThrottleOnCooldown = false;\n let trailingCallArgs: Arguments | null = null;\n\n const invokeAction = (args: Arguments) => {\n callback(...args);\n isThrottleOnCooldown = true;\n setTimeout(() => {\n isThrottleOnCooldown = false;\n if (trailingCallArgs) {\n const nextArgs = trailingCallArgs;\n trailingCallArgs = null;\n invokeAction(nextArgs);\n }\n }, delayInMilliseconds);\n };\n\n return (...args: Arguments) => {\n if (!isThrottleOnCooldown) {\n invokeAction(args);\n } else {\n trailingCallArgs = args;\n }\n };\n}\n","import {\n Component,\n Event,\n type EventEmitter,\n h,\n State,\n Prop,\n} from '@stencil/core';\nimport {\n getDifferenceInUnits,\n getFormattedDateString,\n getStartOf,\n} from '@utils';\nimport { throttle } from '@utils/throttle';\nimport classNames from 'classnames';\n\n/**\n * This web component is designed to allow users to select a value from a range defined by a minimum and maximum value. The component renders a slider interface, which can be used to visually choose a value between two boundaries.\n *\n * @internal\n */\n@Component({\n tag: 'searchcraft-slider',\n shadow: false,\n})\nexport class SearchcraftSlider {\n /**\n * The maximum value allowed.\n */\n @Prop() max = 100;\n /**\n * The minimum value allowed.\n */\n @Prop() min = 0;\n /**\n * The step amount for the slider inputs.\n */\n @Prop() step = 1;\n /** The type of data the sliders are using. */\n @Prop() dataType: 'number' | 'date' = 'number';\n /** The date granularity to use. Used to format date labels. */\n @Prop() dateGranularity?: 'year' | 'month' | 'day' | 'hour';\n\n @State() lowerBound = 0;\n @State() upperBound = 1;\n @State() endValue = 0;\n @State() startValue = 0;\n @State() lastFocusedHandle: 'min' | 'max' = 'max';\n\n throttledEmitUpdate: () => void = () => {};\n\n /**\n * When the range has changed.\n * */\n @Event() rangeChanged:\n | EventEmitter<{ startValue: number; endValue: number }>\n | undefined;\n\n connectedCallback() {\n switch (this.dataType) {\n case 'number':\n this.startValue = this.min;\n this.endValue = this.max;\n this.lowerBound = this.min;\n this.upperBound = this.max;\n break;\n case 'date': {\n this.startValue = 0;\n this.endValue = getDifferenceInUnits(\n this.dateGranularity || 'year',\n this.min,\n this.max,\n );\n this.lowerBound = 0;\n this.upperBound = this.endValue;\n\n break;\n }\n }\n\n this.throttledEmitUpdate = throttle(this.emitUpdate, 120);\n }\n\n private emitUpdate = async () => {\n switch (this.dataType) {\n case 'number':\n this.rangeChanged?.emit({\n startValue: this.startValue,\n endValue: this.endValue,\n });\n break;\n case 'date': {\n const granularity = this.dateGranularity || 'year';\n const startTimestamp = getStartOf(\n this.min,\n granularity,\n this.lowerBound + this.startValue,\n );\n const endTimestamp = getStartOf(\n this.min,\n granularity,\n this.lowerBound + this.endValue + 1,\n );\n this.rangeChanged?.emit({\n startValue: startTimestamp,\n endValue: endTimestamp,\n });\n break;\n }\n }\n };\n\n private handleStartValueChange = (event: InputEvent) => {\n const inputElement = event.target as HTMLInputElement;\n const value = Number.parseInt(inputElement.value, 10);\n this.lastFocusedHandle = 'min';\n\n if (value <= this.endValue) {\n this.startValue = value;\n this.throttledEmitUpdate();\n } else {\n this.startValue = this.endValue;\n inputElement.value = `${this.endValue}`;\n }\n };\n\n private handleEndValueChange = (event: InputEvent) => {\n const inputElement = event.target as HTMLInputElement;\n const value = Number.parseInt(inputElement.value, 10);\n this.lastFocusedHandle = 'max';\n\n if (value >= this.startValue) {\n this.endValue = value;\n this.throttledEmitUpdate();\n } else {\n this.endValue = this.startValue;\n inputElement.value = `${this.startValue}`;\n }\n };\n\n private getLabel = (value): string => {\n switch (this.dataType) {\n case 'number':\n return `${this.startValue}`;\n case 'date': {\n const granularity = this.dateGranularity || 'year';\n const dateOffset = this.lowerBound + value;\n const timestamp = getStartOf(this.min, granularity, dateOffset);\n\n return getFormattedDateString(\n this.dateGranularity || 'year',\n new Date(timestamp),\n );\n }\n }\n };\n\n render() {\n const startPercent =\n ((this.startValue - this.lowerBound) /\n (this.upperBound - this.lowerBound)) *\n 100;\n const endPercent =\n ((this.endValue - this.lowerBound) /\n (this.upperBound - this.lowerBound)) *\n 100;\n\n const startLabel = this.getLabel(this.startValue);\n const endLabel = this.getLabel(this.endValue);\n\n return (\n <div class='searchcraft-slider'>\n <div class='searchcraft-slider-range'>\n <div\n class='searchcraft-slider-active-range'\n style={{\n left: `${startPercent}%`,\n width: `${endPercent - startPercent}%`,\n }}\n />\n <input\n class={classNames(\n 'searchcraft-slider-input',\n 'searchcraft-slider-input-min-handle',\n )}\n max={this.upperBound}\n min={this.lowerBound}\n onInput={this.handleStartValueChange.bind(this)}\n step={this.step}\n style={{ zIndex: this.lastFocusedHandle === 'min' ? '2' : '1' }}\n type='range'\n value={this.startValue}\n />\n <input\n class={classNames(\n 'searchcraft-slider-input',\n 'searchcraft-slider-input-max-handle',\n )}\n max={this.upperBound}\n min={this.lowerBound}\n onInput={this.handleEndValueChange.bind(this)}\n step={this.step}\n style={{ zIndex: this.lastFocusedHandle === 'max' ? '2' : '1' }}\n type='range'\n value={this.endValue}\n />\n </div>\n <div class='searchcraft-slider-label'>\n <span class='searchcraft-slider-start-label'>{startLabel}</span>\n <span class='searchcraft-slider-end-label'>{endLabel}</span>\n </div>\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { p as proxyCustomElement, H, h } from './p-5365011f.js';
|
|
2
|
-
import { s as searchcraftStore } from './p-
|
|
3
|
-
import {
|
|
2
|
+
import { s as searchcraftStore } from './p-7c10ca44.js';
|
|
3
|
+
import { g as getDocumentValueFromSearchResultMapping } from './p-d54771ef.js';
|
|
4
4
|
import './p-a64b4cba.js';
|
|
5
5
|
|
|
6
6
|
const SearchcraftPopoverListItem = /*@__PURE__*/ proxyCustomElement(class SearchcraftPopoverListItem extends H {
|
|
@@ -73,4 +73,4 @@ function defineCustomElement() {
|
|
|
73
73
|
|
|
74
74
|
export { SearchcraftPopoverListItem as S, defineCustomElement as d };
|
|
75
75
|
|
|
76
|
-
//# sourceMappingURL=p-
|
|
76
|
+
//# sourceMappingURL=p-6c471ee0.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"p-
|
|
1
|
+
{"file":"p-6c471ee0.js","mappings":";;;;;MAkBa,0BAA0B;;;;;IAC7B,IAAI,CAAuC;IAC3C,qBAAqB,CAAoC;;IAEzD,gBAAgB,GAAG,CAAC,CAAC;IAEpB,KAAK,CAAU;IACf,QAAQ,CAAU;IAClB,IAAI,CAAU;IACd,WAAW,CAAU;IACrB,QAAQ,CAAU;IAE3B,qBAAqB,CAAC,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1C,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,IAEvC,IAAI,CAAC,WAAW,KACf,4DAAK,KAAK,EAAC,6CAA6C,IACtD,4DACE,GAAG,EAAE,IAAI,CAAC,QAAQ,EAClB,GAAG,EAAE,IAAI,CAAC,WAAW,EACrB,KAAK,EAAC,qCAAqC,GAC3C,CACE,CACP,EACD,4DAAK,KAAK,EAAC,uCAAuC,IAC/C,IAAI,CAAC,KAAK,KACT,0DAAG,KAAK,EAAC,6CAA6C,IACnD,IAAI,CAAC,KAAK,CACT,CACL,EACA,IAAI,CAAC,QAAQ,KACZ,0DAAG,KAAK,EAAC,gDAAgD,IACtD,IAAI,CAAC,QAAQ,CACZ,CACL,CACG,CACJ,CACA,EACN;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() title?: string;\n @State() subtitle?: string;\n @State() href?: string;\n @State() imageSource?: string;\n @State() imageAlt?: string;\n\n mapValuesFromDocument(document: SearchDocument) {\n this.title = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.title,\n );\n this.subtitle = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.subtitle,\n );\n this.href = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.href,\n );\n this.imageSource = 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 core = state.getSearchcraftCore();\n\n if (core) {\n const document_position = this.documentPosition;\n const search_term = state.searchTerm;\n const number_of_documents = state.searchClientResponseItems.length || 0;\n\n core.measureClient?.sendMeasureEvent('document_clicked', {\n document_position,\n number_of_documents,\n search_term,\n });\n }\n };\n\n render() {\n return (\n <div class='searchcraft-popover-list-item'>\n <a\n class='searchcraft-popover-list-item-link'\n href={this.href}\n onClick={this.handleLinkClick.bind(this)}\n >\n {this.imageSource && (\n <div class='searchcraft-popover-list-item-image-wrapper'>\n <img\n alt={this.imageAlt}\n src={this.imageSource}\n class='searchcraft-popover-list-item-image'\n />\n </div>\n )}\n <div class='searchcraft-popover-list-item-content'>\n {this.title && (\n <p class='searchcraft-popover-list-item-content-title'>\n {this.title}\n </p>\n )}\n {this.subtitle && (\n <p class='searchcraft-popover-list-item-content-subtitle'>\n {this.subtitle}\n </p>\n )}\n </div>\n </a>\n </div>\n );\n }\n}\n"],"version":3}
|