angular-ecmascript-intl
Advanced tools
Comparing version
@@ -10,6 +10,7 @@ import * as i0 from "@angular/core"; | ||
import * as i8 from "./list/intl-list.pipe"; | ||
import * as i9 from "./relative-time/relative-time.pipe"; | ||
export declare class IntlModule { | ||
static ɵfac: i0.ɵɵFactoryDeclaration<IntlModule, never>; | ||
static ɵmod: i0.ɵɵNgModuleDeclaration<IntlModule, never, [typeof i1.IntlDatePipe, typeof i2.IntlLanguagePipe, typeof i3.IntlDecimalPipe, typeof i4.IntlPercentPipe, typeof i5.IntlCurrencyPipe, typeof i6.IntlCountryPipe, typeof i7.IntlUnitPipe, typeof i8.IntlListPipe], [typeof i1.IntlDatePipe, typeof i2.IntlLanguagePipe, typeof i3.IntlDecimalPipe, typeof i4.IntlPercentPipe, typeof i5.IntlCurrencyPipe, typeof i6.IntlCountryPipe, typeof i7.IntlUnitPipe, typeof i8.IntlListPipe]>; | ||
static ɵmod: i0.ɵɵNgModuleDeclaration<IntlModule, never, [typeof i1.IntlDatePipe, typeof i2.IntlLanguagePipe, typeof i3.IntlDecimalPipe, typeof i4.IntlPercentPipe, typeof i5.IntlCurrencyPipe, typeof i6.IntlCountryPipe, typeof i7.IntlUnitPipe, typeof i8.IntlListPipe, typeof i9.IntlRelativeTimePipe], [typeof i1.IntlDatePipe, typeof i2.IntlLanguagePipe, typeof i3.IntlDecimalPipe, typeof i4.IntlPercentPipe, typeof i5.IntlCurrencyPipe, typeof i6.IntlCountryPipe, typeof i7.IntlUnitPipe, typeof i8.IntlListPipe, typeof i9.IntlRelativeTimePipe]>; | ||
static ɵinj: i0.ɵɵInjectorDeclaration<IntlModule>; | ||
} |
@@ -6,2 +6,2 @@ import { InjectionToken } from "@angular/core"; | ||
*/ | ||
export declare const INTL_LOCALES: InjectionToken<string | string[]>; | ||
export declare const INTL_LOCALES: InjectionToken<string | string[] | undefined>; |
{ | ||
"name": "angular-ecmascript-intl", | ||
"version": "0.4.0", | ||
"version": "1.0.0", | ||
"peerDependencies": { | ||
@@ -5,0 +5,0 @@ "@angular/common": "^15.1.0", |
@@ -17,3 +17,4 @@ export * from './lib/country/intl-country.pipe'; | ||
export * from './lib/percent/intl-percent-pipe-default-options'; | ||
export * from './lib/relative-time/relative-time.pipe'; | ||
export * from './lib/unit/intl-unit.pipe'; | ||
export * from './lib/unit/intl-unit-pipe-default-options'; |
104
README.md
@@ -47,2 +47,4 @@ # Angular ECMAScript Intl | ||
Also, every pipe accepts the `locale` option. | ||
Now you can use the pipes, see below. | ||
@@ -68,5 +70,8 @@ | ||
The options are a subset of the options for `new Intl.DateTimeFormat()`. For a list of the options, see | ||
their [docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#options). | ||
The following options are supported: | ||
* [`dateStyle`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#datestyle) | ||
* [`timeStyle`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#timestyle) | ||
* [`hour12`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#hour12) | ||
With the `INTL_DATE_PIPE_DEFAULT_OPTIONS` injection token you can specify default options. | ||
@@ -89,5 +94,12 @@ | ||
The options are a subset of the options for `new Intl.NumberFormat()`. For a list of the options, see | ||
their [docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options). | ||
The following options are supported: | ||
* [`notation`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#notation) | ||
* [`signDisplay`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#signdisplay) | ||
* [`minimumIntegerDigits`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumintegerdigits) | ||
* [`minimumFractionDigits`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumfractiondigits) | ||
* [`maximumFractionDigits`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#maximumfractiondigits) | ||
* [`minimumSignificantDigits`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumsignificantdigits) | ||
* [`maximumSignificantDigits`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#maximumsignificantdigits) | ||
With the `INTL_DECIMAL_PIPE_DEFAULT_OPTIONS` injection token you can specify default options. | ||
@@ -110,5 +122,12 @@ | ||
The options are a subset of the options for `new Intl.NumberFormat()`. For a list of the options, see | ||
their [docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options). | ||
The following options are supported: | ||
* [`notation`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#notation) | ||
* [`signDisplay`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#signdisplay) | ||
* [`minimumIntegerDigits`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumintegerdigits) | ||
* [`minimumFractionDigits`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumfractiondigits) | ||
* [`maximumFractionDigits`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#maximumfractiondigits) | ||
* [`minimumSignificantDigits`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumsignificantdigits) | ||
* [`maximumSignificantDigits`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#maximumsignificantdigits) | ||
With the `INTL_PERCENT_PIPE_DEFAULT_OPTIONS` injection token you can specify default options. | ||
@@ -134,5 +153,14 @@ | ||
The options are a subset of the options for `new Intl.NumberFormat()`. For a list of the options, see | ||
their [docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options). | ||
The following additional options are supported: | ||
* [`currencyDisplay`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencydisplay) | ||
* [`currencySign`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencysign) | ||
* [`notation`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#notation) | ||
* [`signDisplay`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#signdisplay) | ||
* [`minimumIntegerDigits`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumintegerdigits) | ||
* [`minimumFractionDigits`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumfractiondigits) | ||
* [`maximumFractionDigits`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#maximumfractiondigits) | ||
* [`minimumSignificantDigits`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumsignificantdigits) | ||
* [`maximumSignificantDigits`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#maximumsignificantdigits) | ||
With the `INTL_CURRENCY_PIPE_DEFAULT_OPTIONS` injection token you can specify default options. | ||
@@ -154,5 +182,6 @@ | ||
The options are a subset of the options for `new Intl.DisplayNames()`. For a list of the options, see | ||
their [docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames#options). | ||
The following option is supported: | ||
* [`languageDisplay`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames#languagedisplay) | ||
With the `INTL_LANGUAGE_PIPE_DEFAULT_OPTIONS` injection token you can specify default options. | ||
@@ -174,7 +203,2 @@ | ||
The options are a subset of the options for `new Intl.DisplayNames()`. For a list of the options, see | ||
their [docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames#options). | ||
With the `INTL_COUNTRY_PIPE_DEFAULT_OPTIONS` injection token you can specify default options. | ||
### Unit pipe | ||
@@ -199,5 +223,13 @@ | ||
The options are a subset of the options for `new Intl.NumberFormat()`. For a list of the options, see | ||
their [docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options). | ||
The following additional options are supported: | ||
* [`unitDisplay`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#unitdisplay) | ||
* [`notation`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#notation) | ||
* [`signDisplay`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#signdisplay) | ||
* [`minimumIntegerDigits`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumintegerdigits) | ||
* [`minimumFractionDigits`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumfractiondigits) | ||
* [`maximumFractionDigits`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#maximumfractiondigits) | ||
* [`minimumSignificantDigits`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumsignificantdigits) | ||
* [`maximumSignificantDigits`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#maximumsignificantdigits) | ||
With the `INTL_UNIT_PIPE_DEFAULT_OPTIONS` injection token you can specify default options. | ||
@@ -219,15 +251,37 @@ | ||
The options are a subset of the options for `new Intl.ListFormat()`. For a list of the options, see | ||
their [docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#options). | ||
The following options are supported: | ||
* [`type`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#type) | ||
* [`style`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#style) | ||
With the `INTL_LIST_PIPE_DEFAULT_OPTIONS` injection token you can specify default options. | ||
## Relative Time (timeago) pipe | ||
The relative time format will format the input date compared to the current date in a "timeago" format. Every minute, | ||
the value will be updated automatically. | ||
Use the relative time pipe like the following: | ||
``` | ||
{{myDate | intlRelativeTime: options}} | ||
``` | ||
The input date can be one of the following: | ||
* `Date` object | ||
* number (UNIX timestamp) | ||
* string (will be parsed by `new Date()` constructor) | ||
* null | ||
* undefined | ||
The following options are supported: | ||
* [`numeric`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#numeric) | ||
* [`style`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#style) | ||
With the `INTL_RELATIVE_TIME_PIPE_DEFAULT_OPTIONS` injection token you can specify default options. | ||
## Background | ||
For more context, see the following [GitHub issue](https://github.com/angular/angular/issues/49143) | ||
## Feature Roadmap | ||
* Performance: Prepare Intl.* object with default options, only construct new object when necessary | ||
* Relative time pipe | ||
* Migration Schematics for usages of Angular pipes |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
229172
26.09%54
8%1772
21.87%1
-50%279
24%