@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,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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
109
|
+
if (button === "previous") {
|
|
110
|
+
return PaginationClickType.Previous;
|
|
111
|
+
} else if (button === "next") {
|
|
112
|
+
return PaginationClickType.Next;
|
|
83
113
|
}
|
|
84
|
-
|
|
114
|
+
|
|
115
|
+
return PaginationClickType.Number;
|
|
85
116
|
}
|
|
86
117
|
|
|
87
|
-
private
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
129
|
+
|
|
130
|
+
return page;
|
|
92
131
|
}
|
|
93
132
|
}
|
|
@@ -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
|
|
7
|
-
@api dark
|
|
6
|
+
@api backgroundColor: string = "transparent";
|
|
7
|
+
@api dark: boolean = false;
|
|
8
8
|
@api headingLevel: "1" | "2" | "3" | "4" | "5" = "3";
|
|
9
|
-
@api label?: string
|
|
10
|
-
@api subtitle?: string
|
|
11
|
-
@api textAlign
|
|
12
|
-
@api title?: string
|
|
13
|
-
@api topGraphic
|
|
14
|
-
@api graphicOverlap
|
|
15
|
-
@api bottomGraphic
|
|
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(
|