@syncfusion/ej2-base 24.2.8 → 25.1.35-579988
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/.eslintrc.json +2 -1
- package/CHANGELOG.md +641 -677
- package/{README.md → ReadMe.md} +100 -100
- package/dist/ej2-base.umd.min.js +1 -10
- package/dist/ej2-base.umd.min.js.map +1 -1
- package/dist/es6/ej2-base.es2015.js +178 -1025
- package/dist/es6/ej2-base.es2015.js.map +1 -1
- package/dist/es6/ej2-base.es5.js +226 -934
- package/dist/es6/ej2-base.es5.js.map +1 -1
- package/dist/global/ej2-base.min.js +1 -10
- package/dist/global/ej2-base.min.js.map +1 -1
- package/dist/global/index.d.ts +0 -9
- package/dist/ts/ajax.ts +236 -0
- package/dist/ts/animation.ts +544 -0
- package/dist/ts/base.ts +357 -0
- package/dist/ts/browser.ts +387 -0
- package/dist/ts/child-property.ts +192 -0
- package/dist/ts/component.ts +519 -0
- package/dist/ts/dom.ts +488 -0
- package/dist/ts/draggable.ts +1155 -0
- package/dist/ts/droppable.ts +172 -0
- package/dist/ts/event-handler.ts +169 -0
- package/dist/ts/internationalization.ts +369 -0
- package/dist/ts/intl/date-formatter.ts +317 -0
- package/dist/ts/intl/date-parser.ts +426 -0
- package/dist/ts/intl/intl-base.ts +1104 -0
- package/dist/ts/intl/number-formatter.ts +411 -0
- package/dist/ts/intl/number-parser.ts +158 -0
- package/dist/ts/intl/parser-base.ts +394 -0
- package/dist/ts/keyboard.ts +238 -0
- package/dist/ts/l10n.ts +94 -0
- package/dist/ts/module-loader.ts +149 -0
- package/dist/ts/notify-property-change.ts +726 -0
- package/dist/ts/observer.ts +236 -0
- package/dist/ts/sanitize-helper.ts +224 -0
- package/dist/ts/template-engine.ts +191 -0
- package/dist/ts/template.ts +329 -0
- package/dist/ts/touch.ts +544 -0
- package/dist/ts/util.ts +523 -0
- package/dist/ts/validate-lic.ts +0 -0
- package/e2e/crypto.js +16 -16
- package/e2e/m.protractor.config.js +286 -286
- package/e2e/modified-protractor/protractor.config.js +316 -316
- package/e2e/protractor.config.js +389 -332
- package/helpers/e2e/index.js +3 -3
- package/license +10 -10
- package/package.json +225 -174
- package/src/ajax.d.ts +1 -1
- package/src/ajax.js +3 -8
- package/src/animation-model.d.ts +41 -41
- package/src/animation.d.ts +6 -6
- package/src/animation.js +25 -25
- package/src/base.d.ts +2 -1
- package/src/base.js +9 -7
- package/src/component-model.d.ts +16 -16
- package/src/component.d.ts +9 -3
- package/src/component.js +50 -38
- package/src/draggable-model.d.ts +113 -113
- package/src/draggable.d.ts +2 -0
- package/src/draggable.js +45 -29
- package/src/droppable-model.d.ts +23 -23
- package/src/droppable.js +19 -19
- package/src/event-handler.js +2 -1
- package/src/index.d.ts +0 -3
- package/src/index.js +0 -3
- package/src/intl/date-formatter.js +2 -6
- package/src/intl/date-parser.js +1 -20
- package/src/intl/intl-base.js +1 -164
- package/src/intl/number-formatter.d.ts +3 -0
- package/src/intl/number-formatter.js +7 -7
- package/src/intl/number-parser.js +1 -0
- package/src/keyboard-model.d.ts +16 -16
- package/src/keyboard.js +19 -19
- package/src/module-loader.d.ts +12 -0
- package/src/module-loader.js +11 -0
- package/src/notify-property-change.js +3 -2
- package/src/observer.js +2 -0
- package/src/sanitize-helper.js +5 -0
- package/src/template-engine.js +1 -0
- package/src/template.js +3 -2
- package/src/touch-model.d.ts +39 -39
- package/src/touch.js +19 -19
- package/src/validate-lic.d.ts +0 -11
- package/src/validate-lic.js +1 -259
- package/styles/_all.scss +2 -2
- package/styles/_bds-dark-definition.scss +15 -0
- package/styles/_bds-definition.scss +15 -0
- package/styles/_bootstrap-dark-definition.scss +42 -42
- package/styles/_bootstrap-definition.scss +42 -42
- package/styles/_bootstrap4-definition.scss +11 -11
- package/styles/_bootstrap5-dark-definition.scss +9 -9
- package/styles/_bootstrap5-definition.scss +8 -8
- package/styles/_fabric-dark-definition.scss +42 -42
- package/styles/_fabric-definition.scss +42 -42
- package/styles/_fluent-dark-definition.scss +9 -9
- package/styles/_fluent-definition.scss +9 -9
- package/styles/_fluent2-definition.scss +9 -0
- package/styles/_fusionnew-dark-definition.scss +8 -8
- package/styles/_fusionnew-definition.scss +8 -8
- package/styles/_highcontrast-definition.scss +42 -42
- package/styles/_highcontrast-light-definition.scss +42 -42
- package/styles/_material-dark-definition.scss +48 -48
- package/styles/_material-definition.scss +49 -49
- package/styles/_material3-dark-definition.scss +14 -14
- package/styles/_material3-definition.scss +15 -15
- package/styles/_tailwind-dark-definition.scss +15 -15
- package/styles/_tailwind-definition.scss +15 -15
- package/styles/animation/_all.scss +560 -560
- package/styles/bootstrap-dark.css +10 -1
- package/styles/bootstrap.css +10 -1
- package/styles/bootstrap4.css +10 -1
- package/styles/bootstrap5-dark.css +10 -1
- package/styles/bootstrap5.css +10 -1
- package/styles/common/_all.scss +2 -2
- package/styles/common/_core.scss +117 -117
- package/styles/common/_mixin.scss +9 -9
- package/styles/definition/_bds-dark.scss +1179 -0
- package/styles/definition/_bds.scss +1474 -0
- package/styles/definition/_bootstrap-dark.scss +219 -219
- package/styles/definition/_bootstrap.scss +215 -215
- package/styles/definition/_bootstrap4.scss +167 -167
- package/styles/definition/_bootstrap5-dark.scss +493 -493
- package/styles/definition/_bootstrap5.scss +494 -494
- package/styles/definition/_fabric-dark.scss +200 -200
- package/styles/definition/_fabric.scss +198 -198
- package/styles/definition/_fluent-dark.scss +557 -557
- package/styles/definition/_fluent.scss +558 -558
- package/styles/definition/_fluent2.scss +2198 -0
- package/styles/definition/_fusionnew-dark.scss +362 -362
- package/styles/definition/_fusionnew.scss +363 -363
- package/styles/definition/_highcontrast-light.scss +193 -193
- package/styles/definition/_highcontrast.scss +195 -195
- package/styles/definition/_material-dark.scss +198 -198
- package/styles/definition/_material.scss +192 -192
- package/styles/definition/_material3-dark.scss +710 -710
- package/styles/definition/_material3.scss +792 -792
- package/styles/definition/_tailwind-dark.scss +488 -488
- package/styles/definition/_tailwind.scss +485 -485
- package/styles/fabric-dark.css +10 -1
- package/styles/fabric.css +10 -1
- package/styles/fluent-dark.css +10 -1
- package/styles/fluent.css +10 -1
- package/styles/highcontrast-light.css +10 -1
- package/styles/highcontrast.css +10 -1
- package/styles/material-dark.css +10 -1
- package/styles/material.css +10 -1
- package/styles/material3-dark.css +10 -1
- package/styles/material3.css +10 -1
- package/styles/offline-theme/material-dark.css +10 -1
- package/styles/offline-theme/material.css +10 -1
- package/styles/offline-theme/tailwind-dark.css +10 -1
- package/styles/offline-theme/tailwind.css +10 -1
- package/styles/tailwind-dark.css +10 -1
- package/styles/tailwind.css +10 -1
- package/.github/PULL_REQUEST_TEMPLATE/Bug.md +0 -60
- package/.github/PULL_REQUEST_TEMPLATE/feature.md +0 -42
- package/bin/syncfusion-license.js +0 -2
- package/dist/ej2-base.min.js +0 -10
- package/e2e/index.d.ts +0 -27
- package/src/fetch.d.ts +0 -114
- package/src/fetch.js +0 -116
- package/src/hijri-parser.d.ts +0 -19
- package/src/hijri-parser.js +0 -204
|
@@ -0,0 +1,1104 @@
|
|
|
1
|
+
import { NumberFormatOptions, DateFormatOptions, defaultCurrencyCode } from '../internationalization';
|
|
2
|
+
import { NumericParts } from './number-parser';
|
|
3
|
+
import { getValue, isNullOrUndefined, extend, isBlazor } from '../util';
|
|
4
|
+
import { ParserBase as parser, getBlazorCurrencySymbol } from './parser-base';
|
|
5
|
+
import { DateFormat, FormatOptions } from './date-formatter';
|
|
6
|
+
import { NumberFormat, FormatParts, CommonOptions } from './number-formatter';
|
|
7
|
+
import { isUndefined } from '../util';
|
|
8
|
+
|
|
9
|
+
const regExp: RegExpConstructor = RegExp;
|
|
10
|
+
|
|
11
|
+
export const blazorCultureFormats: Object = {
|
|
12
|
+
'en-US': {
|
|
13
|
+
'd': 'M/d/y',
|
|
14
|
+
'D': 'EEEE, MMMM d, y',
|
|
15
|
+
'f': 'EEEE, MMMM d, y h:mm a',
|
|
16
|
+
'F': 'EEEE, MMMM d, y h:mm:s a',
|
|
17
|
+
'g': 'M/d/y h:mm a',
|
|
18
|
+
'G': 'M/d/yyyy h:mm:ss tt',
|
|
19
|
+
'm': 'MMMM d',
|
|
20
|
+
'M': 'MMMM d',
|
|
21
|
+
'r': 'ddd, dd MMM yyyy HH\':\'mm\':\'ss \'GMT\'',
|
|
22
|
+
'R': 'ddd, dd MMM yyyy HH\':\'mm\':\'ss \'GMT\'',
|
|
23
|
+
's': 'yyyy\'-\'MM\'-\'dd\'T\'HH\':\'mm\':\'ss',
|
|
24
|
+
't': 'h:mm tt',
|
|
25
|
+
'T': 'h:m:s tt',
|
|
26
|
+
'u': 'yyyy\'-\'MM\'-\'dd HH\':\'mm\':\'ss\'Z\'',
|
|
27
|
+
'U': 'dddd, MMMM d, yyyy h:mm:ss tt',
|
|
28
|
+
'y': 'MMMM yyyy',
|
|
29
|
+
'Y': 'MMMM yyyy'
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Date base common constants and function for date parser and formatter.
|
|
34
|
+
*/
|
|
35
|
+
// eslint-disable-next-line
|
|
36
|
+
export namespace IntlBase {
|
|
37
|
+
/* eslint-disable */
|
|
38
|
+
// tslint:disable-next-line:max-line-length.
|
|
39
|
+
export const negativeDataRegex: RegExp = /^(('[^']+'|''|[^*#@0,.E])*)(\*.)?((([#,]*[0,]*0+)(\.0*[0-9]*#*)?)|([#,]*@+#*))(E\+?0+)?(('[^']+'|''|[^*#@0,.E])*)$/;
|
|
40
|
+
export const customRegex: RegExp = /^(('[^']+'|''|[^*#@0,.])*)(\*.)?((([0#,]*[0,]*[0#]*[0#\ ]*)(\.[0#]*)?)|([#,]*@+#*))(E\+?0+)?(('[^']+'|''|[^*#@0,.E])*)$/;
|
|
41
|
+
export const latnParseRegex: RegExp = /0|1|2|3|4|5|6|7|8|9/g;
|
|
42
|
+
const fractionRegex: RegExp = /[0-9]/g;
|
|
43
|
+
export const defaultCurrency: string = '$';
|
|
44
|
+
const mapper: string[] = ['infinity', 'nan', 'group', 'decimal'];
|
|
45
|
+
const patternRegex: RegExp = /G|M|L|H|c|'| a|yy|y|EEEE|E/g;
|
|
46
|
+
const patternMatch: Object = {
|
|
47
|
+
'G': '',
|
|
48
|
+
'M': 'm',
|
|
49
|
+
'L': 'm',
|
|
50
|
+
'H': 'h',
|
|
51
|
+
'c': 'd',
|
|
52
|
+
'\'': '"',
|
|
53
|
+
' a': ' AM/PM',
|
|
54
|
+
'yy': 'yy',
|
|
55
|
+
'y': 'yyyy',
|
|
56
|
+
'EEEE': 'dddd',
|
|
57
|
+
'E': 'ddd'
|
|
58
|
+
};
|
|
59
|
+
export const dateConverterMapper: RegExp = /dddd|ddd/ig;
|
|
60
|
+
const defaultFirstDay: string = 'sun';
|
|
61
|
+
export const islamicRegex: RegExp = /^islamic/;
|
|
62
|
+
const firstDayMapper: Object = {
|
|
63
|
+
'sun': 0,
|
|
64
|
+
'mon': 1,
|
|
65
|
+
'tue': 2,
|
|
66
|
+
'wed': 3,
|
|
67
|
+
'thu': 4,
|
|
68
|
+
'fri': 5,
|
|
69
|
+
'sat': 6
|
|
70
|
+
};
|
|
71
|
+
export interface NumericSkeleton {
|
|
72
|
+
type?: string;
|
|
73
|
+
isAccount?: boolean;
|
|
74
|
+
fractionDigits?: number;
|
|
75
|
+
}
|
|
76
|
+
export interface GenericFormatOptions {
|
|
77
|
+
nData?: NegativeData;
|
|
78
|
+
pData?: NegativeData;
|
|
79
|
+
zeroData?: NegativeData;
|
|
80
|
+
}
|
|
81
|
+
export interface GroupSize {
|
|
82
|
+
primary?: number;
|
|
83
|
+
secondary?: number;
|
|
84
|
+
}
|
|
85
|
+
export interface NegativeData extends FormatParts {
|
|
86
|
+
nlead?: string;
|
|
87
|
+
nend?: string;
|
|
88
|
+
groupPattern?: string;
|
|
89
|
+
minimumFraction?: number;
|
|
90
|
+
maximumFraction?: number;
|
|
91
|
+
}
|
|
92
|
+
export const formatRegex: RegExp = new regExp("(^[ncpae]{1})([0-1]?[0-9]|20)?$", "i");
|
|
93
|
+
export const currencyFormatRegex: RegExp = new regExp("(^[ca]{1})([0-1]?[0-9]|20)?$", "i");
|
|
94
|
+
export const curWithoutNumberRegex: RegExp = /(c|a)$/ig;
|
|
95
|
+
const typeMapper: Object = {
|
|
96
|
+
'$': 'isCurrency',
|
|
97
|
+
'%': 'isPercent',
|
|
98
|
+
'-': 'isNegative',
|
|
99
|
+
0: 'nlead',
|
|
100
|
+
1: 'nend'
|
|
101
|
+
};
|
|
102
|
+
export const dateParseRegex: RegExp = /([a-z])\1*|'([^']|'')+'|''|./gi;
|
|
103
|
+
export const basicPatterns: string[] = ['short', 'medium', 'long', 'full'];
|
|
104
|
+
export interface Dependables {
|
|
105
|
+
parserObject?: Object;
|
|
106
|
+
dateObject?: Object;
|
|
107
|
+
numericObject?: Object;
|
|
108
|
+
}
|
|
109
|
+
export interface TimeZoneOptions {
|
|
110
|
+
hourFormat?: string;
|
|
111
|
+
gmtFormat?: string;
|
|
112
|
+
gmtZeroFormat?: string;
|
|
113
|
+
}
|
|
114
|
+
/* tslint:disable:quotemark */
|
|
115
|
+
export const defaultObject: Object = {
|
|
116
|
+
'dates': {
|
|
117
|
+
'calendars': {
|
|
118
|
+
'gregorian': {
|
|
119
|
+
'months': {
|
|
120
|
+
'stand-alone': {
|
|
121
|
+
'abbreviated': {
|
|
122
|
+
'1': 'Jan',
|
|
123
|
+
'2': 'Feb',
|
|
124
|
+
'3': 'Mar',
|
|
125
|
+
'4': 'Apr',
|
|
126
|
+
'5': 'May',
|
|
127
|
+
'6': 'Jun',
|
|
128
|
+
'7': 'Jul',
|
|
129
|
+
'8': 'Aug',
|
|
130
|
+
'9': 'Sep',
|
|
131
|
+
'10': 'Oct',
|
|
132
|
+
'11': 'Nov',
|
|
133
|
+
'12': 'Dec'
|
|
134
|
+
},
|
|
135
|
+
'narrow': {
|
|
136
|
+
'1': 'J',
|
|
137
|
+
'2': 'F',
|
|
138
|
+
'3': 'M',
|
|
139
|
+
'4': 'A',
|
|
140
|
+
'5': 'M',
|
|
141
|
+
'6': 'J',
|
|
142
|
+
'7': 'J',
|
|
143
|
+
'8': 'A',
|
|
144
|
+
'9': 'S',
|
|
145
|
+
'10': 'O',
|
|
146
|
+
'11': 'N',
|
|
147
|
+
'12': 'D'
|
|
148
|
+
},
|
|
149
|
+
'wide': {
|
|
150
|
+
'1': 'January',
|
|
151
|
+
'2': 'February',
|
|
152
|
+
'3': 'March',
|
|
153
|
+
'4': 'April',
|
|
154
|
+
'5': 'May',
|
|
155
|
+
'6': 'June',
|
|
156
|
+
'7': 'July',
|
|
157
|
+
'8': 'August',
|
|
158
|
+
'9': 'September',
|
|
159
|
+
'10': 'October',
|
|
160
|
+
'11': 'November',
|
|
161
|
+
'12': 'December'
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
'days': {
|
|
166
|
+
'stand-alone': {
|
|
167
|
+
'abbreviated': {
|
|
168
|
+
'sun': 'Sun',
|
|
169
|
+
'mon': 'Mon',
|
|
170
|
+
'tue': 'Tue',
|
|
171
|
+
'wed': 'Wed',
|
|
172
|
+
'thu': 'Thu',
|
|
173
|
+
'fri': 'Fri',
|
|
174
|
+
'sat': 'Sat'
|
|
175
|
+
},
|
|
176
|
+
'narrow': {
|
|
177
|
+
'sun': 'S',
|
|
178
|
+
'mon': 'M',
|
|
179
|
+
'tue': 'T',
|
|
180
|
+
'wed': 'W',
|
|
181
|
+
'thu': 'T',
|
|
182
|
+
'fri': 'F',
|
|
183
|
+
'sat': 'S'
|
|
184
|
+
},
|
|
185
|
+
'short': {
|
|
186
|
+
'sun': 'Su',
|
|
187
|
+
'mon': 'Mo',
|
|
188
|
+
'tue': 'Tu',
|
|
189
|
+
'wed': 'We',
|
|
190
|
+
'thu': 'Th',
|
|
191
|
+
'fri': 'Fr',
|
|
192
|
+
'sat': 'Sa'
|
|
193
|
+
},
|
|
194
|
+
'wide': {
|
|
195
|
+
'sun': 'Sunday',
|
|
196
|
+
'mon': 'Monday',
|
|
197
|
+
'tue': 'Tuesday',
|
|
198
|
+
'wed': 'Wednesday',
|
|
199
|
+
'thu': 'Thursday',
|
|
200
|
+
'fri': 'Friday',
|
|
201
|
+
'sat': 'Saturday'
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
'dayPeriods': {
|
|
206
|
+
'format': {
|
|
207
|
+
'wide': {
|
|
208
|
+
'am': 'AM',
|
|
209
|
+
'pm': 'PM'
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
'eras': {
|
|
214
|
+
'eraNames': {
|
|
215
|
+
'0': 'Before Christ',
|
|
216
|
+
'0-alt-variant': 'Before Common Era',
|
|
217
|
+
'1': 'Anno Domini',
|
|
218
|
+
'1-alt-variant': 'Common Era'
|
|
219
|
+
},
|
|
220
|
+
'eraAbbr': {
|
|
221
|
+
'0': 'BC',
|
|
222
|
+
'0-alt-variant': 'BCE',
|
|
223
|
+
'1': 'AD',
|
|
224
|
+
'1-alt-variant': 'CE'
|
|
225
|
+
},
|
|
226
|
+
'eraNarrow': {
|
|
227
|
+
'0': 'B',
|
|
228
|
+
'0-alt-variant': 'BCE',
|
|
229
|
+
'1': 'A',
|
|
230
|
+
'1-alt-variant': 'CE'
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
'dateFormats': {
|
|
234
|
+
'full': 'EEEE, MMMM d, y',
|
|
235
|
+
'long': 'MMMM d, y',
|
|
236
|
+
'medium': 'MMM d, y',
|
|
237
|
+
'short': 'M/d/yy'
|
|
238
|
+
},
|
|
239
|
+
'timeFormats': {
|
|
240
|
+
'full': 'h:mm:ss a zzzz',
|
|
241
|
+
'long': 'h:mm:ss a z',
|
|
242
|
+
'medium': 'h:mm:ss a',
|
|
243
|
+
'short': 'h:mm a'
|
|
244
|
+
},
|
|
245
|
+
'dateTimeFormats': {
|
|
246
|
+
'full': '{1} \'at\' {0}',
|
|
247
|
+
'long': '{1} \'at\' {0}',
|
|
248
|
+
'medium': '{1}, {0}',
|
|
249
|
+
'short': '{1}, {0}',
|
|
250
|
+
'availableFormats': {
|
|
251
|
+
'd': 'd',
|
|
252
|
+
'E': 'ccc',
|
|
253
|
+
'Ed': 'd E',
|
|
254
|
+
'Ehm': 'E h:mm a',
|
|
255
|
+
'EHm': 'E HH:mm',
|
|
256
|
+
'Ehms': 'E h:mm:ss a',
|
|
257
|
+
'EHms': 'E HH:mm:ss',
|
|
258
|
+
'Gy': 'y G',
|
|
259
|
+
'GyMMM': 'MMM y G',
|
|
260
|
+
'GyMMMd': 'MMM d, y G',
|
|
261
|
+
'GyMMMEd': 'E, MMM d, y G',
|
|
262
|
+
'h': 'h a',
|
|
263
|
+
'H': 'HH',
|
|
264
|
+
'hm': 'h:mm a',
|
|
265
|
+
'Hm': 'HH:mm',
|
|
266
|
+
'hms': 'h:mm:ss a',
|
|
267
|
+
'Hms': 'HH:mm:ss',
|
|
268
|
+
'hmsv': 'h:mm:ss a v',
|
|
269
|
+
'Hmsv': 'HH:mm:ss v',
|
|
270
|
+
'hmv': 'h:mm a v',
|
|
271
|
+
'Hmv': 'HH:mm v',
|
|
272
|
+
'M': 'L',
|
|
273
|
+
'Md': 'M/d',
|
|
274
|
+
'MEd': 'E, M/d',
|
|
275
|
+
'MMM': 'LLL',
|
|
276
|
+
'MMMd': 'MMM d',
|
|
277
|
+
'MMMEd': 'E, MMM d',
|
|
278
|
+
'MMMMd': 'MMMM d',
|
|
279
|
+
'ms': 'mm:ss',
|
|
280
|
+
'y': 'y',
|
|
281
|
+
'yM': 'M/y',
|
|
282
|
+
'yMd': 'M/d/y',
|
|
283
|
+
'yMEd': 'E, M/d/y',
|
|
284
|
+
'yMMM': 'MMM y',
|
|
285
|
+
'yMMMd': 'MMM d, y',
|
|
286
|
+
'yMMMEd': 'E, MMM d, y',
|
|
287
|
+
'yMMMM': 'MMMM y'
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
'islamic': {
|
|
292
|
+
'months': {
|
|
293
|
+
'stand-alone': {
|
|
294
|
+
'abbreviated': {
|
|
295
|
+
'1': 'Muh.',
|
|
296
|
+
'2': 'Saf.',
|
|
297
|
+
'3': 'Rab. I',
|
|
298
|
+
'4': 'Rab. II',
|
|
299
|
+
'5': 'Jum. I',
|
|
300
|
+
'6': 'Jum. II',
|
|
301
|
+
'7': 'Raj.',
|
|
302
|
+
'8': 'Sha.',
|
|
303
|
+
'9': 'Ram.',
|
|
304
|
+
'10': 'Shaw.',
|
|
305
|
+
'11': 'Dhuʻl-Q.',
|
|
306
|
+
'12': 'Dhuʻl-H.'
|
|
307
|
+
},
|
|
308
|
+
'narrow': {
|
|
309
|
+
'1': '1',
|
|
310
|
+
'2': '2',
|
|
311
|
+
'3': '3',
|
|
312
|
+
'4': '4',
|
|
313
|
+
'5': '5',
|
|
314
|
+
'6': '6',
|
|
315
|
+
'7': '7',
|
|
316
|
+
'8': '8',
|
|
317
|
+
'9': '9',
|
|
318
|
+
'10': '10',
|
|
319
|
+
'11': '11',
|
|
320
|
+
'12': '12'
|
|
321
|
+
},
|
|
322
|
+
'wide': {
|
|
323
|
+
'1': 'Muharram',
|
|
324
|
+
'2': 'Safar',
|
|
325
|
+
'3': 'Rabiʻ I',
|
|
326
|
+
'4': 'Rabiʻ II',
|
|
327
|
+
'5': 'Jumada I',
|
|
328
|
+
'6': 'Jumada II',
|
|
329
|
+
'7': 'Rajab',
|
|
330
|
+
'8': 'Shaʻban',
|
|
331
|
+
'9': 'Ramadan',
|
|
332
|
+
'10': 'Shawwal',
|
|
333
|
+
'11': 'Dhuʻl-Qiʻdah',
|
|
334
|
+
'12': 'Dhuʻl-Hijjah'
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
'days': {
|
|
339
|
+
'stand-alone': {
|
|
340
|
+
'abbreviated': {
|
|
341
|
+
'sun': 'Sun',
|
|
342
|
+
'mon': 'Mon',
|
|
343
|
+
'tue': 'Tue',
|
|
344
|
+
'wed': 'Wed',
|
|
345
|
+
'thu': 'Thu',
|
|
346
|
+
'fri': 'Fri',
|
|
347
|
+
'sat': 'Sat'
|
|
348
|
+
},
|
|
349
|
+
'narrow': {
|
|
350
|
+
'sun': 'S',
|
|
351
|
+
'mon': 'M',
|
|
352
|
+
'tue': 'T',
|
|
353
|
+
'wed': 'W',
|
|
354
|
+
'thu': 'T',
|
|
355
|
+
'fri': 'F',
|
|
356
|
+
'sat': 'S'
|
|
357
|
+
},
|
|
358
|
+
'short': {
|
|
359
|
+
'sun': 'Su',
|
|
360
|
+
'mon': 'Mo',
|
|
361
|
+
'tue': 'Tu',
|
|
362
|
+
'wed': 'We',
|
|
363
|
+
'thu': 'Th',
|
|
364
|
+
'fri': 'Fr',
|
|
365
|
+
'sat': 'Sa'
|
|
366
|
+
},
|
|
367
|
+
'wide': {
|
|
368
|
+
'sun': 'Sunday',
|
|
369
|
+
'mon': 'Monday',
|
|
370
|
+
'tue': 'Tuesday',
|
|
371
|
+
'wed': 'Wednesday',
|
|
372
|
+
'thu': 'Thursday',
|
|
373
|
+
'fri': 'Friday',
|
|
374
|
+
'sat': 'Saturday'
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
'dayPeriods': {
|
|
379
|
+
'format': {
|
|
380
|
+
'wide': {
|
|
381
|
+
'am': 'AM',
|
|
382
|
+
'pm': 'PM'
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
},
|
|
386
|
+
'eras': {
|
|
387
|
+
'eraNames': {
|
|
388
|
+
'0': 'AH'
|
|
389
|
+
},
|
|
390
|
+
'eraAbbr': {
|
|
391
|
+
'0': 'AH'
|
|
392
|
+
},
|
|
393
|
+
'eraNarrow': {
|
|
394
|
+
'0': 'AH'
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
'dateFormats': {
|
|
398
|
+
'full': 'EEEE, MMMM d, y G',
|
|
399
|
+
'long': 'MMMM d, y G',
|
|
400
|
+
'medium': 'MMM d, y G',
|
|
401
|
+
'short': 'M/d/y GGGGG'
|
|
402
|
+
},
|
|
403
|
+
'timeFormats': {
|
|
404
|
+
'full': 'h:mm:ss a zzzz',
|
|
405
|
+
'long': 'h:mm:ss a z',
|
|
406
|
+
'medium': 'h:mm:ss a',
|
|
407
|
+
'short': 'h:mm a'
|
|
408
|
+
},
|
|
409
|
+
'dateTimeFormats': {
|
|
410
|
+
'full': '{1} \'at\' {0}',
|
|
411
|
+
'long': '{1} \'at\' {0}',
|
|
412
|
+
'medium': '{1}, {0}',
|
|
413
|
+
'short': '{1}, {0}',
|
|
414
|
+
'availableFormats': {
|
|
415
|
+
'd': 'd',
|
|
416
|
+
'E': 'ccc',
|
|
417
|
+
'Ed': 'd E',
|
|
418
|
+
'Ehm': 'E h:mm a',
|
|
419
|
+
'EHm': 'E HH:mm',
|
|
420
|
+
'Ehms': 'E h:mm:ss a',
|
|
421
|
+
'EHms': 'E HH:mm:ss',
|
|
422
|
+
'Gy': 'y G',
|
|
423
|
+
'GyMMM': 'MMM y G',
|
|
424
|
+
'GyMMMd': 'MMM d, y G',
|
|
425
|
+
'GyMMMEd': 'E, MMM d, y G',
|
|
426
|
+
'h': 'h a',
|
|
427
|
+
'H': 'HH',
|
|
428
|
+
'hm': 'h:mm a',
|
|
429
|
+
'Hm': 'HH:mm',
|
|
430
|
+
'hms': 'h:mm:ss a',
|
|
431
|
+
'Hms': 'HH:mm:ss',
|
|
432
|
+
'M': 'L',
|
|
433
|
+
'Md': 'M/d',
|
|
434
|
+
'MEd': 'E, M/d',
|
|
435
|
+
'MMM': 'LLL',
|
|
436
|
+
'MMMd': 'MMM d',
|
|
437
|
+
'MMMEd': 'E, MMM d',
|
|
438
|
+
'MMMMd': 'MMMM d',
|
|
439
|
+
'ms': 'mm:ss',
|
|
440
|
+
'y': 'y G',
|
|
441
|
+
'yyyy': 'y G',
|
|
442
|
+
'yyyyM': 'M/y GGGGG',
|
|
443
|
+
'yyyyMd': 'M/d/y GGGGG',
|
|
444
|
+
'yyyyMEd': 'E, M/d/y GGGGG',
|
|
445
|
+
'yyyyMMM': 'MMM y G',
|
|
446
|
+
'yyyyMMMd': 'MMM d, y G',
|
|
447
|
+
'yyyyMMMEd': 'E, MMM d, y G',
|
|
448
|
+
'yyyyMMMM': 'MMMM y G',
|
|
449
|
+
'yyyyQQQ': 'QQQ y G',
|
|
450
|
+
'yyyyQQQQ': 'QQQQ y G'
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
'timeZoneNames': {
|
|
456
|
+
'hourFormat': '+HH:mm;-HH:mm',
|
|
457
|
+
'gmtFormat': 'GMT{0}',
|
|
458
|
+
'gmtZeroFormat': 'GMT'
|
|
459
|
+
}
|
|
460
|
+
},
|
|
461
|
+
'numbers': {
|
|
462
|
+
'currencies': {
|
|
463
|
+
'USD': {
|
|
464
|
+
'displayName': 'US Dollar',
|
|
465
|
+
'symbol': '$',
|
|
466
|
+
'symbol-alt-narrow': '$'
|
|
467
|
+
},
|
|
468
|
+
'EUR': {
|
|
469
|
+
'displayName': 'Euro',
|
|
470
|
+
'symbol': '€',
|
|
471
|
+
'symbol-alt-narrow': '€'
|
|
472
|
+
},
|
|
473
|
+
'GBP': {
|
|
474
|
+
'displayName': 'British Pound',
|
|
475
|
+
'symbol-alt-narrow': '£'
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
'defaultNumberingSystem': 'latn',
|
|
479
|
+
'minimumGroupingDigits': '1',
|
|
480
|
+
'symbols-numberSystem-latn': {
|
|
481
|
+
'decimal': '.',
|
|
482
|
+
'group': ',',
|
|
483
|
+
'list': ';',
|
|
484
|
+
'percentSign': '%',
|
|
485
|
+
'plusSign': '+',
|
|
486
|
+
'minusSign': '-',
|
|
487
|
+
'exponential': 'E',
|
|
488
|
+
'superscriptingExponent': '×',
|
|
489
|
+
'perMille': '‰',
|
|
490
|
+
'infinity': '∞',
|
|
491
|
+
'nan': 'NaN',
|
|
492
|
+
'timeSeparator': ':'
|
|
493
|
+
},
|
|
494
|
+
'decimalFormats-numberSystem-latn': {
|
|
495
|
+
'standard': '#,##0.###'
|
|
496
|
+
},
|
|
497
|
+
'percentFormats-numberSystem-latn': {
|
|
498
|
+
'standard': '#,##0%'
|
|
499
|
+
},
|
|
500
|
+
'currencyFormats-numberSystem-latn': {
|
|
501
|
+
'standard': '¤#,##0.00',
|
|
502
|
+
'accounting': '¤#,##0.00;(¤#,##0.00)'
|
|
503
|
+
},
|
|
504
|
+
'scientificFormats-numberSystem-latn': {
|
|
505
|
+
'standard': '#E0'
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
export const blazorDefaultObject: Object = {};
|
|
510
|
+
/* tslint:enable:quotemark */
|
|
511
|
+
export const monthIndex: Object = {
|
|
512
|
+
3: 'abbreviated',
|
|
513
|
+
4: 'wide',
|
|
514
|
+
5: 'narrow',
|
|
515
|
+
1: 'abbreviated'
|
|
516
|
+
};
|
|
517
|
+
/**
|
|
518
|
+
*
|
|
519
|
+
*/
|
|
520
|
+
|
|
521
|
+
export const month: string = 'months';
|
|
522
|
+
export const days: string = 'days';
|
|
523
|
+
/**
|
|
524
|
+
* Default numerber Object
|
|
525
|
+
*/
|
|
526
|
+
|
|
527
|
+
export const patternMatcher: { [key: string]: Object } = {
|
|
528
|
+
C: 'currency',
|
|
529
|
+
P: 'percent',
|
|
530
|
+
N: 'decimal',
|
|
531
|
+
A: 'currency',
|
|
532
|
+
E: 'scientific'
|
|
533
|
+
};
|
|
534
|
+
/**
|
|
535
|
+
* Returns the resultant pattern based on the skeleton, dateObject and the type provided
|
|
536
|
+
*
|
|
537
|
+
* @private
|
|
538
|
+
* @param {string} skeleton ?
|
|
539
|
+
* @param {Object} dateObject ?
|
|
540
|
+
* @param {string} type ?
|
|
541
|
+
* @param {boolean} isIslamic ?
|
|
542
|
+
* @param {string} blazorCulture ?
|
|
543
|
+
* @returns {string} ?
|
|
544
|
+
*/
|
|
545
|
+
export function getResultantPattern(
|
|
546
|
+
skeleton: string, dateObject: Object, type: string, isIslamic?: boolean,
|
|
547
|
+
blazorCulture?: string): string {
|
|
548
|
+
let resPattern: string;
|
|
549
|
+
const iType: string = type || 'date';
|
|
550
|
+
if (blazorCulture) {
|
|
551
|
+
resPattern = compareBlazorDateFormats({ skeleton: skeleton }, blazorCulture).format ||
|
|
552
|
+
compareBlazorDateFormats({ skeleton: 'd' }, 'en-US').format;
|
|
553
|
+
} else {
|
|
554
|
+
if (basicPatterns.indexOf(skeleton) !== -1) {
|
|
555
|
+
resPattern = getValue(iType + 'Formats.' + skeleton, dateObject);
|
|
556
|
+
if (iType === 'dateTime') {
|
|
557
|
+
const dPattern: string = getValue('dateFormats.' + skeleton, dateObject);
|
|
558
|
+
const tPattern: string = getValue('timeFormats.' + skeleton, dateObject);
|
|
559
|
+
resPattern = resPattern.replace('{1}', dPattern).replace('{0}', tPattern);
|
|
560
|
+
}
|
|
561
|
+
} else {
|
|
562
|
+
resPattern = getValue('dateTimeFormats.availableFormats.' + skeleton, dateObject);
|
|
563
|
+
}
|
|
564
|
+
if (isUndefined(resPattern) && skeleton === 'yMd') {
|
|
565
|
+
resPattern = 'M/d/y';
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
return resPattern;
|
|
569
|
+
}
|
|
570
|
+
export interface DateObject {
|
|
571
|
+
year?: number;
|
|
572
|
+
month?: number;
|
|
573
|
+
date?: number;
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Returns the dependable object for provided cldr data and culture
|
|
577
|
+
*
|
|
578
|
+
* @private
|
|
579
|
+
* @param {Object} cldr ?
|
|
580
|
+
* @param {string} culture ?
|
|
581
|
+
* @param {string} mode ?
|
|
582
|
+
* @param {boolean} isNumber ?
|
|
583
|
+
* @returns {any} ?
|
|
584
|
+
*/
|
|
585
|
+
export function getDependables(cldr: Object, culture: string, mode: string, isNumber?: boolean): Dependables {
|
|
586
|
+
const ret: Dependables = {};
|
|
587
|
+
const calendartype: string = mode || 'gregorian';
|
|
588
|
+
ret.parserObject = parser.getMainObject(cldr, culture) || (isBlazor() ? blazorDefaultObject : defaultObject);
|
|
589
|
+
if (isNumber) {
|
|
590
|
+
ret.numericObject = getValue('numbers', ret.parserObject);
|
|
591
|
+
} else {
|
|
592
|
+
const dateString: string = isBlazor() ? 'dates' : ('dates.calendars.' + calendartype);
|
|
593
|
+
ret.dateObject = getValue(dateString, ret.parserObject);
|
|
594
|
+
}
|
|
595
|
+
return ret;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Returns the symbol pattern for provided parameters
|
|
599
|
+
*
|
|
600
|
+
* @private
|
|
601
|
+
* @param {string} type ?
|
|
602
|
+
* @param {string} numSystem ?
|
|
603
|
+
* @param {Object} obj ?
|
|
604
|
+
* @param {boolean} isAccount ?
|
|
605
|
+
* @returns {string} ?
|
|
606
|
+
*/
|
|
607
|
+
export function getSymbolPattern(type: string, numSystem: string, obj: Object, isAccount: boolean): string {
|
|
608
|
+
return getValue(
|
|
609
|
+
type + 'Formats-numberSystem-' +
|
|
610
|
+
numSystem + (isAccount ? '.accounting' : '.standard'),
|
|
611
|
+
obj) || (isAccount ? getValue(
|
|
612
|
+
type + 'Formats-numberSystem-' +
|
|
613
|
+
numSystem + '.standard',
|
|
614
|
+
obj) : '');
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
*
|
|
619
|
+
* @param {string} format ?
|
|
620
|
+
* @returns {string} ?
|
|
621
|
+
*/
|
|
622
|
+
export function ConvertDateToWeekFormat(format: string): string {
|
|
623
|
+
const convertMapper: string[] = format.match(dateConverterMapper);
|
|
624
|
+
if (convertMapper && isBlazor()) {
|
|
625
|
+
const tempString: string = convertMapper[0].length === 3 ? 'EEE' : 'EEEE';
|
|
626
|
+
return format.replace(dateConverterMapper, tempString);
|
|
627
|
+
}
|
|
628
|
+
return format;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
*
|
|
633
|
+
* @param {DateFormatOptions} formatOptions ?
|
|
634
|
+
* @param {string} culture ?
|
|
635
|
+
* @returns {DateFormatOptions} ?
|
|
636
|
+
*/
|
|
637
|
+
export function compareBlazorDateFormats(formatOptions: DateFormatOptions, culture?: string): DateFormatOptions {
|
|
638
|
+
const format: string = formatOptions.format || formatOptions.skeleton;
|
|
639
|
+
let curFormatMapper: string = getValue((culture || 'en-US') + '.' + format, blazorCultureFormats);
|
|
640
|
+
if (!curFormatMapper) {
|
|
641
|
+
curFormatMapper = getValue('en-US.' + format, blazorCultureFormats);
|
|
642
|
+
}
|
|
643
|
+
if (curFormatMapper) {
|
|
644
|
+
curFormatMapper = ConvertDateToWeekFormat(curFormatMapper);
|
|
645
|
+
formatOptions.format = curFormatMapper.replace(/tt/, 'a');
|
|
646
|
+
}
|
|
647
|
+
return formatOptions;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Returns proper numeric skeleton
|
|
652
|
+
*
|
|
653
|
+
* @private
|
|
654
|
+
* @param {string} skeleton ?
|
|
655
|
+
* @returns {any} ?
|
|
656
|
+
*/
|
|
657
|
+
export function getProperNumericSkeleton(skeleton: string): NumericSkeleton {
|
|
658
|
+
const matches: RegExpMatchArray = skeleton.match(formatRegex);
|
|
659
|
+
const ret: NumericSkeleton = {};
|
|
660
|
+
const pattern: string = matches[1].toUpperCase();
|
|
661
|
+
ret.isAccount = (pattern === 'A');
|
|
662
|
+
(<any>ret).type = patternMatcher[pattern];
|
|
663
|
+
if (skeleton.length > 1) {
|
|
664
|
+
ret.fractionDigits = parseInt(matches[2], 10);
|
|
665
|
+
}
|
|
666
|
+
return ret;
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Returns format data for number formatting like minimum fraction, maximum fraction, etc..,
|
|
670
|
+
*
|
|
671
|
+
* @private
|
|
672
|
+
* @param {string} pattern ?
|
|
673
|
+
* @param {boolean} needFraction ?
|
|
674
|
+
* @param {string} cSymbol ?
|
|
675
|
+
* @param {boolean} fractionOnly ?
|
|
676
|
+
* @returns {any} ?
|
|
677
|
+
*/
|
|
678
|
+
export function getFormatData(pattern: string, needFraction: boolean, cSymbol: string, fractionOnly?: boolean): NegativeData {
|
|
679
|
+
const nData: NegativeData = fractionOnly ? {} : { nlead: '', nend: '' };
|
|
680
|
+
const match: string[] = pattern.match(customRegex);
|
|
681
|
+
if (match) {
|
|
682
|
+
if (!fractionOnly) {
|
|
683
|
+
nData.nlead = changeCurrencySymbol(match[1], cSymbol);
|
|
684
|
+
nData.nend = changeCurrencySymbol(match[10], cSymbol);
|
|
685
|
+
nData.groupPattern = match[4];
|
|
686
|
+
}
|
|
687
|
+
const fraction: string = match[7];
|
|
688
|
+
if (fraction && needFraction) {
|
|
689
|
+
const fmatch: string[] = fraction.match(fractionRegex);
|
|
690
|
+
if (!isNullOrUndefined(fmatch)) {
|
|
691
|
+
nData.minimumFraction = fmatch.length;
|
|
692
|
+
} else {
|
|
693
|
+
nData.minimumFraction = 0;
|
|
694
|
+
}
|
|
695
|
+
nData.maximumFraction = fraction.length - 1;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
}
|
|
699
|
+
return nData;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Changes currency symbol
|
|
703
|
+
*
|
|
704
|
+
* @private
|
|
705
|
+
* @param {string} val ?
|
|
706
|
+
* @param {string} sym ?
|
|
707
|
+
* @returns {string} ?
|
|
708
|
+
*/
|
|
709
|
+
export function changeCurrencySymbol(val: string, sym: string): string {
|
|
710
|
+
if (val) {
|
|
711
|
+
val = val.replace(IntlBase.defaultCurrency, sym);
|
|
712
|
+
return (sym === '')? val.trim() : val;
|
|
713
|
+
}
|
|
714
|
+
return '';
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Returns currency symbol based on currency code ?
|
|
718
|
+
*
|
|
719
|
+
* @private
|
|
720
|
+
* @param {Object} numericObject ?
|
|
721
|
+
* @param {string} currencyCode ?
|
|
722
|
+
* @param {string} altSymbol ?
|
|
723
|
+
* @returns {string} ?
|
|
724
|
+
*/
|
|
725
|
+
export function getCurrencySymbol(numericObject: Object, currencyCode: string, altSymbol?: string): string {
|
|
726
|
+
const symbol: string = altSymbol ? ('.' + altSymbol) : '.symbol';
|
|
727
|
+
const getCurrency: string = getValue('currencies.' + currencyCode + symbol, numericObject) ||
|
|
728
|
+
getValue('currencies.' + currencyCode + '.symbol-alt-narrow', numericObject) || '$';
|
|
729
|
+
return getCurrency;
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Returns formatting options for custom number format
|
|
733
|
+
*
|
|
734
|
+
* @private
|
|
735
|
+
* @param {string} format ?
|
|
736
|
+
* @param {CommonOptions} dOptions ?
|
|
737
|
+
* @param {any} obj ?
|
|
738
|
+
* @returns {any} ?
|
|
739
|
+
*/
|
|
740
|
+
export function customFormat(format: string, dOptions: CommonOptions, obj: Dependables): GenericFormatOptions {
|
|
741
|
+
const options: GenericFormatOptions = {};
|
|
742
|
+
const formatSplit: string[] = format.split(';');
|
|
743
|
+
const data: string[] = ['pData', 'nData', 'zeroData'];
|
|
744
|
+
for (let i: number = 0; i < formatSplit.length; i++) {
|
|
745
|
+
(<any>options)[data[i]] = customNumberFormat(formatSplit[i], dOptions, obj);
|
|
746
|
+
}
|
|
747
|
+
if (isNullOrUndefined(options.nData)) {
|
|
748
|
+
options.nData = extend({}, options.pData);
|
|
749
|
+
options.nData.nlead = isNullOrUndefined(dOptions) ? '-' + options.nData.nlead : dOptions.minusSymbol + options.nData.nlead;
|
|
750
|
+
}
|
|
751
|
+
return options;
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Returns custom formatting options
|
|
755
|
+
*
|
|
756
|
+
* @private
|
|
757
|
+
* @param {string} format ?
|
|
758
|
+
* @param {CommonOptions} dOptions ?
|
|
759
|
+
* @param {Object} numObject ?
|
|
760
|
+
* @returns {any} ?
|
|
761
|
+
*/
|
|
762
|
+
export function customNumberFormat(format: string, dOptions?: CommonOptions, numObject?: Object): NegativeData {
|
|
763
|
+
const cOptions: NegativeData = { type: 'decimal', minimumFractionDigits: 0, maximumFractionDigits: 0 };
|
|
764
|
+
const pattern: string[] = format.match(customRegex);
|
|
765
|
+
if (isNullOrUndefined(pattern) || (pattern[5] === '' && format !== 'N/A')) {
|
|
766
|
+
cOptions.type = undefined;
|
|
767
|
+
return cOptions;
|
|
768
|
+
}
|
|
769
|
+
cOptions.nlead = pattern[1];
|
|
770
|
+
cOptions.nend = pattern[10];
|
|
771
|
+
let integerPart: string = pattern[6];
|
|
772
|
+
const spaceCapture: boolean = integerPart.match(/\ $/g) ? true : false;
|
|
773
|
+
const spaceGrouping: boolean = integerPart.replace(/\ $/g, '').indexOf(' ') !== -1;
|
|
774
|
+
cOptions.useGrouping = integerPart.indexOf(',') !== -1 || spaceGrouping;
|
|
775
|
+
integerPart = integerPart.replace(/,/g, '');
|
|
776
|
+
const fractionPart: string = pattern[7];
|
|
777
|
+
if (integerPart.indexOf('0') !== -1) {
|
|
778
|
+
cOptions.minimumIntegerDigits = integerPart.length - integerPart.indexOf('0');
|
|
779
|
+
}
|
|
780
|
+
if (!isNullOrUndefined(fractionPart)) {
|
|
781
|
+
cOptions.minimumFractionDigits = fractionPart.lastIndexOf('0');
|
|
782
|
+
cOptions.maximumFractionDigits = fractionPart.lastIndexOf('#');
|
|
783
|
+
if (cOptions.minimumFractionDigits === -1) {
|
|
784
|
+
cOptions.minimumFractionDigits = 0;
|
|
785
|
+
}
|
|
786
|
+
if (cOptions.maximumFractionDigits === -1 || cOptions.maximumFractionDigits < cOptions.minimumFractionDigits) {
|
|
787
|
+
cOptions.maximumFractionDigits = cOptions.minimumFractionDigits;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
if (!isNullOrUndefined(dOptions)) {
|
|
791
|
+
dOptions.isCustomFormat = true;
|
|
792
|
+
extend(cOptions, isCurrencyPercent([cOptions.nlead, cOptions.nend], '$', dOptions.currencySymbol));
|
|
793
|
+
if (!cOptions.isCurrency) {
|
|
794
|
+
extend(cOptions, isCurrencyPercent(
|
|
795
|
+
[cOptions.nlead, cOptions.nend], '%', dOptions.percentSymbol));
|
|
796
|
+
}
|
|
797
|
+
} else {
|
|
798
|
+
extend(cOptions, isCurrencyPercent([cOptions.nlead, cOptions.nend], '%', '%'));
|
|
799
|
+
}
|
|
800
|
+
if (!isNullOrUndefined(numObject)) {
|
|
801
|
+
const symbolPattern: string = getSymbolPattern(
|
|
802
|
+
cOptions.type, dOptions.numberMapper.numberSystem, numObject, false);
|
|
803
|
+
if (cOptions.useGrouping) {
|
|
804
|
+
cOptions.groupSeparator = spaceGrouping? ' ' : (<any>dOptions).numberMapper.numberSymbols[mapper[2]];
|
|
805
|
+
cOptions.groupData = NumberFormat.getGroupingDetails(symbolPattern.split(';')[0]);
|
|
806
|
+
}
|
|
807
|
+
cOptions.nlead = cOptions.nlead.replace(/'/g, '');
|
|
808
|
+
cOptions.nend = spaceCapture ? ' ' + cOptions.nend.replace(/'/g, '') : cOptions.nend.replace(/'/g, '');
|
|
809
|
+
}
|
|
810
|
+
return cOptions;
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* Returns formatting options for currency or percent type
|
|
814
|
+
*
|
|
815
|
+
* @private
|
|
816
|
+
* @param {string[]} parts ?
|
|
817
|
+
* @param {string} actual ?
|
|
818
|
+
* @param {string} symbol ?
|
|
819
|
+
* @returns {any} ?
|
|
820
|
+
*/
|
|
821
|
+
export function isCurrencyPercent(parts: string[], actual: string, symbol: string): NegativeData {
|
|
822
|
+
const options: NegativeData = { nlead: parts[0], nend: parts[1] };
|
|
823
|
+
for (let i: number = 0; i < 2; i++) {
|
|
824
|
+
const part: string = parts[parseInt(i.toString(), 10)];
|
|
825
|
+
const loc: number = part.indexOf(actual);
|
|
826
|
+
if ((loc !== -1) && ((loc < part.indexOf('\'')) || (loc > part.lastIndexOf('\'')))) {
|
|
827
|
+
(<any>options)[(<any>typeMapper)[i]] = part.substr(0, loc) + symbol + part.substr(loc + 1);
|
|
828
|
+
(<any>options)[(<any>typeMapper)[actual]] = true;
|
|
829
|
+
options.type = options.isCurrency ? 'currency' : 'percent';
|
|
830
|
+
break;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
return options;
|
|
834
|
+
}
|
|
835
|
+
/**
|
|
836
|
+
* Returns culture based date separator
|
|
837
|
+
*
|
|
838
|
+
* @private
|
|
839
|
+
* @param {Object} dateObj ?
|
|
840
|
+
* @returns {string} ?
|
|
841
|
+
*/
|
|
842
|
+
export function getDateSeparator(dateObj: Object): string {
|
|
843
|
+
const value: string[] = (getValue('dateFormats.short', dateObj) || '').match(/[dM]([^dM])[dM]/i);
|
|
844
|
+
return value ? value[1] : '/';
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* Returns Native Date Time pattern
|
|
849
|
+
*
|
|
850
|
+
* @private
|
|
851
|
+
* @param {string} culture ?
|
|
852
|
+
* @param {DateFormatOptions} options ?
|
|
853
|
+
* @param {Object} cldr ?
|
|
854
|
+
* @param {boolean} isExcelFormat ?
|
|
855
|
+
* @returns {string} ?
|
|
856
|
+
*/
|
|
857
|
+
export function getActualDateTimeFormat(culture: string, options: DateFormatOptions, cldr?: Object, isExcelFormat?: boolean): string {
|
|
858
|
+
const dependable: Dependables = getDependables(cldr, culture, options.calendar);
|
|
859
|
+
if (isBlazor()) {
|
|
860
|
+
options = compareBlazorDateFormats(options, culture);
|
|
861
|
+
}
|
|
862
|
+
let actualPattern: string = options.format || getResultantPattern(options.skeleton, dependable.dateObject, options.type);
|
|
863
|
+
if (isExcelFormat) {
|
|
864
|
+
actualPattern = actualPattern.replace(patternRegex, (pattern: string): string => {
|
|
865
|
+
return (<any>patternMatch)[pattern];
|
|
866
|
+
});
|
|
867
|
+
if (actualPattern.indexOf('z') !== -1) {
|
|
868
|
+
const tLength: number = actualPattern.match(/z/g).length;
|
|
869
|
+
let timeZonePattern: string;
|
|
870
|
+
const options: FormatOptions = { 'timeZone': {} };
|
|
871
|
+
options.numMapper = parser.getNumberMapper(dependable.parserObject, parser.getNumberingSystem(cldr));
|
|
872
|
+
options.timeZone = getValue('dates.timeZoneNames', dependable.parserObject);
|
|
873
|
+
const value: Date = new Date();
|
|
874
|
+
const timezone: number = value.getTimezoneOffset();
|
|
875
|
+
let pattern: string = (tLength < 4) ? '+H;-H' : options.timeZone.hourFormat;
|
|
876
|
+
pattern = pattern.replace(/:/g, options.numMapper.timeSeparator);
|
|
877
|
+
if (timezone === 0) {
|
|
878
|
+
timeZonePattern = options.timeZone.gmtZeroFormat;
|
|
879
|
+
} else {
|
|
880
|
+
timeZonePattern = DateFormat.getTimeZoneValue(timezone, pattern);
|
|
881
|
+
timeZonePattern = options.timeZone.gmtFormat.replace(/\{0\}/, timeZonePattern);
|
|
882
|
+
}
|
|
883
|
+
actualPattern = actualPattern.replace(/[z]+/, '"' + timeZonePattern + '"');
|
|
884
|
+
}
|
|
885
|
+
actualPattern = actualPattern.replace(/ $/, '');
|
|
886
|
+
}
|
|
887
|
+
return actualPattern;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
*
|
|
892
|
+
* @param {string} actual ?
|
|
893
|
+
* @param {any} option ?
|
|
894
|
+
* @returns {any} ?
|
|
895
|
+
*/
|
|
896
|
+
function processSymbol(actual: string, option: any): any {
|
|
897
|
+
if (actual.indexOf(',') !== -1) {
|
|
898
|
+
let split: any = actual.split(',');
|
|
899
|
+
actual = (split[0] + getValue('numberMapper.numberSymbols.group', option) +
|
|
900
|
+
split[1].replace('.', getValue('numberMapper.numberSymbols.decimal', option)));
|
|
901
|
+
} else {
|
|
902
|
+
actual = actual.replace('.', getValue('numberMapper.numberSymbols.decimal', option));
|
|
903
|
+
}
|
|
904
|
+
return actual;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
/**
|
|
908
|
+
* Returns Native Number pattern
|
|
909
|
+
*
|
|
910
|
+
* @private
|
|
911
|
+
* @param {string} culture ?
|
|
912
|
+
* @param {NumberFormatOptions} options ?
|
|
913
|
+
* @param {Object} cldr ?
|
|
914
|
+
* @param {boolean} isExcel ?
|
|
915
|
+
* @returns {string} ?
|
|
916
|
+
*/
|
|
917
|
+
export function getActualNumberFormat(culture: string, options: NumberFormatOptions, cldr?: Object, isExcel?: boolean): string {
|
|
918
|
+
const dependable: Dependables = getDependables(cldr, culture, '', true);
|
|
919
|
+
const parseOptions: NumericParts = { custom: true };
|
|
920
|
+
const numrericObject: Object = dependable.numericObject;
|
|
921
|
+
let minFrac: number;
|
|
922
|
+
const curObj: GenericFormatOptions & { hasNegativePattern?: boolean } = {};
|
|
923
|
+
const curMatch: string[] = (options.format || '').match(currencyFormatRegex);
|
|
924
|
+
const type: NumericSkeleton = formatRegex.test(options.format) ? getProperNumericSkeleton(options.format || 'N') : {};
|
|
925
|
+
const dOptions: CommonOptions = {};
|
|
926
|
+
if (curMatch) {
|
|
927
|
+
dOptions.numberMapper = isBlazor() ?
|
|
928
|
+
extend({}, dependable.numericObject) :
|
|
929
|
+
parser.getNumberMapper(dependable.parserObject, parser.getNumberingSystem(cldr), true);
|
|
930
|
+
const curCode: string = isBlazor() ? getValue('currencySymbol', dependable.numericObject) :
|
|
931
|
+
getCurrencySymbol(dependable.numericObject, options.currency || defaultCurrencyCode, options.altSymbol);
|
|
932
|
+
let symbolPattern: string = getSymbolPattern(
|
|
933
|
+
'currency', dOptions.numberMapper.numberSystem, dependable.numericObject, (/a/i).test(options.format));
|
|
934
|
+
symbolPattern = symbolPattern.replace(/\u00A4/g, curCode);
|
|
935
|
+
const split: string[] = symbolPattern.split(';');
|
|
936
|
+
curObj.hasNegativePattern = isBlazor() ? true : (split.length > 1);
|
|
937
|
+
curObj.nData = isBlazor() ? getValue(type.type + 'nData', numrericObject) :
|
|
938
|
+
getFormatData(split[1] || '-' + split[0], true, curCode);
|
|
939
|
+
curObj.pData = isBlazor() ? getValue(type.type + 'pData', numrericObject) :
|
|
940
|
+
getFormatData(split[0], false, curCode);
|
|
941
|
+
if (!curMatch[2] && !options.minimumFractionDigits && !options.maximumFractionDigits) {
|
|
942
|
+
minFrac = getFormatData(symbolPattern.split(';')[0], true, '', true).minimumFraction;
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
let actualPattern: string;
|
|
946
|
+
if ((formatRegex.test(options.format)) || !(options.format)) {
|
|
947
|
+
extend(parseOptions, getProperNumericSkeleton(options.format || 'N'));
|
|
948
|
+
parseOptions.custom = false;
|
|
949
|
+
actualPattern = '###0';
|
|
950
|
+
if (parseOptions.fractionDigits || options.minimumFractionDigits || options.maximumFractionDigits || minFrac) {
|
|
951
|
+
const defaultMinimum: number = 0;
|
|
952
|
+
if (parseOptions.fractionDigits) {
|
|
953
|
+
options.minimumFractionDigits = options.maximumFractionDigits = parseOptions.fractionDigits;
|
|
954
|
+
}
|
|
955
|
+
actualPattern = fractionDigitsPattern(
|
|
956
|
+
actualPattern, minFrac || parseOptions.fractionDigits ||
|
|
957
|
+
options.minimumFractionDigits || defaultMinimum,
|
|
958
|
+
options.maximumFractionDigits || defaultMinimum);
|
|
959
|
+
}
|
|
960
|
+
if (options.minimumIntegerDigits) {
|
|
961
|
+
actualPattern = minimumIntegerPattern(actualPattern, options.minimumIntegerDigits);
|
|
962
|
+
}
|
|
963
|
+
if (options.useGrouping) {
|
|
964
|
+
actualPattern = groupingPattern(actualPattern);
|
|
965
|
+
}
|
|
966
|
+
if (parseOptions.type === 'currency' || (parseOptions.type && isBlazor())) {
|
|
967
|
+
if (isBlazor() && parseOptions.type !== 'currency') {
|
|
968
|
+
curObj.pData = getValue(parseOptions.type + 'pData', numrericObject);
|
|
969
|
+
curObj.nData = getValue(parseOptions.type + 'nData', numrericObject);
|
|
970
|
+
}
|
|
971
|
+
const cPattern: string = actualPattern;
|
|
972
|
+
actualPattern = curObj.pData.nlead + cPattern + curObj.pData.nend;
|
|
973
|
+
if (curObj.hasNegativePattern || isBlazor()) {
|
|
974
|
+
actualPattern += ';' + curObj.nData.nlead + cPattern + curObj.nData.nend;
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
if (parseOptions.type === 'percent' && !isBlazor()) {
|
|
978
|
+
actualPattern += ' %';
|
|
979
|
+
}
|
|
980
|
+
} else {
|
|
981
|
+
actualPattern = options.format.replace(/'/g, '"');
|
|
982
|
+
}
|
|
983
|
+
if (Object.keys(dOptions).length > 0) {
|
|
984
|
+
actualPattern = !isExcel ? processSymbol(actualPattern, dOptions) : actualPattern;
|
|
985
|
+
}
|
|
986
|
+
return actualPattern;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
*
|
|
991
|
+
* @param {string} pattern ?
|
|
992
|
+
* @param {number} minDigits ?
|
|
993
|
+
* @param {number} maxDigits ?
|
|
994
|
+
* @returns {string} ?
|
|
995
|
+
*/
|
|
996
|
+
export function fractionDigitsPattern(pattern: string, minDigits: number, maxDigits?: number): string {
|
|
997
|
+
pattern += '.';
|
|
998
|
+
for (let a: number = 0; a < minDigits; a++) {
|
|
999
|
+
pattern += '0';
|
|
1000
|
+
}
|
|
1001
|
+
if (minDigits < maxDigits) {
|
|
1002
|
+
const diff: number = maxDigits - minDigits;
|
|
1003
|
+
for (let b: number = 0; b < diff; b++) {
|
|
1004
|
+
pattern += '#';
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
return pattern;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
/**
|
|
1011
|
+
*
|
|
1012
|
+
* @param {string} pattern ?
|
|
1013
|
+
* @param {number} digits ?
|
|
1014
|
+
* @returns {string} ?
|
|
1015
|
+
*/
|
|
1016
|
+
export function minimumIntegerPattern(pattern: string, digits: number): string {
|
|
1017
|
+
const temp: string[] = pattern.split('.');
|
|
1018
|
+
let integer: string = '';
|
|
1019
|
+
for (let x: number = 0; x < digits; x++) {
|
|
1020
|
+
integer += '0';
|
|
1021
|
+
}
|
|
1022
|
+
return temp[1] ? (integer + '.' + temp[1]) : integer;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
/**
|
|
1026
|
+
*
|
|
1027
|
+
* @param {string} pattern ?
|
|
1028
|
+
* @returns {string} ?
|
|
1029
|
+
*/
|
|
1030
|
+
export function groupingPattern(pattern: string): string {
|
|
1031
|
+
const temp: string[] = pattern.split('.');
|
|
1032
|
+
let integer: string = temp[0];
|
|
1033
|
+
const no: number = 3 - integer.length % 3;
|
|
1034
|
+
const hash: string = (no && no === 1) ? '#' : (no === 2 ? '##' : '');
|
|
1035
|
+
integer = hash + integer;
|
|
1036
|
+
pattern = '';
|
|
1037
|
+
for (let x: number = integer.length - 1; x > 0; x = x - 3) {
|
|
1038
|
+
pattern = ',' + integer[x - 2] + integer[x - 1] + integer[parseInt(x.toString(), 10)] + pattern;
|
|
1039
|
+
}
|
|
1040
|
+
pattern = pattern.slice(1);
|
|
1041
|
+
return temp[1] ? (pattern + '.' + temp[1]) : pattern;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
/**
|
|
1045
|
+
*
|
|
1046
|
+
* @param {string} culture ?
|
|
1047
|
+
* @param {Object} cldr ?
|
|
1048
|
+
* @returns {number} ?
|
|
1049
|
+
*/
|
|
1050
|
+
export function getWeekData(culture: string, cldr?: Object): number {
|
|
1051
|
+
let firstDay: string = defaultFirstDay;
|
|
1052
|
+
const mapper: Object = getValue('supplemental.weekData.firstDay', cldr);
|
|
1053
|
+
let iCulture: string = culture;
|
|
1054
|
+
if ((/en-/).test(iCulture)) {
|
|
1055
|
+
iCulture = iCulture.slice(3);
|
|
1056
|
+
}
|
|
1057
|
+
iCulture = iCulture.slice(0, 2).toUpperCase() + iCulture.substr(2);
|
|
1058
|
+
if (mapper) {
|
|
1059
|
+
firstDay = mapper[`${iCulture}`] || mapper[iCulture.slice(0, 2)] || defaultFirstDay;
|
|
1060
|
+
}
|
|
1061
|
+
return firstDayMapper[`${firstDay}`];
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* @private
|
|
1065
|
+
* @param {any} pData ?
|
|
1066
|
+
* @param {string} aCurrency ?
|
|
1067
|
+
* @param {string} rCurrency ?
|
|
1068
|
+
* @returns {void} ?
|
|
1069
|
+
*/
|
|
1070
|
+
export function replaceBlazorCurrency(pData: NegativeData[], aCurrency: string, rCurrency: string): void {
|
|
1071
|
+
const iCurrency: string = getBlazorCurrencySymbol(rCurrency);
|
|
1072
|
+
if (aCurrency !== iCurrency) {
|
|
1073
|
+
for (const data of pData) {
|
|
1074
|
+
data.nend = data.nend.replace(aCurrency, iCurrency);
|
|
1075
|
+
data.nlead = data.nlead.replace(aCurrency, iCurrency);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
/**
|
|
1080
|
+
* @private
|
|
1081
|
+
* @param {Date} date ?
|
|
1082
|
+
* @returns {number} ?
|
|
1083
|
+
*/
|
|
1084
|
+
export function getWeekOfYear(date: Date): number {
|
|
1085
|
+
const newYear: Date = new Date(date.getFullYear(), 0, 1);
|
|
1086
|
+
let day: number = newYear.getDay();
|
|
1087
|
+
let weeknum: number;
|
|
1088
|
+
day = (day >= 0 ? day : day + 7);
|
|
1089
|
+
const daynum: number = Math.floor((date.getTime() - newYear.getTime() -
|
|
1090
|
+
(date.getTimezoneOffset() - newYear.getTimezoneOffset()) * 60000) / 86400000) + 1;
|
|
1091
|
+
if (day < 4) {
|
|
1092
|
+
weeknum = Math.floor((daynum + day - 1) / 7) + 1;
|
|
1093
|
+
if (weeknum > 52) {
|
|
1094
|
+
const nYear: Date = new Date(date.getFullYear() + 1, 0, 1);
|
|
1095
|
+
let nday: number = nYear.getDay();
|
|
1096
|
+
nday = nday >= 0 ? nday : nday + 7;
|
|
1097
|
+
weeknum = nday < 4 ? 1 : 53;
|
|
1098
|
+
}
|
|
1099
|
+
} else {
|
|
1100
|
+
weeknum = Math.floor((daynum + day - 1) / 7);
|
|
1101
|
+
}
|
|
1102
|
+
return weeknum;
|
|
1103
|
+
}
|
|
1104
|
+
}
|