@salesforcedevs/dx-components 0.43.3-tree-selected-scroll-7 → 0.44.1

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/LICENSE ADDED
@@ -0,0 +1,12 @@
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dx-components",
3
- "version": "0.43.3-tree-selected-scroll-7",
3
+ "version": "0.44.1",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -27,5 +27,6 @@
27
27
  "@types/debounce": "^1.2.0",
28
28
  "@types/lodash.get": "^4.4.6",
29
29
  "@types/vimeo__player": "^2.16.2"
30
- }
30
+ },
31
+ "gitHead": "8bcacbac2ec87fc56ed51e45abc2693a26096cef"
31
32
  }
@@ -31,11 +31,16 @@ export default class DropdownOption extends LightningElement {
31
31
  const navSubHeading =
32
32
  (this.navItemLabel ? this.option.label : undefined) || undefined;
33
33
 
34
- const payload = {
34
+ const payload: any = {
35
35
  navHeading,
36
36
  navSubHeading,
37
37
  clickText: this.keyValue || undefined,
38
- pageLocation: window.location.pathname || undefined
38
+ pageLocation: window.location.pathname || undefined,
39
+ elementType: "dropdown",
40
+ destinationType: "internal",
41
+ ctaClick: true,
42
+ itemTitle: this.option.label || undefined,
43
+ clickUrl: e.target?.href || undefined
39
44
  };
40
45
 
41
46
  if (this.analyticsEvent && e.currentTarget) {
@@ -93,12 +93,15 @@ export default class Pagination extends LightningElement {
93
93
  const page = this.calculatePage(e);
94
94
  const clickType = this.getPaginationClickType(e);
95
95
 
96
+ const clickText =
97
+ clickType === PaginationClickType.Number
98
+ ? page
99
+ : (e.target as HTMLElement).dataset.partId;
100
+
96
101
  track(e.currentTarget!, "custEv_pagination", {
97
102
  ...ANALYTICS_INFO,
98
- clickText:
99
- clickType === PaginationClickType.Number
100
- ? page
101
- : (e.target as HTMLElement).dataset.partId
103
+ clickText,
104
+ itemTitle: clickText
102
105
  });
103
106
 
104
107
  this.dispatchEvent(new CustomEvent("pagechange", { detail: page }));
@@ -88,7 +88,6 @@
88
88
  tree-root={tree.tree}
89
89
  onselect={onSelect}
90
90
  value={value}
91
- onselecteditemrendered={onSelectedItemRendered}
92
91
  ></dx-tree>
93
92
  </div>
94
93
  </div>
@@ -1,6 +1,6 @@
1
1
  import cx from "classnames";
2
2
  import { track as trackAnalytics } from "dx/instrumentation";
3
- import { api, track } from "lwc";
3
+ import { LightningElement, api, track } from "lwc";
4
4
  import {
5
5
  TreeNode,
6
6
  SidebarGtmAction,
@@ -9,12 +9,11 @@ import {
9
9
  import { getSidebarSearchParams } from "utils/coveo";
10
10
  import { toJson } from "utils/normalizers";
11
11
  import SidebarSearch from "dx/sidebarSearch";
12
- import { SidebarBase } from "base-elements/sidebarBase";
13
12
 
14
13
  const MOBILE_SIZE_MATCH = "768px";
15
14
  const TOGGLE_BUTTON_LABEL = "Toggle Sidebar";
16
15
 
17
- export default class Sidebar extends SidebarBase {
16
+ export default class Sidebar extends LightningElement {
18
17
  @api coveoOrganizationId!: string;
19
18
  @api coveoPublicAccessToken!: string;
20
19
  @api coveoSearchHub!: string;
@@ -49,7 +49,7 @@
49
49
  ></dx-input>
50
50
  </div>
51
51
  </div>
52
- <div class="sidebar-content sidebar-content-tree" if:true={anyResultMatch}>
52
+ <div class="sidebar-content" if:true={anyResultMatch}>
53
53
  <dx-tree
54
54
  for:each={filteredTrees}
55
55
  for:item="tree"
@@ -57,7 +57,6 @@
57
57
  tree-root={tree.tree}
58
58
  onselect={onSelect}
59
59
  value={value}
60
- onselecteditemrendered={onSelectedItemRendered}
61
60
  ></dx-tree>
62
61
  </div>
63
62
  <dx-empty-state
@@ -1,16 +1,15 @@
1
1
  import cx from "classnames";
2
2
  import { track } from "dx/instrumentation";
3
- import { api } from "lwc";
3
+ import { LightningElement, api } from "lwc";
4
4
 
5
5
  import { TreeNode, SidebarGtmAction } from "typings/custom";
6
6
  import { toJson } from "utils/normalizers";
7
- import { SidebarBase } from "base-elements/sidebarBase";
8
7
 
9
8
  const WAIT_TIME = 500;
10
9
  const MOBILE_SIZE_MATCH = "768px";
11
10
  const TOGGLE_BUTTON_LABEL = "Toggle Sidebar";
12
11
 
13
- export default class Sidebar extends SidebarBase {
12
+ export default class Sidebar extends LightningElement {
14
13
  @api header: string = "";
15
14
 
16
15
  @api
@@ -2,7 +2,6 @@ import { LightningElement, api } from "lwc";
2
2
  import { InternalTreeNode } from "typings/custom";
3
3
  import { track } from "dx/instrumentation";
4
4
  import { SidebarGtmAction } from "typings/custom";
5
- import { isInViewport } from "utils/browser";
6
5
 
7
6
  const DEFAULT_TARGET = "_self";
8
7
 
@@ -62,25 +61,6 @@ export default class TreeItem extends LightningElement {
62
61
  }
63
62
  }
64
63
 
65
- renderedCallback(): void {
66
- this.sendEventToParentIfSelected();
67
- }
68
-
69
- private sendEventToParentIfSelected(): void {
70
- /**
71
- * This is to send selected element reference to parent if it's not visible in the viewport
72
- * Parent component will use the elements offsetTop scrollTo that element's position
73
- */
74
- if (this.isSelected) {
75
- const element = this.template.querySelector("dx-tree-tile");
76
- if (element && !isInViewport(element)) {
77
- this.fireEvent("selecteditemrendered", {
78
- element
79
- });
80
- }
81
- }
82
- }
83
-
84
64
  private onIconClick(event: CustomEvent): void {
85
65
  const isSelectAction = false;
86
66
  this.doExpand(isSelectAction);
@@ -1,45 +0,0 @@
1
- import { LightningElement } from "lwc";
2
- import debounce from "debounce";
3
-
4
- export const HEIGHT_OF_SIDEBAR_ITEM = 32;
5
- export const WAIT_TIME_BEFORE_SCROLL_IN_MS = 500;
6
-
7
- export class SidebarBase extends LightningElement {
8
- _sidebarContent: HTMLElement | null = null;
9
-
10
- timerId: ReturnType<typeof setTimeout> | null = null;
11
-
12
- get sidebarContent() {
13
- if (!this._sidebarContent) {
14
- this._sidebarContent = this.template.querySelector(
15
- ".sidebar-content-tree"
16
- );
17
- }
18
- return this._sidebarContent;
19
- }
20
-
21
- /*Scroll to selected tree item */
22
- private _onSelectedItemRendered = (event: CustomEvent) => {
23
- event.stopPropagation();
24
- const selectedElement = event.detail.element;
25
- if (selectedElement && this.sidebarContent) {
26
- const scrollHeight: number =
27
- selectedElement.getBoundingClientRect().bottom -
28
- this.sidebarContent.getBoundingClientRect().bottom + // We need to remove parent bottom
29
- HEIGHT_OF_SIDEBAR_ITEM * 3 + // add height of 3 more items so that user can see at least three more items after selected item
30
- this.sidebarContent.offsetTop; // We need to add sidebar offsetTop value as scrollTo will consider it
31
- this.sidebarContent.scrollTo({
32
- top: scrollHeight,
33
- behavior: "smooth"
34
- });
35
- }
36
- };
37
-
38
- private onSelectedItemRendered = (event: CustomEvent) => {
39
- debounce(
40
- // @ts-ignore something weird happening here with debounce types
41
- this._onSelectedItemRendered.bind(this)(event),
42
- WAIT_TIME_BEFORE_SCROLL_IN_MS
43
- );
44
- };
45
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * Returns whether given element is in browser viewport or not
3
- */
4
- function isInViewport(element: HTMLElement): boolean {
5
- const rect = element?.getBoundingClientRect();
6
- return (
7
- rect &&
8
- rect.top >= 0 &&
9
- rect.left >= 0 &&
10
- rect.bottom <=
11
- (window.innerHeight || document.documentElement.clientHeight) &&
12
- rect.right <=
13
- (window.innerWidth || document.documentElement.clientWidth)
14
- );
15
- }
16
-
17
- export { isInViewport };