@etsoo/react 1.2.5 → 1.2.6
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/lib/components/GridColumn.js +1 -0
- package/lib/mu/DataGridRenderers.js +5 -7
- package/lib/mu/texts/DateText.js +1 -1
- package/lib/mu/texts/MoneyText.d.ts +4 -0
- package/lib/mu/texts/MoneyText.js +3 -13
- package/lib/mu/texts/NumberText.d.ts +1 -1
- package/lib/mu/texts/NumberText.js +3 -6
- package/package.json +3 -3
- package/src/components/GridColumn.ts +1 -0
- package/src/mu/DataGridRenderers.tsx +10 -7
- package/src/mu/texts/DateText.tsx +1 -1
- package/src/mu/texts/MoneyText.tsx +21 -16
- package/src/mu/texts/NumberText.tsx +4 -9
|
@@ -12,6 +12,7 @@ export { GridDataType };
|
|
|
12
12
|
export const GridAlignGet = (align, type) => {
|
|
13
13
|
if (align == null && type != null) {
|
|
14
14
|
if (type === GridDataType.Money ||
|
|
15
|
+
type === GridDataType.IntMoney ||
|
|
15
16
|
type === GridDataType.Int ||
|
|
16
17
|
type === GridDataType.Number)
|
|
17
18
|
return 'right';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CircularProgress } from '@mui/material';
|
|
3
3
|
import { GridDataType } from '../components/GridColumn';
|
|
4
|
-
import { DateUtils } from '@etsoo/shared';
|
|
4
|
+
import { DateUtils, NumberUtils } from '@etsoo/shared';
|
|
5
5
|
import CheckIcon from '@mui/icons-material/Check';
|
|
6
6
|
import ClearIcon from '@mui/icons-material/Clear';
|
|
7
7
|
/**
|
|
@@ -32,16 +32,14 @@ export var DataGridRenderers;
|
|
|
32
32
|
return undefined;
|
|
33
33
|
// For date time
|
|
34
34
|
if (value instanceof Date) {
|
|
35
|
-
return DateUtils.format(navigator.language,
|
|
35
|
+
return DateUtils.format(value, navigator.language, type === GridDataType.DateTime ? 'ds' : 'd');
|
|
36
36
|
}
|
|
37
37
|
// For numbers
|
|
38
38
|
if (typeof value === 'number') {
|
|
39
|
-
if (type === GridDataType.Money)
|
|
40
|
-
return
|
|
41
|
-
minimumFractionDigits: 2
|
|
42
|
-
}).format(value);
|
|
39
|
+
if (type === GridDataType.Money || type === GridDataType.IntMoney)
|
|
40
|
+
return NumberUtils.formatMoney(value, undefined, undefined, type === GridDataType.IntMoney);
|
|
43
41
|
else
|
|
44
|
-
return
|
|
42
|
+
return NumberUtils.format(value);
|
|
45
43
|
}
|
|
46
44
|
// For boolean
|
|
47
45
|
if (typeof value === 'boolean') {
|
package/lib/mu/texts/DateText.js
CHANGED
|
@@ -12,7 +12,7 @@ export function DateText(props) {
|
|
|
12
12
|
// Formatted value
|
|
13
13
|
const localValue = value == null
|
|
14
14
|
? undefined
|
|
15
|
-
: DateUtils.format(
|
|
15
|
+
: DateUtils.format(value, locale, options, timeZone);
|
|
16
16
|
// Layout
|
|
17
17
|
return (React.createElement(Typography, { noWrap: true, ...rest }, localValue));
|
|
18
18
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NumberUtils } from '@etsoo/shared';
|
|
1
2
|
import { Typography } from '@mui/material';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
/**
|
|
@@ -6,19 +7,8 @@ import React from 'react';
|
|
|
6
7
|
* @returns Component
|
|
7
8
|
*/
|
|
8
9
|
export function MoneyText(props) {
|
|
9
|
-
var _a, _b;
|
|
10
10
|
// Destruct
|
|
11
|
-
const { currency,
|
|
12
|
-
// Default
|
|
13
|
-
if (currency) {
|
|
14
|
-
(_a = options.style) !== null && _a !== void 0 ? _a : (options.style = 'currency');
|
|
15
|
-
options.currency = currency;
|
|
16
|
-
}
|
|
17
|
-
(_b = options.minimumFractionDigits) !== null && _b !== void 0 ? _b : (options.minimumFractionDigits = 2);
|
|
18
|
-
// Formatter
|
|
19
|
-
const intl = new Intl.NumberFormat(locale, options);
|
|
20
|
-
// Formatted value
|
|
21
|
-
const localValue = value == null ? undefined : intl.format(value);
|
|
11
|
+
const { currency, isInteger = false, locale, options = {}, value, ...rest } = props;
|
|
22
12
|
// Layout
|
|
23
|
-
return (React.createElement(Typography, { noWrap: true, ...rest },
|
|
13
|
+
return (React.createElement(Typography, { noWrap: true, ...rest }, NumberUtils.formatMoney(value, currency, locale, isInteger, options)));
|
|
24
14
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NumberUtils } from '@etsoo/shared';
|
|
1
2
|
import { Typography } from '@mui/material';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
/**
|
|
@@ -7,11 +8,7 @@ import React from 'react';
|
|
|
7
8
|
*/
|
|
8
9
|
export function NumberText(props) {
|
|
9
10
|
// Destruct
|
|
10
|
-
const { locale
|
|
11
|
-
// Formatter
|
|
12
|
-
const intl = new Intl.NumberFormat(locale, options);
|
|
13
|
-
// Formatted value
|
|
14
|
-
const localValue = value == null ? undefined : intl.format(value);
|
|
11
|
+
const { locale, options = {}, value, ...rest } = props;
|
|
15
12
|
// Layout
|
|
16
|
-
return (React.createElement(Typography, { noWrap: true, ...rest },
|
|
13
|
+
return (React.createElement(Typography, { noWrap: true, ...rest }, NumberUtils.format(value, locale, options)));
|
|
17
14
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "TypeScript ReactJs framework",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"@emotion/react": "^11.4.1",
|
|
45
45
|
"@emotion/style": "^0.8.0",
|
|
46
46
|
"@emotion/styled": "^11.3.0",
|
|
47
|
-
"@etsoo/appscript": "^1.0.
|
|
47
|
+
"@etsoo/appscript": "^1.0.96",
|
|
48
48
|
"@etsoo/notificationbase": "^1.0.78",
|
|
49
|
-
"@etsoo/shared": "^1.0.
|
|
49
|
+
"@etsoo/shared": "^1.0.44",
|
|
50
50
|
"@mui/icons-material": "^5.0.1",
|
|
51
51
|
"@mui/material": "^5.0.2",
|
|
52
52
|
"@reach/router": "^1.3.4",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CircularProgress } from '@mui/material';
|
|
3
3
|
import { GridCellRendererProps, GridDataType } from '../components/GridColumn';
|
|
4
|
-
import { DateUtils } from '@etsoo/shared';
|
|
4
|
+
import { DateUtils, NumberUtils } from '@etsoo/shared';
|
|
5
5
|
import CheckIcon from '@mui/icons-material/Check';
|
|
6
6
|
import ClearIcon from '@mui/icons-material/Clear';
|
|
7
7
|
import { DataGridExFooterItemRendererProps } from './DataGridEx';
|
|
@@ -42,19 +42,22 @@ export namespace DataGridRenderers {
|
|
|
42
42
|
// For date time
|
|
43
43
|
if (value instanceof Date) {
|
|
44
44
|
return DateUtils.format(
|
|
45
|
-
navigator.language,
|
|
46
45
|
value,
|
|
46
|
+
navigator.language,
|
|
47
47
|
type === GridDataType.DateTime ? 'ds' : 'd'
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
// For numbers
|
|
52
52
|
if (typeof value === 'number') {
|
|
53
|
-
if (type === GridDataType.Money)
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
if (type === GridDataType.Money || type === GridDataType.IntMoney)
|
|
54
|
+
return NumberUtils.formatMoney(
|
|
55
|
+
value,
|
|
56
|
+
undefined,
|
|
57
|
+
undefined,
|
|
58
|
+
type === GridDataType.IntMoney
|
|
59
|
+
);
|
|
60
|
+
else return NumberUtils.format(value);
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
// For boolean
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NumberUtils } from '@etsoo/shared';
|
|
1
2
|
import { Typography } from '@mui/material';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { NumberTextProps } from './NumberText';
|
|
@@ -10,6 +11,11 @@ export interface MoneyTextProps extends NumberTextProps {
|
|
|
10
11
|
* Currency, USD for US dollar
|
|
11
12
|
*/
|
|
12
13
|
currency?: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Is integer number
|
|
17
|
+
*/
|
|
18
|
+
isInteger?: boolean;
|
|
13
19
|
}
|
|
14
20
|
|
|
15
21
|
/**
|
|
@@ -19,26 +25,25 @@ export interface MoneyTextProps extends NumberTextProps {
|
|
|
19
25
|
*/
|
|
20
26
|
export function MoneyText(props: MoneyTextProps) {
|
|
21
27
|
// Destruct
|
|
22
|
-
const {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
options
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
options.minimumFractionDigits ??= 2;
|
|
31
|
-
|
|
32
|
-
// Formatter
|
|
33
|
-
const intl = new Intl.NumberFormat(locale, options);
|
|
34
|
-
|
|
35
|
-
// Formatted value
|
|
36
|
-
const localValue = value == null ? undefined : intl.format(value);
|
|
28
|
+
const {
|
|
29
|
+
currency,
|
|
30
|
+
isInteger = false,
|
|
31
|
+
locale,
|
|
32
|
+
options = {},
|
|
33
|
+
value,
|
|
34
|
+
...rest
|
|
35
|
+
} = props;
|
|
37
36
|
|
|
38
37
|
// Layout
|
|
39
38
|
return (
|
|
40
39
|
<Typography noWrap {...rest}>
|
|
41
|
-
{
|
|
40
|
+
{NumberUtils.formatMoney(
|
|
41
|
+
value,
|
|
42
|
+
currency,
|
|
43
|
+
locale,
|
|
44
|
+
isInteger,
|
|
45
|
+
options
|
|
46
|
+
)}
|
|
42
47
|
</Typography>
|
|
43
48
|
);
|
|
44
49
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NumberUtils } from '@etsoo/shared';
|
|
1
2
|
import { Typography, TypographyProps } from '@mui/material';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
|
|
@@ -8,7 +9,7 @@ export interface NumberTextProps extends TypographyProps {
|
|
|
8
9
|
/**
|
|
9
10
|
* Locale
|
|
10
11
|
*/
|
|
11
|
-
locale?: string;
|
|
12
|
+
locale?: string | string[];
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Options
|
|
@@ -28,18 +29,12 @@ export interface NumberTextProps extends TypographyProps {
|
|
|
28
29
|
*/
|
|
29
30
|
export function NumberText(props: NumberTextProps) {
|
|
30
31
|
// Destruct
|
|
31
|
-
const { locale
|
|
32
|
-
|
|
33
|
-
// Formatter
|
|
34
|
-
const intl = new Intl.NumberFormat(locale, options);
|
|
35
|
-
|
|
36
|
-
// Formatted value
|
|
37
|
-
const localValue = value == null ? undefined : intl.format(value);
|
|
32
|
+
const { locale, options = {}, value, ...rest } = props;
|
|
38
33
|
|
|
39
34
|
// Layout
|
|
40
35
|
return (
|
|
41
36
|
<Typography noWrap {...rest}>
|
|
42
|
-
{
|
|
37
|
+
{NumberUtils.format(value, locale, options)}
|
|
43
38
|
</Typography>
|
|
44
39
|
);
|
|
45
40
|
}
|