@salesforcedevs/dx-components 0.42.1-alpha.1 → 0.43.0-alpha.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dx-components",
3
- "version": "0.42.1-alpha.1",
3
+ "version": "0.43.0-alpha.1",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -1,5 +1,19 @@
1
1
  import classNames from "classnames";
2
2
  import { LightningElement, api } from "lwc";
3
+ import { track } from "dx/instrumentation";
4
+
5
+ const ANALYTICS_INFO = {
6
+ clickUrl: window.location.href,
7
+ ctaClick: false,
8
+ elementType: "button",
9
+ destinationType: "internal"
10
+ };
11
+
12
+ enum PaginationClickType {
13
+ Number,
14
+ Next,
15
+ Previous
16
+ }
3
17
 
4
18
  export default class Pagination extends LightningElement {
5
19
  @api currentPage: string = "1";
@@ -76,18 +90,43 @@ export default class Pagination extends LightningElement {
76
90
  }
77
91
 
78
92
  private onPageChange(e: Event) {
93
+ const page = this.calculatePage(e);
94
+ const clickType = this.getPaginationClickType(e);
95
+
96
+ track(e.currentTarget!, "custEv_pagination", {
97
+ ...ANALYTICS_INFO,
98
+ clickText:
99
+ clickType === PaginationClickType.Number
100
+ ? page
101
+ : (e.target as HTMLElement).dataset.partId
102
+ });
103
+
104
+ this.dispatchEvent(new CustomEvent("pagechange", { detail: page }));
105
+ }
106
+
107
+ private getPaginationClickType(e: Event): PaginationClickType {
79
108
  const button = (e.target as HTMLElement).dataset.partId;
80
- let page = this.returnPage(button);
81
- if (page === 0) {
82
- page = +(e.target as HTMLElement).dataset.pageId!;
109
+ if (button === "previous") {
110
+ return PaginationClickType.Previous;
111
+ } else if (button === "next") {
112
+ return PaginationClickType.Next;
83
113
  }
84
- this.dispatchEvent(new CustomEvent("pagechange", { detail: page }));
114
+
115
+ return PaginationClickType.Number;
85
116
  }
86
117
 
87
- private returnPage(button: string) {
88
- if (!button) {
89
- return 0;
118
+ private calculatePage(e: Event) {
119
+ const clickType = this.getPaginationClickType(e);
120
+
121
+ let page = 0;
122
+ if (clickType === PaginationClickType.Previous) {
123
+ page = this._currentPage - 1;
124
+ } else if (clickType === PaginationClickType.Next) {
125
+ page = this._currentPage + 1;
126
+ } else {
127
+ page = +(e.target as HTMLElement).dataset.pageId!;
90
128
  }
91
- return this._currentPage + (button === "previous" ? -1 : 1);
129
+
130
+ return page;
92
131
  }
93
132
  }
@@ -69,7 +69,7 @@
69
69
  margin-bottom: var(--dx-g-spacing-md);
70
70
  }
71
71
 
72
- .text > .label {
72
+ .text > .label:not(:last-child) {
73
73
  margin-bottom: var(--dx-g-spacing-lg);
74
74
  }
75
75
 
@@ -3,16 +3,16 @@ import cx from "classnames";
3
3
  import { toDxColor } from "utils/css";
4
4
 
5
5
  export default class Section extends LightningElement {
6
- @api backgroundColor?: string | null = "transparent";
7
- @api dark?: boolean = false;
6
+ @api backgroundColor: string = "transparent";
7
+ @api dark: boolean = false;
8
8
  @api headingLevel: "1" | "2" | "3" | "4" | "5" = "3";
9
- @api label?: string | null = null;
10
- @api subtitle?: string | null = null;
11
- @api textAlign?: "center" | "left" = "left";
12
- @api title?: string | null = null;
13
- @api topGraphic?: boolean = false;
14
- @api graphicOverlap?: boolean = false;
15
- @api bottomGraphic?: boolean = false;
9
+ @api label?: string;
10
+ @api subtitle?: string;
11
+ @api textAlign: "center" | "left" = "left";
12
+ @api title?: string;
13
+ @api topGraphic: boolean = false;
14
+ @api graphicOverlap: boolean = false;
15
+ @api bottomGraphic: boolean = false;
16
16
 
17
17
  private get style(): string {
18
18
  return `--dx-c-section-background-color: ${toDxColor(