@coveo/quantic 3.30.3-pre.a55b5cf74a → 3.30.3-pre.a952d10bad

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.
@@ -93,11 +93,11 @@ export class Deferred {
93
93
  export class ResultUtils {
94
94
  /**
95
95
  * Binds the logging of document
96
- * @returns An unbind function for the events
97
96
  * @param {import("coveo").SearchEngine} engine An instance of an Headless Engine
98
97
  * @param {import("coveo").Result} result The result object
99
98
  * @param {import("lwc").ShadowRootTheGoodPart} resultElement Parent result element
100
99
  * @param {string} selector Optional. Css selector that selects all links to the document. Default: "a" tags with the clickUri as "href" parameter.
100
+ * @returns An unbind function for the events
101
101
  */
102
102
  static bindClickEventsOnResult(
103
103
  engine,
@@ -140,9 +140,9 @@ export class ResultUtils {
140
140
  export class LinkUtils {
141
141
  /**
142
142
  * Binds the logging of a link
143
- * @returns An unbind function for the events
144
143
  * @param {HTMLAnchorElement} link the link element
145
144
  * @param {{select:function, beginDelayedSelect: function, cancelPendingSelect: function }} actions
145
+ * @returns An unbind function for the events
146
146
  */
147
147
  static bindAnalyticsToLink(link, actions) {
148
148
  const eventsMap = {
@@ -178,6 +178,13 @@ export class I18nUtils {
178
178
  return new Intl.PluralRules(LOCALE).select(count) === 'one';
179
179
  }
180
180
 
181
+ /**
182
+ * Gets the label name with count.
183
+ * @param {string} labelName
184
+ * @param {number} count
185
+ * @returns {string} The label name with count.
186
+ * @example `labelName_zero`, `labelName_plural` or `labelName`
187
+ */
181
188
  static getLabelNameWithCount(labelName, count) {
182
189
  if (count === 0) {
183
190
  return `${labelName}_zero`;
@@ -187,6 +194,15 @@ export class I18nUtils {
187
194
  return labelName;
188
195
  }
189
196
 
197
+ /**
198
+ * Formats a string with the given arguments.
199
+ * @param {*} stringToFormat
200
+ * @param {...any} formattingArguments
201
+ * @returns {string} The formatted string.
202
+ * @example
203
+ * I18nUtils.format('Hello {{0}}, you have {{1}} new messages', 'John', 5);
204
+ * returns 'Hello John, you have 5 new messages'
205
+ */
190
206
  static format(stringToFormat, ...formattingArguments) {
191
207
  if (typeof stringToFormat !== 'string')
192
208
  throw new Error("'stringToFormat' must be a String");
@@ -197,6 +213,11 @@ export class I18nUtils {
197
213
  );
198
214
  }
199
215
 
216
+ /**
217
+ * Gets the short date pattern for the current locale.
218
+ * @returns {string} The short date pattern.
219
+ * @example `M/d/yyyy` for `en-US`, `d/M/yyyy` for `fr-FR`, etc.
220
+ */
200
221
  static getShortDatePattern() {
201
222
  const date = new Date(2000, 2, 4); // month is zero-based
202
223
  const dateAsString = I18nUtils.formatDate(date);
@@ -215,11 +236,13 @@ export class I18nUtils {
215
236
  }
216
237
 
217
238
  /**
239
+ * Formats the date in the current locale.
218
240
  * @param {Date} date
241
+ * @returns {string} The formatted date.
219
242
  */
220
243
  static formatDate(date) {
221
- const result = new Intl.DateTimeFormat(LOCALE).format(date);
222
- return result;
244
+ const formattedDate = new Intl.DateTimeFormat(LOCALE).format(date);
245
+ return formattedDate;
223
246
  }
224
247
 
225
248
  /**
@@ -227,7 +250,7 @@ export class I18nUtils {
227
250
  * @returns {string}
228
251
  */
229
252
  static escapeHTML(html) {
230
- var escape = document.createElement('textarea');
253
+ const escape = document.createElement('textarea');
231
254
  escape.textContent = html;
232
255
  // eslint-disable-next-line @lwc/lwc/no-inner-html
233
256
  return escape.innerHTML;
@@ -259,11 +282,16 @@ export function setItemInLocalStorage(key, item) {
259
282
  /**
260
283
  * Replace char found in pattern with \\$&
261
284
  * @param {string} value
285
+ * @return {string}
262
286
  */
263
287
  export function regexEncode(value) {
264
288
  return value.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
265
289
  }
266
-
290
+ /**
291
+ * Parses an XML string into a DOM Document.
292
+ * @param {string} string
293
+ * @returns {Document}
294
+ */
267
295
  export function parseXML(string) {
268
296
  return new window.DOMParser().parseFromString(string, 'text/xml');
269
297
  }
@@ -418,6 +446,11 @@ export class DateUtils {
418
446
  return new Date(`${withoutTime}T${time}`);
419
447
  }
420
448
 
449
+ /**
450
+ * Trims the time portion from an ISO 8601 date string.
451
+ * @param {string} dateString
452
+ * @returns {string}
453
+ */
421
454
  static trimIsoTime(dateString) {
422
455
  const timeIdx = dateString.indexOf('T');
423
456
  return timeIdx !== -1 ? dateString.substring(0, timeIdx) : dateString;
@@ -425,6 +458,7 @@ export class DateUtils {
425
458
 
426
459
  /**
427
460
  * @param {number} timestamp
461
+ * @returns {boolean}
428
462
  */
429
463
  static isValidTimestamp(timestamp) {
430
464
  let isValid = true;
@@ -439,8 +473,6 @@ export class DateUtils {
439
473
 
440
474
  /**
441
475
  * Parses a given timestamp into detailed date components.
442
- *
443
- * @function
444
476
  * @param {number} timestamp - The timestamp in milliseconds since January 1, 1970 (epoch time).
445
477
  * @returns {Object} An object containing the following date details:
446
478
  * - {number} year - The four-digit year (e.g., 2024).
@@ -519,10 +551,14 @@ export class RelativeDateFormatter {
519
551
  }
520
552
 
521
553
  /**
522
- *
523
- * @param {RelativeDate} begin
524
- * @param {RelativeDate} end
525
- * @returns {string}
554
+ * Formats a relative date range into a human-readable string.
555
+ * @param {RelativeDate} begin The beginning of the relative date range.
556
+ * @param {RelativeDate} end The end of the relative date range.
557
+ * @returns {string} The formatted human-readable date range.
558
+ * @example
559
+ * begin = { period: 'past', unit: 'day', amount: 2 };
560
+ * end = { period: 'now', unit: 'day', amount: 1 };
561
+ * Output: "2 days ago - 1 day ago"
526
562
  */
527
563
  formatRange(begin, end) {
528
564
  const isPastRange = begin.period === 'past' && end.period === 'now';
@@ -565,9 +601,11 @@ export class Store {
565
601
  };
566
602
  }
567
603
  /**
604
+ * Registers a facet to the store if it does not already exist.
568
605
  * @param {Record<String, unknown>} store
569
606
  * @param {string} facetType
570
607
  * @param {{ label?: string; facetId: any; format?: Function;}} data
608
+ * @return {void}
571
609
  */
572
610
  static registerFacetToStore(store, facetType, data) {
573
611
  if (store?.state[facetType][data.facetId]) {
@@ -577,23 +615,29 @@ export class Store {
577
615
  }
578
616
 
579
617
  /**
618
+ * Registers sort option data to the store.
580
619
  * @param {Record<String, any>} store
581
620
  * @param {Array<{label: string; value: string; criterion: SortCriterion;}>} data
621
+ * @return {void}
582
622
  */
583
623
  static registerSortOptionDataToStore(store, data) {
584
624
  store.state.sort = data;
585
625
  }
586
626
 
587
627
  /**
628
+ * Gets facet data from the store.
588
629
  * @param {Record<String, unknown>} store
589
630
  * @param {string} facetType
631
+ * @return {Object} The facet data.
590
632
  */
591
633
  static getFromStore(store, facetType) {
592
634
  return store.state[facetType];
593
635
  }
594
636
 
595
637
  /**
638
+ * Gets sort options from the store.
596
639
  * @param {Record<String, Object>} store
640
+ * @return {Array} The sort options.
597
641
  */
598
642
  static getSortOptionsFromStore(store) {
599
643
  return store.state.sort;
@@ -763,6 +807,7 @@ export function isCustomElement(element) {
763
807
  /**
764
808
  * Returns the last focusable element in an HTML slot.
765
809
  * @param {HTMLElement & {assignedElements?: () => Array<HTMLElement> | null}} slotElement
810
+ * @returns {HTMLElement | null}
766
811
  */
767
812
  function getLastFocusableElementFromSlot(slotElement) {
768
813
  if (!slotElement && slotElement.assignedElements) {
@@ -782,6 +827,7 @@ function getLastFocusableElementFromSlot(slotElement) {
782
827
  /**
783
828
  * Returns the first focusable element in an HTML slot.
784
829
  * @param {HTMLElement & {assignedElements?: () => Array<HTMLElement> | null}} slotElement
830
+ * @return {HTMLElement | null}
785
831
  */
786
832
  function getFirstFocusableElementFromSlot(slotElement) {
787
833
  if (!slotElement && slotElement.assignedElements) {
@@ -802,6 +848,7 @@ function getFirstFocusableElementFromSlot(slotElement) {
802
848
  * Checks whether an element is indeed the targetElement or one of its parents.
803
849
  * @param {HTMLElement} element
804
850
  * @param {string} targetElement
851
+ * @returns {boolean}
805
852
  */
806
853
  export function isParentOf(element, targetElement) {
807
854
  if (!element || element.nodeType === Node.TEXT_NODE) {
@@ -827,6 +874,7 @@ export function isParentOf(element, targetElement) {
827
874
  * Copies text to clipboard using the Clipboard API.
828
875
  * https://developer.mozilla.org/en-US/docs/Web/API/Clipboard
829
876
  * @param {string} text
877
+ * @return {Promise<void>}
830
878
  */
831
879
  export async function copyToClipboard(text) {
832
880
  try {
@@ -839,6 +887,7 @@ export async function copyToClipboard(text) {
839
887
  /**
840
888
  * Copies text to clipboard using the DOM.
841
889
  * @param {string} text
890
+ * @return {void}
842
891
  */
843
892
  export function copyToClipboardFallback(text) {
844
893
  const el = document.createElement('textarea');
@@ -853,6 +902,7 @@ export function copyToClipboardFallback(text) {
853
902
  * Read the value of a given key from an object.
854
903
  * @param {object} object
855
904
  * @param {string} key
905
+ * @return {object | undefined} The value of the key.
856
906
  */
857
907
  export function readFromObject(object, key) {
858
908
  const firstPeriodIndex = key.indexOf('.');
@@ -898,9 +948,9 @@ export function getElementPadding(element) {
898
948
  }
899
949
 
900
950
  /**
901
- * Returns the absolute width of an element.
951
+ * Returns the absolute height of an element.
902
952
  * @param {Element} element
903
- * @returns {number}
953
+ * @returns {number} The absolute height of the element including padding.
904
954
  */
905
955
  export function getAbsoluteHeight(element) {
906
956
  if (!element) {
@@ -916,7 +966,7 @@ export function getAbsoluteHeight(element) {
916
966
  /**
917
967
  * Returns the absolute width of an element.
918
968
  * @param {Element} element
919
- * @returns {number}
969
+ * @returns {number} The absolute width of the element including padding.
920
970
  */
921
971
  export function getAbsoluteWidth(element) {
922
972
  if (!element) {
@@ -49,4 +49,4 @@ For more information, refer to the documentation: https://docs.coveo.com/en/o3r9
49
49
  * limitations under the License.
50
50
  */if(__exports!=exports)module.exports=exports;return module.exports});
51
51
 
52
- window.coveoQuanticVersion = '3.30.3-pre.a55b5cf74a';
52
+ window.coveoQuanticVersion = '3.30.3-pre.a952d10bad';
@@ -53,4 +53,4 @@ For more information, refer to the documentation: https://docs.coveo.com/en/o3r9
53
53
  * limitations under the License.
54
54
  */if(__exports!=exports)module.exports=exports;return module.exports});
55
55
 
56
- window.coveoQuanticVersion = '3.30.3-pre.a55b5cf74a';
56
+ window.coveoQuanticVersion = '3.30.3-pre.a952d10bad';
@@ -50,4 +50,4 @@ For more information, refer to the documentation: https://docs.coveo.com/en/o3r9
50
50
  * limitations under the License.
51
51
  */if(__exports!=exports)module.exports=exports;return module.exports});
52
52
 
53
- window.coveoQuanticVersion = '3.30.3-pre.a55b5cf74a';
53
+ window.coveoQuanticVersion = '3.30.3-pre.a952d10bad';
@@ -46,4 +46,4 @@ ${y}`:y;break;case"event":n.event=y;break;case"id":e(n.id=y);break;case"retry":D
46
46
  * limitations under the License.
47
47
  */if(__exports!=exports)module.exports=exports;return module.exports});
48
48
 
49
- window.coveoQuanticVersion = '3.30.3-pre.a55b5cf74a';
49
+ window.coveoQuanticVersion = '3.30.3-pre.a952d10bad';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coveo/quantic",
3
- "version": "3.30.3-pre.a55b5cf74a",
3
+ "version": "3.30.3-pre.a952d10bad",
4
4
  "description": "A Salesforce Lightning Web Component (LWC) library for building modern UIs interfacing with the Coveo platform",
5
5
  "author": "coveo.com",
6
6
  "homepage": "https://coveo.com",