@salesforcedevs/dx-components 1.3.321 → 1.3.322-tabrnb-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.3.
|
|
3
|
+
"version": "1.3.322-tabrnb-alpha",
|
|
4
4
|
"description": "DX Lightning web components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -45,6 +45,5 @@
|
|
|
45
45
|
},
|
|
46
46
|
"volta": {
|
|
47
47
|
"node": "16.19.1"
|
|
48
|
-
}
|
|
49
|
-
"gitHead": "284f6c7c36422426de5d8167dcf1f4d88742c9ff"
|
|
48
|
+
}
|
|
50
49
|
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { LightningElement, api } from "lwc";
|
|
2
2
|
|
|
3
3
|
export default class RelativeDateTime extends LightningElement {
|
|
4
|
-
@api messageWhenHoursPast: String = "";
|
|
5
|
-
@api messageWhenDaysPast: String = "";
|
|
6
|
-
@api messageWhenWeeksPast: String = "";
|
|
7
|
-
@api messageWhenMonthsPast: String = "";
|
|
8
|
-
@api messageWhenYearsPast: String = "";
|
|
9
|
-
|
|
10
4
|
@api
|
|
11
5
|
set value(value) {
|
|
12
6
|
if (!value) {
|
|
@@ -14,102 +8,35 @@ export default class RelativeDateTime extends LightningElement {
|
|
|
14
8
|
return;
|
|
15
9
|
}
|
|
16
10
|
|
|
17
|
-
this.
|
|
11
|
+
this._inputDateTime = new Date(value);
|
|
18
12
|
}
|
|
19
13
|
get value() {
|
|
20
|
-
|
|
21
|
-
this.
|
|
22
|
-
);
|
|
23
|
-
this._relativeDateTime = this.getRelativeDateTimeAsString(
|
|
24
|
-
this._selectedDateTime!,
|
|
25
|
-
relativeDateTimeInHours
|
|
14
|
+
this._relativeDateTime = this.getFormattedDateTime(
|
|
15
|
+
this._inputDateTime!
|
|
26
16
|
);
|
|
27
17
|
return this._relativeDateTime;
|
|
28
18
|
}
|
|
29
19
|
get original() {
|
|
30
|
-
return this.
|
|
20
|
+
return this._inputDateTime?.toLocaleString();
|
|
31
21
|
}
|
|
32
22
|
|
|
23
|
+
private _inputDateTime?: Date;
|
|
33
24
|
private _relativeDateTime?: string;
|
|
34
|
-
private _selectedDateTime?: Date;
|
|
35
|
-
|
|
36
|
-
formatDate(selectedDateTime: Date) {
|
|
37
|
-
const currentDateTime = new Date();
|
|
38
|
-
const relativeDateTimeInHours = this.getDifferenceInHours(
|
|
39
|
-
selectedDateTime,
|
|
40
|
-
currentDateTime
|
|
41
|
-
);
|
|
42
|
-
return relativeDateTimeInHours;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
getDifferenceInHours(selectedDateTime: Date, currentDateTime: Date) {
|
|
46
|
-
const milliseconds = Math.abs(+selectedDateTime - +currentDateTime);
|
|
47
|
-
const hours = Math.floor(milliseconds / 36e5);
|
|
48
|
-
return hours;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
getRelativeDateTimeAsString(
|
|
52
|
-
selectedDateTime: Date,
|
|
53
|
-
relativeDateTimeInHours: number
|
|
54
|
-
) {
|
|
55
|
-
const daysPast = Math.floor(+relativeDateTimeInHours / 24);
|
|
56
|
-
const weeksPast = Math.floor(+daysPast / 7);
|
|
57
|
-
const monthsPast = Math.floor(+daysPast / 30);
|
|
58
|
-
const yearsPast = Math.floor(+monthsPast / 12);
|
|
59
|
-
if (yearsPast >= 1) {
|
|
60
|
-
return this.timeLabel("year", yearsPast);
|
|
61
|
-
} else if (monthsPast <= 11 && monthsPast >= 1) {
|
|
62
|
-
return this.timeLabel("month", monthsPast);
|
|
63
|
-
} else if (monthsPast < 1 && daysPast >= 7) {
|
|
64
|
-
return this.timeLabel("week", weeksPast);
|
|
65
|
-
} else if (daysPast <= 7 && daysPast >= 1) {
|
|
66
|
-
return this.timeLabel("day", daysPast);
|
|
67
|
-
} else if (relativeDateTimeInHours < 24) {
|
|
68
|
-
return this.timeLabel("hour", relativeDateTimeInHours);
|
|
69
|
-
}
|
|
70
|
-
return "";
|
|
71
|
-
}
|
|
72
25
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
case "week": {
|
|
89
|
-
suffix =
|
|
90
|
-
this.messageWhenWeeksPast ||
|
|
91
|
-
`${this.pluralize(type, number)} ago`;
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
case "month": {
|
|
95
|
-
suffix =
|
|
96
|
-
this.messageWhenMonthsPast ||
|
|
97
|
-
`${this.pluralize(type, number)} ago`;
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
case "year": {
|
|
101
|
-
suffix =
|
|
102
|
-
this.messageWhenYearsPast ||
|
|
103
|
-
`${this.pluralize(type, number)} ago`;
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
default:
|
|
107
|
-
suffix = "";
|
|
26
|
+
getFormattedDateTime(inputDateTime: Date) {
|
|
27
|
+
const now = new Date();
|
|
28
|
+
const yesterday = new Date(
|
|
29
|
+
now.getTime() - 24 * 60 * 60 * 1000
|
|
30
|
+
).toLocaleDateString();
|
|
31
|
+
const twoDaysAgo = new Date(
|
|
32
|
+
now.getTime() - 48 * 60 * 60 * 1000
|
|
33
|
+
).toLocaleDateString();
|
|
34
|
+
const dateStringFromInput = inputDateTime?.toLocaleDateString();
|
|
35
|
+
if (dateStringFromInput === yesterday) {
|
|
36
|
+
return "1 day ago";
|
|
37
|
+
} else if (dateStringFromInput === twoDaysAgo) {
|
|
38
|
+
return "2 days ago";
|
|
108
39
|
}
|
|
109
|
-
return
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
pluralize(type: String, number: Number) {
|
|
113
|
-
return `${type}${number !== 1 ? "s" : ""}`;
|
|
40
|
+
return dateStringFromInput;
|
|
114
41
|
}
|
|
115
42
|
}
|
|
@@ -7944,7 +7944,7 @@ select.coveo-dropdown::-ms-expand {
|
|
|
7944
7944
|
|
|
7945
7945
|
@font-face {
|
|
7946
7946
|
font-family: "Lato";
|
|
7947
|
-
src: url('https://static.cloud.coveo.com/searchui/v2.
|
|
7947
|
+
src: url('https://static.cloud.coveo.com/searchui/v2.10115/0/fonts/lato.woff2'), url('https://staticdev.cloud.coveo.com/searchui/v2.10115/0/fonts/lato.woff2'), url('../fonts/lato.woff2'), url('https://static.cloud.coveo.com/searchui/v2.10115/0/fonts/lato.woff'), url('https://staticdev.cloud.coveo.com/searchui/v2.10115/0/fonts/lato.woff'), url('../fonts/lato.woff');
|
|
7948
7948
|
font-weight: normal;
|
|
7949
7949
|
font-style: normal;
|
|
7950
7950
|
}
|
|
@@ -92,6 +92,14 @@ export default class TabPanelList extends LightningElement {
|
|
|
92
92
|
this.tabElements.forEach((tab: any, index) => {
|
|
93
93
|
tab.active = this.activeIndex === index;
|
|
94
94
|
});
|
|
95
|
+
|
|
96
|
+
this.dispatchEvent(
|
|
97
|
+
new CustomEvent("tabchanged", {
|
|
98
|
+
detail: this.id || this.groupId,
|
|
99
|
+
bubbles: true,
|
|
100
|
+
composed: true
|
|
101
|
+
})
|
|
102
|
+
);
|
|
95
103
|
}
|
|
96
104
|
|
|
97
105
|
private focusActiveTab() {
|
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.
|