@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
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* Copyright © 2021 Progress Software Corporation. All rights reserved.
|
|
3
3
|
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@progress/kendo-licensing"),require("@
|
|
5
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@progress/kendo-licensing"),require("@progress/kendo-intl")):"function"==typeof define&&define.amd?define("KendoAngularIntl",["exports","@angular/core","@progress/kendo-licensing","@progress/kendo-intl"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoAngularIntl={},e.ng.core,e.KendoLicensing,e.KendoIntl)}(this,function(e,t,r,n){"use strict";function o(r){if(r&&r.__esModule)return r;var n=Object.create(null);return r&&Object.keys(r).forEach(function(e){var t;"default"!==e&&(t=Object.getOwnPropertyDescriptor(r,e),Object.defineProperty(n,e,t.get?t:{enumerable:!0,get:function(){return r[e]}}))}),n.default=r,Object.freeze(n)}var a=o(t),i=o(n),c=function(e,t){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};Object.create;Object.create;var s={name:"@progress/kendo-angular-intl",productName:"Kendo UI for Angular",productCodes:["KENDOUIANGULAR","KENDOUICOMPLETE"],publishDate:1654611794,version:"",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"},n="http://www.telerik.com/kendo-angular-ui/components/internationalization/troubleshooting/",l={NoCurrency:"Solution: "+n+"#toc-no-currency",NoCurrencyDisplay:"Solution: "+n+"#toc-no-currency-display",NoCurrencyRegion:"Solution: "+n+"#toc-no-currency-region",NoDateFieldNames:"Solution: "+n+"#toc-no-date-filed-names",NoFirstDay:"Solution: "+n+"#toc-no-first-day",NoGMTInfo:"Solution: "+n+"#toc-no-gmt-info",NoLocale:"Solution: "+n+"#toc-no-locale",NoValidCurrency:"Solution: "+n+"#toc-no-valid-currency",NoWeekData:"Solution: "+n+"#toc-no-week-data"};function u(e){var t=e.message,e=l[Object.keys(l).filter(function(e){return 0===t.indexOf(e)})[0]];return e?t+" "+e:t}function p(r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return r.apply(null,e)}catch(e){throw e.message=u(e),e}}}var d=p(i.dateFormatNames),m=p(i.dateFieldName),f=p(i.firstDay),g=p(i.format),y=p(i.formatDate),I=p(i.formatNumber),n=p(i.load),v=p(i.numberSymbols),D=p(i.parseDate),h=p(i.parseNumber),b=p(i.splitDateFormat),N=p(i.toString),k=p(i.weekendRange),F=/_/g;function S(e){return new w(e)}j.prototype.notify=function(){this.changes.emit()};var O=j;function j(){this.changes=new t.EventEmitter,r.validatePackage(s)}O.ɵfac=a.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"12.2.16",ngImport:a,type:O,deps:[],target:a.ɵɵFactoryTarget.Injectable}),O.ɵprov=a.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"12.2.16",ngImport:a,type:O,providedIn:"root",useFactory:S,deps:[{token:t.LOCALE_ID}]}),a.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"12.2.16",ngImport:a,type:O,decorators:[{type:t.Injectable,args:[{providedIn:"root",useFactory:S,deps:[t.LOCALE_ID]}]}],ctorParameters:function(){return[]}});var w=function(r){var e=o,t=r;if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}function o(e){var t=r.call(this)||this;return t.localeId=e,t}return c(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n),Object.defineProperty(o.prototype,"localeId",{get:function(){return this.locale},set:function(e){e=e.replace(F,"-");e!==this.locale&&(this.locale=e,this.notify())},enumerable:!1,configurable:!0}),o.prototype.format=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return g(e,t,this.localeId)},o.prototype.toString=function(e,t,r){return N(e,t,r||this.localeId)},o.prototype.formatDate=function(e,t,r){return y(e,t,r||this.localeId)},o.prototype.parseDate=function(e,t,r){return D(e,t,r||this.localeId)},o.prototype.parseNumber=function(e,t,r){return h(e,r||this.localeId,t)},o.prototype.formatNumber=function(e,t,r){return I(e,t,r||this.localeId)},o.prototype.dateFieldName=function(e,t){return m(e,t||this.localeId)},o.prototype.dateFormatNames=function(e,t){return d(t||this.localeId,e)},o.prototype.splitDateFormat=function(e,t){return b(e,t||this.localeId)},o.prototype.numberSymbols=function(e){return v(e||this.localeId)},o.prototype.firstDay=function(e){return f(e||this.localeId)},o.prototype.weekendRange=function(e){return k(e||this.localeId)},o}(O),P=(w.ɵfac=a.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"12.2.16",ngImport:a,type:w,deps:[{token:t.LOCALE_ID}],target:a.ɵɵFactoryTarget.Injectable}),w.ɵprov=a.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"12.2.16",ngImport:a,type:w}),a.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"12.2.16",ngImport:a,type:w,decorators:[{type:t.Injectable}],ctorParameters:function(){return[{type:void 0,decorators:[{type:t.Inject,args:[t.LOCALE_ID]}]}]}}),_.prototype.transform=function(e,t,r){return void 0===t&&(t=""),(e=this.normalize(e))?this.intlService.formatDate(e,t,r):e},_.prototype.normalize=function(e){return e&&"string"==typeof e?e=this.intlService.parseDate(e):e&&!isNaN(e-parseFloat(e))&&(e=new Date(parseFloat(e))),e},_);function _(e){this.intlService=e}P.ɵfac=a.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"12.2.16",ngImport:a,type:P,deps:[{token:O}],target:a.ɵɵFactoryTarget.Pipe}),P.ɵpipe=a.ɵɵngDeclarePipe({minVersion:"12.0.0",version:"12.2.16",ngImport:a,type:P,name:"kendoDate"}),a.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"12.2.16",ngImport:a,type:P,decorators:[{type:t.Pipe,args:[{name:"kendoDate"}]}],ctorParameters:function(){return[{type:O}]}});V.prototype.transform=function(e,t,r){return null!=(e="string"==typeof e?this.intlService.parseNumber(e):e)?this.intlService.formatNumber(e,t,r):e};var C=V;function V(e){this.intlService=e}C.ɵfac=a.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"12.2.16",ngImport:a,type:C,deps:[{token:O}],target:a.ɵɵFactoryTarget.Pipe}),C.ɵpipe=a.ɵɵngDeclarePipe({minVersion:"12.0.0",version:"12.2.16",ngImport:a,type:C,name:"kendoNumber"}),a.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"12.2.16",ngImport:a,type:C,decorators:[{type:t.Pipe,args:[{name:"kendoNumber"}]}],ctorParameters:function(){return[{type:O}]}});var M=[P,C],E=function(){};E.ɵfac=a.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"12.2.16",ngImport:a,type:E,deps:[],target:a.ɵɵFactoryTarget.NgModule}),E.ɵmod=a.ɵɵngDeclareNgModule({minVersion:"12.0.0",version:"12.2.16",ngImport:a,type:E,declarations:[P,C],exports:[P,C]}),E.ɵinj=a.ɵɵngDeclareInjector({minVersion:"12.0.0",version:"12.2.16",ngImport:a,type:E}),a.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"12.2.16",ngImport:a,type:E,decorators:[{type:t.NgModule,args:[{declarations:[M],exports:[M]}]}]}),e.CldrIntlService=w,e.DatePipe=P,e.IntlModule=E,e.IntlService=O,e.NumberPipe=C,e.cldrServiceFactory=S,e.dateFieldName=m,e.dateFormatNames=d,e.firstDay=f,e.format=g,e.formatDate=y,e.formatNumber=I,e.load=n,e.localeData=function(e){try{return i.localeInfo(e)}catch(e){throw e.message=u(e),e}},e.numberSymbols=v,e.parseDate=D,e.parseNumber=h,e.setData=function(e){return i.setData(e)},e.splitDateFormat=b,e.toString=N,e.weekendRange=k,Object.defineProperty(e,"__esModule",{value:!0})});
|
package/date.pipe.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
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 { PipeTransform } from '@angular/core';
|
|
6
|
+
import { IntlService } from './intl.service';
|
|
7
|
+
import { DateFormatOptions } from '@progress/kendo-intl';
|
|
8
|
+
import * as i0 from "@angular/core";
|
|
9
|
+
/**
|
|
10
|
+
* Formats a date value to a string based on the requested format.
|
|
11
|
+
* This pipe uses the [IntlService]({% slug api_intl_intlservice %}).
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ng-template-no-run
|
|
15
|
+
* <ul>
|
|
16
|
+
* <li>{{date | kendoDate }}</li>
|
|
17
|
+
* <li>{{milliseconds | kendoDate: 'M/dd/yyy' }}</li>
|
|
18
|
+
* <li>{{stringDate | kendoDate: 'G' }}</li>
|
|
19
|
+
* </ul>
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare class DatePipe implements PipeTransform {
|
|
23
|
+
private intlService;
|
|
24
|
+
/**
|
|
25
|
+
* @hidden
|
|
26
|
+
*/
|
|
27
|
+
constructor(intlService: IntlService);
|
|
28
|
+
/**
|
|
29
|
+
* Converts a `Date` object into a string based on the specified format.
|
|
30
|
+
* If no format is provided, the default short date format is used.
|
|
31
|
+
*
|
|
32
|
+
* @param value - The date to format.
|
|
33
|
+
* @param format - The format string or options.
|
|
34
|
+
* @param localeId - (Optional) The ID of the locale which will be used instead of the default one.
|
|
35
|
+
* @return - The formatted date.
|
|
36
|
+
*/
|
|
37
|
+
transform(value: any, format?: String | DateFormatOptions, localeId?: string): any;
|
|
38
|
+
private normalize;
|
|
39
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DatePipe, never>;
|
|
40
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<DatePipe, "kendoDate">;
|
|
41
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* @hidden
|
|
7
|
+
*/
|
|
8
|
+
export declare const errorSolutions: {
|
|
9
|
+
[x: string]: string;
|
|
10
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
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 { Pipe } from '@angular/core';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
import * as i1 from "./intl.service";
|
|
8
|
+
const isNumeric = (value) => !isNaN(value - parseFloat(value));
|
|
9
|
+
/**
|
|
10
|
+
* Formats a date value to a string based on the requested format.
|
|
11
|
+
* This pipe uses the [IntlService]({% slug api_intl_intlservice %}).
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ng-template-no-run
|
|
15
|
+
* <ul>
|
|
16
|
+
* <li>{{date | kendoDate }}</li>
|
|
17
|
+
* <li>{{milliseconds | kendoDate: 'M/dd/yyy' }}</li>
|
|
18
|
+
* <li>{{stringDate | kendoDate: 'G' }}</li>
|
|
19
|
+
* </ul>
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export class DatePipe {
|
|
23
|
+
/**
|
|
24
|
+
* @hidden
|
|
25
|
+
*/
|
|
26
|
+
constructor(intlService) {
|
|
27
|
+
this.intlService = intlService;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Converts a `Date` object into a string based on the specified format.
|
|
31
|
+
* If no format is provided, the default short date format is used.
|
|
32
|
+
*
|
|
33
|
+
* @param value - The date to format.
|
|
34
|
+
* @param format - The format string or options.
|
|
35
|
+
* @param localeId - (Optional) The ID of the locale which will be used instead of the default one.
|
|
36
|
+
* @return - The formatted date.
|
|
37
|
+
*/
|
|
38
|
+
transform(value, format = "", localeId) {
|
|
39
|
+
value = this.normalize(value);
|
|
40
|
+
if (value) {
|
|
41
|
+
return this.intlService.formatDate(value, format, localeId);
|
|
42
|
+
}
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
normalize(value) {
|
|
46
|
+
if (value && typeof value === 'string') {
|
|
47
|
+
value = this.intlService.parseDate(value);
|
|
48
|
+
}
|
|
49
|
+
else if (value && isNumeric(value)) {
|
|
50
|
+
value = new Date(parseFloat(value));
|
|
51
|
+
}
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
DatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DatePipe, deps: [{ token: i1.IntlService }], target: i0.ɵɵFactoryTarget.Pipe });
|
|
56
|
+
DatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DatePipe, name: "kendoDate" });
|
|
57
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DatePipe, decorators: [{
|
|
58
|
+
type: Pipe,
|
|
59
|
+
args: [{
|
|
60
|
+
name: 'kendoDate'
|
|
61
|
+
}]
|
|
62
|
+
}], ctorParameters: function () { return [{ type: i1.IntlService }]; } });
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
const DOCS_URL = 'http://www.telerik.com/kendo-angular-ui/components/internationalization/troubleshooting/';
|
|
6
|
+
/**
|
|
7
|
+
* @hidden
|
|
8
|
+
*/
|
|
9
|
+
export const errorSolutions = {
|
|
10
|
+
'NoCurrency': `Solution: ${DOCS_URL}#toc-no-currency`,
|
|
11
|
+
'NoCurrencyDisplay': `Solution: ${DOCS_URL}#toc-no-currency-display`,
|
|
12
|
+
'NoCurrencyRegion': `Solution: ${DOCS_URL}#toc-no-currency-region`,
|
|
13
|
+
'NoDateFieldNames': `Solution: ${DOCS_URL}#toc-no-date-filed-names`,
|
|
14
|
+
'NoFirstDay': `Solution: ${DOCS_URL}#toc-no-first-day`,
|
|
15
|
+
'NoGMTInfo': `Solution: ${DOCS_URL}#toc-no-gmt-info`,
|
|
16
|
+
'NoLocale': `Solution: ${DOCS_URL}#toc-no-locale`,
|
|
17
|
+
'NoValidCurrency': `Solution: ${DOCS_URL}#toc-no-valid-currency`,
|
|
18
|
+
'NoWeekData': `Solution: ${DOCS_URL}#toc-no-week-data`
|
|
19
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
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 intl from '@progress/kendo-intl';
|
|
6
|
+
import { errorSolutions } from './error-solutions';
|
|
7
|
+
function formatMessage(error) {
|
|
8
|
+
const message = error.message;
|
|
9
|
+
const errorSolution = errorSolutions[Object.keys(errorSolutions).filter(key => message.indexOf(key) === 0)[0]];
|
|
10
|
+
return errorSolution ? `${message} ${errorSolution}` : message;
|
|
11
|
+
}
|
|
12
|
+
function intlMethod(fn) {
|
|
13
|
+
return function (...values) {
|
|
14
|
+
try {
|
|
15
|
+
return fn.apply(null, values);
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
error.message = formatMessage(error);
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @hidden
|
|
25
|
+
*/
|
|
26
|
+
export const dateFormatNames = intlMethod(intl.dateFormatNames);
|
|
27
|
+
/**
|
|
28
|
+
* @hidden
|
|
29
|
+
*/
|
|
30
|
+
export const dateFieldName = intlMethod(intl.dateFieldName);
|
|
31
|
+
/**
|
|
32
|
+
* @hidden
|
|
33
|
+
*/
|
|
34
|
+
export const firstDay = intlMethod(intl.firstDay);
|
|
35
|
+
/**
|
|
36
|
+
* @hidden
|
|
37
|
+
*/
|
|
38
|
+
export const format = intlMethod(intl.format);
|
|
39
|
+
/**
|
|
40
|
+
* @hidden
|
|
41
|
+
*/
|
|
42
|
+
export const formatDate = intlMethod(intl.formatDate);
|
|
43
|
+
/**
|
|
44
|
+
* @hidden
|
|
45
|
+
*/
|
|
46
|
+
export const formatNumber = intlMethod(intl.formatNumber);
|
|
47
|
+
/**
|
|
48
|
+
* @hidden
|
|
49
|
+
*/
|
|
50
|
+
export const load = intlMethod(intl.load);
|
|
51
|
+
/**
|
|
52
|
+
* @hidden
|
|
53
|
+
*/
|
|
54
|
+
export const numberSymbols = intlMethod(intl.numberSymbols);
|
|
55
|
+
/**
|
|
56
|
+
* @hidden
|
|
57
|
+
*/
|
|
58
|
+
export const parseDate = intlMethod(intl.parseDate);
|
|
59
|
+
/**
|
|
60
|
+
* @hidden
|
|
61
|
+
*/
|
|
62
|
+
export const parseNumber = intlMethod(intl.parseNumber);
|
|
63
|
+
/**
|
|
64
|
+
* @hidden
|
|
65
|
+
*/
|
|
66
|
+
export const splitDateFormat = intlMethod(intl.splitDateFormat);
|
|
67
|
+
/**
|
|
68
|
+
* @hidden
|
|
69
|
+
*/
|
|
70
|
+
export const toString = intlMethod(intl.toString);
|
|
71
|
+
/**
|
|
72
|
+
* @hidden
|
|
73
|
+
*/
|
|
74
|
+
export const weekendRange = intlMethod(intl.weekendRange);
|
|
75
|
+
/**
|
|
76
|
+
* Sets a pre-built locale.
|
|
77
|
+
*
|
|
78
|
+
* @params data - The pre-built locale data.
|
|
79
|
+
*/
|
|
80
|
+
export const setData = (data) => intl.setData(data);
|
|
81
|
+
/**
|
|
82
|
+
* Retrieves the locale data for the specified locale.
|
|
83
|
+
*
|
|
84
|
+
* @params locale - The locale id.
|
|
85
|
+
* @returns data - The locale data.
|
|
86
|
+
*/
|
|
87
|
+
export const localeData = (locale) => {
|
|
88
|
+
try {
|
|
89
|
+
return intl.localeInfo(locale);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
error.message = formatMessage(error);
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
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 { NgModule } from '@angular/core';
|
|
6
|
+
import { DatePipe } from './date.pipe';
|
|
7
|
+
import { NumberPipe } from './number.pipe';
|
|
8
|
+
import * as i0 from "@angular/core";
|
|
9
|
+
const pipes = [
|
|
10
|
+
DatePipe,
|
|
11
|
+
NumberPipe
|
|
12
|
+
];
|
|
13
|
+
/**
|
|
14
|
+
* Represents the [NgModule]({{ site.data.urls.angular['ngmoduleapi'] }}docs/ts/latest/guide/ngmodule.html)
|
|
15
|
+
* definition for the Intl services.
|
|
16
|
+
*/
|
|
17
|
+
export class IntlModule {
|
|
18
|
+
}
|
|
19
|
+
IntlModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IntlModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
20
|
+
IntlModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IntlModule, declarations: [DatePipe,
|
|
21
|
+
NumberPipe], exports: [DatePipe,
|
|
22
|
+
NumberPipe] });
|
|
23
|
+
IntlModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IntlModule });
|
|
24
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IntlModule, decorators: [{
|
|
25
|
+
type: NgModule,
|
|
26
|
+
args: [{
|
|
27
|
+
declarations: [pipes],
|
|
28
|
+
exports: [pipes]
|
|
29
|
+
}]
|
|
30
|
+
}] });
|
|
@@ -0,0 +1,249 @@
|
|
|
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 { Injectable, EventEmitter, Inject, LOCALE_ID } from '@angular/core';
|
|
6
|
+
import { validatePackage } from '@progress/kendo-licensing';
|
|
7
|
+
import { packageMetadata } from './package-metadata';
|
|
8
|
+
import { formatDate, parseDate, dateFieldName, dateFormatNames, firstDay, splitDateFormat, weekendRange, format as intlFormat, toString, parseNumber, formatNumber, numberSymbols } from './intl-members';
|
|
9
|
+
import * as i0 from "@angular/core";
|
|
10
|
+
const LOCALE_REGEX = /_/g;
|
|
11
|
+
/**
|
|
12
|
+
* @hidden
|
|
13
|
+
*/
|
|
14
|
+
export function cldrServiceFactory(localeId) {
|
|
15
|
+
return new CldrIntlService(localeId);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* An abstract base class that implements
|
|
19
|
+
* the Internationalization service methods
|
|
20
|
+
* for the current locale.
|
|
21
|
+
*/
|
|
22
|
+
export class IntlService {
|
|
23
|
+
/**
|
|
24
|
+
* @hidden
|
|
25
|
+
*/
|
|
26
|
+
constructor() {
|
|
27
|
+
/**
|
|
28
|
+
* @hidden
|
|
29
|
+
*/
|
|
30
|
+
this.changes = new EventEmitter();
|
|
31
|
+
validatePackage(packageMetadata);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Notifies that the service was changed.
|
|
35
|
+
*/
|
|
36
|
+
notify() {
|
|
37
|
+
this.changes.emit();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
IntlService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IntlService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
41
|
+
IntlService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IntlService, providedIn: 'root', useFactory: cldrServiceFactory, deps: [{ token: LOCALE_ID }] });
|
|
42
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: IntlService, decorators: [{
|
|
43
|
+
type: Injectable,
|
|
44
|
+
args: [{
|
|
45
|
+
providedIn: 'root',
|
|
46
|
+
useFactory: cldrServiceFactory,
|
|
47
|
+
deps: [LOCALE_ID]
|
|
48
|
+
}]
|
|
49
|
+
}], ctorParameters: function () { return []; } });
|
|
50
|
+
/**
|
|
51
|
+
* The Internationalization service implemented by using
|
|
52
|
+
* the CLDR Database via the `@progress/kendo-intl` package.
|
|
53
|
+
*/
|
|
54
|
+
export class CldrIntlService extends IntlService {
|
|
55
|
+
/**
|
|
56
|
+
* Creates a new instance of the service with the ID of the specified locale.
|
|
57
|
+
*
|
|
58
|
+
* Note that the parts of the locale ID can be separated by either `_` (underscore)
|
|
59
|
+
* or `-` (dash).
|
|
60
|
+
*
|
|
61
|
+
* @param localeId - The default locale ID.
|
|
62
|
+
*/
|
|
63
|
+
constructor(localeId) {
|
|
64
|
+
super();
|
|
65
|
+
this.localeId = localeId;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Gets or sets the current locale ID.
|
|
69
|
+
*/
|
|
70
|
+
get localeId() {
|
|
71
|
+
return this.locale;
|
|
72
|
+
}
|
|
73
|
+
set localeId(value) {
|
|
74
|
+
// Angular locales use underscore, for example, en_US
|
|
75
|
+
// while IETF BCP-47 specifies a dash.
|
|
76
|
+
// https://tools.ietf.org/html/bcp47
|
|
77
|
+
const locale = value.replace(LOCALE_REGEX, '-');
|
|
78
|
+
if (locale !== this.locale) {
|
|
79
|
+
this.locale = locale;
|
|
80
|
+
this.notify();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Formats a string with placeholders such as
|
|
85
|
+
* `Total amount {0:c}`.
|
|
86
|
+
*
|
|
87
|
+
* @param format - The format string.
|
|
88
|
+
* @param values - One or more values to output in the format string placeholders.
|
|
89
|
+
* @return - The formatted string.
|
|
90
|
+
*/
|
|
91
|
+
format(format, ...values) {
|
|
92
|
+
return intlFormat(format, values, this.localeId);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Converts an object into a string based on the specified format.
|
|
96
|
+
*
|
|
97
|
+
* @param value - The value to format.
|
|
98
|
+
* @param format - The format to use.
|
|
99
|
+
* @param localeId - The locale ID to use in place of the default one. Optional.
|
|
100
|
+
* @return The formatted object.
|
|
101
|
+
*/
|
|
102
|
+
toString(value, format, localeId) {
|
|
103
|
+
return toString(value, format, localeId || this.localeId);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Converts a `Date` object into a string based on the specified format.
|
|
107
|
+
* If no format is provided, the default short date format is used.
|
|
108
|
+
*
|
|
109
|
+
* @param value - The date to format.
|
|
110
|
+
* @param format - The format string or options.
|
|
111
|
+
* @param localeId - The locale ID to use in place of the default one. Optional.
|
|
112
|
+
* @return The formatted date.
|
|
113
|
+
*/
|
|
114
|
+
formatDate(value, format, localeId) {
|
|
115
|
+
return formatDate(value, format, localeId || this.localeId);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Converts a string into a `Date` object based on the specified format.
|
|
119
|
+
*
|
|
120
|
+
* @param value - The string to convert.
|
|
121
|
+
* @param format - The format strings or options.
|
|
122
|
+
* @param localeId - The locale ID to use in place of the default one. Optional.
|
|
123
|
+
* @return The parsed date.
|
|
124
|
+
*/
|
|
125
|
+
parseDate(value, format, localeId) {
|
|
126
|
+
return parseDate(value, format, localeId || this.localeId);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Converts a string into a `Number`.
|
|
130
|
+
*
|
|
131
|
+
* @param value - The string to convert.
|
|
132
|
+
* @param format - The format string or options.
|
|
133
|
+
* @param localeId - The locale ID to use in place of the default one. Optional.
|
|
134
|
+
* @return The parsed number.
|
|
135
|
+
*/
|
|
136
|
+
parseNumber(value, format, localeId) {
|
|
137
|
+
return parseNumber(value, localeId || this.localeId, format);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Converts a `Number` into a string based on the specified format.
|
|
141
|
+
*
|
|
142
|
+
* @param value - The number to format.
|
|
143
|
+
* @param format - The format string or options.
|
|
144
|
+
* @param localeId - The locale ID to use in place of the default one. Optional.
|
|
145
|
+
* @return The formatted number.
|
|
146
|
+
*/
|
|
147
|
+
formatNumber(value, format, localeId) {
|
|
148
|
+
return formatNumber(value, format, localeId || this.localeId);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Returns the date names from the current locale based on the option.
|
|
152
|
+
*
|
|
153
|
+
* The available `type` values are:
|
|
154
|
+
* - `era`
|
|
155
|
+
* - `year`
|
|
156
|
+
* - `quarter`
|
|
157
|
+
* - `month`
|
|
158
|
+
* - `week`
|
|
159
|
+
* - `day`
|
|
160
|
+
* - `dayperiod`
|
|
161
|
+
* - `hour`
|
|
162
|
+
* - `minute`
|
|
163
|
+
* - `second`
|
|
164
|
+
* - `zone`
|
|
165
|
+
*
|
|
166
|
+
* The available `nameType` values are:
|
|
167
|
+
* - `wide`
|
|
168
|
+
* - `narrow`
|
|
169
|
+
* - `short`
|
|
170
|
+
*
|
|
171
|
+
* @param options - Detailed configuration for the desired date field name.
|
|
172
|
+
* @param localeId - The locale ID to use in place of the default one. Optional.
|
|
173
|
+
* @return - The day names from the current locale based on the option.
|
|
174
|
+
* @returns The localized date field name from the current locale based on the option.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```
|
|
178
|
+
* dateFieldName({ type: 'day' }); //returns 'day';
|
|
179
|
+
* dateFieldName({ type: 'day', nameType: 'wide' }); //returns 'day';
|
|
180
|
+
* dateFieldName({ type: 'month', nameType: 'short' }); //returns 'mo.';
|
|
181
|
+
* dateFieldName({ type: 'month', nameType: 'wide' }); //returns 'month';
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
dateFieldName(options, localeId) {
|
|
185
|
+
return dateFieldName(options, localeId || this.localeId);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Returns a localized date field name based on specific dateFieldName options.
|
|
189
|
+
*
|
|
190
|
+
* The available type values are:
|
|
191
|
+
* - `day`
|
|
192
|
+
* - `dayperiod`
|
|
193
|
+
* - `months`
|
|
194
|
+
* - `quarters`
|
|
195
|
+
* - `eras`
|
|
196
|
+
*
|
|
197
|
+
* @param options - Detailed configuration for the desired date format.
|
|
198
|
+
* @param localeId - The locale ID to use in place of the default one. Optional.
|
|
199
|
+
* @return - The day names from the current locale based on the option.
|
|
200
|
+
*/
|
|
201
|
+
dateFormatNames(options, localeId) {
|
|
202
|
+
return dateFormatNames(localeId || this.localeId, options);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Splits the date format into objects containing information about each part of the pattern.
|
|
206
|
+
*
|
|
207
|
+
* @param format The format string or options.
|
|
208
|
+
* @param localeId The optional locale id. If not specified, the `"en"` locale id is used.
|
|
209
|
+
* @returns The date format parts.
|
|
210
|
+
*/
|
|
211
|
+
splitDateFormat(format, localeId) {
|
|
212
|
+
return splitDateFormat(format, localeId || this.localeId);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Returns the number symbols from the current locale based on the option.
|
|
216
|
+
*
|
|
217
|
+
* @param localeId - The locale ID to use in place of the default one. Optional.
|
|
218
|
+
* @return - The number symbols from the current locale.
|
|
219
|
+
*/
|
|
220
|
+
numberSymbols(localeId) {
|
|
221
|
+
return numberSymbols(localeId || this.localeId);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Returns the first day index starting from Sunday.
|
|
225
|
+
*
|
|
226
|
+
* @param localeId - The locale ID. Defaults to the current locale ID.
|
|
227
|
+
* @return - The index of the first day of the week (0 == Sunday).
|
|
228
|
+
*/
|
|
229
|
+
firstDay(localeId) {
|
|
230
|
+
return firstDay(localeId || this.localeId);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Returns the start and end index of the locale weekend starting from Sunday.
|
|
234
|
+
*
|
|
235
|
+
* @param localeId - The locale ID. Defaults to the current locale ID.
|
|
236
|
+
* @return - The the start and end index of the locale weekend (0 == Sunday).
|
|
237
|
+
*/
|
|
238
|
+
weekendRange(localeId) {
|
|
239
|
+
return weekendRange(localeId || this.localeId);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
CldrIntlService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: CldrIntlService, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
243
|
+
CldrIntlService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: CldrIntlService });
|
|
244
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: CldrIntlService, decorators: [{
|
|
245
|
+
type: Injectable
|
|
246
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
247
|
+
type: Inject,
|
|
248
|
+
args: [LOCALE_ID]
|
|
249
|
+
}] }]; } });
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* Generated bundle index. Do not edit.
|
|
7
|
+
*/
|
|
8
|
+
export * from './main';
|
|
@@ -0,0 +1,5 @@
|
|
|
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
|
+
export {};
|
package/esm2015/main.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
export * from './intl.service';
|
|
6
|
+
export * from './date.pipe';
|
|
7
|
+
export * from './number.pipe';
|
|
8
|
+
export * from './intl.module';
|
|
9
|
+
export * from './intl-members';
|
|
10
|
+
export * from './locale-data.interface';
|
|
@@ -0,0 +1,55 @@
|
|
|
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 { Pipe } from '@angular/core';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
import * as i1 from "./intl.service";
|
|
8
|
+
/**
|
|
9
|
+
* Formats a number value to a string based on the requested format.
|
|
10
|
+
* This pipe uses the [`IntlService`]({% slug api_intl_intlservice %}).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ng-template-no-run
|
|
14
|
+
* <ul>
|
|
15
|
+
* <li>{{decimal | kendoNumber:'c' }}</li>
|
|
16
|
+
* <li>{{stringNumber | kendoNumber:'p' }}</li>
|
|
17
|
+
* <li>{{int | kendoNumber:'##.00' }}</li>
|
|
18
|
+
* </ul>
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export class NumberPipe {
|
|
22
|
+
/**
|
|
23
|
+
* @hidden
|
|
24
|
+
*/
|
|
25
|
+
constructor(intlService) {
|
|
26
|
+
this.intlService = intlService;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Converts a `Number` object into a string based on the specified format.
|
|
30
|
+
* If no format is provided, the value is formatted as decimal number using the
|
|
31
|
+
* [`"n"`](https://github.com/telerik/kendo-intl/blob/master/docs/num-formatting/index.md#standard) format.
|
|
32
|
+
*
|
|
33
|
+
* @param value - The numer that will be formatted.
|
|
34
|
+
* @param format - The format string or options.
|
|
35
|
+
* @param localeId - (Optional) The locale ID that will be used in place of the default one.
|
|
36
|
+
* @return - The formatted number.
|
|
37
|
+
*/
|
|
38
|
+
transform(value, format, localeId) {
|
|
39
|
+
if (typeof value === 'string') {
|
|
40
|
+
value = this.intlService.parseNumber(value);
|
|
41
|
+
}
|
|
42
|
+
if (value !== null && value !== undefined) {
|
|
43
|
+
return this.intlService.formatNumber(value, format, localeId);
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
NumberPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: NumberPipe, deps: [{ token: i1.IntlService }], target: i0.ɵɵFactoryTarget.Pipe });
|
|
49
|
+
NumberPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: NumberPipe, name: "kendoNumber" });
|
|
50
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: NumberPipe, decorators: [{
|
|
51
|
+
type: Pipe,
|
|
52
|
+
args: [{
|
|
53
|
+
name: 'kendoNumber'
|
|
54
|
+
}]
|
|
55
|
+
}], ctorParameters: function () { return [{ type: i1.IntlService }]; } });
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* @hidden
|
|
7
|
+
*/
|
|
8
|
+
export const packageMetadata = {
|
|
9
|
+
name: '@progress/kendo-angular-intl',
|
|
10
|
+
productName: 'Kendo UI for Angular',
|
|
11
|
+
productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
|
|
12
|
+
publishDate: 1654611794,
|
|
13
|
+
version: '',
|
|
14
|
+
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'
|
|
15
|
+
};
|