@salesforcedevs/dx-components 1.18.0 → 1.18.2-search-alpha

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.18.0",
3
+ "version": "1.18.2-search-alpha",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -44,6 +44,5 @@
44
44
  },
45
45
  "volta": {
46
46
  "node": "20.19.0"
47
- },
48
- "gitHead": "356246059688070ad1c23baf2a84839ab4e27b6a"
47
+ }
49
48
  }
@@ -23,6 +23,7 @@
23
23
  </a>
24
24
  <div
25
25
  class="dx-card-base_section-vertical dx-card-base_column card_section-text"
26
+ part="content-container"
26
27
  >
27
28
  <span lwc:if={label} part="label" class="label dx-text-label-3">
28
29
  {label}
@@ -58,6 +58,7 @@
58
58
  value={searchText}
59
59
  onchange={onSearchChange}
60
60
  shortcut-key="j"
61
+ clearable
61
62
  ></dx-input>
62
63
  </div>
63
64
  <slot name="version-picker"></slot>
@@ -29,6 +29,15 @@ export default class Sidebar extends SidebarBase {
29
29
  this.assignFilteredTrees();
30
30
  }
31
31
 
32
+ @api
33
+ get emptyStateMessage(): string | undefined {
34
+ return this._emptyStateMessage;
35
+ }
36
+
37
+ set emptyStateMessage(value: string) {
38
+ this._emptyStateMessage = value;
39
+ }
40
+
32
41
  private _searchTimeout?: number;
33
42
  private _trees!: Array<TreeNode>;
34
43
 
@@ -36,6 +45,7 @@ export default class Sidebar extends SidebarBase {
36
45
  private searchText: string = "";
37
46
  private matchMedia!: MediaQueryList;
38
47
  private valueToLabel: { [key: string]: string } = {};
48
+ private _emptyStateMessage?: string;
39
49
 
40
50
  private get anyResultMatch() {
41
51
  return this.filteredTrees.length > 0;
@@ -65,10 +75,13 @@ export default class Sidebar extends SidebarBase {
65
75
  }
66
76
 
67
77
  private get emptyStateSuggestions(): string {
68
- return JSON.stringify([
69
- "Please consider misspellings",
70
- "Try different search keywords"
71
- ]);
78
+ return (
79
+ this.emptyStateMessage ||
80
+ JSON.stringify([
81
+ "Please consider misspellings",
82
+ "Try different search keywords"
83
+ ])
84
+ );
72
85
  }
73
86
 
74
87
  private get isDesktop(): boolean {
@@ -44,16 +44,19 @@ export default class Tree extends LightningElement {
44
44
  onTileSelected(event: CustomEvent) {
45
45
  event.stopPropagation();
46
46
 
47
- const { key, name } = event.detail;
48
- this._value = name;
49
- this.selectedKey = key;
50
- this.dispatchEvent(
51
- new CustomEvent("select", {
52
- detail: { name },
53
- composed: true,
54
- bubbles: true
55
- })
56
- );
47
+ const { isExternalLink } = event.detail;
48
+ if (!isExternalLink) {
49
+ const { key, name } = event.detail;
50
+ this._value = name;
51
+ this.selectedKey = key;
52
+ this.dispatchEvent(
53
+ new CustomEvent("select", {
54
+ detail: { name },
55
+ composed: true,
56
+ bubbles: true
57
+ })
58
+ );
59
+ }
57
60
  }
58
61
 
59
62
  onExpandCollapse(event: CustomEvent) {
@@ -10,6 +10,7 @@
10
10
  oniconclick={onIconClick}
11
11
  show-arrow={isParent}
12
12
  target={target}
13
+ is-external-link={isExternalLink}
13
14
  ></dx-tree-tile>
14
15
  </a>
15
16
  <img
@@ -25,8 +25,12 @@ export default class TreeItem extends LightningElement {
25
25
  private isChildrenLoading: boolean = false;
26
26
  private rootParentLabel: string = "";
27
27
 
28
+ private get isExternalLink(): boolean {
29
+ return this._treeNode?.link?.target === "_blank";
30
+ }
31
+
28
32
  private get isSelected(): boolean {
29
- return this._treeNode.key === this.selectedKey;
33
+ return this._treeNode.key === this.selectedKey && !this.isExternalLink;
30
34
  }
31
35
 
32
36
  private get hasChildren(): boolean {
@@ -142,7 +146,10 @@ export default class TreeItem extends LightningElement {
142
146
  }
143
147
 
144
148
  this.sendGtm(event);
145
- this.fireEvent("tileselected", { name: this._treeNode.name });
149
+ this.fireEvent("tileselected", {
150
+ name: this._treeNode.name,
151
+ isExternalLink: this.isExternalLink
152
+ });
146
153
  }
147
154
 
148
155
  private doExpand(isSelectAction: boolean): void {
@@ -52,6 +52,16 @@
52
52
  margin-left: auto;
53
53
  }
54
54
 
55
+ .tile-external-link-icon {
56
+ display: inline-flex;
57
+ align-items: center;
58
+ margin-left: var(--dx-g-spacing-xs);
59
+ }
60
+
61
+ .whitespace-nowrap {
62
+ white-space: nowrap;
63
+ }
64
+
55
65
  .tile-with-children .tile-label {
56
66
  order: 2;
57
67
  }
@@ -14,7 +14,21 @@
14
14
  class="tile-label sidebar-item-truncate-text"
15
15
  title={treeNode.label}
16
16
  >
17
- {treeNode.label}
17
+ <template lwc:if={isExternalLink}>
18
+ <span lwc:if={modifiedLabel.restOfLabel.length}>
19
+ {modifiedLabel.restOfLabel}
20
+ </span>
21
+ <span class="whitespace-nowrap">
22
+ {modifiedLabel.lastWord}
23
+ <dx-icon
24
+ class="flex tile-icon tile-external-link-icon"
25
+ symbol="new_window"
26
+ sprite="utility"
27
+ size="xsmall"
28
+ ></dx-icon>
29
+ </span>
30
+ </template>
31
+ <template lwc:else>{treeNode.label}</template>
18
32
  </span>
19
33
  <dx-metadata-badge
20
34
  if:true={showMethod}
@@ -31,6 +31,7 @@ export default class TreeTile extends LightningElement {
31
31
  @api href!: string;
32
32
  @api showArrow = false;
33
33
  @api target!: string;
34
+ @api isExternalLink = false;
34
35
 
35
36
  get tileAriaLevel() {
36
37
  return this.treeNode.level + 2;
@@ -58,6 +59,17 @@ export default class TreeTile extends LightningElement {
58
59
  return "";
59
60
  }
60
61
 
62
+ // in case of multiline label, external link icon should not leave alone.
63
+ private get modifiedLabel() {
64
+ const label = this.treeNode.label.trim().split(" ");
65
+ const lastWord = label.pop();
66
+
67
+ return {
68
+ lastWord,
69
+ restOfLabel: label.length ? `${label.join(" ")} ` : ""
70
+ };
71
+ }
72
+
61
73
  private get tileClass() {
62
74
  return cx("tile", "sidebar-item", {
63
75
  "tile-root": this.isRoot,
package/LICENSE DELETED
@@ -1,12 +0,0 @@
1
- Copyright (c) 2020, Salesforce.com, Inc.
2
- All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
-
6
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
-
8
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
-
10
- * Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
-
12
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.