@uxf/localize 10.0.0-beta.44 → 10.0.0-beta.65

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.
Files changed (2) hide show
  1. package/README.md +29 -17
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -34,6 +34,10 @@ export const {
34
34
  useFormatMoney,
35
35
  useFormatNumber,
36
36
  useFormatPercentage,
37
+ FormatDateTime,
38
+ FormatNumber,
39
+ FormatMoney,
40
+ FormatPercentage,
37
41
  } = createLocale({ cs, en });
38
42
  ```
39
43
 
@@ -42,7 +46,7 @@ export const {
42
46
  ```ts
43
47
  import {DateTimes, LocalizeConfig} from "@uxf/localize";
44
48
 
45
- const en: LocalizeConfig = {
49
+ const en: LocalizeConfig<DateTimes> = {
46
50
  number: {
47
51
  thousandsSeparator: ",",
48
52
  decimalSeparator: ".",
@@ -103,49 +107,57 @@ const cs: LocalizeConfig<DateTimes> = {
103
107
 
104
108
  ## Format number
105
109
  ```tsx
106
- const { useFormatNumber } from "./localize";
110
+ const { useFormatNumber, FormatNumber } from "./localize";
107
111
 
108
112
  const formatNumber = useFormatNumber();
109
113
 
110
114
  formatNumber(1000.23); // 1 000
111
115
  formatNumber(1000.23, { precision: 2 }); // 1 000,23
116
+
117
+ <FormatNumber value={1000.23}/>
112
118
  ```
113
119
 
114
120
  ## Format datetime
115
121
  ```tsx
116
- const { useFormatDateTime } from "./localize";
122
+ const { useFormatDateTime, FormatDateTime } from "./localize";
117
123
 
118
124
  const formatDateTime = useFormatDateTime();
119
125
 
120
- formatDateTime(new Date('2000-01-01'), "dateShort") // 1. 1. 20
121
- formatDateTime(new Date('2000-01-01'), "dateTimeMedium") // 1. 1. 2000 00:00
122
- formatDateTime(new Date('2000-01-01'), "timeFull") // 00:00:00
126
+ formatDateTime(new Date('2000-01-01'), "dateShort"); // 1. 1. 20
127
+ formatDateTime(new Date('2000-01-01'), "dateTimeMedium"); // 1. 1. 2000 00:00
128
+ formatDateTime(new Date('2000-01-01'), "timeFull"); // 00:00:00
129
+
130
+ <FormatDateTime value={new Date('2000-01-01')} format="dateShort"/>
123
131
  ```
124
132
 
125
133
  ## Format money
126
134
  ```tsx
127
- const { useFormatMoney } from "./localize";
135
+ const { useFormatMoney, FormatMoney } from "./localize";
128
136
 
129
137
  const formatMoney = useFormatMoney();
130
138
 
131
- formatMoney(1000, "CZK") // 1 000 Kč
132
- formatMoney(1000, "USD") // 1 000 $
133
- formatMoney(1000.23, "CZK", { precision: 1 }) // 1 000,2 Kč
134
- formatMoney(1000.23, "CZK", { preferIsoCode: true }) // 1 000,23 CZK
135
- formatMoney(1000.23, "CZK", { hideSymbol: true }) // 1 000,23
139
+ formatMoney({amount: 1000, currency: "CZK"}); // 1 000 Kč
140
+ formatMoney({amount: 1000, currency: "USD"}); // 1 000 $
141
+ formatMoney({amount: 1000.23, currency: "CZK"}, { precision: 1 }); // 1 000,2 Kč
142
+ formatMoney({amount: 1000.23, currency: "CZK"}, { preferIsoCode: true }); // 1 000,23 CZK
143
+ formatMoney({amount: 1000.23, currency: "CZK"}, { hideSymbol: true }); // 1 000,23
144
+
145
+ <FormatMoney money={{amount: 1000, currency: "CZK"}}/>
136
146
  ```
137
147
 
138
148
  ## Format percentage
139
149
 
140
150
  ```tsx
141
- const { useFormatPercentage } from "./localize";
151
+ const { useFormatPercentage, FormatPercentage } from "./localize";
142
152
 
143
153
  const formatPercentage = useFormatPercentage();
144
154
 
145
- formatPercentage(0.782) // 78,2 %
146
- formatPercentage(0.782, "nearest") // 78,2 %
147
- formatPercentage(0.782, "up") // 78,2 %
148
- formatPercentage(0.782, "down") // 78,2 %
155
+ formatPercentage(0.782); // 78,2 %
156
+ formatPercentage(0.782, "nearest"); // 78,2 %
157
+ formatPercentage(0.782, "up"); // 78,2 %
158
+ formatPercentage(0.782, "down"); // 78,2 %
159
+
160
+ <FormatPercentage value={0.782} roundingType="up" />
149
161
  ```
150
162
 
151
163
  ## Format another locale
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/localize",
3
- "version": "10.0.0-beta.44",
3
+ "version": "10.0.0-beta.65",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {