@seekora-ai/ui-sdk-angular 0.2.11 → 0.2.13

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/index.d.ts CHANGED
@@ -1,11 +1,51 @@
1
+ import { OnInit, OnDestroy, Injector, ElementRef, OnChanges, TemplateRef } from '@angular/core';
1
2
  import { SeekoraClient, SearchResponse, SearchContext, SearchOptions } from '@seekora-ai/search-sdk';
2
3
  import * as _seekora_ai_ui_sdk_types from '@seekora-ai/ui-sdk-types';
3
4
  import { Theme, ThemeConfig, SuggestionItem, ViewMode, FieldMapping, ResultItem } from '@seekora-ai/ui-sdk-types';
4
5
  export { FieldMapping, ResultItem, SuggestionItem, Theme, ThemeConfig, ViewMode } from '@seekora-ai/ui-sdk-types';
5
6
  import { Observable } from 'rxjs';
6
- import { OnInit, OnDestroy, Injector, ElementRef, OnChanges, TemplateRef } from '@angular/core';
7
7
  export { mergeThemes } from '@seekora-ai/ui-sdk-core';
8
8
 
9
+ type RatingVariant = 'stars-only' | 'compact' | 'full' | 'inline';
10
+ type RatingSize = 'small' | 'medium' | 'large';
11
+ declare class RatingDisplayComponent implements OnInit {
12
+ rating: number;
13
+ reviewCount?: number;
14
+ variant: RatingVariant;
15
+ size: RatingSize;
16
+ maxRating: number;
17
+ showNumeric: boolean;
18
+ showHalfStars: boolean;
19
+ interactive: boolean;
20
+ starColor: string;
21
+ emptyStarColor: string;
22
+ textColor: string;
23
+ showReviewCount: boolean;
24
+ reviewCountFormat?: (count: number) => string;
25
+ className: string;
26
+ ratingChange: any;
27
+ hoverRating: number | null;
28
+ private sizeMap;
29
+ private fontSizeMap;
30
+ ngOnInit(): void;
31
+ get starSize(): number;
32
+ get fontSize(): string;
33
+ get clampedRating(): number;
34
+ get displayRating(): number;
35
+ get stars(): number[];
36
+ isStarFilled(index: number): boolean;
37
+ isStarHalf(index: number): boolean;
38
+ formatReviewCount(count: number): string;
39
+ onStarHover(rating: number): void;
40
+ onStarClick(rating: number): void;
41
+ onMouseLeave(): void;
42
+ getStarSVG(filled: boolean, half: boolean): string;
43
+ get containerClasses(): string;
44
+ get containerStyles(): {
45
+ [key: string]: string;
46
+ };
47
+ }
48
+
9
49
  /**
10
50
  * SearchContext Service
11
51
  *
@@ -429,5 +469,5 @@ declare const minimalTheme: Theme;
429
469
 
430
470
  declare const createTheme: (config: ThemeConfig) => _seekora_ai_ui_sdk_types.Theme;
431
471
 
432
- export { CurrentRefinementsComponent, FacetsComponent, PaginationComponent, QuerySuggestionsComponent, QuerySuggestionsService, RangeInputComponent, SEEKORA_CLIENT, SEEKORA_THEME_CONFIG, SearchBarComponent, SearchContextService, SearchLayoutComponent, SearchProviderComponent, SearchResultsComponent, SeekoraSearchService, SortByComponent, StatsComponent, createTheme, darkTheme, defaultTheme, minimalTheme };
433
- export type { Facet, FacetCount, Refinement, SearchState, SortOption, SuggestionsState };
472
+ export { CurrentRefinementsComponent, FacetsComponent, PaginationComponent, QuerySuggestionsComponent, QuerySuggestionsService, RangeInputComponent, RatingDisplayComponent, SEEKORA_CLIENT, SEEKORA_THEME_CONFIG, SearchBarComponent, SearchContextService, SearchLayoutComponent, SearchProviderComponent, SearchResultsComponent, SeekoraSearchService, SortByComponent, StatsComponent, createTheme, darkTheme, defaultTheme, minimalTheme };
473
+ export type { Facet, FacetCount, RatingSize, RatingVariant, Refinement, SearchState, SortOption, SuggestionsState };
package/dist/index.esm.js CHANGED
@@ -1,4 +1,5 @@
1
- import { InjectionToken, Injectable, Component, Input, Output, ViewChild, EventEmitter, ContentChild } from '@angular/core';
1
+ import { Component, Input, Output, EventEmitter, InjectionToken, Injectable, ViewChild, ContentChild } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
2
3
  import { createTheme as createTheme$1, log, extractField, formatPrice } from '@seekora-ai/ui-sdk-core';
3
4
  export { mergeThemes } from '@seekora-ai/ui-sdk-core';
4
5
  import { BehaviorSubject, from, Subject, Subscription } from 'rxjs';
@@ -64,6 +65,241 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
64
65
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
65
66
  };
66
67
 
68
+ let RatingDisplayComponent = (() => {
69
+ let _classDecorators = [Component({
70
+ selector: 'seekora-rating-display',
71
+ standalone: true,
72
+ imports: [CommonModule],
73
+ templateUrl: './rating-display.component.html',
74
+ styleUrls: ['./rating-display.component.css']
75
+ })];
76
+ let _classDescriptor;
77
+ let _classExtraInitializers = [];
78
+ let _classThis;
79
+ let _rating_decorators;
80
+ let _rating_initializers = [];
81
+ let _rating_extraInitializers = [];
82
+ let _reviewCount_decorators;
83
+ let _reviewCount_initializers = [];
84
+ let _reviewCount_extraInitializers = [];
85
+ let _variant_decorators;
86
+ let _variant_initializers = [];
87
+ let _variant_extraInitializers = [];
88
+ let _size_decorators;
89
+ let _size_initializers = [];
90
+ let _size_extraInitializers = [];
91
+ let _maxRating_decorators;
92
+ let _maxRating_initializers = [];
93
+ let _maxRating_extraInitializers = [];
94
+ let _showNumeric_decorators;
95
+ let _showNumeric_initializers = [];
96
+ let _showNumeric_extraInitializers = [];
97
+ let _showHalfStars_decorators;
98
+ let _showHalfStars_initializers = [];
99
+ let _showHalfStars_extraInitializers = [];
100
+ let _interactive_decorators;
101
+ let _interactive_initializers = [];
102
+ let _interactive_extraInitializers = [];
103
+ let _starColor_decorators;
104
+ let _starColor_initializers = [];
105
+ let _starColor_extraInitializers = [];
106
+ let _emptyStarColor_decorators;
107
+ let _emptyStarColor_initializers = [];
108
+ let _emptyStarColor_extraInitializers = [];
109
+ let _textColor_decorators;
110
+ let _textColor_initializers = [];
111
+ let _textColor_extraInitializers = [];
112
+ let _showReviewCount_decorators;
113
+ let _showReviewCount_initializers = [];
114
+ let _showReviewCount_extraInitializers = [];
115
+ let _reviewCountFormat_decorators;
116
+ let _reviewCountFormat_initializers = [];
117
+ let _reviewCountFormat_extraInitializers = [];
118
+ let _className_decorators;
119
+ let _className_initializers = [];
120
+ let _className_extraInitializers = [];
121
+ let _ratingChange_decorators;
122
+ let _ratingChange_initializers = [];
123
+ let _ratingChange_extraInitializers = [];
124
+ _classThis = class {
125
+ constructor() {
126
+ this.rating = __runInitializers(this, _rating_initializers, 0);
127
+ this.reviewCount = (__runInitializers(this, _rating_extraInitializers), __runInitializers(this, _reviewCount_initializers, void 0));
128
+ this.variant = (__runInitializers(this, _reviewCount_extraInitializers), __runInitializers(this, _variant_initializers, 'compact'));
129
+ this.size = (__runInitializers(this, _variant_extraInitializers), __runInitializers(this, _size_initializers, 'medium'));
130
+ this.maxRating = (__runInitializers(this, _size_extraInitializers), __runInitializers(this, _maxRating_initializers, 5));
131
+ this.showNumeric = (__runInitializers(this, _maxRating_extraInitializers), __runInitializers(this, _showNumeric_initializers, false));
132
+ this.showHalfStars = (__runInitializers(this, _showNumeric_extraInitializers), __runInitializers(this, _showHalfStars_initializers, true));
133
+ this.interactive = (__runInitializers(this, _showHalfStars_extraInitializers), __runInitializers(this, _interactive_initializers, false));
134
+ this.starColor = (__runInitializers(this, _interactive_extraInitializers), __runInitializers(this, _starColor_initializers, '#f59e0b'));
135
+ this.emptyStarColor = (__runInitializers(this, _starColor_extraInitializers), __runInitializers(this, _emptyStarColor_initializers, '#d1d5db'));
136
+ this.textColor = (__runInitializers(this, _emptyStarColor_extraInitializers), __runInitializers(this, _textColor_initializers, 'var(--seekora-text-secondary, #6b7280)'));
137
+ this.showReviewCount = (__runInitializers(this, _textColor_extraInitializers), __runInitializers(this, _showReviewCount_initializers, true));
138
+ this.reviewCountFormat = (__runInitializers(this, _showReviewCount_extraInitializers), __runInitializers(this, _reviewCountFormat_initializers, void 0));
139
+ this.className = (__runInitializers(this, _reviewCountFormat_extraInitializers), __runInitializers(this, _className_initializers, ''));
140
+ this.ratingChange = (__runInitializers(this, _className_extraInitializers), __runInitializers(this, _ratingChange_initializers, new EventEmitter()));
141
+ this.hoverRating = (__runInitializers(this, _ratingChange_extraInitializers), null);
142
+ this.sizeMap = {
143
+ small: 14,
144
+ medium: 18,
145
+ large: 24,
146
+ };
147
+ this.fontSizeMap = {
148
+ small: '0.75rem',
149
+ medium: '0.875rem',
150
+ large: '1rem',
151
+ };
152
+ }
153
+ ngOnInit() { }
154
+ get starSize() {
155
+ return this.sizeMap[this.size];
156
+ }
157
+ get fontSize() {
158
+ return this.fontSizeMap[this.size];
159
+ }
160
+ get clampedRating() {
161
+ return Math.max(0, Math.min(this.maxRating, this.rating));
162
+ }
163
+ get displayRating() {
164
+ return this.interactive && this.hoverRating !== null
165
+ ? this.hoverRating
166
+ : this.clampedRating;
167
+ }
168
+ get stars() {
169
+ return Array.from({ length: this.maxRating }, (_, i) => i + 1);
170
+ }
171
+ isStarFilled(index) {
172
+ return index <= Math.floor(this.displayRating);
173
+ }
174
+ isStarHalf(index) {
175
+ return (this.showHalfStars &&
176
+ index === Math.ceil(this.displayRating) &&
177
+ this.displayRating % 1 >= 0.25 &&
178
+ this.displayRating % 1 < 0.75);
179
+ }
180
+ formatReviewCount(count) {
181
+ if (this.reviewCountFormat) {
182
+ return this.reviewCountFormat(count);
183
+ }
184
+ if (count >= 1000000)
185
+ return `${(count / 1000000).toFixed(1)}M`;
186
+ if (count >= 1000)
187
+ return `${(count / 1000).toFixed(1)}K`;
188
+ return count.toString();
189
+ }
190
+ onStarHover(rating) {
191
+ if (this.interactive) {
192
+ this.hoverRating = rating;
193
+ }
194
+ }
195
+ onStarClick(rating) {
196
+ if (this.interactive) {
197
+ this.hoverRating = null;
198
+ this.ratingChange.emit(rating);
199
+ }
200
+ }
201
+ onMouseLeave() {
202
+ if (this.interactive) {
203
+ this.hoverRating = null;
204
+ }
205
+ }
206
+ getStarSVG(filled, half) {
207
+ if (half) {
208
+ const gradientId = `half-fill-${Math.random()}`;
209
+ return `
210
+ <svg width="${this.starSize}" height="${this.starSize}" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
211
+ <defs>
212
+ <linearGradient id="${gradientId}">
213
+ <stop offset="50%" stop-color="${this.starColor}" />
214
+ <stop offset="50%" stop-color="${this.emptyStarColor}" />
215
+ </linearGradient>
216
+ </defs>
217
+ <path
218
+ d="M12 2L15.09 8.26L22 9.27L17 14.14L18.18 21.02L12 17.77L5.82 21.02L7 14.14L2 9.27L8.91 8.26L12 2Z"
219
+ fill="url(#${gradientId})"
220
+ stroke="${this.starColor}"
221
+ stroke-width="1"
222
+ />
223
+ </svg>
224
+ `;
225
+ }
226
+ return `
227
+ <svg width="${this.starSize}" height="${this.starSize}" viewBox="0 0 24 24" fill="${filled ? this.starColor : 'none'}" xmlns="http://www.w3.org/2000/svg">
228
+ <path
229
+ d="M12 2L15.09 8.26L22 9.27L17 14.14L18.18 21.02L12 17.77L5.82 21.02L7 14.14L2 9.27L8.91 8.26L12 2Z"
230
+ stroke="${filled ? this.starColor : this.emptyStarColor}"
231
+ stroke-width="1.5"
232
+ stroke-linecap="round"
233
+ stroke-linejoin="round"
234
+ />
235
+ </svg>
236
+ `;
237
+ }
238
+ get containerClasses() {
239
+ return `seekora-rating-display seekora-rating-display--${this.variant} ${this.className}`;
240
+ }
241
+ get containerStyles() {
242
+ const baseStyles = {
243
+ fontSize: this.fontSize,
244
+ };
245
+ if (this.variant === 'stars-only') {
246
+ return { ...baseStyles, display: 'inline-flex', alignItems: 'center', gap: '2px' };
247
+ }
248
+ else if (this.variant === 'compact' || this.variant === 'inline') {
249
+ return {
250
+ ...baseStyles,
251
+ display: 'inline-flex',
252
+ alignItems: 'center',
253
+ gap: this.variant === 'inline' ? '6px' : '4px',
254
+ };
255
+ }
256
+ else if (this.variant === 'full') {
257
+ return { ...baseStyles, display: 'flex', flexDirection: 'column', gap: '4px' };
258
+ }
259
+ return baseStyles;
260
+ }
261
+ };
262
+ __setFunctionName(_classThis, "RatingDisplayComponent");
263
+ (() => {
264
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
265
+ _rating_decorators = [Input()];
266
+ _reviewCount_decorators = [Input()];
267
+ _variant_decorators = [Input()];
268
+ _size_decorators = [Input()];
269
+ _maxRating_decorators = [Input()];
270
+ _showNumeric_decorators = [Input()];
271
+ _showHalfStars_decorators = [Input()];
272
+ _interactive_decorators = [Input()];
273
+ _starColor_decorators = [Input()];
274
+ _emptyStarColor_decorators = [Input()];
275
+ _textColor_decorators = [Input()];
276
+ _showReviewCount_decorators = [Input()];
277
+ _reviewCountFormat_decorators = [Input()];
278
+ _className_decorators = [Input()];
279
+ _ratingChange_decorators = [Output()];
280
+ __esDecorate(null, null, _rating_decorators, { kind: "field", name: "rating", static: false, private: false, access: { has: obj => "rating" in obj, get: obj => obj.rating, set: (obj, value) => { obj.rating = value; } }, metadata: _metadata }, _rating_initializers, _rating_extraInitializers);
281
+ __esDecorate(null, null, _reviewCount_decorators, { kind: "field", name: "reviewCount", static: false, private: false, access: { has: obj => "reviewCount" in obj, get: obj => obj.reviewCount, set: (obj, value) => { obj.reviewCount = value; } }, metadata: _metadata }, _reviewCount_initializers, _reviewCount_extraInitializers);
282
+ __esDecorate(null, null, _variant_decorators, { kind: "field", name: "variant", static: false, private: false, access: { has: obj => "variant" in obj, get: obj => obj.variant, set: (obj, value) => { obj.variant = value; } }, metadata: _metadata }, _variant_initializers, _variant_extraInitializers);
283
+ __esDecorate(null, null, _size_decorators, { kind: "field", name: "size", static: false, private: false, access: { has: obj => "size" in obj, get: obj => obj.size, set: (obj, value) => { obj.size = value; } }, metadata: _metadata }, _size_initializers, _size_extraInitializers);
284
+ __esDecorate(null, null, _maxRating_decorators, { kind: "field", name: "maxRating", static: false, private: false, access: { has: obj => "maxRating" in obj, get: obj => obj.maxRating, set: (obj, value) => { obj.maxRating = value; } }, metadata: _metadata }, _maxRating_initializers, _maxRating_extraInitializers);
285
+ __esDecorate(null, null, _showNumeric_decorators, { kind: "field", name: "showNumeric", static: false, private: false, access: { has: obj => "showNumeric" in obj, get: obj => obj.showNumeric, set: (obj, value) => { obj.showNumeric = value; } }, metadata: _metadata }, _showNumeric_initializers, _showNumeric_extraInitializers);
286
+ __esDecorate(null, null, _showHalfStars_decorators, { kind: "field", name: "showHalfStars", static: false, private: false, access: { has: obj => "showHalfStars" in obj, get: obj => obj.showHalfStars, set: (obj, value) => { obj.showHalfStars = value; } }, metadata: _metadata }, _showHalfStars_initializers, _showHalfStars_extraInitializers);
287
+ __esDecorate(null, null, _interactive_decorators, { kind: "field", name: "interactive", static: false, private: false, access: { has: obj => "interactive" in obj, get: obj => obj.interactive, set: (obj, value) => { obj.interactive = value; } }, metadata: _metadata }, _interactive_initializers, _interactive_extraInitializers);
288
+ __esDecorate(null, null, _starColor_decorators, { kind: "field", name: "starColor", static: false, private: false, access: { has: obj => "starColor" in obj, get: obj => obj.starColor, set: (obj, value) => { obj.starColor = value; } }, metadata: _metadata }, _starColor_initializers, _starColor_extraInitializers);
289
+ __esDecorate(null, null, _emptyStarColor_decorators, { kind: "field", name: "emptyStarColor", static: false, private: false, access: { has: obj => "emptyStarColor" in obj, get: obj => obj.emptyStarColor, set: (obj, value) => { obj.emptyStarColor = value; } }, metadata: _metadata }, _emptyStarColor_initializers, _emptyStarColor_extraInitializers);
290
+ __esDecorate(null, null, _textColor_decorators, { kind: "field", name: "textColor", static: false, private: false, access: { has: obj => "textColor" in obj, get: obj => obj.textColor, set: (obj, value) => { obj.textColor = value; } }, metadata: _metadata }, _textColor_initializers, _textColor_extraInitializers);
291
+ __esDecorate(null, null, _showReviewCount_decorators, { kind: "field", name: "showReviewCount", static: false, private: false, access: { has: obj => "showReviewCount" in obj, get: obj => obj.showReviewCount, set: (obj, value) => { obj.showReviewCount = value; } }, metadata: _metadata }, _showReviewCount_initializers, _showReviewCount_extraInitializers);
292
+ __esDecorate(null, null, _reviewCountFormat_decorators, { kind: "field", name: "reviewCountFormat", static: false, private: false, access: { has: obj => "reviewCountFormat" in obj, get: obj => obj.reviewCountFormat, set: (obj, value) => { obj.reviewCountFormat = value; } }, metadata: _metadata }, _reviewCountFormat_initializers, _reviewCountFormat_extraInitializers);
293
+ __esDecorate(null, null, _className_decorators, { kind: "field", name: "className", static: false, private: false, access: { has: obj => "className" in obj, get: obj => obj.className, set: (obj, value) => { obj.className = value; } }, metadata: _metadata }, _className_initializers, _className_extraInitializers);
294
+ __esDecorate(null, null, _ratingChange_decorators, { kind: "field", name: "ratingChange", static: false, private: false, access: { has: obj => "ratingChange" in obj, get: obj => obj.ratingChange, set: (obj, value) => { obj.ratingChange = value; } }, metadata: _metadata }, _ratingChange_initializers, _ratingChange_extraInitializers);
295
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
296
+ _classThis = _classDescriptor.value;
297
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
298
+ __runInitializers(_classThis, _classExtraInitializers);
299
+ })();
300
+ return _classThis;
301
+ })();
302
+
67
303
  /**
68
304
  * Default Theme
69
305
  */
@@ -2522,5 +2758,5 @@ const minimalTheme = {
2522
2758
  },
2523
2759
  };
2524
2760
 
2525
- export { CurrentRefinementsComponent, FacetsComponent, PaginationComponent, QuerySuggestionsComponent, QuerySuggestionsService, RangeInputComponent, SEEKORA_CLIENT, SEEKORA_THEME_CONFIG, SearchBarComponent, SearchContextService, SearchLayoutComponent, SearchProviderComponent, SearchResultsComponent, SeekoraSearchService, SortByComponent, StatsComponent, createTheme, darkTheme, defaultTheme, minimalTheme };
2761
+ export { CurrentRefinementsComponent, FacetsComponent, PaginationComponent, QuerySuggestionsComponent, QuerySuggestionsService, RangeInputComponent, RatingDisplayComponent, SEEKORA_CLIENT, SEEKORA_THEME_CONFIG, SearchBarComponent, SearchContextService, SearchLayoutComponent, SearchProviderComponent, SearchResultsComponent, SeekoraSearchService, SortByComponent, StatsComponent, createTheme, darkTheme, defaultTheme, minimalTheme };
2526
2762
  //# sourceMappingURL=index.esm.js.map