@salesforcedevs/dx-components 1.3.252 → 1.3.253

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.252",
3
+ "version": "1.3.253",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -45,5 +45,5 @@
45
45
  "volta": {
46
46
  "node": "16.19.1"
47
47
  },
48
- "gitHead": "8379eb747571af22dfdfc3c440e8c23c85d1fe8b"
48
+ "gitHead": "20e30001e8423cd101d5ac0e94fff7d669cf9ef1"
49
49
  }
@@ -284,6 +284,7 @@ li.coveo-dynamic-facet-breadcrumb-value-list-item {
284
284
  }
285
285
 
286
286
  .dx-result-excerpt {
287
+ display: inline;
287
288
  color: var(--dx-g-gray-10);
288
289
  font-size: 14px;
289
290
  line-height: 20px;
@@ -465,6 +466,10 @@ li.coveo-dynamic-facet-breadcrumb-value-list-item {
465
466
  --dx-c-stroke-width: 1px;
466
467
  }
467
468
 
469
+ .post-info-container {
470
+ margin-top: var(--dx-g-spacing-smd);
471
+ }
472
+
468
473
  @media screen and (max-width: 768px) {
469
474
  .no-results > img {
470
475
  display: none;
@@ -1,5 +1,6 @@
1
1
  import { LightningElement, api, track } from "lwc";
2
2
  import type * as CoveoSDK from "coveo-search-ui";
3
+ import { DateTime } from "luxon";
3
4
  import { track as trackGTM } from "dxUtils/analytics";
4
5
  import {
5
6
  CONTENT_TYPE_LABELS,
@@ -72,7 +73,17 @@ const resultsTemplatesInnerHtml = `
72
73
  <svg xmlns="http://www.w3.org/2000/svg" style="display: inline; vertical-align: baseline;" fill="var(--dx-g-blue-vibrant-20)" width="20" height="20" part="svg" aria-hidden="true"><use xlink:href="/assets/icons/utility-sprite/svg/symbols.svg#new_window"></use></svg>
73
74
  <% } %>
74
75
  </a>
76
+ <span class="CoveoFieldValue" data-field="@sflastmodifieddate" data-helper="postedDate" data-html-value="true"></span>
75
77
  <p class="dx-result-excerpt CoveoExcerpt"></p>
78
+ <% if (raw.sfcommentcount || raw.sflikecount) { %>
79
+ <div class="post-info-container">
80
+ <span class="CoveoFieldValue" data-field="@sfcommentcount" data-helper="replies" data-html-value="true"></span>
81
+ <% if (raw.sfcommentcount && raw.sflikecount) { %>
82
+ <span>&bull;</span>
83
+ <% } %>
84
+ <span class="CoveoFieldValue" data-field="@sflikecount" data-helper="likes" data-html-value="true"></span>
85
+ </div>
86
+ <% } %>
76
87
  </div>
77
88
  </script>
78
89
  <script
@@ -109,7 +120,17 @@ const resultsTemplatesInnerHtml = `
109
120
  <svg xmlns="http://www.w3.org/2000/svg" style="display: inline; vertical-align: baseline;" fill="var(--dx-g-blue-vibrant-20)" width="20" height="20" part="svg" aria-hidden="true"><use xlink:href="/assets/icons/utility-sprite/svg/symbols.svg#new_window"></use></svg>
110
121
  <% } %>
111
122
  </a>
123
+ <span class="CoveoFieldValue" data-field="@sflastmodifieddate" data-helper="postedDate" data-html-value="true"></span>
112
124
  <p class="dx-result-excerpt CoveoExcerpt"></p>
125
+ <% if (raw.sfcommentcount || raw.sflikecount) { %>
126
+ <div class="post-info-container">
127
+ <span class="CoveoFieldValue" data-field="@sfcommentcount" data-helper="replies" data-html-value="true"></span>
128
+ <% if (raw.sfcommentcount && raw.sflikecount) { %>
129
+ <span>&bull;</span>
130
+ <% } %>
131
+ <span class="CoveoFieldValue" data-field="@sflikecount" data-helper="likes" data-html-value="true"></span>
132
+ </div>
133
+ <% } %>
113
134
  </div>
114
135
  </script>
115
136
  `;
@@ -122,7 +143,15 @@ const isTrailheadDomain = (domain: string) =>
122
143
  domain === "trailhead.salesforce.com" ||
123
144
  domain === "dev.trailhead.salesforce.com";
124
145
 
125
- const buildTemplateHelperBadge = (value: keyof typeof CONTENT_TYPE_LABELS) => {
146
+ const buildTemplateHelperBadge = (
147
+ rawValue: keyof typeof CONTENT_TYPE_LABELS | "community posts"
148
+ ) => {
149
+ let value = rawValue;
150
+
151
+ if (value === "community posts") {
152
+ value = "community";
153
+ }
154
+
126
155
  const style = getContentTypeColorVariables(value);
127
156
  const label = CONTENT_TYPE_LABELS[value];
128
157
  const { iconSprite, iconSymbol } = CONTENT_TYPE_ICONS[value];
@@ -242,6 +271,26 @@ const buildTemplateHelperMetaBreadcrumbs = (value: string) => {
242
271
  `;
243
272
  };
244
273
 
274
+ const buildTemplateHelperPostedDate = (value: string) => {
275
+ const time = DateTime.fromMillis(Number(value)).toLocaleString(
276
+ DateTime.DATE_MED
277
+ );
278
+
279
+ return `Posted on: ${time} - `;
280
+ };
281
+
282
+ const buildTemplateHelperReplies = (value: string) => {
283
+ const number = Number(value);
284
+
285
+ return `<strong>${value} ${number > 1 ? "Replies" : "Reply"}</strong>`;
286
+ };
287
+
288
+ const buildTemplateHelperLikes = (value: string) => {
289
+ const number = Number(value);
290
+
291
+ return `<strong>${value} ${number > 1 ? "Likes" : "Like"}</strong>`;
292
+ };
293
+
245
294
  // @ts-ignore Dark Magic (TM) we are overriding the 'title' field with a custom getter. We should really stop doing this.
246
295
  export default class SearchResults extends LightningElement {
247
296
  @api coveoOrganizationId!: string;
@@ -521,6 +570,21 @@ export default class SearchResults extends LightningElement {
521
570
  buildTemplateHelperUriBreadcrumbs
522
571
  );
523
572
 
573
+ Coveo.TemplateHelpers.registerTemplateHelper(
574
+ "postedDate",
575
+ buildTemplateHelperPostedDate
576
+ );
577
+
578
+ Coveo.TemplateHelpers.registerTemplateHelper(
579
+ "replies",
580
+ buildTemplateHelperReplies
581
+ );
582
+
583
+ Coveo.TemplateHelpers.registerTemplateHelper(
584
+ "likes",
585
+ buildTemplateHelperLikes
586
+ );
587
+
524
588
  Coveo.init(this.root);
525
589
  }
526
590
 
@@ -8,7 +8,8 @@ export const CONTENT_TYPE_LABELS = {
8
8
  api: "API",
9
9
  event: "Event",
10
10
  website: "Website",
11
- podcast: "Podcast"
11
+ podcast: "Podcast",
12
+ community: "Community"
12
13
  };
13
14
 
14
15
  export const CONTENT_TYPE_ICONS: {
@@ -45,6 +46,10 @@ export const CONTENT_TYPE_ICONS: {
45
46
  podcast: {
46
47
  iconSprite: "utility",
47
48
  iconSymbol: "unmuted"
49
+ },
50
+ community: {
51
+ iconSprite: "general",
52
+ iconSymbol: "users"
48
53
  }
49
54
  };
50
55
 
@@ -56,5 +61,6 @@ export const CONTENT_TYPES = [
56
61
  "api",
57
62
  "event",
58
63
  "website",
59
- "podcast"
64
+ "podcast",
65
+ "community"
60
66
  ] as ContentType[];