@salesforcedevs/dx-components 1.3.224-alpha.1 → 1.3.224-alpha.2
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/package.json
CHANGED
|
@@ -8,6 +8,9 @@ import {
|
|
|
8
8
|
import { getContentTypeColorVariables } from "dxUtils/contentTypes";
|
|
9
9
|
import { pollUntil } from "dxUtils/async";
|
|
10
10
|
|
|
11
|
+
// Max height for breadcrumb without wrapping
|
|
12
|
+
const MAX_BREADCRUMB_HEIGHT = 16;
|
|
13
|
+
|
|
11
14
|
interface CoveoSearch {
|
|
12
15
|
state: typeof CoveoSDK.state;
|
|
13
16
|
get: typeof CoveoSDK.get;
|
|
@@ -141,10 +144,10 @@ const processParts = (parts: string[], internalFlag = false) => {
|
|
|
141
144
|
return parts.filter(filterFn).map((part) => {
|
|
142
145
|
// Remove special characters & .htm/.xml extension
|
|
143
146
|
part = part
|
|
144
|
-
.replace(/_/g, "
|
|
145
|
-
.replace(/-/g, "
|
|
146
|
-
.replace(/.html*/g, "
|
|
147
|
-
.replace(/.xml/g, "
|
|
147
|
+
.replace(/_/g, "")
|
|
148
|
+
.replace(/-/g, "")
|
|
149
|
+
.replace(/.html*/g, "")
|
|
150
|
+
.replace(/.xml/g, "")
|
|
148
151
|
.replace(/b2c/g, "B2C");
|
|
149
152
|
|
|
150
153
|
// Capitalize first letter of each word
|
|
@@ -367,17 +370,16 @@ export default class SearchResults extends LightningElement {
|
|
|
367
370
|
1000
|
|
368
371
|
);
|
|
369
372
|
|
|
370
|
-
this.processBreadcrumbs(
|
|
373
|
+
this.processBreadcrumbs(root);
|
|
371
374
|
|
|
372
375
|
window.onresize = () => this.processBreadcrumbs(root);
|
|
373
376
|
});
|
|
374
377
|
}
|
|
375
378
|
|
|
376
|
-
//
|
|
377
|
-
private isTextWrapping = (
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
) => elementOne.offsetHeight > elementTwo.offsetHeight;
|
|
379
|
+
// check if the breadcrumb is overflowing or not based on the height of a single character in the text element
|
|
380
|
+
private isTextWrapping = (element: HTMLElement) => {
|
|
381
|
+
return element.offsetHeight > MAX_BREADCRUMB_HEIGHT;
|
|
382
|
+
};
|
|
381
383
|
|
|
382
384
|
private truncateBreadcrumbText = (breadcrumbItems: HTMLElement[]) => {
|
|
383
385
|
breadcrumbItems.forEach((breadcrumbItem: HTMLElement) => {
|
|
@@ -396,10 +398,10 @@ export default class SearchResults extends LightningElement {
|
|
|
396
398
|
breadcrumb: HTMLElement
|
|
397
399
|
) => {
|
|
398
400
|
for (let i = 1; i < breadcrumbItems.length; i++) {
|
|
399
|
-
if (this.isTextWrapping(breadcrumb
|
|
401
|
+
if (this.isTextWrapping(breadcrumb)) {
|
|
400
402
|
// if the previous element is an ellipsis, make it empty (in order to avoid multiple grouped ellipsis)
|
|
401
403
|
if (breadcrumbItems[i - 1]?.textContent === "...") {
|
|
402
|
-
breadcrumbItems[i].
|
|
404
|
+
breadcrumbItems[i].innerHTML = "";
|
|
403
405
|
} else {
|
|
404
406
|
breadcrumbItems[i].textContent = "...";
|
|
405
407
|
}
|
|
@@ -408,8 +410,17 @@ export default class SearchResults extends LightningElement {
|
|
|
408
410
|
}
|
|
409
411
|
}
|
|
410
412
|
|
|
411
|
-
// remove
|
|
412
|
-
breadcrumb.
|
|
413
|
+
// remove any empty breadcrumb items
|
|
414
|
+
breadcrumb.innerHTML = breadcrumb.innerHTML
|
|
415
|
+
.replace(
|
|
416
|
+
/ ?\/ +<span class="breadcrumb-item"><\/span> +\/ ?/g,
|
|
417
|
+
" / "
|
|
418
|
+
)
|
|
419
|
+
// when first loading the page on mobile, the breadcrumb items are not grouped correctly
|
|
420
|
+
.replace(
|
|
421
|
+
`<span class="breadcrumb-item">...</span> / <span class="breadcrumb-item">...</span>`,
|
|
422
|
+
`<span class="breadcrumb-item">...</span>`
|
|
423
|
+
);
|
|
413
424
|
};
|
|
414
425
|
|
|
415
426
|
private formatBreadcrumbs = (breadcrumbs: HTMLElement[]) => {
|
|
@@ -419,7 +430,7 @@ export default class SearchResults extends LightningElement {
|
|
|
419
430
|
breadcrumb.querySelectorAll(".breadcrumb-item");
|
|
420
431
|
|
|
421
432
|
// Check if the breadcrumb is overflowing by comparing it's height to the height of the first breadcrumb item
|
|
422
|
-
if (this.isTextWrapping(breadcrumb
|
|
433
|
+
if (this.isTextWrapping(breadcrumb)) {
|
|
423
434
|
// it is overflowing, so we need to truncate long titles to 30 characters
|
|
424
435
|
this.truncateBreadcrumbText(breadcrumbItems);
|
|
425
436
|
|
|
@@ -427,7 +438,7 @@ export default class SearchResults extends LightningElement {
|
|
|
427
438
|
this.addBreadcrumbEllipsis(breadcrumbItems, breadcrumb);
|
|
428
439
|
|
|
429
440
|
// After processing all breadcrumb items, if it's still overflowing, hide the breadcrumb element
|
|
430
|
-
if (this.isTextWrapping(breadcrumb
|
|
441
|
+
if (this.isTextWrapping(breadcrumb)) {
|
|
431
442
|
breadcrumb.style.display = "none";
|
|
432
443
|
}
|
|
433
444
|
}
|