Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@internationalized/message/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"dependencies": {
"@babel/runtime": "^7.6.2",
"intl-messageformat": "^2.2.0"
"intl-messageformat": "^9.6.12"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 2 additions & 1 deletion packages/@internationalized/message/src/MessageFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* governing permissions and limitations under the License.
*/

import {FormatXMLElementFn, PrimitiveType} from 'intl-messageformat/src/formatters';
import IntlMessageFormat from 'intl-messageformat';
import {MessageDictionary} from './MessageDictionary';

Expand All @@ -27,7 +28,7 @@ export class MessageFormatter {
this.cache = {};
}

format(key: string, variables: object) {
format<T = void>(key: string, variables: Record<string, PrimitiveType | T | FormatXMLElementFn<T, string | T | (string | T)[]>> | undefined) {
let message = this.cache[key];
if (!message) {
let msg = this.messages.getStringForLocale(key, this.locale);
Expand Down
2 changes: 1 addition & 1 deletion packages/@internationalized/number/src/NumberFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function getCachedNumberFormatter(locale: string, options: NumberFormatOptions =
}

/** @private - exported for tests */
export function numberFormatSignDisplayPolyfill(numberFormat: Intl.NumberFormat, signDisplay: 'always' | 'exceptZero' | 'auto' | 'never', num: number) {
export function numberFormatSignDisplayPolyfill(numberFormat: Intl.NumberFormat, signDisplay: string, num: number) {
if (signDisplay === 'auto') {
return numberFormat.format(num);
} else if (signDisplay === 'never') {
Expand Down
103 changes: 80 additions & 23 deletions packages/dev/intl-types-extension/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,93 @@
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
declare namespace Intl {

type UnicodeBCP47LocaleIdentifier = string;

type RelativeTimeFormatUnit =
| 'year' | 'years'
| 'quarter' | 'quarters'
| 'month' | 'months'
| 'week' | 'weeks'
| 'day' | 'days'
| 'hour' | 'hours'
| 'minute' | 'minutes'
| 'second' | 'seconds'
;

type RelativeTimeFormatLocaleMatcher = 'lookup' | 'best fit';

type RelativeTimeFormatNumeric = 'always' | 'auto';

type RelativeTimeFormatStyle = 'long' | 'short' | 'narrow';

interface RelativeTimeFormatOptions {
localeMatcher?: RelativeTimeFormatLocaleMatcher,
numeric?: RelativeTimeFormatNumeric,
style?: RelativeTimeFormatStyle
}

interface ResolvedRelativeTimeFormatOptions {
locale: UnicodeBCP47LocaleIdentifier,
style: RelativeTimeFormatStyle,
numeric: RelativeTimeFormatNumeric,
numberingSystem: string
}

interface RelativeTimeFormatPart {
type: string,
value: string,
unit?: RelativeTimeFormatUnit
}

interface RelativeTimeFormat {
format(
value: number,
unit: RelativeTimeFormatUnit
): string,

formatToParts(
value: number,
unit: RelativeTimeFormatUnit
): RelativeTimeFormatPart[],

resolvedOptions(): ResolvedRelativeTimeFormatOptions
}

const RelativeTimeFormat: {
new(
locales?: UnicodeBCP47LocaleIdentifier | UnicodeBCP47LocaleIdentifier[],
options?: RelativeTimeFormatOptions
): RelativeTimeFormat,

supportedLocalesOf(
locales?: UnicodeBCP47LocaleIdentifier | UnicodeBCP47LocaleIdentifier[],
options?: RelativeTimeFormatOptions
): UnicodeBCP47LocaleIdentifier[]
};

declare namespace Intl {
interface NumberFormatOptions {
currencySign?: string,
signDisplay?: 'always' | 'exceptZero' | 'auto' | 'never',
compactDisplay?: string,
notation?: string,
signDisplay?: string,
unit?: string,
unitDisplay?: string
}

interface ResolvedNumberFormatOptions {
compactDisplay?: string,
currencySign?: string,
signDisplay?: 'always' | 'exceptZero' | 'auto' | 'never',
notation?: string,
signDisplay?: string,
unit?: string,
unitDisplay?: string
}
// eslint-disable-next-line no-undef
type NumberFormatPartTypesExtension = NumberFormatPartTypes | 'unit'
interface NumberFormatPartExtension {
type: NumberFormatPartTypesExtension,
value: string
}
interface NumberFormat {
formatToParts(number?: number): NumberFormatPartExtension[]

interface DateTimeFormatOptions {
dateStyle?: 'full' | 'long' | 'medium' | 'short',
timeStyle?: 'full' | 'long' | 'medium' | 'short',
calendar?: string,
dayPeriod?: 'narrow' | 'short' | 'long',
numberingSystem?: string,
hourCycle?: 'h11' | 'h12' | 'h23' | 'h24',
fractionalSecondDigits?: 0 | 1 | 2 | 3
}
}
51 changes: 41 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2209,6 +2209,35 @@
unique-filename "^1.1.1"
which "^1.3.1"

"@formatjs/[email protected]":
version "1.7.0"
resolved "https://registry.yarnpkg.com/@formatjs/ecma402-abstract/-/ecma402-abstract-1.7.0.tgz#440b341ba18451d53d9172e3110d96ca420b3760"
integrity sha512-0IQF4oDZdO8ruyrNJZuRle3F/YiGgRwTNrZyMI1N1X8GERZusOrXU9Stw+j/lyyfDWaJK44b+Qnri/qfLPCtGQ==
dependencies:
tslib "^2.1.0"

"@formatjs/[email protected]":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@formatjs/fast-memoize/-/fast-memoize-1.1.1.tgz#3006b58aca1e39a98aca213356b42da5d173f26b"
integrity sha512-mIqBr5uigIlx13eZTOPSEh2buDiy3BCdMYUtewICREQjbb4xarDiVWoXSnrERM7NanZ+0TAHNXSqDe6HpEFQUg==

"@formatjs/[email protected]":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@formatjs/icu-messageformat-parser/-/icu-messageformat-parser-2.0.0.tgz#a705da9c5040ebdee295147951cfaeb3e61a8ae0"
integrity sha512-NwbcVP6jtnL+4vpmlWJoBA2/vxrl57uw5jBq8Cb3bfYJLxdL01IRxh//hFBePvLi9cyTYJEC3ZfzIuEH4kyX+w==
dependencies:
"@formatjs/ecma402-abstract" "1.7.0"
"@formatjs/icu-skeleton-parser" "1.2.1"
tslib "^2.1.0"

"@formatjs/[email protected]":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@formatjs/icu-skeleton-parser/-/icu-skeleton-parser-1.2.1.tgz#aa3204b941b436cb88fea9269a6bdf10610336aa"
integrity sha512-mTpmCozmksatv3gQ+6/9dwwtoR+r+DFms22X6D6GLS4TaeaFKIPmC3k/DlsMGZIr3Q+dT+is5IcexChrPBGmCg==
dependencies:
"@formatjs/ecma402-abstract" "1.7.0"
tslib "^2.1.0"

"@iarna/toml@^2.2.0":
version "2.2.5"
resolved "https://registry.yarnpkg.com/@iarna/toml/-/toml-2.2.5.tgz#b32366c89b43c6f8cefbdefac778b9c828e3ba8c"
Expand Down Expand Up @@ -12918,17 +12947,14 @@ interpret@^2.0.0:
resolved "https://registry.yarnpkg.com/interpret/-/interpret-2.0.0.tgz#b783ffac0b8371503e9ab39561df223286aa5433"
integrity sha512-e0/LknJ8wpMMhTiWcjivB+ESwIuvHnBSlBbmP/pSb8CQJldoj1p2qv7xGZ/+BtbTziYRFSz8OsvdbiX45LtYQA==

[email protected]:
version "1.4.0"
resolved "https://registry.yarnpkg.com/intl-messageformat-parser/-/intl-messageformat-parser-1.4.0.tgz#b43d45a97468cadbe44331d74bb1e8dea44fc075"
integrity sha1-tD1FqXRoytvkQzHXS7Ho3qRPwHU=

intl-messageformat@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/intl-messageformat/-/intl-messageformat-2.2.0.tgz#345bcd46de630b7683330c2e52177ff5eab484fc"
integrity sha1-NFvNRt5jC3aDMwwuUhd/9eq0hPw=
intl-messageformat@^9.6.12:
version "9.6.12"
resolved "https://registry.yarnpkg.com/intl-messageformat/-/intl-messageformat-9.6.12.tgz#4794aa6b7beb74ec7dc7bffe7487bcf432c6cb87"
integrity sha512-4oLEiYRWq+GAYETFxYOaGPWb9CT7j9F5UavhXIvBdbcsLIbaQFAa3LQBJh/9/NgV0Y8ZTzX2z+A1sf2AzslWxw==
dependencies:
intl-messageformat-parser "1.4.0"
"@formatjs/fast-memoize" "1.1.1"
"@formatjs/icu-messageformat-parser" "2.0.0"
tslib "^2.1.0"

invariant@^2.2.2, invariant@^2.2.3, invariant@^2.2.4:
version "2.2.4"
Expand Down Expand Up @@ -22199,6 +22225,11 @@ tslib@^2.0.0, tslib@^2.0.1:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.1.0.tgz#da60860f1c2ecaa5703ab7d39bc05b6bf988b97a"
integrity sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==

tslib@^2.1.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.2.0.tgz#fb2c475977e35e241311ede2693cee1ec6698f5c"
integrity sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w==

tsutils@^3.17.1:
version "3.17.1"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.17.1.tgz#ed719917f11ca0dee586272b2ac49e015a2dd759"
Expand Down