@progress/kendo-angular-intl 4.0.0-next.202204060817 → 4.0.1-dev.202206071423
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/bundles/kendo-angular-intl.umd.js +1 -1
- package/date.pipe.d.ts +41 -0
- package/error-solutions.d.ts +10 -0
- package/esm2015/date.pipe.js +62 -0
- package/esm2015/error-solutions.js +19 -0
- package/esm2015/intl-members.js +95 -0
- package/esm2015/intl.module.js +30 -0
- package/esm2015/intl.service.js +249 -0
- package/esm2015/kendo-angular-intl.js +8 -0
- package/esm2015/locale-data.interface.js +5 -0
- package/esm2015/main.js +10 -0
- package/esm2015/number.pipe.js +55 -0
- package/esm2015/package-metadata.js +15 -0
- package/fesm2015/kendo-angular-intl.js +502 -0
- package/intl-members.d.ts +71 -0
- package/intl.module.d.ts +16 -0
- package/intl.service.d.ts +298 -0
- package/kendo-angular-intl.d.ts +9 -0
- package/locale-data.interface.d.ts +392 -0
- package/main.d.ts +10 -0
- package/number.pipe.d.ts +41 -0
- package/package-metadata.d.ts +9 -0
- package/package.json +14 -17
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2021 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import * as i0 from '@angular/core';
|
|
6
|
+
import { EventEmitter, LOCALE_ID, Injectable, Inject, Pipe, NgModule } from '@angular/core';
|
|
7
|
+
import { validatePackage } from '@progress/kendo-licensing';
|
|
8
|
+
import * as intl from '@progress/kendo-intl';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @hidden
|
|
12
|
+
*/
|
|
13
|
+
const packageMetadata = {
|
|
14
|
+
name: '@progress/kendo-angular-intl',
|
|
15
|
+
productName: 'Kendo UI for Angular',
|
|
16
|
+
productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
|
|
17
|
+
publishDate: 1654611794,
|
|
18
|
+
version: '',
|
|
19
|
+
licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/?utm_medium=product&utm_source=kendoangular&utm_campaign=kendo-ui-angular-purchase-license-keys-warning'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const DOCS_URL = 'http://www.telerik.com/kendo-angular-ui/components/internationalization/troubleshooting/';
|
|
23
|
+
/**
|
|
24
|
+
* @hidden
|
|
25
|
+
*/
|
|
26
|
+
const errorSolutions = {
|
|
27
|
+
'NoCurrency': `Solution: ${DOCS_URL}#toc-no-currency`,
|
|
28
|
+
'NoCurrencyDisplay': `Solution: ${DOCS_URL}#toc-no-currency-display`,
|
|
29
|
+
'NoCurrencyRegion': `Solution: ${DOCS_URL}#toc-no-currency-region`,
|
|
30
|
+
'NoDateFieldNames': `Solution: ${DOCS_URL}#toc-no-date-filed-names`,
|
|
31
|
+
'NoFirstDay': `Solution: ${DOCS_URL}#toc-no-first-day`,
|
|
32
|
+
'NoGMTInfo': `Solution: ${DOCS_URL}#toc-no-gmt-info`,
|
|
33
|
+
'NoLocale': `Solution: ${DOCS_URL}#toc-no-locale`,
|
|
34
|
+
'NoValidCurrency': `Solution: ${DOCS_URL}#toc-no-valid-currency`,
|
|
35
|
+
'NoWeekData': `Solution: ${DOCS_URL}#toc-no-week-data`
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
function formatMessage(error) {
|
|
39
|
+
const message = error.message;
|
|
40
|
+
const errorSolution = errorSolutions[Object.keys(errorSolutions).filter(key => message.indexOf(key) === 0)[0]];
|
|
41
|
+
return errorSolution ? `${message} ${errorSolution}` : message;
|
|
42
|
+
}
|
|
43
|
+
function intlMethod(fn) {
|
|
44
|
+
return function (...values) {
|
|
45
|
+
try {
|
|
46
|
+
return fn.apply(null, values);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
error.message = formatMessage(error);
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* @hidden
|
|
56
|
+
*/
|
|
57
|
+
const dateFormatNames = intlMethod(intl.dateFormatNames);
|
|
58
|
+
/**
|
|
59
|
+
* @hidden
|
|
60
|
+
*/
|
|
61
|
+
const dateFieldName = intlMethod(intl.dateFieldName);
|
|
62
|
+
/**
|
|
63
|
+
* @hidden
|
|
64
|
+
*/
|
|
65
|
+
const firstDay = intlMethod(intl.firstDay);
|
|
66
|
+
/**
|
|
67
|
+
* @hidden
|
|
68
|
+
*/
|
|
69
|
+
const format = intlMethod(intl.format);
|
|
70
|
+
/**
|
|
71
|
+
* @hidden
|
|
72
|
+
*/
|
|
73
|
+
const formatDate = intlMethod(intl.formatDate);
|
|
74
|
+
/**
|
|
75
|
+
* @hidden
|
|
76
|
+
*/
|
|
77
|
+
const formatNumber = intlMethod(intl.formatNumber);
|
|
78
|
+
/**
|
|
79
|
+
* @hidden
|
|
80
|
+
*/
|
|
81
|
+
const load = intlMethod(intl.load);
|
|
82
|
+
/**
|
|
83
|
+
* @hidden
|
|
84
|
+
*/
|
|
85
|
+
const numberSymbols = intlMethod(intl.numberSymbols);
|
|
86
|
+
/**
|
|
87
|
+
* @hidden
|
|
88
|
+
*/
|
|
89
|
+
const parseDate = intlMethod(intl.parseDate);
|
|
90
|
+
/**
|
|
91
|
+
* @hidden
|
|
92
|
+
*/
|
|
93
|
+
const parseNumber = intlMethod(intl.parseNumber);
|
|
94
|
+
/**
|
|
95
|
+
* @hidden
|
|
96
|
+
*/
|
|
97
|
+
const splitDateFormat = intlMethod(intl.splitDateFormat);
|
|
98
|
+
/**
|
|
99
|
+
* @hidden
|
|
100
|
+
*/
|
|
101
|
+
const toString = intlMethod(intl.toString);
|
|
102
|
+
/**
|
|
103
|
+
* @hidden
|
|
104
|
+
*/
|
|
105
|
+
const weekendRange = intlMethod(intl.weekendRange);
|
|
106
|
+
/**
|
|
107
|
+
* Sets a pre-built locale.
|
|
108
|
+
*
|
|
109
|
+
* @params data - The pre-built locale data.
|
|
110
|
+
*/
|
|
111
|
+
const setData = (data) => intl.setData(data);
|
|
112
|
+
/**
|
|
113
|
+
* Retrieves the locale data for the specified locale.
|
|
114
|
+
*
|
|
115
|
+
* @params locale - The locale id.
|
|
116
|
+
* @returns data - The locale data.
|
|
117
|
+
*/
|
|
118
|
+
const localeData = (locale) => {
|
|
119
|
+
try {
|
|
120
|
+
return intl.localeInfo(locale);
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
error.message = formatMessage(error);
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const LOCALE_REGEX = /_/g;
|
|
129
|
+
/**
|
|
130
|
+
* @hidden
|
|
131
|
+
*/
|
|
132
|
+
function cldrServiceFactory(localeId) {
|
|
133
|
+
return new CldrIntlService(localeId);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* An abstract base class that implements
|
|
137
|
+
* the Internationalization service methods
|
|
138
|
+
* for the current locale.
|
|
139
|
+
*/
|
|
140
|
+
class IntlService {
|
|
141
|
+
/**
|
|
142
|
+
* @hidden
|
|
143
|
+
*/
|
|
144
|
+
constructor() {
|
|
145
|
+
/**
|
|
146
|
+
* @hidden
|
|
147
|
+
*/
|
|
148
|
+
this.changes = new EventEmitter();
|
|
149
|
+
validatePackage(packageMetadata);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Notifies that the service was changed.
|
|
153
|
+
*/
|
|
154
|
+
notify() {
|
|
155
|
+
this.changes.emit();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
IntlService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IntlService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
159
|
+
IntlService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IntlService, providedIn: 'root', useFactory: cldrServiceFactory, deps: [{ token: LOCALE_ID }] });
|
|
160
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IntlService, decorators: [{
|
|
161
|
+
type: Injectable,
|
|
162
|
+
args: [{
|
|
163
|
+
providedIn: 'root',
|
|
164
|
+
useFactory: cldrServiceFactory,
|
|
165
|
+
deps: [LOCALE_ID]
|
|
166
|
+
}]
|
|
167
|
+
}], ctorParameters: function () { return []; } });
|
|
168
|
+
/**
|
|
169
|
+
* The Internationalization service implemented by using
|
|
170
|
+
* the CLDR Database via the `@progress/kendo-intl` package.
|
|
171
|
+
*/
|
|
172
|
+
class CldrIntlService extends IntlService {
|
|
173
|
+
/**
|
|
174
|
+
* Creates a new instance of the service with the ID of the specified locale.
|
|
175
|
+
*
|
|
176
|
+
* Note that the parts of the locale ID can be separated by either `_` (underscore)
|
|
177
|
+
* or `-` (dash).
|
|
178
|
+
*
|
|
179
|
+
* @param localeId - The default locale ID.
|
|
180
|
+
*/
|
|
181
|
+
constructor(localeId) {
|
|
182
|
+
super();
|
|
183
|
+
this.localeId = localeId;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Gets or sets the current locale ID.
|
|
187
|
+
*/
|
|
188
|
+
get localeId() {
|
|
189
|
+
return this.locale;
|
|
190
|
+
}
|
|
191
|
+
set localeId(value) {
|
|
192
|
+
// Angular locales use underscore, for example, en_US
|
|
193
|
+
// while IETF BCP-47 specifies a dash.
|
|
194
|
+
// https://tools.ietf.org/html/bcp47
|
|
195
|
+
const locale = value.replace(LOCALE_REGEX, '-');
|
|
196
|
+
if (locale !== this.locale) {
|
|
197
|
+
this.locale = locale;
|
|
198
|
+
this.notify();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Formats a string with placeholders such as
|
|
203
|
+
* `Total amount {0:c}`.
|
|
204
|
+
*
|
|
205
|
+
* @param format - The format string.
|
|
206
|
+
* @param values - One or more values to output in the format string placeholders.
|
|
207
|
+
* @return - The formatted string.
|
|
208
|
+
*/
|
|
209
|
+
format(format$1, ...values) {
|
|
210
|
+
return format(format$1, values, this.localeId);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Converts an object into a string based on the specified format.
|
|
214
|
+
*
|
|
215
|
+
* @param value - The value to format.
|
|
216
|
+
* @param format - The format to use.
|
|
217
|
+
* @param localeId - The locale ID to use in place of the default one. Optional.
|
|
218
|
+
* @return The formatted object.
|
|
219
|
+
*/
|
|
220
|
+
toString(value, format, localeId) {
|
|
221
|
+
return toString(value, format, localeId || this.localeId);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Converts a `Date` object into a string based on the specified format.
|
|
225
|
+
* If no format is provided, the default short date format is used.
|
|
226
|
+
*
|
|
227
|
+
* @param value - The date to format.
|
|
228
|
+
* @param format - The format string or options.
|
|
229
|
+
* @param localeId - The locale ID to use in place of the default one. Optional.
|
|
230
|
+
* @return The formatted date.
|
|
231
|
+
*/
|
|
232
|
+
formatDate(value, format, localeId) {
|
|
233
|
+
return formatDate(value, format, localeId || this.localeId);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Converts a string into a `Date` object based on the specified format.
|
|
237
|
+
*
|
|
238
|
+
* @param value - The string to convert.
|
|
239
|
+
* @param format - The format strings or options.
|
|
240
|
+
* @param localeId - The locale ID to use in place of the default one. Optional.
|
|
241
|
+
* @return The parsed date.
|
|
242
|
+
*/
|
|
243
|
+
parseDate(value, format, localeId) {
|
|
244
|
+
return parseDate(value, format, localeId || this.localeId);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Converts a string into a `Number`.
|
|
248
|
+
*
|
|
249
|
+
* @param value - The string to convert.
|
|
250
|
+
* @param format - The format string or options.
|
|
251
|
+
* @param localeId - The locale ID to use in place of the default one. Optional.
|
|
252
|
+
* @return The parsed number.
|
|
253
|
+
*/
|
|
254
|
+
parseNumber(value, format, localeId) {
|
|
255
|
+
return parseNumber(value, localeId || this.localeId, format);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Converts a `Number` into a string based on the specified format.
|
|
259
|
+
*
|
|
260
|
+
* @param value - The number to format.
|
|
261
|
+
* @param format - The format string or options.
|
|
262
|
+
* @param localeId - The locale ID to use in place of the default one. Optional.
|
|
263
|
+
* @return The formatted number.
|
|
264
|
+
*/
|
|
265
|
+
formatNumber(value, format, localeId) {
|
|
266
|
+
return formatNumber(value, format, localeId || this.localeId);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Returns the date names from the current locale based on the option.
|
|
270
|
+
*
|
|
271
|
+
* The available `type` values are:
|
|
272
|
+
* - `era`
|
|
273
|
+
* - `year`
|
|
274
|
+
* - `quarter`
|
|
275
|
+
* - `month`
|
|
276
|
+
* - `week`
|
|
277
|
+
* - `day`
|
|
278
|
+
* - `dayperiod`
|
|
279
|
+
* - `hour`
|
|
280
|
+
* - `minute`
|
|
281
|
+
* - `second`
|
|
282
|
+
* - `zone`
|
|
283
|
+
*
|
|
284
|
+
* The available `nameType` values are:
|
|
285
|
+
* - `wide`
|
|
286
|
+
* - `narrow`
|
|
287
|
+
* - `short`
|
|
288
|
+
*
|
|
289
|
+
* @param options - Detailed configuration for the desired date field name.
|
|
290
|
+
* @param localeId - The locale ID to use in place of the default one. Optional.
|
|
291
|
+
* @return - The day names from the current locale based on the option.
|
|
292
|
+
* @returns The localized date field name from the current locale based on the option.
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```
|
|
296
|
+
* dateFieldName({ type: 'day' }); //returns 'day';
|
|
297
|
+
* dateFieldName({ type: 'day', nameType: 'wide' }); //returns 'day';
|
|
298
|
+
* dateFieldName({ type: 'month', nameType: 'short' }); //returns 'mo.';
|
|
299
|
+
* dateFieldName({ type: 'month', nameType: 'wide' }); //returns 'month';
|
|
300
|
+
* ```
|
|
301
|
+
*/
|
|
302
|
+
dateFieldName(options, localeId) {
|
|
303
|
+
return dateFieldName(options, localeId || this.localeId);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Returns a localized date field name based on specific dateFieldName options.
|
|
307
|
+
*
|
|
308
|
+
* The available type values are:
|
|
309
|
+
* - `day`
|
|
310
|
+
* - `dayperiod`
|
|
311
|
+
* - `months`
|
|
312
|
+
* - `quarters`
|
|
313
|
+
* - `eras`
|
|
314
|
+
*
|
|
315
|
+
* @param options - Detailed configuration for the desired date format.
|
|
316
|
+
* @param localeId - The locale ID to use in place of the default one. Optional.
|
|
317
|
+
* @return - The day names from the current locale based on the option.
|
|
318
|
+
*/
|
|
319
|
+
dateFormatNames(options, localeId) {
|
|
320
|
+
return dateFormatNames(localeId || this.localeId, options);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Splits the date format into objects containing information about each part of the pattern.
|
|
324
|
+
*
|
|
325
|
+
* @param format The format string or options.
|
|
326
|
+
* @param localeId The optional locale id. If not specified, the `"en"` locale id is used.
|
|
327
|
+
* @returns The date format parts.
|
|
328
|
+
*/
|
|
329
|
+
splitDateFormat(format, localeId) {
|
|
330
|
+
return splitDateFormat(format, localeId || this.localeId);
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Returns the number symbols from the current locale based on the option.
|
|
334
|
+
*
|
|
335
|
+
* @param localeId - The locale ID to use in place of the default one. Optional.
|
|
336
|
+
* @return - The number symbols from the current locale.
|
|
337
|
+
*/
|
|
338
|
+
numberSymbols(localeId) {
|
|
339
|
+
return numberSymbols(localeId || this.localeId);
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Returns the first day index starting from Sunday.
|
|
343
|
+
*
|
|
344
|
+
* @param localeId - The locale ID. Defaults to the current locale ID.
|
|
345
|
+
* @return - The index of the first day of the week (0 == Sunday).
|
|
346
|
+
*/
|
|
347
|
+
firstDay(localeId) {
|
|
348
|
+
return firstDay(localeId || this.localeId);
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Returns the start and end index of the locale weekend starting from Sunday.
|
|
352
|
+
*
|
|
353
|
+
* @param localeId - The locale ID. Defaults to the current locale ID.
|
|
354
|
+
* @return - The the start and end index of the locale weekend (0 == Sunday).
|
|
355
|
+
*/
|
|
356
|
+
weekendRange(localeId) {
|
|
357
|
+
return weekendRange(localeId || this.localeId);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
CldrIntlService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: CldrIntlService, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
361
|
+
CldrIntlService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: CldrIntlService });
|
|
362
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: CldrIntlService, decorators: [{
|
|
363
|
+
type: Injectable
|
|
364
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
365
|
+
type: Inject,
|
|
366
|
+
args: [LOCALE_ID]
|
|
367
|
+
}] }]; } });
|
|
368
|
+
|
|
369
|
+
const isNumeric = (value) => !isNaN(value - parseFloat(value));
|
|
370
|
+
/**
|
|
371
|
+
* Formats a date value to a string based on the requested format.
|
|
372
|
+
* This pipe uses the [IntlService]({% slug api_intl_intlservice %}).
|
|
373
|
+
*
|
|
374
|
+
* @example
|
|
375
|
+
* ```ng-template-no-run
|
|
376
|
+
* <ul>
|
|
377
|
+
* <li>{{date | kendoDate }}</li>
|
|
378
|
+
* <li>{{milliseconds | kendoDate: 'M/dd/yyy' }}</li>
|
|
379
|
+
* <li>{{stringDate | kendoDate: 'G' }}</li>
|
|
380
|
+
* </ul>
|
|
381
|
+
* ```
|
|
382
|
+
*/
|
|
383
|
+
class DatePipe {
|
|
384
|
+
/**
|
|
385
|
+
* @hidden
|
|
386
|
+
*/
|
|
387
|
+
constructor(intlService) {
|
|
388
|
+
this.intlService = intlService;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Converts a `Date` object into a string based on the specified format.
|
|
392
|
+
* If no format is provided, the default short date format is used.
|
|
393
|
+
*
|
|
394
|
+
* @param value - The date to format.
|
|
395
|
+
* @param format - The format string or options.
|
|
396
|
+
* @param localeId - (Optional) The ID of the locale which will be used instead of the default one.
|
|
397
|
+
* @return - The formatted date.
|
|
398
|
+
*/
|
|
399
|
+
transform(value, format = "", localeId) {
|
|
400
|
+
value = this.normalize(value);
|
|
401
|
+
if (value) {
|
|
402
|
+
return this.intlService.formatDate(value, format, localeId);
|
|
403
|
+
}
|
|
404
|
+
return value;
|
|
405
|
+
}
|
|
406
|
+
normalize(value) {
|
|
407
|
+
if (value && typeof value === 'string') {
|
|
408
|
+
value = this.intlService.parseDate(value);
|
|
409
|
+
}
|
|
410
|
+
else if (value && isNumeric(value)) {
|
|
411
|
+
value = new Date(parseFloat(value));
|
|
412
|
+
}
|
|
413
|
+
return value;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
DatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DatePipe, deps: [{ token: IntlService }], target: i0.ɵɵFactoryTarget.Pipe });
|
|
417
|
+
DatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DatePipe, name: "kendoDate" });
|
|
418
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DatePipe, decorators: [{
|
|
419
|
+
type: Pipe,
|
|
420
|
+
args: [{
|
|
421
|
+
name: 'kendoDate'
|
|
422
|
+
}]
|
|
423
|
+
}], ctorParameters: function () { return [{ type: IntlService }]; } });
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Formats a number value to a string based on the requested format.
|
|
427
|
+
* This pipe uses the [`IntlService`]({% slug api_intl_intlservice %}).
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```ng-template-no-run
|
|
431
|
+
* <ul>
|
|
432
|
+
* <li>{{decimal | kendoNumber:'c' }}</li>
|
|
433
|
+
* <li>{{stringNumber | kendoNumber:'p' }}</li>
|
|
434
|
+
* <li>{{int | kendoNumber:'##.00' }}</li>
|
|
435
|
+
* </ul>
|
|
436
|
+
* ```
|
|
437
|
+
*/
|
|
438
|
+
class NumberPipe {
|
|
439
|
+
/**
|
|
440
|
+
* @hidden
|
|
441
|
+
*/
|
|
442
|
+
constructor(intlService) {
|
|
443
|
+
this.intlService = intlService;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Converts a `Number` object into a string based on the specified format.
|
|
447
|
+
* If no format is provided, the value is formatted as decimal number using the
|
|
448
|
+
* [`"n"`](https://github.com/telerik/kendo-intl/blob/master/docs/num-formatting/index.md#standard) format.
|
|
449
|
+
*
|
|
450
|
+
* @param value - The numer that will be formatted.
|
|
451
|
+
* @param format - The format string or options.
|
|
452
|
+
* @param localeId - (Optional) The locale ID that will be used in place of the default one.
|
|
453
|
+
* @return - The formatted number.
|
|
454
|
+
*/
|
|
455
|
+
transform(value, format, localeId) {
|
|
456
|
+
if (typeof value === 'string') {
|
|
457
|
+
value = this.intlService.parseNumber(value);
|
|
458
|
+
}
|
|
459
|
+
if (value !== null && value !== undefined) {
|
|
460
|
+
return this.intlService.formatNumber(value, format, localeId);
|
|
461
|
+
}
|
|
462
|
+
return value;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
NumberPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: NumberPipe, deps: [{ token: IntlService }], target: i0.ɵɵFactoryTarget.Pipe });
|
|
466
|
+
NumberPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: NumberPipe, name: "kendoNumber" });
|
|
467
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: NumberPipe, decorators: [{
|
|
468
|
+
type: Pipe,
|
|
469
|
+
args: [{
|
|
470
|
+
name: 'kendoNumber'
|
|
471
|
+
}]
|
|
472
|
+
}], ctorParameters: function () { return [{ type: IntlService }]; } });
|
|
473
|
+
|
|
474
|
+
const pipes = [
|
|
475
|
+
DatePipe,
|
|
476
|
+
NumberPipe
|
|
477
|
+
];
|
|
478
|
+
/**
|
|
479
|
+
* Represents the [NgModule]({{ site.data.urls.angular['ngmoduleapi'] }}docs/ts/latest/guide/ngmodule.html)
|
|
480
|
+
* definition for the Intl services.
|
|
481
|
+
*/
|
|
482
|
+
class IntlModule {
|
|
483
|
+
}
|
|
484
|
+
IntlModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IntlModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
485
|
+
IntlModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IntlModule, declarations: [DatePipe,
|
|
486
|
+
NumberPipe], exports: [DatePipe,
|
|
487
|
+
NumberPipe] });
|
|
488
|
+
IntlModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IntlModule });
|
|
489
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IntlModule, decorators: [{
|
|
490
|
+
type: NgModule,
|
|
491
|
+
args: [{
|
|
492
|
+
declarations: [pipes],
|
|
493
|
+
exports: [pipes]
|
|
494
|
+
}]
|
|
495
|
+
}] });
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Generated bundle index. Do not edit.
|
|
499
|
+
*/
|
|
500
|
+
|
|
501
|
+
export { CldrIntlService, DatePipe, IntlModule, IntlService, NumberPipe, cldrServiceFactory, dateFieldName, dateFormatNames, firstDay, format, formatDate, formatNumber, load, localeData, numberSymbols, parseDate, parseNumber, setData, splitDateFormat, toString, weekendRange };
|
|
502
|
+
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2021 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { Locale } from './locale-data.interface';
|
|
6
|
+
export { DateFieldNameOptions, DateFormatNameOptions, DateFormatOptions, NumberFormatOptions, DateFormatPart } from '@progress/kendo-intl';
|
|
7
|
+
/**
|
|
8
|
+
* @hidden
|
|
9
|
+
*/
|
|
10
|
+
export declare const dateFormatNames: Function;
|
|
11
|
+
/**
|
|
12
|
+
* @hidden
|
|
13
|
+
*/
|
|
14
|
+
export declare const dateFieldName: Function;
|
|
15
|
+
/**
|
|
16
|
+
* @hidden
|
|
17
|
+
*/
|
|
18
|
+
export declare const firstDay: Function;
|
|
19
|
+
/**
|
|
20
|
+
* @hidden
|
|
21
|
+
*/
|
|
22
|
+
export declare const format: Function;
|
|
23
|
+
/**
|
|
24
|
+
* @hidden
|
|
25
|
+
*/
|
|
26
|
+
export declare const formatDate: Function;
|
|
27
|
+
/**
|
|
28
|
+
* @hidden
|
|
29
|
+
*/
|
|
30
|
+
export declare const formatNumber: Function;
|
|
31
|
+
/**
|
|
32
|
+
* @hidden
|
|
33
|
+
*/
|
|
34
|
+
export declare const load: Function;
|
|
35
|
+
/**
|
|
36
|
+
* @hidden
|
|
37
|
+
*/
|
|
38
|
+
export declare const numberSymbols: Function;
|
|
39
|
+
/**
|
|
40
|
+
* @hidden
|
|
41
|
+
*/
|
|
42
|
+
export declare const parseDate: Function;
|
|
43
|
+
/**
|
|
44
|
+
* @hidden
|
|
45
|
+
*/
|
|
46
|
+
export declare const parseNumber: Function;
|
|
47
|
+
/**
|
|
48
|
+
* @hidden
|
|
49
|
+
*/
|
|
50
|
+
export declare const splitDateFormat: Function;
|
|
51
|
+
/**
|
|
52
|
+
* @hidden
|
|
53
|
+
*/
|
|
54
|
+
export declare const toString: Function;
|
|
55
|
+
/**
|
|
56
|
+
* @hidden
|
|
57
|
+
*/
|
|
58
|
+
export declare const weekendRange: Function;
|
|
59
|
+
/**
|
|
60
|
+
* Sets a pre-built locale.
|
|
61
|
+
*
|
|
62
|
+
* @params data - The pre-built locale data.
|
|
63
|
+
*/
|
|
64
|
+
export declare const setData: (data: any) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Retrieves the locale data for the specified locale.
|
|
67
|
+
*
|
|
68
|
+
* @params locale - The locale id.
|
|
69
|
+
* @returns data - The locale data.
|
|
70
|
+
*/
|
|
71
|
+
export declare const localeData: (locale: string) => Locale;
|
package/intl.module.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2021 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
import * as i1 from "./date.pipe";
|
|
7
|
+
import * as i2 from "./number.pipe";
|
|
8
|
+
/**
|
|
9
|
+
* Represents the [NgModule]({{ site.data.urls.angular['ngmoduleapi'] }}docs/ts/latest/guide/ngmodule.html)
|
|
10
|
+
* definition for the Intl services.
|
|
11
|
+
*/
|
|
12
|
+
export declare class IntlModule {
|
|
13
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<IntlModule, never>;
|
|
14
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<IntlModule, [typeof i1.DatePipe, typeof i2.NumberPipe], never, [typeof i1.DatePipe, typeof i2.NumberPipe]>;
|
|
15
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<IntlModule>;
|
|
16
|
+
}
|