@syncfusion/ej2-base 24.2.7 → 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,394 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parser
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const defaultNumberingSystem: Object = {
|
|
6
|
+
'latn': {
|
|
7
|
+
'_digits': '0123456789',
|
|
8
|
+
'_type': 'numeric'
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
import { isUndefined, getValue, isBlazor } from '../util';
|
|
13
|
+
const defaultNumberSymbols: Object = {
|
|
14
|
+
'decimal': '.',
|
|
15
|
+
'group': ',',
|
|
16
|
+
'percentSign': '%',
|
|
17
|
+
'plusSign': '+',
|
|
18
|
+
'minusSign': '-',
|
|
19
|
+
'infinity': '∞',
|
|
20
|
+
'nan': 'NaN',
|
|
21
|
+
'exponential': 'E'
|
|
22
|
+
};
|
|
23
|
+
const latnNumberSystem: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
|
24
|
+
/**
|
|
25
|
+
* Interface for numeric Options
|
|
26
|
+
*/
|
|
27
|
+
export interface NumericOptions {
|
|
28
|
+
numericPair?: Object;
|
|
29
|
+
numericRegex?: string;
|
|
30
|
+
numberParseRegex?: RegExp;
|
|
31
|
+
symbolNumberSystem?: Object;
|
|
32
|
+
symbolMatch?: Object;
|
|
33
|
+
numberSystem?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Interface for numeric object
|
|
37
|
+
*/
|
|
38
|
+
export interface NumericObject {
|
|
39
|
+
obj?: Object;
|
|
40
|
+
nSystem?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Interface for number mapper
|
|
44
|
+
*/
|
|
45
|
+
export interface NumberMapper {
|
|
46
|
+
mapper?: Object;
|
|
47
|
+
timeSeparator?: string;
|
|
48
|
+
numberSymbols?: Object;
|
|
49
|
+
numberSystem?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Interface for parser base
|
|
53
|
+
*
|
|
54
|
+
* @private
|
|
55
|
+
*/
|
|
56
|
+
export class ParserBase {
|
|
57
|
+
public static nPair: string = 'numericPair';
|
|
58
|
+
public static nRegex: string = 'numericRegex';
|
|
59
|
+
public static numberingSystems: Object = defaultNumberingSystem;
|
|
60
|
+
/**
|
|
61
|
+
* Returns the cldr object for the culture specifies
|
|
62
|
+
*
|
|
63
|
+
* @param {Object} obj - Specifies the object from which culture object to be acquired.
|
|
64
|
+
* @param {string} cName - Specifies the culture name.
|
|
65
|
+
* @returns {Object} ?
|
|
66
|
+
*/
|
|
67
|
+
public static getMainObject(obj: Object, cName: string): Object {
|
|
68
|
+
const value: string = isBlazor() ? cName : 'main.' + cName;
|
|
69
|
+
return getValue(value, obj);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Returns the numbering system object from given cldr data.
|
|
73
|
+
*
|
|
74
|
+
* @param {Object} obj - Specifies the object from which number system is acquired.
|
|
75
|
+
* @returns {Object} ?
|
|
76
|
+
*/
|
|
77
|
+
public static getNumberingSystem(obj: Object): Object {
|
|
78
|
+
return getValue('supplemental.numberingSystems', obj) || this.numberingSystems;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Returns the reverse of given object keys or keys specified.
|
|
82
|
+
*
|
|
83
|
+
* @param {Object} prop - Specifies the object to be reversed.
|
|
84
|
+
* @param {number[]} keys - Optional parameter specifies the custom keyList for reversal.
|
|
85
|
+
* @returns {Object} ?
|
|
86
|
+
*/
|
|
87
|
+
public static reverseObject(prop: Object, keys?: number[]): Object {
|
|
88
|
+
const propKeys: string[] | number[] = keys || Object.keys(prop);
|
|
89
|
+
const res: Object = {};
|
|
90
|
+
for (const key of propKeys) {
|
|
91
|
+
// eslint-disable-next-line
|
|
92
|
+
if (!res.hasOwnProperty((<any>prop)[key])) {
|
|
93
|
+
// eslint-disable-next-line
|
|
94
|
+
(<any>res)[(<any>prop)[key]] = key;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return res;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Returns the symbol regex by skipping the escape sequence.
|
|
101
|
+
*
|
|
102
|
+
* @param {string[]} props - Specifies the array values to be skipped.
|
|
103
|
+
* @returns {RegExp} ?
|
|
104
|
+
*/
|
|
105
|
+
public static getSymbolRegex(props: string[]): RegExp {
|
|
106
|
+
const regexStr: string = props.map((str: string): string => {
|
|
107
|
+
return str.replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1');
|
|
108
|
+
}).join('|');
|
|
109
|
+
const regExp: RegExpConstructor = RegExp;
|
|
110
|
+
return new regExp(regexStr, 'g');
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
*
|
|
114
|
+
* @param {Object} prop ?
|
|
115
|
+
* @returns {Object} ?
|
|
116
|
+
*/
|
|
117
|
+
private static getSymbolMatch(prop: Object): Object {
|
|
118
|
+
const matchKeys: string[] = Object.keys(defaultNumberSymbols);
|
|
119
|
+
const ret: Object = {};
|
|
120
|
+
for (const key of matchKeys) {
|
|
121
|
+
// eslint-disable-next-line
|
|
122
|
+
(<any>ret)[(<any>prop)[key]] = (<any>defaultNumberSymbols)[key];
|
|
123
|
+
}
|
|
124
|
+
return ret;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Returns regex string for provided value
|
|
128
|
+
*
|
|
129
|
+
* @param {string} val ?
|
|
130
|
+
* @returns {string} ?
|
|
131
|
+
*/
|
|
132
|
+
private static constructRegex(val: string): string {
|
|
133
|
+
const len: number = val.length;
|
|
134
|
+
let ret: string = '';
|
|
135
|
+
for (let i: number = 0; i < len; i++) {
|
|
136
|
+
if (i !== len - 1) {
|
|
137
|
+
ret += val[parseInt(i.toString(), 10)] + '|';
|
|
138
|
+
} else {
|
|
139
|
+
ret += val[parseInt(i.toString(), 10)];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return ret;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Returns the replaced value of matching regex and obj mapper.
|
|
146
|
+
*
|
|
147
|
+
* @param {string} value - Specifies the values to be replaced.
|
|
148
|
+
* @param {RegExp} regex - Specifies the regex to search.
|
|
149
|
+
* @param {Object} obj - Specifies the object matcher to be replace value parts.
|
|
150
|
+
* @returns {string} ?
|
|
151
|
+
*/
|
|
152
|
+
public static convertValueParts(value: string, regex: RegExp, obj: Object): string {
|
|
153
|
+
return value.replace(regex, (str: string): string => {
|
|
154
|
+
// eslint-disable-next-line
|
|
155
|
+
return (<any>obj)[str];
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Returns default numbering system object for formatting from cldr data
|
|
160
|
+
*
|
|
161
|
+
* @param {Object} obj ?
|
|
162
|
+
* @returns {NumericObject} ?
|
|
163
|
+
*/
|
|
164
|
+
public static getDefaultNumberingSystem(obj: Object): NumericObject {
|
|
165
|
+
const ret: NumericObject = {};
|
|
166
|
+
ret.obj = getValue('numbers', obj);
|
|
167
|
+
ret.nSystem = getValue('defaultNumberingSystem', ret.obj);
|
|
168
|
+
return ret;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Returns the replaced value of matching regex and obj mapper.
|
|
172
|
+
*
|
|
173
|
+
* @param {Object} curObj ?
|
|
174
|
+
* @param {Object} numberSystem ?
|
|
175
|
+
* @param {boolean} needSymbols ?
|
|
176
|
+
* @param {boolean} blazorMode ?
|
|
177
|
+
* @returns {Object} ?
|
|
178
|
+
*/
|
|
179
|
+
public static getCurrentNumericOptions(curObj: Object, numberSystem: Object, needSymbols?: boolean, blazorMode?: boolean): Object {
|
|
180
|
+
const ret: NumericOptions = {};
|
|
181
|
+
const cur: NumericObject = this.getDefaultNumberingSystem(curObj);
|
|
182
|
+
if (!isUndefined(cur.nSystem) || blazorMode) {
|
|
183
|
+
const digits: string = blazorMode ? getValue('obj.mapperDigits', cur) : getValue(cur.nSystem + '._digits', numberSystem);
|
|
184
|
+
if (!isUndefined(digits)) {
|
|
185
|
+
ret.numericPair = this.reverseObject(digits, latnNumberSystem);
|
|
186
|
+
const regExp: RegExpConstructor = RegExp;
|
|
187
|
+
ret.numberParseRegex = new regExp(this.constructRegex(digits), 'g');
|
|
188
|
+
ret.numericRegex = '[' + digits[0] + '-' + digits[9] + ']';
|
|
189
|
+
if (needSymbols) {
|
|
190
|
+
ret.numericRegex = digits[0] + '-' + digits[9];
|
|
191
|
+
ret.symbolNumberSystem = getValue(blazorMode ? 'numberSymbols' : 'symbols-numberSystem-' + cur.nSystem, cur.obj);
|
|
192
|
+
ret.symbolMatch = this.getSymbolMatch(ret.symbolNumberSystem);
|
|
193
|
+
ret.numberSystem = cur.nSystem;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return ret;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Returns number mapper object for the provided cldr data
|
|
201
|
+
*
|
|
202
|
+
* @param {Object} curObj ?
|
|
203
|
+
* @param {Object} numberSystem ?
|
|
204
|
+
* @param {boolean} isNumber ?
|
|
205
|
+
* @returns {NumberMapper} ?
|
|
206
|
+
*/
|
|
207
|
+
// eslint-disable-next-line
|
|
208
|
+
public static getNumberMapper(curObj: Object, numberSystem: Object, isNumber?: boolean): NumberMapper {
|
|
209
|
+
const ret: NumberMapper = { mapper: {} };
|
|
210
|
+
const cur: NumericObject = this.getDefaultNumberingSystem(curObj);
|
|
211
|
+
if (!isUndefined(cur.nSystem)) {
|
|
212
|
+
ret.numberSystem = cur.nSystem;
|
|
213
|
+
ret.numberSymbols = getValue('symbols-numberSystem-' + cur.nSystem, cur.obj);
|
|
214
|
+
ret.timeSeparator = getValue('timeSeparator', ret.numberSymbols);
|
|
215
|
+
const digits: string = getValue(cur.nSystem + '._digits', numberSystem);
|
|
216
|
+
if (!isUndefined(digits)) {
|
|
217
|
+
for (const i of latnNumberSystem) {
|
|
218
|
+
// eslint-disable-next-line
|
|
219
|
+
(<any>ret).mapper[i] = digits[i];
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return ret;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* @private
|
|
228
|
+
*/
|
|
229
|
+
const blazorCurrencyData: Object = {
|
|
230
|
+
'DJF': 'Fdj',
|
|
231
|
+
'ERN': 'Nfk',
|
|
232
|
+
'ETB': 'Br',
|
|
233
|
+
'NAD': '$',
|
|
234
|
+
'ZAR': 'R',
|
|
235
|
+
'XAF': 'FCFA',
|
|
236
|
+
'GHS': 'GH₵',
|
|
237
|
+
'XDR': 'XDR',
|
|
238
|
+
'AED': 'د.إ.',
|
|
239
|
+
'BHD': 'د.ب.',
|
|
240
|
+
'DZD': 'د.ج.',
|
|
241
|
+
'EGP': 'ج.م.',
|
|
242
|
+
'ILS': '₪',
|
|
243
|
+
'IQD': 'د.ع.',
|
|
244
|
+
'JOD': 'د.ا.',
|
|
245
|
+
'KMF': 'CF',
|
|
246
|
+
'KWD': 'د.ك.',
|
|
247
|
+
'LBP': 'ل.ل.',
|
|
248
|
+
'LYD': 'د.ل.',
|
|
249
|
+
'MAD': 'د.م.',
|
|
250
|
+
'MRU': 'أ.م.',
|
|
251
|
+
'OMR': 'ر.ع.',
|
|
252
|
+
'QAR': 'ر.ق.',
|
|
253
|
+
'SAR': 'ر.س.',
|
|
254
|
+
'SDG': 'ج.س.',
|
|
255
|
+
'SOS': 'S',
|
|
256
|
+
'SSP': '£',
|
|
257
|
+
'SYP': 'ل.س.',
|
|
258
|
+
'TND': 'د.ت.',
|
|
259
|
+
'YER': 'ر.ي.',
|
|
260
|
+
'CLP': '$',
|
|
261
|
+
'INR': '₹',
|
|
262
|
+
'TZS': 'TSh',
|
|
263
|
+
'EUR': '€',
|
|
264
|
+
'AZN': '₼',
|
|
265
|
+
'RUB': '₽',
|
|
266
|
+
'BYN': 'Br',
|
|
267
|
+
'ZMW': 'K',
|
|
268
|
+
'BGN': 'лв.',
|
|
269
|
+
'NGN': '₦',
|
|
270
|
+
'XOF': 'CFA',
|
|
271
|
+
'BDT': '৳',
|
|
272
|
+
'CNY': '¥',
|
|
273
|
+
'BAM': 'КМ',
|
|
274
|
+
'UGX': 'USh',
|
|
275
|
+
'USD': '$',
|
|
276
|
+
'CZK': 'Kč',
|
|
277
|
+
'GBP': '£',
|
|
278
|
+
'DKK': 'kr.',
|
|
279
|
+
'KES': 'Ksh',
|
|
280
|
+
'CHF': 'CHF',
|
|
281
|
+
'MVR': 'ރ.',
|
|
282
|
+
'BTN': 'Nu.',
|
|
283
|
+
'XCD': 'EC$',
|
|
284
|
+
'AUD': '$',
|
|
285
|
+
'BBD': '$',
|
|
286
|
+
'BIF': 'FBu',
|
|
287
|
+
'BMD': '$',
|
|
288
|
+
'BSD': '$',
|
|
289
|
+
'BWP': 'P',
|
|
290
|
+
'BZD': '$',
|
|
291
|
+
'CAD': '$',
|
|
292
|
+
'NZD': '$',
|
|
293
|
+
'FJD': '$',
|
|
294
|
+
'FKP': '£',
|
|
295
|
+
'GIP': '£',
|
|
296
|
+
'GMD': 'D',
|
|
297
|
+
'GYD': '$',
|
|
298
|
+
'HKD': '$',
|
|
299
|
+
'IDR': 'Rp',
|
|
300
|
+
'JMD': '$',
|
|
301
|
+
'KYD': '$',
|
|
302
|
+
'LRD': '$',
|
|
303
|
+
'MGA': 'Ar',
|
|
304
|
+
'MOP': 'MOP$',
|
|
305
|
+
'MUR': 'Rs',
|
|
306
|
+
'MWK': 'MK',
|
|
307
|
+
'MYR': 'RM',
|
|
308
|
+
'PGK': 'K',
|
|
309
|
+
'PHP': '₱',
|
|
310
|
+
'PKR': 'Rs',
|
|
311
|
+
'RWF': 'RF',
|
|
312
|
+
'SBD': '$',
|
|
313
|
+
'SCR': 'SR',
|
|
314
|
+
'SEK': 'kr',
|
|
315
|
+
'SGD': '$',
|
|
316
|
+
'SHP': '£',
|
|
317
|
+
'SLL': 'Le',
|
|
318
|
+
'ANG': 'NAf.',
|
|
319
|
+
'SZL': 'E',
|
|
320
|
+
'TOP': 'T$',
|
|
321
|
+
'TTD': '$',
|
|
322
|
+
'VUV': 'VT',
|
|
323
|
+
'WST': 'WS$',
|
|
324
|
+
'ARS': '$',
|
|
325
|
+
'BOB': 'Bs',
|
|
326
|
+
'BRL': 'R$',
|
|
327
|
+
'COP': '$',
|
|
328
|
+
'CRC': '₡',
|
|
329
|
+
'CUP': '$',
|
|
330
|
+
'DOP': '$',
|
|
331
|
+
'GTQ': 'Q',
|
|
332
|
+
'HNL': 'L',
|
|
333
|
+
'MXN': '$',
|
|
334
|
+
'NIO': 'C$',
|
|
335
|
+
'PAB': 'B/.',
|
|
336
|
+
'PEN': 'S/',
|
|
337
|
+
'PYG': '₲',
|
|
338
|
+
'UYU': '$',
|
|
339
|
+
'VES': 'Bs.S',
|
|
340
|
+
'IRR': 'ريال',
|
|
341
|
+
'GNF': 'FG',
|
|
342
|
+
'CDF': 'FC',
|
|
343
|
+
'HTG': 'G',
|
|
344
|
+
'XPF': 'FCFP',
|
|
345
|
+
'HRK': 'kn',
|
|
346
|
+
'HUF': 'Ft',
|
|
347
|
+
'AMD': '֏',
|
|
348
|
+
'ISK': 'kr',
|
|
349
|
+
'JPY': '¥',
|
|
350
|
+
'GEL': '₾',
|
|
351
|
+
'CVE': '',
|
|
352
|
+
'KZT': '₸',
|
|
353
|
+
'KHR': '៛',
|
|
354
|
+
'KPW': '₩',
|
|
355
|
+
'KRW': '₩',
|
|
356
|
+
'KGS': 'сом',
|
|
357
|
+
'AOA': 'Kz',
|
|
358
|
+
'LAK': '₭',
|
|
359
|
+
'MZN': 'MTn',
|
|
360
|
+
'MKD': 'ден',
|
|
361
|
+
'MNT': '₮',
|
|
362
|
+
'BND': '$',
|
|
363
|
+
'MMK': 'K',
|
|
364
|
+
'NOK': 'kr',
|
|
365
|
+
'NPR': 'रु',
|
|
366
|
+
'AWG': 'Afl.',
|
|
367
|
+
'SRD': '$',
|
|
368
|
+
'PLN': 'zł',
|
|
369
|
+
'AFN': '؋',
|
|
370
|
+
'STN': 'Db',
|
|
371
|
+
'MDL': 'L',
|
|
372
|
+
'RON': 'lei',
|
|
373
|
+
'UAH': '₴',
|
|
374
|
+
'LKR': 'රු.',
|
|
375
|
+
'ALL': 'Lekë',
|
|
376
|
+
'RSD': 'дин.',
|
|
377
|
+
'TJS': 'смн',
|
|
378
|
+
'THB': '฿',
|
|
379
|
+
'TMT': 'm.',
|
|
380
|
+
'TRY': '₺',
|
|
381
|
+
'UZS': 'сўм',
|
|
382
|
+
'VND': '₫',
|
|
383
|
+
'TWD': 'NT$'
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
*
|
|
388
|
+
* @param {string} currencyCode ?
|
|
389
|
+
* @returns {string} ?
|
|
390
|
+
*/
|
|
391
|
+
export function getBlazorCurrencySymbol(currencyCode: string): string {
|
|
392
|
+
return getValue(currencyCode || '', blazorCurrencyData);
|
|
393
|
+
}
|
|
394
|
+
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { Property, NotifyPropertyChanges, INotifyPropertyChanged, Event } from './notify-property-change';
|
|
2
|
+
import { Base, EmitType } from './base';
|
|
3
|
+
import { KeyboardEventsModel } from './keyboard-model';
|
|
4
|
+
/**
|
|
5
|
+
* KeyboardEvents
|
|
6
|
+
*/
|
|
7
|
+
export interface KeyboardEventArgs extends KeyboardEvent {
|
|
8
|
+
/**
|
|
9
|
+
* action of the KeyboardEvent
|
|
10
|
+
*/
|
|
11
|
+
action: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const keyCode: { [key: string]: number } = {
|
|
15
|
+
'backspace': 8,
|
|
16
|
+
'tab': 9,
|
|
17
|
+
'enter': 13,
|
|
18
|
+
'shift': 16,
|
|
19
|
+
'control': 17,
|
|
20
|
+
'alt': 18,
|
|
21
|
+
'pause': 19,
|
|
22
|
+
'capslock': 20,
|
|
23
|
+
'space': 32,
|
|
24
|
+
'escape': 27,
|
|
25
|
+
'pageup': 33,
|
|
26
|
+
'pagedown': 34,
|
|
27
|
+
'end': 35,
|
|
28
|
+
'home': 36,
|
|
29
|
+
'leftarrow': 37,
|
|
30
|
+
'uparrow': 38,
|
|
31
|
+
'rightarrow': 39,
|
|
32
|
+
'downarrow': 40,
|
|
33
|
+
'insert': 45,
|
|
34
|
+
'delete': 46,
|
|
35
|
+
'f1': 112,
|
|
36
|
+
'f2': 113,
|
|
37
|
+
'f3': 114,
|
|
38
|
+
'f4': 115,
|
|
39
|
+
'f5': 116,
|
|
40
|
+
'f6': 117,
|
|
41
|
+
'f7': 118,
|
|
42
|
+
'f8': 119,
|
|
43
|
+
'f9': 120,
|
|
44
|
+
'f10': 121,
|
|
45
|
+
'f11': 122,
|
|
46
|
+
'f12': 123,
|
|
47
|
+
'semicolon': 186,
|
|
48
|
+
'plus': 187,
|
|
49
|
+
'comma': 188,
|
|
50
|
+
'minus': 189,
|
|
51
|
+
'dot': 190,
|
|
52
|
+
'forwardslash': 191,
|
|
53
|
+
'graveaccent': 192,
|
|
54
|
+
'openbracket': 219,
|
|
55
|
+
'backslash': 220,
|
|
56
|
+
'closebracket': 221,
|
|
57
|
+
'singlequote': 222
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* KeyboardEvents class enables you to bind key action desired key combinations for ex., Ctrl+A, Delete, Alt+Space etc.
|
|
62
|
+
* ```html
|
|
63
|
+
* <div id='testEle'> </div>;
|
|
64
|
+
* <script>
|
|
65
|
+
* let node: HTMLElement = document.querySelector('#testEle');
|
|
66
|
+
* let kbInstance = new KeyboardEvents({
|
|
67
|
+
* element: node,
|
|
68
|
+
* keyConfigs:{ selectAll : 'ctrl+a' },
|
|
69
|
+
* keyAction: function (e:KeyboardEvent, action:string) {
|
|
70
|
+
* // handler function code
|
|
71
|
+
* }
|
|
72
|
+
* });
|
|
73
|
+
* </script>
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
@NotifyPropertyChanges
|
|
77
|
+
export class KeyboardEvents extends Base<HTMLElement> implements INotifyPropertyChanged {
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Specifies key combination and it respective action name.
|
|
81
|
+
*
|
|
82
|
+
* @default null
|
|
83
|
+
*/
|
|
84
|
+
@Property({})
|
|
85
|
+
public keyConfigs: { [key: string]: string };
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Specifies on which event keyboardEvents class should listen for key press. For ex., `keyup`, `keydown` or `keypress`
|
|
89
|
+
*
|
|
90
|
+
* @default keyup
|
|
91
|
+
*/
|
|
92
|
+
@Property('keyup')
|
|
93
|
+
public eventName: string;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Specifies the listener when keyboard actions is performed.
|
|
97
|
+
*
|
|
98
|
+
* @event keyAction
|
|
99
|
+
*/
|
|
100
|
+
@Event()
|
|
101
|
+
public keyAction: EmitType<KeyboardEventArgs>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Initializes the KeyboardEvents
|
|
105
|
+
*
|
|
106
|
+
* @param {HTMLElement} element ?
|
|
107
|
+
* @param {KeyboardEventsModel} options ?
|
|
108
|
+
*/
|
|
109
|
+
constructor(element: HTMLElement, options?: KeyboardEventsModel) {
|
|
110
|
+
super(options, element);
|
|
111
|
+
this.bind();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Unwire bound events and destroy the instance.
|
|
116
|
+
*
|
|
117
|
+
* @returns {void} ?
|
|
118
|
+
*/
|
|
119
|
+
public destroy(): void {
|
|
120
|
+
this.unwireEvents();
|
|
121
|
+
super.destroy();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Function can be used to specify certain action if a property is changed
|
|
126
|
+
*
|
|
127
|
+
* @param {KeyboardEventsModel} newProp ?
|
|
128
|
+
* @param {KeyboardEventsModel} oldProp ?
|
|
129
|
+
* @returns {void} ?
|
|
130
|
+
* @private
|
|
131
|
+
*/
|
|
132
|
+
// eslint-disable-next-line
|
|
133
|
+
public onPropertyChanged(newProp: KeyboardEventsModel, oldProp?: KeyboardEventsModel): void {
|
|
134
|
+
// No code are needed
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
protected bind(): void {
|
|
138
|
+
this.wireEvents();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* To get the module name, returns 'keyboard'.
|
|
143
|
+
*
|
|
144
|
+
* @returns {string} ?
|
|
145
|
+
* @private
|
|
146
|
+
*/
|
|
147
|
+
public getModuleName(): string {
|
|
148
|
+
return 'keyboard';
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Wiring event handlers to events
|
|
153
|
+
*
|
|
154
|
+
* @returns {void} ?
|
|
155
|
+
* @private
|
|
156
|
+
*/
|
|
157
|
+
private wireEvents(): void {
|
|
158
|
+
this.element.addEventListener(this.eventName, this.keyPressHandler);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Unwiring event handlers to events
|
|
163
|
+
*
|
|
164
|
+
* @returns {void} ?
|
|
165
|
+
* @private
|
|
166
|
+
*/
|
|
167
|
+
|
|
168
|
+
private unwireEvents(): void {
|
|
169
|
+
this.element.removeEventListener(this.eventName, this.keyPressHandler);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* To handle a key press event returns null
|
|
174
|
+
*
|
|
175
|
+
* @param {KeyboardEventArgs} e ?
|
|
176
|
+
* @returns {void} ?
|
|
177
|
+
*/
|
|
178
|
+
|
|
179
|
+
private keyPressHandler: EventListener = (e: KeyboardEventArgs): void => {
|
|
180
|
+
const isAltKey: boolean = e.altKey;
|
|
181
|
+
const isCtrlKey: boolean = e.ctrlKey;
|
|
182
|
+
const isShiftKey: boolean = e.shiftKey;
|
|
183
|
+
const curkeyCode: number = e.which;
|
|
184
|
+
const keys: string[] = Object.keys(this.keyConfigs);
|
|
185
|
+
for (const key of keys) {
|
|
186
|
+
const configCollection: string[] = this.keyConfigs[`${key}`].split(',');
|
|
187
|
+
for (const rconfig of configCollection) {
|
|
188
|
+
const rKeyObj: KeyData = KeyboardEvents.getKeyConfigData(rconfig.trim());
|
|
189
|
+
if (isAltKey === rKeyObj.altKey && isCtrlKey === rKeyObj.ctrlKey &&
|
|
190
|
+
isShiftKey === rKeyObj.shiftKey && curkeyCode === rKeyObj.keyCode) {
|
|
191
|
+
e.action = key;
|
|
192
|
+
if (this.keyAction) { this.keyAction(e); }
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
private static configCache: { [key: string]: KeyData } = {};
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* To get the key configuration data
|
|
202
|
+
*
|
|
203
|
+
* @param {string} config - configuration data
|
|
204
|
+
* @returns {KeyData} ?
|
|
205
|
+
*/
|
|
206
|
+
|
|
207
|
+
private static getKeyConfigData(config: string): KeyData {
|
|
208
|
+
if (config in this.configCache) { return this.configCache[`${config}`]; }
|
|
209
|
+
const keys: string[] = config.toLowerCase().split('+');
|
|
210
|
+
const keyData: KeyData = {
|
|
211
|
+
altKey: (keys.indexOf('alt') !== -1 ? true : false),
|
|
212
|
+
ctrlKey: (keys.indexOf('ctrl') !== -1 ? true : false),
|
|
213
|
+
shiftKey: (keys.indexOf('shift') !== -1 ? true : false),
|
|
214
|
+
keyCode: null
|
|
215
|
+
};
|
|
216
|
+
if (keys[keys.length - 1].length > 1 && !!Number(keys[keys.length - 1])) {
|
|
217
|
+
keyData.keyCode = Number(keys[keys.length - 1]);
|
|
218
|
+
|
|
219
|
+
} else {
|
|
220
|
+
keyData.keyCode = KeyboardEvents.getKeyCode(keys[keys.length - 1]);
|
|
221
|
+
}
|
|
222
|
+
KeyboardEvents.configCache[`${config}`] = keyData;
|
|
223
|
+
return keyData;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Return the keycode value as string
|
|
227
|
+
private static getKeyCode(keyVal: string): number {
|
|
228
|
+
return keyCode[`${keyVal}`] || keyVal.toUpperCase().charCodeAt(0);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
interface KeyData {
|
|
233
|
+
altKey: boolean;
|
|
234
|
+
ctrlKey: boolean;
|
|
235
|
+
shiftKey: boolean;
|
|
236
|
+
keyCode: number | string;
|
|
237
|
+
}
|
|
238
|
+
|