@salesforcedevs/dx-components 1.3.91 → 1.3.92-dx-headings-wes1

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dx-components",
3
- "version": "1.3.91",
3
+ "version": "1.3.92-dx-headings-wes1",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -24,14 +24,14 @@ export default class Audio extends LightningElement {
24
24
  );
25
25
  }
26
26
 
27
- private trackClick(e: Event, clickType: string) {
27
+ private trackClick(e: Event, eventType: string, action: string) {
28
28
  const audioElement = this.template.querySelector(
29
29
  "audio"
30
30
  ) as HTMLMediaElement;
31
31
 
32
32
  const payload = {
33
- event: "custEv_blogAudioPlay",
34
- media_action: clickType,
33
+ event: eventType,
34
+ media_action: action,
35
35
  media_name: this.postName,
36
36
  media_percentage_played: (
37
37
  (audioElement!.currentTime * 100) /
@@ -44,12 +44,12 @@ export default class Audio extends LightningElement {
44
44
  }
45
45
 
46
46
  private trackPlay(e: Event) {
47
- this.trackClick(e, "play");
47
+ this.trackClick(e, "custEv_blogAudioPlay", "play");
48
48
  }
49
49
  private trackEnded(e: Event) {
50
- this.trackClick(e, "complete");
50
+ this.trackClick(e, "custEv_blogAudioComplete", "complete");
51
51
  }
52
52
  private trackPause(e: Event) {
53
- this.trackClick(e, "pause");
53
+ this.trackClick(e, "custEv_blogAudioPause", "pause");
54
54
  }
55
55
  }
@@ -8,7 +8,9 @@
8
8
  part="container"
9
9
  >
10
10
  <div class={textContainerClassName}>
11
- <h3 class="dx-text-display-4" lwc:dom="manual"></h3>
11
+ <h3 class="dx-text-display-4">
12
+ <dx-formatted-rich-text value={title}></dx-formatted-rich-text>
13
+ </h3>
12
14
  <p>{body}</p>
13
15
  <div class="cta">
14
16
  <dx-button if:true={hasLargeButton} size="large">
@@ -29,10 +29,6 @@ export default class CardNews extends LightningElement {
29
29
  @api target?: string | null = null;
30
30
  @api textContainerWidth?: CardNewsTextContainerSize = "small";
31
31
 
32
- renderedCallback() {
33
- this.template.querySelector("h3").innerHTML = this.title;
34
- }
35
-
36
32
  private get style(): string {
37
33
  const background = `background-color: ${toDxColor(
38
34
  this.backgroundColor
@@ -0,0 +1,3 @@
1
+ <template>
2
+ <div class="container" lwc:dom="manual"></div>
3
+ </template>
@@ -0,0 +1,17 @@
1
+ import { LightningElement, api } from "lwc";
2
+ import { sanitizeHtml } from "dxUtils/sanitizeHtml";
3
+
4
+ export default class FormattedRichText extends LightningElement {
5
+ @api value!: string;
6
+
7
+ private get sanitizedValue(): string {
8
+ return sanitizeHtml(this.value);
9
+ }
10
+ renderedCallback() {
11
+ const containerEl = this.template.querySelector(".container");
12
+
13
+ if (containerEl) {
14
+ containerEl.innerHTML = this.sanitizedValue;
15
+ }
16
+ }
17
+ }
@@ -1,7 +1,10 @@
1
1
  import { LightningElement, api, track } from "lwc";
2
2
  import type * as CoveoSDK from "coveo-search-ui";
3
3
  import { track as trackGTM } from "dxUtils/analytics";
4
- import { CONTENT_TYPE_LABELS } from "dxConstants/contentTypes";
4
+ import {
5
+ CONTENT_TYPE_LABELS,
6
+ CONTENT_TYPE_ICONS
7
+ } from "dxConstants/contentTypes";
5
8
  import { getContentTypeColorVariables } from "dxUtils/contentTypes";
6
9
 
7
10
  interface CoveoSearch {
@@ -19,9 +22,7 @@ interface CoveoSearch {
19
22
 
20
23
  declare const Coveo: CoveoSearch;
21
24
 
22
- function getPaginationState(
23
- event: CoveoSDK.IQuerySuccessEventArgs
24
- ): {
25
+ function getPaginationState(event: CoveoSDK.IQuerySuccessEventArgs): {
25
26
  numberOfPages: number;
26
27
  currentPage: number;
27
28
  } {
@@ -67,6 +68,25 @@ const resultsTemplatesInnerHtml = `
67
68
  </script>
68
69
  `;
69
70
 
71
+ const buildTemplateHelperBadge = (value: string) => {
72
+ const style = getContentTypeColorVariables(value);
73
+ const label = CONTENT_TYPE_LABELS[value];
74
+ const { iconSprite, iconSymbol } = CONTENT_TYPE_ICONS[value];
75
+ return `
76
+ <div style="${style}" class="dx-badge">
77
+ <svg
78
+ aria-hidden="true"
79
+ style="display: inline; margin-bottom: 1px; fill: var(--color); height: var(--dx-g-icon-size-xs); width: var(--dx-g-icon-size-xs);"
80
+ xmlns="http://www.w3.org/2000/svg"
81
+ part="svg"
82
+ >
83
+ <use xlink:href="/assets/icons/${iconSprite}-sprite/svg/symbols.svg#${iconSymbol}"></use>
84
+ </svg>
85
+ <span>${label}</span>
86
+ </div>
87
+ `;
88
+ };
89
+
70
90
  export default class SearchResults extends LightningElement {
71
91
  @api coveoOrganizationId!: string;
72
92
  @api coveoPublicAccessToken!: string;
@@ -179,11 +199,7 @@ export default class SearchResults extends LightningElement {
179
199
 
180
200
  Coveo.TemplateHelpers.registerTemplateHelper(
181
201
  "badge",
182
- (value: string) => {
183
- const style = getContentTypeColorVariables(value);
184
- const label = CONTENT_TYPE_LABELS[value];
185
- return `<div style="${style}" class="dx-badge"><span>${label}</span></div>`;
186
- }
202
+ buildTemplateHelperBadge
187
203
  );
188
204
 
189
205
  Coveo.init(this.root);
@@ -32,6 +32,10 @@
32
32
  <h2 class="dx-text-display-6 header-title">{header}</h2>
33
33
  <slot name="header"></slot>
34
34
  </div>
35
+ <div class="mobile-header" if:true={mobile}>
36
+ <h2 class="dx-text-display-6">{header}</h2>
37
+ <slot name="header"></slot>
38
+ </div>
35
39
  <div class="search">
36
40
  <dx-sidebar-search
37
41
  onchange={onSearchChange}
@@ -72,6 +76,7 @@
72
76
  selected={result.selected}
73
77
  title-highlights={result.titleHighlights}
74
78
  title={result.title}
79
+ select={result.select}
75
80
  ></dx-sidebar-search-result>
76
81
  </template>
77
82
  <dx-empty-state
@@ -34,6 +34,10 @@
34
34
  <h2 class="dx-text-display-6 header-title">{header}</h2>
35
35
  <slot name="header"></slot>
36
36
  </div>
37
+ <div class="mobile-header" if:true={mobile}>
38
+ <h2 class="dx-text-display-6">{header}</h2>
39
+ <slot name="header"></slot>
40
+ </div>
37
41
  <div class="search">
38
42
  <dx-input
39
43
  class="search-box"
@@ -6,6 +6,7 @@ import {
6
6
  Unsubscribe,
7
7
  ResultsPerPage,
8
8
  SearchBox,
9
+ buildInteractiveResult,
9
10
  buildResultList,
10
11
  buildResultsPerPage,
11
12
  buildSearchBox,
@@ -247,11 +248,8 @@ export default class SidebarSearch extends LightningElement {
247
248
  return;
248
249
  }
249
250
 
250
- const {
251
- isLoading,
252
- firstSearchExecuted,
253
- results
254
- } = this.resultList.state;
251
+ const { isLoading, firstSearchExecuted, results } =
252
+ this.resultList.state;
255
253
 
256
254
  if ((!firstSearchExecuted && !isLoading) || !this.value) {
257
255
  // coveo search is firing off some unwanted payloads on startup
@@ -289,15 +287,22 @@ export default class SidebarSearch extends LightningElement {
289
287
  engine.dispatch(registerSearchQueryAction);
290
288
  }
291
289
 
292
- private normalizeCoveoResult = ({
293
- clickUri,
294
- excerpt,
295
- excerptHighlights,
296
- raw: { sfhtml_url__c },
297
- title,
298
- titleHighlights,
299
- uniqueId
300
- }: Result): SidebarSearchResult => {
290
+ private normalizeCoveoResult = (result: Result): SidebarSearchResult => {
291
+ const {
292
+ clickUri,
293
+ excerpt,
294
+ excerptHighlights,
295
+ raw: { sfhtml_url__c },
296
+ title,
297
+ titleHighlights,
298
+ uniqueId
299
+ } = result;
300
+
301
+ const interactiveResult = buildInteractiveResult(this.engine!, {
302
+ options: { result }
303
+ });
304
+ interactiveResult.cancelPendingSelect();
305
+
301
306
  // discussion about this normalization here: https://salesforce-internal.slack.com/archives/C020S6784JX/p1639506238376600
302
307
 
303
308
  let pathname, queryParam;
@@ -348,7 +353,8 @@ export default class SidebarSearch extends LightningElement {
348
353
  excerptHighlights,
349
354
  uniqueId,
350
355
  href,
351
- selected: isSelected
356
+ selected: isSelected,
357
+ select: interactiveResult.select
352
358
  };
353
359
  };
354
360
 
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <a class={className} href={href}>
2
+ <a class={className} href={href} onclick={select}>
3
3
  <span class="title search-text">
4
4
  <template for:each={titleChunks} for:item="chunk">
5
5
  <span class={chunk.class} key={chunk.id}>{chunk.value}</span>
@@ -55,6 +55,7 @@ export default class SidebarSearchResult extends LightningElement {
55
55
  @api selected!: boolean;
56
56
  @api title!: string;
57
57
  @api titleHighlights!: CoveoHighlights;
58
+ @api select!: Function;
58
59
 
59
60
  private get titleChunks() {
60
61
  return toChunks(this.title, this.titleHighlights);
@@ -24,6 +24,12 @@ dx-tree:not(:last-child) {
24
24
  margin-bottom: 12px;
25
25
  }
26
26
 
27
+ .mobile-header {
28
+ display: flex;
29
+ line-height: var(--dx-g-spacing-xl);
30
+ margin-bottom: 12px;
31
+ }
32
+
27
33
  .padding-horizontal {
28
34
  padding-left: var(--dx-g-spacing-md);
29
35
  padding-right: var(--dx-g-spacing-md);
@@ -107,6 +113,12 @@ dx-tree:not(:last-child) {
107
113
  background-color: #dddbda;
108
114
  }
109
115
 
116
+ /* This class checks if an element with container class has an elemnt with container-mobile class and
117
+ must not contain any collapsed class and finally must have a mobile-header class (to which this css will be applied) */
118
+ .container.container-mobile:not(.collapsed) .mobile-header {
119
+ background-color: var(--dx-g-gray-95);
120
+ }
121
+
110
122
  .container.container-mobile .header-title {
111
123
  color: var(--dx-g-gray-10);
112
124
  font-family: var(--dx-g-font-sans);
@@ -3,7 +3,7 @@
3
3
  color: var(--dx-g-text-heading-color);
4
4
  font-family: var(--dx-g-font-display);
5
5
  font-size: var(--dx-g-text-6xl);
6
- letter-spacing: -1.4px;
6
+ letter-spacing: -1.8px;
7
7
  line-height: 88px;
8
8
  }
9
9
 
@@ -21,7 +21,7 @@
21
21
  color: var(--dx-g-text-heading-color);
22
22
  font-family: var(--dx-g-font-display);
23
23
  font-size: var(--dx-g-text-5xl);
24
- letter-spacing: -0.6px;
24
+ letter-spacing: -1.2px;
25
25
  line-height: 64px;
26
26
  }
27
27
 
@@ -30,7 +30,7 @@
30
30
  color: var(--dx-g-text-heading-color);
31
31
  font-family: var(--dx-g-font-display);
32
32
  font-size: var(--dx-g-text-4xl);
33
- letter-spacing: -0.5px;
33
+ letter-spacing: -1px;
34
34
  line-height: 56px;
35
35
  }
36
36
 
@@ -39,7 +39,7 @@
39
39
  color: var(--dx-g-text-heading-color);
40
40
  font-family: var(--dx-g-font-display);
41
41
  font-size: var(--dx-g-text-3xl);
42
- letter-spacing: -0.3px;
42
+ letter-spacing: -0.8px;
43
43
  line-height: 48px;
44
44
  }
45
45
 
@@ -48,7 +48,7 @@
48
48
  color: var(--dx-g-text-heading-color);
49
49
  font-family: var(--dx-g-font-display);
50
50
  font-size: var(--dx-g-text-2xl);
51
- letter-spacing: -0.1px;
51
+ letter-spacing: -0.4px;
52
52
  line-height: 40px;
53
53
  }
54
54
 
@@ -57,7 +57,7 @@
57
57
  color: var(--dx-g-text-heading-color);
58
58
  font-family: var(--dx-g-font-display);
59
59
  font-size: var(--dx-g-text-xl);
60
- letter-spacing: -0.1px;
60
+ letter-spacing: -0.4px;
61
61
  line-height: 32px;
62
62
  }
63
63
 
@@ -66,7 +66,7 @@
66
66
  color: var(--dx-g-text-heading-color);
67
67
  font-family: var(--dx-g-font-display);
68
68
  font-size: var(--dx-g-text-lg);
69
- letter-spacing: -0.1px;
69
+ letter-spacing: -0.4px;
70
70
  line-height: 28px;
71
71
  }
72
72
 
@@ -75,7 +75,7 @@
75
75
  color: var(--dx-g-text-heading-color);
76
76
  font-family: var(--dx-g-font-display);
77
77
  font-size: var(--dx-g-text-base);
78
- letter-spacing: -0.1px;
78
+ letter-spacing: -0.5px;
79
79
  line-height: 24px;
80
80
  }
81
81
 
@@ -26,6 +26,7 @@
26
26
  --height: var(--dx-g-spacing-mlg);
27
27
  }
28
28
 
29
+ svg,
29
30
  dx-icon {
30
31
  margin-right: var(--dx-g-spacing-sm);
31
32
  }
@@ -0,0 +1,8 @@
1
+ export function sanitizeHtml(str: string) {
2
+ const allowedTags = ["a", "b", "em", "br", "strong"];
3
+ const pattern = new RegExp(
4
+ `<(/?(?!${allowedTags.join("|")})\\b[^>]*?)>`,
5
+ "gi"
6
+ );
7
+ return str.replace(pattern, "");
8
+ }