@seekora-ai/ui-sdk-vanilla 0.2.0 → 0.2.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.
@@ -49,7 +49,10 @@ export declare class InfiniteHits {
49
49
  private createDefaultEmpty;
50
50
  private createDefaultLoading;
51
51
  private createShowMoreButton;
52
+ /** Extract string value using fieldMapping (no hardcoded field names) */
52
53
  private extractField;
54
+ /** Extract raw value (string | number) for fields like price - uses fieldMapping */
55
+ private extractFieldValue;
53
56
  private get theme();
54
57
  private getHitStyle;
55
58
  private getImageStyle;
@@ -1 +1 @@
1
- {"version":3,"file":"infinite-hits.d.ts","sourceRoot":"","sources":["../../src/components/infinite-hits.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,WAAW,GAAG,MAAM,CAAC;IAChC,0CAA0C;IAC1C,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,KAAK,WAAW,CAAC;IAC5D,oCAAoC;IACpC,WAAW,CAAC,EAAE,MAAM,WAAW,CAAC;IAChC,sCAAsC;IACtC,aAAa,CAAC,EAAE,MAAM,WAAW,CAAC;IAClC,6DAA6D;IAC7D,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gFAAgF;IAChF,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,wDAAwD;IACxD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kDAAkD;IAClD,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,kCAAkC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6BAA6B;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qCAAqC;IACrC,UAAU,CAAC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,oFAAoF;IACpF,OAAO,CAAC,iBAAiB;IAczB,OAAO,KAAK,KAAK,GAEhB;IAED,OAAO,CAAC,WAAW;IAanB,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,sBAAsB;CAmB/B"}
@@ -155,7 +155,7 @@ export class InfiniteHits {
155
155
  const item = document.createElement('div');
156
156
  item.style.cssText = this.getHitStyle();
157
157
  const mapping = this.options.fieldMapping;
158
- // If fieldMapping is provided, use it to extract and display fields
158
+ // If fieldMapping is provided, use it to extract and display fields (no hardcoded field names)
159
159
  if (mapping) {
160
160
  const imageField = this.extractField(hit, 'image');
161
161
  if (imageField) {
@@ -181,14 +181,22 @@ export class InfiniteHits {
181
181
  descEl.style.cssText = this.getDescriptionStyle();
182
182
  content.appendChild(descEl);
183
183
  }
184
+ const priceVal = this.extractFieldValue(hit, 'price');
185
+ if (priceVal !== undefined && priceVal !== null && priceVal !== '') {
186
+ const priceEl = document.createElement('span');
187
+ const priceStr = typeof priceVal === 'number' ? priceVal.toFixed(2) : String(priceVal);
188
+ priceEl.textContent = `$${priceStr}`;
189
+ priceEl.style.cssText = this.getPriceStyle();
190
+ content.appendChild(priceEl);
191
+ }
184
192
  item.appendChild(content);
185
193
  }
186
194
  else {
187
- // No fieldMapping - render as simple key-value pairs
195
+ // No fieldMapping - render as simple key-value pairs (no hardcoded field names)
188
196
  const content = document.createElement('div');
189
197
  content.style.cssText = 'flex: 1;';
190
198
  const keys = Object.keys(hit).slice(0, 5); // Show first 5 fields
191
- keys.forEach(key => {
199
+ keys.forEach((key) => {
192
200
  const value = hit[key];
193
201
  if (value != null && typeof value !== 'object') {
194
202
  const field = document.createElement('div');
@@ -234,13 +242,33 @@ export class InfiniteHits {
234
242
  button.addEventListener('click', () => this.handleShowMore());
235
243
  return button;
236
244
  }
245
+ /** Extract string value using fieldMapping (no hardcoded field names) */
237
246
  extractField(hit, field) {
238
- const mapping = this.options.fieldMapping;
239
- if (!mapping || !mapping[field]) {
240
- return hit[field] || '';
247
+ if (!this.options.fieldMapping || !this.options.fieldMapping[field]) {
248
+ const val = hit[field];
249
+ return val != null ? String(val) : '';
250
+ }
251
+ const mappedField = this.options.fieldMapping[field];
252
+ if (typeof mappedField !== 'string') {
253
+ const val = hit[field];
254
+ return val != null ? String(val) : '';
255
+ }
256
+ const val = hit[mappedField];
257
+ return val != null ? String(val) : '';
258
+ }
259
+ /** Extract raw value (string | number) for fields like price - uses fieldMapping */
260
+ extractFieldValue(hit, field) {
261
+ if (!this.options.fieldMapping || !this.options.fieldMapping[field]) {
262
+ const val = hit[field];
263
+ return val !== undefined && val !== null ? val : undefined;
264
+ }
265
+ const mappedField = this.options.fieldMapping[field];
266
+ if (typeof mappedField !== 'string') {
267
+ const val = hit[field];
268
+ return val !== undefined && val !== null ? val : undefined;
241
269
  }
242
- const mappedField = mapping[field];
243
- return hit[mappedField] || '';
270
+ const val = hit[mappedField];
271
+ return val !== undefined && val !== null ? val : undefined;
244
272
  }
245
273
  get theme() {
246
274
  return this.provider.theme;
package/dist/index.d.ts CHANGED
@@ -530,7 +530,10 @@ declare class InfiniteHits {
530
530
  private createDefaultEmpty;
531
531
  private createDefaultLoading;
532
532
  private createShowMoreButton;
533
+ /** Extract string value using fieldMapping (no hardcoded field names) */
533
534
  private extractField;
535
+ /** Extract raw value (string | number) for fields like price - uses fieldMapping */
536
+ private extractFieldValue;
534
537
  private get theme();
535
538
  private getHitStyle;
536
539
  private getImageStyle;
package/dist/index.esm.js CHANGED
@@ -3323,7 +3323,7 @@ class InfiniteHits {
3323
3323
  const item = document.createElement('div');
3324
3324
  item.style.cssText = this.getHitStyle();
3325
3325
  const mapping = this.options.fieldMapping;
3326
- // If fieldMapping is provided, use it to extract and display fields
3326
+ // If fieldMapping is provided, use it to extract and display fields (no hardcoded field names)
3327
3327
  if (mapping) {
3328
3328
  const imageField = this.extractField(hit, 'image');
3329
3329
  if (imageField) {
@@ -3349,14 +3349,22 @@ class InfiniteHits {
3349
3349
  descEl.style.cssText = this.getDescriptionStyle();
3350
3350
  content.appendChild(descEl);
3351
3351
  }
3352
+ const priceVal = this.extractFieldValue(hit, 'price');
3353
+ if (priceVal !== undefined && priceVal !== null && priceVal !== '') {
3354
+ const priceEl = document.createElement('span');
3355
+ const priceStr = typeof priceVal === 'number' ? priceVal.toFixed(2) : String(priceVal);
3356
+ priceEl.textContent = `$${priceStr}`;
3357
+ priceEl.style.cssText = this.getPriceStyle();
3358
+ content.appendChild(priceEl);
3359
+ }
3352
3360
  item.appendChild(content);
3353
3361
  }
3354
3362
  else {
3355
- // No fieldMapping - render as simple key-value pairs
3363
+ // No fieldMapping - render as simple key-value pairs (no hardcoded field names)
3356
3364
  const content = document.createElement('div');
3357
3365
  content.style.cssText = 'flex: 1;';
3358
3366
  const keys = Object.keys(hit).slice(0, 5); // Show first 5 fields
3359
- keys.forEach(key => {
3367
+ keys.forEach((key) => {
3360
3368
  const value = hit[key];
3361
3369
  if (value != null && typeof value !== 'object') {
3362
3370
  const field = document.createElement('div');
@@ -3402,13 +3410,33 @@ class InfiniteHits {
3402
3410
  button.addEventListener('click', () => this.handleShowMore());
3403
3411
  return button;
3404
3412
  }
3413
+ /** Extract string value using fieldMapping (no hardcoded field names) */
3405
3414
  extractField(hit, field) {
3406
- const mapping = this.options.fieldMapping;
3407
- if (!mapping || !mapping[field]) {
3408
- return hit[field] || '';
3409
- }
3410
- const mappedField = mapping[field];
3411
- return hit[mappedField] || '';
3415
+ if (!this.options.fieldMapping || !this.options.fieldMapping[field]) {
3416
+ const val = hit[field];
3417
+ return val != null ? String(val) : '';
3418
+ }
3419
+ const mappedField = this.options.fieldMapping[field];
3420
+ if (typeof mappedField !== 'string') {
3421
+ const val = hit[field];
3422
+ return val != null ? String(val) : '';
3423
+ }
3424
+ const val = hit[mappedField];
3425
+ return val != null ? String(val) : '';
3426
+ }
3427
+ /** Extract raw value (string | number) for fields like price - uses fieldMapping */
3428
+ extractFieldValue(hit, field) {
3429
+ if (!this.options.fieldMapping || !this.options.fieldMapping[field]) {
3430
+ const val = hit[field];
3431
+ return val !== undefined && val !== null ? val : undefined;
3432
+ }
3433
+ const mappedField = this.options.fieldMapping[field];
3434
+ if (typeof mappedField !== 'string') {
3435
+ const val = hit[field];
3436
+ return val !== undefined && val !== null ? val : undefined;
3437
+ }
3438
+ const val = hit[mappedField];
3439
+ return val !== undefined && val !== null ? val : undefined;
3412
3440
  }
3413
3441
  get theme() {
3414
3442
  return this.provider.theme;