use-intl 2.9.2-alpha.0 → 2.10.0-alpha.3
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/CHANGELOG.md +463 -0
- package/dist/core/use-intl.esm.js +140 -27
- package/dist/core/use-intl.esm.js.map +1 -1
- package/dist/core/use-intl.esm2.js +27 -140
- package/dist/core/use-intl.esm2.js.map +1 -1
- package/dist/core/use-intl.esm3.js +2 -2
- package/dist/core/use-intl.esm4.js +12 -56
- package/dist/core/use-intl.esm4.js.map +1 -1
- package/dist/core/use-intl.esm5.js +56 -12
- package/dist/core/use-intl.esm5.js.map +1 -1
- package/dist/core/use-intl.esm6.js +7 -29
- package/dist/core/use-intl.esm6.js.map +1 -1
- package/dist/core/use-intl.esm7.js +9 -9
- package/dist/core/use-intl.esm7.js.map +1 -1
- package/dist/core/use-intl.esm8.js +29 -7
- package/dist/core/use-intl.esm8.js.map +1 -1
- package/dist/react/IntlContext.d.ts +2 -19
- package/dist/react/IntlContextValue.d.ts +19 -0
- package/dist/react/IntlProvider.d.ts +2 -16
- package/dist/react/IntlProviderProps.d.ts +15 -0
- package/dist/react/getIntlContextValue.d.ts +18 -0
- package/dist/react/use-intl.esm.js +12 -21
- package/dist/react/use-intl.esm.js.map +1 -1
- package/dist/react/use-intl.esm10.js +44 -0
- package/dist/react/use-intl.esm10.js.map +1 -0
- package/dist/react/use-intl.esm2.js +2 -2
- package/dist/react/use-intl.esm3.js +20 -30
- package/dist/react/use-intl.esm3.js.map +1 -1
- package/dist/react/use-intl.esm4.js +46 -4
- package/dist/react/use-intl.esm4.js.map +1 -1
- package/dist/react/use-intl.esm5.js +1 -1
- package/dist/react/use-intl.esm6.js +4 -46
- package/dist/react/use-intl.esm6.js.map +1 -1
- package/dist/react/use-intl.esm7.js +3 -12
- package/dist/react/use-intl.esm7.js.map +1 -1
- package/dist/react/use-intl.esm8.js +30 -3
- package/dist/react/use-intl.esm8.js.map +1 -1
- package/dist/react/use-intl.esm9.js +9 -38
- package/dist/react/use-intl.esm9.js.map +1 -1
- package/dist/react/useIntlContext.d.ts +1 -1
- package/dist/src/core/AbstractIntlMessages.d.ts +9 -0
- package/dist/src/core/AbstractIntlMessages.js +2 -0
- package/dist/src/core/AbstractIntlMessages.js.map +1 -0
- package/dist/src/core/DateTimeFormatOptions.d.ts +72 -0
- package/dist/src/core/DateTimeFormatOptions.js +3 -0
- package/dist/src/core/DateTimeFormatOptions.js.map +1 -0
- package/dist/src/core/Formats.d.ts +7 -0
- package/dist/src/core/Formats.js +2 -0
- package/dist/src/core/Formats.js.map +1 -0
- package/dist/src/core/IntlConfiguration.d.ts +46 -0
- package/dist/src/core/IntlConfiguration.js +2 -0
- package/dist/src/core/IntlConfiguration.js.map +1 -0
- package/dist/src/core/IntlError.d.ts +13 -0
- package/dist/src/core/IntlError.js +23 -0
- package/dist/src/core/IntlError.js.map +1 -0
- package/dist/src/core/IntlMessages.d.ts +2 -0
- package/dist/src/core/IntlMessages.js +4 -0
- package/dist/src/core/IntlMessages.js.map +1 -0
- package/dist/src/core/NumberFormatOptions.d.ts +2 -0
- package/dist/src/core/NumberFormatOptions.js +2 -0
- package/dist/src/core/NumberFormatOptions.js.map +1 -0
- package/dist/src/core/TranslationValues.d.ts +5 -0
- package/dist/src/core/TranslationValues.js +2 -0
- package/dist/src/core/TranslationValues.js.map +1 -0
- package/dist/src/core/convertFormatsToIntlMessageFormat.d.ts +10 -0
- package/dist/src/core/convertFormatsToIntlMessageFormat.js +31 -0
- package/dist/src/core/convertFormatsToIntlMessageFormat.js.map +1 -0
- package/dist/src/core/createBaseTranslator.d.ts +26 -0
- package/dist/src/core/createBaseTranslator.js +185 -0
- package/dist/src/core/createBaseTranslator.js.map +1 -0
- package/dist/src/core/createIntl.d.ts +17 -0
- package/dist/src/core/createIntl.js +126 -0
- package/dist/src/core/createIntl.js.map +1 -0
- package/dist/src/core/createTranslator.d.ts +48 -0
- package/dist/src/core/createTranslator.js +24 -0
- package/dist/src/core/createTranslator.js.map +1 -0
- package/dist/src/core/createTranslatorImpl.d.ts +14 -0
- package/dist/src/core/createTranslatorImpl.js +43 -0
- package/dist/src/core/createTranslatorImpl.js.map +1 -0
- package/dist/src/core/defaults.d.ts +11 -0
- package/dist/src/core/defaults.js +11 -0
- package/dist/src/core/defaults.js.map +1 -0
- package/dist/src/core/index.d.ts +8 -0
- package/dist/src/core/index.js +4 -0
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/core/resolveNamespace.d.ts +5 -0
- package/dist/src/core/resolveNamespace.js +10 -0
- package/dist/src/core/resolveNamespace.js.map +1 -0
- package/dist/src/core/utils/MessageKeys.d.ts +5 -0
- package/dist/src/core/utils/MessageKeys.js +2 -0
- package/dist/src/core/utils/MessageKeys.js.map +1 -0
- package/dist/src/core/utils/NamespaceKeys.d.ts +5 -0
- package/dist/src/core/utils/NamespaceKeys.js +2 -0
- package/dist/src/core/utils/NamespaceKeys.js.map +1 -0
- package/dist/src/core/utils/NestedKeyOf.d.ts +4 -0
- package/dist/src/core/utils/NestedKeyOf.js +2 -0
- package/dist/src/core/utils/NestedKeyOf.js.map +1 -0
- package/dist/src/core/utils/NestedValueOf.d.ts +2 -0
- package/dist/src/core/utils/NestedValueOf.js +2 -0
- package/dist/src/core/utils/NestedValueOf.js.map +1 -0
- package/dist/src/core/validateMessages.d.ts +3 -0
- package/dist/src/core/validateMessages.js +22 -0
- package/dist/src/core/validateMessages.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +3 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/react/IntlContext.d.ts +4 -0
- package/dist/src/react/IntlContext.js +4 -0
- package/dist/src/react/IntlContext.js.map +1 -0
- package/dist/src/react/IntlContextValue.d.ts +19 -0
- package/dist/src/react/IntlContextValue.js +2 -0
- package/dist/src/react/IntlContextValue.js.map +1 -0
- package/dist/src/react/IntlProvider.d.ts +2 -0
- package/dist/src/react/IntlProvider.js +7 -0
- package/dist/src/react/IntlProvider.js.map +1 -0
- package/dist/src/react/IntlProviderProps.d.ts +15 -0
- package/dist/src/react/IntlProviderProps.js +2 -0
- package/dist/src/react/IntlProviderProps.js.map +1 -0
- package/dist/src/react/getIntlContextValue.d.ts +18 -0
- package/dist/src/react/getIntlContextValue.js +21 -0
- package/dist/src/react/getIntlContextValue.js.map +1 -0
- package/dist/src/react/index.d.ts +6 -0
- package/dist/src/react/index.js +7 -0
- package/dist/src/react/index.js.map +1 -0
- package/dist/src/react/useIntl.d.ts +5 -0
- package/dist/src/react/useIntl.js +14 -0
- package/dist/src/react/useIntl.js.map +1 -0
- package/dist/src/react/useIntlContext.d.ts +1 -0
- package/dist/src/react/useIntlContext.js +12 -0
- package/dist/src/react/useIntlContext.js.map +1 -0
- package/dist/src/react/useLocale.d.ts +1 -0
- package/dist/src/react/useLocale.js +5 -0
- package/dist/src/react/useLocale.js.map +1 -0
- package/dist/src/react/useNow.d.ts +23 -0
- package/dist/src/react/useNow.js +40 -0
- package/dist/src/react/useNow.js.map +1 -0
- package/dist/src/react/useTimeZone.d.ts +1 -0
- package/dist/src/react/useTimeZone.js +5 -0
- package/dist/src/react/useTimeZone.js.map +1 -0
- package/dist/src/react/useTranslations.d.ts +44 -0
- package/dist/src/react/useTranslations.js +21 -0
- package/dist/src/react/useTranslations.js.map +1 -0
- package/dist/src/react/useTranslationsImpl.d.ts +8 -0
- package/dist/src/react/useTranslationsImpl.js +35 -0
- package/dist/src/react/useTranslationsImpl.js.map +1 -0
- package/dist/use-intl.cjs.development.js +37 -28
- package/dist/use-intl.cjs.development.js.map +1 -1
- package/dist/use-intl.cjs.production.min.js +1 -1
- package/dist/use-intl.cjs.production.min.js.map +1 -1
- package/dist/use-intl.esm.js +6 -6
- package/package.json +6 -5
- package/src/core/createBaseTranslator.tsx +11 -7
- package/src/core/createIntl.tsx +2 -2
- package/src/core/createTranslatorImpl.tsx +1 -1
- package/src/react/IntlContext.tsx +2 -20
- package/src/react/IntlContextValue.tsx +21 -0
- package/src/react/IntlProvider.tsx +5 -36
- package/src/react/IntlProviderProps.tsx +17 -0
- package/src/react/getIntlContextValue.tsx +30 -0
- package/src/react/useIntlContext.tsx +1 -1
- package/LICENSE +0 -21
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## 2.9.1 (2022-11-03)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package use-intl
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# 2.9.0 (2022-10-27)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* Next.js 13 compatibility ([#140](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/140)) ([65326a0](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/65326a0b47980f260df466a283a6e7a0aa5e1cd0)), closes [#139](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/139)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# 2.8.0 (2022-10-18)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
* Provide `createTranslator` and `createIntl` by extracting a React-agnostic core library. Thanks to David Brands from Marvia for sponsoring the work on this feature, participating in discussion and providing feedback! ([#137](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/137)) ([91f7489](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/91f748972008b8587553b48aa36c95d7348b4b0c))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## 2.7.6 (2022-09-22)
|
|
37
|
+
|
|
38
|
+
**Note:** Version bump only for package use-intl
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## 2.7.5 (2022-08-30)
|
|
45
|
+
|
|
46
|
+
**Note:** Version bump only for package use-intl
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## 2.7.4 (2022-05-30)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
### Bug Fixes
|
|
56
|
+
|
|
57
|
+
* Adapt TypeScript validation to work with messages files that only have a single top-level namespace ([#115](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/115)) ([cf0b83e](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/cf0b83e3a591cfe87e17537c3ca0c7000cc70b1e))
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
## 2.7.3 (2022-05-20)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
### Bug Fixes
|
|
67
|
+
|
|
68
|
+
* Add back the ability to render the provider without messages ([#113](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/113)) ([8395822](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/8395822fa17cd0a04b88f8edce3b20e5e613fc78))
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## 2.7.2 (2022-05-10)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
### Bug Fixes
|
|
78
|
+
|
|
79
|
+
* Enable tree-shaking ([#108](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/108)) ([157b0e2](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/157b0e28376055e7e34e86007c51d008c8e214aa))
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
## 2.7.1 (2022-04-28)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
### Bug Fixes
|
|
89
|
+
|
|
90
|
+
* Allow null message values ([#110](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/110)) ([14ae8ff](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/14ae8ffdf1b295873f14081e2c3709d0f9bd2b9e))
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
# 2.7.0 (2022-04-28)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
### Features
|
|
100
|
+
|
|
101
|
+
* Warn for invalid namespace keys ([#106](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/106)) ([e86ab28](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/e86ab28b9180b866ce1a0a9173355d4b686b7d07))
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
# 2.6.0 (2022-04-08)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
### Features
|
|
111
|
+
|
|
112
|
+
* Support React 18 ([#98](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/98)) ([38614eb](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/38614eb9c6d6fb96704424d7f3ff8a67a24b789e))
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
# 2.5.0 (2022-04-01)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
### Features
|
|
122
|
+
|
|
123
|
+
* Type safe messages ([#93](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/93)) ([13b49b1](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/13b49b138bc0ec3adbe661af6a70dfabfe7e86b0))
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
## 2.4.1 (2022-03-24)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
### Bug Fixes
|
|
137
|
+
|
|
138
|
+
* Overwrite prerelease ([6caf5c4](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/6caf5c48a35179f802503bc6580469187765c837))
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
# [2.4.0](https://github.com/amannn/next-intl/tree/main/packages/use-intl/compare/v2.3.5...v2.4.0) (2022-02-08)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
### Features
|
|
148
|
+
|
|
149
|
+
* Default translation values ([#86](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/86)) ([0ed5e70](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/0ed5e70ffc57dcdb1b7b9270dbce9e8475b3f478))
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
## 2.3.5 (2022-01-19)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
### Bug Fixes
|
|
159
|
+
|
|
160
|
+
* Support identical wrappers with identical text content in rich text ([#80](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/80)) ([b35bb9f](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/b35bb9ffc5fa56c6260b6b424be3cd875f199aef))
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
## 2.3.4 (2022-01-04)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
### Bug Fixes
|
|
170
|
+
|
|
171
|
+
* Allow usage outside of Next.js (e.g. Jest and Storybook) ([#76](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/76)) ([7c6925b](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/7c6925b39338be95c1c940c67a1ae2f5e3f85cdd))
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
## 2.3.3 (2021-12-23)
|
|
178
|
+
|
|
179
|
+
**Note:** Version bump only for package use-intl
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
## 2.3.2 (2021-12-23)
|
|
186
|
+
|
|
187
|
+
**Note:** Version bump only for package use-intl
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
## 2.3.1 (2021-12-23)
|
|
194
|
+
|
|
195
|
+
**Note:** Version bump only for package use-intl
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
# 2.3.0 (2021-11-24)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
### Features
|
|
205
|
+
|
|
206
|
+
* Add `useLocale` and `useTimeZone` ([#67](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/67)) ([7833f4a](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/7833f4adc1aadc937cbaa550a968ef6f7b4f5ee1))
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
## 2.2.1 (2021-11-23)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
### Bug Fixes
|
|
216
|
+
|
|
217
|
+
* Clearer error message when no messages are provided ([#66](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/66)) ([742729a](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/742729aaddd63367efc2b79ef0cdf93545abdfb0))
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
# 2.2.0 (2021-11-02)
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
### Features
|
|
227
|
+
|
|
228
|
+
* TypeScript improvements: Use enum type for `style` of `NumberFormatOptions`, only allow passing React children to messages rendered with `t.rich` and update `tslib` ([#63](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/63)) ([d73e935](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/d73e9358bf13c87c0a653bd9fbed35e41548ff1d))
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
## 2.1.1 (2021-10-28)
|
|
235
|
+
|
|
236
|
+
**Note:** Version bump only for package use-intl
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
# 2.1.0 (2021-10-27)
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
### Features
|
|
246
|
+
|
|
247
|
+
* Support Next.js 12 ([#61](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/61)) ([0391cc8](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/0391cc85d3401bca9df29080a569957f6be93c85))
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
## 2.0.5 (2021-09-28)
|
|
254
|
+
|
|
255
|
+
**Note:** Version bump only for package use-intl
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
## 2.0.4 (2021-09-28)
|
|
262
|
+
|
|
263
|
+
**Note:** Version bump only for package use-intl
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
## 2.0.3 (2021-09-17)
|
|
270
|
+
|
|
271
|
+
**Note:** Version bump only for package use-intl
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
## 2.0.2 (2021-09-17)
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
### Bug Fixes
|
|
281
|
+
|
|
282
|
+
* Render correct messages when the namespace changes in `useTranslations` ([#58](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/58)) ([b8f7dab](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/b8f7dab0e3a213a91bdcd7929547cd01ba0b5f54))
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
## 2.0.1 (2021-09-04)
|
|
289
|
+
|
|
290
|
+
**Note:** Version bump only for package use-intl
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
# 2.0.0 (2021-08-26)
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
* feat!: Use a separate API for rich text formatting to avoid type casting in TypeScript #54 ([4c13a64](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/4c13a644ce99992d9e57887afe35a09b8e3d6572)), closes [#54](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/54)
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
### BREAKING CHANGES
|
|
303
|
+
|
|
304
|
+
* Instead of using the `t` function for formatting both regular messages and rich text, this function will only work for regular messages now. For rich text you can use `t.rich` instead now.
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
## 1.5.1 (2021-08-13)
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
### Bug Fixes
|
|
314
|
+
|
|
315
|
+
* Improve API for rendering raw messages and add docs ([#51](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/51)) ([19f4a7e](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/19f4a7e4e81e1cff78dc7e3f337dce69800be280))
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
# 1.5.0 (2021-08-10)
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
### Features
|
|
325
|
+
|
|
326
|
+
* Add flag to return raw messages ([#48](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/48)) ([b34e19f](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/b34e19ff618308b7d0c01e7969975215d96ff608))
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
## 1.4.7 (2021-08-02)
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
### Bug Fixes
|
|
336
|
+
|
|
337
|
+
* Adjust default for `onError` of the provider to log errors correctly ([#46](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/46)) ([d0a1986](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/d0a1986905e30acac40630e9ea6d099caad617fb))
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
## 1.4.6 (2021-08-02)
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
### Bug Fixes
|
|
347
|
+
|
|
348
|
+
* Use `timeZone` in translation function from `useTranslations` ([#45](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/45)) ([ebf75f2](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/ebf75f2add0ddc46f89768e9481bb16c56f94720))
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
## 1.4.5 (2021-07-26)
|
|
355
|
+
|
|
356
|
+
**Note:** Version bump only for package use-intl
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
## 1.4.4 (2021-07-08)
|
|
363
|
+
|
|
364
|
+
**Note:** Version bump only for package use-intl
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
## 1.4.3 (2021-07-08)
|
|
371
|
+
|
|
372
|
+
**Note:** Version bump only for package use-intl
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
## [1.4.2](https://github.com/amannn/next-intl/tree/main/packages/use-intl/compare/v1.4.1...v1.4.2) (2021-06-16)
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
### Bug Fixes
|
|
382
|
+
|
|
383
|
+
* Don't require `react-dom` as a peer dependency ([#39](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/39)) ([39edfcd](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/39edfcd9091e09570fc2152cda6a1e9ae5e7c210))
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
## 1.3.11 (2021-05-07)
|
|
390
|
+
|
|
391
|
+
**Note:** Version bump only for package use-intl
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
## 1.3.10 (2021-05-02)
|
|
398
|
+
|
|
399
|
+
**Note:** Version bump only for package use-intl
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
## 1.3.9 (2021-05-02)
|
|
406
|
+
|
|
407
|
+
**Note:** Version bump only for package use-intl
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
## 1.3.8 (2021-03-26)
|
|
414
|
+
|
|
415
|
+
**Note:** Version bump only for package use-intl
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
## 1.3.7 (2021-02-12)
|
|
422
|
+
|
|
423
|
+
**Note:** Version bump only for package use-intl
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
## 1.3.6 (2021-02-09)
|
|
430
|
+
|
|
431
|
+
**Note:** Version bump only for package use-intl
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
## 1.3.5 (2021-02-09)
|
|
438
|
+
|
|
439
|
+
**Note:** Version bump only for package use-intl
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
## 1.3.4 (2021-02-09)
|
|
446
|
+
|
|
447
|
+
**Note:** Version bump only for package use-intl
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
## [1.3.3](https://github.com/amannn/next-intl/tree/main/packages/use-intl/compare/v1.3.2...v1.3.3) (2021-02-09)
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
### Bug Fixes
|
|
457
|
+
|
|
458
|
+
* Update DateTimeFormatOptions ([#29](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/29)) ([91a8f52](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/91a8f5216a9ef2a0e76be6e3e8bd706f5c7496a3))
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
## Previous releases
|
|
462
|
+
|
|
463
|
+
See [next-intl changelog](https://github.com/amannn/next-intl/blob/main/CHANGELOG.md).
|
|
@@ -1,42 +1,155 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { extends as _extends } from '../_virtual/use-intl.esm.js';
|
|
2
|
+
import IntlError, { IntlErrorCode } from './use-intl.esm2.js';
|
|
3
|
+
import { defaultOnError } from './use-intl.esm4.js';
|
|
2
4
|
|
|
3
|
-
var
|
|
5
|
+
var MINUTE = 60;
|
|
6
|
+
var HOUR = MINUTE * 60;
|
|
7
|
+
var DAY = HOUR * 24;
|
|
8
|
+
var WEEK = DAY * 7;
|
|
9
|
+
var MONTH = DAY * (365 / 12); // Approximation
|
|
4
10
|
|
|
5
|
-
|
|
6
|
-
IntlErrorCode["MISSING_MESSAGE"] = "MISSING_MESSAGE";
|
|
7
|
-
IntlErrorCode["MISSING_FORMAT"] = "MISSING_FORMAT";
|
|
8
|
-
IntlErrorCode["INSUFFICIENT_PATH"] = "INSUFFICIENT_PATH";
|
|
9
|
-
IntlErrorCode["INVALID_MESSAGE"] = "INVALID_MESSAGE";
|
|
10
|
-
IntlErrorCode["INVALID_KEY"] = "INVALID_KEY";
|
|
11
|
-
IntlErrorCode["FORMATTING_ERROR"] = "FORMATTING_ERROR";
|
|
12
|
-
})(IntlErrorCode || (IntlErrorCode = {}));
|
|
11
|
+
var YEAR = DAY * 365;
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
function getRelativeTimeFormatConfig(seconds) {
|
|
14
|
+
var absValue = Math.abs(seconds);
|
|
15
|
+
var value, unit; // We have to round the resulting values, as `Intl.RelativeTimeFormat`
|
|
16
|
+
// will include fractions like '2.1 hours ago'.
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
if (absValue < MINUTE) {
|
|
19
|
+
unit = 'second';
|
|
20
|
+
value = Math.round(seconds);
|
|
21
|
+
} else if (absValue < HOUR) {
|
|
22
|
+
unit = 'minute';
|
|
23
|
+
value = Math.round(seconds / MINUTE);
|
|
24
|
+
} else if (absValue < DAY) {
|
|
25
|
+
unit = 'hour';
|
|
26
|
+
value = Math.round(seconds / HOUR);
|
|
27
|
+
} else if (absValue < WEEK) {
|
|
28
|
+
unit = 'day';
|
|
29
|
+
value = Math.round(seconds / DAY);
|
|
30
|
+
} else if (absValue < MONTH) {
|
|
31
|
+
unit = 'week';
|
|
32
|
+
value = Math.round(seconds / WEEK);
|
|
33
|
+
} else if (absValue < YEAR) {
|
|
34
|
+
unit = 'month';
|
|
35
|
+
value = Math.round(seconds / MONTH);
|
|
36
|
+
} else {
|
|
37
|
+
unit = 'year';
|
|
38
|
+
value = Math.round(seconds / YEAR);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
value: value,
|
|
43
|
+
unit: unit
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function createIntl(_ref) {
|
|
48
|
+
var formats = _ref.formats,
|
|
49
|
+
locale = _ref.locale,
|
|
50
|
+
globalNow = _ref.now,
|
|
51
|
+
_ref$onError = _ref.onError,
|
|
52
|
+
onError = _ref$onError === void 0 ? defaultOnError : _ref$onError,
|
|
53
|
+
timeZone = _ref.timeZone;
|
|
19
54
|
|
|
20
|
-
|
|
55
|
+
function resolveFormatOrOptions(typeFormats, formatOrOptions) {
|
|
56
|
+
var options;
|
|
21
57
|
|
|
22
|
-
if (
|
|
23
|
-
|
|
58
|
+
if (typeof formatOrOptions === 'string') {
|
|
59
|
+
var formatName = formatOrOptions;
|
|
60
|
+
options = typeFormats == null ? void 0 : typeFormats[formatName];
|
|
61
|
+
|
|
62
|
+
if (!options) {
|
|
63
|
+
var error = new IntlError(IntlErrorCode.MISSING_FORMAT, process.env.NODE_ENV !== 'production' ? "Format `" + formatName + "` is not available. You can configure it on the provider or provide custom options." : undefined);
|
|
64
|
+
onError(error);
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
options = formatOrOptions;
|
|
24
69
|
}
|
|
25
70
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
71
|
+
return options;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function getFormattedValue(value, formatOrOptions, typeFormats, formatter) {
|
|
75
|
+
var options;
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
options = resolveFormatOrOptions(typeFormats, formatOrOptions);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
return String(value);
|
|
81
|
+
}
|
|
30
82
|
|
|
31
|
-
|
|
32
|
-
|
|
83
|
+
try {
|
|
84
|
+
return formatter(options);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
onError(new IntlError(IntlErrorCode.FORMATTING_ERROR, error.message));
|
|
87
|
+
return String(value);
|
|
33
88
|
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function formatDateTime(
|
|
92
|
+
/** If a number is supplied, this is interpreted as a UTC timestamp. */
|
|
93
|
+
value,
|
|
94
|
+
/** If a time zone is supplied, the `value` is converted to that time zone.
|
|
95
|
+
* Otherwise the user time zone will be used. */
|
|
96
|
+
formatOrOptions) {
|
|
97
|
+
return getFormattedValue(value, formatOrOptions, formats == null ? void 0 : formats.dateTime, function (options) {
|
|
98
|
+
var _options;
|
|
34
99
|
|
|
35
|
-
|
|
100
|
+
if (timeZone && !((_options = options) != null && _options.timeZone)) {
|
|
101
|
+
options = _extends({}, options, {
|
|
102
|
+
timeZone: timeZone
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return new Intl.DateTimeFormat(locale, options).format(value);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function formatNumber(value, formatOrOptions) {
|
|
111
|
+
return getFormattedValue(value, formatOrOptions, formats == null ? void 0 : formats.number, function (options) {
|
|
112
|
+
return new Intl.NumberFormat(locale, options).format(value);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function formatRelativeTime(
|
|
117
|
+
/** The date time that needs to be formatted. */
|
|
118
|
+
date,
|
|
119
|
+
/** The reference point in time to which `date` will be formatted in relation to. */
|
|
120
|
+
now) {
|
|
121
|
+
try {
|
|
122
|
+
if (!now) {
|
|
123
|
+
if (globalNow) {
|
|
124
|
+
now = globalNow;
|
|
125
|
+
} else {
|
|
126
|
+
throw new Error(process.env.NODE_ENV !== 'production' ? "The `now` parameter wasn't provided to `formatRelativeTime` and there was no global fallback configured on the provider." : undefined);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
var dateDate = date instanceof Date ? date : new Date(date);
|
|
131
|
+
var nowDate = now instanceof Date ? now : new Date(now);
|
|
132
|
+
var seconds = (dateDate.getTime() - nowDate.getTime()) / 1000;
|
|
133
|
+
|
|
134
|
+
var _getRelativeTimeForma = getRelativeTimeFormatConfig(seconds),
|
|
135
|
+
unit = _getRelativeTimeForma.unit,
|
|
136
|
+
value = _getRelativeTimeForma.value;
|
|
137
|
+
|
|
138
|
+
return new Intl.RelativeTimeFormat(locale, {
|
|
139
|
+
numeric: 'auto'
|
|
140
|
+
}).format(value, unit);
|
|
141
|
+
} catch (error) {
|
|
142
|
+
onError(new IntlError(IntlErrorCode.FORMATTING_ERROR, error.message));
|
|
143
|
+
return String(date);
|
|
144
|
+
}
|
|
36
145
|
}
|
|
37
146
|
|
|
38
|
-
return
|
|
39
|
-
|
|
147
|
+
return {
|
|
148
|
+
formatDateTime: formatDateTime,
|
|
149
|
+
formatNumber: formatNumber,
|
|
150
|
+
formatRelativeTime: formatRelativeTime
|
|
151
|
+
};
|
|
152
|
+
}
|
|
40
153
|
|
|
41
|
-
export {
|
|
154
|
+
export { createIntl as default };
|
|
42
155
|
//# sourceMappingURL=use-intl.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm.js","sources":["../../src/core/IntlError.tsx"],"sourcesContent":["export enum IntlErrorCode {\n MISSING_MESSAGE = 'MISSING_MESSAGE',\n MISSING_FORMAT = 'MISSING_FORMAT',\n INSUFFICIENT_PATH = 'INSUFFICIENT_PATH',\n INVALID_MESSAGE = 'INVALID_MESSAGE',\n INVALID_KEY = 'INVALID_KEY',\n FORMATTING_ERROR = 'FORMATTING_ERROR'\n}\n\nexport default class IntlError extends Error {\n public readonly code: IntlErrorCode;\n public readonly originalMessage: string | undefined;\n\n constructor(code: IntlErrorCode, originalMessage?: string) {\n let message: string = code;\n if (originalMessage) {\n message += ': ' + originalMessage;\n }\n super(message);\n\n this.code = code;\n if (originalMessage) {\n this.originalMessage = originalMessage;\n }\n }\n}\n"],"names":["IntlErrorCode","IntlError","code","originalMessage","message","Error"],"mappings":";;IAAYA,cAAZ;;AAAA,CAAA,UAAYA,aAAZ,EAAyB;AACvBA,EAAAA,aAAA,CAAA,iBAAA,CAAA,GAAA,iBAAA,CAAA;AACAA,EAAAA,aAAA,CAAA,gBAAA,CAAA,GAAA,gBAAA,CAAA;AACAA,EAAAA,aAAA,CAAA,mBAAA,CAAA,GAAA,mBAAA,CAAA;AACAA,EAAAA,aAAA,CAAA,iBAAA,CAAA,GAAA,iBAAA,CAAA;AACAA,EAAAA,aAAA,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;AACAA,EAAAA,aAAA,CAAA,kBAAA,CAAA,GAAA,kBAAA,CAAA;AACD,CAPD,EAAYA,aAAa,KAAbA,aAAa,GAOxB,EAPwB,CAAzB,CAAA,CAAA;;IASqBC;;;AAInB,EAAYC,SAAAA,SAAAA,CAAAA,IAAZ,EAAiCC,eAAjC,EAAyD;AAAA,IAAA,IAAA,KAAA,CAAA;;AACvD,IAAIC,IAAAA,OAAO,GAAWF,IAAtB,CAAA;;AACA,IAAA,IAAIC,eAAJ,EAAqB;AACnBC,MAAAA,OAAO,IAAI,IAAA,GAAOD,eAAlB,CAAA;AACD,KAAA;;AACD,IAAA,KAAA,GAAA,MAAA,CAAA,IAAA,CAAA,IAAA,EAAMC,OAAN,CAAA,IAAA,IAAA,CAAA;AALuD,IAAA,KAAA,CAHzCF,IAGyC,GAAA,KAAA,CAAA,CAAA;AAAA,IAAA,KAAA,CAFzCC,eAEyC,GAAA,KAAA,CAAA,CAAA;AAOvD,IAAKD,KAAAA,CAAAA,IAAL,GAAYA,IAAZ,CAAA;;AACA,IAAA,IAAIC,eAAJ,EAAqB;AACnB,MAAKA,KAAAA,CAAAA,eAAL,GAAuBA,eAAvB,CAAA;AACD,KAAA;;AAVsD,IAAA,OAAA,KAAA,CAAA;AAWxD,GAAA;;;iCAfoCE;;;;"}
|
|
1
|
+
{"version":3,"file":"use-intl.esm.js","sources":["../../src/core/createIntl.tsx"],"sourcesContent":["import DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport NumberFormatOptions from './NumberFormatOptions';\nimport {defaultOnError} from './defaults';\n\nconst MINUTE = 60;\nconst HOUR = MINUTE * 60;\nconst DAY = HOUR * 24;\nconst WEEK = DAY * 7;\nconst MONTH = DAY * (365 / 12); // Approximation\nconst YEAR = DAY * 365;\n\nfunction getRelativeTimeFormatConfig(seconds: number) {\n const absValue = Math.abs(seconds);\n let value, unit: Intl.RelativeTimeFormatUnit;\n\n // We have to round the resulting values, as `Intl.RelativeTimeFormat`\n // will include fractions like '2.1 hours ago'.\n\n if (absValue < MINUTE) {\n unit = 'second';\n value = Math.round(seconds);\n } else if (absValue < HOUR) {\n unit = 'minute';\n value = Math.round(seconds / MINUTE);\n } else if (absValue < DAY) {\n unit = 'hour';\n value = Math.round(seconds / HOUR);\n } else if (absValue < WEEK) {\n unit = 'day';\n value = Math.round(seconds / DAY);\n } else if (absValue < MONTH) {\n unit = 'week';\n value = Math.round(seconds / WEEK);\n } else if (absValue < YEAR) {\n unit = 'month';\n value = Math.round(seconds / MONTH);\n } else {\n unit = 'year';\n value = Math.round(seconds / YEAR);\n }\n\n return {value, unit};\n}\n\ntype Props = {\n locale: string;\n timeZone?: string;\n onError?(error: IntlError): void;\n formats?: Partial<Formats>;\n now?: Date;\n};\n\nexport default function createIntl({\n formats,\n locale,\n now: globalNow,\n onError = defaultOnError,\n timeZone\n}: Props) {\n function resolveFormatOrOptions<Options>(\n typeFormats: Record<string, Options> | undefined,\n formatOrOptions?: string | Options\n ) {\n let options;\n if (typeof formatOrOptions === 'string') {\n const formatName = formatOrOptions;\n options = typeFormats?.[formatName];\n\n if (!options) {\n const error = new IntlError(\n IntlErrorCode.MISSING_FORMAT,\n process.env.NODE_ENV !== 'production'\n ? `Format \\`${formatName}\\` is not available. You can configure it on the provider or provide custom options.`\n : undefined\n );\n onError(error);\n throw error;\n }\n } else {\n options = formatOrOptions;\n }\n\n return options;\n }\n\n function getFormattedValue<Value, Options>(\n value: Value,\n formatOrOptions: string | Options | undefined,\n typeFormats: Record<string, Options> | undefined,\n formatter: (options?: Options) => string\n ) {\n let options;\n try {\n options = resolveFormatOrOptions(typeFormats, formatOrOptions);\n } catch (error) {\n return String(value);\n }\n\n try {\n return formatter(options);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(value);\n }\n }\n\n function formatDateTime(\n /** If a number is supplied, this is interpreted as a UTC timestamp. */\n value: Date | number,\n /** If a time zone is supplied, the `value` is converted to that time zone.\n * Otherwise the user time zone will be used. */\n formatOrOptions?: string | DateTimeFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.dateTime,\n (options) => {\n if (timeZone && !options?.timeZone) {\n options = {...options, timeZone};\n }\n\n return new Intl.DateTimeFormat(locale, options).format(value);\n }\n );\n }\n\n function formatNumber(\n value: number,\n formatOrOptions?: string | NumberFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.number,\n (options) => new Intl.NumberFormat(locale, options).format(value)\n );\n }\n\n function formatRelativeTime(\n /** The date time that needs to be formatted. */\n date: number | Date,\n /** The reference point in time to which `date` will be formatted in relation to. */\n now?: number | Date\n ) {\n try {\n if (!now) {\n if (globalNow) {\n now = globalNow;\n } else {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `The \\`now\\` parameter wasn't provided to \\`formatRelativeTime\\` and there was no global fallback configured on the provider.`\n : undefined\n );\n }\n }\n\n const dateDate = date instanceof Date ? date : new Date(date);\n const nowDate = now instanceof Date ? now : new Date(now);\n\n const seconds = (dateDate.getTime() - nowDate.getTime()) / 1000;\n const {unit, value} = getRelativeTimeFormatConfig(seconds);\n\n return new Intl.RelativeTimeFormat(locale, {\n numeric: 'auto'\n }).format(value, unit);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(date);\n }\n }\n\n return {formatDateTime, formatNumber, formatRelativeTime};\n}\n"],"names":["MINUTE","HOUR","DAY","WEEK","MONTH","YEAR","getRelativeTimeFormatConfig","seconds","absValue","Math","abs","value","unit","round","createIntl","formats","locale","globalNow","now","onError","defaultOnError","timeZone","resolveFormatOrOptions","typeFormats","formatOrOptions","options","formatName","error","IntlError","IntlErrorCode","MISSING_FORMAT","process","env","NODE_ENV","undefined","getFormattedValue","formatter","String","FORMATTING_ERROR","message","formatDateTime","dateTime","Intl","DateTimeFormat","format","formatNumber","number","NumberFormat","formatRelativeTime","date","Error","dateDate","Date","nowDate","getTime","RelativeTimeFormat","numeric"],"mappings":";;;;AAMA,IAAMA,MA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