@salesforcedevs/dx-components 1.43.0 → 1.44.0
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
|
+
"version": "1.44.0",
|
|
4
4
|
"description": "DX Lightning web components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"luxon": "3.4.4",
|
|
45
45
|
"msw": "^2.12.4"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "0abdf26134a564b4a943ae4d8a99a1f66dbf6baa"
|
|
48
48
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
@import "dxHelpers/reset";
|
|
1
2
|
@import "dxHelpers/text";
|
|
2
3
|
|
|
3
4
|
:host {
|
|
@@ -81,6 +82,7 @@
|
|
|
81
82
|
color: var(--dx-g-blue-vibrant-50);
|
|
82
83
|
font-family: var(--dx-g-font-display);
|
|
83
84
|
font-size: var(--dx-g-text-sm);
|
|
85
|
+
cursor: pointer;
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
.dx-filter-clear:disabled {
|
|
@@ -88,10 +90,6 @@
|
|
|
88
90
|
cursor: default;
|
|
89
91
|
}
|
|
90
92
|
|
|
91
|
-
.dx-search-range {
|
|
92
|
-
margin: 0 0 var(--dx-g-spacing-lg);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
93
|
.dx-search-main {
|
|
96
94
|
flex: 1 1 0;
|
|
97
95
|
min-width: 0;
|
|
@@ -31,9 +31,7 @@
|
|
|
31
31
|
class="dx-filter-type"
|
|
32
32
|
name="contentType"
|
|
33
33
|
header="Content Type"
|
|
34
|
-
single-select
|
|
35
34
|
options={typeFilterOptions}
|
|
36
|
-
value={selectedTypeValue}
|
|
37
35
|
onchange={handleTypeFilterChange}
|
|
38
36
|
></dx-filter-menu>
|
|
39
37
|
<dx-filter-menu
|
|
@@ -49,13 +47,6 @@
|
|
|
49
47
|
</aside>
|
|
50
48
|
|
|
51
49
|
<div class="dx-search-main">
|
|
52
|
-
<p
|
|
53
|
-
if:true={showRange}
|
|
54
|
-
class="dx-search-range dx-text-body-2"
|
|
55
|
-
aria-live="polite"
|
|
56
|
-
>
|
|
57
|
-
Showing {rangeStart} - {rangeEnd} of {total}
|
|
58
|
-
</p>
|
|
59
50
|
<!-- Loading -->
|
|
60
51
|
<template if:true={isLoading}>
|
|
61
52
|
<div class="dx-search-status" aria-live="polite">
|
|
@@ -221,8 +221,12 @@ const ALL = ROWS.map(row);
|
|
|
221
221
|
* reflect the full result set (disjunctive facets), as the real API does.
|
|
222
222
|
*/
|
|
223
223
|
export function mockSearchResponse(params: URLSearchParams) {
|
|
224
|
-
|
|
225
|
-
const
|
|
224
|
+
// `type` is a comma-separated list; selected types are OR'd.
|
|
225
|
+
const types = (params.get("type") ?? "").split(",").filter(Boolean);
|
|
226
|
+
const type = types.length > 0;
|
|
227
|
+
const results = type
|
|
228
|
+
? ALL.filter((r) => types.includes(r.contentType))
|
|
229
|
+
: ALL;
|
|
226
230
|
return {
|
|
227
231
|
query: params.get("q") ?? "apex",
|
|
228
232
|
locale: params.get("lang") ?? "en-us",
|
|
@@ -57,7 +57,6 @@ interface DisplayResult {
|
|
|
57
57
|
interface FacetChip {
|
|
58
58
|
value: string;
|
|
59
59
|
label: string;
|
|
60
|
-
count: number;
|
|
61
60
|
active: boolean;
|
|
62
61
|
cssClass: string;
|
|
63
62
|
}
|
|
@@ -77,6 +76,15 @@ export default class SearchHybrid extends LightningElement {
|
|
|
77
76
|
/** The page's server locale, used as the default search language. */
|
|
78
77
|
@api defaultLanguage: string = "en-us";
|
|
79
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Comma-separated content types to always offer in the Content Type filter
|
|
81
|
+
* (e.g. "docs,blog,page"), in display order. Counts come from the search
|
|
82
|
+
* response and default to 0. Types that appear in a response but are not
|
|
83
|
+
* listed here are appended, so nothing is hidden. When unset, the menu lists
|
|
84
|
+
* only the types in the response.
|
|
85
|
+
*/
|
|
86
|
+
@api contentTypes?: string;
|
|
87
|
+
|
|
80
88
|
/** Results per page. */
|
|
81
89
|
@api limit?: number;
|
|
82
90
|
|
|
@@ -256,66 +264,76 @@ export default class SearchHybrid extends LightningElement {
|
|
|
256
264
|
// ---- content-type facet chips (disjunctive) ---------------------------
|
|
257
265
|
|
|
258
266
|
get facetChips(): FacetChip[] {
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
.
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
267
|
+
const responseFacets = (this.vm?.contentTypeFacets ?? []).filter(
|
|
268
|
+
(b) => b.value != null && b.value !== ""
|
|
269
|
+
);
|
|
270
|
+
const configured = (this.contentTypes ?? "")
|
|
271
|
+
.split(",")
|
|
272
|
+
.map((t) => t.trim())
|
|
273
|
+
.filter(Boolean);
|
|
274
|
+
// Configured types first (stable order), then any extra types the
|
|
275
|
+
// response returned. Per-type counts are intentionally not shown: they
|
|
276
|
+
// change as filters change, which is confusing.
|
|
277
|
+
const values = [
|
|
278
|
+
...new Set([...configured, ...responseFacets.map((b) => b.value)])
|
|
279
|
+
];
|
|
280
|
+
const selected = this.selectedTypeList;
|
|
281
|
+
return values.map((value) => {
|
|
282
|
+
const active = selected.includes(value);
|
|
283
|
+
return {
|
|
284
|
+
value,
|
|
285
|
+
label: this.contentTypeLabel(value) ?? value,
|
|
286
|
+
active,
|
|
287
|
+
cssClass: active
|
|
288
|
+
? "dx-facet-chip dx-facet-chip_active"
|
|
289
|
+
: "dx-facet-chip"
|
|
290
|
+
};
|
|
291
|
+
});
|
|
275
292
|
}
|
|
276
293
|
|
|
277
294
|
get hasFacets(): boolean {
|
|
278
295
|
return this.facetChips.length > 0;
|
|
279
296
|
}
|
|
280
297
|
|
|
281
|
-
/** Options for the sidebar dx-filter-menu (
|
|
298
|
+
/** Options for the sidebar dx-filter-menu (multi-select by content type, sent to the API as a comma-separated `type`). */
|
|
282
299
|
get typeFilterOptions(): Array<{
|
|
283
300
|
id: string;
|
|
284
301
|
name: string;
|
|
285
302
|
value: string;
|
|
303
|
+
checked: boolean;
|
|
286
304
|
}> {
|
|
287
305
|
return this.facetChips.map((chip) => ({
|
|
288
306
|
id: chip.value,
|
|
289
|
-
name:
|
|
290
|
-
value: chip.value
|
|
307
|
+
name: chip.label,
|
|
308
|
+
value: chip.value,
|
|
309
|
+
checked: chip.active
|
|
291
310
|
}));
|
|
292
311
|
}
|
|
293
312
|
|
|
294
|
-
|
|
295
|
-
|
|
313
|
+
/** The view model's selectedType (null | string | string[]) as a list. */
|
|
314
|
+
private get selectedTypeList(): string[] {
|
|
315
|
+
const t = this.vm?.selectedType;
|
|
316
|
+
return t == null ? [] : Array.isArray(t) ? t : [t];
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/** Adds `value` to the selection, or removes it if already selected. */
|
|
320
|
+
private toggleType(value: string): void {
|
|
321
|
+
const list = this.selectedTypeList;
|
|
322
|
+
const next = list.includes(value)
|
|
323
|
+
? list.filter((t) => t !== value)
|
|
324
|
+
: [...list, value];
|
|
325
|
+
// A single type is passed as a string, several as an array.
|
|
326
|
+
this.controller?.setType(next.length > 1 ? next : next[0] ?? null);
|
|
296
327
|
}
|
|
297
328
|
|
|
298
329
|
get hasActiveType(): boolean {
|
|
299
|
-
return
|
|
330
|
+
return this.selectedTypeList.length > 0;
|
|
300
331
|
}
|
|
301
332
|
|
|
302
333
|
get noActiveFilters(): boolean {
|
|
303
334
|
return !this.hasActiveType && this.localeValue === this.defaultLanguage;
|
|
304
335
|
}
|
|
305
336
|
|
|
306
|
-
get showRange(): boolean {
|
|
307
|
-
return this.hasResults && this.total > 0;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
get rangeStart(): number {
|
|
311
|
-
return ((this.vm?.page ?? 1) - 1) * (this.vm?.limit ?? 10) + 1;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
get rangeEnd(): number {
|
|
315
|
-
const limit = this.vm?.limit ?? 10;
|
|
316
|
-
return Math.min(this.rangeStart + limit - 1, this.total);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
337
|
// ---- locale select options -------------------------------------
|
|
320
338
|
|
|
321
339
|
get showLocaleSelector(): boolean {
|
|
@@ -369,8 +387,8 @@ export default class SearchHybrid extends LightningElement {
|
|
|
369
387
|
): void {
|
|
370
388
|
const value = event.detail?.value?.value;
|
|
371
389
|
if (value) {
|
|
372
|
-
//
|
|
373
|
-
this.
|
|
390
|
+
// Toggle: the controller adds the type, or removes it if selected.
|
|
391
|
+
this.toggleType(value);
|
|
374
392
|
}
|
|
375
393
|
}
|
|
376
394
|
|
|
@@ -386,9 +404,9 @@ export default class SearchHybrid extends LightningElement {
|
|
|
386
404
|
handleFacetClick(event: Event): void {
|
|
387
405
|
const value = (event.currentTarget as HTMLElement)?.dataset?.value;
|
|
388
406
|
if (value) {
|
|
389
|
-
//
|
|
390
|
-
//
|
|
391
|
-
this.
|
|
407
|
+
// Toggle: the controller adds the type, or removes it if it is
|
|
408
|
+
// already selected.
|
|
409
|
+
this.toggleType(value);
|
|
392
410
|
}
|
|
393
411
|
}
|
|
394
412
|
|