@qrvey/utils 1.15.0 → 1.16.0-0
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/dist/cjs/dates/constants/DATE_DISTINCT_PROPERTY.d.ts +2 -1
- package/dist/cjs/dates/constants/DATE_DISTINCT_PROPERTY.js +1 -0
- package/dist/cjs/globalization/helpers/getI18nDateGroupLabel.d.ts +6 -0
- package/dist/cjs/globalization/helpers/getI18nDateGroupLabel.js +120 -0
- package/dist/dates/constants/DATE_DISTINCT_PROPERTY.d.ts +2 -1
- package/dist/dates/constants/DATE_DISTINCT_PROPERTY.js +1 -0
- package/dist/globalization/helpers/getI18nDateGroupLabel.d.ts +6 -0
- package/dist/globalization/helpers/getI18nDateGroupLabel.js +120 -0
- package/package.json +1 -1
|
@@ -8,4 +8,5 @@ var DATE_DISTINCT_PROPERTY;
|
|
|
8
8
|
// YEAR_DAY = 'p-y-day',
|
|
9
9
|
DATE_DISTINCT_PROPERTY["MONTH_DAY"] = "day_only";
|
|
10
10
|
// WEEK_DAY = 'p-w-day'
|
|
11
|
+
DATE_DISTINCT_PROPERTY["DAY_CUSTOM"] = "day_custom";
|
|
11
12
|
})(DATE_DISTINCT_PROPERTY || (exports.DATE_DISTINCT_PROPERTY = DATE_DISTINCT_PROPERTY = {}));
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { IDateColumnPropertyType } from "../../columns/interfaces/IDateColumnPropertyType";
|
|
2
2
|
import { II18nServiceTranslate } from "../interfaces/II18nServiceTranslate";
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param label
|
|
6
|
+
* @param dateGroup
|
|
7
|
+
* @param translate
|
|
8
|
+
*/
|
|
3
9
|
export declare function getI18nDateGroupLabel(label: string, dateGroup: IDateColumnPropertyType, translate?: II18nServiceTranslate): string;
|
|
@@ -6,6 +6,12 @@ const DATE_GROUPING_PROPERTY_1 = require("../../dates/constants/DATE_GROUPING_PR
|
|
|
6
6
|
const DATE_YEAR_MONTHS_1 = require("../../dates/constants/DATE_YEAR_MONTHS");
|
|
7
7
|
const isEmpty_1 = require("../../general/mix/isEmpty");
|
|
8
8
|
const isTokenLabel_1 = require("../../tokens/isTokenLabel");
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param label
|
|
12
|
+
* @param dateGroup
|
|
13
|
+
* @param translate
|
|
14
|
+
*/
|
|
9
15
|
function getI18nDateGroupLabel(label, dateGroup, translate) {
|
|
10
16
|
if ((0, isEmpty_1.isEmpty)(label))
|
|
11
17
|
return label;
|
|
@@ -19,14 +25,26 @@ function getI18nDateGroupLabel(label, dateGroup, translate) {
|
|
|
19
25
|
return getI18nYearMonthLabel(label, translate);
|
|
20
26
|
else if (dateGroup === DATE_DISTINCT_PROPERTY_1.DATE_DISTINCT_PROPERTY.YEAR_QUARTER)
|
|
21
27
|
return getI18nYearQuarterLabel(label, translate);
|
|
28
|
+
else if (dateGroup === DATE_DISTINCT_PROPERTY_1.DATE_DISTINCT_PROPERTY.DAY_CUSTOM)
|
|
29
|
+
return getI18nDayCustomLabel(label, translate);
|
|
22
30
|
return label;
|
|
23
31
|
}
|
|
24
32
|
exports.getI18nDateGroupLabel = getI18nDateGroupLabel;
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @param label
|
|
36
|
+
* @param translate
|
|
37
|
+
*/
|
|
25
38
|
function getI18nMonthLabel(label, translate) {
|
|
26
39
|
const splittedLabel = label.split(" ");
|
|
27
40
|
splittedLabel[0] = getI18nYearMonthLabel(splittedLabel[0], translate);
|
|
28
41
|
return splittedLabel.join(" ");
|
|
29
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @param label
|
|
46
|
+
* @param translate
|
|
47
|
+
*/
|
|
30
48
|
function getI18nYearMonthLabel(label, translate) {
|
|
31
49
|
let newLabel = label;
|
|
32
50
|
if (!(0, isTokenLabel_1.isTokenLabel)(newLabel) && !(0, isEmpty_1.isEmpty)(translate)) {
|
|
@@ -36,6 +54,10 @@ function getI18nYearMonthLabel(label, translate) {
|
|
|
36
54
|
}
|
|
37
55
|
return newLabel;
|
|
38
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
* @param index
|
|
60
|
+
*/
|
|
39
61
|
function getI18nMonthPropertyByIndex(index) {
|
|
40
62
|
const months = [
|
|
41
63
|
"january",
|
|
@@ -53,11 +75,21 @@ function getI18nMonthPropertyByIndex(index) {
|
|
|
53
75
|
];
|
|
54
76
|
return months[index];
|
|
55
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
*
|
|
80
|
+
* @param label
|
|
81
|
+
* @param translate
|
|
82
|
+
*/
|
|
56
83
|
function getI18nQuarterLabel(label, translate) {
|
|
57
84
|
const splittedLabel = label.split(" ");
|
|
58
85
|
splittedLabel[0] = getI18nYearQuarterLabel(splittedLabel[0], translate);
|
|
59
86
|
return splittedLabel.join(" ");
|
|
60
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
*
|
|
90
|
+
* @param label
|
|
91
|
+
* @param translate
|
|
92
|
+
*/
|
|
61
93
|
function getI18nYearQuarterLabel(label, translate) {
|
|
62
94
|
let newLabel = label;
|
|
63
95
|
if (!(0, isTokenLabel_1.isTokenLabel)(newLabel) && !(0, isEmpty_1.isEmpty)(translate)) {
|
|
@@ -65,11 +97,21 @@ function getI18nYearQuarterLabel(label, translate) {
|
|
|
65
97
|
}
|
|
66
98
|
return newLabel;
|
|
67
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
*
|
|
102
|
+
* @param label
|
|
103
|
+
* @param translate
|
|
104
|
+
*/
|
|
68
105
|
function getI18nWeekLabel(label, translate) {
|
|
69
106
|
const splittedLabel = label.split(" ");
|
|
70
107
|
splittedLabel[0] = getI18nYearWeekLabel(splittedLabel[0], translate);
|
|
71
108
|
return splittedLabel.join(" ");
|
|
72
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
*
|
|
112
|
+
* @param label
|
|
113
|
+
* @param translate
|
|
114
|
+
*/
|
|
73
115
|
function getI18nYearWeekLabel(label, translate) {
|
|
74
116
|
let newLabel = label;
|
|
75
117
|
if (!(0, isTokenLabel_1.isTokenLabel)(newLabel) && !(0, isEmpty_1.isEmpty)(translate)) {
|
|
@@ -77,3 +119,81 @@ function getI18nYearWeekLabel(label, translate) {
|
|
|
77
119
|
}
|
|
78
120
|
return newLabel;
|
|
79
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
*
|
|
124
|
+
* @param label
|
|
125
|
+
* @param translate
|
|
126
|
+
*/
|
|
127
|
+
function getI18nDayCustomLabel(label, translate) {
|
|
128
|
+
const dayMapper = {
|
|
129
|
+
Monday: "monday",
|
|
130
|
+
Tuesday: "tuesday",
|
|
131
|
+
Wednesday: "wednesday",
|
|
132
|
+
Thursday: "thursday",
|
|
133
|
+
Friday: "friday",
|
|
134
|
+
Saturday: "saturday",
|
|
135
|
+
Sunday: "sunday",
|
|
136
|
+
};
|
|
137
|
+
const dayAbbMapper = {
|
|
138
|
+
Mon: "monday",
|
|
139
|
+
Tue: "tuesday",
|
|
140
|
+
Wed: "wednesday",
|
|
141
|
+
Thu: "thursday",
|
|
142
|
+
Fri: "friday",
|
|
143
|
+
Sat: "saturday",
|
|
144
|
+
Sun: "sunday",
|
|
145
|
+
};
|
|
146
|
+
const monthMapper = {
|
|
147
|
+
January: "january",
|
|
148
|
+
February: "february",
|
|
149
|
+
March: "march",
|
|
150
|
+
April: "april",
|
|
151
|
+
May: "may",
|
|
152
|
+
June: "june",
|
|
153
|
+
July: "july",
|
|
154
|
+
August: "august",
|
|
155
|
+
September: "september",
|
|
156
|
+
October: "october",
|
|
157
|
+
November: "november",
|
|
158
|
+
December: "december",
|
|
159
|
+
};
|
|
160
|
+
const monthAbbMapper = {
|
|
161
|
+
Jan: "january",
|
|
162
|
+
Feb: "february",
|
|
163
|
+
Mar: "march",
|
|
164
|
+
Apr: "april",
|
|
165
|
+
May: "may",
|
|
166
|
+
Jun: "june",
|
|
167
|
+
Jul: "july",
|
|
168
|
+
Aug: "august",
|
|
169
|
+
Sep: "september",
|
|
170
|
+
Oct: "october",
|
|
171
|
+
Nov: "november",
|
|
172
|
+
Dec: "december",
|
|
173
|
+
};
|
|
174
|
+
let newLabel = label;
|
|
175
|
+
if (!(0, isTokenLabel_1.isTokenLabel)(newLabel) && !(0, isEmpty_1.isEmpty)(translate)) {
|
|
176
|
+
const regex = new RegExp([
|
|
177
|
+
...Object.keys(dayMapper),
|
|
178
|
+
...Object.keys(dayAbbMapper),
|
|
179
|
+
...Object.keys(monthMapper),
|
|
180
|
+
...Object.keys(monthAbbMapper),
|
|
181
|
+
].join("|"), "g");
|
|
182
|
+
newLabel = newLabel.replace(regex, (match) => {
|
|
183
|
+
if (dayMapper[match]) {
|
|
184
|
+
return translate(`common.day_names.${dayMapper[match]}_dddd`);
|
|
185
|
+
}
|
|
186
|
+
else if (dayAbbMapper[match]) {
|
|
187
|
+
return translate(`common.day_names.${dayAbbMapper[match]}_ddd`);
|
|
188
|
+
}
|
|
189
|
+
else if (monthMapper[match]) {
|
|
190
|
+
return translate(`common.date_grouping.${monthMapper[match]}_mmmm`);
|
|
191
|
+
}
|
|
192
|
+
else if (monthAbbMapper[match]) {
|
|
193
|
+
return translate(`common.date_grouping.${monthAbbMapper[match]}_mmm`);
|
|
194
|
+
}
|
|
195
|
+
return match;
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
return newLabel;
|
|
199
|
+
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { IDateColumnPropertyType } from "../../columns/interfaces/IDateColumnPropertyType";
|
|
2
2
|
import { II18nServiceTranslate } from "../interfaces/II18nServiceTranslate";
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param label
|
|
6
|
+
* @param dateGroup
|
|
7
|
+
* @param translate
|
|
8
|
+
*/
|
|
3
9
|
export declare function getI18nDateGroupLabel(label: string, dateGroup: IDateColumnPropertyType, translate?: II18nServiceTranslate): string;
|
|
@@ -3,6 +3,12 @@ import { DATE_GROUPING_PROPERTY } from "../../dates/constants/DATE_GROUPING_PROP
|
|
|
3
3
|
import { DATE_YEAR_MONTHS } from "../../dates/constants/DATE_YEAR_MONTHS";
|
|
4
4
|
import { isEmpty } from "../../general/mix/isEmpty";
|
|
5
5
|
import { isTokenLabel } from "../../tokens/isTokenLabel";
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param label
|
|
9
|
+
* @param dateGroup
|
|
10
|
+
* @param translate
|
|
11
|
+
*/
|
|
6
12
|
export function getI18nDateGroupLabel(label, dateGroup, translate) {
|
|
7
13
|
if (isEmpty(label))
|
|
8
14
|
return label;
|
|
@@ -16,13 +22,25 @@ export function getI18nDateGroupLabel(label, dateGroup, translate) {
|
|
|
16
22
|
return getI18nYearMonthLabel(label, translate);
|
|
17
23
|
else if (dateGroup === DATE_DISTINCT_PROPERTY.YEAR_QUARTER)
|
|
18
24
|
return getI18nYearQuarterLabel(label, translate);
|
|
25
|
+
else if (dateGroup === DATE_DISTINCT_PROPERTY.DAY_CUSTOM)
|
|
26
|
+
return getI18nDayCustomLabel(label, translate);
|
|
19
27
|
return label;
|
|
20
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param label
|
|
32
|
+
* @param translate
|
|
33
|
+
*/
|
|
21
34
|
function getI18nMonthLabel(label, translate) {
|
|
22
35
|
const splittedLabel = label.split(" ");
|
|
23
36
|
splittedLabel[0] = getI18nYearMonthLabel(splittedLabel[0], translate);
|
|
24
37
|
return splittedLabel.join(" ");
|
|
25
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param label
|
|
42
|
+
* @param translate
|
|
43
|
+
*/
|
|
26
44
|
function getI18nYearMonthLabel(label, translate) {
|
|
27
45
|
let newLabel = label;
|
|
28
46
|
if (!isTokenLabel(newLabel) && !isEmpty(translate)) {
|
|
@@ -32,6 +50,10 @@ function getI18nYearMonthLabel(label, translate) {
|
|
|
32
50
|
}
|
|
33
51
|
return newLabel;
|
|
34
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @param index
|
|
56
|
+
*/
|
|
35
57
|
function getI18nMonthPropertyByIndex(index) {
|
|
36
58
|
const months = [
|
|
37
59
|
"january",
|
|
@@ -49,11 +71,21 @@ function getI18nMonthPropertyByIndex(index) {
|
|
|
49
71
|
];
|
|
50
72
|
return months[index];
|
|
51
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
*
|
|
76
|
+
* @param label
|
|
77
|
+
* @param translate
|
|
78
|
+
*/
|
|
52
79
|
function getI18nQuarterLabel(label, translate) {
|
|
53
80
|
const splittedLabel = label.split(" ");
|
|
54
81
|
splittedLabel[0] = getI18nYearQuarterLabel(splittedLabel[0], translate);
|
|
55
82
|
return splittedLabel.join(" ");
|
|
56
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
*
|
|
86
|
+
* @param label
|
|
87
|
+
* @param translate
|
|
88
|
+
*/
|
|
57
89
|
function getI18nYearQuarterLabel(label, translate) {
|
|
58
90
|
let newLabel = label;
|
|
59
91
|
if (!isTokenLabel(newLabel) && !isEmpty(translate)) {
|
|
@@ -61,11 +93,21 @@ function getI18nYearQuarterLabel(label, translate) {
|
|
|
61
93
|
}
|
|
62
94
|
return newLabel;
|
|
63
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
*
|
|
98
|
+
* @param label
|
|
99
|
+
* @param translate
|
|
100
|
+
*/
|
|
64
101
|
function getI18nWeekLabel(label, translate) {
|
|
65
102
|
const splittedLabel = label.split(" ");
|
|
66
103
|
splittedLabel[0] = getI18nYearWeekLabel(splittedLabel[0], translate);
|
|
67
104
|
return splittedLabel.join(" ");
|
|
68
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
*
|
|
108
|
+
* @param label
|
|
109
|
+
* @param translate
|
|
110
|
+
*/
|
|
69
111
|
function getI18nYearWeekLabel(label, translate) {
|
|
70
112
|
let newLabel = label;
|
|
71
113
|
if (!isTokenLabel(newLabel) && !isEmpty(translate)) {
|
|
@@ -73,3 +115,81 @@ function getI18nYearWeekLabel(label, translate) {
|
|
|
73
115
|
}
|
|
74
116
|
return newLabel;
|
|
75
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
*
|
|
120
|
+
* @param label
|
|
121
|
+
* @param translate
|
|
122
|
+
*/
|
|
123
|
+
function getI18nDayCustomLabel(label, translate) {
|
|
124
|
+
const dayMapper = {
|
|
125
|
+
Monday: "monday",
|
|
126
|
+
Tuesday: "tuesday",
|
|
127
|
+
Wednesday: "wednesday",
|
|
128
|
+
Thursday: "thursday",
|
|
129
|
+
Friday: "friday",
|
|
130
|
+
Saturday: "saturday",
|
|
131
|
+
Sunday: "sunday",
|
|
132
|
+
};
|
|
133
|
+
const dayAbbMapper = {
|
|
134
|
+
Mon: "monday",
|
|
135
|
+
Tue: "tuesday",
|
|
136
|
+
Wed: "wednesday",
|
|
137
|
+
Thu: "thursday",
|
|
138
|
+
Fri: "friday",
|
|
139
|
+
Sat: "saturday",
|
|
140
|
+
Sun: "sunday",
|
|
141
|
+
};
|
|
142
|
+
const monthMapper = {
|
|
143
|
+
January: "january",
|
|
144
|
+
February: "february",
|
|
145
|
+
March: "march",
|
|
146
|
+
April: "april",
|
|
147
|
+
May: "may",
|
|
148
|
+
June: "june",
|
|
149
|
+
July: "july",
|
|
150
|
+
August: "august",
|
|
151
|
+
September: "september",
|
|
152
|
+
October: "october",
|
|
153
|
+
November: "november",
|
|
154
|
+
December: "december",
|
|
155
|
+
};
|
|
156
|
+
const monthAbbMapper = {
|
|
157
|
+
Jan: "january",
|
|
158
|
+
Feb: "february",
|
|
159
|
+
Mar: "march",
|
|
160
|
+
Apr: "april",
|
|
161
|
+
May: "may",
|
|
162
|
+
Jun: "june",
|
|
163
|
+
Jul: "july",
|
|
164
|
+
Aug: "august",
|
|
165
|
+
Sep: "september",
|
|
166
|
+
Oct: "october",
|
|
167
|
+
Nov: "november",
|
|
168
|
+
Dec: "december",
|
|
169
|
+
};
|
|
170
|
+
let newLabel = label;
|
|
171
|
+
if (!isTokenLabel(newLabel) && !isEmpty(translate)) {
|
|
172
|
+
const regex = new RegExp([
|
|
173
|
+
...Object.keys(dayMapper),
|
|
174
|
+
...Object.keys(dayAbbMapper),
|
|
175
|
+
...Object.keys(monthMapper),
|
|
176
|
+
...Object.keys(monthAbbMapper),
|
|
177
|
+
].join("|"), "g");
|
|
178
|
+
newLabel = newLabel.replace(regex, (match) => {
|
|
179
|
+
if (dayMapper[match]) {
|
|
180
|
+
return translate(`common.day_names.${dayMapper[match]}_dddd`);
|
|
181
|
+
}
|
|
182
|
+
else if (dayAbbMapper[match]) {
|
|
183
|
+
return translate(`common.day_names.${dayAbbMapper[match]}_ddd`);
|
|
184
|
+
}
|
|
185
|
+
else if (monthMapper[match]) {
|
|
186
|
+
return translate(`common.date_grouping.${monthMapper[match]}_mmmm`);
|
|
187
|
+
}
|
|
188
|
+
else if (monthAbbMapper[match]) {
|
|
189
|
+
return translate(`common.date_grouping.${monthAbbMapper[match]}_mmm`);
|
|
190
|
+
}
|
|
191
|
+
return match;
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
return newLabel;
|
|
195
|
+
}
|