@seekora-ai/ui-sdk-vanilla 1.0.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.
Files changed (71) hide show
  1. package/dist/components/clear-refinements.d.ts +39 -0
  2. package/dist/components/clear-refinements.d.ts.map +1 -0
  3. package/dist/components/clear-refinements.js +133 -0
  4. package/dist/components/current-refinements.d.ts +36 -0
  5. package/dist/components/current-refinements.d.ts.map +1 -0
  6. package/dist/components/current-refinements.js +186 -0
  7. package/dist/components/facets.d.ts +45 -0
  8. package/dist/components/facets.d.ts.map +1 -0
  9. package/dist/components/facets.js +259 -0
  10. package/dist/components/hits-per-page.d.ts +37 -0
  11. package/dist/components/hits-per-page.d.ts.map +1 -0
  12. package/dist/components/hits-per-page.js +132 -0
  13. package/dist/components/infinite-hits.d.ts +61 -0
  14. package/dist/components/infinite-hits.d.ts.map +1 -0
  15. package/dist/components/infinite-hits.js +316 -0
  16. package/dist/components/pagination.d.ts +33 -0
  17. package/dist/components/pagination.d.ts.map +1 -0
  18. package/dist/components/pagination.js +364 -0
  19. package/dist/components/query-suggestions.d.ts +39 -0
  20. package/dist/components/query-suggestions.d.ts.map +1 -0
  21. package/dist/components/query-suggestions.js +217 -0
  22. package/dist/components/range-input.d.ts +42 -0
  23. package/dist/components/range-input.d.ts.map +1 -0
  24. package/dist/components/range-input.js +274 -0
  25. package/dist/components/search-bar.d.ts +140 -0
  26. package/dist/components/search-bar.d.ts.map +1 -0
  27. package/dist/components/search-bar.js +899 -0
  28. package/dist/components/search-layout.d.ts +35 -0
  29. package/dist/components/search-layout.d.ts.map +1 -0
  30. package/dist/components/search-layout.js +144 -0
  31. package/dist/components/search-provider.d.ts +28 -0
  32. package/dist/components/search-provider.d.ts.map +1 -0
  33. package/dist/components/search-provider.js +44 -0
  34. package/dist/components/search-results.d.ts +55 -0
  35. package/dist/components/search-results.d.ts.map +1 -0
  36. package/dist/components/search-results.js +537 -0
  37. package/dist/components/sort-by.d.ts +33 -0
  38. package/dist/components/sort-by.d.ts.map +1 -0
  39. package/dist/components/sort-by.js +122 -0
  40. package/dist/components/stats.d.ts +36 -0
  41. package/dist/components/stats.d.ts.map +1 -0
  42. package/dist/components/stats.js +138 -0
  43. package/dist/index.d.ts +670 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.esm.js +4008 -0
  46. package/dist/index.esm.js.map +1 -0
  47. package/dist/index.js +4055 -0
  48. package/dist/index.js.map +1 -0
  49. package/dist/index.umd.js +1 -0
  50. package/dist/themes/createTheme.d.ts +8 -0
  51. package/dist/themes/createTheme.d.ts.map +1 -0
  52. package/dist/themes/createTheme.js +10 -0
  53. package/dist/themes/dark.d.ts +6 -0
  54. package/dist/themes/dark.d.ts.map +1 -0
  55. package/dist/themes/dark.js +34 -0
  56. package/dist/themes/default.d.ts +6 -0
  57. package/dist/themes/default.d.ts.map +1 -0
  58. package/dist/themes/default.js +71 -0
  59. package/dist/themes/mergeThemes.d.ts +7 -0
  60. package/dist/themes/mergeThemes.d.ts.map +1 -0
  61. package/dist/themes/mergeThemes.js +6 -0
  62. package/dist/themes/minimal.d.ts +6 -0
  63. package/dist/themes/minimal.d.ts.map +1 -0
  64. package/dist/themes/minimal.js +34 -0
  65. package/dist/themes/types.d.ts +7 -0
  66. package/dist/themes/types.d.ts.map +1 -0
  67. package/dist/themes/types.js +6 -0
  68. package/dist/utils/search-manager.d.ts +33 -0
  69. package/dist/utils/search-manager.d.ts.map +1 -0
  70. package/dist/utils/search-manager.js +89 -0
  71. package/package.json +60 -0
@@ -0,0 +1,39 @@
1
+ /**
2
+ * ClearRefinements Component
3
+ *
4
+ * A standalone button to clear all active refinements/filters
5
+ * Integrates with SearchStateManager for automatic state sync
6
+ */
7
+ import { SearchProvider } from './search-provider';
8
+ export interface ClearRefinementsOptions {
9
+ container: HTMLElement | string;
10
+ /** Whether clicking should also clear the search query */
11
+ clearsQuery?: boolean;
12
+ /** Button text when there are refinements to clear */
13
+ resetLabel?: string;
14
+ /** Button text shown when there are no refinements */
15
+ disabledLabel?: string;
16
+ /** Fields to include (if not specified, all fields are included) */
17
+ includedFields?: string[];
18
+ /** Fields to exclude from clearing */
19
+ excludedFields?: string[];
20
+ /** Callback when refinements are cleared */
21
+ onClear?: () => void;
22
+ /** Whether to hide when there are no refinements */
23
+ hideWhenEmpty?: boolean;
24
+ }
25
+ export declare class ClearRefinements {
26
+ private container;
27
+ private provider;
28
+ private options;
29
+ private unsubscribeStateManager;
30
+ constructor(provider: SearchProvider, options: ClearRefinementsOptions);
31
+ destroy(): void;
32
+ private getRelevantRefinements;
33
+ private canClear;
34
+ private handleClick;
35
+ private render;
36
+ private get theme();
37
+ private getButtonStyle;
38
+ }
39
+ //# sourceMappingURL=clear-refinements.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clear-refinements.d.ts","sourceRoot":"","sources":["../../src/components/clear-refinements.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,WAAW,GAAG,MAAM,CAAC;IAChC,0DAA0D;IAC1D,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,sDAAsD;IACtD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oEAAoE;IACpE,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,sCAAsC;IACtC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,oDAAoD;IACpD,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,OAAO,CAQb;IACF,OAAO,CAAC,uBAAuB,CAA6B;gBAEhD,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,uBAAuB;IAgCtE,OAAO,IAAI,IAAI;IAQf,OAAO,CAAC,sBAAsB;IAS9B,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,WAAW;IAyCnB,OAAO,CAAC,MAAM;IAqBd,OAAO,KAAK,KAAK,GAEhB;IAED,OAAO,CAAC,cAAc;CAkBvB"}
@@ -0,0 +1,133 @@
1
+ /**
2
+ * ClearRefinements Component
3
+ *
4
+ * A standalone button to clear all active refinements/filters
5
+ * Integrates with SearchStateManager for automatic state sync
6
+ */
7
+ import { log } from '@seekora-ai/ui-sdk-core';
8
+ export class ClearRefinements {
9
+ constructor(provider, options) {
10
+ this.unsubscribeStateManager = null;
11
+ this.provider = provider;
12
+ const container = typeof options.container === 'string'
13
+ ? document.querySelector(options.container)
14
+ : options.container;
15
+ if (!container) {
16
+ const error = new Error('ClearRefinements: container element not found');
17
+ log.error('ClearRefinements: Initialization failed', { error: error.message });
18
+ throw error;
19
+ }
20
+ this.container = container;
21
+ this.options = {
22
+ clearsQuery: options.clearsQuery ?? false,
23
+ resetLabel: options.resetLabel ?? 'Clear all filters',
24
+ disabledLabel: options.disabledLabel ?? 'No filters applied',
25
+ includedFields: options.includedFields,
26
+ excludedFields: options.excludedFields ?? [],
27
+ onClear: options.onClear,
28
+ hideWhenEmpty: options.hideWhenEmpty ?? false,
29
+ };
30
+ // Subscribe to state manager to update on refinement changes
31
+ this.unsubscribeStateManager = this.provider.stateManager.subscribe(() => {
32
+ this.render();
33
+ });
34
+ this.render();
35
+ }
36
+ destroy() {
37
+ if (this.unsubscribeStateManager) {
38
+ this.unsubscribeStateManager();
39
+ this.unsubscribeStateManager = null;
40
+ }
41
+ this.container.innerHTML = '';
42
+ }
43
+ getRelevantRefinements() {
44
+ const refinements = this.provider.stateManager.getRefinements();
45
+ return refinements.filter(r => {
46
+ if (this.options.excludedFields.includes(r.field))
47
+ return false;
48
+ if (this.options.includedFields && !this.options.includedFields.includes(r.field))
49
+ return false;
50
+ return true;
51
+ });
52
+ }
53
+ canClear() {
54
+ const relevantRefinements = this.getRelevantRefinements();
55
+ const query = this.provider.stateManager.getQuery();
56
+ return relevantRefinements.length > 0 || (this.options.clearsQuery && query.length > 0);
57
+ }
58
+ handleClick() {
59
+ const canClear = this.canClear();
60
+ if (!canClear)
61
+ return;
62
+ const relevantRefinements = this.getRelevantRefinements();
63
+ log.verbose('ClearRefinements: Clearing refinements', {
64
+ count: relevantRefinements.length,
65
+ clearsQuery: this.options.clearsQuery,
66
+ });
67
+ // Clear relevant refinements
68
+ if (this.options.includedFields || this.options.excludedFields.length > 0) {
69
+ // Clear only specific refinements
70
+ relevantRefinements.forEach(r => {
71
+ this.provider.stateManager.removeRefinement(r.field, r.value, false);
72
+ });
73
+ }
74
+ else {
75
+ // Clear all refinements
76
+ this.provider.stateManager.clearRefinements(false);
77
+ }
78
+ // Clear query if requested
79
+ if (this.options.clearsQuery) {
80
+ this.provider.stateManager.setQuery('', true);
81
+ }
82
+ else if (relevantRefinements.length > 0) {
83
+ // Trigger search after clearing
84
+ this.provider.stateManager.search();
85
+ }
86
+ // Call the callback
87
+ if (this.options.onClear) {
88
+ try {
89
+ this.options.onClear();
90
+ }
91
+ catch (err) {
92
+ const error = err instanceof Error ? err : new Error(String(err));
93
+ log.error('ClearRefinements: Error in onClear callback', { error: error.message });
94
+ }
95
+ }
96
+ }
97
+ render() {
98
+ this.container.innerHTML = '';
99
+ const canClear = this.canClear();
100
+ // Hide when empty if requested
101
+ if (this.options.hideWhenEmpty && !canClear) {
102
+ return;
103
+ }
104
+ const button = document.createElement('button');
105
+ button.type = 'button';
106
+ button.textContent = canClear ? this.options.resetLabel : this.options.disabledLabel;
107
+ button.disabled = !canClear;
108
+ button.style.cssText = this.getButtonStyle(canClear);
109
+ button.setAttribute('aria-label', canClear ? this.options.resetLabel : this.options.disabledLabel);
110
+ button.addEventListener('click', () => this.handleClick());
111
+ this.container.appendChild(button);
112
+ }
113
+ get theme() {
114
+ return this.provider.theme;
115
+ }
116
+ getButtonStyle(canClear) {
117
+ const borderRadius = typeof this.theme.borderRadius === 'string'
118
+ ? this.theme.borderRadius
119
+ : this.theme.borderRadius.medium;
120
+ return `
121
+ padding: ${this.theme.spacing.small} ${this.theme.spacing.medium};
122
+ font-size: ${this.theme.typography.fontSize.medium};
123
+ font-weight: ${this.theme.typography.fontWeight?.medium || 500};
124
+ background-color: ${canClear ? this.theme.colors.primary : this.theme.colors.hover};
125
+ color: ${canClear ? '#ffffff' : this.theme.colors.textSecondary};
126
+ border: none;
127
+ border-radius: ${borderRadius};
128
+ cursor: ${canClear ? 'pointer' : 'not-allowed'};
129
+ opacity: ${canClear ? '1' : '0.6'};
130
+ transition: ${this.theme.transitions?.fast || '150ms ease-in-out'};
131
+ `;
132
+ }
133
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * CurrentRefinements Component
3
+ *
4
+ * Displays currently active filters/refinements with ability to clear them
5
+ */
6
+ import { SearchProvider } from './search-provider';
7
+ export interface Refinement {
8
+ field: string;
9
+ label?: string;
10
+ value: string;
11
+ displayValue?: string;
12
+ }
13
+ export interface CurrentRefinementsOptions {
14
+ container: HTMLElement | string;
15
+ refinements?: Refinement[];
16
+ showClearAll?: boolean;
17
+ onRefinementClear?: (field: string, value: string) => void;
18
+ onClearAll?: () => void;
19
+ }
20
+ export declare class CurrentRefinements {
21
+ private container;
22
+ private provider;
23
+ private options;
24
+ private unsubscribeStateManager;
25
+ constructor(provider: SearchProvider, options: CurrentRefinementsOptions);
26
+ update(options: Partial<Pick<CurrentRefinementsOptions, 'refinements'>>): void;
27
+ private render;
28
+ private get theme();
29
+ private getContainerStyle;
30
+ private getItemStyle;
31
+ private getLabelStyle;
32
+ private getValueStyle;
33
+ private getClearButtonStyle;
34
+ private getClearAllButtonStyle;
35
+ }
36
+ //# sourceMappingURL=current-refinements.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"current-refinements.d.ts","sourceRoot":"","sources":["../../src/components/current-refinements.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,WAAW,GAAG,MAAM,CAAC;IAChC,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,OAAO,CAAoM;IACnN,OAAO,CAAC,uBAAuB,CAA6B;gBAEhD,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,yBAAyB;IAmCxE,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,yBAAyB,EAAE,aAAa,CAAC,CAAC,GAAG,IAAI;IAO9E,OAAO,CAAC,MAAM;IAqFd,OAAO,KAAK,KAAK,GAEhB;IAED,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,YAAY;IAepB,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,mBAAmB;IAqB3B,OAAO,CAAC,sBAAsB;CAe/B"}
@@ -0,0 +1,186 @@
1
+ /**
2
+ * CurrentRefinements Component
3
+ *
4
+ * Displays currently active filters/refinements with ability to clear them
5
+ */
6
+ import { log } from '@seekora-ai/ui-sdk-core';
7
+ export class CurrentRefinements {
8
+ constructor(provider, options) {
9
+ this.unsubscribeStateManager = null;
10
+ this.provider = provider;
11
+ const container = typeof options.container === 'string'
12
+ ? document.querySelector(options.container)
13
+ : options.container;
14
+ if (!container) {
15
+ const error = new Error('CurrentRefinements: container element not found');
16
+ log.error('CurrentRefinements: Initialization failed', { error: error.message });
17
+ throw error;
18
+ }
19
+ this.container = container;
20
+ this.options = {
21
+ showClearAll: options.showClearAll !== false,
22
+ refinements: options.refinements || [],
23
+ onRefinementClear: options.onRefinementClear,
24
+ onClearAll: options.onClearAll,
25
+ };
26
+ // Subscribe to state manager to get refinements automatically
27
+ this.unsubscribeStateManager = this.provider.stateManager.subscribe((state) => {
28
+ // Convert state manager refinements to CurrentRefinements format
29
+ this.options.refinements = state.refinements.map(r => ({
30
+ field: r.field,
31
+ value: r.value,
32
+ label: r.field, // Use field as label if not provided
33
+ }));
34
+ this.render();
35
+ });
36
+ this.render();
37
+ }
38
+ update(options) {
39
+ if (options.refinements !== undefined) {
40
+ this.options.refinements = options.refinements;
41
+ this.render();
42
+ }
43
+ }
44
+ render() {
45
+ this.container.innerHTML = '';
46
+ if (!this.options.refinements || this.options.refinements.length === 0) {
47
+ return;
48
+ }
49
+ const wrapper = document.createElement('div');
50
+ wrapper.style.cssText = this.getContainerStyle();
51
+ this.options.refinements.forEach((refinement, index) => {
52
+ const item = document.createElement('div');
53
+ item.style.cssText = this.getItemStyle();
54
+ const label = document.createElement('span');
55
+ label.textContent = `${refinement.label || refinement.field}: `;
56
+ label.style.cssText = this.getLabelStyle();
57
+ item.appendChild(label);
58
+ const value = document.createElement('span');
59
+ value.textContent = refinement.displayValue || refinement.value;
60
+ value.style.cssText = this.getValueStyle();
61
+ item.appendChild(value);
62
+ const clearBtn = document.createElement('button');
63
+ clearBtn.innerHTML = '×';
64
+ clearBtn.type = 'button'; // Prevent form submission
65
+ clearBtn.style.cssText = this.getClearButtonStyle();
66
+ clearBtn.setAttribute('aria-label', `Clear ${refinement.field} filter`);
67
+ // Use a named function to ensure the listener is properly attached
68
+ const handleClearClick = (e) => {
69
+ e.preventDefault();
70
+ e.stopPropagation();
71
+ // Update state manager (automatically triggers search)
72
+ this.provider.stateManager.removeRefinement(refinement.field, refinement.value);
73
+ // Call callback for backwards compatibility
74
+ if (this.options.onRefinementClear) {
75
+ log.verbose('CurrentRefinements: Refinement cleared', { field: refinement.field, value: refinement.value });
76
+ try {
77
+ this.options.onRefinementClear(refinement.field, refinement.value);
78
+ }
79
+ catch (err) {
80
+ const error = err instanceof Error ? err : new Error(String(err));
81
+ log.error('CurrentRefinements: Error in onRefinementClear callback', {
82
+ field: refinement.field,
83
+ value: refinement.value,
84
+ error: error.message,
85
+ });
86
+ }
87
+ }
88
+ };
89
+ clearBtn.addEventListener('click', handleClearClick, { passive: false });
90
+ item.appendChild(clearBtn);
91
+ wrapper.appendChild(item);
92
+ });
93
+ if (this.options.showClearAll && this.options.refinements.length > 1) {
94
+ const clearAllBtn = document.createElement('button');
95
+ clearAllBtn.textContent = 'Clear all';
96
+ clearAllBtn.style.cssText = this.getClearAllButtonStyle();
97
+ // Use a named function to ensure the listener is properly attached
98
+ const handleClearAllClick = (e) => {
99
+ e.preventDefault();
100
+ e.stopPropagation();
101
+ // Clear all refinements in state manager (automatically triggers search)
102
+ this.provider.stateManager.clearRefinements();
103
+ // Call callback for backwards compatibility
104
+ if (this.options.onClearAll) {
105
+ this.options.onClearAll();
106
+ }
107
+ };
108
+ clearAllBtn.addEventListener('click', handleClearAllClick, { passive: false });
109
+ wrapper.appendChild(clearAllBtn);
110
+ }
111
+ this.container.appendChild(wrapper);
112
+ }
113
+ get theme() {
114
+ return this.provider.theme;
115
+ }
116
+ getContainerStyle() {
117
+ return `
118
+ display: flex;
119
+ flex-wrap: wrap;
120
+ align-items: center;
121
+ gap: ${this.theme.spacing.small};
122
+ `;
123
+ }
124
+ getItemStyle() {
125
+ const borderRadius = typeof this.theme.borderRadius === 'string'
126
+ ? this.theme.borderRadius
127
+ : this.theme.borderRadius.medium;
128
+ return `
129
+ display: inline-flex;
130
+ align-items: center;
131
+ padding: ${this.theme.spacing.small} ${this.theme.spacing.medium};
132
+ background-color: ${this.theme.colors.hover};
133
+ border: 1px solid ${this.theme.colors.border};
134
+ border-radius: ${borderRadius};
135
+ font-size: ${this.theme.typography.fontSize.small};
136
+ `;
137
+ }
138
+ getLabelStyle() {
139
+ return `
140
+ margin-right: ${this.theme.spacing.small};
141
+ color: ${this.theme.colors.text};
142
+ font-weight: ${this.theme.typography.fontWeight?.medium || 500};
143
+ `;
144
+ }
145
+ getValueStyle() {
146
+ return `
147
+ margin-right: ${this.theme.spacing.small};
148
+ color: ${this.theme.colors.text};
149
+ `;
150
+ }
151
+ getClearButtonStyle() {
152
+ const borderRadius = typeof this.theme.borderRadius === 'string'
153
+ ? this.theme.borderRadius
154
+ : this.theme.borderRadius.full || '50%';
155
+ return `
156
+ width: 20px;
157
+ height: 20px;
158
+ display: flex;
159
+ align-items: center;
160
+ justify-content: center;
161
+ border-radius: ${borderRadius};
162
+ background-color: transparent;
163
+ border: none;
164
+ color: ${this.theme.colors.text};
165
+ cursor: pointer;
166
+ font-size: ${this.theme.typography.fontSize.medium};
167
+ line-height: 1;
168
+ transition: ${this.theme.transitions?.fast || '150ms ease-in-out'};
169
+ `;
170
+ }
171
+ getClearAllButtonStyle() {
172
+ const borderRadius = typeof this.theme.borderRadius === 'string'
173
+ ? this.theme.borderRadius
174
+ : this.theme.borderRadius.medium;
175
+ return `
176
+ padding: ${this.theme.spacing.small} ${this.theme.spacing.medium};
177
+ font-size: ${this.theme.typography.fontSize.small};
178
+ color: ${this.theme.colors.primary};
179
+ background: transparent;
180
+ border: 1px solid ${this.theme.colors.border};
181
+ border-radius: ${borderRadius};
182
+ cursor: pointer;
183
+ transition: ${this.theme.transitions?.fast || '150ms ease-in-out'};
184
+ `;
185
+ }
186
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Facets Component
3
+ *
4
+ * Displays facet filters for search results
5
+ */
6
+ import type { SearchResponse } from '@seekora-ai/search-sdk';
7
+ import { SearchProvider } from './search-provider';
8
+ export interface FacetItem {
9
+ value: string;
10
+ count: number;
11
+ selected?: boolean;
12
+ }
13
+ export interface Facet {
14
+ field: string;
15
+ label?: string;
16
+ items: FacetItem[];
17
+ }
18
+ export interface FacetsOptions {
19
+ container: HTMLElement | string;
20
+ results?: SearchResponse | null;
21
+ facets?: Facet[];
22
+ maxItems?: number;
23
+ showMore?: boolean;
24
+ onFacetChange?: (field: string, value: string, selected: boolean) => void;
25
+ }
26
+ export declare class Facets {
27
+ private container;
28
+ private provider;
29
+ private options;
30
+ private expandedFacets;
31
+ private unsubscribeStateManager;
32
+ constructor(provider: SearchProvider, options: FacetsOptions);
33
+ update(options: Partial<Pick<FacetsOptions, 'results' | 'facets'>>): void;
34
+ private render;
35
+ private getFacets;
36
+ private get theme();
37
+ private getFacetStyle;
38
+ private getFacetHeaderStyle;
39
+ private getFacetListStyle;
40
+ private getFacetItemStyle;
41
+ private getFacetItemLabelStyle;
42
+ private getFacetItemCountStyle;
43
+ private getShowMoreStyle;
44
+ }
45
+ //# sourceMappingURL=facets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"facets.d.ts","sourceRoot":"","sources":["../../src/components/facets.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,WAAW,GAAG,MAAM,CAAC;IAChC,OAAO,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IAChC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;CAC3E;AAED,qBAAa,MAAM;IACjB,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,OAAO,CAAoJ;IACnK,OAAO,CAAC,cAAc,CAA+B;IACrD,OAAO,CAAC,uBAAuB,CAA6B;gBAEhD,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa;IAiC5D,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,QAAQ,CAAC,CAAC,GAAG,IAAI;IAMzE,OAAO,CAAC,MAAM;IA0Gd,OAAO,CAAC,SAAS;IA8EjB,OAAO,KAAK,KAAK,GAEhB;IAED,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,sBAAsB;IAS9B,OAAO,CAAC,sBAAsB;IAQ9B,OAAO,CAAC,gBAAgB;CAezB"}